@xelis/sdk 0.11.36 → 0.11.38
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/dist/cjs/contract/contract.js +1 -1
- package/dist/cjs/contract/typed_contract.js +2 -2
- package/dist/cjs/contract/xvm_serializer.js +81 -58
- package/dist/esm/contract/contract.js +1 -1
- package/dist/esm/contract/typed_contract.js +2 -2
- package/dist/esm/contract/xvm_serializer.js +79 -56
- package/dist/types/contract/contract.d.ts +1 -1
- package/dist/types/contract/typed_contract.d.ts +1 -1
- package/dist/types/contract/xvm_serializer.d.ts +17 -15
- package/dist/types/daemon/types.d.ts +5 -4
- package/package.json +1 -1
|
@@ -142,7 +142,7 @@ class TypedContract {
|
|
|
142
142
|
}
|
|
143
143
|
const invocation_params = {
|
|
144
144
|
contract: this.address,
|
|
145
|
-
|
|
145
|
+
entry_id: entry.entry_id,
|
|
146
146
|
parameters,
|
|
147
147
|
permission,
|
|
148
148
|
maxGas: maxGas || 50000000
|
|
@@ -270,7 +270,7 @@ function validate_abi(abi) {
|
|
|
270
270
|
if (typeof entry !== 'object' || !entry) {
|
|
271
271
|
return false;
|
|
272
272
|
}
|
|
273
|
-
if (typeof entry.
|
|
273
|
+
if (typeof entry.entry_id !== 'number') {
|
|
274
274
|
return false;
|
|
275
275
|
}
|
|
276
276
|
if (typeof entry.name !== 'string') {
|
|
@@ -1,49 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createContractDeployment = exports.createContractInvocation = exports.
|
|
3
|
+
exports.createContractDeployment = exports.createContractInvocation = exports.create_deposits = exports.createVMParameter = exports.typeRegistry = exports.defineStruct = exports.defineEnum = exports.VMParam = exports.serialize_optional = exports.serialize_map = exports.serialize_array = exports.createVMPrimitive = void 0;
|
|
4
|
+
function toBigIntStrict(v, label) {
|
|
5
|
+
if (typeof v === "bigint")
|
|
6
|
+
return v;
|
|
7
|
+
if (typeof v === "number") {
|
|
8
|
+
if (!Number.isFinite(v) || !Number.isInteger(v)) {
|
|
9
|
+
throw new Error(`${label} must be a finite integer number`);
|
|
10
|
+
}
|
|
11
|
+
return BigInt(v);
|
|
12
|
+
}
|
|
13
|
+
if (typeof v === "string") {
|
|
14
|
+
if (!/^-?\d+$/.test(v.trim())) {
|
|
15
|
+
throw new Error(`${label} must be a base-10 integer string`);
|
|
16
|
+
}
|
|
17
|
+
return BigInt(v.trim());
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return BigInt(v);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error(`${label} is not convertible to bigint`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
4
26
|
// Known opaque types that need special wrapping
|
|
5
27
|
const OPAQUE_TYPES = new Set(['Hash', 'Address', 'PublicKey', 'Blob']);
|
|
28
|
+
const MAX_U32 = 0xffffffffn;
|
|
29
|
+
const MAX_U16 = 0xffffn;
|
|
30
|
+
const MAX_U8 = 255n;
|
|
31
|
+
const MAX_U64 = 0xffffffffffffffffn;
|
|
6
32
|
// Type validation and conversion helpers
|
|
7
33
|
const TYPE_VALIDATORS = {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
34
|
+
u256: (v) => {
|
|
35
|
+
const n = toBigIntStrict(v, "u256");
|
|
36
|
+
if (n < 0n)
|
|
11
37
|
throw new Error(`Value ${v} cannot be negative for u256`);
|
|
12
|
-
return
|
|
38
|
+
return n.toString(10);
|
|
13
39
|
},
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
40
|
+
u128: (v) => {
|
|
41
|
+
const n = toBigIntStrict(v, "u128");
|
|
42
|
+
if (n < 0n)
|
|
17
43
|
throw new Error(`Value ${v} cannot be negative for u128`);
|
|
18
|
-
return
|
|
44
|
+
return n.toString(10);
|
|
19
45
|
},
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
46
|
+
u64: (v) => {
|
|
47
|
+
const n = toBigIntStrict(v, "u64");
|
|
48
|
+
if (n < 0n || n > MAX_U64)
|
|
23
49
|
throw new Error(`Value ${v} is out of range for u64`);
|
|
24
|
-
|
|
25
|
-
return Number(num);
|
|
50
|
+
return n.toString(10);
|
|
26
51
|
},
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
throw new Error(`Value ${v} is
|
|
31
|
-
|
|
32
|
-
return num;
|
|
52
|
+
u32: (v) => {
|
|
53
|
+
const n = toBigIntStrict(v, "u32");
|
|
54
|
+
if (n < 0n || n > MAX_U32)
|
|
55
|
+
throw new Error(`Value ${v} is out of range for u32`);
|
|
56
|
+
return Number(n);
|
|
33
57
|
},
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
throw new Error(`Value ${v} is
|
|
38
|
-
|
|
39
|
-
return num;
|
|
58
|
+
u16: (v) => {
|
|
59
|
+
const n = toBigIntStrict(v, "u16");
|
|
60
|
+
if (n < 0n || n > MAX_U16)
|
|
61
|
+
throw new Error(`Value ${v} is out of range for u16`);
|
|
62
|
+
return Number(n);
|
|
40
63
|
},
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
throw new Error(`Value ${v} is
|
|
45
|
-
|
|
46
|
-
return num;
|
|
64
|
+
u8: (v) => {
|
|
65
|
+
const n = toBigIntStrict(v, "u8");
|
|
66
|
+
if (n < 0n || n > MAX_U8)
|
|
67
|
+
throw new Error(`Value ${v} is out of range for u8`);
|
|
68
|
+
return Number(n);
|
|
47
69
|
},
|
|
48
70
|
'boolean': (v) => Boolean(v),
|
|
49
71
|
'string': (v) => String(v),
|
|
@@ -78,7 +100,6 @@ const TYPE_VALIDATORS = {
|
|
|
78
100
|
*/
|
|
79
101
|
function createVMPrimitive(value, type, validate = true) {
|
|
80
102
|
let processed_value = value;
|
|
81
|
-
// Validate and convert value if requested
|
|
82
103
|
if (validate && TYPE_VALIDATORS[type]) {
|
|
83
104
|
try {
|
|
84
105
|
processed_value = TYPE_VALIDATORS[type](value);
|
|
@@ -87,26 +108,26 @@ function createVMPrimitive(value, type, validate = true) {
|
|
|
87
108
|
throw new Error(`Failed to create VM parameter for type ${type}: ${error}`);
|
|
88
109
|
}
|
|
89
110
|
}
|
|
90
|
-
// Handle opaque types (Hash, Address, PublicKey)
|
|
111
|
+
// Handle opaque types (Hash, Address, PublicKey, Blob)
|
|
91
112
|
if (OPAQUE_TYPES.has(type)) {
|
|
92
113
|
return {
|
|
93
114
|
type: "primitive",
|
|
94
115
|
value: {
|
|
95
116
|
type: "opaque",
|
|
96
117
|
value: {
|
|
97
|
-
type
|
|
98
|
-
value: processed_value
|
|
99
|
-
}
|
|
100
|
-
}
|
|
118
|
+
type,
|
|
119
|
+
value: processed_value,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
101
122
|
};
|
|
102
123
|
}
|
|
103
|
-
// Handle regular
|
|
124
|
+
// Handle regular primitives
|
|
104
125
|
return {
|
|
105
126
|
type: "primitive",
|
|
106
127
|
value: {
|
|
107
|
-
type
|
|
108
|
-
value: processed_value
|
|
109
|
-
}
|
|
128
|
+
type,
|
|
129
|
+
value: processed_value,
|
|
130
|
+
},
|
|
110
131
|
};
|
|
111
132
|
}
|
|
112
133
|
exports.createVMPrimitive = createVMPrimitive;
|
|
@@ -157,16 +178,18 @@ exports.serialize_optional = serialize_optional;
|
|
|
157
178
|
* Convenience functions for common types
|
|
158
179
|
*/
|
|
159
180
|
exports.VMParam = {
|
|
160
|
-
hash: (value) => createVMPrimitive(value,
|
|
161
|
-
address: (value) => createVMPrimitive(value,
|
|
162
|
-
public_key: (value) => createVMPrimitive(value,
|
|
163
|
-
blob: (value) => createVMPrimitive(value,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
hash: (value) => createVMPrimitive(value, "Hash"),
|
|
182
|
+
address: (value) => createVMPrimitive(value, "Address"),
|
|
183
|
+
public_key: (value) => createVMPrimitive(value, "PublicKey"),
|
|
184
|
+
blob: (value) => createVMPrimitive(value, "Blob"),
|
|
185
|
+
u256: (value) => createVMPrimitive(value, "u256"),
|
|
186
|
+
u128: (value) => createVMPrimitive(value, "u128"),
|
|
187
|
+
u64: (value) => createVMPrimitive(value, "u64"),
|
|
188
|
+
u32: (value) => createVMPrimitive(value, "u32"),
|
|
189
|
+
u16: (value) => createVMPrimitive(value, "u16"),
|
|
190
|
+
u8: (value) => createVMPrimitive(value, "u8"),
|
|
191
|
+
string: (value) => createVMPrimitive(value, "string"),
|
|
192
|
+
boolean: (value) => createVMPrimitive(value, "boolean"),
|
|
170
193
|
};
|
|
171
194
|
/**
|
|
172
195
|
* Define an enum type from ABI schema
|
|
@@ -351,7 +374,7 @@ exports.createVMParameter = createVMParameter;
|
|
|
351
374
|
* Creates a deposits object for contract calls
|
|
352
375
|
* @param deposits - Object mapping token hashes to amounts
|
|
353
376
|
*/
|
|
354
|
-
function
|
|
377
|
+
function create_deposits(deposits) {
|
|
355
378
|
const result = {};
|
|
356
379
|
for (const [token_hash, amount] of Object.entries(deposits)) {
|
|
357
380
|
// Validate hash format
|
|
@@ -362,20 +385,20 @@ function createDeposits(deposits) {
|
|
|
362
385
|
}
|
|
363
386
|
return result;
|
|
364
387
|
}
|
|
365
|
-
exports.
|
|
388
|
+
exports.create_deposits = create_deposits;
|
|
366
389
|
function createContractInvocation(params) {
|
|
367
|
-
const { contract,
|
|
390
|
+
const { contract, entry_id, parameters = [], deposits, permission, maxGas = 50000000 } = params;
|
|
368
391
|
const result = {
|
|
369
392
|
invoke_contract: {
|
|
370
393
|
contract,
|
|
371
394
|
max_gas: maxGas,
|
|
372
|
-
entry_id:
|
|
395
|
+
entry_id: entry_id,
|
|
373
396
|
permission,
|
|
374
397
|
parameters
|
|
375
398
|
}
|
|
376
399
|
};
|
|
377
400
|
if (deposits && Object.keys(deposits).length > 0) {
|
|
378
|
-
result.invoke_contract.deposits =
|
|
401
|
+
result.invoke_contract.deposits = create_deposits(deposits);
|
|
379
402
|
}
|
|
380
403
|
return result;
|
|
381
404
|
}
|
|
@@ -385,7 +408,7 @@ function createContractDeployment(params) {
|
|
|
385
408
|
const result = {
|
|
386
409
|
deploy_contract: {
|
|
387
410
|
module: bytecode,
|
|
388
|
-
...(hasConstructor && { invoke: { maxGas } })
|
|
411
|
+
...(hasConstructor && { invoke: { max_gas: maxGas } })
|
|
389
412
|
}
|
|
390
413
|
};
|
|
391
414
|
return result;
|
|
@@ -139,7 +139,7 @@ export class TypedContract {
|
|
|
139
139
|
}
|
|
140
140
|
const invocation_params = {
|
|
141
141
|
contract: this.address,
|
|
142
|
-
|
|
142
|
+
entry_id: entry.entry_id,
|
|
143
143
|
parameters,
|
|
144
144
|
permission,
|
|
145
145
|
maxGas: maxGas || 50000000
|
|
@@ -264,7 +264,7 @@ export function validate_abi(abi) {
|
|
|
264
264
|
if (typeof entry !== 'object' || !entry) {
|
|
265
265
|
return false;
|
|
266
266
|
}
|
|
267
|
-
if (typeof entry.
|
|
267
|
+
if (typeof entry.entry_id !== 'number') {
|
|
268
268
|
return false;
|
|
269
269
|
}
|
|
270
270
|
if (typeof entry.name !== 'string') {
|
|
@@ -1,46 +1,68 @@
|
|
|
1
|
+
function toBigIntStrict(v, label) {
|
|
2
|
+
if (typeof v === "bigint")
|
|
3
|
+
return v;
|
|
4
|
+
if (typeof v === "number") {
|
|
5
|
+
if (!Number.isFinite(v) || !Number.isInteger(v)) {
|
|
6
|
+
throw new Error(`${label} must be a finite integer number`);
|
|
7
|
+
}
|
|
8
|
+
return BigInt(v);
|
|
9
|
+
}
|
|
10
|
+
if (typeof v === "string") {
|
|
11
|
+
if (!/^-?\d+$/.test(v.trim())) {
|
|
12
|
+
throw new Error(`${label} must be a base-10 integer string`);
|
|
13
|
+
}
|
|
14
|
+
return BigInt(v.trim());
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
return BigInt(v);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error(`${label} is not convertible to bigint`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
1
23
|
// Known opaque types that need special wrapping
|
|
2
24
|
const OPAQUE_TYPES = new Set(['Hash', 'Address', 'PublicKey', 'Blob']);
|
|
25
|
+
const MAX_U32 = 0xffffffffn;
|
|
26
|
+
const MAX_U16 = 0xffffn;
|
|
27
|
+
const MAX_U8 = 255n;
|
|
28
|
+
const MAX_U64 = 0xffffffffffffffffn;
|
|
3
29
|
// Type validation and conversion helpers
|
|
4
30
|
const TYPE_VALIDATORS = {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
31
|
+
u256: (v) => {
|
|
32
|
+
const n = toBigIntStrict(v, "u256");
|
|
33
|
+
if (n < 0n)
|
|
8
34
|
throw new Error(`Value ${v} cannot be negative for u256`);
|
|
9
|
-
return
|
|
35
|
+
return n.toString(10);
|
|
10
36
|
},
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
37
|
+
u128: (v) => {
|
|
38
|
+
const n = toBigIntStrict(v, "u128");
|
|
39
|
+
if (n < 0n)
|
|
14
40
|
throw new Error(`Value ${v} cannot be negative for u128`);
|
|
15
|
-
return
|
|
41
|
+
return n.toString(10);
|
|
16
42
|
},
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
43
|
+
u64: (v) => {
|
|
44
|
+
const n = toBigIntStrict(v, "u64");
|
|
45
|
+
if (n < 0n || n > MAX_U64)
|
|
20
46
|
throw new Error(`Value ${v} is out of range for u64`);
|
|
21
|
-
|
|
22
|
-
return Number(num);
|
|
47
|
+
return n.toString(10);
|
|
23
48
|
},
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
throw new Error(`Value ${v} is
|
|
28
|
-
|
|
29
|
-
return num;
|
|
49
|
+
u32: (v) => {
|
|
50
|
+
const n = toBigIntStrict(v, "u32");
|
|
51
|
+
if (n < 0n || n > MAX_U32)
|
|
52
|
+
throw new Error(`Value ${v} is out of range for u32`);
|
|
53
|
+
return Number(n);
|
|
30
54
|
},
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
throw new Error(`Value ${v} is
|
|
35
|
-
|
|
36
|
-
return num;
|
|
55
|
+
u16: (v) => {
|
|
56
|
+
const n = toBigIntStrict(v, "u16");
|
|
57
|
+
if (n < 0n || n > MAX_U16)
|
|
58
|
+
throw new Error(`Value ${v} is out of range for u16`);
|
|
59
|
+
return Number(n);
|
|
37
60
|
},
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
throw new Error(`Value ${v} is
|
|
42
|
-
|
|
43
|
-
return num;
|
|
61
|
+
u8: (v) => {
|
|
62
|
+
const n = toBigIntStrict(v, "u8");
|
|
63
|
+
if (n < 0n || n > MAX_U8)
|
|
64
|
+
throw new Error(`Value ${v} is out of range for u8`);
|
|
65
|
+
return Number(n);
|
|
44
66
|
},
|
|
45
67
|
'boolean': (v) => Boolean(v),
|
|
46
68
|
'string': (v) => String(v),
|
|
@@ -75,7 +97,6 @@ const TYPE_VALIDATORS = {
|
|
|
75
97
|
*/
|
|
76
98
|
export function createVMPrimitive(value, type, validate = true) {
|
|
77
99
|
let processed_value = value;
|
|
78
|
-
// Validate and convert value if requested
|
|
79
100
|
if (validate && TYPE_VALIDATORS[type]) {
|
|
80
101
|
try {
|
|
81
102
|
processed_value = TYPE_VALIDATORS[type](value);
|
|
@@ -84,26 +105,26 @@ export function createVMPrimitive(value, type, validate = true) {
|
|
|
84
105
|
throw new Error(`Failed to create VM parameter for type ${type}: ${error}`);
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
|
-
// Handle opaque types (Hash, Address, PublicKey)
|
|
108
|
+
// Handle opaque types (Hash, Address, PublicKey, Blob)
|
|
88
109
|
if (OPAQUE_TYPES.has(type)) {
|
|
89
110
|
return {
|
|
90
111
|
type: "primitive",
|
|
91
112
|
value: {
|
|
92
113
|
type: "opaque",
|
|
93
114
|
value: {
|
|
94
|
-
type
|
|
95
|
-
value: processed_value
|
|
96
|
-
}
|
|
97
|
-
}
|
|
115
|
+
type,
|
|
116
|
+
value: processed_value,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
98
119
|
};
|
|
99
120
|
}
|
|
100
|
-
// Handle regular
|
|
121
|
+
// Handle regular primitives
|
|
101
122
|
return {
|
|
102
123
|
type: "primitive",
|
|
103
124
|
value: {
|
|
104
|
-
type
|
|
105
|
-
value: processed_value
|
|
106
|
-
}
|
|
125
|
+
type,
|
|
126
|
+
value: processed_value,
|
|
127
|
+
},
|
|
107
128
|
};
|
|
108
129
|
}
|
|
109
130
|
/**
|
|
@@ -150,16 +171,18 @@ export function serialize_optional(value, inner_type) {
|
|
|
150
171
|
* Convenience functions for common types
|
|
151
172
|
*/
|
|
152
173
|
export const VMParam = {
|
|
153
|
-
hash: (value) => createVMPrimitive(value,
|
|
154
|
-
address: (value) => createVMPrimitive(value,
|
|
155
|
-
public_key: (value) => createVMPrimitive(value,
|
|
156
|
-
blob: (value) => createVMPrimitive(value,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
hash: (value) => createVMPrimitive(value, "Hash"),
|
|
175
|
+
address: (value) => createVMPrimitive(value, "Address"),
|
|
176
|
+
public_key: (value) => createVMPrimitive(value, "PublicKey"),
|
|
177
|
+
blob: (value) => createVMPrimitive(value, "Blob"),
|
|
178
|
+
u256: (value) => createVMPrimitive(value, "u256"),
|
|
179
|
+
u128: (value) => createVMPrimitive(value, "u128"),
|
|
180
|
+
u64: (value) => createVMPrimitive(value, "u64"),
|
|
181
|
+
u32: (value) => createVMPrimitive(value, "u32"),
|
|
182
|
+
u16: (value) => createVMPrimitive(value, "u16"),
|
|
183
|
+
u8: (value) => createVMPrimitive(value, "u8"),
|
|
184
|
+
string: (value) => createVMPrimitive(value, "string"),
|
|
185
|
+
boolean: (value) => createVMPrimitive(value, "boolean"),
|
|
163
186
|
};
|
|
164
187
|
/**
|
|
165
188
|
* Define an enum type from ABI schema
|
|
@@ -341,7 +364,7 @@ export function createVMParameter(value, type, validate = true) {
|
|
|
341
364
|
* Creates a deposits object for contract calls
|
|
342
365
|
* @param deposits - Object mapping token hashes to amounts
|
|
343
366
|
*/
|
|
344
|
-
export function
|
|
367
|
+
export function create_deposits(deposits) {
|
|
345
368
|
const result = {};
|
|
346
369
|
for (const [token_hash, amount] of Object.entries(deposits)) {
|
|
347
370
|
// Validate hash format
|
|
@@ -353,18 +376,18 @@ export function createDeposits(deposits) {
|
|
|
353
376
|
return result;
|
|
354
377
|
}
|
|
355
378
|
export function createContractInvocation(params) {
|
|
356
|
-
const { contract,
|
|
379
|
+
const { contract, entry_id, parameters = [], deposits, permission, maxGas = 50000000 } = params;
|
|
357
380
|
const result = {
|
|
358
381
|
invoke_contract: {
|
|
359
382
|
contract,
|
|
360
383
|
max_gas: maxGas,
|
|
361
|
-
entry_id:
|
|
384
|
+
entry_id: entry_id,
|
|
362
385
|
permission,
|
|
363
386
|
parameters
|
|
364
387
|
}
|
|
365
388
|
};
|
|
366
389
|
if (deposits && Object.keys(deposits).length > 0) {
|
|
367
|
-
result.invoke_contract.deposits =
|
|
390
|
+
result.invoke_contract.deposits = create_deposits(deposits);
|
|
368
391
|
}
|
|
369
392
|
return result;
|
|
370
393
|
}
|
|
@@ -373,7 +396,7 @@ export function createContractDeployment(params) {
|
|
|
373
396
|
const result = {
|
|
374
397
|
deploy_contract: {
|
|
375
398
|
module: bytecode,
|
|
376
|
-
...(hasConstructor && { invoke: { maxGas } })
|
|
399
|
+
...(hasConstructor && { invoke: { max_gas: maxGas } })
|
|
377
400
|
}
|
|
378
401
|
};
|
|
379
402
|
return result;
|
|
@@ -3,9 +3,9 @@ export interface VMParameter {
|
|
|
3
3
|
value: any;
|
|
4
4
|
}
|
|
5
5
|
declare const TYPE_VALIDATORS: {
|
|
6
|
-
readonly u256: (v: any) =>
|
|
7
|
-
readonly u128: (v: any) =>
|
|
8
|
-
readonly u64: (v: any) =>
|
|
6
|
+
readonly u256: (v: any) => string;
|
|
7
|
+
readonly u128: (v: any) => string;
|
|
8
|
+
readonly u64: (v: any) => string;
|
|
9
9
|
readonly u32: (v: any) => number;
|
|
10
10
|
readonly u16: (v: any) => number;
|
|
11
11
|
readonly u8: (v: any) => number;
|
|
@@ -40,16 +40,18 @@ export declare function serialize_optional(value: any, inner_type: string): VMPa
|
|
|
40
40
|
* Convenience functions for common types
|
|
41
41
|
*/
|
|
42
42
|
export declare const VMParam: {
|
|
43
|
-
hash: (value: string) => VMParameter;
|
|
44
|
-
address: (value: string) => VMParameter;
|
|
45
|
-
public_key: (value: string) => VMParameter;
|
|
46
|
-
blob: (value: string) => VMParameter;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
readonly hash: (value: string) => VMParameter;
|
|
44
|
+
readonly address: (value: string) => VMParameter;
|
|
45
|
+
readonly public_key: (value: string) => VMParameter;
|
|
46
|
+
readonly blob: (value: string) => VMParameter;
|
|
47
|
+
readonly u256: (value: number | bigint | string) => VMParameter;
|
|
48
|
+
readonly u128: (value: number | bigint | string) => VMParameter;
|
|
49
|
+
readonly u64: (value: number | bigint | string) => VMParameter;
|
|
50
|
+
readonly u32: (value: number | bigint | string) => VMParameter;
|
|
51
|
+
readonly u16: (value: number | bigint | string) => VMParameter;
|
|
52
|
+
readonly u8: (value: number | bigint | string) => VMParameter;
|
|
53
|
+
readonly string: (value: string) => VMParameter;
|
|
54
|
+
readonly boolean: (value: boolean) => VMParameter;
|
|
53
55
|
};
|
|
54
56
|
/**
|
|
55
57
|
* A type that knows how to serialize itself to VMParameter
|
|
@@ -106,7 +108,7 @@ export declare function createVMParameter(value: any, type: string, validate?: b
|
|
|
106
108
|
* Creates a deposits object for contract calls
|
|
107
109
|
* @param deposits - Object mapping token hashes to amounts
|
|
108
110
|
*/
|
|
109
|
-
export declare function
|
|
111
|
+
export declare function create_deposits(deposits: Record<string, number | bigint>): Record<string, {
|
|
110
112
|
amount: number | bigint;
|
|
111
113
|
}>;
|
|
112
114
|
/**
|
|
@@ -114,7 +116,7 @@ export declare function createDeposits(deposits: Record<string, number | bigint>
|
|
|
114
116
|
*/
|
|
115
117
|
export interface ContractInvocationParams {
|
|
116
118
|
contract: string;
|
|
117
|
-
|
|
119
|
+
entry_id: number;
|
|
118
120
|
parameters?: VMParameter[];
|
|
119
121
|
permission: string;
|
|
120
122
|
deposits?: Record<string, number | bigint>;
|
|
@@ -16,6 +16,7 @@ export interface GetInfoResult {
|
|
|
16
16
|
mempool_size: number;
|
|
17
17
|
version: string;
|
|
18
18
|
network: string;
|
|
19
|
+
block_version: number;
|
|
19
20
|
}
|
|
20
21
|
export interface Block {
|
|
21
22
|
hash: string;
|
|
@@ -316,8 +317,8 @@ export interface Transaction {
|
|
|
316
317
|
data: TransactionData;
|
|
317
318
|
fee: number;
|
|
318
319
|
fee_limit: number;
|
|
319
|
-
fee_paid
|
|
320
|
-
fee_refund
|
|
320
|
+
fee_paid?: number;
|
|
321
|
+
fee_refund?: number;
|
|
321
322
|
nonce: number;
|
|
322
323
|
source_commitments: SourceCommitment[];
|
|
323
324
|
range_proof: number[];
|
|
@@ -635,7 +636,7 @@ export type Access = "all" | "internal" | {
|
|
|
635
636
|
export interface Module {
|
|
636
637
|
chunks: (Chunk | Access)[];
|
|
637
638
|
constants: any[];
|
|
638
|
-
|
|
639
|
+
hook_entry_ids: number[];
|
|
639
640
|
}
|
|
640
641
|
export interface GetContractModuleResult {
|
|
641
642
|
previous_topoheight: number | null;
|
|
@@ -754,7 +755,7 @@ export interface GetContractScheduledExecutionsAtTopoheightParams {
|
|
|
754
755
|
export interface ScheduledExecution {
|
|
755
756
|
hash: string;
|
|
756
757
|
contract: string;
|
|
757
|
-
|
|
758
|
+
entry_id: number;
|
|
758
759
|
params: any[];
|
|
759
760
|
max_gas: number;
|
|
760
761
|
}
|
package/package.json
CHANGED