@sentio/sdk 2.10.2-rc.1 → 2.11.0-rc.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/lib/aptos/codegen/codegen.js +0 -1
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +2 -1
- package/lib/move/abstract-codegen.js +9 -8
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +170 -170
- package/lib/solana/builtin/types.js +2 -1
- package/lib/solana/builtin/types.js.map +1 -1
- package/lib/sui/builtin/0x1.js +1 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +235 -640
- package/lib/sui/builtin/0x2.js +294 -716
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +566 -0
- package/lib/sui/builtin/0x3.js +681 -0
- package/lib/sui/builtin/0x3.js.map +1 -0
- package/lib/sui/builtin/index.d.ts +1 -0
- package/lib/sui/builtin/index.js +1 -0
- package/lib/sui/builtin/index.js.map +1 -1
- package/lib/sui/codegen/codegen.js +4 -3
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/context.d.ts +3 -3
- package/lib/sui/context.js +1 -1
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/models.d.ts +4 -4
- package/lib/sui/models.js.map +1 -1
- package/lib/sui/move-coder.d.ts +5 -5
- package/lib/sui/move-coder.js +19 -7
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/move-types.js +7 -7
- package/lib/sui/move-types.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +3 -3
- package/lib/sui/sui-processor.js +15 -9
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/utils.d.ts +2 -2
- package/lib/sui/utils.js +13 -5
- package/lib/sui/utils.js.map +1 -1
- package/lib/testing/sui-facet.d.ts +4 -4
- package/lib/testing/sui-facet.js +7 -7
- package/lib/testing/sui-facet.js.map +1 -1
- package/package.json +7 -5
- package/src/aptos/codegen/codegen.ts +0 -1
- package/src/move/abstract-codegen.ts +9 -8
- package/src/solana/builtin/types.ts +2 -1
- package/src/sui/abis/0x1.json +357 -357
- package/src/sui/abis/0x2.json +5563 -8247
- package/src/sui/abis/0x3.json +8399 -0
- package/src/sui/builtin/0x1.ts +1 -1
- package/src/sui/builtin/0x2.ts +531 -1537
- package/src/sui/builtin/0x3.ts +1515 -0
- package/src/sui/builtin/index.ts +1 -0
- package/src/sui/codegen/codegen.ts +5 -3
- package/src/sui/context.ts +4 -4
- package/src/sui/models.ts +4 -4
- package/src/sui/move-coder.ts +24 -12
- package/src/sui/move-types.ts +7 -7
- package/src/sui/sui-processor.ts +28 -15
- package/src/sui/utils.ts +21 -5
- package/src/testing/sui-facet.ts +19 -15
- package/src/eth/codegen/tsconfig.json +0 -8
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sui-facet.js","sourceRoot":"","sources":["../../src/testing/sui-facet.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"sui-facet.js","sourceRoot":"","sources":["../../src/testing/sui-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAqB;IAC3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,qBAAqB,CAAC,WAAwC,EAAE,UAAsB,UAAU,CAAC,QAAQ;QACvG,OAAO,IAAI,CAAC,s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AAE;YACV,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAA;SAC1D;QAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;YAChD,IAAI,MAAM,CAAC,QAAQ,EAAE,OAAO,KAAK,UAAU,CAAC,OAAO,CAAC,EAAE;gBACpD,SAAQ;aACT;YACD,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,gBAAgB,EAAE;gBACjD,KAAK,MAAM,WAAW,IAAI,WAAW,CAAC,OAAO,EAAE;oBAC7C,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,GAAG,WAAW,CAAC,IAAI,KAAK,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;wBACzF,WAAW,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAA;wBAC5B,OAAO;4BACL,IAAI,EAAE;gCACJ,QAAQ,EAAE;oCACR,WAAW;oCACX,SAAS,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,IAAI,CAAC,CAAC;oCACjD,IAAI,EAAE,MAAM;iCACb;6BACF;4BACD,UAAU,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;4BACnC,WAAW,EAAE,WAAW,CAAC,SAAS;yBACnC,CAAA;qBACF;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF","sourcesContent":["import { SuiEvent, SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'\nimport { DataBinding, HandlerType } from '@sentio/protos'\nimport { getChainId } from '../sui/network.js'\nimport { TestProcessorServer } from './test-processor-server.js'\nimport { parseMoveType } from '../move/types.js'\nimport { SuiNetwork } from '../sui/index.js'\nimport { getMoveCalls } from '../sui/utils.js'\nimport { SPLITTER } from '../move/index.js'\n\nexport class SuiFacet {\n server: TestProcessorServer\n constructor(server: TestProcessorServer) {\n this.server = server\n }\n\n testEntryFunctionCall(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {\n return this.testEntryFunctionCalls([transaction], network)\n }\n\n testEntryFunctionCalls(transactions: SuiTransactionBlockResponse[], network: SuiNetwork = SuiNetwork.MAIN_NET) {\n const bindings = []\n for (const trans of transactions) {\n const binding = this.buildEntryFunctionCallBinding(trans, network)\n if (!binding) {\n throw Error('Invalid test transaction: ' + JSON.stringify(trans))\n }\n bindings.push(binding)\n }\n return this.server.processBindings({\n bindings: bindings,\n })\n }\n\n private buildEntryFunctionCallBinding(\n transaction: SuiTransactionBlockResponse,\n network: SuiNetwork = SuiNetwork.MAIN_NET\n ): DataBinding | undefined {\n const calls: MoveCallSuiTransaction[] = getMoveCalls(transaction)\n if (calls.length !== 1) {\n throw Error('Transaction has more than one calls')\n }\n const functionType = [calls[0].package, calls[0].module, calls[0].function].join(SPLITTER)\n\n for (const config of this.server.contractConfigs) {\n if (config.contract?.chainId !== getChainId(network)) {\n continue\n }\n for (const callConfig of config.moveCallConfigs) {\n for (const callFilter of callConfig.filters) {\n if (config.contract.address + '::' + callFilter.function === functionType) {\n return {\n data: {\n suiCall: {\n transaction,\n timestamp: new Date(),\n slot: 10000n,\n },\n },\n handlerIds: [callConfig.handlerId],\n handlerType: HandlerType.SUI_CALL,\n }\n }\n }\n }\n }\n return undefined\n }\n\n testEvent(\n transaction: SuiTransactionBlockResponse,\n event: number | SuiEvent,\n network: SuiNetwork = SuiNetwork.MAIN_NET\n ) {\n if (typeof event !== 'number') {\n const transaction2: SuiTransactionBlockResponse = {} as any\n Object.assign(transaction2, transaction)\n transaction = transaction2\n transaction.events = [event]\n event = 0\n }\n const binding = this.buildEventBinding(transaction, event, network)\n if (!binding) {\n throw Error('Invalid test event: ' + JSON.stringify(transaction))\n }\n return this.server.processBinding(binding)\n }\n\n private buildEventBinding(\n transaction: SuiTransactionBlockResponse,\n eventIdx: number,\n network: SuiNetwork = SuiNetwork.MAIN_NET\n ): DataBinding | undefined {\n // const allEvents = new Set(transaction.events.map(e => e.type))\n const event = transaction.events?.[eventIdx]\n if (!event) {\n throw Error('Invaild test transaction, no event located')\n }\n\n for (const config of this.server.contractConfigs) {\n if (config.contract?.chainId !== getChainId(network)) {\n continue\n }\n for (const eventConfig of config.moveEventConfigs) {\n for (const eventFilter of eventConfig.filters) {\n if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {\n transaction.events = [event]\n return {\n data: {\n suiEvent: {\n transaction,\n timestamp: new Date(transaction.timestampMs || 0),\n slot: 10000n,\n },\n },\n handlerIds: [eventConfig.handlerId],\n handlerType: HandlerType.SUI_EVENT,\n }\n }\n }\n }\n }\n return undefined\n }\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.
|
4
|
+
"version": "2.11.0-rc.1",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
@@ -19,12 +19,12 @@
|
|
19
19
|
"docs": "typedoc --options typedoc.json"
|
20
20
|
},
|
21
21
|
"dependencies": {
|
22
|
-
"@mysten/sui.js": "npm:@sentio/sui.js
|
22
|
+
"@mysten/sui.js": "npm:@sentio/sui.js@^0.30.0",
|
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.
|
27
|
-
"@sentio/runtime": "^2.
|
26
|
+
"@sentio/protos": "^2.11.0-rc.1",
|
27
|
+
"@sentio/runtime": "^2.11.0-rc.1",
|
28
28
|
"@solana/web3.js": "^1.73.2",
|
29
29
|
"@types/prettier": "^2.7.2",
|
30
30
|
"aptos-sdk": "npm:aptos@^1.7.1",
|
@@ -37,6 +37,8 @@
|
|
37
37
|
"node-fetch": "^3.3.1",
|
38
38
|
"p-queue": "^7.3.4",
|
39
39
|
"prettier": "^2.8.4",
|
40
|
+
"superstruct": "^1.0.3",
|
41
|
+
"superstruct_solana": "npm:superstruct@^0.14.2",
|
40
42
|
"typechain": "^8.0.0",
|
41
43
|
"yaml": "^2.2.1"
|
42
44
|
},
|
@@ -81,5 +83,5 @@
|
|
81
83
|
"engines": {
|
82
84
|
"node": ">=16"
|
83
85
|
},
|
84
|
-
"gitHead": "
|
86
|
+
"gitHead": "d0bce70cde54e15e5cbd3fded4f61d7bb1d76b8e"
|
85
87
|
}
|
@@ -34,7 +34,6 @@ class AptosCodegen extends AbstractCodegen<MoveModuleBytecode[], AptosNetwork> {
|
|
34
34
|
MAIN_NET = AptosNetwork.MAIN_NET
|
35
35
|
TEST_NET = AptosNetwork.TEST_NET
|
36
36
|
PREFIX = 'Aptos'
|
37
|
-
// GENERATED_CLIENT = true
|
38
37
|
|
39
38
|
async fetchModules(account: string, network: AptosNetwork): Promise<MoveModuleBytecode[]> {
|
40
39
|
const client = getRpcClient(network)
|
@@ -30,7 +30,8 @@ export abstract class AbstractCodegen<ModuleTypes, NetworkType> {
|
|
30
30
|
ADDRESS_TYPE: string
|
31
31
|
PREFIX: string
|
32
32
|
STRUCT_FIELD_NAME: string = 'data'
|
33
|
-
|
33
|
+
GENERATE_CLIENT = false
|
34
|
+
GENERATE_ON_ENTRY = true
|
34
35
|
|
35
36
|
abstract fetchModules(account: string, network: NetworkType): Promise<ModuleTypes>
|
36
37
|
abstract toInternalModules(modules: ModuleTypes): InternalMoveModule[]
|
@@ -155,12 +156,12 @@ export abstract class AbstractCodegen<ModuleTypes, NetworkType> {
|
|
155
156
|
}
|
156
157
|
|
157
158
|
generateModule(module: InternalMoveModule, network: NetworkType) {
|
158
|
-
const functions =
|
159
|
-
.map((f) => this.generateOnEntryFunctions(module, f))
|
160
|
-
|
161
|
-
const clientFunctions =
|
162
|
-
.map((f) => this.generateClientFunctions(module, f))
|
163
|
-
|
159
|
+
const functions = this.GENERATE_ON_ENTRY
|
160
|
+
? module.exposedFunctions.map((f) => this.generateOnEntryFunctions(module, f)).filter((s) => s !== '')
|
161
|
+
: []
|
162
|
+
const clientFunctions = this.GENERATE_CLIENT
|
163
|
+
? module.exposedFunctions.map((f) => this.generateClientFunctions(module, f)).filter((s) => s !== '')
|
164
|
+
: []
|
164
165
|
const eventStructs = this.getEventStructs(module)
|
165
166
|
const eventTypes = new Set(eventStructs.keys())
|
166
167
|
const events = Array.from(eventStructs.values())
|
@@ -173,7 +174,7 @@ export abstract class AbstractCodegen<ModuleTypes, NetworkType> {
|
|
173
174
|
let processor = ''
|
174
175
|
let client = ''
|
175
176
|
|
176
|
-
if (
|
177
|
+
if (clientFunctions.length > 0) {
|
177
178
|
client = `
|
178
179
|
export class ${moduleName}_client extends ModuleClient {
|
179
180
|
${clientFunctions.join('\n')}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-redeclare */
|
2
2
|
// copy from https://github.com/solana-labs/solana/blob/master/explorer/src/components/instruction/token/types.ts
|
3
|
+
// https://github.com/solana-labs/explorer/blob/411b42439553262ef9036985d287a7249acaad77/src/components/instruction/token/types.ts
|
3
4
|
|
4
5
|
import {
|
5
6
|
enums,
|
@@ -13,7 +14,7 @@ import {
|
|
13
14
|
union,
|
14
15
|
coerce,
|
15
16
|
instance,
|
16
|
-
} from "
|
17
|
+
} from "superstruct_solana";
|
17
18
|
|
18
19
|
// Replace with string
|
19
20
|
export const PublicKeyFromString = coerce(
|