You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.3 KiB

2 years ago
import { toNano, Address } from "ton";
2 years ago
import { ContractSystem } from "ton-emulator";
import {SampleJetton} from './output/jetton_SampleJetton';
2 years ago
import { default_content } from './config';
import { JettonDefaultWallet } from './output/jetton_JettonDefaultWallet';
import { toBufferBE } from "bigint-buffer";
2 years ago
describe('jetton', () => {
it('should deploy', async () => {
// Create jetton
let system = await ContractSystem.create();
let owner = system.treasure('owner');
2 years ago
2 years ago
let contract = system.open(await SampleJetton.fromInit(owner.address, default_content));
2 years ago
let tracker = system.track(contract.address);
2 years ago
let wallet_contract = system.open(await JettonDefaultWallet.fromInit(contract.address, owner.address));
let wallet_tracker = system.track(wallet_contract.address);
2 years ago
// Mint
2 years ago
let res1 = await contract.send(owner, { value: toNano(1) }, { $$type: 'Mint', amount: toNano(1000000) });
let res = await system.run();
console.log(res1)
console.log(res)
2 years ago
expect(tracker.events()).toMatchSnapshot();
2 years ago
// expect(wallet_tracker.events()).toMatchSnapshot();
let addr_get = await contract.getGetWalletAddress(owner.address);
let addr = toBufferBE(res[1].address, owner.address.hash.length);
// console.log(await wallet_contract.getGetWalletData());
console.log((new Address(0, addr)).toString())
console.log(wallet_contract.address.toString())
let wc_proto = await JettonDefaultWallet.fromInit(contract.address, owner.address);
// wc_proto.address = new Address(0, addr);
let wallet_contract_2 = system.contract(new Address(0, addr));
let wdata = (await wallet_contract_2.get(97026, [])) as any;
console.log('wdata', wdata, )
console.log(wdata.stack)
console.log(wallet_contract.address.toString(), addr_get.toString());
// let c = system.open({address: addr, abi: wallet_contract.abi});
// console.log(await c.abi.getGetWalletData());
2 years ago
// Check owner
expect((await contract.getOwner()).toString()).toEqual(owner.address.toString());
// Data
let data = await contract.getGetJettonData();
// console.warn(data);
2 years ago
console.log(tracker.events())
2 years ago
});
2 years ago
});