@layerzerolabs/common-suimove 0.0.73
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/.turbo/turbo-build.log +64 -0
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +16 -0
- package/dist/7LWJNWY6.cjs +4 -0
- package/dist/7LWJNWY6.cjs.map +1 -0
- package/dist/AHFVRB2R.cjs +27 -0
- package/dist/AHFVRB2R.cjs.map +1 -0
- package/dist/CHPRFEFD.js +69 -0
- package/dist/CHPRFEFD.js.map +1 -0
- package/dist/DMFKLZKD.js +3 -0
- package/dist/DMFKLZKD.js.map +1 -0
- package/dist/EAFPTVEK.cjs +74 -0
- package/dist/EAFPTVEK.cjs.map +1 -0
- package/dist/L6EI37IO.cjs +4 -0
- package/dist/L6EI37IO.cjs.map +1 -0
- package/dist/OQ5C7BFY.js +23 -0
- package/dist/OQ5C7BFY.js.map +1 -0
- package/dist/PKPG4OQE.cjs +4 -0
- package/dist/PKPG4OQE.cjs.map +1 -0
- package/dist/QRJFMNTB.js +3 -0
- package/dist/QRJFMNTB.js.map +1 -0
- package/dist/Y5EOMP5J.js +3 -0
- package/dist/Y5EOMP5J.js.map +1 -0
- package/dist/error.cjs +16 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +7 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +3 -0
- package/dist/error.js.map +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.cjs +6 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.ts +36 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +3 -0
- package/dist/provider.js.map +1 -0
- package/dist/transaction.cjs +6 -0
- package/dist/transaction.cjs.map +1 -0
- package/dist/transaction.d.ts +73 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +3 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.cjs +6 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +25 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +4 -0
- package/dist/utils.js.map +1 -0
- package/package.json +36 -0
- package/src/error.ts +9 -0
- package/src/index.ts +4 -0
- package/src/provider.ts +45 -0
- package/src/transaction.ts +83 -0
- package/src/types.ts +109 -0
- package/src/utils.ts +86 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transaction.js"}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.cjs"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { bcs as iotaBcs, BcsType as IotaBcsType } from '@iota/iota-sdk/bcs';
|
|
2
|
+
import type { DevInspectResults as IotaDevInspectResults, IotaExecutionResult } from '@iota/iota-sdk/client';
|
|
3
|
+
import type { bcs as suiBcs, BcsType as SuiBcsType } from '@mysten/sui/bcs';
|
|
4
|
+
import type { DevInspectResults as SuiDevInspectResults, SuiExecutionResult } from '@mysten/sui/client';
|
|
5
|
+
export type SuiMoveBcsType<T, U> = SuiBcsType<T, U> | IotaBcsType<T, U>;
|
|
6
|
+
export type SuiTypes = typeof suiBcs.U128 | typeof suiBcs.U64 | typeof suiBcs.U32 | typeof suiBcs.U16 | typeof suiBcs.U8 | typeof suiBcs.bool | typeof suiBcs.Address | typeof suiBcs.vector | SuiBcsType<string[], Iterable<string | Uint8Array> & {
|
|
7
|
+
length: number;
|
|
8
|
+
}>;
|
|
9
|
+
export type IotaTypes = typeof iotaBcs.U128 | typeof iotaBcs.U64 | typeof iotaBcs.U32 | typeof iotaBcs.U16 | typeof iotaBcs.U8 | typeof iotaBcs.bool | typeof iotaBcs.Address | typeof iotaBcs.vector | IotaBcsType<string[], Iterable<string | Uint8Array> & {
|
|
10
|
+
length: number;
|
|
11
|
+
}>;
|
|
12
|
+
export type SuiMoveTypes = SuiTypes | IotaTypes;
|
|
13
|
+
export interface SuiMoveBcs {
|
|
14
|
+
u256: typeof suiBcs.U128 | typeof iotaBcs.U128;
|
|
15
|
+
u128: typeof suiBcs.U128 | typeof iotaBcs.U128;
|
|
16
|
+
u64: typeof suiBcs.U64 | typeof iotaBcs.U64;
|
|
17
|
+
u32: typeof suiBcs.U32 | typeof iotaBcs.U32;
|
|
18
|
+
u16: typeof suiBcs.U16 | typeof iotaBcs.U16;
|
|
19
|
+
u8: typeof suiBcs.U8 | typeof iotaBcs.U8;
|
|
20
|
+
bool: typeof suiBcs.bool | typeof iotaBcs.bool;
|
|
21
|
+
address: typeof suiBcs.Address | typeof iotaBcs.Address;
|
|
22
|
+
vectorAddress: SuiMoveBcsType<string[], Iterable<string | Uint8Array> & {
|
|
23
|
+
length: number;
|
|
24
|
+
}>;
|
|
25
|
+
toAddress(bytes: Uint8Array): string;
|
|
26
|
+
toU64(bytes: Uint8Array): string;
|
|
27
|
+
toU16(bytes: Uint8Array): number;
|
|
28
|
+
toU8(bytes: Uint8Array): number;
|
|
29
|
+
toU8Vector(bytes: Uint8Array): number[];
|
|
30
|
+
toBool(bytes: Uint8Array): boolean;
|
|
31
|
+
toStruct<T>(bytes: Uint8Array, structName: string, fields: Record<string, SuiMoveTypes>): T;
|
|
32
|
+
}
|
|
33
|
+
export interface SuiMoveEventCursor {
|
|
34
|
+
txDigest: string;
|
|
35
|
+
eventSeq: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SuiMoveEvent {
|
|
38
|
+
type: string;
|
|
39
|
+
data: any;
|
|
40
|
+
txHash: string;
|
|
41
|
+
blockSequenceNumber?: number;
|
|
42
|
+
blockDigest?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SuiMoveCheckpoint {
|
|
45
|
+
digest: string;
|
|
46
|
+
sequenceNumber: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SuiMoveTransactionBlockResponse {
|
|
49
|
+
digest: string;
|
|
50
|
+
events: SuiMoveEvent[];
|
|
51
|
+
checkpoint?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface SuiMoveCoinBalance {
|
|
54
|
+
coinType: string;
|
|
55
|
+
totalBalance: string;
|
|
56
|
+
}
|
|
57
|
+
export interface SuiMoveViewResult {
|
|
58
|
+
value: Uint8Array;
|
|
59
|
+
type: string;
|
|
60
|
+
}
|
|
61
|
+
export type SuiMoveDevInspectResult = SuiDevInspectResults | IotaDevInspectResults;
|
|
62
|
+
export type SuiMoveExecutionResult = SuiExecutionResult | IotaExecutionResult;
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,IAAI,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EACR,iBAAiB,IAAI,qBAAqB,EAC1C,mBAAmB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,IAAI,MAAM,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EACR,iBAAiB,IAAI,oBAAoB,EACzC,kBAAkB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC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;IACf,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,+BAA+B;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAEnF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG,mBAAmB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var EAFPTVEK_cjs = require('./EAFPTVEK.cjs');
|
|
4
|
+
require('./AHFVRB2R.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "convertToSuiMoveEvents", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return EAFPTVEK_cjs.convertToSuiMoveEvents; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "handleError", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return EAFPTVEK_cjs.handleError; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "suiMoveView", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return EAFPTVEK_cjs.suiMoveView; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "suiMoveViewMultiResult", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return EAFPTVEK_cjs.suiMoveViewMultiResult; }
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=utils.cjs.map
|
|
25
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.cjs"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SuiMoveProvider } from './provider';
|
|
2
|
+
import type { SuiMoveTransaction } from './transaction';
|
|
3
|
+
import type { SuiMoveEvent, SuiMoveViewResult } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Converts raw Sui move events to SuiMoveEvent format
|
|
6
|
+
*/
|
|
7
|
+
export declare const convertToSuiMoveEvents: (rawEvents: any[]) => SuiMoveEvent[];
|
|
8
|
+
export declare function handleError(e: string): unknown;
|
|
9
|
+
export declare function suiMoveViewMultiResult(client: SuiMoveProvider, tx: SuiMoveTransaction, resultIndex: number[]): Promise<SuiMoveViewResult[][]>;
|
|
10
|
+
export declare function suiMoveView(suiClient: SuiMoveProvider, tx: SuiMoveTransaction): Promise<SuiMoveViewResult[]>;
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAA0B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIvF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,GAAG,EAAE,KAAG,YAAY,EAMrE,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAkB9C;AAED,wBAAsB,sBAAsB,CACxC,MAAM,EAAE,eAAe,EACvB,EAAE,EAAE,kBAAkB,EACtB,WAAW,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CA+BhC;AAED,wBAAsB,WAAW,CAC7B,SAAS,EAAE,eAAe,EAC1B,EAAE,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAK9B"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerzerolabs/common-suimove",
|
|
3
|
+
"version": "0.0.73",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"require": "./dist/index.cjs",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@iota/iota-sdk": "^1.6.1",
|
|
18
|
+
"@mysten/sui": "^1.35.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"tsup": "^8.4.0",
|
|
22
|
+
"vitest": "^3.2.3",
|
|
23
|
+
"@layerzerolabs/tsup-configuration": "0.0.73",
|
|
24
|
+
"@layerzerolabs/typescript-configuration": "0.0.73"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "restricted",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"clean": "rm -rf ./node_modules .turbo ./dist",
|
|
33
|
+
"lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
|
|
34
|
+
"test": "vitest --run --pass-with-no-tests --typecheck"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/error.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export class SuiMoveAbortError extends Error {
|
|
2
|
+
readonly abortCode: number;
|
|
3
|
+
constructor(abortCode: number, rawMsg: string) {
|
|
4
|
+
super(`Move abort with code: ${abortCode}. Raw error message: ${rawMsg}`);
|
|
5
|
+
this.abortCode = abortCode;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class SuiMoveUnclassifiedError extends Error {}
|
package/src/index.ts
ADDED
package/src/provider.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SuiMoveTransaction } from './transaction';
|
|
2
|
+
import type {
|
|
3
|
+
SuiMoveCheckpoint,
|
|
4
|
+
SuiMoveCoinBalance,
|
|
5
|
+
SuiMoveDevInspectResult,
|
|
6
|
+
SuiMoveEvent,
|
|
7
|
+
SuiMoveEventCursor,
|
|
8
|
+
SuiMoveTransactionBlockResponse,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export interface SuiMoveProvider {
|
|
12
|
+
queryEventsByType(args: {
|
|
13
|
+
type: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
order?: 'ascending' | 'descending';
|
|
16
|
+
cursor?: SuiMoveEventCursor;
|
|
17
|
+
}): Promise<SuiMoveEvent[]>;
|
|
18
|
+
|
|
19
|
+
queryEventByTxHash(args: {
|
|
20
|
+
txHash: string;
|
|
21
|
+
limit?: number;
|
|
22
|
+
order?: 'ascending' | 'descending';
|
|
23
|
+
cursor?: SuiMoveEventCursor;
|
|
24
|
+
}): Promise<SuiMoveEvent[]>;
|
|
25
|
+
|
|
26
|
+
getCheckpoint(args: { id: string }): Promise<SuiMoveCheckpoint>;
|
|
27
|
+
|
|
28
|
+
getSuiMoveTransactionBlock(args: { digest: string }): Promise<SuiMoveTransactionBlockResponse>;
|
|
29
|
+
|
|
30
|
+
getLatestCheckpointSequenceNumber(): Promise<string>;
|
|
31
|
+
|
|
32
|
+
getReferenceGasPrice(): Promise<bigint>;
|
|
33
|
+
|
|
34
|
+
executeSuiMoveTransactionBlock(args: {
|
|
35
|
+
transactionBlock: string | Uint8Array;
|
|
36
|
+
signature: string | string[];
|
|
37
|
+
}): Promise<SuiMoveTransactionBlockResponse>;
|
|
38
|
+
|
|
39
|
+
getCoinBalance(args: { address: string }): Promise<SuiMoveCoinBalance>;
|
|
40
|
+
|
|
41
|
+
devInspectSuiMoveTransactionBlock(args: {
|
|
42
|
+
transactionBlock: SuiMoveTransaction;
|
|
43
|
+
sender: string;
|
|
44
|
+
}): Promise<SuiMoveDevInspectResult>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TransactionArgument as IotaTransactionArgument,
|
|
3
|
+
TransactionObjectArgument as IotaTransactionObjectArgument,
|
|
4
|
+
TransactionResult as IotaTransactionResult,
|
|
5
|
+
} from '@iota/iota-sdk/transactions';
|
|
6
|
+
import type { Transaction as IotaTransaction } from '@iota/iota-sdk/transactions';
|
|
7
|
+
import type {
|
|
8
|
+
TransactionArgument as SuiTransactionArgument,
|
|
9
|
+
TransactionObjectArgument as SuiTransactionObjectArgument,
|
|
10
|
+
TransactionResult as SuiTransactionResult,
|
|
11
|
+
} from '@mysten/sui/transactions';
|
|
12
|
+
import type { Transaction as SuiTransaction } from '@mysten/sui/transactions';
|
|
13
|
+
|
|
14
|
+
export type SuiMoveObjectArgument = SuiTransactionObjectArgument | IotaTransactionObjectArgument;
|
|
15
|
+
|
|
16
|
+
export type SuiMoveArgument = SuiTransactionArgument | IotaTransactionArgument;
|
|
17
|
+
|
|
18
|
+
export type SuiMoveTransactionResult = SuiTransactionResult | IotaTransactionResult;
|
|
19
|
+
|
|
20
|
+
export type SuiMoveClock = SuiTransaction['object']['clock'] | IotaTransaction['object']['clock'];
|
|
21
|
+
|
|
22
|
+
export interface SuiMoveTransaction {
|
|
23
|
+
getNew(): SuiMoveTransaction;
|
|
24
|
+
|
|
25
|
+
from(tx: SuiMoveTransaction): SuiMoveTransaction;
|
|
26
|
+
|
|
27
|
+
setSender(sender: string): void;
|
|
28
|
+
|
|
29
|
+
suiMoveCall(args: {
|
|
30
|
+
target: string;
|
|
31
|
+
arguments: SuiMoveArgument[];
|
|
32
|
+
typeArguments: string[];
|
|
33
|
+
}): SuiMoveTransactionResult;
|
|
34
|
+
|
|
35
|
+
suiMovePublish(args: {
|
|
36
|
+
modules: number[][] | string[];
|
|
37
|
+
dependencies: string[];
|
|
38
|
+
}): SuiMoveTransactionResult;
|
|
39
|
+
|
|
40
|
+
suiMoveTransferObjects(
|
|
41
|
+
objects: SuiMoveObjectArgument[],
|
|
42
|
+
target: string | SuiMoveArgument,
|
|
43
|
+
): SuiMoveTransactionResult;
|
|
44
|
+
|
|
45
|
+
suiMakeMoveVec(args: {
|
|
46
|
+
type: string;
|
|
47
|
+
elements: SuiMoveObjectArgument[];
|
|
48
|
+
}): SuiMoveTransactionResult;
|
|
49
|
+
|
|
50
|
+
toJSON(): Promise<string>;
|
|
51
|
+
|
|
52
|
+
getData(): ReturnType<SuiTransaction['getData'] | IotaTransaction['getData']>;
|
|
53
|
+
|
|
54
|
+
suiMoveSplitCoins(args: { amounts: SuiMoveArgument[] }): SuiMoveTransactionResult;
|
|
55
|
+
|
|
56
|
+
asObject(args: { objectId: string | SuiMoveArgument }): SuiMoveArgument;
|
|
57
|
+
|
|
58
|
+
asAddress(args: { address: string | SuiMoveArgument }): SuiMoveArgument;
|
|
59
|
+
|
|
60
|
+
asAddressVector(args: { addresses: string[] | SuiMoveArgument }): SuiMoveArgument;
|
|
61
|
+
|
|
62
|
+
asBytesVector(args: { bytes: Uint8Array[] | SuiMoveArgument }): SuiMoveArgument;
|
|
63
|
+
|
|
64
|
+
asBytes(args: { bytes: Uint8Array | SuiMoveArgument }): SuiMoveArgument;
|
|
65
|
+
|
|
66
|
+
asU8(args: { value: number | SuiMoveArgument }): SuiMoveArgument;
|
|
67
|
+
|
|
68
|
+
asU16(args: { value: number | SuiMoveArgument }): SuiMoveArgument;
|
|
69
|
+
|
|
70
|
+
asU32(args: { value: number | SuiMoveArgument }): SuiMoveArgument;
|
|
71
|
+
|
|
72
|
+
asU64(args: { value: bigint | number | string | SuiMoveArgument }): SuiMoveArgument;
|
|
73
|
+
|
|
74
|
+
asU128(args: { value: bigint | number | string | SuiMoveArgument }): SuiMoveArgument;
|
|
75
|
+
|
|
76
|
+
asU256(args: { value: bigint | number | string | SuiMoveArgument }): SuiMoveArgument;
|
|
77
|
+
|
|
78
|
+
asString(args: { value: string | SuiMoveArgument }): SuiMoveArgument;
|
|
79
|
+
|
|
80
|
+
asBool(args: { value: boolean | SuiMoveArgument }): SuiMoveArgument;
|
|
81
|
+
|
|
82
|
+
getClock(): ReturnType<SuiMoveClock>;
|
|
83
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { bcs as iotaBcs, BcsType as IotaBcsType } from '@iota/iota-sdk/bcs';
|
|
2
|
+
import type {
|
|
3
|
+
DevInspectResults as IotaDevInspectResults,
|
|
4
|
+
IotaExecutionResult,
|
|
5
|
+
} from '@iota/iota-sdk/client';
|
|
6
|
+
import type { bcs as suiBcs, BcsType as SuiBcsType } from '@mysten/sui/bcs';
|
|
7
|
+
import type {
|
|
8
|
+
DevInspectResults as SuiDevInspectResults,
|
|
9
|
+
SuiExecutionResult,
|
|
10
|
+
} from '@mysten/sui/client';
|
|
11
|
+
|
|
12
|
+
export type SuiMoveBcsType<T, U> = SuiBcsType<T, U> | IotaBcsType<T, U>;
|
|
13
|
+
|
|
14
|
+
export type SuiTypes =
|
|
15
|
+
| typeof suiBcs.U128
|
|
16
|
+
| typeof suiBcs.U64
|
|
17
|
+
| typeof suiBcs.U32
|
|
18
|
+
| typeof suiBcs.U16
|
|
19
|
+
| typeof suiBcs.U8
|
|
20
|
+
| typeof suiBcs.bool
|
|
21
|
+
| typeof suiBcs.Address
|
|
22
|
+
| typeof suiBcs.vector
|
|
23
|
+
| SuiBcsType<
|
|
24
|
+
string[],
|
|
25
|
+
Iterable<string | Uint8Array> & {
|
|
26
|
+
length: number;
|
|
27
|
+
}
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
export type IotaTypes =
|
|
31
|
+
| typeof iotaBcs.U128
|
|
32
|
+
| typeof iotaBcs.U64
|
|
33
|
+
| typeof iotaBcs.U32
|
|
34
|
+
| typeof iotaBcs.U16
|
|
35
|
+
| typeof iotaBcs.U8
|
|
36
|
+
| typeof iotaBcs.bool
|
|
37
|
+
| typeof iotaBcs.Address
|
|
38
|
+
| typeof iotaBcs.vector
|
|
39
|
+
| IotaBcsType<
|
|
40
|
+
string[],
|
|
41
|
+
Iterable<string | Uint8Array> & {
|
|
42
|
+
length: number;
|
|
43
|
+
}
|
|
44
|
+
>;
|
|
45
|
+
|
|
46
|
+
export type SuiMoveTypes = SuiTypes | IotaTypes;
|
|
47
|
+
|
|
48
|
+
export interface SuiMoveBcs {
|
|
49
|
+
u256: typeof suiBcs.U128 | typeof iotaBcs.U128;
|
|
50
|
+
u128: typeof suiBcs.U128 | typeof iotaBcs.U128;
|
|
51
|
+
u64: typeof suiBcs.U64 | typeof iotaBcs.U64;
|
|
52
|
+
u32: typeof suiBcs.U32 | typeof iotaBcs.U32;
|
|
53
|
+
u16: typeof suiBcs.U16 | typeof iotaBcs.U16;
|
|
54
|
+
u8: typeof suiBcs.U8 | typeof iotaBcs.U8;
|
|
55
|
+
bool: typeof suiBcs.bool | typeof iotaBcs.bool;
|
|
56
|
+
address: typeof suiBcs.Address | typeof iotaBcs.Address;
|
|
57
|
+
vectorAddress: SuiMoveBcsType<
|
|
58
|
+
string[],
|
|
59
|
+
Iterable<string | Uint8Array> & {
|
|
60
|
+
length: number;
|
|
61
|
+
}
|
|
62
|
+
>;
|
|
63
|
+
|
|
64
|
+
toAddress(bytes: Uint8Array): string;
|
|
65
|
+
toU64(bytes: Uint8Array): string;
|
|
66
|
+
toU16(bytes: Uint8Array): number;
|
|
67
|
+
toU8(bytes: Uint8Array): number;
|
|
68
|
+
toU8Vector(bytes: Uint8Array): number[];
|
|
69
|
+
toBool(bytes: Uint8Array): boolean;
|
|
70
|
+
toStruct<T>(bytes: Uint8Array, structName: string, fields: Record<string, SuiMoveTypes>): T;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SuiMoveEventCursor {
|
|
74
|
+
txDigest: string;
|
|
75
|
+
eventSeq: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SuiMoveEvent {
|
|
79
|
+
type: string;
|
|
80
|
+
data: any;
|
|
81
|
+
txHash: string;
|
|
82
|
+
blockSequenceNumber?: number;
|
|
83
|
+
blockDigest?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface SuiMoveCheckpoint {
|
|
87
|
+
digest: string;
|
|
88
|
+
sequenceNumber: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SuiMoveTransactionBlockResponse {
|
|
92
|
+
digest: string;
|
|
93
|
+
events: SuiMoveEvent[];
|
|
94
|
+
checkpoint?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface SuiMoveCoinBalance {
|
|
98
|
+
coinType: string;
|
|
99
|
+
totalBalance: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface SuiMoveViewResult {
|
|
103
|
+
value: Uint8Array;
|
|
104
|
+
type: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type SuiMoveDevInspectResult = SuiDevInspectResults | IotaDevInspectResults;
|
|
108
|
+
|
|
109
|
+
export type SuiMoveExecutionResult = SuiExecutionResult | IotaExecutionResult;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { fromBase64 } from '@mysten/sui/utils';
|
|
2
|
+
|
|
3
|
+
import { SuiMoveAbortError, SuiMoveUnclassifiedError } from './error';
|
|
4
|
+
import type { SuiMoveProvider } from './provider';
|
|
5
|
+
import type { SuiMoveTransaction } from './transaction';
|
|
6
|
+
import type { SuiMoveEvent, SuiMoveExecutionResult, SuiMoveViewResult } from './types';
|
|
7
|
+
|
|
8
|
+
const MOCK_SENDER = '0x1234567890123456789012345678901234567890123456789012345678901234';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Converts raw Sui move events to SuiMoveEvent format
|
|
12
|
+
*/
|
|
13
|
+
export const convertToSuiMoveEvents = (rawEvents: any[]): SuiMoveEvent[] => {
|
|
14
|
+
return rawEvents.map((event) => ({
|
|
15
|
+
type: event.type,
|
|
16
|
+
data: event.parsedJson,
|
|
17
|
+
txHash: event.id.txDigest,
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function handleError(e: string): unknown {
|
|
22
|
+
if (e.includes('ExecutionError')) {
|
|
23
|
+
const majorStatusMatch = e.match(/major_status:\s([A-Z_]+)/);
|
|
24
|
+
if (majorStatusMatch !== null) {
|
|
25
|
+
const major_status = majorStatusMatch[1];
|
|
26
|
+
if (major_status === 'ABORTED') {
|
|
27
|
+
const subStatusMatch = e.match(/sub_status:\sSome\((\d+)\)/);
|
|
28
|
+
if (subStatusMatch === null) {
|
|
29
|
+
return new SuiMoveAbortError(Number.NEGATIVE_INFINITY, e);
|
|
30
|
+
} else {
|
|
31
|
+
return new SuiMoveAbortError(Number(subStatusMatch[1]), e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
return new SuiMoveUnclassifiedError(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return new Error(e);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function suiMoveViewMultiResult(
|
|
42
|
+
client: SuiMoveProvider,
|
|
43
|
+
tx: SuiMoveTransaction,
|
|
44
|
+
resultIndex: number[],
|
|
45
|
+
): Promise<SuiMoveViewResult[][]> {
|
|
46
|
+
const { results, error } = await client.devInspectSuiMoveTransactionBlock({
|
|
47
|
+
transactionBlock: tx,
|
|
48
|
+
sender: MOCK_SENDER,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (error != undefined && error != null) {
|
|
52
|
+
throw handleError(error);
|
|
53
|
+
}
|
|
54
|
+
if (results === undefined || results === null) {
|
|
55
|
+
throw new Error('No results found');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const selectedResults: SuiMoveExecutionResult[] = resultIndex.map((idx) => {
|
|
59
|
+
return results[idx];
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return selectedResults.map((result) => {
|
|
63
|
+
if (result.returnValues === undefined) {
|
|
64
|
+
throw new Error('No return values found');
|
|
65
|
+
}
|
|
66
|
+
return result.returnValues.map((result) => {
|
|
67
|
+
return {
|
|
68
|
+
value:
|
|
69
|
+
typeof result[0] === 'string'
|
|
70
|
+
? fromBase64(result[0])
|
|
71
|
+
: new Uint8Array(result[0]),
|
|
72
|
+
type: result[1],
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function suiMoveView(
|
|
79
|
+
suiClient: SuiMoveProvider,
|
|
80
|
+
tx: SuiMoveTransaction,
|
|
81
|
+
): Promise<SuiMoveViewResult[]> {
|
|
82
|
+
const results = await suiMoveViewMultiResult(suiClient, tx, [
|
|
83
|
+
tx.getData().commands.length - 1, // last command
|
|
84
|
+
]);
|
|
85
|
+
return results[0];
|
|
86
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@layerzerolabs/typescript-configuration/tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"strictPropertyInitialization": false,
|
|
7
|
+
"noUnusedLocals": false,
|
|
8
|
+
"noUnusedParameters": false,
|
|
9
|
+
"jsx": "react-jsx"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"**/__mocks__/*",
|
|
14
|
+
"**/__tests__/*",
|
|
15
|
+
"**/*.spec.ts",
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"include": ["src/**/*"]
|
|
20
|
+
}
|