@sentio/sdk 2.5.4 → 2.5.5-rc.2
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/lib/aptos/builtin/0x1.d.ts +70 -76
- package/lib/aptos/builtin/0x1.js +4 -4
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +14 -32
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +1 -0
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/codegen/types.test.js.map +1 -1
- package/lib/aptos/index.d.ts +2 -1
- package/lib/aptos/index.js +1 -0
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +1 -1
- package/lib/aptos/models.js.map +1 -1
- package/lib/aptos/module-client.d.ts +6 -0
- package/lib/aptos/module-client.js +25 -0
- package/lib/aptos/module-client.js.map +1 -0
- package/lib/aptos/module-client.test.d.ts +1 -0
- package/lib/aptos/module-client.test.js.map +1 -0
- package/lib/aptos/move-coder.d.ts +2 -0
- package/lib/aptos/move-coder.js +7 -15
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/network.d.ts +2 -0
- package/lib/aptos/network.js +1 -0
- package/lib/aptos/network.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +2 -0
- package/lib/move/abstract-codegen.js +44 -7
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/abstract-move-coder.d.ts +12 -5
- package/lib/move/abstract-move-coder.js +102 -6
- package/lib/move/abstract-move-coder.js.map +1 -1
- package/lib/move/ts-type.js +3 -1
- package/lib/move/ts-type.js.map +1 -1
- package/lib/move/types.js +2 -0
- package/lib/move/types.js.map +1 -1
- package/lib/move/utils.js +1 -1
- package/lib/move/utils.js.map +1 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +49 -49
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/codegen/codegen.js +2 -4
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/index.d.ts +1 -0
- package/lib/sui/index.js +1 -0
- package/lib/sui/index.js.map +1 -1
- package/lib/sui/models.d.ts +1 -1
- package/lib/sui/models.js.map +1 -1
- package/lib/sui/module-client.d.ts +3 -0
- package/lib/sui/module-client.js +7 -0
- package/lib/sui/module-client.js.map +1 -0
- package/lib/sui/move-coder.d.ts +2 -0
- package/lib/sui/move-coder.js +8 -17
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/utils.d.ts +2 -0
- package/lib/sui/utils.js +6 -0
- package/lib/sui/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/builtin/0x1.ts +71 -81
- package/src/aptos/builtin/0x3.ts +15 -21
- package/src/aptos/codegen/codegen.ts +1 -0
- package/src/aptos/index.ts +2 -1
- package/src/aptos/models.ts +1 -1
- package/src/aptos/module-client.ts +30 -0
- package/src/aptos/move-coder.ts +11 -17
- package/src/aptos/network.ts +2 -0
- package/src/move/abstract-codegen.ts +55 -9
- package/src/move/abstract-move-coder.ts +118 -10
- package/src/move/ts-type.ts +3 -1
- package/src/move/types.ts +2 -0
- package/src/move/utils.ts +1 -1
- package/src/sui/builtin/0x1.ts +2 -2
- package/src/sui/builtin/0x2.ts +50 -51
- package/src/sui/codegen/codegen.ts +2 -4
- package/src/sui/index.ts +2 -0
- package/src/sui/models.ts +1 -1
- package/src/sui/module-client.ts +7 -0
- package/src/sui/move-coder.ts +11 -21
- package/src/sui/utils.ts +8 -0
|
@@ -5,6 +5,7 @@ import { AbstractCodegen } from '../../move/abstract-codegen.js';
|
|
|
5
5
|
import { JsonRpcProvider } from '@mysten/sui.js';
|
|
6
6
|
import { toInternalModule } from '../move-types.js';
|
|
7
7
|
import { moduleQname, SPLITTER } from '../../move/index.js';
|
|
8
|
+
import { getMeaningfulFunctionParams } from '../utils.js';
|
|
8
9
|
export async function codegen(abisDir, outDir = 'src/types/sui') {
|
|
9
10
|
if (!fs.existsSync(abisDir)) {
|
|
10
11
|
return;
|
|
@@ -34,10 +35,7 @@ class SuiCodegen extends AbstractCodegen {
|
|
|
34
35
|
return await client.getNormalizedMoveModulesByPackage(account);
|
|
35
36
|
}
|
|
36
37
|
getMeaningfulFunctionParams(params) {
|
|
37
|
-
|
|
38
|
-
return params;
|
|
39
|
-
}
|
|
40
|
-
return params.slice(0, params.length - 1);
|
|
38
|
+
return getMeaningfulFunctionParams(params);
|
|
41
39
|
}
|
|
42
40
|
toInternalModules(modules) {
|
|
43
41
|
return Object.values(modules).map(toInternalModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAA4B,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAA4B,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,M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M,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACrD,CAAC;IAED,eAAe,CAAC,MAA0B;QACxC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA8B,CAAA;QAEtD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAC3C,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAClD,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;aACrD;SACF;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,eAAe,CAAC,QAAgB;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC3C,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,GAAG,CAAC,MAAM,CAAA;SAClB;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF","sourcesContent":["import { SuiNetwork } from '../network.js'\nimport * as fs from 'fs'\nimport chalk from 'chalk'\nimport { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'\nimport { AbstractCodegen } from '../../move/abstract-codegen.js'\nimport { JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'\nimport { toInternalModule } from '../move-types.js'\nimport { moduleQname, SPLITTER, TypeDescriptor } from '../../move/index.js'\nimport { getMeaningfulFunctionParams } from '../utils.js'\n\nexport async function codegen(abisDir: string, outDir = 'src/types/sui') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n console.log(chalk.green('Generated Types for Sui'))\n const gen = new SuiCodegen()\n await gen.generate(abisDir, outDir)\n}\n\nfunction getRpcEndpoint(network: SuiNetwork): string {\n switch (network) {\n case SuiNetwork.TEST_NET:\n return 'https://fullnode.testnet.sui.io/'\n }\n return 'https://fullnode.mainnet.sui.io/'\n}\n\nfunction getRpcClient(network: SuiNetwork): JsonRpcProvider {\n return new JsonRpcProvider(getRpcEndpoint(network))\n}\n\nclass SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {\n ADDRESS_TYPE = 'SuiAddress'\n MAIN_NET = SuiNetwork.MAIN_NET\n TEST_NET = SuiNetwork.TEST_NET\n PREFIX = 'Sui'\n STRUCT_FIELD_NAME = 'fields'\n\n async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModules> {\n const client = getRpcClient(network)\n return await client.getNormalizedMoveModulesByPackage(account)\n }\n\n getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n return getMeaningfulFunctionParams(params)\n }\n\n toInternalModules(modules: SuiMoveNormalizedModules): InternalMoveModule[] {\n return Object.values(modules).map(toInternalModule)\n }\n\n getEventStructs(module: InternalMoveModule) {\n const qname = moduleQname(module)\n const eventMap = new Map<string, InternalMoveStruct>()\n\n for (const struct of module.structs) {\n const abilities = new Set(struct.abilities)\n if (abilities.has('Drop') && abilities.has('Copy')) {\n eventMap.set(qname + SPLITTER + struct.name, struct)\n }\n }\n return eventMap\n }\n\n readModulesFile(fullPath: string) {\n const res = super.readModulesFile(fullPath)\n if (res.result) {\n return res.result\n }\n return res\n }\n}\n"]}
|
package/lib/sui/index.d.ts
CHANGED
package/lib/sui/index.js
CHANGED
package/lib/sui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAErE,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAI3B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["export { SuiBaseProcessor, SuiBindOptions } from './sui-processor.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAErE,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAI3B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA","sourcesContent":["export { SuiBaseProcessor, SuiBindOptions } from './sui-processor.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n\nexport { ModuleClient } from './module-client.js'\n"]}
|
package/lib/sui/models.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type TypedEventInstance<T> = MoveEvent & {
|
|
|
6
6
|
fields_decoded: T;
|
|
7
7
|
type_arguments: string[];
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type TypedFunctionPayload<T extends Array<any>> = MoveCall & {
|
|
10
10
|
/**
|
|
11
11
|
* decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
|
|
12
12
|
*/
|
package/lib/sui/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/sui/models.ts"],"names":[],"mappings":"","sourcesContent":["import { MoveEvent, MoveCall } from '@mysten/sui.js'\n\nexport type TypedEventInstance<T> = MoveEvent & {\n /**\n * decoded data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch\n */\n fields_decoded: T\n\n type_arguments: string[]\n}\n\nexport type
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/sui/models.ts"],"names":[],"mappings":"","sourcesContent":["import { MoveEvent, MoveCall } from '@mysten/sui.js'\n\nexport type TypedEventInstance<T> = MoveEvent & {\n /**\n * decoded data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch\n */\n fields_decoded: T\n\n type_arguments: string[]\n}\n\nexport type TypedFunctionPayload<T extends Array<any>> = MoveCall & {\n /**\n * decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch\n */\n arguments_decoded: T\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-client.js","sourceRoot":"","sources":["../../src/sui/module-client.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,MAAM,OAAO,YAAY;IAChB,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,aAAuB,EAAE,IAAW,EAAE,cAAuB;QAClG,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["// import { JsonRpcProvider } from \"@mysten/sui.js\";\n\nexport class ModuleClient {\n public async viewDecoded(func: string, typeArguments: string[], args: any[], ledger_version?: bigint) {\n throw Error('not implemented')\n }\n}\n"]}
|
package/lib/sui/move-coder.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TypedEventInstance } from './models.js';
|
|
2
2
|
import { AbstractMoveCoder } from '../move/abstract-move-coder.js';
|
|
3
3
|
import { MoveCall, MoveEvent, SuiMoveNormalizedModule } from '@mysten/sui.js';
|
|
4
|
+
import { TypeDescriptor } from '../move/index.js';
|
|
4
5
|
export declare class MoveCoder extends AbstractMoveCoder<MoveEvent> {
|
|
5
6
|
load(module: SuiMoveNormalizedModule): void;
|
|
6
7
|
decodeEvent<T>(event: MoveEvent): TypedEventInstance<T> | undefined;
|
|
7
8
|
filterAndDecodeEvents<T>(typeQname: string, resources: MoveEvent[]): TypedEventInstance<T>[];
|
|
9
|
+
getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
|
|
8
10
|
decodeFunctionPayload(payload: MoveCall): MoveCall;
|
|
9
11
|
}
|
|
10
12
|
export declare const MOVE_CODER: MoveCoder;
|
package/lib/sui/move-coder.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbstractMoveCoder } from '../move/abstract-move-coder.js';
|
|
2
2
|
import { toInternalModule } from './move-types.js';
|
|
3
3
|
import { SPLITTER } from '../move/index.js';
|
|
4
|
+
import { getMeaningfulFunctionParams } from './utils.js';
|
|
4
5
|
export class MoveCoder extends AbstractMoveCoder {
|
|
5
6
|
load(module) {
|
|
6
7
|
if (this.contains(module.address, module.name)) {
|
|
@@ -22,24 +23,14 @@ export class MoveCoder extends AbstractMoveCoder {
|
|
|
22
23
|
return { ...event, fields_decoded: res?.data_decoded, type_arguments: res?.type_arguments || [] };
|
|
23
24
|
});
|
|
24
25
|
}
|
|
26
|
+
getMeaningfulFunctionParams(params) {
|
|
27
|
+
return getMeaningfulFunctionParams(params);
|
|
28
|
+
}
|
|
25
29
|
decodeFunctionPayload(payload) {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const func = this.getMoveFunction(functionType);
|
|
31
|
-
const params = func.params.slice(0, func.params.length - 1);
|
|
32
|
-
const args = payload.arguments || [];
|
|
33
|
-
for (const [idx, arg] of args.entries()) {
|
|
34
|
-
// TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
|
|
35
|
-
const argType = params[idx];
|
|
36
|
-
argumentsTyped.push(this.decode(arg, argType));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
console.error('Decoding error for ', JSON.stringify(payload), e);
|
|
41
|
-
return payload;
|
|
42
|
-
}
|
|
30
|
+
const functionType = [payload.package.objectId, payload.module, payload.function].join(SPLITTER);
|
|
31
|
+
const func = this.getMoveFunction(functionType);
|
|
32
|
+
const params = getMeaningfulFunctionParams(func.params);
|
|
33
|
+
const argumentsTyped = this.decodeArray(payload.arguments || [], params);
|
|
43
34
|
return {
|
|
44
35
|
...payload,
|
|
45
36
|
arguments_decoded: argumentsTyped,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-coder.js","sourceRoot":"","sources":["../../src/sui/move-coder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"move-coder.js","sourceRoot":"","sources":["../../src/sui/move-coder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAkB,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,OAAO,SAAU,SAAQ,iBAA4B;IACzD,IAAI,CAAC,MAA+B;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE;YAC9C,OAAM;SACP;QACD,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED,WAAW,CAAI,KAAgB;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAI,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;QACrE,OAAO,EAAE,GAAG,KAAK,EAAE,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BAAiB,EAAE,cAAc;SACL,CAAA;IAChC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,SAAS,EAAE,CAAA;AAEzC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { TypedEventInstance, TypedFunctionPayload } from './models.js'\nimport { AbstractMoveCoder } from '../move/abstract-move-coder.js'\nimport { MoveCall, MoveEvent, SuiMoveNormalizedModule } from '@mysten/sui.js'\nimport { toInternalModule } from './move-types.js'\nimport { SPLITTER, TypeDescriptor } from '../move/index.js'\nimport { getMeaningfulFunctionParams } from './utils.js'\n\nexport class MoveCoder extends AbstractMoveCoder<MoveEvent> {\n load(module: SuiMoveNormalizedModule) {\n if (this.contains(module.address, module.name)) {\n return\n }\n this.loadInternal(toInternalModule(module))\n }\n\n decodeEvent<T>(event: MoveEvent): TypedEventInstance<T> | undefined {\n const res = this.decodedInternal<T>({ ...event, data: event.fields })\n return { ...event, fields_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }\n }\n filterAndDecodeEvents<T>(typeQname: string, resources: MoveEvent[]): TypedEventInstance<T>[] {\n const resp = this.filterAndDecodeInternal(\n typeQname,\n resources.map((event) => {\n return { ...event, data: event.fields, type: event.type }\n })\n )\n return resp.map((res) => {\n delete res.data_decoded\n const event = res as MoveEvent\n return { ...event, fields_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }\n })\n }\n getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n return getMeaningfulFunctionParams(params)\n }\n\n decodeFunctionPayload(payload: MoveCall): MoveCall {\n const functionType = [payload.package.objectId, payload.module, payload.function].join(SPLITTER)\n const func = this.getMoveFunction(functionType)\n const params = getMeaningfulFunctionParams(func.params)\n const argumentsTyped = this.decodeArray(payload.arguments || [], params)\n return {\n ...payload,\n arguments_decoded: argumentsTyped,\n } as TypedFunctionPayload<any>\n }\n}\n\nexport const MOVE_CODER = new MoveCoder()\n\nexport function defaultMoveCoder(): MoveCoder {\n return MOVE_CODER\n}\n"]}
|
package/lib/sui/utils.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { SuiTransactionResponse } from '@mysten/sui.js';
|
|
2
|
+
import { TypeDescriptor } from '../move/index.js';
|
|
2
3
|
export declare function getMoveCalls(tx: SuiTransactionResponse): import("@mysten/sui.js").MoveCall[];
|
|
4
|
+
export declare function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
|
package/lib/sui/utils.js
CHANGED
package/lib/sui/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sui/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,sBAAsB,EAAsB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sui/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,sBAAsB,EAAsB,MAAM,gBAAgB,CAAA;AAGnG,MAAM,UAAU,YAAY,CAAC,EAA0B;IACrD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAsB,EAAE,EAAE;QACzE,MAAM,IAAI,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAA;QACvC,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,IAAI,CAAC,CAAA;SACd;QACD,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAAwB;IAClE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,MAAM,CAAA;KACd;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { SuiTransactionResponse, getMoveCallTransaction, SuiTransactionKind } from '@mysten/sui.js'\nimport { TypeDescriptor } from '../move/index.js'\n\nexport function getMoveCalls(tx: SuiTransactionResponse) {\n return tx.certificate.data.transactions.flatMap((tx: SuiTransactionKind) => {\n const call = getMoveCallTransaction(tx)\n if (call) {\n return [call]\n }\n return []\n })\n}\n\nexport function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n if (params.length === 0) {\n return params\n }\n return params.slice(0, params.length - 1)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.5-rc.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@project-serum/anchor": "^0.26.0",
|
|
24
24
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
|
25
25
|
"@sentio/ethers-v6": "^1.0.25",
|
|
26
|
-
"@sentio/protos": "^2.5.
|
|
27
|
-
"@sentio/runtime": "^2.5.
|
|
26
|
+
"@sentio/protos": "^2.5.5-rc.2",
|
|
27
|
+
"@sentio/runtime": "^2.5.5-rc.2",
|
|
28
28
|
"@solana/web3.js": "^1.73.2",
|
|
29
29
|
"@types/prettier": "^2.7.2",
|
|
30
30
|
"aptos-sdk": "npm:@sentio/aptos@^1.6.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=16"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "1b27caf3f508236131c4dc11827f1f10daee052a"
|
|
82
82
|
}
|