@mysten/sui 2.20.3 → 2.21.0
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/CHANGELOG.md +18 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +4 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +29 -7
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +1 -1
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +13 -5
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +68 -46
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/index.d.mts +2 -2
- package/dist/grpc/index.mjs +2 -2
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/jsonRpc/client.d.mts +160 -0
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +142 -0
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +80 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +80 -0
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/errors.d.mts +12 -0
- package/dist/jsonRpc/errors.d.mts.map +1 -1
- package/dist/jsonRpc/errors.mjs +12 -0
- package/dist/jsonRpc/errors.mjs.map +1 -1
- package/dist/jsonRpc/http-transport.d.mts +30 -0
- package/dist/jsonRpc/http-transport.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.mjs +16 -0
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/jsonRpc/network.d.mts +4 -0
- package/dist/jsonRpc/network.d.mts.map +1 -1
- package/dist/jsonRpc/network.mjs +4 -0
- package/dist/jsonRpc/network.mjs.map +1 -1
- package/dist/jsonRpc/types/chain.d.mts +68 -0
- package/dist/jsonRpc/types/chain.d.mts.map +1 -1
- package/dist/jsonRpc/types/changes.d.mts +24 -0
- package/dist/jsonRpc/types/changes.d.mts.map +1 -1
- package/dist/jsonRpc/types/coins.d.mts +4 -0
- package/dist/jsonRpc/types/coins.d.mts.map +1 -1
- package/dist/jsonRpc/types/common.d.mts +4 -0
- package/dist/jsonRpc/types/common.d.mts.map +1 -1
- package/dist/jsonRpc/types/generated.d.mts +497 -16
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/params.d.mts +289 -41
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/transactions/Transaction.d.mts +9 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/client/core.ts +1 -0
- package/src/client/mvr.ts +39 -6
- package/src/grpc/client.ts +10 -7
- package/src/grpc/core.ts +251 -168
- package/src/grpc/index.ts +5 -1
- package/src/jsonRpc/client.ts +160 -0
- package/src/jsonRpc/core.ts +80 -0
- package/src/jsonRpc/errors.ts +12 -0
- package/src/jsonRpc/http-transport.ts +30 -0
- package/src/jsonRpc/network.ts +4 -0
- package/src/jsonRpc/types/chain.ts +68 -0
- package/src/jsonRpc/types/changes.ts +24 -0
- package/src/jsonRpc/types/coins.ts +4 -0
- package/src/jsonRpc/types/common.ts +4 -0
- package/src/jsonRpc/types/generated.ts +497 -16
- package/src/jsonRpc/types/params.ts +289 -41
- package/src/version.ts +1 -1
package/dist/grpc/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/grpc/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';\nimport { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';\nimport { TransactionExecutionServiceClient } from './proto/sui/rpc/v2/transaction_execution_service.client.js';\nimport { LedgerServiceClient } from './proto/sui/rpc/v2/ledger_service.client.js';\nimport { MovePackageServiceClient } from './proto/sui/rpc/v2/move_package_service.client.js';\nimport { SignatureVerificationServiceClient } from './proto/sui/rpc/v2/signature_verification_service.client.js';\nimport type { RpcTransport } from '@protobuf-ts/runtime-rpc';\nimport { StateServiceClient } from './proto/sui/rpc/v2/state_service.client.js';\nimport { SubscriptionServiceClient } from './proto/sui/rpc/v2/subscription_service.client.js';\nimport { GrpcCoreClient } from './core.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { BaseClient } from '../client/index.js';\nimport { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';\nimport { ForkingServiceClient } from './proto/sui/forking/v1alpha/forking_service.client.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\n\ninterface SuiGrpcTransportOptions extends GrpcWebOptions {\n\ttransport?: never;\n}\n\nexport type SuiGrpcClientOptions = {\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n} & (\n\t| {\n\t\t\ttransport: RpcTransport;\n\t }\n\t| SuiGrpcTransportOptions\n);\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGrpcClient') as never;\n\nexport function isSuiGrpcClient(client: unknown): client is SuiGrpcClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {\n\tcore: GrpcCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\ttransactionExecutionService: TransactionExecutionServiceClient;\n\tledgerService: LedgerServiceClient;\n\tstateService: StateServiceClient;\n\tsubscriptionService: SubscriptionServiceClient;\n\tmovePackageService: MovePackageServiceClient;\n\tsignatureVerificationService: SignatureVerificationServiceClient;\n\tnameService: NameServiceClient;\n\tforkingService: ForkingServiceClient;\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor(options: SuiGrpcClientOptions) {\n\t\tsuper({ network: options.network });\n\t\tconst transport =\n\t\t\toptions.transport ??\n\t\t\tnew GrpcWebFetchTransport({ baseUrl: options.baseUrl, fetchInit: options.fetchInit });\n\t\tthis.transactionExecutionService = new TransactionExecutionServiceClient(transport);\n\t\tthis.ledgerService = new LedgerServiceClient(transport);\n\t\tthis.stateService = new StateServiceClient(transport);\n\t\tthis.subscriptionService = new SubscriptionServiceClient(transport);\n\t\tthis.movePackageService = new MovePackageServiceClient(transport);\n\t\tthis.signatureVerificationService = new SignatureVerificationServiceClient(transport);\n\t\tthis.nameService = new NameServiceClient(transport);\n\t\tthis.forkingService = new ForkingServiceClient(transport);\n\n\t\tthis.core = new GrpcCoreClient({\n\t\t\tclient: this,\n\t\t\tbase: this,\n\t\t\tnetwork: options.network,\n\t\t\tmvr: options.mvr,\n\t\t});\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.GetTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input);\n\t}\n\n\texecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input);\n\t}\n\n\tsignAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SignAndExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input);\n\t}\n\n\twaitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.WaitForTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input);\n\t}\n\n\tsimulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SimulateTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input);\n\t}\n\n\tgetReferenceGasPrice(): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice();\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\t\tconst paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];\n\t\tif (includeValue) {\n\t\t\tpaths.push('value');\n\t\t}\n\n\t\tconst response = await this.stateService.listDynamicFields({\n\t\t\tparent: input.parentId,\n\t\t\tpageToken: input.cursor ? fromBase64(input.cursor) : undefined,\n\t\t\tpageSize: input.limit,\n\t\t\treadMask: {\n\t\t\t\tpaths,\n\t\t\t},\n\t\t});\n\n\t\treturn {\n\t\t\tdynamicFields: response.response.dynamicFields.map(\n\t\t\t\t(field): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\t\tconst isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;\n\t\t\t\t\tconst fieldType = isDynamicObject\n\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`\n\t\t\t\t\t\t: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\t\tfieldId: field.fieldId!,\n\t\t\t\t\t\tname: {\n\t\t\t\t\t\t\ttype: field.name?.name!,\n\t\t\t\t\t\t\tbcs: field.name?.value!,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalueType: field.valueType!,\n\t\t\t\t\t\ttype: normalizeStructTag(fieldType),\n\t\t\t\t\t\tchildId: field.childId,\n\t\t\t\t\t\tvalue: (includeValue\n\t\t\t\t\t\t\t? { type: field.valueType!, bcs: field.value?.value ?? new Uint8Array() }\n\t\t\t\t\t\t\t: undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t\t},\n\t\t\t),\n\t\t\tcursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,\n\t\t\thasNextPage: response.response.nextPageToken !== undefined,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,mBAAmB,OAAO,IAAI,wBAAwB;AAE5D,SAAgB,gBAAgB,QAA0C;AACzE,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAmBzF,IAAa,gBAAb,cAAmC,WAAsD;CAExF,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAWlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,SAA+B;AAC1C,QAAM,EAAE,SAAS,QAAQ,SAAS,CAAC;EACnC,MAAM,YACL,QAAQ,aACR,IAAI,sBAAsB;GAAE,SAAS,QAAQ;GAAS,WAAW,QAAQ;GAAW,CAAC;AACtF,OAAK,8BAA8B,IAAI,kCAAkC,UAAU;AACnF,OAAK,gBAAgB,IAAI,oBAAoB,UAAU;AACvD,OAAK,eAAe,IAAI,mBAAmB,UAAU;AACrD,OAAK,sBAAsB,IAAI,0BAA0B,UAAU;AACnE,OAAK,qBAAqB,IAAI,yBAAyB,UAAU;AACjE,OAAK,+BAA+B,IAAI,mCAAmC,UAAU;AACrF,OAAK,cAAc,IAAI,kBAAkB,UAAU;AACnD,OAAK,iBAAiB,IAAI,qBAAqB,UAAU;AAEzD,OAAK,OAAO,IAAI,eAAe;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,CAAC;;CAGH,WACC,OACsD;AACtD,SAAO,KAAK,KAAK,WAAW,MAAM;;CAGnC,UACC,OACqD;AACrD,SAAO,KAAK,KAAK,UAAU,MAAM;;CAGlC,UAAU,OAAmF;AAC5F,SAAO,KAAK,KAAK,UAAU,MAAM;;CAGlC,iBACC,OAC4D;AAC5D,SAAO,KAAK,KAAK,iBA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AM;KACf,OAAQ,eACL;MAAE,MAAM,MAAM;MAAY,KAAK,MAAM,OAAO,SAAS,IAAI,YAAY;MAAE,GACvE;KACH;KAEF;GACD,QAAQ,SAAS,SAAS,gBAAgB,SAAS,SAAS,SAAS,cAAc,GAAG;GACtF,aAAa,SAAS,SAAS,kBAAkB;GACjD;;CAGF,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,2BAA8C;AAC7C,SAAO,KAAK,KAAK,0BAA0B;;CAG5C,uBACC,OACgD;AAChD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,uBACC,OACyD;AACzD,SAAO,KAAK,KAAK,uBAAuB,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/grpc/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';\nimport { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';\nimport { TransactionExecutionServiceClient } from './proto/sui/rpc/v2/transaction_execution_service.client.js';\nimport { LedgerServiceClient } from './proto/sui/rpc/v2/ledger_service.client.js';\nimport { MovePackageServiceClient } from './proto/sui/rpc/v2/move_package_service.client.js';\nimport { SignatureVerificationServiceClient } from './proto/sui/rpc/v2/signature_verification_service.client.js';\nimport type { RpcTransport } from '@protobuf-ts/runtime-rpc';\nimport { StateServiceClient } from './proto/sui/rpc/v2/state_service.client.js';\nimport { SubscriptionServiceClient } from './proto/sui/rpc/v2/subscription_service.client.js';\nimport { GrpcCoreClient } from './core.js';\nimport type { SuiClientTypes } from '../client/index.js';\nimport { BaseClient } from '../client/index.js';\nimport { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';\nimport { normalizeStructTag } from '../utils/sui-types.js';\nimport { fromBase64, toBase64 } from '@mysten/utils';\nimport { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';\nimport { ForkingServiceClient } from './proto/sui/forking/v1alpha/forking_service.client.js';\nimport type { TransactionPlugin } from '../transactions/index.js';\n\ninterface SuiGrpcTransportOptions extends GrpcWebOptions {\n\ttransport?: never;\n}\n\nexport type SuiGrpcClientOptions = {\n\tnetwork: SuiClientTypes.Network;\n\tmvr?: SuiClientTypes.MvrOptions;\n} & (\n\t| {\n\t\t\ttransport: RpcTransport;\n\t }\n\t| SuiGrpcTransportOptions\n);\n\nconst SUI_CLIENT_BRAND = Symbol.for('@mysten/SuiGrpcClient') as never;\n\nexport function isSuiGrpcClient(client: unknown): client is SuiGrpcClient {\n\treturn (\n\t\ttypeof client === 'object' && client !== null && (client as any)[SUI_CLIENT_BRAND] === true\n\t);\n}\n\nexport interface DynamicFieldInclude {\n\tvalue?: boolean;\n}\n\nexport type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =\n\tSuiClientTypes.DynamicFieldEntry & {\n\t\tvalue: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;\n\t};\n\nexport interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {\n\thasNextPage: boolean;\n\tcursor: string | null;\n\tdynamicFields: DynamicFieldEntryWithValue<Include>[];\n}\n\nexport class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {\n\tcore: GrpcCoreClient;\n\tget mvr(): SuiClientTypes.MvrMethods {\n\t\treturn this.core.mvr;\n\t}\n\ttransactionExecutionService: TransactionExecutionServiceClient;\n\tledgerService: LedgerServiceClient;\n\tstateService: StateServiceClient;\n\tsubscriptionService: SubscriptionServiceClient;\n\tmovePackageService: MovePackageServiceClient;\n\tsignatureVerificationService: SignatureVerificationServiceClient;\n\tnameService: NameServiceClient;\n\tforkingService: ForkingServiceClient;\n\n\tget [SUI_CLIENT_BRAND]() {\n\t\treturn true;\n\t}\n\n\tconstructor(options: SuiGrpcClientOptions) {\n\t\tsuper({ network: options.network });\n\t\tconst transport =\n\t\t\toptions.transport ??\n\t\t\tnew GrpcWebFetchTransport({ baseUrl: options.baseUrl, fetchInit: options.fetchInit });\n\t\tthis.transactionExecutionService = new TransactionExecutionServiceClient(transport);\n\t\tthis.ledgerService = new LedgerServiceClient(transport);\n\t\tthis.stateService = new StateServiceClient(transport);\n\t\tthis.subscriptionService = new SubscriptionServiceClient(transport);\n\t\tthis.movePackageService = new MovePackageServiceClient(transport);\n\t\tthis.signatureVerificationService = new SignatureVerificationServiceClient(transport);\n\t\tthis.nameService = new NameServiceClient(transport);\n\t\tthis.forkingService = new ForkingServiceClient(transport);\n\n\t\tthis.core = new GrpcCoreClient({\n\t\t\tclient: this,\n\t\t\tbase: this,\n\t\t\tnetwork: options.network,\n\t\t\tmvr: options.mvr,\n\t\t});\n\t}\n\n\tgetObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectsResponse<Include>> {\n\t\treturn this.core.getObjects(input);\n\t}\n\n\tgetObject<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.GetObjectOptions<Include>,\n\t): Promise<SuiClientTypes.GetObjectResponse<Include>> {\n\t\treturn this.core.getObject(input);\n\t}\n\n\tlistCoins(input: SuiClientTypes.ListCoinsOptions): Promise<SuiClientTypes.ListCoinsResponse> {\n\t\treturn this.core.listCoins(input);\n\t}\n\n\tlistOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(\n\t\tinput: SuiClientTypes.ListOwnedObjectsOptions<Include>,\n\t): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {\n\t\treturn this.core.listOwnedObjects(input);\n\t}\n\n\tgetBalance(input: SuiClientTypes.GetBalanceOptions): Promise<SuiClientTypes.GetBalanceResponse> {\n\t\treturn this.core.getBalance(input);\n\t}\n\n\tlistBalances(\n\t\tinput: SuiClientTypes.ListBalancesOptions,\n\t): Promise<SuiClientTypes.ListBalancesResponse> {\n\t\treturn this.core.listBalances(input);\n\t}\n\n\tgetCoinMetadata(\n\t\tinput: SuiClientTypes.GetCoinMetadataOptions,\n\t): Promise<SuiClientTypes.GetCoinMetadataResponse> {\n\t\treturn this.core.getCoinMetadata(input);\n\t}\n\n\tgetTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.GetTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.getTransaction(input);\n\t}\n\n\texecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.ExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.executeTransaction(input);\n\t}\n\n\tsignAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SignAndExecuteTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.signAndExecuteTransaction(input);\n\t}\n\n\twaitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(\n\t\tinput: SuiClientTypes.WaitForTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.TransactionResult<Include>> {\n\t\treturn this.core.waitForTransaction(input);\n\t}\n\n\tsimulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(\n\t\tinput: SuiClientTypes.SimulateTransactionOptions<Include>,\n\t): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {\n\t\treturn this.core.simulateTransaction(input);\n\t}\n\n\tgetReferenceGasPrice(): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {\n\t\treturn this.core.getReferenceGasPrice();\n\t}\n\n\tasync listDynamicFields<Include extends DynamicFieldInclude = {}>(\n\t\tinput: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },\n\t): Promise<ListDynamicFieldsWithValueResponse<Include>> {\n\t\tconst includeValue = input.include?.value ?? false;\n\t\tconst paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];\n\t\tif (includeValue) {\n\t\t\tpaths.push('value');\n\t\t}\n\n\t\tconst response = await this.stateService.listDynamicFields(\n\t\t\t{\n\t\t\t\tparent: input.parentId,\n\t\t\t\tpageToken: input.cursor ? fromBase64(input.cursor) : undefined,\n\t\t\t\tpageSize: input.limit,\n\t\t\t\treadMask: {\n\t\t\t\t\tpaths,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ abort: input.signal },\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFields: response.response.dynamicFields.map(\n\t\t\t\t(field): DynamicFieldEntryWithValue<Include> => {\n\t\t\t\t\tconst isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;\n\t\t\t\t\tconst fieldType = isDynamicObject\n\t\t\t\t\t\t? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`\n\t\t\t\t\t\t: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',\n\t\t\t\t\t\tfieldId: field.fieldId!,\n\t\t\t\t\t\tname: {\n\t\t\t\t\t\t\ttype: field.name?.name!,\n\t\t\t\t\t\t\tbcs: field.name?.value!,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalueType: field.valueType!,\n\t\t\t\t\t\ttype: normalizeStructTag(fieldType),\n\t\t\t\t\t\tchildId: field.childId,\n\t\t\t\t\t\tvalue: (includeValue\n\t\t\t\t\t\t\t? { type: field.valueType!, bcs: field.value?.value ?? new Uint8Array() }\n\t\t\t\t\t\t\t: undefined) as DynamicFieldEntryWithValue<Include>['value'],\n\t\t\t\t\t} as DynamicFieldEntryWithValue<Include>;\n\t\t\t\t},\n\t\t\t),\n\t\t\tcursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,\n\t\t\thasNextPage: response.response.nextPageToken !== undefined,\n\t\t};\n\t}\n\n\tgetDynamicField(\n\t\tinput: SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<SuiClientTypes.GetDynamicFieldResponse> {\n\t\treturn this.core.getDynamicField(input);\n\t}\n\n\tgetMoveFunction(\n\t\tinput: SuiClientTypes.GetMoveFunctionOptions,\n\t): Promise<SuiClientTypes.GetMoveFunctionResponse> {\n\t\treturn this.core.getMoveFunction(input);\n\t}\n\n\tresolveTransactionPlugin(): TransactionPlugin {\n\t\treturn this.core.resolveTransactionPlugin();\n\t}\n\n\tverifyZkLoginSignature(\n\t\tinput: SuiClientTypes.VerifyZkLoginSignatureOptions,\n\t): Promise<SuiClientTypes.ZkLoginVerifyResponse> {\n\t\treturn this.core.verifyZkLoginSignature(input);\n\t}\n\n\tdefaultNameServiceName(\n\t\tinput: SuiClientTypes.DefaultNameServiceNameOptions,\n\t): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {\n\t\treturn this.core.defaultNameServiceName(input);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,mBAAmB,OAAO,IAAI,wBAAwB;AAE5D,SAAgB,gBAAgB,QAA0C;AACzE,QACC,OAAO,WAAW,YAAY,WAAW,QAAS,OAAe,sBAAsB;;AAmBzF,IAAa,gBAAb,cAAmC,WAAsD;CAExF,IAAI,MAAiC;AACpC,SAAO,KAAK,KAAK;;CAWlB,KAAK,oBAAoB;AACxB,SAAO;;CAGR,YAAY,SAA+B;AAC1C,QAAM,EAAE,SAAS,QAAQ,SAAS,CAAC;EACnC,MAAM,YACL,QAAQ,aACR,IAAI,sBAAsB;GAAE,SAAS,QAAQ;GAAS,WAAW,QAAQ;GAAW,CAAC;AACtF,OAAK,8BAA8B,IAAI,kCAAkC,UAAU;AACnF,OAAK,gBAAgB,IAAI,oBAAoB,UAAU;AACvD,OAAK,eAAe,IAAI,mBAAmB,UAAU;AACrD,OAAK,sBAAsB,IAAI,0BAA0B,UAAU;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AM;GACd,WAAW,MAAM,SAAS,WAAW,MAAM,OAAO,GAAG;GACrD,UAAU,MAAM;GAChB,UAAU,EACT,OACA;GACD,EACD,EAAE,OAAO,MAAM,QAAQ,CACvB;AAED,SAAO;GACN,eAAe,SAAS,SAAS,cAAc,KAC7C,UAA+C;IAC/C,MAAM,kBAAkB,MAAM,SAAS,8BAA8B;IACrE,MAAM,YAAY,kBACf,gEAAgE,MAAM,MAAM,KAAM,sBAClF,6BAA6B,MAAM,MAAM,KAAM,GAAG,MAAM,UAAW;AACtE,WAAO;KACN,OAAO,kBAAkB,kBAAkB;KAC3C,SAAS,MAAM;KACf,MAAM;MACL,MAAM,MAAM,MAAM;MAClB,KAAK,MAAM,MAAM;MACjB;KACD,WAAW,MAAM;KACjB,MAAM,mBAAmB,UAAU;KACnC,SAAS,MAAM;KACf,OAAQ,eACL;MAAE,MAAM,MAAM;MAAY,KAAK,MAAM,OAAO,SAAS,IAAI,YAAY;MAAE,GACvE;KACH;KAEF;GACD,QAAQ,SAAS,SAAS,gBAAgB,SAAS,SAAS,SAAS,cAAc,GAAG;GACtF,aAAa,SAAS,SAAS,kBAAkB;GACjD;;CAGF,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,gBACC,OACkD;AAClD,SAAO,KAAK,KAAK,gBAAgB,MAAM;;CAGxC,2BAA8C;AAC7C,SAAO,KAAK,KAAK,0BAA0B;;CAG5C,uBACC,OACgD;AAChD,SAAO,KAAK,KAAK,uBAAuB,MAAM;;CAG/C,uBACC,OACyD;AACzD,SAAO,KAAK,KAAK,uBAAuB,MAAM"}
|
package/dist/grpc/core.d.mts
CHANGED
|
@@ -5,6 +5,8 @@ import "../transactions/index.mjs";
|
|
|
5
5
|
import { CoreClient, CoreClientOptions } from "../client/core.mjs";
|
|
6
6
|
import "../client/index.mjs";
|
|
7
7
|
import "./proto/sui/rpc/v2/effects.mjs";
|
|
8
|
+
import { ExecutedTransaction } from "./proto/sui/rpc/v2/executed_transaction.mjs";
|
|
9
|
+
import { SimulateTransactionResponse } from "./proto/sui/rpc/v2/transaction_execution_service.mjs";
|
|
8
10
|
import { SuiGrpcClient } from "./client.mjs";
|
|
9
11
|
|
|
10
12
|
//#region src/grpc/core.d.ts
|
|
@@ -26,16 +28,22 @@ declare class GrpcCoreClient extends CoreClient {
|
|
|
26
28
|
getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(options: SuiClientTypes.GetTransactionOptions<Include>): Promise<SuiClientTypes.TransactionResult<Include>>;
|
|
27
29
|
executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(options: SuiClientTypes.ExecuteTransactionOptions<Include>): Promise<SuiClientTypes.TransactionResult<Include>>;
|
|
28
30
|
simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(options: SuiClientTypes.SimulateTransactionOptions<Include>): Promise<SuiClientTypes.SimulateTransactionResult<Include>>;
|
|
29
|
-
getReferenceGasPrice(): Promise<SuiClientTypes.GetReferenceGasPriceResponse>;
|
|
30
|
-
getProtocolConfig(): Promise<SuiClientTypes.GetProtocolConfigResponse>;
|
|
31
|
-
getCurrentSystemState(): Promise<SuiClientTypes.GetCurrentSystemStateResponse>;
|
|
31
|
+
getReferenceGasPrice(options?: SuiClientTypes.GetReferenceGasPriceOptions): Promise<SuiClientTypes.GetReferenceGasPriceResponse>;
|
|
32
|
+
getProtocolConfig(options?: SuiClientTypes.GetProtocolConfigOptions): Promise<SuiClientTypes.GetProtocolConfigResponse>;
|
|
33
|
+
getCurrentSystemState(options?: SuiClientTypes.GetCurrentSystemStateOptions): Promise<SuiClientTypes.GetCurrentSystemStateResponse>;
|
|
32
34
|
listDynamicFields(options: SuiClientTypes.ListDynamicFieldsOptions): Promise<SuiClientTypes.ListDynamicFieldsResponse>;
|
|
33
35
|
verifyZkLoginSignature(options: SuiClientTypes.VerifyZkLoginSignatureOptions): Promise<SuiClientTypes.ZkLoginVerifyResponse>;
|
|
34
36
|
defaultNameServiceName(options: SuiClientTypes.DefaultNameServiceNameOptions): Promise<SuiClientTypes.DefaultNameServiceNameResponse>;
|
|
35
37
|
getMoveFunction(options: SuiClientTypes.GetMoveFunctionOptions): Promise<SuiClientTypes.GetMoveFunctionResponse>;
|
|
36
|
-
getChainIdentifier(
|
|
38
|
+
getChainIdentifier(options?: SuiClientTypes.GetChainIdentifierOptions): Promise<SuiClientTypes.GetChainIdentifierResponse>;
|
|
37
39
|
resolveTransactionPlugin(): (transactionData: TransactionDataBuilder, options: BuildTransactionOptions, next: () => Promise<void>) => Promise<void>;
|
|
38
40
|
}
|
|
41
|
+
declare function parseGrpcTransactionResponse<Include extends SuiClientTypes.TransactionInclude = {}>(transaction: ExecutedTransaction, options?: {
|
|
42
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
43
|
+
}): SuiClientTypes.TransactionResult<Include>;
|
|
44
|
+
declare function parseGrpcSimulateTransactionResponse<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(response: SimulateTransactionResponse, options?: {
|
|
45
|
+
include?: Include & SuiClientTypes.SimulateTransactionInclude;
|
|
46
|
+
}): SuiClientTypes.SimulateTransactionResult<Include>;
|
|
39
47
|
//#endregion
|
|
40
|
-
export { GrpcCoreClient, GrpcCoreClientOptions };
|
|
48
|
+
export { GrpcCoreClient, GrpcCoreClientOptions, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse };
|
|
41
49
|
//# sourceMappingURL=core.d.mts.map
|
package/dist/grpc/core.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.mts","names":[],"sources":["../../src/grpc/core.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.mts","names":[],"sources":["../../src/grpc/core.ts"],"mappings":";;;;;;;;;;;;UAkDiB,qBAAA,SAA8B,iBAAA;EAC9C,MAAA,EAAQ,aAAA;AAAA;AAAA,cAEI,cAAA,SAAuB,UAAA;EAAA;;IAErB,MAAA;IAAA,GAAW;EAAA,GAAW,qBAAA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s";
|
|
3
|
+
import { raceSignal } from "../client/mvr.mjs";
|
|
3
4
|
import { CoreClient } from "../client/core.mjs";
|
|
4
5
|
import { formatMoveAbortMessage } from "../client/utils.mjs";
|
|
5
6
|
import { SimulationError } from "../client/errors.mjs";
|
|
@@ -39,7 +40,7 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
39
40
|
const response = await this.#client.ledgerService.batchGetObjects({
|
|
40
41
|
requests: batch.map((id) => ({ objectId: id })),
|
|
41
42
|
readMask: { paths }
|
|
42
|
-
});
|
|
43
|
+
}, { abort: options.signal });
|
|
43
44
|
results.push(...response.response.objects.map((object) => {
|
|
44
45
|
if (object.result.oneofKind === "error") return new Error(object.result.error.message);
|
|
45
46
|
if (object.result.oneofKind !== "object") return /* @__PURE__ */ new Error("Unexpected result type");
|
|
@@ -80,11 +81,14 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
80
81
|
if (options.include?.display) paths.push("display");
|
|
81
82
|
const response = await this.#client.stateService.listOwnedObjects({
|
|
82
83
|
owner: options.owner,
|
|
83
|
-
objectType: options.type ? (await this.mvr.resolveType({
|
|
84
|
+
objectType: options.type ? (await this.mvr.resolveType({
|
|
85
|
+
type: options.type,
|
|
86
|
+
signal: options.signal
|
|
87
|
+
})).type : void 0,
|
|
84
88
|
pageToken: options.cursor ? fromBase64(options.cursor) : void 0,
|
|
85
89
|
pageSize: options.limit,
|
|
86
90
|
readMask: { paths }
|
|
87
|
-
});
|
|
91
|
+
}, { abort: options.signal });
|
|
88
92
|
return {
|
|
89
93
|
objects: response.response.objects.map((object) => ({
|
|
90
94
|
objectId: object.objectId,
|
|
@@ -114,11 +118,14 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
114
118
|
const coinType = options.coinType ?? SUI_TYPE_ARG;
|
|
115
119
|
const response = await this.#client.stateService.listOwnedObjects({
|
|
116
120
|
owner: options.owner,
|
|
117
|
-
objectType: `0x2::coin::Coin<${(await this.mvr.resolveType({
|
|
121
|
+
objectType: `0x2::coin::Coin<${(await this.mvr.resolveType({
|
|
122
|
+
type: coinType,
|
|
123
|
+
signal: options.signal
|
|
124
|
+
})).type}>`,
|
|
118
125
|
pageToken: options.cursor ? fromBase64(options.cursor) : void 0,
|
|
119
126
|
pageSize: options.limit,
|
|
120
127
|
readMask: { paths }
|
|
121
|
-
});
|
|
128
|
+
}, { abort: options.signal });
|
|
122
129
|
return {
|
|
123
130
|
objects: response.response.objects.map((object) => ({
|
|
124
131
|
objectId: object.objectId,
|
|
@@ -136,8 +143,11 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
136
143
|
const coinType = options.coinType ?? SUI_TYPE_ARG;
|
|
137
144
|
const result = await this.#client.stateService.getBalance({
|
|
138
145
|
owner: options.owner,
|
|
139
|
-
coinType: (await this.mvr.resolveType({
|
|
140
|
-
|
|
146
|
+
coinType: (await this.mvr.resolveType({
|
|
147
|
+
type: coinType,
|
|
148
|
+
signal: options.signal
|
|
149
|
+
})).type
|
|
150
|
+
}, { abort: options.signal });
|
|
141
151
|
return { balance: {
|
|
142
152
|
balance: result.response.balance?.balance?.toString() ?? "0",
|
|
143
153
|
coinType: result.response.balance?.coinType ?? coinType,
|
|
@@ -146,11 +156,15 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
146
156
|
} };
|
|
147
157
|
}
|
|
148
158
|
async getCoinMetadata(options) {
|
|
149
|
-
const coinType = (await this.mvr.resolveType({
|
|
159
|
+
const coinType = (await this.mvr.resolveType({
|
|
160
|
+
type: options.coinType,
|
|
161
|
+
signal: options.signal
|
|
162
|
+
})).type;
|
|
150
163
|
let response;
|
|
151
164
|
try {
|
|
152
|
-
({response} = await this.#client.stateService.getCoinInfo({ coinType }));
|
|
153
|
-
} catch {
|
|
165
|
+
({response} = await this.#client.stateService.getCoinInfo({ coinType }, { abort: options.signal }));
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (options.signal?.aborted) throw error;
|
|
154
168
|
return { coinMetadata: null };
|
|
155
169
|
}
|
|
156
170
|
if (!response.metadata) return { coinMetadata: null };
|
|
@@ -168,7 +182,7 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
168
182
|
owner: options.owner,
|
|
169
183
|
pageToken: options.cursor ? fromBase64(options.cursor) : void 0,
|
|
170
184
|
pageSize: options.limit
|
|
171
|
-
});
|
|
185
|
+
}, { abort: options.signal });
|
|
172
186
|
return {
|
|
173
187
|
hasNextPage: !!result.response.nextPageToken,
|
|
174
188
|
cursor: result.response.nextPageToken ? toBase64(result.response.nextPageToken) : null,
|
|
@@ -199,9 +213,9 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
199
213
|
const { response } = await this.#client.ledgerService.getTransaction({
|
|
200
214
|
digest: options.digest,
|
|
201
215
|
readMask: { paths }
|
|
202
|
-
});
|
|
216
|
+
}, { abort: options.signal });
|
|
203
217
|
if (!response.transaction) throw new Error(`Transaction ${options.digest} not found`);
|
|
204
|
-
return
|
|
218
|
+
return parseGrpcTransactionResponse(response.transaction, { include: options.include });
|
|
205
219
|
}
|
|
206
220
|
async executeTransaction(options) {
|
|
207
221
|
const paths = [
|
|
@@ -226,8 +240,8 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
226
240
|
signature: { oneofKind: void 0 }
|
|
227
241
|
})),
|
|
228
242
|
readMask: { paths }
|
|
229
|
-
});
|
|
230
|
-
return
|
|
243
|
+
}, { abort: options.signal });
|
|
244
|
+
return parseGrpcTransactionResponse(response.transaction, { include: options.include });
|
|
231
245
|
}
|
|
232
246
|
async simulateTransaction(options) {
|
|
233
247
|
const paths = [
|
|
@@ -252,28 +266,14 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
252
266
|
readMask: { paths },
|
|
253
267
|
doGasSelection: false,
|
|
254
268
|
checks: options.checksEnabled === false ? SimulateTransactionRequest_TransactionChecks.DISABLED : SimulateTransactionRequest_TransactionChecks.ENABLED
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const commandResults = options.include?.commandResults && response.commandOutputs ? response.commandOutputs.map((output) => ({
|
|
258
|
-
returnValues: (output.returnValues ?? []).map((rv) => ({ bcs: rv.value?.value ?? null })),
|
|
259
|
-
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({ bcs: mr.value?.value ?? null }))
|
|
260
|
-
})) : void 0;
|
|
261
|
-
if (transactionResult.$kind === "Transaction") return {
|
|
262
|
-
$kind: "Transaction",
|
|
263
|
-
Transaction: transactionResult.Transaction,
|
|
264
|
-
commandResults
|
|
265
|
-
};
|
|
266
|
-
else return {
|
|
267
|
-
$kind: "FailedTransaction",
|
|
268
|
-
FailedTransaction: transactionResult.FailedTransaction,
|
|
269
|
-
commandResults
|
|
270
|
-
};
|
|
269
|
+
}, { abort: options.signal });
|
|
270
|
+
return parseGrpcSimulateTransactionResponse(response, { include: options.include });
|
|
271
271
|
}
|
|
272
|
-
async getReferenceGasPrice() {
|
|
273
|
-
return { referenceGasPrice: (await this.#client.ledgerService.getEpoch({ readMask: { paths: ["reference_gas_price"] } })).response.epoch?.referenceGasPrice?.toString() ?? "" };
|
|
272
|
+
async getReferenceGasPrice(options) {
|
|
273
|
+
return { referenceGasPrice: (await this.#client.ledgerService.getEpoch({ readMask: { paths: ["reference_gas_price"] } }, { abort: options?.signal })).response.epoch?.referenceGasPrice?.toString() ?? "" };
|
|
274
274
|
}
|
|
275
|
-
async getProtocolConfig() {
|
|
276
|
-
const protocolConfig = (await this.#client.ledgerService.getEpoch({ readMask: { paths: ["protocol_config"] } })).response.epoch?.protocolConfig;
|
|
275
|
+
async getProtocolConfig(options) {
|
|
276
|
+
const protocolConfig = (await this.#client.ledgerService.getEpoch({ readMask: { paths: ["protocol_config"] } }, { abort: options?.signal })).response.epoch?.protocolConfig;
|
|
277
277
|
if (!protocolConfig) throw new Error("Protocol config not found in response");
|
|
278
278
|
const featureFlags = { ...protocolConfig.featureFlags };
|
|
279
279
|
const attributes = {};
|
|
@@ -284,7 +284,7 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
284
284
|
attributes
|
|
285
285
|
} };
|
|
286
286
|
}
|
|
287
|
-
async getCurrentSystemState() {
|
|
287
|
+
async getCurrentSystemState(options) {
|
|
288
288
|
const epoch = (await this.#client.ledgerService.getEpoch({ readMask: { paths: [
|
|
289
289
|
"system_state.version",
|
|
290
290
|
"system_state.epoch",
|
|
@@ -299,7 +299,7 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
299
299
|
"system_state.parameters",
|
|
300
300
|
"system_state.storage_fund",
|
|
301
301
|
"system_state.stake_subsidy"
|
|
302
|
-
] } })).response.epoch;
|
|
302
|
+
] } }, { abort: options?.signal })).response.epoch;
|
|
303
303
|
const systemState = epoch?.systemState;
|
|
304
304
|
if (!systemState) throw new Error("System state not found in response");
|
|
305
305
|
const startMs = epoch?.start?.seconds ? Number(epoch.start.seconds) * 1e3 + Math.floor((epoch.start.nanos || 0) / 1e6) : systemState.epochStartTimestampMs ? Number(systemState.epochStartTimestampMs) : null;
|
|
@@ -352,22 +352,25 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
352
352
|
},
|
|
353
353
|
address: options.address,
|
|
354
354
|
jwks: []
|
|
355
|
-
});
|
|
355
|
+
}, { abort: options.signal });
|
|
356
356
|
return {
|
|
357
357
|
success: response.isValid ?? false,
|
|
358
358
|
errors: response.reason ? [response.reason] : []
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
361
|
async defaultNameServiceName(options) {
|
|
362
|
-
return { data: { name: (await this.#client.nameService.reverseLookupName({ address: options.address })).response.record?.name ?? null } };
|
|
362
|
+
return { data: { name: (await this.#client.nameService.reverseLookupName({ address: options.address }, { abort: options.signal })).response.record?.name ?? null } };
|
|
363
363
|
}
|
|
364
364
|
async getMoveFunction(options) {
|
|
365
|
-
const resolvedPackageId = (await this.mvr.resolvePackage({
|
|
365
|
+
const resolvedPackageId = (await this.mvr.resolvePackage({
|
|
366
|
+
package: options.packageId,
|
|
367
|
+
signal: options.signal
|
|
368
|
+
})).package;
|
|
366
369
|
const { response } = await this.#client.movePackageService.getFunction({
|
|
367
370
|
packageId: resolvedPackageId,
|
|
368
371
|
moduleName: options.moduleName,
|
|
369
372
|
name: options.name
|
|
370
|
-
});
|
|
373
|
+
}, { abort: options.signal });
|
|
371
374
|
let visibility = "unknown";
|
|
372
375
|
switch (response.function?.visibility) {
|
|
373
376
|
case FunctionDescriptor_Visibility.PUBLIC:
|
|
@@ -402,12 +405,12 @@ var GrpcCoreClient = class extends CoreClient {
|
|
|
402
405
|
returns: response.function?.returns?.map((ret) => parseNormalizedSuiMoveType(ret)) ?? []
|
|
403
406
|
} };
|
|
404
407
|
}
|
|
405
|
-
async getChainIdentifier(
|
|
406
|
-
return this.cache.read(["chainIdentifier"], async () => {
|
|
408
|
+
async getChainIdentifier(options) {
|
|
409
|
+
return raceSignal(Promise.resolve(this.cache.read(["chainIdentifier"], async () => {
|
|
407
410
|
const { response } = await this.#client.ledgerService.getServiceInfo({});
|
|
408
411
|
if (!response.chainId) throw new Error("Chain identifier not found in service info");
|
|
409
412
|
return { chainIdentifier: response.chainId };
|
|
410
|
-
});
|
|
413
|
+
})), options?.signal);
|
|
411
414
|
}
|
|
412
415
|
resolveTransactionPlugin() {
|
|
413
416
|
const client = this.#client;
|
|
@@ -706,7 +709,8 @@ function parseTransactionEffects({ effects }) {
|
|
|
706
709
|
auxiliaryDataDigest: effects.auxiliaryDataDigest ?? null
|
|
707
710
|
};
|
|
708
711
|
}
|
|
709
|
-
function
|
|
712
|
+
function parseGrpcTransactionResponse(transaction, options) {
|
|
713
|
+
const include = options?.include;
|
|
710
714
|
const objectTypes = {};
|
|
711
715
|
if (include?.objectTypes) transaction.effects?.changedObjects?.forEach((change) => {
|
|
712
716
|
if (change.objectId && change.objectType) objectTypes[change.objectId] = change.objectType;
|
|
@@ -769,6 +773,24 @@ function parseTransaction(transaction, include) {
|
|
|
769
773
|
FailedTransaction: result
|
|
770
774
|
};
|
|
771
775
|
}
|
|
776
|
+
function parseGrpcSimulateTransactionResponse(response, options) {
|
|
777
|
+
const include = options?.include;
|
|
778
|
+
const transactionResult = parseGrpcTransactionResponse(response.transaction, { include });
|
|
779
|
+
const commandResults = include?.commandResults && response.commandOutputs ? response.commandOutputs.map((output) => ({
|
|
780
|
+
returnValues: (output.returnValues ?? []).map((rv) => ({ bcs: rv.value?.value ?? null })),
|
|
781
|
+
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({ bcs: mr.value?.value ?? null }))
|
|
782
|
+
})) : void 0;
|
|
783
|
+
if (transactionResult.$kind === "Transaction") return {
|
|
784
|
+
$kind: "Transaction",
|
|
785
|
+
Transaction: transactionResult.Transaction,
|
|
786
|
+
commandResults
|
|
787
|
+
};
|
|
788
|
+
return {
|
|
789
|
+
$kind: "FailedTransaction",
|
|
790
|
+
FailedTransaction: transactionResult.FailedTransaction,
|
|
791
|
+
commandResults
|
|
792
|
+
};
|
|
793
|
+
}
|
|
772
794
|
function parseNormalizedSuiMoveType(type) {
|
|
773
795
|
let reference = null;
|
|
774
796
|
if (type.reference === OpenSignature_Reference.IMMUTABLE) reference = "immutable";
|
|
@@ -809,5 +831,5 @@ function parseNormalizedSuiMoveTypeBody(type) {
|
|
|
809
831
|
}
|
|
810
832
|
|
|
811
833
|
//#endregion
|
|
812
|
-
export { GrpcCoreClient };
|
|
834
|
+
export { GrpcCoreClient, parseGrpcSimulateTransactionResponse, parseGrpcTransactionResponse };
|
|
813
835
|
//# sourceMappingURL=core.mjs.map
|