Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nonce argument to JettonMaster contructor #28

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/jetton/master.tact
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract JettonMaster with TEP74JettonMaster, TEP89JettonDiscoverable, Deployabl
// Is token initialized (to avoid double init)
deployed: Bool = false;

init(owner: Address){
init(owner: Address, nonce: Int){
self.owner = owner;
let init = initOf JettonWallet(myAddress(), myAddress());
let data = init.data.beginParse();
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployJettonMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { JettonMaster } from '../wrappers/JettonMaster';
import { NetworkProvider } from '@ton/blueprint';

export async function run(provider: NetworkProvider) {
const jettonMaster = provider.open(await JettonMaster.fromInit(provider.sender().address!!));
const jettonMaster = provider.open(await JettonMaster.fromInit(provider.sender().address!!, 0n));

await jettonMaster.send(
provider.sender(),
Expand Down
12 changes: 10 additions & 2 deletions tests/JettonMaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('JettonMaster', () => {
deployer = await blockchain.treasury('deployer');
other = await blockchain.treasury("other");

jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address));
jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));
jettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, deployer.address));
otherJettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, other.address));

Expand Down Expand Up @@ -66,6 +66,14 @@ describe('JettonMaster', () => {
});
});

it('should mint multiple jettons per wallet', async () => {
const jettonMasterSameNonce = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));;
expect(jettonMasterSameNonce.address).toEqualAddress(jettonMaster.address);

const jettonMasterDiffNonce = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 1n));;
expect(jettonMasterDiffNonce.address).not.toEqualAddress(jettonMaster.address);
});

it('should handle big strings', async () => {
const LONG_JETTON_NAME = JETTON_NAME.repeat(100);
const LONG_JETTON_DESCRIPTION = JETTON_DESCRIPTION.repeat(20);
Expand All @@ -75,7 +83,7 @@ describe('JettonMaster', () => {
expect(LONG_JETTON_DESCRIPTION.length).toBeGreaterThan(1024);
expect(LONG_JETTON_SYMBOL.length).toBeGreaterThan(1024);

const otherJettonMaster = blockchain.openContract(await JettonMaster.fromInit(other.address));
const otherJettonMaster = blockchain.openContract(await JettonMaster.fromInit(other.address, 0n));
await otherJettonMaster.send(
other.getSender(),
{
Expand Down
2 changes: 1 addition & 1 deletion tests/JettonWallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('JettonMaster', () => {
deployer = await blockchain.treasury('deployer');
other = await blockchain.treasury("other");

jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address));
jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));
jettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, deployer.address));
otherJettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, other.address));

Expand Down
2 changes: 1 addition & 1 deletion tests/MaxSupply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('MaxSupply - Unlimited', () => {
deployer = await blockchain.treasury('deployer');
other = await blockchain.treasury("other");

jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address));
jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));
jettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, deployer.address));
otherJettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, other.address));

Expand Down
2 changes: 1 addition & 1 deletion tests/Mintable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Mintable', () => {
deployer = await blockchain.treasury('deployer');
other = await blockchain.treasury("other");

jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address));
jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));
jettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, deployer.address));
otherJettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, other.address));

Expand Down
2 changes: 1 addition & 1 deletion tests/Ownership.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('OwnerShip', () => {
deployer = await blockchain.treasury('deployer');
other = await blockchain.treasury("other");

jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address));
jettonMaster = blockchain.openContract(await JettonMaster.fromInit(deployer.address, 0n));
jettonWallet = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, deployer.address));
jettonWallet2 = blockchain.openContract(await JettonWallet.fromInit(jettonMaster.address, other.address));

Expand Down
Loading