Skip to content

Commit e77c2dd

Browse files
authored
Contracts metadata v3 test data (#4470)
* Contracts metadata v3 test data * Reformat
1 parent 6e7ce90 commit e77c2dd

File tree

6 files changed

+140
-3
lines changed

6 files changed

+140
-3
lines changed

packages/api-contract/src/Abi/Abi.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ interface JSONAbi {
3232
},
3333
V2: {
3434
spec: SpecDef;
35+
},
36+
V3: {
37+
spec: SpecDef;
3538
}
3639
}
3740

@@ -56,7 +59,7 @@ describe('Abi', (): void => {
5659

5760
it(`initializes from a contract ABI (${abiName})`, (): void => {
5861
try {
59-
const messageIds = (abi.V2 || abi.V1 || abi).spec.messages.map(({ label, name }) =>
62+
const messageIds = (abi.V3 || abi.V2 || abi.V1 || abi).spec.messages.map(({ label, name }) =>
6063
label || (
6164
Array.isArray(name)
6265
? name[0]

packages/api-contract/src/Abi/toLatest.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2017-2022 @polkadot/api-contract authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { v0ToLatest, v1ToLatest, v2ToLatest } from '@polkadot/api-contract/Abi/toLatest';
4+
import { v0ToLatest, v1ToLatest, v2ToLatest, v3ToLatest } from '@polkadot/api-contract/Abi/toLatest';
55
import { TypeRegistry } from '@polkadot/types';
66

77
import abis from '../test/contracts';
@@ -83,3 +83,18 @@ describe('v2ToLatest', (): void => {
8383
).toEqual(true);
8484
});
8585
});
86+
87+
describe('v3ToLatest', (): void => {
88+
const registry = new TypeRegistry();
89+
const contract = registry.createType('ContractMetadata', { V3: abis.ink_v3_flipper.V3 });
90+
const latest = v3ToLatest(registry, contract.asV3);
91+
92+
it('has the correct constructor flags', (): void => {
93+
expect(
94+
latest.spec.constructors[0].payable.isTrue
95+
).toEqual(false);
96+
expect(
97+
latest.spec.constructors[1].payable.isTrue
98+
).toEqual(true);
99+
});
100+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"info": "Plain",
4+
"lookupIndex": 0,
5+
"type": "bool",
6+
"docs": [],
7+
"namespace": ""
8+
}
9+
]

packages/api-contract/src/test/contracts/ink/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import { createVersionedExport } from '../util';
55
import * as v0 from './v0';
66
import * as v1 from './v1';
77
import * as v2 from './v2';
8+
import * as v3 from './v3';
89

9-
export default createVersionedExport({ v0, v1, v2 });
10+
export default createVersionedExport({ v0, v1, v2, v3 });
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"source": {
3+
"hash": "0xbb381c2fc980121b17c7b2bf2756d5964a12151cb846e0a9eff9cc337806456d",
4+
"language": "ink! 3.0.0-rc7",
5+
"compiler": "rustc 1.60.0-nightly",
6+
"wasm": "0x0061736d0100000001280860027f7f0060000060037f7f7f0060017f006000017f60017f017f60037f7f7f017f60017f017e02880106057365616c30107365616c5f7365745f73746f726167650002057365616c30107365616c5f6765745f73746f726167650006057365616c300a7365616c5f696e7075740000057365616c300b7365616c5f72657475726e0002057365616c30167365616c5f76616c75655f7472616e73666572726564000003656e76066d656d6f727902010210030a090400050103070001000608017f01418080040b071102066465706c6f7900080463616c6c000c0ac40b096102027f027e230041206b22002400200041106a22014200370300200042003703082000411036021c200041086a2000411c6a1004200028021c41114f0440000b2001290300210220002903082103200041206a2400410541042002200384501b0bc20101027f230041306b220224004101210302402000027f20014101714504404104100541ff01714105470d011a0b200241106a4200370300200241186a4200370300200241206a42003703002002420037030820024201370300200241808001360228200241086a41808004200241286a100120022802282201418180014f720d012002200136022c200241808004360228200241286a100741ff017122014102460d014100210320014100470b3a0001200020033a0000200241306a24000f0b000b4201027f230041106b22012400200141086a2000100d20012d0009210020012d00082102200141106a240041024101410220004101461b410020001b20024101711b0bd30202057f027e230041306b2200240020004180800136020c200041808004360208200041086a1009200020002903083703100240200041106a100a22054201832206a70d00200542807e8342002006501b22064280feffffff1f832205422088a721012005421888a721022005421088a7210302402006a741087641ff0171220441ed014704402004419b0147200341ff017141ae014772200241ff0171419d0147200141de004772720d02200041106a100741ff017122014102460d02100541ff01714105470d02200041286a4200370300200041206a4200370300200041186a4200370300200042003703102001410171200041106a100b0c010b200341ff017141cb0047200241ff0171419d0147722001411b47720d01200041286a4200370300200041206a4200370300200041186a4200370300200042003703104100200041106a100b0b200041306a24000f0b000b4101027f230041106b2201240020012000280204220236020c20002802002001410c6a10022002200128020c2202490440000b20002002360204200141106a24000b850102027f017e230041106b220124002001420437030841042102027f02400240034020012000100d20012d00004101710d01200141086a20026a20012d00013a0000200241016a22024108470d000b20012903082203a741044f0d01000b4101210241000c010b410021022003422088a70b2100200141106a24002002ad2000ad420886840b6b01017f230041306b220224004180800420003a0000200241286a200141186a290000370300200241206a200141106a290000370300200241186a200141086a2900003703002002420137030820022001290000370310200241106a4180800441011000200241306a24000b910302057f027e230041406a22002400024002400240100541ff01714105470d0020004180800136021c200041808004360218200041186a100920002000290318370320027f0240200041206a100a22054201832206a70d00200542807e8342002006501b22064280feffffff1f832205422088a721022005421888a721012005421088a721032006a741087641ff01712204412f470440200441e30047200341ff0171413a4772200141ff017141a50147200241d1004772720d014101210141000c020b200341ff017141860147200141ff017141db0047720d00410021014100200241d901460d011a0b4101210141010b0d00024020010440200041086a418002100620002d0009210120002d00084101710d01200041386a4200370300200041306a4200370300200041286a4200370300200042003703202001417f73410171200041206a100b0c040b200041106a4100100620002d0011210120002d0010410171450d020b20014105460d020b000b4180800420014101713a000041004180800441011003000b200041406b24000b3c01017f200020012802042202047f2001200241016b36020420012001280200220141016a36020020012d00000520010b3a000120002002453a00000b"
7+
},
8+
"contract": {
9+
"name": "flipper",
10+
"version": "3.0.0-rc7",
11+
"authors": [
12+
"Parity Technologies <[email protected]>"
13+
]
14+
},
15+
"V3": {
16+
"spec": {
17+
"constructors": [
18+
{
19+
"args": [
20+
{
21+
"label": "init_value",
22+
"type": {
23+
"displayName": [
24+
"bool"
25+
],
26+
"type": 0
27+
}
28+
}
29+
],
30+
"docs": [
31+
"Creates a new flipper smart contract initialized with the given value."
32+
],
33+
"label": "new",
34+
"payable": false,
35+
"selector": "0x9bae9d5e"
36+
},
37+
{
38+
"args": [],
39+
"docs": [
40+
"Creates a new flipper smart contract initialized to `false`."
41+
],
42+
"label": "default",
43+
"payable": true,
44+
"selector": "0xed4b9d1b"
45+
}
46+
],
47+
"docs": [],
48+
"events": [],
49+
"messages": [
50+
{
51+
"args": [],
52+
"docs": [
53+
" Flips the current value of the Flipper's boolean."
54+
],
55+
"label": "flip",
56+
"mutates": true,
57+
"payable": false,
58+
"returnType": null,
59+
"selector": "0x633aa551"
60+
},
61+
{
62+
"args": [],
63+
"docs": [
64+
" Returns the current value of the Flipper's boolean."
65+
],
66+
"label": "get",
67+
"mutates": false,
68+
"payable": false,
69+
"returnType": {
70+
"displayName": [
71+
"bool"
72+
],
73+
"type": 0
74+
},
75+
"selector": "0x2f865bd9"
76+
}
77+
]
78+
},
79+
"storage": {
80+
"struct": {
81+
"fields": [
82+
{
83+
"layout": {
84+
"cell": {
85+
"key": "0x0000000000000000000000000000000000000000000000000000000000000000",
86+
"ty": 0
87+
}
88+
},
89+
"name": "value"
90+
}
91+
]
92+
}
93+
},
94+
"types": [
95+
{
96+
"id": 0,
97+
"type": {
98+
"def": {
99+
"primitive": "bool"
100+
}
101+
}
102+
}
103+
]
104+
}
105+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright 2017-2022 @polkadot/api-contract authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export { default as flipper } from './flipper.contract.json';

0 commit comments

Comments
 (0)