Browse Source

Minor fixes

master
Tal Kol 3 years ago
parent
commit
2acf7ba0b2
  1. 5
      build/deploy.ts
  2. 8
      build/main.deploy.ts

5
build/deploy.ts

@ -14,7 +14,6 @@ import glob from "fast-glob";
import { Address, Cell, CellMessage, CommonMessageInfo, fromNano, InternalMessage, StateInit, toNano } from "ton"; import { Address, Cell, CellMessage, CommonMessageInfo, fromNano, InternalMessage, StateInit, toNano } from "ton";
import { TonClient, WalletContract, WalletV3R2Source, contractAddress, SendMode } from "ton"; import { TonClient, WalletContract, WalletV3R2Source, contractAddress, SendMode } from "ton";
import { mnemonicNew, mnemonicToWalletKey } from "ton-crypto"; import { mnemonicNew, mnemonicToWalletKey } from "ton-crypto";
import { postDeployTest } from "./main.deploy";
async function main() { async function main() {
console.log(`=================================================================`); console.log(`=================================================================`);
@ -68,7 +67,7 @@ async function main() {
const rootContracts = glob.sync(["build/*.deploy.ts"]); const rootContracts = glob.sync(["build/*.deploy.ts"]);
for (const rootContract of rootContracts) { for (const rootContract of rootContracts) {
// deploy a new root contract // deploy a new root contract
console.log(`\n* Found root contract to deploy '${rootContract}':`); console.log(`\n* Found root contract '${rootContract} - let's deploy it':`);
const contractName = path.parse(path.parse(rootContract).name).name; const contractName = path.parse(path.parse(rootContract).name).name;
// prepare the init data cell // prepare the init data cell
@ -158,5 +157,5 @@ async function performPostDeploymentTest(rootContract: string, deployInitScript:
return; return;
} }
console.log(` - Running a post deployment test:`); console.log(` - Running a post deployment test:`);
await postDeployTest(walletContract, secretKey, newContractAddress); await deployInitScript.postDeployTest(walletContract, secretKey, newContractAddress);
} }

8
build/main.deploy.ts

@ -6,7 +6,7 @@ import { sendInternalMessageWithWallet } from "../test/helpers";
export function initData() { export function initData() {
return main.data({ return main.data({
ownerAddress: Address.parseFriendly("EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N").address, ownerAddress: Address.parseFriendly("EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N").address,
counter: 0, counter: 10,
}); });
} }
@ -19,13 +19,13 @@ export function initMessage() {
export async function postDeployTest(walletContract: WalletContract, secretKey: Buffer, contractAddress: Address) { export async function postDeployTest(walletContract: WalletContract, secretKey: Buffer, contractAddress: Address) {
const call = await walletContract.client.callGetMethod(contractAddress, "counter"); const call = await walletContract.client.callGetMethod(contractAddress, "counter");
const counter = new TupleSlice(call.stack).readBigNumber(); const counter = new TupleSlice(call.stack).readBigNumber();
console.log(` # Getter 'counter' = ${counter.toString()}`); console.log(` # Getter 'counter' = ${counter.toString()}`);
const message = main.increment(); const message = main.increment();
await sendInternalMessageWithWallet({ walletContract, secretKey, to: contractAddress, value: toNano(0.02), body: message }); await sendInternalMessageWithWallet({ walletContract, secretKey, to: contractAddress, value: toNano(0.02), body: message });
console.log(` # Sent 'increment' op message`); console.log(` # Sent 'increment' op message`);
const call2 = await walletContract.client.callGetMethod(contractAddress, "counter"); const call2 = await walletContract.client.callGetMethod(contractAddress, "counter");
const counter2 = new TupleSlice(call2.stack).readBigNumber(); const counter2 = new TupleSlice(call2.stack).readBigNumber();
console.log(` # Getter 'counter' = ${counter2.toString()}`); console.log(` # Getter 'counter' = ${counter2.toString()}`);
} }

Loading…
Cancel
Save