Skip to content

Commit 4e56ec7

Browse files
committed
Rename redeem to unmint
1 parent 29f1a3c commit 4e56ec7

File tree

9 files changed

+46
-46
lines changed

9 files changed

+46
-46
lines changed

test/functional/test_framework/wallet_cli_controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ async def issue_new_token(self,
189189
async def mint_tokens(self, token_id: str, address: str, amount: int) -> str:
190190
return await self._write_command(f"minttokens {token_id} {address} {amount}\n")
191191

192-
async def redeem_tokens(self, token_id: str, amount: int) -> str:
193-
return await self._write_command(f"redeemtokens {token_id} {amount}\n")
192+
async def unmint_tokens(self, token_id: str, amount: int) -> str:
193+
return await self._write_command(f"unminttokens {token_id} {amount}\n")
194194

195195
async def lock_tokens(self, token_id: str) -> str:
196196
return await self._write_command(f"locktokens {token_id}\n")

test/functional/wallet_tokens_change_supply.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* check balance
2525
* issue new token
2626
* mint new tokens
27-
* redeem existing tokens
27+
* unmint existing tokens
2828
* lock the tokens supply
2929
"""
3030

@@ -155,11 +155,11 @@ async def async_test(self):
155155
assert_in(f"{token_id} amount: {total_tokens_supply}", await wallet.get_balance())
156156

157157
# cannot unmint more than minted
158-
assert_in(f"Trying to redeem Amount {{ val: {tokens_to_mint+1}00 }} but the current supply is Amount {{ val: {tokens_to_mint}00 }}", await wallet.redeem_tokens(token_id, tokens_to_mint + 1))
158+
assert_in(f"Trying to unmint Amount {{ val: {tokens_to_mint+1}00 }} but the current supply is Amount {{ val: {tokens_to_mint}00 }}", await wallet.unmint_tokens(token_id, tokens_to_mint + 1))
159159

160-
tokens_to_redeem = 1000
161-
total_tokens_supply = total_tokens_supply - tokens_to_redeem
162-
assert_in("The transaction was submitted successfully", await wallet.redeem_tokens(token_id, tokens_to_redeem))
160+
tokens_to_unmint = 1000
161+
total_tokens_supply = total_tokens_supply - tokens_to_unmint
162+
assert_in("The transaction was submitted successfully", await wallet.unmint_tokens(token_id, tokens_to_unmint))
163163

164164
self.generate_block()
165165
assert_in("Success", await wallet.sync())
@@ -182,7 +182,7 @@ async def async_test(self):
182182

183183
# cannot mint any more tokens as it is locked
184184
assert_in("Cannot change a Locked Token supply", await wallet.mint_tokens(token_id, address, tokens_to_mint))
185-
assert_in("Cannot change a Locked Token supply", await wallet.redeem_tokens(token_id, tokens_to_mint))
185+
assert_in("Cannot change a Locked Token supply", await wallet.unmint_tokens(token_id, tokens_to_mint))
186186
assert_in("Cannot lock Token supply in state: Locked", await wallet.lock_tokens(token_id))
187187

188188

wallet/src/account/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::key_chain::{make_path_to_vrf_key, AccountKeyChain, KeyChainError};
3434
use crate::send_request::{
3535
get_tx_output_destination, make_address_output, make_address_output_from_delegation,
3636
make_address_output_token, make_decomission_stake_pool_output, make_lock_token_outputs,
37-
make_mint_token_outputs, make_redeem_token_outputs, make_stake_output, IssueNftArguments,
37+
make_mint_token_outputs, make_stake_output, make_unmint_token_outputs, IssueNftArguments,
3838
StakePoolDataArguments,
3939
};
4040
use crate::wallet_events::{WalletEvents, WalletEventsNoOp};
@@ -742,18 +742,18 @@ impl Account {
742742
)
743743
}
744744

745-
pub fn redeem_tokens(
745+
pub fn unmint_tokens(
746746
&mut self,
747747
db_tx: &mut impl WalletStorageWriteUnlocked,
748748
token_id: TokenId,
749749
amount: Amount,
750750
median_time: BlockTimestamp,
751751
fee_rate: CurrentFeeRate,
752752
) -> WalletResult<SignedTransaction> {
753-
let outputs = make_redeem_token_outputs(token_id, amount, self.chain_config.as_ref())?;
753+
let outputs = make_unmint_token_outputs(token_id, amount, self.chain_config.as_ref())?;
754754

755755
let token_data = self.find_token(&token_id)?;
756-
token_data.total_supply.check_can_redeem(amount)?;
756+
token_data.total_supply.check_can_unmint(amount)?;
757757

758758
let nonce = token_data
759759
.last_nonce

wallet/src/account/output_cache/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ impl TokenTotalSupplyState {
122122
}
123123
}
124124

125-
pub fn check_can_redeem(&self, amount: Amount) -> WalletResult<()> {
125+
pub fn check_can_unmint(&self, amount: Amount) -> WalletResult<()> {
126126
match self {
127127
Self::Unlimited(current) | Self::Lockable(current) | Self::Fixed(_, current) => {
128128
ensure!(
129129
*current >= amount,
130-
WalletError::CannotRedeemTokenSupply(amount, *current)
130+
WalletError::CannotUnmintTokenSupply(amount, *current)
131131
);
132132
Ok(())
133133
}
@@ -175,20 +175,20 @@ impl TokenTotalSupplyState {
175175
}
176176
}
177177

178-
fn redeem(&self, amount: Amount) -> WalletResult<TokenTotalSupplyState> {
178+
fn unmint(&self, amount: Amount) -> WalletResult<TokenTotalSupplyState> {
179179
match self {
180180
TokenTotalSupplyState::Lockable(current) => Ok(TokenTotalSupplyState::Lockable(
181181
(*current - amount)
182-
.ok_or(WalletError::CannotRedeemTokenSupply(amount, *current))?,
182+
.ok_or(WalletError::CannotUnmintTokenSupply(amount, *current))?,
183183
)),
184184
TokenTotalSupplyState::Unlimited(current) => Ok(TokenTotalSupplyState::Unlimited(
185185
(*current - amount)
186-
.ok_or(WalletError::CannotRedeemTokenSupply(amount, *current))?,
186+
.ok_or(WalletError::CannotUnmintTokenSupply(amount, *current))?,
187187
)),
188188
TokenTotalSupplyState::Fixed(max, current) => Ok(TokenTotalSupplyState::Fixed(
189189
*max,
190190
(*current - amount)
191-
.ok_or(WalletError::CannotRedeemTokenSupply(amount, *current))?,
191+
.ok_or(WalletError::CannotUnmintTokenSupply(amount, *current))?,
192192
)),
193193
TokenTotalSupplyState::Locked(_) => Err(WalletError::CannotChangeLockedTokenSupply),
194194
}
@@ -503,7 +503,7 @@ impl OutputCache {
503503
tx_id,
504504
)?;
505505
let amount = sum_burned_token_amount(tx.outputs(), token_id)?;
506-
data.total_supply = data.total_supply.redeem(amount)?;
506+
data.total_supply = data.total_supply.unmint(amount)?;
507507
}
508508
}
509509
AccountSpending::TokenSupplyLock(token_id) => {
@@ -610,7 +610,7 @@ impl OutputCache {
610610
data.last_nonce = outpoint.nonce().decrement();
611611
data.last_parent =
612612
find_parent(&self.unconfirmed_descendants, tx_id.clone());
613-
data.total_supply = data.total_supply.redeem(*amount)?;
613+
data.total_supply = data.total_supply.unmint(*amount)?;
614614
}
615615
}
616616
AccountSpending::TokenCirculatingSupply(token_id) => {
@@ -811,7 +811,7 @@ impl OutputCache {
811811
tx_id.into(),
812812
);
813813
data.total_supply =
814-
data.total_supply.redeem(*amount)?;
814+
data.total_supply.unmint(*amount)?;
815815
}
816816
}
817817
AccountSpending::TokenCirculatingSupply(token_id) => {

wallet/src/send_request/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn make_mint_token_outputs(
101101
Ok(vec![mint_output, token_change_supply_fee])
102102
}
103103

104-
pub fn make_redeem_token_outputs(
104+
pub fn make_unmint_token_outputs(
105105
token_id: TokenId,
106106
amount: Amount,
107107
chain_config: &ChainConfig,

wallet/src/wallet/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ pub enum WalletError {
151151
"Cannot mint Token over the fixed supply {0:?}, current supply {1:?} trying to mint {2:?}"
152152
)]
153153
CannotMintFixedTokenSupply(Amount, Amount, Amount),
154-
#[error("Trying to redeem {0:?} but the current supply is {1:?}")]
155-
CannotRedeemTokenSupply(Amount, Amount),
154+
#[error("Trying to unmint {0:?} but the current supply is {1:?}")]
155+
CannotUnmintTokenSupply(Amount, Amount),
156156
}
157157

158158
/// Result type used for the wallet
@@ -828,7 +828,7 @@ impl<B: storage::Backend> Wallet<B> {
828828
})
829829
}
830830

831-
pub fn redeem_tokens(
831+
pub fn unmint_tokens(
832832
&mut self,
833833
account_index: U31,
834834
token_id: TokenId,
@@ -838,7 +838,7 @@ impl<B: storage::Backend> Wallet<B> {
838838
) -> WalletResult<SignedTransaction> {
839839
let latest_median_time = self.latest_median_time;
840840
self.for_account_rw_unlocked(account_index, |account, db_tx| {
841-
account.redeem_tokens(
841+
account.unmint_tokens(
842842
db_tx,
843843
token_id,
844844
amount,

wallet/src/wallet/tests.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,36 +2471,36 @@ fn change_and_lock_token_supply(#[case] seed: Seed) {
24712471
token_amount_to_mint,
24722472
);
24732473

2474-
// Try to redeem more than the current total supply
2475-
let token_amount_to_redeem = (token_amount_to_mint + Amount::from_atoms(1)).unwrap();
2474+
// Try to unmint more than the current total supply
2475+
let token_amount_to_unmint = (token_amount_to_mint + Amount::from_atoms(1)).unwrap();
24762476
let err = wallet
2477-
.redeem_tokens(
2477+
.unmint_tokens(
24782478
DEFAULT_ACCOUNT_INDEX,
24792479
issued_token_id,
2480-
token_amount_to_redeem,
2480+
token_amount_to_unmint,
24812481
FeeRate::new(Amount::ZERO),
24822482
FeeRate::new(Amount::ZERO),
24832483
)
24842484
.unwrap_err();
24852485
assert_eq!(
24862486
err,
2487-
WalletError::CannotRedeemTokenSupply(token_amount_to_redeem, token_amount_to_mint)
2487+
WalletError::CannotUnmintTokenSupply(token_amount_to_unmint, token_amount_to_mint)
24882488
);
24892489

2490-
let token_amount_to_redeem =
2490+
let token_amount_to_unmint =
24912491
Amount::from_atoms(rng.gen_range(1..token_amount_to_mint.into_atoms()));
2492-
let redeem_transaction = wallet
2493-
.redeem_tokens(
2492+
let unmint_transaction = wallet
2493+
.unmint_tokens(
24942494
DEFAULT_ACCOUNT_INDEX,
24952495
issued_token_id,
2496-
token_amount_to_redeem,
2496+
token_amount_to_unmint,
24972497
FeeRate::new(Amount::ZERO),
24982498
FeeRate::new(Amount::ZERO),
24992499
)
25002500
.unwrap();
25012501

25022502
let block4 = Block::new(
2503-
vec![redeem_transaction],
2503+
vec![unmint_transaction],
25042504
block1_id.into(),
25052505
block1_timestamp,
25062506
ConsensusData::None,
@@ -2526,7 +2526,7 @@ fn change_and_lock_token_supply(#[case] seed: Seed) {
25262526

25272527
assert_eq!(
25282528
token_issuance_data.total_supply.current_supply(),
2529-
(token_amount_to_mint - token_amount_to_redeem).unwrap(),
2529+
(token_amount_to_mint - token_amount_to_unmint).unwrap(),
25302530
);
25312531
assert!(token_issuance_data.total_supply.check_can_lock().is_ok());
25322532

@@ -2566,7 +2566,7 @@ fn change_and_lock_token_supply(#[case] seed: Seed) {
25662566

25672567
assert_eq!(
25682568
token_issuance_data.total_supply.current_supply(),
2569-
(token_amount_to_mint - token_amount_to_redeem).unwrap(),
2569+
(token_amount_to_mint - token_amount_to_unmint).unwrap(),
25702570
);
25712571

25722572
assert_eq!(
@@ -2586,10 +2586,10 @@ fn change_and_lock_token_supply(#[case] seed: Seed) {
25862586
.unwrap_err();
25872587
assert_eq!(err, WalletError::CannotChangeLockedTokenSupply);
25882588
let err = wallet
2589-
.redeem_tokens(
2589+
.unmint_tokens(
25902590
DEFAULT_ACCOUNT_INDEX,
25912591
issued_token_id,
2592-
token_amount_to_redeem,
2592+
token_amount_to_unmint,
25932593
FeeRate::new(Amount::ZERO),
25942594
FeeRate::new(Amount::ZERO),
25952595
)

wallet/wallet-cli-lib/src/commands/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ pub enum WalletCommand {
213213
amount: String,
214214
},
215215

216-
/// Redeem existing tokens and reduce the total supply
217-
RedeemTokens {
216+
/// Unmint existing tokens and reduce the total supply
217+
UnmintTokens {
218218
token_id: String,
219219
amount: String,
220220
},
@@ -866,7 +866,7 @@ impl CommandHandler {
866866
Ok(Self::tx_submitted_command())
867867
}
868868

869-
WalletCommand::RedeemTokens { token_id, amount } => {
869+
WalletCommand::UnmintTokens { token_id, amount } => {
870870
let token_id = parse_token_id(chain_config, token_id.as_str())?;
871871
let amount = {
872872
let token_number_of_decimals = self
@@ -879,7 +879,7 @@ impl CommandHandler {
879879

880880
self.get_synced_controller()
881881
.await?
882-
.redeem_tokens(token_id, amount)
882+
.unmint_tokens(token_id, amount)
883883
.await
884884
.map_err(WalletCliError::Controller)?;
885885

wallet/wallet-controller/src/synced_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, T: NodeInterface, W: WalletEvents> SyncedController<'a, T, W> {
183183
self.broadcast_to_mempool(tx).await
184184
}
185185

186-
pub async fn redeem_tokens(
186+
pub async fn unmint_tokens(
187187
&mut self,
188188
token_id: TokenId,
189189
amount: Amount,
@@ -193,7 +193,7 @@ impl<'a, T: NodeInterface, W: WalletEvents> SyncedController<'a, T, W> {
193193

194194
let tx = self
195195
.wallet
196-
.redeem_tokens(
196+
.unmint_tokens(
197197
self.account_index,
198198
token_id,
199199
amount,

0 commit comments

Comments
 (0)