import chai, {assert, expect} from "chai"; import chaiBN from "chai-bn"; import BN from "bn.js"; chai.use(chaiBN(BN)); import {Address, Builder, Cell, contractAddress, Slice} from "ton"; import {runContract, SmartContract} from "ton-contract-executor"; import * as main from "../contracts/main"; import {internalMessage, randomAddress} from "./helpers"; import {hex as item_code} from "../build/nft-item.compiled.json"; import {makeSnakeCell} from "../contracts/utils"; import {keyPairFromSeed, KeyPair, sign, keyPairFromSecretKey} from "ton-crypto"; import {signBuy} from "../contracts/main"; let data = main.itemDataUninit({domain: "test", collectionAddress: randomAddress("collection")}); describe("Creating items tests", () => { let contract: SmartContract; let debug: boolean = true; beforeEach(async () => { contract = await SmartContract.fromCell( Cell.fromBoc(item_code)[0], data, {debug: debug} ); contract.setC7Config({ myself: randomAddress("item") }) }); it("allows to set the data", async () => { let ownerAddr = randomAddress("dude"); const initializeMsg = internalMessage({ from: randomAddress("collection"), body: main.initializeItemMsg({domain: "test", ownerAddr}), value: new BN(0), }); const res = await contract.sendInternalMessage(initializeMsg); // let nft_data = await contract.invokeGetMethod("get_nft_data", []); // console.log(nft_data.result); expect(res.type).to.equal("success"); expect(res.exit_code).to.equal(0); const setDataMsg = internalMessage({ from: ownerAddr, body: await main.setContent({domain: "test", zone: "example.ton"}), value: new BN(0), }) const res2 = await contract.sendInternalMessage(setDataMsg); expect(res2.type).to.equal("success"); expect(res2.exit_code).to.equal(0); let nft_data = await contract.invokeGetMethod("get_nft_data", []); console.log(nft_data.result); // @ts-ignore let content = (nft_data.result[4] as Slice); }); });