Lev
2 years ago
13 changed files with 250 additions and 81 deletions
@ -1,27 +0,0 @@
|
||||
import { toNano, beginCell } from "ton"; |
||||
import { ContractSystem } from "ton-emulator"; |
||||
import {TONB} from './output/jetton_TONB'; |
||||
|
||||
describe('jetton', () => { |
||||
it('should deploy', async () => { |
||||
|
||||
// Create jetton
|
||||
let system = await ContractSystem.create(); |
||||
let owner = system.treasure('owner'); |
||||
|
||||
let contract = system.open(await TONB.fromInit(owner.address, null)); |
||||
let tracker = system.track(contract.address); |
||||
|
||||
// Mint
|
||||
await contract.send(owner, { value: toNano(1) }, { $$type: 'Mint', amount: toNano(1000000) }); |
||||
await system.run(); |
||||
expect(tracker.events()).toMatchSnapshot(); |
||||
|
||||
// Check owner
|
||||
expect((await contract.getOwner()).toString()).toEqual(owner.address.toString()); |
||||
|
||||
// Data
|
||||
let data = await contract.getGetJettonData(); |
||||
// console.warn(data);
|
||||
}); |
||||
}); |
@ -0,0 +1,29 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`jetton should deploy 1`] = ` |
||||
[ |
||||
{ |
||||
"type": "deploy", |
||||
}, |
||||
{ |
||||
"message": { |
||||
"body": { |
||||
"cell": "x{8999B1640000000000000000000000000000000000000000000000000001C6BF526340004_}", |
||||
"type": "cell", |
||||
}, |
||||
"bounce": true, |
||||
"from": "kQAI-3FJVc_ywSuY4vq0bYrzR7S4Och4y7bTU_i5yLOB3A6P", |
||||
"to": "kQCrEWck7tGRuwnumilB-HRzp2v-IxRzWG4Lw0mP_VYl72fg", |
||||
"type": "internal", |
||||
"value": 1000000000n, |
||||
}, |
||||
"type": "received", |
||||
}, |
||||
{ |
||||
"gasUsed": 22165n, |
||||
"type": "processed", |
||||
}, |
||||
] |
||||
`; |
||||
|
||||
exports[`jetton should deploy 2`] = `[]`; |
@ -0,0 +1,36 @@
|
||||
import { toNano, beginCell } from "ton"; |
||||
import { ContractSystem } from "ton-emulator"; |
||||
import {TONB} from '../output/jetton_TONB'; |
||||
import { default_content } from '../utils/config'; |
||||
import { TONBWallet } from '../output/jetton_TONBWallet'; |
||||
|
||||
describe('jetton', () => { |
||||
it('should deploy', async () => { |
||||
|
||||
// Create jetton
|
||||
let system = await ContractSystem.create(); |
||||
let owner = system.treasure('owner'); |
||||
|
||||
let contract = system.open(await TONB.fromInit(owner.address, default_content)); |
||||
let tracker = system.track(contract.address); |
||||
let wallet_contract = system.open(await TONBWallet.fromInit(contract.address, owner.address)); |
||||
let wallet_tracker = system.track(wallet_contract.address); |
||||
|
||||
// Mint
|
||||
let res1 = await contract.send(owner, { value: toNano(1) }, { $$type: 'Deposit', amount: toNano(1000000) }); |
||||
let res = await system.run(); |
||||
console.log(res1) |
||||
console.log(res) |
||||
expect(tracker.events()).toMatchSnapshot(); |
||||
expect(wallet_tracker.events()).toMatchSnapshot(); |
||||
console.log(await wallet_contract.getGetWalletData()); |
||||
|
||||
// Check owner
|
||||
expect((await contract.getOwner()).toString()).toEqual(owner.address.toString()); |
||||
|
||||
// Data
|
||||
let data = await contract.getGetJettonData(); |
||||
// console.warn(data);
|
||||
console.log(tracker.events()) |
||||
}); |
||||
}); |
@ -0,0 +1,10 @@
|
||||
import { deployTONB, deposit, withdraw } from "../utils/interactions"; |
||||
import { wallet_data } from '../utils/config'; |
||||
import { randomAddress, TON } from '../utils/helpers'; |
||||
|
||||
(async () => { |
||||
let {my_wallet, secretKey} = await wallet_data(); |
||||
let tonb_addr = await deployTONB(); |
||||
await deposit(my_wallet, secretKey, 1 * TON(), tonb_addr); |
||||
await withdraw(my_wallet, secretKey, 0.5 * TON(), tonb_addr); |
||||
})(); |
@ -0,0 +1,42 @@
|
||||
|
||||
import { TonClient, Address, WalletContractV3R2 } from "ton"; |
||||
import { mnemonicToPrivateKey } from "ton-crypto"; |
||||
import { buildOnchainMetadata } from "./helpers"; |
||||
|
||||
export const client = new TonClient({ |
||||
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC', |
||||
apiKey: 'bb38df0c2756c66e2ab49f064e2484ec444b01244d2bd49793bd5b58f61ae3d2' |
||||
}) |
||||
|
||||
let mnemonics = "basic security merge opera inject core melody polar become force cool glance history order warfare consider company slim twice balcony scare shoot winner rude"; |
||||
// read more about wallet apps https://ton.org/docs/participate/wallets/apps#tonhub-test-environment
|
||||
|
||||
export async function wallet_data() { |
||||
let keyPair = await mnemonicToPrivateKey(mnemonics.split(" ")); |
||||
let secretKey = keyPair.secretKey; |
||||
//Create deployment wallet contract
|
||||
let wallet_contract = WalletContractV3R2.create({ workchain, publicKey: keyPair.publicKey }); |
||||
let my_wallet = client.open(wallet_contract); |
||||
return { my_wallet, secretKey, keyPair }; |
||||
} |
||||
//workchain = 1 - masterchain (expensive operation cost, validator's election contract works here)
|
||||
//workchain = 0 - basechain (normal operation cost, user's contracts works here)
|
||||
export let workchain = 0; //we are working in basechain.
|
||||
|
||||
|
||||
// This is example data - Modify these params for your own jetton
|
||||
// - Data is stored on-chain (except for the image data itself)
|
||||
|
||||
export const jettonParams = { |
||||
name: "TactJet", |
||||
description: "This is description of Test tact jetton", |
||||
image: "https://ipfs.io/ipfs/QmbPZjC1tuP6ickCCBtoTCQ9gc3RpkbKx7C1LMYQdcLwti" // Image url
|
||||
}; |
||||
|
||||
// Owner should usually be the deploying wallet's address.
|
||||
export let owner = Address.parse('EQAuAiFGgkxoQvBWXjXQcLYb8BW4fO6UJkt6_uCONJ2y5VUk'); |
||||
|
||||
|
||||
// Create content Cell
|
||||
export let default_content = buildOnchainMetadata(jettonParams); |
||||
|
@ -0,0 +1,3 @@
|
||||
#!/bin/hash |
||||
for file in $(find sources/output -type f); do sed -i 's/,\ {\ logs:\ res.vmLogs\ }//g' $file; done |
||||
for file in $(find sources/output -type f); do sed -i 's/stringtoreplace//g' $file; done |
Loading…
Reference in new issue