Skip to content

Instantly share code, notes, and snippets.

@DamianPala
Created April 23, 2024 13:09
Show Gist options
  • Select an option

  • Save DamianPala/59cde366bba2acb5fc6560e5b1ff72c0 to your computer and use it in GitHub Desktop.

Select an option

Save DamianPala/59cde366bba2acb5fc6560e5b1ff72c0 to your computer and use it in GitHub Desktop.
import "@stdlib/deploy";
import "@stdlib/ownable";
import "./messages.tact";
import "./jetton.tact";
contract MemeJettonLite with Jetton, Deployable {
totalSupply: Int as coins;
owner: Address;
content: Cell;
mintable: Bool;
max_supply: Int as coins;
init(owner: Address, content: Cell, max_supply: Int) {
self.totalSupply = 0;
self.owner = owner;
self.mintable = true;
self.content = content;
self.max_supply = max_supply;
self.mint(self.owner, self.max_supply, self.owner);
self.mintable = false;
// self.owner = address("0:0000000000000000000000000000000000000000000000000000000000000000");
}
}
import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox';
import { Address, toNano } from '@ton/core';
import { MemeJettonLite } from '../wrappers/MemeJettonLite';
import { JettonDefaultWallet } from "../build/MemeJettonLite/tact_JettonDefaultWallet";
import { buildOnchainMetadata } from "../utils/jetton-helpers";
import jettonParams from "../jetton.json";
import '@ton/test-utils';
describe('MemeJettonLite', () => {
let blockchain: Blockchain;
let deployer: SandboxContract<TreasuryContract>;
let token: SandboxContract<MemeJettonLite>;
let content = buildOnchainMetadata(jettonParams);
let max_supply = toNano(1E9);
beforeEach(async () => {
blockchain = await Blockchain.create();
deployer = await blockchain.treasury('deployer');
token = blockchain.openContract(await MemeJettonLite.fromInit(
deployer.address,
content,
max_supply
));
await token.send(
deployer.getSender(),
{ value: toNano('0.05') },
{ $$type: 'Deploy', queryId: 0n }
);
expect((await token.getOwner()).toString()).toEqual(deployer.address.toString());
});
it('should deployer has valid balance after deploy', async () => {
const deployerWalletAddress = await token.getGetWalletAddress(deployer.address);
const deployerWallet = blockchain.openContract(JettonDefaultWallet.fromAddress(deployerWalletAddress));
const deployerBalance = (await deployerWallet.getGetWalletData()).balance;
console.log("Deployer's jetton balance: ", deployerBalance);
expect(deployerBalance).toEqual(max_supply);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment