@sentio/sdk 2.14.2-rc.1 → 2.14.2-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/context.d.ts +2 -0
- package/lib/aptos/context.js +10 -0
- package/lib/aptos/context.js.map +1 -1
- package/lib/sui/context.d.ts +2 -1
- package/lib/sui/context.js +10 -0
- package/lib/sui/context.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/context.ts +11 -0
- package/src/sui/context.ts +11 -1
package/lib/aptos/context.d.ts
CHANGED
@@ -3,6 +3,7 @@ import { type Labels, BaseContext } from '@sentio/sdk';
|
|
3
3
|
import { Transaction_UserTransaction } from './move-types.js';
|
4
4
|
import { AptosNetwork } from './network.js';
|
5
5
|
import { MoveCoder } from './move-coder.js';
|
6
|
+
import { AptosClient } from 'aptos-sdk';
|
6
7
|
export declare class AptosContext extends BaseContext {
|
7
8
|
address: string;
|
8
9
|
network: AptosNetwork;
|
@@ -24,4 +25,5 @@ export declare class AptosResourcesContext extends BaseContext {
|
|
24
25
|
constructor(network: AptosNetwork, address: string, version: bigint, timestampInMicros: number);
|
25
26
|
getChainId(): string;
|
26
27
|
getMetaData(name: string, labels: Labels): RecordMetaData;
|
28
|
+
getClient(): AptosClient;
|
27
29
|
}
|
package/lib/aptos/context.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
import { BaseContext, normalizeLabels } from '@sentio/sdk';
|
2
2
|
import { getChainId } from './network.js';
|
3
3
|
import { defaultMoveCoder } from './move-coder.js';
|
4
|
+
import { Endpoints } from '@sentio/runtime';
|
5
|
+
import { ServerError, Status } from 'nice-grpc';
|
6
|
+
import { AptosClient } from 'aptos-sdk';
|
4
7
|
export class AptosContext extends BaseContext {
|
5
8
|
address;
|
6
9
|
network;
|
@@ -68,5 +71,12 @@ export class AptosResourcesContext extends BaseContext {
|
|
68
71
|
labels: normalizeLabels(labels),
|
69
72
|
};
|
70
73
|
}
|
74
|
+
getClient() {
|
75
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network));
|
76
|
+
if (!chainServer) {
|
77
|
+
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided');
|
78
|
+
}
|
79
|
+
return new AptosClient(chainServer);
|
80
|
+
}
|
71
81
|
}
|
72
82
|
//# sourceMappingURL=context.js.map
|
package/lib/aptos/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/aptos/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEvE,OAAO,EAAgB,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/aptos/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEvE,OAAO,EAAgB,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAQ;IACf,OAAO,CAAc;IACrB,UAAU,CAAQ;IAClB,OAAO,CAAQ;IACf,WAAW,CAA6B;IACxC,UAAU,CAAQ;IAClB,KAAK,CAAW;IAEhB,YACE,UAAkB,EAClB,OAAqB,EACrB,OAAe,EACf,OAAe,EACf,WAAwC,EACxC,UAAkB;QAElB,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;QAC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B,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,UAAU;QACR,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,IAAI,CAAC,OAAO;YACzB,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;IAED,SAAS;QACP,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAChF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;SACpE;QACD,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAA;IACrC,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, BaseContext, normalizeLabels } from '@sentio/sdk'\nimport { Transaction_UserTransaction } from './move-types.js'\nimport { AptosNetwork, getChainId } from './network.js'\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { Endpoints } from '@sentio/runtime'\nimport { ServerError, Status } from 'nice-grpc'\nimport { AptosClient } from 'aptos-sdk'\n\nexport class AptosContext extends BaseContext {\n address: string\n network: AptosNetwork\n moduleName: string\n version: bigint\n transaction: Transaction_UserTransaction\n eventIndex: number\n coder: MoveCoder\n\n constructor(\n moduleName: string,\n network: AptosNetwork,\n address: string,\n version: bigint,\n transaction: Transaction_UserTransaction,\n eventIndex: number\n ) {\n super()\n this.address = address.toLowerCase()\n this.network = network\n this.moduleName = moduleName\n this.version = version\n this.eventIndex = eventIndex\n this.coder = defaultMoveCoder(network)\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getChainId(): string {\n return getChainId(this.network)\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.version,\n transactionIndex: 0,\n transactionHash: this.transaction?.hash || '', // TODO\n logIndex: this.eventIndex,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n\nexport class AptosResourcesContext extends BaseContext {\n address: string\n network: AptosNetwork\n version: bigint\n timestampInMicros: number\n coder: MoveCoder\n\n constructor(network: AptosNetwork, address: string, version: bigint, timestampInMicros: number) {\n super()\n this.address = address\n this.network = network\n this.version = version\n this.timestampInMicros = timestampInMicros\n this.coder = defaultMoveCoder(network)\n }\n\n getChainId(): string {\n return getChainId(this.network)\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: 'resources',\n blockNumber: this.version,\n transactionIndex: 0,\n transactionHash: '',\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n getClient(): AptosClient {\n const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network))\n if (!chainServer) {\n throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')\n }\n return new AptosClient(chainServer)\n }\n}\n"]}
|
package/lib/sui/context.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { RecordMetaData } from '@sentio/protos';
|
2
2
|
import { type Labels, BaseContext } from '../index.js';
|
3
3
|
import { SuiNetwork } from './network.js';
|
4
|
-
import { SuiTransactionBlockResponse } from '@mysten/sui.js';
|
4
|
+
import { SuiTransactionBlockResponse, JsonRpcProvider } from '@mysten/sui.js';
|
5
5
|
import { MoveCoder } from './move-coder.js';
|
6
6
|
export declare class SuiContext extends BaseContext {
|
7
7
|
address: string;
|
@@ -25,4 +25,5 @@ export declare class SuiObjectsContext extends BaseContext {
|
|
25
25
|
constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date);
|
26
26
|
getChainId(): string;
|
27
27
|
getMetaData(name: string, labels: Labels): RecordMetaData;
|
28
|
+
getClient(): JsonRpcProvider;
|
28
29
|
}
|
package/lib/sui/context.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
import { BaseContext, normalizeLabels } from '../index.js';
|
2
2
|
import { getChainId } from './network.js';
|
3
|
+
import { JsonRpcProvider, Connection } from '@mysten/sui.js';
|
3
4
|
import { defaultMoveCoder } from './move-coder.js';
|
5
|
+
import { Endpoints } from '@sentio/runtime';
|
6
|
+
import { ServerError, Status } from 'nice-grpc';
|
4
7
|
export class SuiContext extends BaseContext {
|
5
8
|
address;
|
6
9
|
network;
|
@@ -70,5 +73,12 @@ export class SuiObjectsContext extends BaseContext {
|
|
70
73
|
labels: normalizeLabels(labels),
|
71
74
|
};
|
72
75
|
}
|
76
|
+
getClient() {
|
77
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network));
|
78
|
+
if (!chainServer) {
|
79
|
+
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided');
|
80
|
+
}
|
81
|
+
return new JsonRpcProvider(new Connection({ fullnode: chainServer }));
|
82
|
+
}
|
73
83
|
}
|
74
84
|
//# sourceMappingURL=context.js.map
|
package/lib/sui/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAc,UAAU,EAAE,MAAM,cAAc,CAAA;
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,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AAC,CAAA;QAChF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;SACpE;QACD,OAAO,IAAI,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;IACvE,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, BaseContext, normalizeLabels } from '../index.js'\nimport { SuiNetwork, getChainId } from './network.js'\nimport { SuiTransactionBlockResponse, JsonRpcProvider, Connection } from '@mysten/sui.js'\nimport { MoveCoder, defaultMoveCoder } from './move-coder.js'\nimport { Endpoints } from '@sentio/runtime'\nimport { ServerError, Status } from 'nice-grpc'\n\nexport class SuiContext extends BaseContext {\n address: string\n network: SuiNetwork\n moduleName: string\n timestamp: Date\n slot: bigint\n transaction: SuiTransactionBlockResponse\n eventIndex: number\n coder: MoveCoder\n\n constructor(\n moduleName: string,\n network: SuiNetwork,\n address: string,\n timestamp: Date,\n slot: bigint,\n transaction: SuiTransactionBlockResponse,\n eventIndex: number\n ) {\n super()\n this.address = address.toLowerCase()\n this.network = network\n this.moduleName = moduleName\n this.timestamp = timestamp\n this.slot = slot\n this.eventIndex = eventIndex\n this.coder = defaultMoveCoder(network)\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getChainId(): string {\n return getChainId(this.network)\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: this.transaction?.digest || '', // TODO\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n\nexport class SuiObjectsContext extends BaseContext {\n address: string\n network: SuiNetwork\n slot: bigint\n timestamp: Date\n coder: MoveCoder\n\n constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date) {\n super()\n this.address = address\n this.network = network\n this.slot = slot\n this.timestamp = timestamp\n this.coder = defaultMoveCoder(network)\n }\n\n getChainId(): string {\n return getChainId(this.network)\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: 'objects',\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: '',\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n getClient(): JsonRpcProvider {\n const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network))\n if (!chainServer) {\n throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')\n }\n return new JsonRpcProvider(new Connection({ fullnode: chainServer }))\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.14.2-rc.
|
3
|
+
"version": "2.14.2-rc.2",
|
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.2-rc.
|
72
|
-
"@sentio/runtime": "^2.14.2-rc.
|
71
|
+
"@sentio/protos": "^2.14.2-rc.2",
|
72
|
+
"@sentio/runtime": "^2.14.2-rc.2"
|
73
73
|
},
|
74
74
|
"peerDependencies": {
|
75
75
|
"tsup": "npm:@sentio/tsup@^6.7.0"
|
package/src/aptos/context.ts
CHANGED
@@ -3,6 +3,9 @@ import { type Labels, BaseContext, normalizeLabels } from '@sentio/sdk'
|
|
3
3
|
import { Transaction_UserTransaction } from './move-types.js'
|
4
4
|
import { AptosNetwork, getChainId } from './network.js'
|
5
5
|
import { defaultMoveCoder, MoveCoder } from './move-coder.js'
|
6
|
+
import { Endpoints } from '@sentio/runtime'
|
7
|
+
import { ServerError, Status } from 'nice-grpc'
|
8
|
+
import { AptosClient } from 'aptos-sdk'
|
6
9
|
|
7
10
|
export class AptosContext extends BaseContext {
|
8
11
|
address: string
|
@@ -85,4 +88,12 @@ export class AptosResourcesContext extends BaseContext {
|
|
85
88
|
labels: normalizeLabels(labels),
|
86
89
|
}
|
87
90
|
}
|
91
|
+
|
92
|
+
getClient(): AptosClient {
|
93
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network))
|
94
|
+
if (!chainServer) {
|
95
|
+
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
|
96
|
+
}
|
97
|
+
return new AptosClient(chainServer)
|
98
|
+
}
|
88
99
|
}
|
package/src/sui/context.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
import { RecordMetaData } from '@sentio/protos'
|
2
2
|
import { type Labels, BaseContext, normalizeLabels } from '../index.js'
|
3
3
|
import { SuiNetwork, getChainId } from './network.js'
|
4
|
-
import { SuiTransactionBlockResponse } from '@mysten/sui.js'
|
4
|
+
import { SuiTransactionBlockResponse, JsonRpcProvider, Connection } from '@mysten/sui.js'
|
5
5
|
import { MoveCoder, defaultMoveCoder } from './move-coder.js'
|
6
|
+
import { Endpoints } from '@sentio/runtime'
|
7
|
+
import { ServerError, Status } from 'nice-grpc'
|
6
8
|
|
7
9
|
export class SuiContext extends BaseContext {
|
8
10
|
address: string
|
@@ -88,4 +90,12 @@ export class SuiObjectsContext extends BaseContext {
|
|
88
90
|
labels: normalizeLabels(labels),
|
89
91
|
}
|
90
92
|
}
|
93
|
+
|
94
|
+
getClient(): JsonRpcProvider {
|
95
|
+
const chainServer = Endpoints.INSTANCE.chainServer.get(getChainId(this.network))
|
96
|
+
if (!chainServer) {
|
97
|
+
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
|
98
|
+
}
|
99
|
+
return new JsonRpcProvider(new Connection({ fullnode: chainServer }))
|
100
|
+
}
|
91
101
|
}
|