Skip to content

Commit

Permalink
Removed Deployable trait. Added Mermaid diagram. Slightly adjusted de…
Browse files Browse the repository at this point in the history
…ployment in tests
  • Loading branch information
Shvandre committed Dec 6, 2024
1 parent b336ed6 commit 042d004
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,28 @@ Also, additional utils from `sources/utils/` are used in tests and deployment sc

Main smart contract is `jetton_minter.tact`. It imports `messages.tact` and `jetton_wallet.tact`, so they will be compiled automatically, when setting `jetton_minter.tact` as target in `tact.config.json`.
### Traits
Jetton minter is using *OwnableTransferable* and *Deployable* trait. Actually, you can remove *Deployable* trait. It is used only for more convenient deployment in tests.
Jetton minter is using only *OwnableTransferable* which is inherited from *Ownable* trait.

Jetton wallet is using only *Ownable* trait.

**Note: These traits are implemented in stdlib.**

Scheme of inheritance and imports:
```mermaid
graph LR
B[jetton_minter.tact] -->|import| A[messages.tact]
C[jetton_wallet.tact] -->|import| A[messages.tact]
B[jetton_minter.tact] -->|import| C[jetton_wallet.tact]
C[jetton_wallet.tact] -->|uses| E[ownable]
B[jetton_minter.tact] -->|uses| F[ownableTransferable]
F[ownableTransferable] -->|inherits| E[ownable]
class E,F ownableStyle;
classDef ownableStyle stroke-width:2,rx:25,ry:25;
```
You can learn more about traits in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/).

## Best Practices
Expand Down
9 changes: 6 additions & 3 deletions sources/contract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ describe("JettonMinter", () => {
notDeployer = await blockchain.treasury('notDeployer');

defaultContent = beginCell().endCell();
let msg: Deploy = {
$$type: "Deploy",
queryId: 0n,
let msg: TokenUpdateContent = {
$$type: "TokenUpdateContent",
content: defaultContent,
}


jettonMinter = blockchain.openContract(await JettonMinter.fromInit(deployer.address, defaultContent));

//We send Update content to deploy the contract, because it is not automatically deployed after blockchain.openContract
//And to deploy it we should send any message. But update content message with same content does not affect anything. That is why I chose it.
const deployResult = await jettonMinter.send(deployer.getSender(), {value: toNano("0.1")}, msg);

expect(deployResult.transactions).toHaveTransaction({
Expand Down
2 changes: 1 addition & 1 deletion sources/jetton_minter.tact
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct JettonMasterState {
jettonWalletCode: Cell;
}

contract JettonMinter with OwnableTransferable, Deployable {
contract JettonMinter with OwnableTransferable {
totalSupply: Int as coins;
mintable: Bool;
owner: Address;
Expand Down

0 comments on commit 042d004

Please sign in to comment.