@sentio/sdk 1.37.0-rc.1 → 1.37.0-rc.3

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.
Files changed (136) hide show
  1. package/lib/builtin/index.d.ts +0 -2
  2. package/lib/builtin/index.js +1 -3
  3. package/lib/builtin/index.js.map +1 -1
  4. package/lib/core/eth-plugin.js +12 -15
  5. package/lib/core/eth-plugin.js.map +1 -1
  6. package/lib/core/index.d.ts +0 -4
  7. package/lib/core/index.js +1 -9
  8. package/lib/core/index.js.map +1 -1
  9. package/lib/core/numberish.d.ts +1 -1
  10. package/lib/core/numberish.js +5 -13
  11. package/lib/core/numberish.js.map +1 -1
  12. package/lib/core/sui-plugin.js +1 -1
  13. package/lib/core/sui-plugin.js.map +1 -1
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js +3 -14
  16. package/lib/index.js.map +1 -1
  17. package/lib/service.d.ts +0 -4
  18. package/lib/service.js +40 -71
  19. package/lib/service.js.map +1 -1
  20. package/package.json +5 -15
  21. package/src/builtin/index.ts +1 -4
  22. package/src/core/eth-plugin.ts +5 -8
  23. package/src/core/index.ts +0 -5
  24. package/src/core/numberish.ts +8 -15
  25. package/src/core/sui-plugin.ts +2 -2
  26. package/src/index.ts +3 -1
  27. package/src/service.ts +13 -71
  28. package/lib/aptos/api.d.ts +0 -2
  29. package/lib/aptos/api.js +0 -14
  30. package/lib/aptos/api.js.map +0 -1
  31. package/lib/aptos/aptos-plugin.d.ts +0 -14
  32. package/lib/aptos/aptos-plugin.js +0 -185
  33. package/lib/aptos/aptos-plugin.js.map +0 -1
  34. package/lib/aptos/aptos-processor.d.ts +0 -75
  35. package/lib/aptos/aptos-processor.js +0 -193
  36. package/lib/aptos/aptos-processor.js.map +0 -1
  37. package/lib/aptos/context.d.ts +0 -22
  38. package/lib/aptos/context.js +0 -65
  39. package/lib/aptos/context.js.map +0 -1
  40. package/lib/aptos/index.d.ts +0 -9
  41. package/lib/aptos/index.js +0 -34
  42. package/lib/aptos/index.js.map +0 -1
  43. package/lib/aptos/models.d.ts +0 -23
  44. package/lib/aptos/models.js +0 -3
  45. package/lib/aptos/models.js.map +0 -1
  46. package/lib/aptos/network.d.ts +0 -14
  47. package/lib/aptos/network.js +0 -46
  48. package/lib/aptos/network.js.map +0 -1
  49. package/lib/aptos/runtime.d.ts +0 -2
  50. package/lib/aptos/runtime.js +0 -16
  51. package/lib/aptos/runtime.js.map +0 -1
  52. package/lib/aptos/type-registry.d.ts +0 -21
  53. package/lib/aptos/type-registry.js +0 -156
  54. package/lib/aptos/type-registry.js.map +0 -1
  55. package/lib/aptos/types.d.ts +0 -9
  56. package/lib/aptos/types.js +0 -135
  57. package/lib/aptos/types.js.map +0 -1
  58. package/lib/aptos/types.test.d.ts +0 -1
  59. package/lib/aptos/types.test.js.map +0 -1
  60. package/lib/aptos/utils.d.ts +0 -7
  61. package/lib/aptos/utils.js +0 -27
  62. package/lib/aptos/utils.js.map +0 -1
  63. package/lib/aptos-codegen/codegen.d.ts +0 -23
  64. package/lib/aptos-codegen/codegen.js +0 -364
  65. package/lib/aptos-codegen/codegen.js.map +0 -1
  66. package/lib/aptos-codegen/typegen.d.ts +0 -17
  67. package/lib/aptos-codegen/typegen.js +0 -142
  68. package/lib/aptos-codegen/typegen.js.map +0 -1
  69. package/lib/builtin/aptos/0x1.d.ts +0 -1913
  70. package/lib/builtin/aptos/0x1.js +0 -2748
  71. package/lib/builtin/aptos/0x1.js.map +0 -1
  72. package/lib/builtin/aptos/0x3.d.ts +0 -482
  73. package/lib/builtin/aptos/0x3.js +0 -526
  74. package/lib/builtin/aptos/0x3.js.map +0 -1
  75. package/lib/builtin/aptos/index.d.ts +0 -2
  76. package/lib/builtin/aptos/index.js +0 -29
  77. package/lib/builtin/aptos/index.js.map +0 -1
  78. package/lib/builtin/solana/index.d.ts +0 -2
  79. package/lib/builtin/solana/index.js +0 -19
  80. package/lib/builtin/solana/index.js.map +0 -1
  81. package/lib/builtin/solana/spl-token-processor.d.ts +0 -39
  82. package/lib/builtin/solana/spl-token-processor.js +0 -258
  83. package/lib/builtin/solana/spl-token-processor.js.map +0 -1
  84. package/lib/builtin/solana/types.d.ts +0 -427
  85. package/lib/builtin/solana/types.js +0 -203
  86. package/lib/builtin/solana/types.js.map +0 -1
  87. package/lib/builtin/solana/wormhole-processor.d.ts +0 -16
  88. package/lib/builtin/solana/wormhole-processor.js +0 -195
  89. package/lib/builtin/solana/wormhole-processor.js.map +0 -1
  90. package/lib/core/solana-context.d.ts +0 -11
  91. package/lib/core/solana-context.js +0 -34
  92. package/lib/core/solana-context.js.map +0 -1
  93. package/lib/core/solana-options.d.ts +0 -8
  94. package/lib/core/solana-options.js +0 -13
  95. package/lib/core/solana-options.js.map +0 -1
  96. package/lib/core/solana-plugin.d.ts +0 -9
  97. package/lib/core/solana-plugin.js +0 -79
  98. package/lib/core/solana-plugin.js.map +0 -1
  99. package/lib/core/solana-processor.d.ts +0 -40
  100. package/lib/core/solana-processor.js +0 -80
  101. package/lib/core/solana-processor.js.map +0 -1
  102. package/lib/solana-codegen/codegen.d.ts +0 -1
  103. package/lib/solana-codegen/codegen.js +0 -113
  104. package/lib/solana-codegen/codegen.js.map +0 -1
  105. package/lib/test-abi-code-gen.d.ts +0 -2
  106. package/lib/test-abi-code-gen.js +0 -20
  107. package/lib/test-abi-code-gen.js.map +0 -1
  108. package/src/abis/aptos/0x1.json +0 -9205
  109. package/src/abis/aptos/0x3.json +0 -1515
  110. package/src/aptos/api.ts +0 -11
  111. package/src/aptos/aptos-plugin.ts +0 -216
  112. package/src/aptos/aptos-processor.ts +0 -305
  113. package/src/aptos/context.ts +0 -74
  114. package/src/aptos/index.ts +0 -10
  115. package/src/aptos/models.ts +0 -34
  116. package/src/aptos/network.ts +0 -42
  117. package/src/aptos/runtime.ts +0 -13
  118. package/src/aptos/type-registry.ts +0 -187
  119. package/src/aptos/types.ts +0 -149
  120. package/src/aptos/utils.ts +0 -26
  121. package/src/aptos-codegen/codegen.ts +0 -428
  122. package/src/aptos-codegen/tsconfig.json +0 -9
  123. package/src/aptos-codegen/typegen.ts +0 -153
  124. package/src/builtin/aptos/0x1.ts +0 -4210
  125. package/src/builtin/aptos/0x3.ts +0 -888
  126. package/src/builtin/aptos/index.ts +0 -2
  127. package/src/builtin/solana/index.ts +0 -2
  128. package/src/builtin/solana/spl-token-processor.ts +0 -298
  129. package/src/builtin/solana/types.ts +0 -279
  130. package/src/builtin/solana/wormhole-processor.ts +0 -178
  131. package/src/core/solana-context.ts +0 -34
  132. package/src/core/solana-options.ts +0 -8
  133. package/src/core/solana-plugin.ts +0 -97
  134. package/src/core/solana-processor.ts +0 -102
  135. package/src/solana-codegen/codegen.ts +0 -116
  136. package/src/test-abi-code-gen.ts +0 -16
@@ -1,156 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TYPE_REGISTRY = exports.TypeRegistry = void 0;
4
- const utils_1 = require("./utils");
5
- const types_1 = require("./types");
6
- class TypeRegistry {
7
- moduleMapping = new Map();
8
- typeMapping = new Map();
9
- funcMapping = new Map();
10
- contains(account, name) {
11
- return this.moduleMapping.has(account + '::' + name);
12
- }
13
- load(module) {
14
- if (this.contains(module.address, module.name)) {
15
- return;
16
- }
17
- this.moduleMapping.set((0, utils_1.moduleQname)(module), module);
18
- for (const struct of module.structs) {
19
- // TODO move to util
20
- const key = [module.address, module.name, struct.name].join(utils_1.SPLITTER);
21
- this.typeMapping.set(key, struct);
22
- }
23
- for (const func of module.exposed_functions) {
24
- if (!func.is_entry) {
25
- continue;
26
- }
27
- const key = [module.address, module.name, func.name].join(utils_1.SPLITTER);
28
- this.funcMapping.set(key, func);
29
- }
30
- }
31
- getMoveStruct(type) {
32
- const struct = this.typeMapping.get(type);
33
- if (!struct) {
34
- throw new Error('Failed to load type' + type);
35
- }
36
- return struct;
37
- }
38
- getMoveFunction(type) {
39
- const func = this.funcMapping.get(type);
40
- if (!func) {
41
- throw new Error('Failed to load function' + type);
42
- }
43
- return func;
44
- }
45
- decode(data, type) {
46
- // process simple type
47
- if (type.qname.startsWith('&')) {
48
- return data;
49
- }
50
- switch (type.qname) {
51
- case 'signer': // TODO check this
52
- case 'address':
53
- case '0x1::string::String':
54
- case 'bool':
55
- case 'u8':
56
- case 'u16':
57
- case 'u32':
58
- return data;
59
- case 'u64':
60
- case 'u128':
61
- return BigInt(data);
62
- }
63
- // process vector
64
- if (type.qname === utils_1.VECTOR_STR) {
65
- // vector<u8> as hex string
66
- if (type.typeArgs[0].qname === 'u8') {
67
- return data;
68
- }
69
- const res = [];
70
- for (const entry of data) {
71
- res.push(this.decode(entry, type.typeArgs[0]));
72
- }
73
- return res;
74
- }
75
- // Process complex type
76
- const struct = this.getMoveStruct(type.qname);
77
- const typeCtx = new Map();
78
- for (const [idx, typeArg] of type.typeArgs.entries()) {
79
- typeCtx.set('T' + idx, typeArg);
80
- }
81
- const typedData = {};
82
- for (const field of struct.fields) {
83
- let filedType = (0, types_1.parseMoveType)(field.type);
84
- filedType = filedType.applyTypeArgs(typeCtx);
85
- const value = this.decode(data[field.name], filedType);
86
- typedData[field.name] = value;
87
- }
88
- return typedData;
89
- }
90
- decodeEvent(event) {
91
- return this.decodedInternal(event);
92
- }
93
- filterAndDecodeEvents(typeQname, resources) {
94
- return this.filterAndDecodeInternal(typeQname, resources);
95
- }
96
- decodeResource(res) {
97
- return this.decodedInternal(res);
98
- }
99
- filterAndDecodeResources(typeQname, resources) {
100
- return this.filterAndDecodeInternal(typeQname, resources);
101
- }
102
- filterAndDecodeInternal(typeQname, structs) {
103
- if (!structs) {
104
- return [];
105
- }
106
- const results = [];
107
- for (const resource of structs) {
108
- if (resource.type.split('<')[0] !== typeQname) {
109
- continue;
110
- }
111
- const result = this.decodedInternal(resource);
112
- if (result) {
113
- results.push(result);
114
- }
115
- }
116
- return results;
117
- }
118
- decodedInternal(typeStruct) {
119
- const registry = exports.TYPE_REGISTRY;
120
- // this.loadTypes(registry)
121
- // TODO check if module is not loaded
122
- const typeDescriptor = (0, types_1.parseMoveType)(typeStruct.type);
123
- const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature());
124
- let dataTyped = undefined;
125
- try {
126
- dataTyped = registry.decode(typeStruct.data, typeDescriptor);
127
- }
128
- catch (e) {
129
- console.error('Decoding error for ', JSON.stringify(typeStruct), e);
130
- return undefined;
131
- }
132
- return { ...typeStruct, data_typed: dataTyped, type_arguments: typeArguments };
133
- }
134
- decodeFunctionPayload(payload) {
135
- const registry = exports.TYPE_REGISTRY;
136
- // this.loadTypes(registry)
137
- const argumentsTyped = [];
138
- try {
139
- const func = registry.getMoveFunction(payload.function);
140
- const params = (0, utils_1.getMeaningfulFunctionParams)(func);
141
- for (const [idx, arg] of payload.arguments.entries()) {
142
- // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
143
- const argType = (0, types_1.parseMoveType)(params[idx]);
144
- argumentsTyped.push(registry.decode(arg, argType));
145
- }
146
- }
147
- catch (e) {
148
- console.error('Decoding error for ', JSON.stringify(payload), e);
149
- return payload;
150
- }
151
- return { ...payload, arguments_typed: argumentsTyped };
152
- }
153
- }
154
- exports.TypeRegistry = TypeRegistry;
155
- exports.TYPE_REGISTRY = new TypeRegistry();
156
- //# sourceMappingURL=type-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-registry.js","sourceRoot":"","sources":["../../src/aptos/type-registry.ts"],"names":[],"mappings":";;;AAQA,mCAAwF;AACxF,mCAAuD;AASvD,MAAa,YAAY;IACvB,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC7C,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC3C,WAAW,GAAG,IAAI,GAAG,EAAwB,CAAA;IAE7C,QAAQ,CAAC,OAAe,EAAE,IAAY;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,CAAC,MAAkB;QACr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,EAAE;gBACpD,sGAAsG;gBACtG,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;gBAC1C,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;aACnD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;YAChE,OAAO,OAAO,CAAA;SACf;QAED,OAAO,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAoC,CAAA;IAC1F,CAAC;CACF;AAtKD,oCAsKC;AAEY,QAAA,aAAa,GAAG,IAAI,YAAY,EAAE,CAAA","sourcesContent":["import {\n Event,\n MoveFunction,\n MoveModule,\n MoveResource,\n MoveStruct,\n TransactionPayload_EntryFunctionPayload,\n} from 'aptos-sdk/src/generated'\nimport { getMeaningfulFunctionParams, moduleQname, SPLITTER, VECTOR_STR } from './utils'\nimport { parseMoveType, TypeDescriptor } from './types'\nimport {\n TypedEventInstance,\n TypedMoveResource,\n StructWithTag,\n StructWithType,\n TypedEntryFunctionPayload,\n} from './models'\n\nexport class TypeRegistry {\n moduleMapping = new Map<string, MoveModule>()\n typeMapping = new Map<string, MoveStruct>()\n funcMapping = new Map<string, MoveFunction>()\n\n contains(account: string, name: string) {\n return this.moduleMapping.has(account + '::' + name)\n }\n\n load(module: MoveModule) {\n if (this.contains(module.address, module.name)) {\n return\n }\n this.moduleMapping.set(moduleQname(module), module)\n\n for (const struct of module.structs) {\n // TODO move to util\n const key = [module.address, module.name, struct.name].join(SPLITTER)\n this.typeMapping.set(key, struct)\n }\n\n for (const func of module.exposed_functions) {\n if (!func.is_entry) {\n continue\n }\n const key = [module.address, module.name, func.name].join(SPLITTER)\n this.funcMapping.set(key, func)\n }\n }\n\n getMoveStruct(type: string): MoveStruct {\n const struct = this.typeMapping.get(type)\n if (!struct) {\n throw new Error('Failed to load type' + type)\n }\n return struct\n }\n\n getMoveFunction(type: string): MoveFunction {\n const func = this.funcMapping.get(type)\n if (!func) {\n throw new Error('Failed to load function' + type)\n }\n return func\n }\n\n decode(data: any, type: TypeDescriptor): any {\n // process simple type\n if (type.qname.startsWith('&')) {\n return data\n }\n switch (type.qname) {\n case 'signer': // TODO check this\n case 'address':\n case '0x1::string::String':\n case 'bool':\n case 'u8':\n case 'u16':\n case 'u32':\n return data\n case 'u64':\n case 'u128':\n return BigInt(data)\n }\n\n // process vector\n if (type.qname === VECTOR_STR) {\n // vector<u8> as hex string\n if (type.typeArgs[0].qname === 'u8') {\n return data\n }\n\n const res = []\n for (const entry of data) {\n res.push(this.decode(entry, type.typeArgs[0]))\n }\n return res\n }\n\n // Process complex type\n const struct = this.getMoveStruct(type.qname)\n\n const typeCtx = new Map<string, TypeDescriptor>()\n for (const [idx, typeArg] of type.typeArgs.entries()) {\n typeCtx.set('T' + idx, typeArg)\n }\n\n const typedData: any = {}\n\n for (const field of struct.fields) {\n let filedType = parseMoveType(field.type)\n filedType = filedType.applyTypeArgs(typeCtx)\n const value = this.decode(data[field.name], filedType)\n typedData[field.name] = value\n }\n return typedData\n }\n\n decodeEvent<T>(event: Event): TypedEventInstance<T> | undefined {\n return this.decodedInternal<T>(event) as TypedEventInstance<T>\n }\n filterAndDecodeEvents<T>(typeQname: string, resources: Event[]): TypedEventInstance<T>[] {\n return this.filterAndDecodeInternal(typeQname, resources) as TypedEventInstance<T>[]\n }\n decodeResource<T>(res: MoveResource): TypedMoveResource<T> | undefined {\n return this.decodedInternal<T>(res)\n }\n filterAndDecodeResources<T>(typeQname: string, resources: MoveResource[]): TypedMoveResource<T>[] {\n return this.filterAndDecodeInternal(typeQname, resources)\n }\n\n private filterAndDecodeInternal<T>(typeQname: string, structs: StructWithTag[]): StructWithType<T>[] {\n if (!structs) {\n return []\n }\n const results: StructWithType<T>[] = []\n for (const resource of structs) {\n if (resource.type.split('<')[0] !== typeQname) {\n continue\n }\n const result = this.decodedInternal(resource)\n if (result) {\n results.push(result as StructWithType<T>)\n }\n }\n return results\n }\n\n private decodedInternal<T>(typeStruct: StructWithTag): StructWithType<T> | undefined {\n const registry = TYPE_REGISTRY\n // this.loadTypes(registry)\n // TODO check if module is not loaded\n\n const typeDescriptor = parseMoveType(typeStruct.type)\n const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature())\n\n let dataTyped = undefined\n try {\n dataTyped = registry.decode(typeStruct.data, typeDescriptor)\n } catch (e) {\n console.error('Decoding error for ', JSON.stringify(typeStruct), e)\n return undefined\n }\n return { ...typeStruct, data_typed: dataTyped, type_arguments: typeArguments } as StructWithType<T>\n }\n\n decodeFunctionPayload(payload: TransactionPayload_EntryFunctionPayload): TransactionPayload_EntryFunctionPayload {\n const registry = TYPE_REGISTRY\n // this.loadTypes(registry)\n const argumentsTyped: any[] = []\n\n try {\n const func = registry.getMoveFunction(payload.function)\n const params = getMeaningfulFunctionParams(func)\n for (const [idx, arg] of payload.arguments.entries()) {\n // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them\n const argType = parseMoveType(params[idx])\n argumentsTyped.push(registry.decode(arg, argType))\n }\n } catch (e) {\n console.error('Decoding error for ', JSON.stringify(payload), e)\n return payload\n }\n\n return { ...payload, arguments_typed: argumentsTyped } as TypedEntryFunctionPayload<any>\n }\n}\n\nexport const TYPE_REGISTRY = new TypeRegistry()\n"]}
@@ -1,9 +0,0 @@
1
- export declare class TypeDescriptor {
2
- qname: string;
3
- typeArgs: TypeDescriptor[];
4
- constructor(symbol: string, typeParams?: TypeDescriptor[]);
5
- getSignature(): string;
6
- applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor;
7
- dependedTypes(): string[];
8
- }
9
- export declare function parseMoveType(type: string): TypeDescriptor;
@@ -1,135 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMoveType = exports.TypeDescriptor = void 0;
4
- const utils_1 = require("./utils");
5
- class TypeDescriptor {
6
- // type: string
7
- // qualified name without type parameters
8
- qname;
9
- // account?: string
10
- // module?: string
11
- typeArgs;
12
- constructor(symbol, typeParams) {
13
- this.qname = symbol;
14
- this.typeArgs = typeParams || [];
15
- }
16
- getSignature() {
17
- if (this.typeArgs.length > 0) {
18
- return this.qname + '<' + this.typeArgs.map((t) => t.getSignature()).join(', ') + '>';
19
- }
20
- return this.qname;
21
- }
22
- // Replace T0, T1 with more concrete type
23
- applyTypeArgs(ctx) {
24
- const replace = ctx.get(this.qname);
25
- if (replace) {
26
- return replace;
27
- }
28
- if (ctx.size === 0 || this.typeArgs.length === 0) {
29
- return this;
30
- }
31
- const typeArgs = [];
32
- for (const arg of this.typeArgs) {
33
- const replace = ctx.get(arg.qname);
34
- if (replace) {
35
- typeArgs.push(replace);
36
- }
37
- else {
38
- typeArgs.push(arg.applyTypeArgs(ctx));
39
- }
40
- }
41
- return new TypeDescriptor(this.qname, typeArgs);
42
- }
43
- // all depended types including itself, not include system type
44
- dependedTypes() {
45
- if (this.qname.startsWith('&')) {
46
- return [];
47
- }
48
- switch (this.qname) {
49
- case 'signer':
50
- case 'address':
51
- case '0x1::string::String':
52
- case 'bool':
53
- case 'u8':
54
- case 'u16':
55
- case 'u32':
56
- case 'u64':
57
- case 'u128':
58
- return [];
59
- }
60
- // Type parameters are not depended
61
- if (this.qname.indexOf(utils_1.SPLITTER) == -1) {
62
- if (this.qname.startsWith('T')) {
63
- return [];
64
- }
65
- }
66
- const types = new Set();
67
- for (const param of this.typeArgs) {
68
- param.dependedTypes().forEach((t) => types.add(t));
69
- }
70
- if (this.qname !== utils_1.VECTOR_STR) {
71
- types.add(this.qname);
72
- }
73
- return Array.from(types);
74
- }
75
- }
76
- exports.TypeDescriptor = TypeDescriptor;
77
- function parseMoveType(type) {
78
- // type = type.replace('&', '')
79
- type = type.replaceAll('&mut ', '&');
80
- type = type.replaceAll('mut ', '');
81
- // TODO replace ' ' is not exactly safe, need to double check this
82
- type = type.replaceAll(' ', '');
83
- const stack = [new TypeDescriptor('')];
84
- let buffer = [];
85
- // xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>
86
- for (let i = 0; i < type.length; i++) {
87
- const ch = type[i];
88
- if (ch === '<') {
89
- // const symbol = type.slice(symbolStart, i)
90
- // symbolStart =
91
- const symbol = buffer.join('');
92
- buffer = [];
93
- stack[stack.length - 1].qname = symbol;
94
- stack.push(new TypeDescriptor(''));
95
- continue;
96
- }
97
- if (ch === '>') {
98
- const typeParam = stack.pop();
99
- if (!typeParam) {
100
- throw Error('Uxpectecd stack size');
101
- }
102
- if (buffer.length > 0) {
103
- typeParam.qname = buffer.join('');
104
- buffer = [];
105
- }
106
- stack[stack.length - 1].typeArgs.push(typeParam);
107
- continue;
108
- }
109
- if (ch === ',') {
110
- const typeParam = stack.pop();
111
- if (!typeParam) {
112
- throw Error('Uxpectecd stack size');
113
- }
114
- if (buffer.length > 0) {
115
- typeParam.qname = buffer.join('');
116
- buffer = [];
117
- }
118
- stack[stack.length - 1].typeArgs.push(typeParam);
119
- // continue parse next param
120
- stack.push(new TypeDescriptor(''));
121
- continue;
122
- }
123
- buffer.push(ch);
124
- }
125
- if (buffer.length > 0) {
126
- stack[stack.length - 1].qname = buffer.join('');
127
- }
128
- const res = stack.pop();
129
- if (!res || stack.length > 0) {
130
- throw Error('Uxpectecd stack size');
131
- }
132
- return res;
133
- }
134
- exports.parseMoveType = parseMoveType;
135
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/aptos/types.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAE9C,MAAa,cAAc;IACzB,eAAe;IAEf,yCAAyC;IACzC,KAAK,CAAQ;IACb,mBAAmB;IACnB,kBAAkB;IAElB,QAAQ,CAAkB;IAE1B,YAAY,MAAc,EAAE,UAA6B;QACvD,IAAI,CAAC,KAAK,GAAG,MAAM,C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CAAC,EAAE;gBACrB,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBACjC,MAAM,GAAG,EAAE,CAAA;aACZ;YAED,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAChD,4BAA4B;YAC5B,KAAK,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;YAClC,SAAQ;SACT;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAChB;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAChD;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAA;IACvB,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;KACpC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAhED,sCAgEC","sourcesContent":["import { SPLITTER, VECTOR_STR } from './utils'\n\nexport class TypeDescriptor {\n // type: string\n\n // qualified name without type parameters\n qname: string\n // account?: string\n // module?: string\n\n typeArgs: TypeDescriptor[]\n\n constructor(symbol: string, typeParams?: TypeDescriptor[]) {\n this.qname = symbol\n this.typeArgs = typeParams || []\n }\n\n getSignature(): string {\n if (this.typeArgs.length > 0) {\n return this.qname + '<' + this.typeArgs.map((t) => t.getSignature()).join(', ') + '>'\n }\n return this.qname\n }\n\n // Replace T0, T1 with more concrete type\n applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor {\n const replace = ctx.get(this.qname)\n if (replace) {\n return replace\n }\n if (ctx.size === 0 || this.typeArgs.length === 0) {\n return this\n }\n\n const typeArgs: TypeDescriptor[] = []\n for (const arg of this.typeArgs) {\n const replace = ctx.get(arg.qname)\n if (replace) {\n typeArgs.push(replace)\n } else {\n typeArgs.push(arg.applyTypeArgs(ctx))\n }\n }\n return new TypeDescriptor(this.qname, typeArgs)\n }\n\n // all depended types including itself, not include system type\n dependedTypes(): string[] {\n if (this.qname.startsWith('&')) {\n return []\n }\n switch (this.qname) {\n case 'signer':\n case 'address':\n case '0x1::string::String':\n case 'bool':\n case 'u8':\n case 'u16':\n case 'u32':\n case 'u64':\n case 'u128':\n return []\n }\n\n // Type parameters are not depended\n if (this.qname.indexOf(SPLITTER) == -1) {\n if (this.qname.startsWith('T')) {\n return []\n }\n }\n\n const types = new Set<string>()\n for (const param of this.typeArgs) {\n param.dependedTypes().forEach((t) => types.add(t))\n }\n\n if (this.qname !== VECTOR_STR) {\n types.add(this.qname)\n }\n\n return Array.from(types)\n }\n}\n\nexport function parseMoveType(type: string): TypeDescriptor {\n // type = type.replace('&', '')\n\n type = type.replaceAll('&mut ', '&')\n type = type.replaceAll('mut ', '')\n\n // TODO replace ' ' is not exactly safe, need to double check this\n type = type.replaceAll(' ', '')\n\n const stack: TypeDescriptor[] = [new TypeDescriptor('')]\n let buffer = []\n\n // xxx:asdf<g1<a,<c,d>>, b, g2<a,b>, e>\n for (let i = 0; i < type.length; i++) {\n const ch = type[i]\n if (ch === '<') {\n // const symbol = type.slice(symbolStart, i)\n // symbolStart =\n const symbol = buffer.join('')\n buffer = []\n stack[stack.length - 1].qname = symbol\n stack.push(new TypeDescriptor(''))\n continue\n }\n if (ch === '>') {\n const typeParam = stack.pop()\n if (!typeParam) {\n throw Error('Uxpectecd stack size')\n }\n if (buffer.length > 0) {\n typeParam.qname = buffer.join('')\n buffer = []\n }\n stack[stack.length - 1].typeArgs.push(typeParam)\n continue\n }\n if (ch === ',') {\n const typeParam = stack.pop()\n if (!typeParam) {\n throw Error('Uxpectecd stack size')\n }\n if (buffer.length > 0) {\n typeParam.qname = buffer.join('')\n buffer = []\n }\n\n stack[stack.length - 1].typeArgs.push(typeParam)\n // continue parse next param\n stack.push(new TypeDescriptor(''))\n continue\n }\n\n buffer.push(ch)\n }\n\n if (buffer.length > 0) {\n stack[stack.length - 1].qname = buffer.join('')\n }\n\n const res = stack.pop()\n if (!res || stack.length > 0) {\n throw Error('Uxpectecd stack size')\n }\n return res\n}\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.test.js","sourceRoot":"","sources":["../../src/aptos/types.test.ts"],"names":[],"mappings":";;AAAA,mDAA+C;AAC/C,+CAAoD;AAEpD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,oBAAa,CAAC,SAAS,CAAC,6BAAa,CAAC,CAAA;IACtC,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,OAAO,GAAG,6BAAa,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG;IACX,IAAI,EAAE,wBAAwB;IAC9B,cAAc,EAAE,EAAE;IAClB,SAAS,EAAE,CAAC,oEAAoE,CAAC;IACjF,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtB,QAAQ,EAAE,oCAAoC;CAC/C,CAAA","sourcesContent":["import { TYPE_REGISTRY } from './type-registry'\nimport { aptos_account } from '../builtin/aptos/0x1'\n\ndescribe('type decode', () => {\n aptos_account.loadTypes(TYPE_REGISTRY)\n test('decode function payload', async () => {\n const decoded = TYPE_REGISTRY.decodeFunctionPayload(data)\n console.log(decoded)\n })\n})\n\nconst data = {\n type: 'entry_function_payload',\n type_arguments: [],\n arguments: ['0xaaaf981fec16d967eb79bb51b4c6d39e75acb3482c6dabddb19ca9adbfceee80'],\n code: { bytecode: '' },\n function: '0x1::aptos_account::create_account',\n}\n"]}
@@ -1,7 +0,0 @@
1
- import { MoveFunction, MoveModule } from 'aptos-sdk/src/generated';
2
- export declare const SPLITTER = "::";
3
- export declare const VECTOR_STR = "vector";
4
- export declare function isFrameworkAccount(account: string): boolean;
5
- export declare function moduleQname(module: MoveModule): string;
6
- export declare function moduleQnameForType(type: string): [string, string];
7
- export declare function getMeaningfulFunctionParams(func: MoveFunction): string[];
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMeaningfulFunctionParams = exports.moduleQnameForType = exports.moduleQname = exports.isFrameworkAccount = exports.VECTOR_STR = exports.SPLITTER = void 0;
4
- exports.SPLITTER = '::';
5
- exports.VECTOR_STR = 'vector';
6
- function isFrameworkAccount(account) {
7
- return account === '0x1' || account === '0x2' || account === '0x3';
8
- }
9
- exports.isFrameworkAccount = isFrameworkAccount;
10
- function moduleQname(module) {
11
- return module.address.toLowerCase() + exports.SPLITTER + module.name;
12
- }
13
- exports.moduleQname = moduleQname;
14
- function moduleQnameForType(type) {
15
- const parts = type.split(exports.SPLITTER).slice(0, 2);
16
- return [parts[0], parts[1]];
17
- }
18
- exports.moduleQnameForType = moduleQnameForType;
19
- function getMeaningfulFunctionParams(func) {
20
- let params = func.params;
21
- if (func.params[0] === '&signer') {
22
- params = params.slice(1);
23
- }
24
- return params;
25
- }
26
- exports.getMeaningfulFunctionParams = getMeaningfulFunctionParams;
27
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/aptos/utils.ts"],"names":[],"mappings":";;;AAEa,QAAA,QAAQ,GAAG,IAAI,CAAA;AAEf,QAAA,UAAU,GAAG,QAAQ,CAAA;AAElC,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAA;AACpE,CAAC;AAFD,gDAEC;AAED,SAAgB,WAAW,CAAC,MAAkB;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,gBAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;AAC9D,CAAC;AAFD,kCAEC;AAED,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC7B,CAAC;AAHD,gDAGC;AAED,SAAgB,2BAA2B,CAAC,IAAkB;IAC5D,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IACxB,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QAChC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACzB;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kEAMC","sourcesContent":["import { MoveFunction, MoveModule } from 'aptos-sdk/src/generated'\n\nexport const SPLITTER = '::'\n\nexport const VECTOR_STR = 'vector'\n\nexport function isFrameworkAccount(account: string) {\n return account === '0x1' || account === '0x2' || account === '0x3'\n}\n\nexport function moduleQname(module: MoveModule): string {\n return module.address.toLowerCase() + SPLITTER + module.name\n}\n\nexport function moduleQnameForType(type: string): [string, string] {\n const parts = type.split(SPLITTER).slice(0, 2)\n return [parts[0], parts[1]]\n}\n\nexport function getMeaningfulFunctionParams(func: MoveFunction): string[] {\n let params = func.params\n if (func.params[0] === '&signer') {\n params = params.slice(1)\n }\n return params\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { MoveModuleBytecode } from 'aptos-sdk/src/generated';
2
- import { AccountRegister } from './typegen';
3
- import { AptosNetwork } from '../aptos/network';
4
- export declare function codeGenAptosProcessor(abisDir: string, outDir?: string): void;
5
- export declare function generate(srcDir: string, outputDir: string): Promise<void>;
6
- export declare function generateForNetwork(srcDir: string, outputDir: string, network: AptosNetwork): Promise<void>;
7
- interface OutputFile {
8
- fileName: string;
9
- fileContent: string;
10
- }
11
- interface Config {
12
- fileName: string;
13
- outputDir: string;
14
- network: AptosNetwork;
15
- }
16
- export declare class AccountCodegen {
17
- modules: MoveModuleBytecode[];
18
- config: Config;
19
- loader: AccountRegister;
20
- constructor(loader: AccountRegister, modules: MoveModuleBytecode[], config: Config);
21
- generate(): OutputFile[];
22
- }
23
- export {};