@alephium/web3 1.12.0-beta.0 → 1.12.0-danube.1
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/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/address/address.d.ts +1 -0
- package/dist/src/address/address.js +45 -22
- package/dist/src/api/api-alephium.d.ts +78 -124
- package/dist/src/api/api-alephium.js +0 -50
- package/dist/src/api/node-provider.d.ts +0 -2
- package/dist/src/api/node-provider.js +0 -1
- package/dist/src/codec/instr-codec.d.ts +26 -10
- package/dist/src/codec/instr-codec.js +38 -18
- package/dist/src/contract/contract.d.ts +11 -6
- package/dist/src/contract/contract.js +35 -21
- package/dist/src/contract/deployment.d.ts +2 -0
- package/dist/src/signer/signer.d.ts +13 -13
- package/dist/src/signer/signer.js +84 -9
- package/dist/src/signer/tx-builder.d.ts +4 -10
- package/dist/src/signer/tx-builder.js +41 -67
- package/dist/src/signer/types.d.ts +14 -27
- package/dist/src/signer/types.js +0 -3
- package/dist/src/utils/sign.js +2 -2
- package/package.json +1 -1
- package/src/address/address.ts +50 -19
- package/src/api/api-alephium.ts +92 -172
- package/src/api/node-provider.ts +0 -3
- package/src/codec/instr-codec.ts +45 -21
- package/src/contract/contract.ts +45 -29
- package/src/contract/deployment.ts +2 -0
- package/src/signer/signer.ts +118 -24
- package/src/signer/tx-builder.ts +60 -99
- package/src/signer/types.ts +31 -39
- package/src/utils/sign.ts +2 -2
package/src/api/api-alephium.ts
CHANGED
|
@@ -206,7 +206,7 @@ export interface BuildChainedDeployContractTx {
|
|
|
206
206
|
|
|
207
207
|
/** BuildChainedDeployContractTxResult */
|
|
208
208
|
export interface BuildChainedDeployContractTxResult {
|
|
209
|
-
value:
|
|
209
|
+
value: BuildSimpleDeployContractTxResult
|
|
210
210
|
type: string
|
|
211
211
|
}
|
|
212
212
|
|
|
@@ -218,7 +218,7 @@ export interface BuildChainedExecuteScriptTx {
|
|
|
218
218
|
|
|
219
219
|
/** BuildChainedExecuteScriptTxResult */
|
|
220
220
|
export interface BuildChainedExecuteScriptTxResult {
|
|
221
|
-
value:
|
|
221
|
+
value: BuildSimpleExecuteScriptTxResult
|
|
222
222
|
type: string
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -230,7 +230,7 @@ export interface BuildChainedTransferTx {
|
|
|
230
230
|
|
|
231
231
|
/** BuildChainedTransferTxResult */
|
|
232
232
|
export interface BuildChainedTransferTxResult {
|
|
233
|
-
value:
|
|
233
|
+
value: BuildSimpleTransferTxResult
|
|
234
234
|
type: string
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -262,26 +262,14 @@ export interface BuildDeployContractTx {
|
|
|
262
262
|
gasAmount?: number
|
|
263
263
|
/** @format uint256 */
|
|
264
264
|
gasPrice?: string
|
|
265
|
+
/** @format group-index */
|
|
266
|
+
group?: number
|
|
265
267
|
/** @format block-hash */
|
|
266
268
|
targetBlockHash?: string
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
/** BuildDeployContractTxResult */
|
|
270
|
-
export
|
|
271
|
-
/** @format int32 */
|
|
272
|
-
fromGroup: number
|
|
273
|
-
/** @format int32 */
|
|
274
|
-
toGroup: number
|
|
275
|
-
unsignedTx: string
|
|
276
|
-
/** @format gas */
|
|
277
|
-
gasAmount: number
|
|
278
|
-
/** @format uint256 */
|
|
279
|
-
gasPrice: string
|
|
280
|
-
/** @format 32-byte-hash */
|
|
281
|
-
txId: string
|
|
282
|
-
/** @format address */
|
|
283
|
-
contractAddress: string
|
|
284
|
-
}
|
|
272
|
+
export type BuildDeployContractTxResult = BuildGrouplessDeployContractTxResult | BuildSimpleDeployContractTxResult
|
|
285
273
|
|
|
286
274
|
/** BuildExecuteScriptTx */
|
|
287
275
|
export interface BuildExecuteScriptTx {
|
|
@@ -300,80 +288,34 @@ export interface BuildExecuteScriptTx {
|
|
|
300
288
|
gasPrice?: string
|
|
301
289
|
/** @format block-hash */
|
|
302
290
|
targetBlockHash?: string
|
|
291
|
+
/** @format group-index */
|
|
292
|
+
group?: number
|
|
303
293
|
/** @format double */
|
|
304
294
|
gasEstimationMultiplier?: number
|
|
305
295
|
}
|
|
306
296
|
|
|
307
297
|
/** BuildExecuteScriptTxResult */
|
|
308
|
-
export
|
|
309
|
-
/** @format int32 */
|
|
310
|
-
fromGroup: number
|
|
311
|
-
/** @format int32 */
|
|
312
|
-
toGroup: number
|
|
313
|
-
unsignedTx: string
|
|
314
|
-
/** @format gas */
|
|
315
|
-
gasAmount: number
|
|
316
|
-
/** @format uint256 */
|
|
317
|
-
gasPrice: string
|
|
318
|
-
/** @format 32-byte-hash */
|
|
319
|
-
txId: string
|
|
320
|
-
simulationResult: SimulationResult
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/** BuildGrouplessDeployContractTx */
|
|
324
|
-
export interface BuildGrouplessDeployContractTx {
|
|
325
|
-
fromAddress: string
|
|
326
|
-
/** @format hex-string */
|
|
327
|
-
bytecode: string
|
|
328
|
-
/** @format uint256 */
|
|
329
|
-
initialAttoAlphAmount?: string
|
|
330
|
-
initialTokenAmounts?: Token[]
|
|
331
|
-
/** @format uint256 */
|
|
332
|
-
issueTokenAmount?: string
|
|
333
|
-
/** @format address */
|
|
334
|
-
issueTokenTo?: string
|
|
335
|
-
/** @format uint256 */
|
|
336
|
-
gasPrice?: string
|
|
337
|
-
/** @format block-hash */
|
|
338
|
-
targetBlockHash?: string
|
|
339
|
-
}
|
|
298
|
+
export type BuildExecuteScriptTxResult = BuildGrouplessExecuteScriptTxResult | BuildSimpleExecuteScriptTxResult
|
|
340
299
|
|
|
341
300
|
/** BuildGrouplessDeployContractTxResult */
|
|
342
301
|
export interface BuildGrouplessDeployContractTxResult {
|
|
343
|
-
transferTxs:
|
|
344
|
-
deployContractTx:
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/** BuildGrouplessExecuteScriptTx */
|
|
348
|
-
export interface BuildGrouplessExecuteScriptTx {
|
|
349
|
-
fromAddress: string
|
|
350
|
-
/** @format hex-string */
|
|
351
|
-
bytecode: string
|
|
352
|
-
/** @format uint256 */
|
|
353
|
-
attoAlphAmount?: string
|
|
354
|
-
tokens?: Token[]
|
|
355
|
-
/** @format uint256 */
|
|
356
|
-
gasPrice?: string
|
|
357
|
-
/** @format block-hash */
|
|
358
|
-
targetBlockHash?: string
|
|
359
|
-
/** @format double */
|
|
360
|
-
gasEstimationMultiplier?: number
|
|
302
|
+
transferTxs: BuildSimpleTransferTxResult[]
|
|
303
|
+
deployContractTx: BuildSimpleDeployContractTxResult
|
|
304
|
+
type: string
|
|
361
305
|
}
|
|
362
306
|
|
|
363
307
|
/** BuildGrouplessExecuteScriptTxResult */
|
|
364
308
|
export interface BuildGrouplessExecuteScriptTxResult {
|
|
365
|
-
transferTxs:
|
|
366
|
-
executeScriptTx:
|
|
309
|
+
transferTxs: BuildSimpleTransferTxResult[]
|
|
310
|
+
executeScriptTx: BuildSimpleExecuteScriptTxResult
|
|
311
|
+
type: string
|
|
367
312
|
}
|
|
368
313
|
|
|
369
|
-
/**
|
|
370
|
-
export interface
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
gasPrice?: string
|
|
375
|
-
/** @format block-hash */
|
|
376
|
-
targetBlockHash?: string
|
|
314
|
+
/** BuildGrouplessTransferTxResult */
|
|
315
|
+
export interface BuildGrouplessTransferTxResult {
|
|
316
|
+
transferTxs: BuildSimpleTransferTxResult[]
|
|
317
|
+
transferTx: BuildSimpleTransferTxResult
|
|
318
|
+
type: string
|
|
377
319
|
}
|
|
378
320
|
|
|
379
321
|
/** BuildInfo */
|
|
@@ -416,6 +358,57 @@ export interface BuildMultisigAddressResult {
|
|
|
416
358
|
address: string
|
|
417
359
|
}
|
|
418
360
|
|
|
361
|
+
/** BuildSimpleDeployContractTxResult */
|
|
362
|
+
export interface BuildSimpleDeployContractTxResult {
|
|
363
|
+
/** @format int32 */
|
|
364
|
+
fromGroup: number
|
|
365
|
+
/** @format int32 */
|
|
366
|
+
toGroup: number
|
|
367
|
+
unsignedTx: string
|
|
368
|
+
/** @format gas */
|
|
369
|
+
gasAmount: number
|
|
370
|
+
/** @format uint256 */
|
|
371
|
+
gasPrice: string
|
|
372
|
+
/** @format 32-byte-hash */
|
|
373
|
+
txId: string
|
|
374
|
+
/** @format address */
|
|
375
|
+
contractAddress: string
|
|
376
|
+
type: string
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** BuildSimpleExecuteScriptTxResult */
|
|
380
|
+
export interface BuildSimpleExecuteScriptTxResult {
|
|
381
|
+
/** @format int32 */
|
|
382
|
+
fromGroup: number
|
|
383
|
+
/** @format int32 */
|
|
384
|
+
toGroup: number
|
|
385
|
+
unsignedTx: string
|
|
386
|
+
/** @format gas */
|
|
387
|
+
gasAmount: number
|
|
388
|
+
/** @format uint256 */
|
|
389
|
+
gasPrice: string
|
|
390
|
+
/** @format 32-byte-hash */
|
|
391
|
+
txId: string
|
|
392
|
+
simulationResult: SimulationResult
|
|
393
|
+
type: string
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** BuildSimpleTransferTxResult */
|
|
397
|
+
export interface BuildSimpleTransferTxResult {
|
|
398
|
+
unsignedTx: string
|
|
399
|
+
/** @format gas */
|
|
400
|
+
gasAmount: number
|
|
401
|
+
/** @format uint256 */
|
|
402
|
+
gasPrice: string
|
|
403
|
+
/** @format 32-byte-hash */
|
|
404
|
+
txId: string
|
|
405
|
+
/** @format int32 */
|
|
406
|
+
fromGroup: number
|
|
407
|
+
/** @format int32 */
|
|
408
|
+
toGroup: number
|
|
409
|
+
type: string
|
|
410
|
+
}
|
|
411
|
+
|
|
419
412
|
/** BuildSweepAddressTransactions */
|
|
420
413
|
export interface BuildSweepAddressTransactions {
|
|
421
414
|
/** @format public-key */
|
|
@@ -478,24 +471,14 @@ export interface BuildTransferTx {
|
|
|
478
471
|
gasAmount?: number
|
|
479
472
|
/** @format uint256 */
|
|
480
473
|
gasPrice?: string
|
|
474
|
+
/** @format group-index */
|
|
475
|
+
group?: number
|
|
481
476
|
/** @format block-hash */
|
|
482
477
|
targetBlockHash?: string
|
|
483
478
|
}
|
|
484
479
|
|
|
485
480
|
/** BuildTransferTxResult */
|
|
486
|
-
export
|
|
487
|
-
unsignedTx: string
|
|
488
|
-
/** @format gas */
|
|
489
|
-
gasAmount: number
|
|
490
|
-
/** @format uint256 */
|
|
491
|
-
gasPrice: string
|
|
492
|
-
/** @format 32-byte-hash */
|
|
493
|
-
txId: string
|
|
494
|
-
/** @format int32 */
|
|
495
|
-
fromGroup: number
|
|
496
|
-
/** @format int32 */
|
|
497
|
-
toGroup: number
|
|
498
|
-
}
|
|
481
|
+
export type BuildTransferTxResult = BuildGrouplessTransferTxResult | BuildSimpleTransferTxResult
|
|
499
482
|
|
|
500
483
|
/** CallContract */
|
|
501
484
|
export interface CallContract {
|
|
@@ -1281,6 +1264,7 @@ export interface TestContract {
|
|
|
1281
1264
|
args?: Val[]
|
|
1282
1265
|
existingContracts?: ContractState[]
|
|
1283
1266
|
inputAssets?: TestInputAsset[]
|
|
1267
|
+
dustAmount?: string
|
|
1284
1268
|
}
|
|
1285
1269
|
|
|
1286
1270
|
/** TestContractResult */
|
|
@@ -1620,8 +1604,8 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1620
1604
|
property instanceof Blob
|
|
1621
1605
|
? property
|
|
1622
1606
|
: typeof property === 'object' && property !== null
|
|
1623
|
-
|
|
1624
|
-
|
|
1607
|
+
? JSON.stringify(property)
|
|
1608
|
+
: `${property}`
|
|
1625
1609
|
)
|
|
1626
1610
|
return formData
|
|
1627
1611
|
}, new FormData()),
|
|
@@ -1701,18 +1685,18 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1701
1685
|
const data = !responseFormat
|
|
1702
1686
|
? r
|
|
1703
1687
|
: await response[responseFormat]()
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1688
|
+
.then((data) => {
|
|
1689
|
+
if (r.ok) {
|
|
1690
|
+
r.data = data
|
|
1691
|
+
} else {
|
|
1692
|
+
r.error = data
|
|
1693
|
+
}
|
|
1694
|
+
return r
|
|
1695
|
+
})
|
|
1696
|
+
.catch((e) => {
|
|
1697
|
+
r.error = e
|
|
1698
|
+
return r
|
|
1699
|
+
})
|
|
1716
1700
|
|
|
1717
1701
|
if (cancelToken) {
|
|
1718
1702
|
this.abortControllers.delete(cancelToken)
|
|
@@ -2797,7 +2781,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2797
2781
|
*/
|
|
2798
2782
|
postTransactionsBuildTransferFromOneToManyGroups: (data: BuildTransferTx, params: RequestParams = {}) =>
|
|
2799
2783
|
this.request<
|
|
2800
|
-
|
|
2784
|
+
BuildSimpleTransferTxResult[],
|
|
2801
2785
|
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
2802
2786
|
>({
|
|
2803
2787
|
path: `/transactions/build-transfer-from-one-to-many-groups`,
|
|
@@ -2818,7 +2802,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
2818
2802
|
*/
|
|
2819
2803
|
postTransactionsBuildMultiAddresses: (data: BuildMultiAddressesTransaction, params: RequestParams = {}) =>
|
|
2820
2804
|
this.request<
|
|
2821
|
-
|
|
2805
|
+
BuildSimpleTransferTxResult,
|
|
2822
2806
|
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
2823
2807
|
>({
|
|
2824
2808
|
path: `/transactions/build-multi-addresses`,
|
|
@@ -3466,7 +3450,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
3466
3450
|
*/
|
|
3467
3451
|
postMultisigBuild: (data: BuildMultisig, params: RequestParams = {}) =>
|
|
3468
3452
|
this.request<
|
|
3469
|
-
|
|
3453
|
+
BuildSimpleTransferTxResult,
|
|
3470
3454
|
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
3471
3455
|
>({
|
|
3472
3456
|
path: `/multisig/build`,
|
|
@@ -3778,68 +3762,4 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
3778
3762
|
...params
|
|
3779
3763
|
}).then(convertHttpResponse)
|
|
3780
3764
|
}
|
|
3781
|
-
groupless = {
|
|
3782
|
-
/**
|
|
3783
|
-
* No description
|
|
3784
|
-
*
|
|
3785
|
-
* @tags Groupless
|
|
3786
|
-
* @name PostGrouplessTransfer
|
|
3787
|
-
* @summary Build unsigned transfer transactions from a groupless address
|
|
3788
|
-
* @request POST:/groupless/transfer
|
|
3789
|
-
*/
|
|
3790
|
-
postGrouplessTransfer: (data: BuildGrouplessTransferTx, params: RequestParams = {}) =>
|
|
3791
|
-
this.request<
|
|
3792
|
-
BuildTransferTxResult[],
|
|
3793
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
3794
|
-
>({
|
|
3795
|
-
path: `/groupless/transfer`,
|
|
3796
|
-
method: 'POST',
|
|
3797
|
-
body: data,
|
|
3798
|
-
type: ContentType.Json,
|
|
3799
|
-
format: 'json',
|
|
3800
|
-
...params
|
|
3801
|
-
}).then(convertHttpResponse),
|
|
3802
|
-
|
|
3803
|
-
/**
|
|
3804
|
-
* No description
|
|
3805
|
-
*
|
|
3806
|
-
* @tags Groupless
|
|
3807
|
-
* @name PostGrouplessExecuteScript
|
|
3808
|
-
* @summary Build an unsigned execute script transaction from a groupless address
|
|
3809
|
-
* @request POST:/groupless/execute-script
|
|
3810
|
-
*/
|
|
3811
|
-
postGrouplessExecuteScript: (data: BuildGrouplessExecuteScriptTx, params: RequestParams = {}) =>
|
|
3812
|
-
this.request<
|
|
3813
|
-
BuildGrouplessExecuteScriptTxResult,
|
|
3814
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
3815
|
-
>({
|
|
3816
|
-
path: `/groupless/execute-script`,
|
|
3817
|
-
method: 'POST',
|
|
3818
|
-
body: data,
|
|
3819
|
-
type: ContentType.Json,
|
|
3820
|
-
format: 'json',
|
|
3821
|
-
...params
|
|
3822
|
-
}).then(convertHttpResponse),
|
|
3823
|
-
|
|
3824
|
-
/**
|
|
3825
|
-
* No description
|
|
3826
|
-
*
|
|
3827
|
-
* @tags Groupless
|
|
3828
|
-
* @name PostGrouplessDeployContract
|
|
3829
|
-
* @summary Build an unsigned deploy contract transaction from a groupless address
|
|
3830
|
-
* @request POST:/groupless/deploy-contract
|
|
3831
|
-
*/
|
|
3832
|
-
postGrouplessDeployContract: (data: BuildGrouplessDeployContractTx, params: RequestParams = {}) =>
|
|
3833
|
-
this.request<
|
|
3834
|
-
BuildGrouplessDeployContractTxResult,
|
|
3835
|
-
BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable | GatewayTimeout
|
|
3836
|
-
>({
|
|
3837
|
-
path: `/groupless/deploy-contract`,
|
|
3838
|
-
method: 'POST',
|
|
3839
|
-
body: data,
|
|
3840
|
-
type: ContentType.Json,
|
|
3841
|
-
format: 'json',
|
|
3842
|
-
...params
|
|
3843
|
-
}).then(convertHttpResponse)
|
|
3844
|
-
}
|
|
3845
3765
|
}
|
package/src/api/node-provider.ts
CHANGED
|
@@ -55,7 +55,6 @@ interface NodeProviderApis {
|
|
|
55
55
|
utils: NodeApi<string>['utils']
|
|
56
56
|
miners: NodeApi<string>['miners']
|
|
57
57
|
events: NodeApi<string>['events']
|
|
58
|
-
groupless: NodeApi<string>['groupless']
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
export class NodeProvider implements NodeProviderApis {
|
|
@@ -70,7 +69,6 @@ export class NodeProvider implements NodeProviderApis {
|
|
|
70
69
|
readonly utils: NodeApi<string>['utils']
|
|
71
70
|
readonly miners: NodeApi<string>['miners']
|
|
72
71
|
readonly events: NodeApi<string>['events']
|
|
73
|
-
readonly groupless: NodeApi<string>['groupless']
|
|
74
72
|
|
|
75
73
|
constructor(baseUrl: string, apiKey?: string, customFetch?: typeof fetch)
|
|
76
74
|
constructor(provider: NodeProvider)
|
|
@@ -97,7 +95,6 @@ export class NodeProvider implements NodeProviderApis {
|
|
|
97
95
|
this.utils = { ...nodeApi.utils }
|
|
98
96
|
this.miners = { ...nodeApi.miners }
|
|
99
97
|
this.events = { ...nodeApi.events }
|
|
100
|
-
this.groupless = { ...nodeApi.groupless }
|
|
101
98
|
requestWithLog(this)
|
|
102
99
|
}
|
|
103
100
|
|
package/src/codec/instr-codec.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { ArrayCodec } from './array-codec'
|
|
|
20
20
|
import { i256Codec, u256Codec, i32Codec } from './compact-int-codec'
|
|
21
21
|
import { ByteString, byteStringCodec, byteStringsCodec } from './bytestring-codec'
|
|
22
22
|
import { LockupScript, lockupScriptCodec } from './lockup-script-codec'
|
|
23
|
-
import {
|
|
23
|
+
import { byteCodec, Codec } from './codec'
|
|
24
24
|
import { intAs4BytesCodec } from './int-as-4bytes-codec'
|
|
25
25
|
import { Reader } from './reader'
|
|
26
26
|
export type Instr =
|
|
@@ -80,11 +80,11 @@ export type Instr =
|
|
|
80
80
|
| { name: 'U256ModAdd'; code: 0x35 }
|
|
81
81
|
| { name: 'U256ModSub'; code: 0x36 }
|
|
82
82
|
| { name: 'U256ModMul'; code: 0x37 }
|
|
83
|
-
| { name: '
|
|
84
|
-
| { name: '
|
|
85
|
-
| { name: '
|
|
86
|
-
| { name: '
|
|
87
|
-
| { name: '
|
|
83
|
+
| { name: 'NumericBitAnd'; code: 0x38 }
|
|
84
|
+
| { name: 'NumericBitOr'; code: 0x39 }
|
|
85
|
+
| { name: 'NumericXor'; code: 0x3a }
|
|
86
|
+
| { name: 'NumericSHL'; code: 0x3b }
|
|
87
|
+
| { name: 'NumericSHR'; code: 0x3c }
|
|
88
88
|
| { name: 'I256ToU256'; code: 0x3d }
|
|
89
89
|
| { name: 'I256ToByteVec'; code: 0x3e }
|
|
90
90
|
| { name: 'U256ToI256'; code: 0x3f }
|
|
@@ -165,6 +165,8 @@ export type Instr =
|
|
|
165
165
|
| { name: 'I256ToString'; code: 0x8a }
|
|
166
166
|
| { name: 'BoolToString'; code: 0x8b }
|
|
167
167
|
| { name: 'GroupOfAddress'; code: 0x8c }
|
|
168
|
+
| { name: 'VerifySignature'; code: 0x8d }
|
|
169
|
+
| { name: 'GetSegregatedWebAuthnSignature'; code: 0x8e }
|
|
168
170
|
| { name: 'LoadMutField'; code: 0xa0; index: number }
|
|
169
171
|
| { name: 'StoreMutField'; code: 0xa1; index: number }
|
|
170
172
|
| { name: 'ApproveAlph'; code: 0xa2 }
|
|
@@ -218,6 +220,8 @@ export type Instr =
|
|
|
218
220
|
| { name: 'CreateMapEntry'; code: 0xd2; immFieldsNum: number; mutFieldsNum: number }
|
|
219
221
|
| { name: 'MethodSelector'; code: 0xd3; selector: number }
|
|
220
222
|
| { name: 'CallExternalBySelector'; code: 0xd4; selector: number }
|
|
223
|
+
| { name: 'ExternalCallerContractId'; code: 0xd5 }
|
|
224
|
+
| { name: 'ExternalCallerAddress'; code: 0xd6 }
|
|
221
225
|
export const CallLocalCode = 0x00
|
|
222
226
|
export const CallExternalCode = 0x01
|
|
223
227
|
export const I256ConstCode = 0x12
|
|
@@ -308,11 +312,11 @@ export const U256Ge: Instr = { name: 'U256Ge', code: 0x34 }
|
|
|
308
312
|
export const U256ModAdd: Instr = { name: 'U256ModAdd', code: 0x35 }
|
|
309
313
|
export const U256ModSub: Instr = { name: 'U256ModSub', code: 0x36 }
|
|
310
314
|
export const U256ModMul: Instr = { name: 'U256ModMul', code: 0x37 }
|
|
311
|
-
export const
|
|
312
|
-
export const
|
|
313
|
-
export const
|
|
314
|
-
export const
|
|
315
|
-
export const
|
|
315
|
+
export const NumericBitAnd: Instr = { name: 'NumericBitAnd', code: 0x38 }
|
|
316
|
+
export const NumericBitOr: Instr = { name: 'NumericBitOr', code: 0x39 }
|
|
317
|
+
export const NumericXor: Instr = { name: 'NumericXor', code: 0x3a }
|
|
318
|
+
export const NumericSHL: Instr = { name: 'NumericSHL', code: 0x3b }
|
|
319
|
+
export const NumericSHR: Instr = { name: 'NumericSHR', code: 0x3c }
|
|
316
320
|
export const I256ToU256: Instr = { name: 'I256ToU256', code: 0x3d }
|
|
317
321
|
export const I256ToByteVec: Instr = { name: 'I256ToByteVec', code: 0x3e }
|
|
318
322
|
export const U256ToI256: Instr = { name: 'U256ToI256', code: 0x3f }
|
|
@@ -401,6 +405,8 @@ export const U256ToString: Instr = { name: 'U256ToString', code: 0x89 }
|
|
|
401
405
|
export const I256ToString: Instr = { name: 'I256ToString', code: 0x8a }
|
|
402
406
|
export const BoolToString: Instr = { name: 'BoolToString', code: 0x8b }
|
|
403
407
|
export const GroupOfAddress: Instr = { name: 'GroupOfAddress', code: 0x8c }
|
|
408
|
+
export const VerifySignature: Instr = { name: 'VerifySignature', code: 0x8d }
|
|
409
|
+
export const GetSegregatedWebAuthnSignature: Instr = { name: 'GetSegregatedWebAuthnSignature', code: 0x8e }
|
|
404
410
|
export const LoadMutField: (index: number) => Instr = (index: number) => {
|
|
405
411
|
return { name: 'LoadMutField', code: 0xa0, index }
|
|
406
412
|
}
|
|
@@ -472,6 +478,8 @@ export const MethodSelector: (selector: number) => Instr = (selector: number) =>
|
|
|
472
478
|
export const CallExternalBySelector: (selector: number) => Instr = (selector: number) => {
|
|
473
479
|
return { name: 'CallExternalBySelector', code: 0xd4, selector }
|
|
474
480
|
}
|
|
481
|
+
export const ExternalCallerContractId: Instr = { name: 'ExternalCallerContractId', code: 0xd5 }
|
|
482
|
+
export const ExternalCallerAddress: Instr = { name: 'ExternalCallerAddress', code: 0xd6 }
|
|
475
483
|
export class InstrCodec extends Codec<Instr> {
|
|
476
484
|
encode(instr: Instr): Uint8Array {
|
|
477
485
|
switch (instr.name) {
|
|
@@ -587,15 +595,15 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
587
595
|
return new Uint8Array([0x36])
|
|
588
596
|
case 'U256ModMul':
|
|
589
597
|
return new Uint8Array([0x37])
|
|
590
|
-
case '
|
|
598
|
+
case 'NumericBitAnd':
|
|
591
599
|
return new Uint8Array([0x38])
|
|
592
|
-
case '
|
|
600
|
+
case 'NumericBitOr':
|
|
593
601
|
return new Uint8Array([0x39])
|
|
594
|
-
case '
|
|
602
|
+
case 'NumericXor':
|
|
595
603
|
return new Uint8Array([0x3a])
|
|
596
|
-
case '
|
|
604
|
+
case 'NumericSHL':
|
|
597
605
|
return new Uint8Array([0x3b])
|
|
598
|
-
case '
|
|
606
|
+
case 'NumericSHR':
|
|
599
607
|
return new Uint8Array([0x3c])
|
|
600
608
|
case 'I256ToU256':
|
|
601
609
|
return new Uint8Array([0x3d])
|
|
@@ -757,6 +765,10 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
757
765
|
return new Uint8Array([0x8b])
|
|
758
766
|
case 'GroupOfAddress':
|
|
759
767
|
return new Uint8Array([0x8c])
|
|
768
|
+
case 'VerifySignature':
|
|
769
|
+
return new Uint8Array([0x8d])
|
|
770
|
+
case 'GetSegregatedWebAuthnSignature':
|
|
771
|
+
return new Uint8Array([0x8e])
|
|
760
772
|
case 'LoadMutField':
|
|
761
773
|
return new Uint8Array([0xa0, ...byteCodec.encode(instr.index)])
|
|
762
774
|
case 'StoreMutField':
|
|
@@ -863,6 +875,10 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
863
875
|
return new Uint8Array([0xd3, ...intAs4BytesCodec.encode(instr.selector)])
|
|
864
876
|
case 'CallExternalBySelector':
|
|
865
877
|
return new Uint8Array([0xd4, ...intAs4BytesCodec.encode(instr.selector)])
|
|
878
|
+
case 'ExternalCallerContractId':
|
|
879
|
+
return new Uint8Array([0xd5])
|
|
880
|
+
case 'ExternalCallerAddress':
|
|
881
|
+
return new Uint8Array([0xd6])
|
|
866
882
|
}
|
|
867
883
|
}
|
|
868
884
|
_decode(input: Reader): Instr {
|
|
@@ -981,15 +997,15 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
981
997
|
case 0x37:
|
|
982
998
|
return U256ModMul
|
|
983
999
|
case 0x38:
|
|
984
|
-
return
|
|
1000
|
+
return NumericBitAnd
|
|
985
1001
|
case 0x39:
|
|
986
|
-
return
|
|
1002
|
+
return NumericBitOr
|
|
987
1003
|
case 0x3a:
|
|
988
|
-
return
|
|
1004
|
+
return NumericXor
|
|
989
1005
|
case 0x3b:
|
|
990
|
-
return
|
|
1006
|
+
return NumericSHL
|
|
991
1007
|
case 0x3c:
|
|
992
|
-
return
|
|
1008
|
+
return NumericSHR
|
|
993
1009
|
case 0x3d:
|
|
994
1010
|
return I256ToU256
|
|
995
1011
|
case 0x3e:
|
|
@@ -1150,6 +1166,10 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
1150
1166
|
return BoolToString
|
|
1151
1167
|
case 0x8c:
|
|
1152
1168
|
return GroupOfAddress
|
|
1169
|
+
case 0x8d:
|
|
1170
|
+
return VerifySignature
|
|
1171
|
+
case 0x8e:
|
|
1172
|
+
return GetSegregatedWebAuthnSignature
|
|
1153
1173
|
case 0xa0:
|
|
1154
1174
|
return LoadMutField(byteCodec._decode(input))
|
|
1155
1175
|
case 0xa1:
|
|
@@ -1256,6 +1276,10 @@ export class InstrCodec extends Codec<Instr> {
|
|
|
1256
1276
|
return MethodSelector(intAs4BytesCodec._decode(input))
|
|
1257
1277
|
case 0xd4:
|
|
1258
1278
|
return CallExternalBySelector(intAs4BytesCodec._decode(input))
|
|
1279
|
+
case 0xd5:
|
|
1280
|
+
return ExternalCallerContractId
|
|
1281
|
+
case 0xd6:
|
|
1282
|
+
return ExternalCallerAddress
|
|
1259
1283
|
default:
|
|
1260
1284
|
throw new Error(`Unknown instr code: ${code}`)
|
|
1261
1285
|
}
|