@sentio/sdk 2.14.2-rc.2 → 2.14.3-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/testing/sui-facet.js +23 -21
- package/lib/testing/sui-facet.js.map +1 -1
- package/package.json +3 -3
- package/src/testing/sui-facet.ts +22 -20
package/lib/testing/sui-facet.js
CHANGED
@@ -27,28 +27,30 @@ export class SuiFacet {
|
|
27
27
|
}
|
28
28
|
buildEntryFunctionCallBinding(transaction, network = SuiNetwork.MAIN_NET) {
|
29
29
|
const calls = getMoveCalls(transaction);
|
30
|
-
if (calls.length !== 1) {
|
31
|
-
|
32
|
-
}
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
for (const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
30
|
+
// if (calls.length !== 1) {
|
31
|
+
// throw Error('Transaction has more than one calls')
|
32
|
+
// }
|
33
|
+
for (const call of calls) {
|
34
|
+
const functionType = [call.package, call.module, call.function].join(SPLITTER);
|
35
|
+
for (const config of this.server.contractConfigs) {
|
36
|
+
if (config.contract?.chainId !== getChainId(network)) {
|
37
|
+
continue;
|
38
|
+
}
|
39
|
+
for (const callConfig of config.moveCallConfigs) {
|
40
|
+
for (const callFilter of callConfig.filters) {
|
41
|
+
if (config.contract.address + '::' + callFilter.function === functionType) {
|
42
|
+
return {
|
43
|
+
data: {
|
44
|
+
suiCall: {
|
45
|
+
transaction,
|
46
|
+
timestamp: new Date(),
|
47
|
+
slot: 10000n,
|
48
|
+
},
|
47
49
|
},
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
50
|
+
handlerIds: [callConfig.handlerId],
|
51
|
+
handlerType: HandlerType.SUI_CALL,
|
52
|
+
};
|
53
|
+
}
|
52
54
|
}
|
53
55
|
}
|
54
56
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version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AC,WAAW,CAAC,CAAC,CAAA;SAClE;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;IAEO,iBAAiB,CACvB,WAAwC,EACxC,UAAsB,UAAU,CAAC,QAAQ;QAEzC,iEAAiE;QAEjE,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,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE;wBAC5C,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,GAAG,WAAW,CAAC,IAAI,KAAK,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;4BACzF,OAAO;gCACL,IAAI,EAAE;oCACJ,QAAQ,EAAE;wCACR,WAAW;wCACX,SAAS,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,IAAI,CAAC,CAAC;wCACjD,IAAI,EAAE,MAAM;qCACb;iCACF;gCACD,UAAU,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;gCACnC,WAAW,EAAE,WAAW,CAAC,SAAS;6BACnC,CAAA;yBACF;qBACF;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF","sourcesContent":["import { 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 for (const call of calls) {\n const functionType = [call.package, call.module, call.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 }\n return undefined\n }\n\n testEvent(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {\n const binding = this.buildEventBinding(transaction, 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 network: SuiNetwork = SuiNetwork.MAIN_NET\n ): DataBinding | undefined {\n // const allEvents = new Set(transaction.events.map(e => e.type))\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 for (const event of transaction.events || []) {\n if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {\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 }\n return undefined\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.14.
|
3
|
+
"version": "2.14.3-rc.1",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -68,8 +68,8 @@
|
|
68
68
|
"typechain": "^8.0.0",
|
69
69
|
"typedoc": "^0.24.1",
|
70
70
|
"yaml": "^2.2.1",
|
71
|
-
"@sentio/protos": "^2.14.
|
72
|
-
"@sentio/runtime": "^2.14.
|
71
|
+
"@sentio/protos": "^2.14.3-rc.1",
|
72
|
+
"@sentio/runtime": "^2.14.3-rc.1"
|
73
73
|
},
|
74
74
|
"peerDependencies": {
|
75
75
|
"tsup": "npm:@sentio/tsup@^6.7.0"
|
package/src/testing/sui-facet.ts
CHANGED
@@ -36,28 +36,30 @@ export class SuiFacet {
|
|
36
36
|
network: SuiNetwork = SuiNetwork.MAIN_NET
|
37
37
|
): DataBinding | undefined {
|
38
38
|
const calls: MoveCallSuiTransaction[] = getMoveCalls(transaction)
|
39
|
-
if (calls.length !== 1) {
|
40
|
-
|
41
|
-
}
|
42
|
-
const
|
39
|
+
// if (calls.length !== 1) {
|
40
|
+
// throw Error('Transaction has more than one calls')
|
41
|
+
// }
|
42
|
+
for (const call of calls) {
|
43
|
+
const functionType = [call.package, call.module, call.function].join(SPLITTER)
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
for (const config of this.server.contractConfigs) {
|
46
|
+
if (config.contract?.chainId !== getChainId(network)) {
|
47
|
+
continue
|
48
|
+
}
|
49
|
+
for (const callConfig of config.moveCallConfigs) {
|
50
|
+
for (const callFilter of callConfig.filters) {
|
51
|
+
if (config.contract.address + '::' + callFilter.function === functionType) {
|
52
|
+
return {
|
53
|
+
data: {
|
54
|
+
suiCall: {
|
55
|
+
transaction,
|
56
|
+
timestamp: new Date(),
|
57
|
+
slot: 10000n,
|
58
|
+
},
|
57
59
|
},
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
handlerIds: [callConfig.handlerId],
|
61
|
+
handlerType: HandlerType.SUI_CALL,
|
62
|
+
}
|
61
63
|
}
|
62
64
|
}
|
63
65
|
}
|