diff --git a/contracts/jetton/master.tact b/contracts/jetton/master.tact index 48c66e8..6abdf62 100644 --- a/contracts/jetton/master.tact +++ b/contracts/jetton/master.tact @@ -46,10 +46,86 @@ contract JettonMaster with TEP74JettonMaster, TEP89JettonDiscoverable, Deployabl self.metadata.set("description", msg.jetton_description); self.metadata.set("symbol", msg.jetton_symbol); self.max_supply = msg.max_supply > 0 ? msg.max_supply : 0; - self.notify(JettonInitOk{query_id: msg.query_id}.toCell()); self.deployed = true; + + // Mint tokens during initialization + if (msg.mint_amount != null && msg.mint_amount!! > 0) { + let ctx: Context = context(); + + // Calculate remaining balance for minting + let initialTransactionValue = ctx.value; + let forwardFee = ctx.readForwardFee(); + let compute_gas: Int = ton("0.01"); + let notify_gas: Int = ton("0.02"); + let remainingValue = initialTransactionValue - notify_gas - compute_gas - forwardFee; + + // Ensure remaining value is sufficient + nativeThrowUnless(ERROR_CODE_NEED_FEE,remainingValue > ton("0.05")); + + //Excess ton will be handled by the transfer process + self.mint(msg.mint_amount!!, self.owner, msg.query_id,remainingValue); + + send(SendParameters{ + to: ctx.sender, // back to the sender + value: notify_gas, //reserved gas for this op + bounce: false, + mode: 0, + body: JettonInitOk{query_id: msg.query_id}.toCell() + }); + }else{ + // notify and send remaining ton back + self.notify(JettonInitOk{query_id: msg.query_id}.toCell()); + } + } + + + 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(); + + // The mint operation + self.mint(msg.amount, msg.destination, msg.query_id,null); } + fun mint(amount: Int, destination: Address, query_id: Int, value: Int?) { + // Ensure the new supply does not exceed the max supply + if (self.max_supply > 0) { + nativeThrowIf(ERROR_MAX_SUPPLY_EXCEEDED, (self.current_supply + amount) > self.max_supply); + } + + // Prepare wallet initialization + let init = self.discover_wallet_state_init(myAddress(), destination); + let to = contractAddress(init); + + // Determine value and mode based on whether a value is provided + let sendValue = value != null ? value!! : 0; + let sendMode = value != null ? 0 : SendRemainingValue; + + // Send minting transaction + send(SendParameters{ + to: to, + value: sendValue, + mode: sendMode, + code: init.code, + data: init.data, + bounce: true, + body: JettonTransferInternal{ + query_id: query_id, + amount: amount, + from: myAddress(), + response_destination: destination, + forward_ton_amount: 0, + forward_payload: emptySlice() + }.toCell() + }); + + // Update the current supply + self.current_supply += amount; + } + + + receive(msg: JettonSetParameter) { self.requireOwner(); // Ensure only the current owner can update parameters @@ -72,38 +148,6 @@ contract JettonMaster with TEP74JettonMaster, TEP89JettonDiscoverable, Deployabl 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(); - - // Ensure the new supply does not exceed the max supply - // Only for the case that max_supply is not set to unlimited (0) - if(self.max_supply > 0){ - nativeThrowIf(ERROR_MAX_SUPPLY_EXCEEDED, (self.current_supply + msg.amount) > self.max_supply); - } - - let init = self.discover_wallet_state_init(myAddress(), msg.destination); - let to = contractAddress(init); - send(SendParameters{ - to: to, - value: 0, - mode: SendRemainingValue, - code: init.code, - data: init.data, - bounce: true, - body: JettonTransferInternal{ - query_id: msg.query_id, - amount: msg.amount, - from: myAddress(), - response_destination: msg.destination, - forward_ton_amount: 0, - forward_payload: emptySlice() - }.toCell() - } - ); - self.current_supply += msg.amount; - } bounced(msg: bounced){ nativeThrowUnless(ERROR_CODE_INVALID_AMOUNT, msg.amount > 0); // Is this needed? Keeping it for consistency diff --git a/contracts/messages.tact b/contracts/messages.tact index 09d7797..c33a5a1 100644 --- a/contracts/messages.tact +++ b/contracts/messages.tact @@ -4,7 +4,9 @@ message(0x133701) JettonInit { jetton_description: Slice; jetton_symbol: Slice; max_supply: Int as coins; + mint_amount: Int? as coins; } + message(0x133702) JettonInitOk { query_id: Int as uint64; } diff --git a/scripts/deployJettonMaster.ts b/scripts/deployJettonMaster.ts index 7cd9b77..5f0c992 100644 --- a/scripts/deployJettonMaster.ts +++ b/scripts/deployJettonMaster.ts @@ -30,6 +30,7 @@ export async function run(provider: NetworkProvider) { jetton_description: beginCell().storeStringRefTail('Long' + ' long '.repeat(100) + 'description').asSlice(), jetton_symbol: beginCell().storeStringRefTail('SMBL').asSlice(), max_supply: toNano(1337), + mint_amount: null } ); await jettonMaster.send( diff --git a/tests/JettonInit.spec.ts b/tests/JettonInit.spec.ts new file mode 100644 index 0000000..068a04f --- /dev/null +++ b/tests/JettonInit.spec.ts @@ -0,0 +1,239 @@ +import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; +import { beginCell, toNano } from '@ton/core'; +import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; +import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; +import { OP_CODES , SYSTEM_CELL, ERROR_CODES} from './constants/constants'; + +import '@ton/test-utils'; + +const JETTON_NAME = "Test jetton"; +const JETTON_DESCRIPTION = "Test jetton description. Test jetton description. Test jetton description"; +const JETTON_SYMBOL = "TSTJTN"; +const JETTON_MAX_SUPPLY = toNano("100500"); + +describe('JettonMaster', () => { + let blockchain: Blockchain; + let deployer: SandboxContract; + let other: SandboxContract; + let jettonMaster: SandboxContract; + let jettonWallet: SandboxContract; + let otherJettonWallet: SandboxContract; + + // handle the init and optional minting + const initializeJettonMaster = async (mintAmount: bigint | null) => { + const initValue = mintAmount && mintAmount > 0n ? toNano("1") : toNano("0.05"); + + // Send the JettonInit message with the mintAmount + const deployResult = await jettonMaster.send( + deployer.getSender(), + { + value: initValue, + }, + { + $$type: 'JettonInit', + query_id: 0n, + jetton_name: beginCell().storeStringTail(JETTON_NAME).asSlice(), + jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), + jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), + max_supply: JETTON_MAX_SUPPLY, + mint_amount: mintAmount, // Pass the mint amount as a parameter + } + ); + + // Verify the deployment transactions + expect(deployResult.transactions).toHaveTransaction({ + from: deployer.address, + to: jettonMaster.address, + success: true, + deploy: true, + op: OP_CODES.JettonInit, + }); + + expect(deployResult.transactions).toHaveTransaction({ + from: jettonMaster.address, + to: deployer.address, + success: true, + deploy: false, + op: OP_CODES.JettonInitOk, + }); + + // If mintAmount is specified and greater than 0, validate the minting logic + if (mintAmount && mintAmount > 0n) { + expect(deployResult.transactions).toHaveTransaction({ + from: jettonMaster.address, + to: jettonWallet.address, + deploy: true, + success: true, + op: OP_CODES.JettonTransferInternal, + }); + } + }; + + beforeEach(async () => { + blockchain = await Blockchain.create(); + + deployer = await blockchain.treasury('deployer'); + other = await blockchain.treasury("other"); + + 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)); + }); + + + it('should correct build wallet address', async () => { + await initializeJettonMaster(10n); + + let walletAddressData = await jettonMaster.getGetWalletAddress(deployer.address); + expect(walletAddressData.toString()).toEqual(jettonWallet.address.toString()); + + let otherWalletAddressData = await jettonMaster.getGetWalletAddress(other.address); + expect(otherWalletAddressData.toString()).toEqual(otherJettonWallet.address.toString()); + }); + + + it('should not double init', async () => { + + await initializeJettonMaster(null); + + const deployResult = await jettonMaster.send( + deployer.getSender(), + { + value: toNano("0.05"), + }, + { + $$type: 'JettonInit', + query_id: 0n, + jetton_name: beginCell().storeStringTail(JETTON_NAME).asSlice(), + jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), + jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), + max_supply: JETTON_MAX_SUPPLY, + mint_amount: null + } + ); + + expect(deployResult.transactions).toHaveTransaction({ + from: deployer.address, + to: jettonMaster.address, + success: false, + deploy: false, + op: OP_CODES.JettonInit, + exitCode: ERROR_CODES.JettonInitialized, + }); + }); + + + it('should mint tokens', async () => { + await initializeJettonMaster(null); + + const mintResult = await jettonMaster.send( + deployer.getSender(), + { + value: toNano("0.05"), + }, + { + $$type: 'JettonMint', + query_id: 0n, + amount: toNano("1337"), + destination: deployer.address, + } + ); + expect(mintResult.transactions).toHaveTransaction({ + from: deployer.address, + to: jettonMaster.address, + success: true, + deploy: false, + op: OP_CODES.JettonMint, + }); + expect(mintResult.transactions).toHaveTransaction({ + from: jettonMaster.address, + to: jettonWallet.address, + success: true, + deploy: true, + op: OP_CODES.JettonTransferInternal, + }); + + let jettonMasterMetadata = await jettonMaster.getGetJettonData(); + expect(jettonMasterMetadata.total_supply).toEqual(toNano("1337")); + + let jettonWalletData = await jettonWallet.getGetWalletData(); + expect(jettonWalletData.balance).toEqual(toNano("1337")); + }); + + it('should init with mint tokens', async () => { + const mint = 120n + await initializeJettonMaster(mint); + + // Fetch updated wallet data and validate balance + let jettonWalletData = await jettonWallet.getGetWalletData(); + expect(jettonWalletData.balance).toEqual(mint); + }); + + it('should init with mint and continue minting outside init', async () => { + const mint = 120n + await initializeJettonMaster(mint); + + // Fetch updated wallet data and validate balance + let jettonWalletDataBefore = await jettonWallet.getGetWalletData(); + expect(jettonWalletDataBefore.balance).toEqual(mint); + + + const mintResult = await jettonMaster.send( + deployer.getSender(), + { + value: toNano("0.05"), + }, + { + $$type: 'JettonMint', + query_id: 0n, + amount: toNano("1337"), + destination: deployer.address, + } + ); + expect(mintResult.transactions).toHaveTransaction({ + from: deployer.address, + to: jettonMaster.address, + success: true, + deploy: false, + op: OP_CODES.JettonMint, + }); + expect(mintResult.transactions).toHaveTransaction({ + from: jettonMaster.address, + to: jettonWallet.address, + success: true, + deploy: false, + op: OP_CODES.JettonTransferInternal, + }); + + let jettonWalletDataAfter = await jettonWallet.getGetWalletData(); + expect(jettonWalletDataAfter.balance).toEqual(mint + toNano("1337")); + }); + + it('should init with mint 0 new jettons (using non-null value)', async () => { + const mint = 0n; + await initializeJettonMaster(mint); + + try { + // Attempt to fetch wallet data , since we didnt proceed with mint, account should be inactive + await jettonWallet.getGetWalletData(); + + // If no error is thrown, the test should fail + throw new Error('Expected an error when accessing a non-active wallet contract'); + } catch (error) { + if (error instanceof Error) { + expect(error.message).toContain('Trying to run get method on non-active contract'); + } else { + throw new Error(`Unexpected error type: ${typeof error}`); + } + } + }); + + + it('should return system cell', async () => { + await initializeJettonMaster(null); + + let systemCell = await jettonMaster.getTactSystemCell(); + expect(systemCell).toEqualCell(SYSTEM_CELL); + }); + +}); diff --git a/tests/JettonMaster.spec.ts b/tests/JettonMaster.spec.ts index bc128a9..dd5fd2b 100644 --- a/tests/JettonMaster.spec.ts +++ b/tests/JettonMaster.spec.ts @@ -2,11 +2,10 @@ import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; import { beginCell, Builder, Cell, Dictionary, toNano } from '@ton/core'; import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; -import { OP_CODES } from './constants/opCodes'; +import { OP_CODES , SYSTEM_CELL, ERROR_CODES} from './constants/constants'; import '@ton/test-utils'; -const SYSTEM_CELL = Cell.fromBase64('te6cckECJAEACFMAAQHAAQEFoB1rAgEU/wD0pBP0vPLICwMCAWIEFwN60AHQ0wMBcbCjAfpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhUUFMDbwT4YQL4Yts8VRTbPPLgghwFFgP2AY5XgCDXIXAh10nCH5UwINcLH94gghAXjUUZuo4YMNMfAYIQF41FGbry4IHTP/oAWWwSMaB/4IIQe92X3rqOF9MfAYIQe92X3rry4IHTP/oAWWwSMaB/4DB/4HAh10nCH5UwINcLH94gghAPin6luo8IMNs8bBfbPH/gBgcKAMbTHwGCEA+KfqW68uCB0z/6APpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJ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68tCJgwm68uCIzxYBINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WyQAIVHA0JQIBICIjAN27vRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnAgVcAbgGdjlM5YOq5HJbLDgnCdl05as07LczoOlm2UZuikgnCd0eAD5bNgPJ/IOrJZrKITgnBAznVp5xX50lCwHWFuJkeygAEbgr7tRNDSAAGDOqBFY='); const JETTON_NAME = "Test jetton"; const JETTON_DESCRIPTION = "Test jetton description. Test jetton description. Test jetton description"; @@ -48,6 +47,7 @@ describe('JettonMaster', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); expect(deployResult.transactions).toHaveTransaction({ @@ -106,6 +106,7 @@ describe('JettonMaster', () => { jetton_description: beginCell().storeStringRefTail(LONG_JETTON_DESCRIPTION).asCell().asSlice(), jetton_symbol: beginCell().storeStringRefTail(LONG_JETTON_SYMBOL).asCell().asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); expect(deployResult.transactions).toHaveTransaction({ @@ -192,6 +193,7 @@ describe('JettonMaster', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); @@ -201,7 +203,7 @@ describe('JettonMaster', () => { success: false, deploy: false, op: OP_CODES.JettonInit, - exitCode: 6903, + exitCode: ERROR_CODES.JettonInitialized, }); }); @@ -218,6 +220,7 @@ describe('JettonMaster', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); @@ -227,7 +230,7 @@ describe('JettonMaster', () => { success: false, deploy: false, op: OP_CODES.JettonInit, - exitCode: 132, + exitCode: ERROR_CODES.InvalidOwner, }); }); @@ -310,7 +313,7 @@ describe('JettonMaster', () => { success: false, deploy: false, op: OP_CODES.JettonSetParameter, - exitCode: 6905 + exitCode: ERROR_CODES.InvalidAmount }); // Checks @@ -364,7 +367,7 @@ describe('JettonMaster', () => { to: jettonWallet.address, success: true, deploy: true, - op: 0x178d4519, + op: OP_CODES.JettonTransferInternal, }); let jettonMasterMetadata = await jettonMaster.getGetJettonData(); @@ -393,7 +396,7 @@ describe('JettonMaster', () => { success: false, deploy: false, op: OP_CODES.JettonMint, - exitCode: 132, + exitCode: ERROR_CODES.InvalidOwner, }); }); diff --git a/tests/JettonWallet.spec.ts b/tests/JettonWallet.spec.ts index dcce5f0..ddb89ce 100644 --- a/tests/JettonWallet.spec.ts +++ b/tests/JettonWallet.spec.ts @@ -2,7 +2,7 @@ import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; import { beginCell, Builder, toNano } from '@ton/core'; import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; -import { OP_CODES } from './constants/opCodes'; +import { OP_CODES , ERROR_CODES } from './constants/constants'; import '@ton/test-utils'; const JETTON_NAME = "Test jetton"; @@ -40,6 +40,7 @@ describe('JettonMaster', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); await jettonMaster.send( @@ -129,7 +130,7 @@ describe('JettonMaster', () => { deploy: false, success: false, op: OP_CODES.JettonTransfer, - exitCode: 132, + exitCode: ERROR_CODES.InvalidOwner, }); let jettonWalletData = await jettonWallet.getGetWalletData(); @@ -159,7 +160,7 @@ describe('JettonMaster', () => { deploy: false, success: false, op: OP_CODES.JettonTransfer, - exitCode: 6901, + exitCode: ERROR_CODES.NotEnoughBalance, }); let jettonWalletData = await jettonWallet.getGetWalletData(); @@ -226,7 +227,7 @@ describe('JettonMaster', () => { deploy: false, success: false, op: OP_CODES.JettonBurn, - exitCode: 132, + exitCode: ERROR_CODES.InvalidOwner, }); let jettonWalletData = await jettonWallet.getGetWalletData(); @@ -253,7 +254,7 @@ describe('JettonMaster', () => { deploy: false, success: false, op: OP_CODES.JettonBurn, - exitCode: 6901, + exitCode: ERROR_CODES.NotEnoughBalance, }); let jettonWalletData = await jettonWallet.getGetWalletData(); diff --git a/tests/MaxSupply.spec.ts b/tests/MaxSupply.spec.ts index 406ba86..ffd06f8 100644 --- a/tests/MaxSupply.spec.ts +++ b/tests/MaxSupply.spec.ts @@ -2,12 +2,10 @@ import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; import { beginCell, Builder, Cell, Dictionary, toNano } from '@ton/core'; import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; -import { OP_CODES } from './constants/opCodes'; +import { OP_CODES , SYSTEM_CELL , ERROR_CODES } from './constants/constants'; import '@ton/test-utils'; -const SYSTEM_CELL = Cell.fromBase64('te6cckECJAEACFMAAQHAAQEFoB1rAgEU/wD0pBP0vPLICwMCAWIEFwN60AHQ0wMBcbCjAfpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhUUFMDbwT4YQL4Yts8VRTbPPLgghwFFgP2AY5XgCDXIXAh10nCH5UwINcLH94gghAXjUUZuo4YMNMfAYIQF41FGbry4IHTP/oAWWwSMaB/4IIQe92X3rqOF9MfAYIQe92X3rry4IHTP/oAWWwSMaB/4DB/4HAh10nCH5UwINcLH94gghAPin6luo8IMNs8bBfbPH/gBgcKAMbTHwGCEA+KfqW68uCB0z/6APpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHSAAGR1JJtAeL6AFFmFhUUQzAEkjKBGvklwgDy9PhBbyQQThA9TLr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HA0JQIBICIjAN27vRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnAgVcAbgGdjlM5YOq5HJbLDgnCdl05as07LczoOlm2UZuikgnCd0eAD5bNgPJ/IOrJZrKITgnBAznVp5xX50lCwHWFuJkeygAEbgr7tRNDSAAGDOqBFY='); - const JETTON_NAME = "Test jetton"; const JETTON_DESCRIPTION = "Test jetton description. Test jetton description. Test jetton description"; const JETTON_SYMBOL = "TSTJTN"; @@ -43,6 +41,7 @@ describe('MaxSupply - Unlimited', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); expect(deployResult.transactions).toHaveTransaction({ @@ -85,6 +84,7 @@ describe('MaxSupply - Unlimited', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); @@ -94,7 +94,7 @@ describe('MaxSupply - Unlimited', () => { success: false, deploy: false, op: OP_CODES.JettonInit, - exitCode: 6903, + exitCode: ERROR_CODES.JettonInitialized, }); }); @@ -125,7 +125,7 @@ describe('MaxSupply - Unlimited', () => { to: jettonWallet.address, success: true, deploy: true, - op: 0x178d4519, + op: OP_CODES.JettonTransferInternal, }); let jettonMasterMetadata = await jettonMaster.getGetJettonData(); @@ -198,7 +198,7 @@ describe('MaxSupply - Unlimited', () => { success: false, deploy: false, op: OP_CODES.JettonSetParameter, - exitCode: 6905, + exitCode: ERROR_CODES.InvalidAmount, }); }); @@ -265,7 +265,7 @@ describe('MaxSupply - Unlimited', () => { success: false, deploy: false, op: OP_CODES.JettonMint, - exitCode: 6904, + exitCode: ERROR_CODES.MaxSupplyExceeded, }); @@ -287,7 +287,7 @@ describe('MaxSupply - Unlimited', () => { success: false, deploy: false, op: OP_CODES.JettonSetParameter, - exitCode: 6905 + exitCode: ERROR_CODES.InvalidAmount }); //set max_supply to 200 diff --git a/tests/Mintable.spec.ts b/tests/Mintable.spec.ts index eea2013..aeff312 100644 --- a/tests/Mintable.spec.ts +++ b/tests/Mintable.spec.ts @@ -2,12 +2,10 @@ import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; import { beginCell, Builder, Cell, Dictionary, toNano } from '@ton/core'; import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; -import { OP_CODES } from './constants/opCodes'; +import { OP_CODES , SYSTEM_CELL , ERROR_CODES} from './constants/constants'; import '@ton/test-utils'; -const SYSTEM_CELL = Cell.fromBase64('te6cckECJAEACFMAAQHAAQEFoB1rAgEU/wD0pBP0vPLICwMCAWIEFwN60AHQ0wMBcbCjAfpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhUUFMDbwT4YQL4Yts8VRTbPPLgghwFFgP2AY5XgCDXIXAh10nCH5UwINcLH94gghAXjUUZuo4YMNMfAYIQF41FGbry4IHTP/oAWWwSMaB/4IIQe92X3rqOF9MfAYIQe92X3rry4IHTP/oAWWwSMaB/4DB/4HAh10nCH5UwINcLH94gghAPin6luo8IMNs8bBfbPH/gBgcKAMbTHwGCEA+KfqW68uCB0z/6APpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHSAAGR1JJtAeL6AFFmFhUUQzAEkjKBGvklwgDy9PhBbyQQThA9TLrbPCihgRr1IcL/8vRUHcuBGvYM2zyqAIIJMS0AoIIImJaAoC2gUAq5GPL0UgZeNBA6SRjbPFwREg0IAtZwWchwAcsBcwHLAXABywASzMzJ+QDIcgHLAXABywASygfL/8nQINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFCYcIBAfylPEwEREAEOyFVQ2zzJEGcQWRBKEDtBgBA2EDUQNFnbPDB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jPFgEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJJwRDE1CZECQQI21t2zwwVQMUAcrIcQHKAVAHAcoAcAHKAlAFINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WUAP6AnABymgjbrORf5MkbrPilzMzAXABygDjDSFus5x/AcoAASBu8tCAAcyVMXABygDiyQH7CBUAmH8BygDIcAHKAHABygAkbrOdfwHKAAQgbvLQgFAEzJY0A3ABygDiJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4nABygACfwHKAALJWMwAqsj4QwHMfwHKAFVAUFQg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxZYINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WzBLMgQEBzwDJ7VQCASAYIQIBWBkbAhG0o7tnm2eNijAcGgACIwIRt2BbZ5tnjYqQHCABxu1E0NQB+GPSAAGOS/pAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHU1IEBAdcAVUBsFeD4KNcLCoMJuvLgiR0BivpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiBIC0QHbPB4BGnAi+ENUEEDbPNDUMFgfANYC0PQEMG0BgQ61AYAQ9A9vofLghwGBDrUiAoAQ9BfIAcj0AMkBzHABygBAA1kg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxYBINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WyQAIVHA0JQIBICIjAN27vRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnAgVcAbgGdjlM5YOq5HJbLDgnCdl05as07LczoOlm2UZuikgnCd0eAD5bNgPJ/IOrJZrKITgnBAznVp5xX50lCwHWFuJkeygAEbgr7tRNDSAAGDOqBFY='); - const JETTON_NAME = "Test jetton"; const JETTON_DESCRIPTION = "Test jetton description. Test jetton description. Test jetton description"; const JETTON_SYMBOL = "TSTJTN"; @@ -43,6 +41,7 @@ describe('Mintable', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); expect(deployResult.transactions).toHaveTransaction({ @@ -85,6 +84,7 @@ describe('Mintable', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); @@ -94,7 +94,7 @@ describe('Mintable', () => { success: false, deploy: false, op: OP_CODES.JettonInit, - exitCode: 6903, + exitCode: ERROR_CODES.JettonInitialized, }); }); @@ -120,12 +120,13 @@ describe('Mintable', () => { deploy: false, op: OP_CODES.JettonMint, }); + expect(mintResult.transactions).toHaveTransaction({ from: jettonMaster.address, to: jettonWallet.address, success: true, deploy: true, - op: 0x178d4519, + op: OP_CODES.JettonTransferInternal, }); let jettonMasterMetadata = await jettonMaster.getGetJettonData(); @@ -153,8 +154,8 @@ describe('Mintable', () => { to: jettonMaster.address, success: false, deploy: false, - op: 0x133704, - exitCode: 132, + op: OP_CODES.JettonMint, + exitCode: ERROR_CODES.InvalidOwner, }); }); @@ -244,7 +245,7 @@ describe('Mintable', () => { success: false, deploy: false, op: OP_CODES.JettonMint, - exitCode: 6907, + exitCode: ERROR_CODES.MintingDisabled, }); }); @@ -289,7 +290,7 @@ describe('Mintable', () => { success: false, deploy: false, op: OP_CODES.JettonMint, - exitCode: 6907, + exitCode: ERROR_CODES.MintingDisabled, }); //try to enable minting back @@ -311,7 +312,7 @@ describe('Mintable', () => { success: false, deploy: false, op: OP_CODES.JettonSetParameter, - exitCode: 6906, + exitCode: ERROR_CODES.MintingAlreadyDisabled, }); //try to mint 100 tokens @@ -333,7 +334,7 @@ describe('Mintable', () => { success: false, deploy: false, op: OP_CODES.JettonMint, - exitCode: 6907, + exitCode: ERROR_CODES.MintingDisabled, }); }); diff --git a/tests/Ownership.spec.ts b/tests/Ownership.spec.ts index 07b1c42..05cbf53 100644 --- a/tests/Ownership.spec.ts +++ b/tests/Ownership.spec.ts @@ -2,7 +2,9 @@ import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox'; import { beginCell, Address, toNano } from '@ton/core'; import { JettonWallet } from '../build/Jetton/tact_JettonWallet'; import { JettonMaster } from '../build/Jetton/tact_JettonMaster'; +import { OP_CODES , ERROR_CODES } from './constants/constants'; import '@ton/test-utils'; +import { error } from 'console'; const JETTON_NAME = "Test jetton"; @@ -41,6 +43,7 @@ describe('OwnerShip', () => { jetton_description: beginCell().storeStringTail(JETTON_DESCRIPTION).asSlice(), jetton_symbol: beginCell().storeStringTail(JETTON_SYMBOL).asSlice(), max_supply: JETTON_MAX_SUPPLY, + mint_amount: null } ); expect(deployResult.transactions).toHaveTransaction({ @@ -48,14 +51,14 @@ describe('OwnerShip', () => { to: jettonMaster.address, success: true, deploy: true, - op: 0x133701, + op: OP_CODES.JettonInit, }); expect(deployResult.transactions).toHaveTransaction({ from: jettonMaster.address, to: deployer.address, success: true, deploy: false, - op: 0x133702, + op: OP_CODES.JettonInitOk, }); }); @@ -77,14 +80,14 @@ describe('OwnerShip', () => { to: jettonMaster.address, success: true, deploy: false, - op: 0x133704, + op: OP_CODES.JettonMint, }); expect(mintResult.transactions).toHaveTransaction({ from: jettonMaster.address, to: jettonWallet.address, success: true, deploy: true, - op: 0x178d4519, + op: OP_CODES.JettonTransferInternal, }); let jettonMasterMetadata = await jettonMaster.getGetJettonData(); @@ -138,8 +141,8 @@ describe('OwnerShip', () => { to: jettonMaster.address, success: false, deploy: false, - op: 0x133704, - exitCode: 132, + op: OP_CODES.JettonMint, + exitCode: ERROR_CODES.InvalidOwner, }); }); @@ -161,7 +164,7 @@ describe('OwnerShip', () => { to: jettonMaster.address, success: true, deploy: false, - op: 0x133704, + op: OP_CODES.JettonMint, }); expect(mintResult.transactions).toHaveTransaction({ @@ -169,7 +172,7 @@ describe('OwnerShip', () => { to: jettonWallet2.address, success: true, deploy: true, - op: 0x178d4519, + op: OP_CODES.JettonTransferInternal, }); let jettonMasterMetadata = await jettonMaster.getGetJettonData(); @@ -223,8 +226,8 @@ describe('OwnerShip', () => { to: jettonMaster.address, success: false, deploy: false, - op: 0x133704, - exitCode: 132, + op: OP_CODES.JettonMint, + exitCode: ERROR_CODES.InvalidOwner, }); }); }); diff --git a/tests/constants/constants.ts b/tests/constants/constants.ts new file mode 100644 index 0000000..8c40790 --- /dev/null +++ b/tests/constants/constants.ts @@ -0,0 +1,30 @@ +import { Cell } from '@ton/core'; + +//Wallet System Cell +export const SYSTEM_CELL = Cell.fromBase64('te6cckECJAEACFMAAQHAAQEFoB1rAgEU/wD0pBP0vPLICwMCAWIEFwN60AHQ0wMBcbCjAfpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhUUFMDbwT4YQL4Yts8VRTbPPLgghwFFgP2AY5XgCDXIXAh10nCH5UwINcLH94gghAXjUUZuo4YMNMfAYIQF41FGbry4IHTP/oAWWwSMaB/4IIQe92X3rqOF9MfAYIQe92X3rry4IHTP/oAWWwSMaB/4DB/4HAh10nCH5UwINcLH94gghAPin6luo8IMNs8bBfbPH/gBgcKAMbTHwGCEA+KfqW68uCB0z/6APpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IgB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHSAAGR1JJtAeL6AFFmFhUUQzAEkjKBGvklwgDy9PhBbyQQThA9TLrbPCihgRr1IcL/8vRUHcuBGvYM2zyqAIIJMS0AoIIImJaAoC2gUAq5GPL0UgZeNBA6SRjbPFwREg0IAtZwWchwAcsBcwHLAXABywASzMzJ+QDIcgHLAXABywASygfL/8nQINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFCYcIBAfylPEwEREAEOyFVQ2z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ODES = { + JettonTransfer: 0x0f8a7ea5, // Message for transferring Jettons + JettonTransferInternal: 0x178d4519, // Internal Jetton transfer + JettonTransferNotification: 0x7362d09c,// Notification for a completed transfer + JettonBurn: 0x595f07bc, // Burn Jettons + JettonBurnInternal: 0x7bdd97de, // Internal Jetton burn + Excesses: 0xd53276db, // Handle excess balances + ProvideWalletAddress: 0x2c76b973, // Request a Jetton wallet address + TakeWalletAddress: 0xd1735400, // Respond with a Jetton wallet address + JettonInit: 0x133701, // Initialize the Jetton + JettonInitOk: 0x133702, // Confirm Jetton initialization + JettonSetParameter: 0x133703, // Set Jetton parameters + JettonMint: 0x133704, // Mint new Jettons +}; + +export const ERROR_CODES = { + InvalidOwner: 132, // Default Tact error code for invalid owner + NotEnoughBalance: 6901, // Jetton wallet balance doesn't have enough tokens + NeedFee: 6902, // Need more TONs in request for fee + JettonInitialized: 6903, // Jetton already initialized + MaxSupplyExceeded: 6904, // Jetton max supply exceeded + InvalidAmount: 6905, // Invalid transfer amount (e.g., zero tokens) + MintingAlreadyDisabled: 6906, // Minting already disabled + MintingDisabled: 6907, // Minting is disabled +}; \ No newline at end of file diff --git a/tests/constants/opCodes.ts b/tests/constants/opCodes.ts deleted file mode 100644 index 98cf483..0000000 --- a/tests/constants/opCodes.ts +++ /dev/null @@ -1,15 +0,0 @@ - -export const OP_CODES = { - JettonTransfer: 0x0f8a7ea5, // Message for transferring Jettons - JettonTransferInternal: 0x178d4519, // Internal Jetton transfer - JettonTransferNotification: 0x7362d09c,// Notification for a completed transfer - JettonBurn: 0x595f07bc, // Burn Jettons - JettonBurnInternal: 0x7bdd97de, // Internal Jetton burn - Excesses: 0xd53276db, // Handle excess balances - ProvideWalletAddress: 0x2c76b973, // Request a Jetton wallet address - TakeWalletAddress: 0xd1735400, // Respond with a Jetton wallet address - JettonInit: 0x133701, // Initialize the Jetton - JettonInitOk: 0x133702, // Confirm Jetton initialization - JettonSetParameter: 0x133703, // Set Jetton parameters - JettonMint: 0x133704, // Mint new Jettons -};