Skip to content

Commit

Permalink
feat: implement mintable attribute with irreversible state logic (#26)
Browse files Browse the repository at this point in the history
### Summary of Changes

- **Added `mintable` attribute**:
  - Enables toggling of minting functionality.
  - Once set to `false`, it cannot be changed back to `true`.

- **Updated `JettonSetParameter` logic**:
  - Ensured `mintable` updates respect the irreversible `false` state.

- **Added Tests**:
  - Verified behavior for `mintable` updates.

---------

Co-authored-by: Kyriakos Andreou <[email protected]>
  • Loading branch information
iamIcarus and Kyriakos Andreou authored Jan 3, 2025
1 parent f88f14c commit 6fa2563
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@ This is default Tact blueprint project with default commands:
Invalid transfer amount.</br><i>Occurs when you try to send, burn or mint 0 tokens.</i>
</td>
</tr>
<tr>
<td>6906</td>
<td>
Minting already disabled.</br><i>Occurs when you attempt to enable minting after it has been permanently disabled.</i>
</td>
</tr>
<tr>
<td>6907</td>
<td>
Minting is disabled.</br><i>Occurs when you try to mint tokens while the minting functionality is disabled.</i>
</td>
</tr>
</table>
6 changes: 5 additions & 1 deletion contracts/errors.tact
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ const ERROR_JETTON_INITIALIZED: Int = 6903;
// Jetton max supply exceeded
const ERROR_MAX_SUPPLY_EXCEEDED: Int = 6904;
// Invalid transfer amount (e.g., zero tokens)
const ERROR_CODE_INVALID_AMOUNT: Int = 6905;
const ERROR_CODE_INVALID_AMOUNT: Int = 6905;
// Minting already disabled
const ERROR_CODE_MINTING_ALREADY_DISABLED: Int = 6906;
// Minting is disabled
const ERROR_CODE_MINTING_DISABLED: Int = 6907;
9 changes: 9 additions & 0 deletions contracts/jetton/master.tact
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ contract JettonMaster with TEP74JettonMaster, TEP89JettonDiscoverable, Deployabl
max_supply: Int = 0;
// Current tokens minted
current_supply: Int = 0;
// Is token mintable
mintable: Bool = true;
// Administrator of token. Who can mint new tokens
owner: Address;
// Initial code of jetton wallet
Expand Down Expand Up @@ -59,12 +61,19 @@ contract JettonMaster with TEP74JettonMaster, TEP89JettonDiscoverable, Deployabl

self.max_supply = new_max_supply;
return;
}else if(msg.key == "mintable"){
// Once mintable is set to false, it cannot be changed back to true
nativeThrowIf(ERROR_CODE_MINTING_ALREADY_DISABLED, !self.mintable);

self.mintable = msg.value.loadBool();
return;
}

self.metadata.set(msg.key, msg.value); // Update metadata for other keys
}

receive(msg: JettonMint){
nativeThrowIf(ERROR_CODE_MINTING_DISABLED, !self.mintable); // Reject mint if minting is disabled
nativeThrowUnless(ERROR_CODE_INVALID_AMOUNT, msg.amount > 0); // Reject mint with amount <= 0
self.requireOwner();

Expand Down
Loading

0 comments on commit 6fa2563

Please sign in to comment.