@sentio/cli 4.4.1 → 4.4.2-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/dist/index.js +37556 -22984
- package/package.json +1 -1
- package/src/abi.ts +27 -9
package/package.json
CHANGED
package/src/abi.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { AptosChainId, ChainId, SuiChainId } from '@sentio/chain'
|
|
|
7
7
|
|
|
8
8
|
import type { Aptos } from '@aptos-labs/ts-sdk'
|
|
9
9
|
import type { IotaClient } from '@iota/iota-sdk/client'
|
|
10
|
-
import type {
|
|
10
|
+
import type { SuiGrpcClient } from '@mysten/sui/grpc'
|
|
11
11
|
import { ReadKey } from './key.js'
|
|
12
12
|
import { Auth } from './commands/upload.js'
|
|
13
13
|
import { getApiUrl } from './utils.js'
|
|
@@ -251,6 +251,27 @@ export function convertLegacySuiAbis(baseDir = path.resolve('abis', 'sui')): voi
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
// Download a Sui package ABI over gRPC, in the `[{ address, module }]` shape the
|
|
255
|
+
// v2 codegen reads (the same shape `typemove-sui` writes from its
|
|
256
|
+
// `SuiChainAdapter.fetchModules`). @mysten/sui 3 removed the JSON-RPC client, so
|
|
257
|
+
// this replaces `getNormalizedMoveModulesByPackage` + `normalizedModulesToAbi`.
|
|
258
|
+
// No selector: fetch the package stored at exactly this id. The caller-supplied
|
|
259
|
+
// address is kept (gRPC returns the long-form storage id, while system packages
|
|
260
|
+
// are keyed by their short form such as 0x2).
|
|
261
|
+
export async function fetchSuiAbi(
|
|
262
|
+
client: Pick<SuiGrpcClient, 'movePackageService'>,
|
|
263
|
+
address: string
|
|
264
|
+
): Promise<Array<{ address: string; module: any }>> {
|
|
265
|
+
const { response } = await client.movePackageService.getPackage({
|
|
266
|
+
packageId: address,
|
|
267
|
+
selector: { oneofKind: undefined }
|
|
268
|
+
})
|
|
269
|
+
if (!response.package) {
|
|
270
|
+
throw Error(`No package returned for ${address}`)
|
|
271
|
+
}
|
|
272
|
+
return (response.package.modules ?? []).map((module) => ({ address, module }))
|
|
273
|
+
}
|
|
274
|
+
|
|
254
275
|
export async function getABI(
|
|
255
276
|
chain: ChainId,
|
|
256
277
|
address: string,
|
|
@@ -263,22 +284,19 @@ export async function getABI(
|
|
|
263
284
|
|
|
264
285
|
// SUI
|
|
265
286
|
try {
|
|
266
|
-
const
|
|
267
|
-
let suiClient:
|
|
287
|
+
const SuiGrpcClient = (await import('@mysten/sui/grpc')).SuiGrpcClient
|
|
288
|
+
let suiClient: SuiGrpcClient | undefined
|
|
268
289
|
switch (chain) {
|
|
269
290
|
case SuiChainId.SUI_MAINNET:
|
|
270
|
-
suiClient = new
|
|
291
|
+
suiClient = new SuiGrpcClient({ baseUrl: 'https://fullnode.mainnet.sui.io', network: 'mainnet' })
|
|
271
292
|
break
|
|
272
293
|
case SuiChainId.SUI_TESTNET:
|
|
273
|
-
suiClient = new
|
|
294
|
+
suiClient = new SuiGrpcClient({ baseUrl: 'https://fullnode.testnet.sui.io', network: 'testnet' })
|
|
274
295
|
break
|
|
275
296
|
}
|
|
276
297
|
if (suiClient) {
|
|
277
298
|
try {
|
|
278
|
-
return {
|
|
279
|
-
abi: normalizedModulesToAbi(await suiClient.getNormalizedMoveModulesByPackage({ package: address })),
|
|
280
|
-
name
|
|
281
|
-
}
|
|
299
|
+
return { abi: await fetchSuiAbi(suiClient, address), name }
|
|
282
300
|
} catch (e) {
|
|
283
301
|
console.error(baseErrMsg, e)
|
|
284
302
|
process.exit(1)
|