Revert "Move contracts into api-contract"
This reverts commit af0e8cf07a.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"name": "Erc20",
|
||||
"deploy": {
|
||||
"args": [
|
||||
{
|
||||
"name": "init_value",
|
||||
"type": "Balance"
|
||||
}
|
||||
]
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"name": "total_supply",
|
||||
"selector": 949181842,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": "Balance"
|
||||
},
|
||||
{
|
||||
"name": "balance_of",
|
||||
"selector": 3827153702,
|
||||
"mutates": false,
|
||||
"args": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "Address"
|
||||
}
|
||||
],
|
||||
"return_type": "Balance"
|
||||
},
|
||||
{
|
||||
"name": "allowance",
|
||||
"selector": 3057219184,
|
||||
"mutates": false,
|
||||
"args": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "Address"
|
||||
}
|
||||
],
|
||||
"return_type": "Balance"
|
||||
},
|
||||
{
|
||||
"name": "transfer",
|
||||
"selector": 3374842663,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "Balance"
|
||||
}
|
||||
],
|
||||
"return_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "approve",
|
||||
"selector": 431186122,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "Balance"
|
||||
}
|
||||
],
|
||||
"return_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "transfer_from",
|
||||
"selector": 197482595,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "from",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "Balance"
|
||||
}
|
||||
],
|
||||
"return_type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Flipper",
|
||||
"deploy": {
|
||||
"args": []
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"name": "flip",
|
||||
"selector": 970692492,
|
||||
"mutates": true,
|
||||
"args": [],
|
||||
"return_type": null
|
||||
},
|
||||
{
|
||||
"name": "get",
|
||||
"selector": 4266279973,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "Incrementer",
|
||||
"deploy": {
|
||||
"args": [
|
||||
{
|
||||
"name": "init_value",
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"name": "inc",
|
||||
"selector": 257544423,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "by",
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"return_type": null
|
||||
},
|
||||
{
|
||||
"name": "get",
|
||||
"selector": 4266279973,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "compare",
|
||||
"selector": 363906316,
|
||||
"mutates": false,
|
||||
"args": [
|
||||
{
|
||||
"name": "with",
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"return_type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"name": "SharedVec",
|
||||
"deploy": {
|
||||
"args": []
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"name": "push",
|
||||
"selector": 865577567,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "value",
|
||||
"type": "i32"
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"Result<T,E>": {
|
||||
"T": [],
|
||||
"E": "u32"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "register",
|
||||
"selector": 572030971,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "mutator",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"name": "begin",
|
||||
"type": {
|
||||
"Option<T>": {
|
||||
"T": "u32"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "end",
|
||||
"type": {
|
||||
"Option<T>": {
|
||||
"T": "u32"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"Result<T,E>": {
|
||||
"T": [],
|
||||
"E": "u32"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "set",
|
||||
"selector": 2028185770,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "at",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "i32"
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"Result<T,E>": {
|
||||
"T": "i32",
|
||||
"E": "u32"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "get",
|
||||
"selector": 4266279973,
|
||||
"mutates": false,
|
||||
"args": [
|
||||
{
|
||||
"name": "at",
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"return_type": {
|
||||
"Option<T>": {
|
||||
"T": "i32"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "len",
|
||||
"selector": 1403873684,
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": "u32"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,20 +2,17 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { KeyringPair } from '@polkadot/keyring/types';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { Abi } from '@polkadot/api-contract';
|
||||
import { ContractAbi, Address, Hash } from '@polkadot/types';
|
||||
import { KeyringPair } from '@polkadot/keyring/types';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { Address, Hash } from '@polkadot/types';
|
||||
|
||||
import flipperAbi from '../../../api-contract/test/contracts/flipper.json';
|
||||
|
||||
import { ApiPromise, SubmittableResult } from '../../src';
|
||||
|
||||
const flipperCode = fs.readFileSync(path.join(__dirname, '../../../api-contract/test/contracts/flipper-pruned.wasm')).toString('hex');
|
||||
import Api from './../../src/promise';
|
||||
import flipperAbi from '../data/flipper.json';
|
||||
import erc20Abi from '../data/erc20.json';
|
||||
import { SubmittableResult } from './../../src';
|
||||
|
||||
describe.skip('Promise e2e contracts', () => {
|
||||
let address: Address;
|
||||
@@ -23,11 +20,11 @@ describe.skip('Promise e2e contracts', () => {
|
||||
let keyring: {
|
||||
[index: string]: KeyringPair
|
||||
};
|
||||
let api: ApiPromise;
|
||||
let api: Api;
|
||||
|
||||
beforeEach(async (done) => {
|
||||
if (!api) {
|
||||
api = await ApiPromise.create();
|
||||
api = await Api.create();
|
||||
|
||||
keyring = testingPairs({ type: 'sr25519' });
|
||||
}
|
||||
@@ -38,29 +35,31 @@ describe.skip('Promise e2e contracts', () => {
|
||||
|
||||
describe('flipper', () => {
|
||||
const MAX_GAS = 500000;
|
||||
let abi: Abi;
|
||||
let abi: ContractAbi;
|
||||
|
||||
beforeEach(() => {
|
||||
abi = new Abi(flipperAbi);
|
||||
abi = new ContractAbi(flipperAbi);
|
||||
});
|
||||
|
||||
it('allows putCode', (done) => {
|
||||
const code = fs.readFileSync(path.join(__dirname, '../data/flipper-pruned.wasm')).toString('hex');
|
||||
|
||||
return (
|
||||
api.tx.contract
|
||||
.putCode(MAX_GAS, `0x${flipperCode}`)
|
||||
.signAndSend(keyring.eve, (result: SubmittableResult) => {
|
||||
console.error('putCode', JSON.stringify(result));
|
||||
.putCode(MAX_GAS, `0x${code}`)
|
||||
.signAndSend(keyring.eve, (result: SubmittableResult) => {
|
||||
console.error('putCode', JSON.stringify(result));
|
||||
|
||||
if (result.status.isFinalized) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
if (result.status.isFinalized) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
|
||||
if (record) {
|
||||
codeHash = record.event.data[0] as Hash;
|
||||
if (record) {
|
||||
codeHash = record.event.data[0] as Hash;
|
||||
|
||||
done();
|
||||
}
|
||||
done();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -102,4 +101,18 @@ describe.skip('Promise e2e contracts', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('erc20', () => {
|
||||
let abi: ContractAbi;
|
||||
|
||||
beforeEach(() => {
|
||||
abi = new ContractAbi(erc20Abi);
|
||||
});
|
||||
|
||||
it('has the attached methods', () => {
|
||||
expect(Object.keys(abi.messages)).toEqual(
|
||||
['totalSupply', 'balanceOf', 'allowance', 'transfer', 'approve', 'transferFrom']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user