git.delta.rocks / unique-network / refs/commits / 07e3bb10437a

difftreelog

initialize contract by metadata test

kpozdnikin2020-12-18parent: #82ca9c1.patch.diff
in: master

1 file changed

modifiedtests/src/contracts.test.tsdiffbeforeafterboth
1import { expect } from "chai";1import { expect } from "chai";
2import usingApi from "./substrate/substrate-api";2import usingApi from "./substrate/substrate-api";
3import fs from "fs";3import fs from "fs";
4import { Abi, BlueprintPromise, CodePromise } from "@polkadot/api-contract";4import { Abi, BlueprintPromise, CodePromise, ContractPromise } from "@polkadot/api-contract";
5import { IKeyringPair } from "@polkadot/types/types";5import { IKeyringPair } from "@polkadot/types/types";
6import { Keyring } from "@polkadot/api";6import { Keyring } from "@polkadot/api";
7import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";7import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";
88
9const value = 0;9const value = 0;
10const gasLimit = 3000n * 1000000n;10const gasLimit = 3000n * 1000000n;
11const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';
1112
12function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<BlueprintPromise> {13function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<BlueprintPromise> {
13 return new Promise<BlueprintPromise>(async (resolve, reject) => {14 return new Promise<BlueprintPromise>(async (resolve, reject) => {
93 });94 });
94 });95 });
96
97 it('Can initialize contract instance', async () => {
98 await usingApi(async (api) => {
99 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));
100 const abi = new Abi(metadata);
101 const newContractInstance = new ContractPromise(api, abi, marketContractAddress);
102 expect(newContractInstance).to.have.property('address');
103 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);
104 });
105 });
95106
96 it.skip('Can transfer balance using smart contract.', async () => {107 it.skip('Can transfer balance using smart contract.', async () => {
97 await usingApi(async api => {108 await usingApi(async api => {