@taqueria/plugin-contract-types 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunk-GC2KSB5D.js +226 -0
- package/chunk-GC2KSB5D.js.map +1 -0
- package/chunk-T4SGVAIL.js +604 -0
- package/chunk-T4SGVAIL.js.map +1 -0
- package/example/test-generation/example-contract-0.jest-demo.ts +78 -0
- package/example/test-generation/example-contract-1.jest-demo.ts +196 -0
- package/example/test-generation/example-contract-10.jest-demo.ts +47 -0
- package/example/test-generation/example-contract-11.jest-demo.ts +48 -0
- package/example/test-generation/example-contract-2.jest-demo.ts +277 -0
- package/example/test-generation/example-contract-4.jest-demo.ts +203 -0
- package/example/test-generation/example-contract-5.jest-demo.ts +235 -0
- package/example/test-generation/example-contract-6.jest-demo.ts +277 -0
- package/example/test-generation/example-contract-7.jest-demo.ts +170 -0
- package/example/test-generation/example-contract-8.jest-demo.ts +227 -0
- package/example/test-generation/example-contract-9.jest-demo.ts +42 -0
- package/example/types-file/example-contract-10.types.ts +2 -2
- package/example/types-file/example-contract-11.types.ts +2 -2
- package/example/types-file/type-aliases.ts +4 -0
- package/index.cjs +920 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +78 -882
- package/index.js.map +1 -1
- package/index.ts +1 -0
- package/package.json +27 -12
- package/src/cli-process.cjs +848 -0
- package/src/cli-process.cjs.map +1 -0
- package/src/cli-process.d.ts +9 -0
- package/src/cli-process.js +8 -0
- package/src/cli-process.js.map +1 -0
- package/src/generator/process.ts +37 -13
- package/src/generator/testing-code-generator-jest-demo.ts +75 -0
- package/src/generator/testing-code-generator.cjs +613 -0
- package/src/generator/testing-code-generator.cjs.map +1 -0
- package/src/generator/testing-code-generator.d.ts +79 -0
- package/src/generator/testing-code-generator.js +131 -0
- package/src/generator/testing-code-generator.js.map +1 -0
- package/src/generator/testing-code-generator.ts +282 -0
- package/src/generator/typescript-output.ts +136 -14
- package/src/type-aliases.ts +1 -0
- package/tsconfig.json +4 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
|
|
2
|
+
import { TezosToolkit } from '@taquito/taquito';
|
|
3
|
+
import { char2Bytes } from '@taquito/utils';
|
|
4
|
+
import { tas } from '../types-file/type-aliases';
|
|
5
|
+
import { ExampleContract8ContractType as ContractType } from '../types-file/example-contract-8.types';
|
|
6
|
+
import { ExampleContract8Code as ContractCode } from '../types-file/example-contract-8.code';
|
|
7
|
+
|
|
8
|
+
describe('example-contract-8', () => {
|
|
9
|
+
const Tezos = new TezosToolkit('RPC_URL');
|
|
10
|
+
let contract: ContractType = undefined as unknown as ContractType;
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
|
|
13
|
+
const newContractOrigination = await Tezos.contract.originate<ContractType>({
|
|
14
|
+
code: ContractCode.code,
|
|
15
|
+
storage: {
|
|
16
|
+
entries: tas.bigMap([{
|
|
17
|
+
key: tas.nat('42'),
|
|
18
|
+
value: (
|
|
19
|
+
{ waiting01: tas.unit() }
|
|
20
|
+
| { waiting02: tas.unit() }
|
|
21
|
+
| { p1: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456') }
|
|
22
|
+
| { p2: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456') }
|
|
23
|
+
| {
|
|
24
|
+
finished: {
|
|
25
|
+
bob: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
26
|
+
result: (
|
|
27
|
+
{ result1: tas.unit() }
|
|
28
|
+
| { result2: tas.unit() }
|
|
29
|
+
| { ok: tas.unit() }
|
|
30
|
+
),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
| { cancelled: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456') }
|
|
34
|
+
),
|
|
35
|
+
}]),
|
|
36
|
+
alice: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
37
|
+
caleb: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
38
|
+
dodge: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
39
|
+
count: tas.nat('42'),
|
|
40
|
+
free: true,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const newContractResult = await newContractOrigination.contract();
|
|
44
|
+
const newContractAddress = newContractResult.address;
|
|
45
|
+
contract = await Tezos.contract.at<ContractType>(newContractAddress);
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
it('should call make', async () => {
|
|
51
|
+
|
|
52
|
+
const getStorageValue = async () => {
|
|
53
|
+
const storage = await contract.storage();
|
|
54
|
+
const value = storage;
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const storageValueBefore = await getStorageValue();
|
|
59
|
+
|
|
60
|
+
const makeRequest = await contract.methodsObject.make({
|
|
61
|
+
id: tas.nat('42'),
|
|
62
|
+
p1: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
63
|
+
fee: tas.mutez('42'),
|
|
64
|
+
otherFee: tas.mutez('42'),
|
|
65
|
+
}).send();
|
|
66
|
+
await makeRequest.confirmation(3);
|
|
67
|
+
|
|
68
|
+
const storageValueAfter = await getStorageValue();
|
|
69
|
+
|
|
70
|
+
expect(storageValueAfter).toBe('');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should call join', async () => {
|
|
74
|
+
|
|
75
|
+
const getStorageValue = async () => {
|
|
76
|
+
const storage = await contract.storage();
|
|
77
|
+
const value = storage;
|
|
78
|
+
return value;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const storageValueBefore = await getStorageValue();
|
|
82
|
+
|
|
83
|
+
const joinRequest = await contract.methodsObject.join(tas.nat('42')).send();
|
|
84
|
+
await joinRequest.confirmation(3);
|
|
85
|
+
|
|
86
|
+
const storageValueAfter = await getStorageValue();
|
|
87
|
+
|
|
88
|
+
expect(storageValueAfter).toBe('');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should call register2', async () => {
|
|
92
|
+
|
|
93
|
+
const getStorageValue = async () => {
|
|
94
|
+
const storage = await contract.storage();
|
|
95
|
+
const value = storage;
|
|
96
|
+
return value;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const storageValueBefore = await getStorageValue();
|
|
100
|
+
|
|
101
|
+
const register2Request = await contract.methodsObject.register2({
|
|
102
|
+
id: tas.nat('42'),
|
|
103
|
+
p2: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
104
|
+
}).send();
|
|
105
|
+
await register2Request.confirmation(3);
|
|
106
|
+
|
|
107
|
+
const storageValueAfter = await getStorageValue();
|
|
108
|
+
|
|
109
|
+
expect(storageValueAfter).toBe('');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should call accept', async () => {
|
|
113
|
+
|
|
114
|
+
const getStorageValue = async () => {
|
|
115
|
+
const storage = await contract.storage();
|
|
116
|
+
const value = storage;
|
|
117
|
+
return value;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const storageValueBefore = await getStorageValue();
|
|
121
|
+
|
|
122
|
+
const acceptRequest = await contract.methodsObject.accept({
|
|
123
|
+
id: tas.nat('42'),
|
|
124
|
+
result: (
|
|
125
|
+
{ result1: tas.unit() }
|
|
126
|
+
| { result2: tas.unit() }
|
|
127
|
+
| { ok: tas.unit() }
|
|
128
|
+
),
|
|
129
|
+
}).send();
|
|
130
|
+
await acceptRequest.confirmation(3);
|
|
131
|
+
|
|
132
|
+
const storageValueAfter = await getStorageValue();
|
|
133
|
+
|
|
134
|
+
expect(storageValueAfter).toBe('');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should call cancel', async () => {
|
|
138
|
+
|
|
139
|
+
const getStorageValue = async () => {
|
|
140
|
+
const storage = await contract.storage();
|
|
141
|
+
const value = storage;
|
|
142
|
+
return value;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const storageValueBefore = await getStorageValue();
|
|
146
|
+
|
|
147
|
+
const cancelRequest = await contract.methodsObject.cancel(tas.nat('42')).send();
|
|
148
|
+
await cancelRequest.confirmation(3);
|
|
149
|
+
|
|
150
|
+
const storageValueAfter = await getStorageValue();
|
|
151
|
+
|
|
152
|
+
expect(storageValueAfter).toBe('');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should call setAuth', async () => {
|
|
156
|
+
|
|
157
|
+
const getStorageValue = async () => {
|
|
158
|
+
const storage = await contract.storage();
|
|
159
|
+
const value = storage;
|
|
160
|
+
return value;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const storageValueBefore = await getStorageValue();
|
|
164
|
+
|
|
165
|
+
const setAuthRequest = await contract.methodsObject.setAuth(tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456')).send();
|
|
166
|
+
await setAuthRequest.confirmation(3);
|
|
167
|
+
|
|
168
|
+
const storageValueAfter = await getStorageValue();
|
|
169
|
+
|
|
170
|
+
expect(storageValueAfter).toBe('');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should call confirmAuth', async () => {
|
|
174
|
+
|
|
175
|
+
const getStorageValue = async () => {
|
|
176
|
+
const storage = await contract.storage();
|
|
177
|
+
const value = storage;
|
|
178
|
+
return value;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const storageValueBefore = await getStorageValue();
|
|
182
|
+
|
|
183
|
+
const confirmAuthRequest = await contract.methodsObject.confirmAuth().send();
|
|
184
|
+
await confirmAuthRequest.confirmation(3);
|
|
185
|
+
|
|
186
|
+
const storageValueAfter = await getStorageValue();
|
|
187
|
+
|
|
188
|
+
expect(storageValueAfter).toBe('');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should call setCollector', async () => {
|
|
192
|
+
|
|
193
|
+
const getStorageValue = async () => {
|
|
194
|
+
const storage = await contract.storage();
|
|
195
|
+
const value = storage;
|
|
196
|
+
return value;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const storageValueBefore = await getStorageValue();
|
|
200
|
+
|
|
201
|
+
const setCollectorRequest = await contract.methodsObject.setCollector(tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456')).send();
|
|
202
|
+
await setCollectorRequest.confirmation(3);
|
|
203
|
+
|
|
204
|
+
const storageValueAfter = await getStorageValue();
|
|
205
|
+
|
|
206
|
+
expect(storageValueAfter).toBe('');
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should call free', async () => {
|
|
210
|
+
|
|
211
|
+
const getStorageValue = async () => {
|
|
212
|
+
const storage = await contract.storage();
|
|
213
|
+
const value = storage;
|
|
214
|
+
return value;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const storageValueBefore = await getStorageValue();
|
|
218
|
+
|
|
219
|
+
const freeRequest = await contract.methodsObject.free().send();
|
|
220
|
+
await freeRequest.confirmation(3);
|
|
221
|
+
|
|
222
|
+
const storageValueAfter = await getStorageValue();
|
|
223
|
+
|
|
224
|
+
expect(storageValueAfter).toBe('');
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import { TezosToolkit } from '@taquito/taquito';
|
|
3
|
+
import { char2Bytes } from '@taquito/utils';
|
|
4
|
+
import { tas } from '../types-file/type-aliases';
|
|
5
|
+
import { ExampleContract9ContractType as ContractType } from '../types-file/example-contract-9.types';
|
|
6
|
+
import { ExampleContract9Code as ContractCode } from '../types-file/example-contract-9.code';
|
|
7
|
+
|
|
8
|
+
describe('example-contract-9', () => {
|
|
9
|
+
const Tezos = new TezosToolkit('RPC_URL');
|
|
10
|
+
let contract: ContractType = undefined as unknown as ContractType;
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
|
|
13
|
+
const newContractOrigination = await Tezos.contract.originate<ContractType>({
|
|
14
|
+
code: ContractCode.code,
|
|
15
|
+
storage: {
|
|
16
|
+
0: tas.bigMap([{
|
|
17
|
+
key: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
18
|
+
value: {
|
|
19
|
+
0: tas.nat('42'),
|
|
20
|
+
1: tas.map([{
|
|
21
|
+
key: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
22
|
+
value: tas.nat('42'),
|
|
23
|
+
}]),
|
|
24
|
+
},
|
|
25
|
+
}]),
|
|
26
|
+
1: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456'),
|
|
27
|
+
2: true,
|
|
28
|
+
3: tas.nat('42'),
|
|
29
|
+
4: (
|
|
30
|
+
{ 0: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456') }
|
|
31
|
+
| { 1: tas.address('tz1ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456') }
|
|
32
|
+
),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const newContractResult = await newContractOrigination.contract();
|
|
36
|
+
const newContractAddress = newContractResult.address;
|
|
37
|
+
contract = await Tezos.contract.at<ContractType>(newContractAddress);
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
});
|
|
@@ -7,14 +7,14 @@ type Storage = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
type Methods = {
|
|
10
|
-
|
|
10
|
+
default: (
|
|
11
11
|
_0: nat,
|
|
12
12
|
_1: bytes,
|
|
13
13
|
) => Promise<void>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
type MethodsObject = {
|
|
17
|
-
|
|
17
|
+
default: (params: {
|
|
18
18
|
0: nat,
|
|
19
19
|
1: bytes,
|
|
20
20
|
}) => Promise<void>;
|
|
@@ -7,7 +7,7 @@ type Storage = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
type Methods = {
|
|
10
|
-
|
|
10
|
+
default: (param: Array<{
|
|
11
11
|
token_id: nat;
|
|
12
12
|
ipfs_hash: bytes;
|
|
13
13
|
owner: address;
|
|
@@ -15,7 +15,7 @@ type Methods = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
type MethodsObject = {
|
|
18
|
-
|
|
18
|
+
default: (param: Array<{
|
|
19
19
|
token_id: nat;
|
|
20
20
|
ipfs_hash: bytes;
|
|
21
21
|
owner: address;
|
|
@@ -25,6 +25,8 @@ type MapKey = Array<any> | object | string | boolean | number;
|
|
|
25
25
|
export type MMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => V };
|
|
26
26
|
export type BigMap<K extends MapKey, V> = Omit<MichelsonMap<K, V>, 'get'> & { get: (key: K) => Promise<V> };
|
|
27
27
|
|
|
28
|
+
export type chest = string & { __type: 'chest' };
|
|
29
|
+
export type chest_key = string & { __type: 'chest_key' };
|
|
28
30
|
|
|
29
31
|
const createStringTypeTas = <T extends string>() => {
|
|
30
32
|
return (value: string): T => value as T;
|
|
@@ -63,6 +65,8 @@ export const tas = {
|
|
|
63
65
|
address: createStringTypeTas<address>(),
|
|
64
66
|
bytes: createStringTypeTas<bytes>(),
|
|
65
67
|
contract: createStringTypeTas<contract>(),
|
|
68
|
+
chest: createStringTypeTas<chest>(),
|
|
69
|
+
chest_key: createStringTypeTas<chest_key>(),
|
|
66
70
|
timestamp: (value: string | Date): timestamp => new Date(value).toISOString() as timestamp,
|
|
67
71
|
|
|
68
72
|
int: createBigNumberTypeTas<int>(),
|