@mysten/sui 2.30.0 → 2.31.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/CHANGELOG.md +43 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +5 -1
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/index.d.mts +139 -47
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/types.d.mts.map +1 -1
- package/dist/client/core-resolver.d.mts.map +1 -1
- package/dist/client/core-resolver.mjs +5 -3
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/transaction-resolver.mjs +35 -8
- package/dist/client/transaction-resolver.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +74 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/input.d.mts +21 -1
- package/dist/grpc/proto/sui/rpc/v2/input.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/input.mjs +21 -0
- package/dist/grpc/proto/sui/rpc/v2/input.mjs.map +1 -1
- 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/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/core.mjs +1 -1
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +47 -42
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +65 -24
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/data/internal.d.mts +12 -0
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs +5 -1
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v2.d.mts +5 -0
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/index.d.mts +3 -2
- package/dist/transactions/intents/AllowanceBalance.mjs +147 -0
- package/dist/transactions/intents/AllowanceBalance.mjs.map +1 -0
- package/dist/transactions/intents/BalanceIntentNames.mjs +7 -0
- package/dist/transactions/intents/BalanceIntentNames.mjs.map +1 -0
- package/dist/transactions/intents/BalanceOptions.d.mts +27 -0
- package/dist/transactions/intents/BalanceOptions.d.mts.map +1 -0
- package/dist/transactions/intents/BalanceOptions.mjs +12 -0
- package/dist/transactions/intents/BalanceOptions.mjs.map +1 -0
- package/dist/transactions/intents/CoinWithBalance.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +31 -10
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/transactions/intents/ResolveBalances.mjs +16 -0
- package/dist/transactions/intents/ResolveBalances.mjs.map +1 -0
- package/dist/transactions/resolve.d.mts.map +1 -1
- package/dist/transactions/resolve.mjs +1 -1
- package/dist/transactions/resolve.mjs.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/docs/llms-index.md +1 -0
- package/docs/transactions/allowances.md +176 -0
- package/docs/transactions/coins-and-balances.md +12 -9
- package/package.json +1 -1
- package/src/bcs/bcs.ts +4 -0
- package/src/bcs/types.ts +2 -1
- package/src/client/core-resolver.ts +12 -6
- package/src/client/transaction-resolver.ts +43 -9
- package/src/graphql/generated/schema.graphql +87 -42
- package/src/graphql/generated/tada-env.ts +84 -0
- package/src/grpc/proto/sui/rpc/v2/input.ts +22 -0
- package/src/jsonRpc/core.ts +3 -4
- package/src/transactions/Transaction.ts +70 -49
- package/src/transactions/data/internal.ts +4 -0
- package/src/transactions/index.ts +3 -0
- package/src/transactions/intents/AllowanceBalance.ts +204 -0
- package/src/transactions/intents/BalanceIntentNames.ts +5 -0
- package/src/transactions/intents/BalanceOptions.ts +45 -0
- package/src/transactions/intents/CoinWithBalance.ts +51 -8
- package/src/transactions/intents/ResolveBalances.ts +30 -0
- package/src/transactions/resolve.ts +6 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-resolver.mjs","names":[],"sources":["../../src/client/core-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeSuiAddress,\n\tnormalizeSuiObjectId,\n\tnormalizeStructTag,\n\tSUI_TYPE_ARG,\n} from '../utils/index.js';\nimport { createCoinReservationRef } from '../utils/coin-reservation.js';\nimport type { ClientWithCoreApi } from './core.js';\nimport type { CallArg, Command } from '../transactions/data/internal.js';\nimport type { SuiClientTypes } from './types.js';\nimport { SimulationError } from './errors.js';\nimport { Inputs } from '../transactions/Inputs.js';\nimport { getPureBcsSchema, isTxContext } from '../transactions/serializer.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { chunk } from '@mysten/utils';\nimport type { BuildTransactionOptions } from '../transactions/index.js';\nimport { transactionUsesGasCoin } from '../transactions/resolution-utils.js';\n\n// The maximum objects that can be fetched at once using multiGetObjects.\nconst MAX_OBJECTS_PER_FETCH = 50;\n\n// An amount of gas (in gas units) that is added to transactions as an overhead to ensure transactions do not fail.\nconst GAS_SAFE_OVERHEAD = 1000n;\nconst MAX_GAS = 50_000_000_000;\n\n/** Compute a gas budget from gasUsed effects data. */\nexport function computeGasBudget(\n\tgasUsed: { computationCost: string; storageCost: string; storageRebate: string },\n\tgasPrice: bigint | string = 1n,\n): string {\n\tconst safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);\n\tconst baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;\n\tconst gasBudget =\n\t\tbaseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);\n\treturn String(\n\t\tgasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,\n\t);\n}\n\nfunction getClient(options: BuildTransactionOptions): ClientWithCoreApi {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\treturn options.client;\n}\n\nexport async function coreClientResolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tconst client = getClient(options);\n\tconst needsGasPrice = !options.onlyTransactionKind && !transactionData.gasData.price;\n\tconst needsPayment = !options.onlyTransactionKind && !transactionData.gasData.payment;\n\tconst gasPayer = transactionData.gasData.owner ?? transactionData.sender;\n\n\tconst usesGasCoin = transactionUsesGasCoin(transactionData);\n\tlet withdrawals = 0n;\n\n\tconst normalizedGasPayer = gasPayer ? normalizeSuiAddress(gasPayer) : null;\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.$kind !== 'FundsWithdrawal' || !normalizedGasPayer) continue;\n\t\tif (normalizeStructTag(input.FundsWithdrawal.typeArg.Balance) !== SUI_TYPE_ARG) continue;\n\n\t\tconst withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender\n\t\t\t? transactionData.sender\n\t\t\t: gasPayer;\n\t\tif (\n\t\t\twithdrawalOwner &&\n\t\t\tnormalizeSuiAddress(withdrawalOwner) === normalizedGasPayer &&\n\t\t\tinput.FundsWithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t) {\n\t\t\twithdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);\n\t\t}\n\t}\n\n\t// `setGasBudget` simulates with `payment: []` whenever it has to compute a\n\t// budget (i.e. one wasn't preset). The validator's replay-protection check\n\t// then requires either a `ValidDuring` expiration or at least one\n\t// \"address-owned\" input — an `ImmOrOwnedMoveObject` whose owner is\n\t// `AddressOwner`, which we can't tell from `Immutable` without owner info we\n\t// don't track. Provide a simulate-only `ValidDuring` whenever we'll actually\n\t// simulate and one isn't user-set.\n\tconst needsSimulateExpiration =\n\t\t!options.onlyTransactionKind && !transactionData.expiration && !transactionData.gasData.budget;\n\tconst needsSystemState =\n\t\tneedsGasPrice || (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst needsChainId = (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([\n\t\tnormalizeInputs(transactionData, client),\n\t\tneedsSystemState ? client.core.getCurrentSystemState() : null,\n\t\tneedsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,\n\t\tneedsPayment && gasPayer\n\t\t\t? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })\n\t\t\t: null,\n\t\tneedsChainId ? client.core.getChainIdentifier() : null,\n\t]);\n\n\tawait resolveObjectReferences(transactionData, client);\n\n\tif (!options.onlyTransactionKind) {\n\t\tconst systemState = systemStateResult?.systemState ?? null;\n\t\tconst chainIdentifier = chainIdResult?.chainIdentifier ?? null;\n\n\t\tif (systemState && !transactionData.gasData.price) {\n\t\t\ttransactionData.gasData.price = systemState.referenceGasPrice;\n\t\t}\n\n\t\tconst simulateExpiration =\n\t\t\tneedsSimulateExpiration && systemState && chainIdentifier\n\t\t\t\t? buildValidDuringExpiration(systemState, chainIdentifier)\n\t\t\t\t: undefined;\n\n\t\tawait setGasBudget(transactionData, client, simulateExpiration);\n\n\t\tif (needsPayment) {\n\t\t\tif (!balanceResult || !coinsResult) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsetGasPayment({\n\t\t\t\ttransactionData,\n\t\t\t\tbalance: balanceResult,\n\t\t\t\tcoins: coinsResult,\n\t\t\t\tusesGasCoin,\n\t\t\t\twithdrawals,\n\t\t\t\tgasPayer: gasPayer!,\n\t\t\t\tchainIdentifier,\n\t\t\t\tepoch: systemState?.epoch ?? null,\n\t\t\t});\n\t\t}\n\n\t\tif (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {\n\t\t\tawait setExpiration(transactionData, client, systemState, chainIdentifier);\n\t\t}\n\t}\n\n\treturn await next();\n}\n\nasync function setGasBudget(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsimulateExpiration?: ValidDuringExpiration,\n) {\n\tif (transactionData.gasData.budget) {\n\t\treturn;\n\t}\n\n\tconst simulateResult = await client.core.simulateTransaction({\n\t\ttransaction: transactionData.build({\n\t\t\toverrides: {\n\t\t\t\tgasData: {\n\t\t\t\t\tbudget: String(MAX_GAS),\n\t\t\t\t\tpayment: [],\n\t\t\t\t},\n\t\t\t\t...(simulateExpiration && { expiration: simulateExpiration }),\n\t\t\t},\n\t\t}),\n\t\tinclude: { effects: true },\n\t\t// The empty payment above is a placeholder for budget estimation, not a real address\n\t\t// balance payment, so the server must simulate with a mocked gas coin rather than\n\t\t// selecting gas. gRPC and GraphQL support this option, and JSON-RPC always mocks gas.\n\t\tdoGasSelection: false,\n\t} as SuiClientTypes.SimulateTransactionOptions<{ effects: true }> & { doGasSelection: boolean });\n\n\tif (simulateResult.$kind === 'FailedTransaction') {\n\t\tconst executionError = simulateResult.FailedTransaction.status.error ?? undefined;\n\t\tconst errorMessage = executionError?.message ?? 'Unknown error';\n\t\tthrow new SimulationError(`Transaction resolution failed: ${errorMessage}`, {\n\t\t\tcause: simulateResult,\n\t\t\texecutionError,\n\t\t});\n\t}\n\n\ttransactionData.gasData.budget = computeGasBudget(\n\t\tsimulateResult.Transaction.effects!.gasUsed,\n\t\ttransactionData.gasData.price ? String(transactionData.gasData.price) : undefined,\n\t);\n}\n\nfunction setGasPayment({\n\ttransactionData,\n\tbalance,\n\tcoins,\n\tusesGasCoin,\n\twithdrawals,\n\tgasPayer,\n\tchainIdentifier,\n\tepoch,\n}: {\n\ttransactionData: TransactionDataBuilder;\n\tbalance: SuiClientTypes.GetBalanceResponse;\n\tcoins: SuiClientTypes.ListCoinsResponse;\n\tusesGasCoin: boolean;\n\twithdrawals: bigint;\n\tgasPayer: string;\n\tchainIdentifier: string | null;\n\tepoch: string | null;\n}) {\n\tconst budget = BigInt(transactionData.gasData.budget!);\n\tconst addressBalance = BigInt(balance.balance.addressBalance);\n\n\tif (budget === 0n || (!usesGasCoin && addressBalance >= budget + withdrawals)) {\n\t\ttransactionData.gasData.payment = [];\n\t\treturn;\n\t}\n\n\tconst filteredCoins = coins.objects.filter((coin) => {\n\t\tconst matchingInput = transactionData.inputs.find((input) => {\n\t\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\t\treturn coin.objectId === input.Object.ImmOrOwnedObject.objectId;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn !matchingInput;\n\t});\n\n\tconst paymentCoins = filteredCoins.map((coin) => ({\n\t\tobjectId: coin.objectId,\n\t\tdigest: coin.digest,\n\t\tversion: coin.version,\n\t}));\n\n\tconst reservationAmount = addressBalance - withdrawals;\n\n\tif (usesGasCoin && reservationAmount > 0n && chainIdentifier && epoch) {\n\t\ttransactionData.gasData.payment = [\n\t\t\tcreateCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch),\n\t\t\t...paymentCoins,\n\t\t];\n\t} else if (!filteredCoins.length) {\n\t\tthrow new Error('No valid gas coins found for the transaction.');\n\t} else {\n\t\ttransactionData.gasData.payment = paymentCoins;\n\t}\n}\n\ninterface SystemStateData {\n\tepoch: string;\n\treferenceGasPrice: string;\n}\n\nasync function setExpiration(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsystemState: SystemStateData | null,\n\texistingChainIdentifier: string | null = null,\n) {\n\tconst [chainIdentifier, resolvedSystemState] = await Promise.all([\n\t\texistingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),\n\t\tsystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),\n\t]);\n\ttransactionData.expiration = buildValidDuringExpiration(resolvedSystemState, chainIdentifier);\n}\n\ntype ValidDuringExpiration = {\n\t$kind: 'ValidDuring';\n\tValidDuring: {\n\t\tminEpoch: string;\n\t\tmaxEpoch: string;\n\t\tminTimestamp: null;\n\t\tmaxTimestamp: null;\n\t\tchain: string;\n\t\tnonce: number;\n\t};\n};\n\nfunction buildValidDuringExpiration(\n\tsystemState: SystemStateData,\n\tchainIdentifier: string,\n): ValidDuringExpiration {\n\tconst currentEpoch = BigInt(systemState.epoch);\n\treturn {\n\t\t$kind: 'ValidDuring',\n\t\tValidDuring: {\n\t\t\tminEpoch: String(currentEpoch),\n\t\t\tmaxEpoch: String(currentEpoch + 1n),\n\t\t\tminTimestamp: null,\n\t\t\tmaxTimestamp: null,\n\t\t\tchain: chainIdentifier,\n\t\t\tnonce: (Math.random() * 0x100000000) >>> 0,\n\t\t},\n\t};\n}\n\nasync function resolveObjectReferences(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n) {\n\t// Keep track of the object references that will need to be resolved at the end of the transaction.\n\t// We keep the input by-reference to avoid needing to re-resolve it:\n\tconst objectsToResolve = transactionData.inputs.filter((input) => {\n\t\treturn (\n\t\t\tinput.UnresolvedObject &&\n\t\t\t!(input.UnresolvedObject.version || input.UnresolvedObject?.initialSharedVersion)\n\t\t);\n\t}) as Extract<CallArg, { UnresolvedObject: unknown }>[];\n\n\tconst dedupedIds = [\n\t\t...new Set(\n\t\t\tobjectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)),\n\t\t),\n\t];\n\n\tconst objectChunks = dedupedIds.length ? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH) : [];\n\tconst resolved = (\n\t\tawait Promise.all(\n\t\t\tobjectChunks.map((chunkIds) =>\n\t\t\t\tclient.core.getObjects({\n\t\t\t\t\tobjectIds: chunkIds,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).flatMap((result) => result.objects);\n\n\tconst responsesById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, resolved[index]];\n\t\t}),\n\t);\n\n\tconst invalidObjects = Array.from(responsesById)\n\t\t.filter(([_, obj]) => obj instanceof Error)\n\t\t.map(([_, obj]) => (obj as Error).message);\n\n\tif (invalidObjects.length) {\n\t\tthrow new Error(`The following input objects are invalid: ${invalidObjects.join(', ')}`);\n\t}\n\n\tconst objects = resolved.map((object) => {\n\t\tif (object instanceof Error) {\n\t\t\tthrow new Error(`Failed to fetch object: ${object.message}`);\n\t\t}\n\t\tconst owner = object.owner;\n\t\tconst initialSharedVersion =\n\t\t\towner && typeof owner === 'object'\n\t\t\t\t? owner.$kind === 'Shared'\n\t\t\t\t\t? owner.Shared.initialSharedVersion\n\t\t\t\t\t: owner.$kind === 'ConsensusAddressOwner'\n\t\t\t\t\t\t? owner.ConsensusAddressOwner.startVersion\n\t\t\t\t\t\t: null\n\t\t\t\t: null;\n\n\t\treturn {\n\t\t\tobjectId: object.objectId,\n\t\t\tdigest: object.digest,\n\t\t\tversion: object.version,\n\t\t\tinitialSharedVersion,\n\t\t};\n\t});\n\n\tconst objectsById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, objects[index]];\n\t\t}),\n\t);\n\n\tfor (const [index, input] of transactionData.inputs.entries()) {\n\t\tif (!input.UnresolvedObject) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet updated: CallArg | undefined;\n\t\tconst id = normalizeSuiAddress(input.UnresolvedObject.objectId);\n\t\tconst object = objectsById.get(id);\n\n\t\tif (input.UnresolvedObject.initialSharedVersion ?? object?.initialSharedVersion) {\n\t\t\tupdated = Inputs.SharedObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tinitialSharedVersion:\n\t\t\t\t\tinput.UnresolvedObject.initialSharedVersion || object?.initialSharedVersion!,\n\t\t\t\tmutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index),\n\t\t\t});\n\t\t} else if (isUsedAsReceiving(transactionData, index)) {\n\t\t\tupdated = Inputs.ReceivingRef(\n\t\t\t\t{\n\t\t\t\t\tobjectId: id,\n\t\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t\t}!,\n\t\t\t);\n\t\t}\n\n\t\ttransactionData.inputs[transactionData.inputs.indexOf(input)] =\n\t\t\tupdated ??\n\t\t\tInputs.ObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t});\n\t}\n}\n\nasync function normalizeInputs(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {\n\tconst { inputs, commands } = transactionData;\n\tconst moveCallsToResolve: Extract<Command, { MoveCall: unknown }>['MoveCall'][] = [];\n\tconst moveFunctionsToResolve = new Set<string>();\n\n\tcommands.forEach((command) => {\n\t\t// Special case move call:\n\t\tif (command.MoveCall) {\n\t\t\t// Determine if any of the arguments require encoding.\n\t\t\t// - If they don't, then this is good to go.\n\t\t\t// - If they do, then we need to fetch the normalized move module.\n\n\t\t\t// If we already know the argument types, we don't need to resolve them again\n\t\t\tif (command.MoveCall._argumentTypes) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputs = command.MoveCall.arguments.map((arg) => {\n\t\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\t\treturn transactionData.inputs[arg.Input];\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tconst needsResolution = inputs.some(\n\t\t\t\t(input) =>\n\t\t\t\t\tinput?.UnresolvedPure ||\n\t\t\t\t\t(input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== 'boolean'),\n\t\t\t);\n\n\t\t\tif (needsResolution) {\n\t\t\t\tconst functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;\n\t\t\t\tmoveFunctionsToResolve.add(functionName);\n\t\t\t\tmoveCallsToResolve.push(command.MoveCall);\n\t\t\t}\n\t\t}\n\t});\n\n\tconst moveFunctionParameters = new Map<string, SuiClientTypes.OpenSignature[]>();\n\tif (moveFunctionsToResolve.size > 0) {\n\t\tawait Promise.all(\n\t\t\t[...moveFunctionsToResolve].map(async (functionName) => {\n\t\t\t\tconst [packageId, moduleName, name] = functionName.split('::');\n\t\t\t\tconst { function: def } = await client.core.getMoveFunction({\n\t\t\t\t\tpackageId,\n\t\t\t\t\tmoduleName,\n\t\t\t\t\tname,\n\t\t\t\t});\n\n\t\t\t\tmoveFunctionParameters.set(functionName, def.parameters);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (moveCallsToResolve.length) {\n\t\tawait Promise.all(\n\t\t\tmoveCallsToResolve.map(async (moveCall) => {\n\t\t\t\tconst parameters = moveFunctionParameters.get(\n\t\t\t\t\t`${moveCall.package}::${moveCall.module}::${moveCall.function}`,\n\t\t\t\t);\n\n\t\t\t\tif (!parameters) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Entry functions can have a mutable reference to an instance of the TxContext\n\t\t\t\t// struct defined in the TxContext module as the last parameter. The caller of\n\t\t\t\t// the function does not need to pass it in as an argument.\n\t\t\t\tconst hasTxContext = parameters.length > 0 && isTxContext(parameters.at(-1)!);\n\t\t\t\tconst params = hasTxContext ? parameters.slice(0, parameters.length - 1) : parameters;\n\n\t\t\t\tmoveCall._argumentTypes = params;\n\t\t\t}),\n\t\t);\n\t}\n\n\tcommands.forEach((command) => {\n\t\tif (!command.MoveCall) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst moveCall = command.MoveCall;\n\t\tconst fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;\n\t\tconst params = moveCall._argumentTypes;\n\n\t\tif (!params) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (params.length !== command.MoveCall.arguments.length) {\n\t\t\tthrow new Error(`Incorrect number of arguments for ${fnName}`);\n\t\t}\n\n\t\tparams.forEach((param, i) => {\n\t\t\tconst arg = moveCall.arguments[i];\n\t\t\tif (arg.$kind !== 'Input') return;\n\t\t\tconst input = inputs[arg.Input];\n\n\t\t\t// Skip if the input is already resolved\n\t\t\tif (!input.UnresolvedPure && !input.UnresolvedObject) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputValue = input.UnresolvedPure?.value ?? input.UnresolvedObject?.objectId!;\n\n\t\t\tconst schema = getPureBcsSchema(param.body);\n\t\t\tif (schema) {\n\t\t\t\targ.type = 'pure';\n\t\t\t\tinputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof inputValue !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expect the argument to be an object id string, got ${JSON.stringify(\n\t\t\t\t\t\tinputValue,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t2,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ.type = 'object';\n\t\t\tconst unresolvedObject: typeof input = input.UnresolvedPure\n\t\t\t\t? {\n\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\tUnresolvedObject: {\n\t\t\t\t\t\t\tobjectId: inputValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: input;\n\n\t\t\tinputs[arg.Input] = unresolvedObject;\n\t\t});\n\t});\n}\n\nfunction isUsedAsMutable(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsMutable = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsMutable =\n\t\t\t\ttx.MoveCall._argumentTypes[argIndex].reference !== 'immutable' || usedAsMutable;\n\t\t}\n\n\t\tif (\n\t\t\ttx.$kind === 'MakeMoveVec' ||\n\t\t\ttx.$kind === 'MergeCoins' ||\n\t\t\ttx.$kind === 'SplitCoins' ||\n\t\t\ttx.$kind === 'TransferObjects'\n\t\t) {\n\t\t\tusedAsMutable = true;\n\t\t}\n\t});\n\n\treturn usedAsMutable;\n}\n\nfunction isUsedAsReceiving(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsReceiving = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsReceiving = isReceivingType(tx.MoveCall._argumentTypes[argIndex]) || usedAsReceiving;\n\t\t}\n\t});\n\n\treturn usedAsReceiving;\n}\n\nconst RECEIVING_TYPE =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving';\n\nfunction isReceivingType(type: SuiClientTypes.OpenSignature): boolean {\n\tif (type.body.$kind !== 'datatype') {\n\t\treturn false;\n\t}\n\n\treturn type.body.datatype.typeName === RECEIVING_TYPE;\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,wBAAwB;AAG9B,MAAM,oBAAoB;AAC1B,MAAM,UAAU;;AAGhB,SAAgB,iBACf,SACA,WAA4B,IACnB;CACT,MAAM,eAAe,oBAAoB,OAAO,SAAS;CACzD,MAAM,kCAAkC,OAAO,QAAQ,gBAAgB,GAAG;CAC1E,MAAM,YACL,kCAAkC,OAAO,QAAQ,YAAY,GAAG,OAAO,QAAQ,cAAc;AAC9F,QAAO,OACN,YAAY,kCAAkC,YAAY,gCAC1D;;AAGF,SAAS,UAAU,SAAqD;AACvE,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,uGACA;AAEF,QAAO,QAAQ;;AAGhB,eAAsB,mCACrB,iBACA,SACA,MACC;CACD,MAAM,SAAS,UAAU,QAAQ;CACjC,MAAM,gBAAgB,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC/E,MAAM,eAAe,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC9E,MAAM,WAAW,gBAAgB,QAAQ,SAAS,gBAAgB;CAElE,MAAM,cAAc,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ACA,OAAO;IACP,kBAAkB,EACjB,UAAU,YACV;IACD,GACA;AAEH,UAAO,IAAI,SAAS;IACnB;GACD;;AAGH,SAAS,gBAAgB,iBAAyC,OAAe;CAChF,IAAI,gBAAgB;AAEpB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,mBACC,GAAG,SAAS,eAAe,UAAU,cAAc,eAAe;;AAGpE,MACC,GAAG,UAAU,iBACb,GAAG,UAAU,gBACb,GAAG,UAAU,gBACb,GAAG,UAAU,kBAEb,iBAAgB;GAEhB;AAEF,QAAO;;AAGR,SAAS,kBAAkB,iBAAyC,OAAe;CAClF,IAAI,kBAAkB;AAEtB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,qBAAkB,gBAAgB,GAAG,SAAS,eAAe,UAAU,IAAI;;GAE3E;AAEF,QAAO;;AAGR,MAAM,iBACL;AAED,SAAS,gBAAgB,MAA6C;AACrE,KAAI,KAAK,KAAK,UAAU,WACvB,QAAO;AAGR,QAAO,KAAK,KAAK,SAAS,aAAa"}
|
|
1
|
+
{"version":3,"file":"core-resolver.mjs","names":[],"sources":["../../src/client/core-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeSuiAddress,\n\tnormalizeSuiObjectId,\n\tnormalizeStructTag,\n\tSUI_TYPE_ARG,\n} from '../utils/index.js';\nimport { createCoinReservationRef } from '../utils/coin-reservation.js';\nimport type { ClientWithCoreApi } from './core.js';\nimport type { CallArg, Command } from '../transactions/data/internal.js';\nimport type { SuiClientTypes } from './types.js';\nimport { SimulationError } from './errors.js';\nimport { Inputs } from '../transactions/Inputs.js';\nimport { getPureBcsSchema, isTxContext } from '../transactions/serializer.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { chunk } from '@mysten/utils';\nimport type { BuildTransactionOptions } from '../transactions/index.js';\nimport { transactionUsesGasCoin } from '../transactions/resolution-utils.js';\n\n// The maximum objects that can be fetched at once using multiGetObjects.\nconst MAX_OBJECTS_PER_FETCH = 50;\n\n// The gas payment limit is inclusive as of protocol version 96.\nconst MAX_GAS_PAYMENT_OBJECTS = 256;\n\n// An amount of gas (in gas units) that is added to transactions as an overhead to ensure transactions do not fail.\nconst GAS_SAFE_OVERHEAD = 1000n;\nconst MAX_GAS = 50_000_000_000;\n\n/** Compute a gas budget from gasUsed effects data. */\nexport function computeGasBudget(\n\tgasUsed: { computationCost: string; storageCost: string; storageRebate: string },\n\tgasPrice: bigint | string = 1n,\n): string {\n\tconst safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);\n\tconst baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;\n\tconst gasBudget =\n\t\tbaseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);\n\treturn String(\n\t\tgasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,\n\t);\n}\n\nfunction getClient(options: BuildTransactionOptions): ClientWithCoreApi {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\treturn options.client;\n}\n\nexport async function coreClientResolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tconst client = getClient(options);\n\tconst needsGasPrice = !options.onlyTransactionKind && !transactionData.gasData.price;\n\tconst needsPayment = !options.onlyTransactionKind && !transactionData.gasData.payment;\n\tconst gasPayer = transactionData.gasData.owner ?? transactionData.sender;\n\n\tconst usesGasCoin = transactionUsesGasCoin(transactionData);\n\tlet withdrawals = 0n;\n\n\tconst normalizedGasPayer = gasPayer ? normalizeSuiAddress(gasPayer) : null;\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.$kind !== 'FundsWithdrawal' || !normalizedGasPayer) continue;\n\t\tif (normalizeStructTag(input.FundsWithdrawal.typeArg.Balance) !== SUI_TYPE_ARG) continue;\n\t\tconst source = input.FundsWithdrawal.withdrawFrom;\n\t\tconst withdrawalOwner = source.SenderAllowance\n\t\t\t? source.SenderAllowance.funder\n\t\t\t: source.Sender\n\t\t\t\t? transactionData.sender\n\t\t\t\t: gasPayer;\n\t\tif (\n\t\t\twithdrawalOwner &&\n\t\t\tnormalizeSuiAddress(withdrawalOwner) === normalizedGasPayer &&\n\t\t\tinput.FundsWithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t) {\n\t\t\twithdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);\n\t\t}\n\t}\n\n\t// `setGasBudget` simulates with `payment: []` whenever it has to compute a\n\t// budget (i.e. one wasn't preset). The validator's replay-protection check\n\t// then requires either a `ValidDuring` expiration or at least one\n\t// \"address-owned\" input — an `ImmOrOwnedMoveObject` whose owner is\n\t// `AddressOwner`, which we can't tell from `Immutable` without owner info we\n\t// don't track. Provide a simulate-only `ValidDuring` whenever we'll actually\n\t// simulate and one isn't user-set.\n\tconst needsSimulateExpiration =\n\t\t!options.onlyTransactionKind && !transactionData.expiration && !transactionData.gasData.budget;\n\tconst needsSystemState =\n\t\tneedsGasPrice || (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst needsChainId = (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([\n\t\tnormalizeInputs(transactionData, client),\n\t\tneedsSystemState ? client.core.getCurrentSystemState() : null,\n\t\tneedsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,\n\t\tneedsPayment && gasPayer\n\t\t\t? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })\n\t\t\t: null,\n\t\tneedsChainId ? client.core.getChainIdentifier() : null,\n\t]);\n\n\tawait resolveObjectReferences(transactionData, client);\n\n\tif (!options.onlyTransactionKind) {\n\t\tconst systemState = systemStateResult?.systemState ?? null;\n\t\tconst chainIdentifier = chainIdResult?.chainIdentifier ?? null;\n\n\t\tif (systemState && !transactionData.gasData.price) {\n\t\t\ttransactionData.gasData.price = systemState.referenceGasPrice;\n\t\t}\n\n\t\tconst simulateExpiration =\n\t\t\tneedsSimulateExpiration && systemState && chainIdentifier\n\t\t\t\t? buildValidDuringExpiration(systemState, chainIdentifier)\n\t\t\t\t: undefined;\n\n\t\tawait setGasBudget(transactionData, client, simulateExpiration);\n\n\t\tif (needsPayment) {\n\t\t\tif (!balanceResult || !coinsResult) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsetGasPayment({\n\t\t\t\ttransactionData,\n\t\t\t\tbalance: balanceResult,\n\t\t\t\tcoins: coinsResult,\n\t\t\t\tusesGasCoin,\n\t\t\t\twithdrawals,\n\t\t\t\tgasPayer: gasPayer!,\n\t\t\t\tchainIdentifier,\n\t\t\t\tepoch: systemState?.epoch ?? null,\n\t\t\t});\n\t\t}\n\n\t\tif (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {\n\t\t\tawait setExpiration(transactionData, client, systemState, chainIdentifier);\n\t\t}\n\t}\n\n\treturn await next();\n}\n\nasync function setGasBudget(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsimulateExpiration?: ValidDuringExpiration,\n) {\n\tif (transactionData.gasData.budget) {\n\t\treturn;\n\t}\n\n\tconst simulateResult = await client.core.simulateTransaction({\n\t\ttransaction: transactionData.build({\n\t\t\toverrides: {\n\t\t\t\tgasData: {\n\t\t\t\t\tbudget: String(MAX_GAS),\n\t\t\t\t\tpayment: [],\n\t\t\t\t},\n\t\t\t\t...(simulateExpiration && { expiration: simulateExpiration }),\n\t\t\t},\n\t\t}),\n\t\tinclude: { effects: true },\n\t\t// The empty payment above is a placeholder for budget estimation, not a real address\n\t\t// balance payment, so the server must simulate with a mocked gas coin rather than\n\t\t// selecting gas. gRPC and GraphQL support this option, and JSON-RPC always mocks gas.\n\t\tdoGasSelection: false,\n\t} as SuiClientTypes.SimulateTransactionOptions<{ effects: true }> & { doGasSelection: boolean });\n\n\tif (simulateResult.$kind === 'FailedTransaction') {\n\t\tconst executionError = simulateResult.FailedTransaction.status.error ?? undefined;\n\t\tconst errorMessage = executionError?.message ?? 'Unknown error';\n\t\tthrow new SimulationError(`Transaction resolution failed: ${errorMessage}`, {\n\t\t\tcause: simulateResult,\n\t\t\texecutionError,\n\t\t});\n\t}\n\n\ttransactionData.gasData.budget = computeGasBudget(\n\t\tsimulateResult.Transaction.effects!.gasUsed,\n\t\ttransactionData.gasData.price ? String(transactionData.gasData.price) : undefined,\n\t);\n}\n\nfunction setGasPayment({\n\ttransactionData,\n\tbalance,\n\tcoins,\n\tusesGasCoin,\n\twithdrawals,\n\tgasPayer,\n\tchainIdentifier,\n\tepoch,\n}: {\n\ttransactionData: TransactionDataBuilder;\n\tbalance: SuiClientTypes.GetBalanceResponse;\n\tcoins: SuiClientTypes.ListCoinsResponse;\n\tusesGasCoin: boolean;\n\twithdrawals: bigint;\n\tgasPayer: string;\n\tchainIdentifier: string | null;\n\tepoch: string | null;\n}) {\n\tconst budget = BigInt(transactionData.gasData.budget!);\n\tconst addressBalance = BigInt(balance.balance.addressBalance);\n\n\tif (budget === 0n || (!usesGasCoin && addressBalance >= budget + withdrawals)) {\n\t\ttransactionData.gasData.payment = [];\n\t\treturn;\n\t}\n\n\tconst filteredCoins = coins.objects.filter((coin) => {\n\t\tconst matchingInput = transactionData.inputs.find((input) => {\n\t\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\t\treturn coin.objectId === input.Object.ImmOrOwnedObject.objectId;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn !matchingInput;\n\t});\n\n\tconst paymentCoins = filteredCoins.map((coin) => ({\n\t\tobjectId: coin.objectId,\n\t\tdigest: coin.digest,\n\t\tversion: coin.version,\n\t}));\n\n\tconst reservationAmount = addressBalance - withdrawals;\n\n\tif (usesGasCoin && reservationAmount > 0n && chainIdentifier && epoch) {\n\t\ttransactionData.gasData.payment = [\n\t\t\tcreateCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch),\n\t\t\t// The reservation occupies one entry in the gas payment limit.\n\t\t\t...paymentCoins.slice(0, MAX_GAS_PAYMENT_OBJECTS - 1),\n\t\t];\n\t} else if (!filteredCoins.length) {\n\t\tthrow new Error('No valid gas coins found for the transaction.');\n\t} else {\n\t\ttransactionData.gasData.payment = paymentCoins.slice(0, MAX_GAS_PAYMENT_OBJECTS);\n\t}\n}\n\ninterface SystemStateData {\n\tepoch: string;\n\treferenceGasPrice: string;\n}\n\nasync function setExpiration(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsystemState: SystemStateData | null,\n\texistingChainIdentifier: string | null = null,\n) {\n\tconst [chainIdentifier, resolvedSystemState] = await Promise.all([\n\t\texistingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),\n\t\tsystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),\n\t]);\n\ttransactionData.expiration = buildValidDuringExpiration(resolvedSystemState, chainIdentifier);\n}\n\ntype ValidDuringExpiration = {\n\t$kind: 'ValidDuring';\n\tValidDuring: {\n\t\tminEpoch: string;\n\t\tmaxEpoch: string;\n\t\tminTimestamp: null;\n\t\tmaxTimestamp: null;\n\t\tchain: string;\n\t\tnonce: number;\n\t};\n};\n\nfunction buildValidDuringExpiration(\n\tsystemState: SystemStateData,\n\tchainIdentifier: string,\n): ValidDuringExpiration {\n\tconst currentEpoch = BigInt(systemState.epoch);\n\treturn {\n\t\t$kind: 'ValidDuring',\n\t\tValidDuring: {\n\t\t\tminEpoch: String(currentEpoch),\n\t\t\tmaxEpoch: String(currentEpoch + 1n),\n\t\t\tminTimestamp: null,\n\t\t\tmaxTimestamp: null,\n\t\t\tchain: chainIdentifier,\n\t\t\tnonce: (Math.random() * 0x100000000) >>> 0,\n\t\t},\n\t};\n}\n\nasync function resolveObjectReferences(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n) {\n\t// Keep track of the object references that will need to be resolved at the end of the transaction.\n\t// We keep the input by-reference to avoid needing to re-resolve it:\n\tconst objectsToResolve = transactionData.inputs.filter((input) => {\n\t\treturn (\n\t\t\tinput.UnresolvedObject &&\n\t\t\t!(input.UnresolvedObject.version || input.UnresolvedObject?.initialSharedVersion)\n\t\t);\n\t}) as Extract<CallArg, { UnresolvedObject: unknown }>[];\n\n\tconst dedupedIds = [\n\t\t...new Set(\n\t\t\tobjectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)),\n\t\t),\n\t];\n\n\tconst objectChunks = dedupedIds.length ? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH) : [];\n\tconst resolved = (\n\t\tawait Promise.all(\n\t\t\tobjectChunks.map((chunkIds) =>\n\t\t\t\tclient.core.getObjects({\n\t\t\t\t\tobjectIds: chunkIds,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).flatMap((result) => result.objects);\n\n\tconst responsesById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, resolved[index]];\n\t\t}),\n\t);\n\n\tconst invalidObjects = Array.from(responsesById)\n\t\t.filter(([_, obj]) => obj instanceof Error)\n\t\t.map(([_, obj]) => (obj as Error).message);\n\n\tif (invalidObjects.length) {\n\t\tthrow new Error(`The following input objects are invalid: ${invalidObjects.join(', ')}`);\n\t}\n\n\tconst objects = resolved.map((object) => {\n\t\tif (object instanceof Error) {\n\t\t\tthrow new Error(`Failed to fetch object: ${object.message}`);\n\t\t}\n\t\tconst owner = object.owner;\n\t\tconst initialSharedVersion =\n\t\t\towner && typeof owner === 'object'\n\t\t\t\t? owner.$kind === 'Shared'\n\t\t\t\t\t? owner.Shared.initialSharedVersion\n\t\t\t\t\t: owner.$kind === 'ConsensusAddressOwner'\n\t\t\t\t\t\t? owner.ConsensusAddressOwner.startVersion\n\t\t\t\t\t\t: null\n\t\t\t\t: null;\n\n\t\treturn {\n\t\t\tobjectId: object.objectId,\n\t\t\tdigest: object.digest,\n\t\t\tversion: object.version,\n\t\t\tinitialSharedVersion,\n\t\t};\n\t});\n\n\tconst objectsById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, objects[index]];\n\t\t}),\n\t);\n\n\tfor (const [index, input] of transactionData.inputs.entries()) {\n\t\tif (!input.UnresolvedObject) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet updated: CallArg | undefined;\n\t\tconst id = normalizeSuiAddress(input.UnresolvedObject.objectId);\n\t\tconst object = objectsById.get(id);\n\n\t\tif (input.UnresolvedObject.initialSharedVersion ?? object?.initialSharedVersion) {\n\t\t\tupdated = Inputs.SharedObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tinitialSharedVersion:\n\t\t\t\t\tinput.UnresolvedObject.initialSharedVersion || object?.initialSharedVersion!,\n\t\t\t\tmutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index),\n\t\t\t});\n\t\t} else if (isUsedAsReceiving(transactionData, index)) {\n\t\t\tupdated = Inputs.ReceivingRef(\n\t\t\t\t{\n\t\t\t\t\tobjectId: id,\n\t\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t\t}!,\n\t\t\t);\n\t\t}\n\n\t\ttransactionData.inputs[transactionData.inputs.indexOf(input)] =\n\t\t\tupdated ??\n\t\t\tInputs.ObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t});\n\t}\n}\n\nasync function normalizeInputs(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {\n\tconst { inputs, commands } = transactionData;\n\tconst moveCallsToResolve: Extract<Command, { MoveCall: unknown }>['MoveCall'][] = [];\n\tconst moveFunctionsToResolve = new Set<string>();\n\n\tcommands.forEach((command) => {\n\t\t// Special case move call:\n\t\tif (command.MoveCall) {\n\t\t\t// Determine if any of the arguments require encoding.\n\t\t\t// - If they don't, then this is good to go.\n\t\t\t// - If they do, then we need to fetch the normalized move module.\n\n\t\t\t// If we already know the argument types, we don't need to resolve them again\n\t\t\tif (command.MoveCall._argumentTypes) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputs = command.MoveCall.arguments.map((arg) => {\n\t\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\t\treturn transactionData.inputs[arg.Input];\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tconst needsResolution = inputs.some(\n\t\t\t\t(input) =>\n\t\t\t\t\tinput?.UnresolvedPure ||\n\t\t\t\t\t(input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== 'boolean'),\n\t\t\t);\n\n\t\t\tif (needsResolution) {\n\t\t\t\tconst functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;\n\t\t\t\tmoveFunctionsToResolve.add(functionName);\n\t\t\t\tmoveCallsToResolve.push(command.MoveCall);\n\t\t\t}\n\t\t}\n\t});\n\n\tconst moveFunctionParameters = new Map<string, SuiClientTypes.OpenSignature[]>();\n\tif (moveFunctionsToResolve.size > 0) {\n\t\tawait Promise.all(\n\t\t\t[...moveFunctionsToResolve].map(async (functionName) => {\n\t\t\t\tconst [packageId, moduleName, name] = functionName.split('::');\n\t\t\t\tconst { function: def } = await client.core.getMoveFunction({\n\t\t\t\t\tpackageId,\n\t\t\t\t\tmoduleName,\n\t\t\t\t\tname,\n\t\t\t\t});\n\n\t\t\t\tmoveFunctionParameters.set(functionName, def.parameters);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (moveCallsToResolve.length) {\n\t\tawait Promise.all(\n\t\t\tmoveCallsToResolve.map(async (moveCall) => {\n\t\t\t\tconst parameters = moveFunctionParameters.get(\n\t\t\t\t\t`${moveCall.package}::${moveCall.module}::${moveCall.function}`,\n\t\t\t\t);\n\n\t\t\t\tif (!parameters) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Entry functions can have a mutable reference to an instance of the TxContext\n\t\t\t\t// struct defined in the TxContext module as the last parameter. The caller of\n\t\t\t\t// the function does not need to pass it in as an argument.\n\t\t\t\tconst hasTxContext = parameters.length > 0 && isTxContext(parameters.at(-1)!);\n\t\t\t\tconst params = hasTxContext ? parameters.slice(0, parameters.length - 1) : parameters;\n\n\t\t\t\tmoveCall._argumentTypes = params;\n\t\t\t}),\n\t\t);\n\t}\n\n\tcommands.forEach((command) => {\n\t\tif (!command.MoveCall) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst moveCall = command.MoveCall;\n\t\tconst fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;\n\t\tconst params = moveCall._argumentTypes;\n\n\t\tif (!params) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (params.length !== command.MoveCall.arguments.length) {\n\t\t\tthrow new Error(`Incorrect number of arguments for ${fnName}`);\n\t\t}\n\n\t\tparams.forEach((param, i) => {\n\t\t\tconst arg = moveCall.arguments[i];\n\t\t\tif (arg.$kind !== 'Input') return;\n\t\t\tconst input = inputs[arg.Input];\n\n\t\t\t// Skip if the input is already resolved\n\t\t\tif (!input.UnresolvedPure && !input.UnresolvedObject) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputValue = input.UnresolvedPure?.value ?? input.UnresolvedObject?.objectId!;\n\n\t\t\tconst schema = getPureBcsSchema(param.body);\n\t\t\tif (schema) {\n\t\t\t\targ.type = 'pure';\n\t\t\t\tinputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof inputValue !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expect the argument to be an object id string, got ${JSON.stringify(\n\t\t\t\t\t\tinputValue,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t2,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ.type = 'object';\n\t\t\tconst unresolvedObject: typeof input = input.UnresolvedPure\n\t\t\t\t? {\n\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\tUnresolvedObject: {\n\t\t\t\t\t\t\tobjectId: inputValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: input;\n\n\t\t\tinputs[arg.Input] = unresolvedObject;\n\t\t});\n\t});\n}\n\nfunction isUsedAsMutable(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsMutable = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsMutable =\n\t\t\t\ttx.MoveCall._argumentTypes[argIndex].reference !== 'immutable' || usedAsMutable;\n\t\t}\n\n\t\tif (\n\t\t\ttx.$kind === 'MakeMoveVec' ||\n\t\t\ttx.$kind === 'MergeCoins' ||\n\t\t\ttx.$kind === 'SplitCoins' ||\n\t\t\ttx.$kind === 'TransferObjects'\n\t\t) {\n\t\t\tusedAsMutable = true;\n\t\t}\n\t});\n\n\treturn usedAsMutable;\n}\n\nfunction isUsedAsReceiving(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsReceiving = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsReceiving = isReceivingType(tx.MoveCall._argumentTypes[argIndex]) || usedAsReceiving;\n\t\t}\n\t});\n\n\treturn usedAsReceiving;\n}\n\nconst RECEIVING_TYPE =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving';\n\nfunction isReceivingType(type: SuiClientTypes.OpenSignature): boolean {\n\tif (type.body.$kind !== 'datatype') {\n\t\treturn false;\n\t}\n\n\treturn type.body.datatype.typeName === RECEIVING_TYPE;\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,wBAAwB;AAG9B,MAAM,0BAA0B;AAGhC,MAAM,oBAAoB;AAC1B,MAAM,UAAU;;AAGhB,SAAgB,iBACf,SACA,WAA4B,IACnB;CACT,MAAM,eAAe,oBAAoB,OAAO,SAAS;CACzD,MAAM,kCAAkC,OAAO,QAAQ,gBAAgB,GAAG;CAC1E,MAAM,YACL,kCAAkC,OAAO,QAAQ,YAAY,GAAG,OAAO,QAAQ,cAAc;AAC9F,QAAO,OACN,YAAY,kCAAkC,YAAY,gCAC1D;;AAGF,SAAS,UAAU,SAAqD;AACvE,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,uGACA;AAEF,QAAO,QAAQ;;AAGhB,eAAsB,mCACrB,iBACA,SACA,MACC;CACD,MAAM,SAAS,UAAU,QAAQ;CACjC,MAAM,gBAAgB,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC/E,MAAM,eAAe,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC9E,MAAM,WAAW,gBAAgB,QAAQ,SAAS,gBAAgB;CAElE,MAAM,cAAc,uBAAuB,gBAAgB;CAC3D,IAAI,cAAc;CAElB,MAAM,qBAAqB,WAAW,oBAAoB,SAAS,GAAG;AACtE,MAAK,MAAM,SAAS,gBAAgB,QAAQ;AAC3C,MAAI,MAAM,UAAU,qBAAqB,CAAC,mBAAoB;AAC9D,MAAI,mBAAmB,MAAM,gBAAgB,QAAQ,QAAQ,KAAK,aAAc;EAChF,MAAM,SAAS,MAA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EpB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,mBACC,GAAG,SAAS,eAAe,UAAU,cAAc,eAAe;;AAGpE,MACC,GAAG,UAAU,iBACb,GAAG,UAAU,gBACb,GAAG,UAAU,gBACb,GAAG,UAAU,kBAEb,iBAAgB;GAEhB;AAEF,QAAO;;AAGR,SAAS,kBAAkB,iBAAyC,OAAe;CAClF,IAAI,kBAAkB;AAEtB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,qBAAkB,gBAAgB,GAAG,SAAS,eAAe,UAAU,IAAI;;GAE3E;AAEF,QAAO;;AAGR,MAAM,iBACL;AAED,SAAS,gBAAgB,MAA6C;AACrE,KAAI,KAAK,KAAK,UAAU,WACvB,QAAO;AAGR,QAAO,KAAK,KAAK,SAAS,aAAa"}
|
|
@@ -60,13 +60,46 @@ function callArgToGrpcInput(arg) {
|
|
|
60
60
|
fundsWithdrawal: {
|
|
61
61
|
amount: withdrawal.reservation.$kind === "MaxAmountU64" ? BigInt(withdrawal.reservation.MaxAmountU64) : void 0,
|
|
62
62
|
coinType: withdrawal.typeArg.$kind === "Balance" ? withdrawal.typeArg.Balance : void 0,
|
|
63
|
-
|
|
63
|
+
...tsWithdrawFromToGrpc(withdrawal.withdrawFrom)
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
default: throw new Error(`Unknown CallArg kind: ${JSON.stringify(arg)}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
function tsWithdrawFromToGrpc(withdrawFrom) {
|
|
71
|
+
switch (withdrawFrom.$kind) {
|
|
72
|
+
case "Sender": return { source: FundsWithdrawal_Source.SENDER };
|
|
73
|
+
case "Sponsor": return { source: FundsWithdrawal_Source.SPONSOR };
|
|
74
|
+
case "SenderAllowance": return {
|
|
75
|
+
source: FundsWithdrawal_Source.SENDER_ALLOWANCE,
|
|
76
|
+
funder: withdrawFrom.SenderAllowance.funder,
|
|
77
|
+
allowance: withdrawFrom.SenderAllowance.allowance
|
|
78
|
+
};
|
|
79
|
+
default: throw new Error(`Unknown WithdrawFrom kind: ${JSON.stringify(withdrawFrom)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function grpcWithdrawFromToTs(withdrawal) {
|
|
83
|
+
switch (withdrawal?.source) {
|
|
84
|
+
case FundsWithdrawal_Source.SPONSOR: return {
|
|
85
|
+
$kind: "Sponsor",
|
|
86
|
+
Sponsor: true
|
|
87
|
+
};
|
|
88
|
+
case FundsWithdrawal_Source.SENDER_ALLOWANCE:
|
|
89
|
+
if (!withdrawal.funder || !withdrawal.allowance) throw new Error(`SENDER_ALLOWANCE withdrawal is missing funder or allowance: ${JSON.stringify(withdrawal)}`);
|
|
90
|
+
return {
|
|
91
|
+
$kind: "SenderAllowance",
|
|
92
|
+
SenderAllowance: {
|
|
93
|
+
funder: withdrawal.funder,
|
|
94
|
+
allowance: withdrawal.allowance
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
default: return {
|
|
98
|
+
$kind: "Sender",
|
|
99
|
+
Sender: true
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
70
103
|
/**
|
|
71
104
|
* Converts a TypeScript Argument to gRPC Argument
|
|
72
105
|
*/
|
|
@@ -272,13 +305,7 @@ function grpcInputToCallArg(input) {
|
|
|
272
305
|
$kind: "Balance",
|
|
273
306
|
Balance: input.fundsWithdrawal?.coinType ?? "0x2::sui::SUI"
|
|
274
307
|
},
|
|
275
|
-
withdrawFrom: input.fundsWithdrawal
|
|
276
|
-
$kind: "Sponsor",
|
|
277
|
-
Sponsor: true
|
|
278
|
-
} : {
|
|
279
|
-
$kind: "Sender",
|
|
280
|
-
Sender: true
|
|
281
|
-
}
|
|
308
|
+
withdrawFrom: grpcWithdrawFromToTs(input.fundsWithdrawal)
|
|
282
309
|
}
|
|
283
310
|
};
|
|
284
311
|
default: throw new Error(`Unknown Input kind: ${JSON.stringify(input)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-resolver.mjs","names":["GrpcTransactionType"],"sources":["../../src/client/transaction-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\n\nimport type { bcs } from '../bcs/index.js';\nimport {\n\tassertAllowedProposersNotEmpty,\n\tassertAllowedProposersStrictlyIncreasing,\n} from '../bcs/bcs.js';\nimport { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport type {\n\tCallArg,\n\tCommand as BcsCommand,\n\tTransactionData,\n} from '../transactions/data/internal.js';\nimport type { Transaction as GrpcTransaction } from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport {\n\tTransaction as GrpcTransactionType,\n\tTransactionExpiration_TransactionExpirationKind,\n} from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport type { ObjectReference } from '../grpc/proto/sui/rpc/v2/object_reference.js';\nimport type { Input } from '../grpc/proto/sui/rpc/v2/input.js';\nimport { FundsWithdrawal_Source, Input_InputKind } from '../grpc/proto/sui/rpc/v2/input.js';\nimport type { Command } from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport type { Argument } from '../grpc/proto/sui/rpc/v2/argument.js';\nimport { Argument_ArgumentKind } from '../grpc/proto/sui/rpc/v2/argument.js';\nimport { Transaction } from '../transactions/Transaction.js';\n\nfunction millisecondsToGrpcTimestamp(value: string | number) {\n\tconst milliseconds = BigInt(value);\n\treturn {\n\t\tseconds: milliseconds / 1000n,\n\t\tnanos: Number(milliseconds % 1000n) * 1_000_000,\n\t};\n}\n\nfunction grpcTimestampToMilliseconds(timestamp: { seconds: bigint; nanos: number }) {\n\treturn (timestamp.seconds * 1000n + BigInt(Math.floor(timestamp.nanos / 1_000_000))).toString();\n}\n\n/**\n * Converts CallArg (TypeScript internal format) to gRPC Input format\n */\nfunction callArgToGrpcInput(arg: CallArg): Input {\n\tswitch (arg.$kind) {\n\t\tcase 'Pure':\n\t\t\t// Pure.bytes is a base64-encoded string that needs to be decoded\n\t\t\treturn {\n\t\t\t\tkind: Input_InputKind.PURE,\n\t\t\t\tpure: fromBase64(arg.Pure.bytes),\n\t\t\t};\n\n\t\tcase 'Object':\n\t\t\tif (arg.Object.$kind === 'ImmOrOwnedObject') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.IMMUTABLE_OR_OWNED,\n\t\t\t\t\tobjectId: arg.Object.ImmOrOwnedObject.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.ImmOrOwnedObject.version),\n\t\t\t\t\tdigest: arg.Object.ImmOrOwnedObject.digest,\n\t\t\t\t};\n\t\t\t} else if (arg.Object.$kind === 'SharedObject') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.SHARED,\n\t\t\t\t\tobjectId: arg.Object.SharedObject.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.SharedObject.initialSharedVersion),\n\t\t\t\t\tmutable: arg.Object.SharedObject.mutable,\n\t\t\t\t};\n\t\t\t} else if (arg.Object.$kind === 'Receiving') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.RECEIVING,\n\t\t\t\t\tobjectId: arg.Object.Receiving.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.Receiving.version),\n\t\t\t\t\tdigest: arg.Object.Receiving.digest,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(`Unknown Object kind: ${JSON.stringify(arg.Object)}`);\n\n\t\tcase 'UnresolvedObject':\n\t\t\tconst unresolved = arg.UnresolvedObject;\n\t\t\treturn {\n\t\t\t\tobjectId: unresolved.objectId,\n\t\t\t\tversion: unresolved.version\n\t\t\t\t\t? BigInt(unresolved.version)\n\t\t\t\t\t: unresolved.initialSharedVersion\n\t\t\t\t\t\t? BigInt(unresolved.initialSharedVersion)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tdigest: unresolved.digest ?? undefined,\n\t\t\t\tmutable: unresolved.mutable ?? undefined,\n\t\t\t};\n\n\t\tcase 'UnresolvedPure':\n\t\t\tthrow new Error('UnresolvedPure arguments must be resolved before converting to gRPC format');\n\n\t\tcase 'FundsWithdrawal': {\n\t\t\tconst withdrawal = arg.FundsWithdrawal;\n\t\t\treturn {\n\t\t\t\tkind: Input_InputKind.FUNDS_WITHDRAWAL,\n\t\t\t\tfundsWithdrawal: {\n\t\t\t\t\tamount:\n\t\t\t\t\t\twithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t\t\t\t\t\t? BigInt(withdrawal.reservation.MaxAmountU64)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcoinType: withdrawal.typeArg.$kind === 'Balance' ? withdrawal.typeArg.Balance : undefined,\n\t\t\t\t\tsource:\n\t\t\t\t\t\twithdrawal.withdrawFrom.$kind === 'Sponsor'\n\t\t\t\t\t\t\t? FundsWithdrawal_Source.SPONSOR\n\t\t\t\t\t\t\t: FundsWithdrawal_Source.SENDER,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown CallArg kind: ${JSON.stringify(arg)}`);\n\t}\n}\n\n/**\n * Converts a TypeScript Argument to gRPC Argument\n */\nfunction tsArgumentToGrpcArgument(arg: typeof bcs.Argument.$inferInput): Argument {\n\tif ('GasCoin' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.GAS };\n\t} else if ('Input' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.INPUT, input: arg.Input };\n\t} else if ('Result' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.RESULT, result: arg.Result };\n\t} else if ('NestedResult' in arg) {\n\t\treturn {\n\t\t\tkind: Argument_ArgumentKind.RESULT,\n\t\t\tresult: arg.NestedResult[0],\n\t\t\tsubresult: arg.NestedResult[1],\n\t\t};\n\t}\n\tthrow new Error(`Unknown Argument: ${JSON.stringify(arg)}`);\n}\n\n/**\n * Converts TypeScript Command to gRPC Command\n */\nfunction tsCommandToGrpcCommand(cmd: BcsCommand): Command {\n\tswitch (cmd.$kind) {\n\t\tcase 'MoveCall':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'moveCall',\n\t\t\t\t\tmoveCall: {\n\t\t\t\t\t\tpackage: cmd.MoveCall.package,\n\t\t\t\t\t\tmodule: cmd.MoveCall.module,\n\t\t\t\t\t\tfunction: cmd.MoveCall.function,\n\t\t\t\t\t\ttypeArguments: cmd.MoveCall.typeArguments,\n\t\t\t\t\t\targuments: cmd.MoveCall.arguments.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'TransferObjects':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'transferObjects',\n\t\t\t\t\ttransferObjects: {\n\t\t\t\t\t\tobjects: cmd.TransferObjects.objects.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t\taddress: tsArgumentToGrpcArgument(cmd.TransferObjects.address),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'SplitCoins':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'splitCoins',\n\t\t\t\t\tsplitCoins: {\n\t\t\t\t\t\tcoin: tsArgumentToGrpcArgument(cmd.SplitCoins.coin),\n\t\t\t\t\t\tamounts: cmd.SplitCoins.amounts.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'MergeCoins':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'mergeCoins',\n\t\t\t\t\tmergeCoins: {\n\t\t\t\t\t\tcoin: tsArgumentToGrpcArgument(cmd.MergeCoins.destination),\n\t\t\t\t\t\tcoinsToMerge: cmd.MergeCoins.sources.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'Publish':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'publish',\n\t\t\t\t\tpublish: {\n\t\t\t\t\t\t// modules are base64-encoded strings in internal format\n\t\t\t\t\t\tmodules: cmd.Publish.modules.map((m) => fromBase64(m)),\n\t\t\t\t\t\tdependencies: cmd.Publish.dependencies,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'MakeMoveVec':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'makeMoveVector',\n\t\t\t\t\tmakeMoveVector: {\n\t\t\t\t\t\telementType: cmd.MakeMoveVec.type ?? undefined,\n\t\t\t\t\t\telements: cmd.MakeMoveVec.elements.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'Upgrade':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'upgrade',\n\t\t\t\t\tupgrade: {\n\t\t\t\t\t\t// modules are base64-encoded strings in internal format\n\t\t\t\t\t\tmodules: cmd.Upgrade.modules.map((m) => fromBase64(m)),\n\t\t\t\t\t\tdependencies: cmd.Upgrade.dependencies,\n\t\t\t\t\t\tpackage: cmd.Upgrade.package,\n\t\t\t\t\t\tticket: tsArgumentToGrpcArgument(cmd.Upgrade.ticket),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Command kind: ${JSON.stringify(cmd)}`);\n\t}\n}\n\nexport function transactionDataToGrpcTransaction(data: TransactionData): GrpcTransaction {\n\tconst grpcInputs = data.inputs.map(callArgToGrpcInput);\n\n\tconst grpcCommands = data.commands.map(tsCommandToGrpcCommand);\n\n\tconst transaction: GrpcTransaction = {\n\t\tversion: 1,\n\t\tkind: {\n\t\t\tdata: {\n\t\t\t\toneofKind: 'programmableTransaction',\n\t\t\t\tprogrammableTransaction: {\n\t\t\t\t\tinputs: grpcInputs,\n\t\t\t\t\tcommands: grpcCommands,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (data.sender) {\n\t\ttransaction.sender = data.sender;\n\t}\n\n\tconst gasOwner = data.gasData.owner ?? data.sender;\n\n\ttransaction.gasPayment = {\n\t\tobjects: data.gasData.payment\n\t\t\t? data.gasData.payment.map((ref) => ({\n\t\t\t\t\tobjectId: ref.objectId,\n\t\t\t\t\tversion: BigInt(ref.version),\n\t\t\t\t\tdigest: ref.digest,\n\t\t\t\t}))\n\t\t\t: [],\n\t\tprice: data.gasData.price ? BigInt(data.gasData.price) : undefined,\n\t\tbudget: data.gasData.budget ? BigInt(data.gasData.budget) : undefined,\n\t};\n\n\tif (gasOwner) {\n\t\ttransaction.gasPayment.owner = gasOwner;\n\t}\n\n\tif (data.expiration) {\n\t\tif ('None' in data.expiration) {\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind: TransactionExpiration_TransactionExpirationKind.NONE,\n\t\t\t};\n\t\t} else if (data.expiration.$kind === 'Epoch') {\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind: TransactionExpiration_TransactionExpirationKind.EPOCH,\n\t\t\t\tepoch: BigInt(data.expiration.Epoch),\n\t\t\t};\n\t\t} else if (data.expiration.$kind === 'ValidDuring' || data.expiration.$kind === 'Validity') {\n\t\t\tconst validity =\n\t\t\t\tdata.expiration.$kind === 'ValidDuring'\n\t\t\t\t\t? data.expiration.ValidDuring\n\t\t\t\t\t: data.expiration.Validity;\n\t\t\tconst allowedProposers =\n\t\t\t\tdata.expiration.$kind === 'Validity' ? data.expiration.Validity.allowedProposers : null;\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind:\n\t\t\t\t\tdata.expiration.$kind === 'ValidDuring'\n\t\t\t\t\t\t? TransactionExpiration_TransactionExpirationKind.VALID_DURING\n\t\t\t\t\t\t: TransactionExpiration_TransactionExpirationKind.VALIDITY,\n\t\t\t\tminEpoch: validity.minEpoch != null ? BigInt(validity.minEpoch) : undefined,\n\t\t\t\tepoch: validity.maxEpoch != null ? BigInt(validity.maxEpoch) : undefined,\n\t\t\t\tminTimestamp:\n\t\t\t\t\tvalidity.minTimestamp != null\n\t\t\t\t\t\t? millisecondsToGrpcTimestamp(validity.minTimestamp)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tmaxTimestamp:\n\t\t\t\t\tvalidity.maxTimestamp != null\n\t\t\t\t\t\t? millisecondsToGrpcTimestamp(validity.maxTimestamp)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tchain: validity.chain,\n\t\t\t\tnonce: validity.nonce,\n\t\t\t\tallowedProposers: allowedProposers\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tepoch: BigInt(allowedProposers.epoch),\n\t\t\t\t\t\t\tproposers: assertAllowedProposersStrictlyIncreasing(allowedProposers.proposers),\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn transaction;\n}\n\nexport function applyGrpcResolvedTransaction(\n\ttransactionData: TransactionDataBuilder,\n\tresolvedTransaction: GrpcTransaction,\n\toptions?: { onlyTransactionKind?: boolean },\n): void {\n\tconst resolved = grpcTransactionToTransactionData(resolvedTransaction);\n\n\tif (options?.onlyTransactionKind) {\n\t\ttransactionData.applyResolvedData({\n\t\t\t...resolved,\n\t\t\tsender: null,\n\t\t\tgasData: {\n\t\t\t\tbudget: null,\n\t\t\t\towner: null,\n\t\t\t\tpayment: null,\n\t\t\t\tprice: null,\n\t\t\t},\n\t\t\texpiration: null,\n\t\t});\n\t} else {\n\t\ttransactionData.applyResolvedData(resolved);\n\t}\n}\n\n/**\n * Converts an array of ObjectReferences from gRPC format to TypeScript SuiObjectRef format\n */\nexport function grpcObjectReferencesToBcs(refs: ObjectReference[]): {\n\tobjectId: string;\n\tversion: string;\n\tdigest: string;\n}[] {\n\treturn refs.map((ref) => ({\n\t\tobjectId: ref.objectId!,\n\t\tversion: ref.version?.toString()!,\n\t\tdigest: ref.digest!,\n\t}));\n}\n\nexport function transactionToGrpcTransaction(transaction: Transaction) {\n\tconst snapshot = transaction.getData();\n\n\tif (!snapshot.sender) {\n\t\tsnapshot.sender = '0x0000000000000000000000000000000000000000000000000000000000000000';\n\t}\n\n\treturn transactionDataToGrpcTransaction(snapshot);\n}\n\nexport function transactionToGrpcJson(transaction: Transaction): unknown {\n\tconst grpcTransaction = transactionToGrpcTransaction(transaction);\n\treturn GrpcTransactionType.toJson(grpcTransaction);\n}\n\nfunction grpcInputToCallArg(input: Input): CallArg {\n\tswitch (input.kind) {\n\t\tcase Input_InputKind.PURE:\n\t\t\treturn {\n\t\t\t\t$kind: 'Pure',\n\t\t\t\tPure: { bytes: toBase64(input.pure!) },\n\t\t\t};\n\n\t\tcase Input_InputKind.IMMUTABLE_OR_OWNED:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'ImmOrOwnedObject',\n\t\t\t\t\tImmOrOwnedObject: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tversion: input.version!.toString(),\n\t\t\t\t\t\tdigest: input.digest!,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.SHARED:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'SharedObject',\n\t\t\t\t\tSharedObject: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tinitialSharedVersion: input.version!.toString(),\n\t\t\t\t\t\tmutable: input.mutable ?? false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.RECEIVING:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'Receiving',\n\t\t\t\t\tReceiving: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tversion: input.version!.toString(),\n\t\t\t\t\t\tdigest: input.digest!,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.FUNDS_WITHDRAWAL:\n\t\t\treturn {\n\t\t\t\t$kind: 'FundsWithdrawal',\n\t\t\t\tFundsWithdrawal: {\n\t\t\t\t\treservation: {\n\t\t\t\t\t\t$kind: 'MaxAmountU64' as const,\n\t\t\t\t\t\tMaxAmountU64: input.fundsWithdrawal?.amount?.toString() ?? '0',\n\t\t\t\t\t},\n\t\t\t\t\ttypeArg: {\n\t\t\t\t\t\t$kind: 'Balance' as const,\n\t\t\t\t\t\tBalance: input.fundsWithdrawal?.coinType ?? '0x2::sui::SUI',\n\t\t\t\t\t},\n\t\t\t\t\twithdrawFrom:\n\t\t\t\t\t\tinput.fundsWithdrawal?.source === FundsWithdrawal_Source.SPONSOR\n\t\t\t\t\t\t\t? { $kind: 'Sponsor' as const, Sponsor: true as const }\n\t\t\t\t\t\t\t: { $kind: 'Sender' as const, Sender: true as const },\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Input kind: ${JSON.stringify(input)}`);\n\t}\n}\n\nfunction grpcArgumentToTsArgument(\n\targ: Argument,\n):\n\t| { $kind: 'GasCoin'; GasCoin: true }\n\t| { $kind: 'Input'; Input: number }\n\t| { $kind: 'Result'; Result: number }\n\t| { $kind: 'NestedResult'; NestedResult: [number, number] } {\n\tswitch (arg.kind) {\n\t\tcase Argument_ArgumentKind.GAS:\n\t\t\treturn { $kind: 'GasCoin', GasCoin: true };\n\t\tcase Argument_ArgumentKind.INPUT:\n\t\t\treturn { $kind: 'Input', Input: arg.input! };\n\t\tcase Argument_ArgumentKind.RESULT:\n\t\t\tif (arg.subresult != null) {\n\t\t\t\treturn { $kind: 'NestedResult', NestedResult: [arg.result!, arg.subresult] };\n\t\t\t}\n\t\t\treturn { $kind: 'Result', Result: arg.result! };\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Argument kind: ${JSON.stringify(arg)}`);\n\t}\n}\n\nfunction grpcCommandToTsCommand(cmd: Command): BcsCommand {\n\tconst command = cmd.command;\n\tif (!command) {\n\t\tthrow new Error('Command is missing');\n\t}\n\n\tswitch (command.oneofKind) {\n\t\tcase 'moveCall':\n\t\t\treturn {\n\t\t\t\t$kind: 'MoveCall',\n\t\t\t\tMoveCall: {\n\t\t\t\t\tpackage: command.moveCall.package!,\n\t\t\t\t\tmodule: command.moveCall.module!,\n\t\t\t\t\tfunction: command.moveCall.function!,\n\t\t\t\t\ttypeArguments: command.moveCall.typeArguments ?? [],\n\t\t\t\t\targuments: command.moveCall.arguments.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'transferObjects':\n\t\t\treturn {\n\t\t\t\t$kind: 'TransferObjects',\n\t\t\t\tTransferObjects: {\n\t\t\t\t\tobjects: command.transferObjects.objects.map(grpcArgumentToTsArgument),\n\t\t\t\t\taddress: grpcArgumentToTsArgument(command.transferObjects.address!),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'splitCoins':\n\t\t\treturn {\n\t\t\t\t$kind: 'SplitCoins',\n\t\t\t\tSplitCoins: {\n\t\t\t\t\tcoin: grpcArgumentToTsArgument(command.splitCoins.coin!),\n\t\t\t\t\tamounts: command.splitCoins.amounts.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'mergeCoins':\n\t\t\treturn {\n\t\t\t\t$kind: 'MergeCoins',\n\t\t\t\tMergeCoins: {\n\t\t\t\t\tdestination: grpcArgumentToTsArgument(command.mergeCoins.coin!),\n\t\t\t\t\tsources: command.mergeCoins.coinsToMerge.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'publish':\n\t\t\treturn {\n\t\t\t\t$kind: 'Publish',\n\t\t\t\tPublish: {\n\t\t\t\t\tmodules: command.publish.modules.map((m) => toBase64(m)),\n\t\t\t\t\tdependencies: command.publish.dependencies ?? [],\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'makeMoveVector':\n\t\t\treturn {\n\t\t\t\t$kind: 'MakeMoveVec',\n\t\t\t\tMakeMoveVec: {\n\t\t\t\t\ttype: command.makeMoveVector.elementType ?? null,\n\t\t\t\t\telements: command.makeMoveVector.elements.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'upgrade':\n\t\t\treturn {\n\t\t\t\t$kind: 'Upgrade',\n\t\t\t\tUpgrade: {\n\t\t\t\t\tmodules: command.upgrade.modules.map((m) => toBase64(m)),\n\t\t\t\t\tdependencies: command.upgrade.dependencies ?? [],\n\t\t\t\t\tpackage: command.upgrade.package!,\n\t\t\t\t\tticket: grpcArgumentToTsArgument(command.upgrade.ticket!),\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Command kind: ${JSON.stringify(command)}`);\n\t}\n}\n\nexport function grpcTransactionToTransactionData(grpcTx: GrpcTransaction): TransactionData {\n\tconst programmableTx = grpcTx.kind?.data;\n\tif (programmableTx?.oneofKind !== 'programmableTransaction') {\n\t\tthrow new Error('Only programmable transactions are supported');\n\t}\n\n\tconst inputs = programmableTx.programmableTransaction.inputs.map(grpcInputToCallArg);\n\tconst commands = programmableTx.programmableTransaction.commands.map(grpcCommandToTsCommand);\n\n\tlet expiration: TransactionData['expiration'] = null;\n\tif (grpcTx.expiration) {\n\t\tswitch (grpcTx.expiration.kind) {\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.NONE:\n\t\t\t\texpiration = { $kind: 'None', None: true };\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.EPOCH:\n\t\t\t\texpiration = { $kind: 'Epoch', Epoch: grpcTx.expiration.epoch!.toString() };\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.VALID_DURING:\n\t\t\t\texpiration = {\n\t\t\t\t\t$kind: 'ValidDuring',\n\t\t\t\t\tValidDuring: {\n\t\t\t\t\t\tminEpoch: grpcTx.expiration.minEpoch?.toString() ?? null,\n\t\t\t\t\t\tmaxEpoch: grpcTx.expiration.epoch?.toString() ?? null,\n\t\t\t\t\t\tminTimestamp: grpcTx.expiration.minTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.minTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tmaxTimestamp: grpcTx.expiration.maxTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.maxTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tchain: grpcTx.expiration.chain ?? '',\n\t\t\t\t\t\tnonce: grpcTx.expiration.nonce ?? 0,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.VALIDITY:\n\t\t\t\texpiration = {\n\t\t\t\t\t$kind: 'Validity',\n\t\t\t\t\tValidity: {\n\t\t\t\t\t\tminEpoch: grpcTx.expiration.minEpoch?.toString() ?? null,\n\t\t\t\t\t\tmaxEpoch: grpcTx.expiration.epoch?.toString() ?? null,\n\t\t\t\t\t\tminTimestamp: grpcTx.expiration.minTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.minTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tmaxTimestamp: grpcTx.expiration.maxTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.maxTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tchain: grpcTx.expiration.chain ?? '',\n\t\t\t\t\t\tnonce: grpcTx.expiration.nonce ?? 0,\n\t\t\t\t\t\tallowedProposers: grpcTx.expiration.allowedProposers\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tepoch: grpcTx.expiration.allowedProposers.epoch?.toString() ?? '0',\n\t\t\t\t\t\t\t\t\tproposers: assertAllowedProposersNotEmpty(\n\t\t\t\t\t\t\t\t\t\tgrpcTx.expiration.allowedProposers.proposers,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Leaving `expiration` null here would drop a restriction the server did send.\n\t\t\t\tthrow new Error(`Unknown transaction expiration kind: ${grpcTx.expiration.kind}`);\n\t\t}\n\t}\n\n\treturn {\n\t\tversion: 2 as const,\n\t\tsender: grpcTx.sender ?? null,\n\t\texpiration,\n\t\tgasData: {\n\t\t\tbudget: grpcTx.gasPayment?.budget?.toString() ?? null,\n\t\t\towner: grpcTx.gasPayment?.owner ?? null,\n\t\t\tpayment:\n\t\t\t\tgrpcTx.gasPayment?.objects?.map((obj) => ({\n\t\t\t\t\tobjectId: obj.objectId!,\n\t\t\t\t\tversion: obj.version!.toString(),\n\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t})) ?? null,\n\t\t\tprice: grpcTx.gasPayment?.price?.toString() ?? null,\n\t\t},\n\t\tinputs,\n\t\tcommands,\n\t};\n}\n"],"mappings":";;;;;;;AA6BA,SAAS,4BAA4B,OAAwB;CAC5D,MAAM,eAAe,OAAO,MAAM;AAClC,QAAO;EACN,SAAS,eAAe;EACxB,OAAO,OAAO,eAAe,MAAM,GAAG;EACtC;;AAGF,SAAS,4BAA4B,WAA+C;AACnF,SAAQ,UAAU,UAAU,QAAQ,OAAO,KAAK,MAAM,UAAU,QAAQ,IAAU,CAAC,EAAE,UAAU;;;;;AAMhG,SAAS,mBAAmB,KAAqB;AAChD,SAAQ,IAAI,OAAZ;EACC,KAAK,OAEJ,QAAO;GACN,MAAM,gBAAgB;GACtB,MAAM,WAAW,IAAI,KAAK,MAAM;G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AU,UAAU,IAAI;KACpD,UAAU,OAAO,WAAW,OAAO,UAAU,IAAI;KACjD,cAAc,OAAO,WAAW,eAC7B,4BAA4B,OAAO,WAAW,aAAa,GAC3D;KACH,cAAc,OAAO,WAAW,eAC7B,4BAA4B,OAAO,WAAW,aAAa,GAC3D;KACH,OAAO,OAAO,WAAW,SAAS;KAClC,OAAO,OAAO,WAAW,SAAS;KAClC,kBAAkB,OAAO,WAAW,mBACjC;MACA,OAAO,OAAO,WAAW,iBAAiB,OAAO,UAAU,IAAI;MAC/D,WAAW,+BACV,OAAO,WAAW,iBAAiB,UACnC;MACD,GACA;KACH;IACD;AACD;EACD,QAEC,OAAM,IAAI,MAAM,wCAAwC,OAAO,WAAW,OAAO;;AAIpF,QAAO;EACN,SAAS;EACT,QAAQ,OAAO,UAAU;EACzB;EACA,SAAS;GACR,QAAQ,OAAO,YAAY,QAAQ,UAAU,IAAI;GACjD,OAAO,OAAO,YAAY,SAAS;GACnC,SACC,OAAO,YAAY,SAAS,KAAK,SAAS;IACzC,UAAU,IAAI;IACd,SAAS,IAAI,QAAS,UAAU;IAChC,QAAQ,IAAI;IACZ,EAAE,IAAI;GACR,OAAO,OAAO,YAAY,OAAO,UAAU,IAAI;GAC/C;EACD;EACA;EACA"}
|
|
1
|
+
{"version":3,"file":"transaction-resolver.mjs","names":["GrpcTransactionType"],"sources":["../../src/client/transaction-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@mysten/bcs';\n\nimport type { bcs } from '../bcs/index.js';\nimport {\n\tassertAllowedProposersNotEmpty,\n\tassertAllowedProposersStrictlyIncreasing,\n} from '../bcs/bcs.js';\nimport { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport type {\n\tCallArg,\n\tCommand as BcsCommand,\n\tTransactionData,\n} from '../transactions/data/internal.js';\nimport type { Transaction as GrpcTransaction } from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport {\n\tTransaction as GrpcTransactionType,\n\tTransactionExpiration_TransactionExpirationKind,\n} from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport type { ObjectReference } from '../grpc/proto/sui/rpc/v2/object_reference.js';\nimport type { FundsWithdrawal, Input } from '../grpc/proto/sui/rpc/v2/input.js';\nimport { FundsWithdrawal_Source, Input_InputKind } from '../grpc/proto/sui/rpc/v2/input.js';\nimport type { Command } from '../grpc/proto/sui/rpc/v2/transaction.js';\nimport type { Argument } from '../grpc/proto/sui/rpc/v2/argument.js';\nimport { Argument_ArgumentKind } from '../grpc/proto/sui/rpc/v2/argument.js';\nimport { Transaction } from '../transactions/Transaction.js';\n\nfunction millisecondsToGrpcTimestamp(value: string | number) {\n\tconst milliseconds = BigInt(value);\n\treturn {\n\t\tseconds: milliseconds / 1000n,\n\t\tnanos: Number(milliseconds % 1000n) * 1_000_000,\n\t};\n}\n\nfunction grpcTimestampToMilliseconds(timestamp: { seconds: bigint; nanos: number }) {\n\treturn (timestamp.seconds * 1000n + BigInt(Math.floor(timestamp.nanos / 1_000_000))).toString();\n}\n\n/**\n * Converts CallArg (TypeScript internal format) to gRPC Input format\n */\nfunction callArgToGrpcInput(arg: CallArg): Input {\n\tswitch (arg.$kind) {\n\t\tcase 'Pure':\n\t\t\t// Pure.bytes is a base64-encoded string that needs to be decoded\n\t\t\treturn {\n\t\t\t\tkind: Input_InputKind.PURE,\n\t\t\t\tpure: fromBase64(arg.Pure.bytes),\n\t\t\t};\n\n\t\tcase 'Object':\n\t\t\tif (arg.Object.$kind === 'ImmOrOwnedObject') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.IMMUTABLE_OR_OWNED,\n\t\t\t\t\tobjectId: arg.Object.ImmOrOwnedObject.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.ImmOrOwnedObject.version),\n\t\t\t\t\tdigest: arg.Object.ImmOrOwnedObject.digest,\n\t\t\t\t};\n\t\t\t} else if (arg.Object.$kind === 'SharedObject') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.SHARED,\n\t\t\t\t\tobjectId: arg.Object.SharedObject.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.SharedObject.initialSharedVersion),\n\t\t\t\t\tmutable: arg.Object.SharedObject.mutable,\n\t\t\t\t};\n\t\t\t} else if (arg.Object.$kind === 'Receiving') {\n\t\t\t\treturn {\n\t\t\t\t\tkind: Input_InputKind.RECEIVING,\n\t\t\t\t\tobjectId: arg.Object.Receiving.objectId,\n\t\t\t\t\tversion: BigInt(arg.Object.Receiving.version),\n\t\t\t\t\tdigest: arg.Object.Receiving.digest,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(`Unknown Object kind: ${JSON.stringify(arg.Object)}`);\n\n\t\tcase 'UnresolvedObject':\n\t\t\tconst unresolved = arg.UnresolvedObject;\n\t\t\treturn {\n\t\t\t\tobjectId: unresolved.objectId,\n\t\t\t\tversion: unresolved.version\n\t\t\t\t\t? BigInt(unresolved.version)\n\t\t\t\t\t: unresolved.initialSharedVersion\n\t\t\t\t\t\t? BigInt(unresolved.initialSharedVersion)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tdigest: unresolved.digest ?? undefined,\n\t\t\t\tmutable: unresolved.mutable ?? undefined,\n\t\t\t};\n\n\t\tcase 'UnresolvedPure':\n\t\t\tthrow new Error('UnresolvedPure arguments must be resolved before converting to gRPC format');\n\n\t\tcase 'FundsWithdrawal': {\n\t\t\tconst withdrawal = arg.FundsWithdrawal;\n\t\t\treturn {\n\t\t\t\tkind: Input_InputKind.FUNDS_WITHDRAWAL,\n\t\t\t\tfundsWithdrawal: {\n\t\t\t\t\tamount:\n\t\t\t\t\t\twithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t\t\t\t\t\t? BigInt(withdrawal.reservation.MaxAmountU64)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcoinType: withdrawal.typeArg.$kind === 'Balance' ? withdrawal.typeArg.Balance : undefined,\n\t\t\t\t\t...tsWithdrawFromToGrpc(withdrawal.withdrawFrom),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown CallArg kind: ${JSON.stringify(arg)}`);\n\t}\n}\n\nfunction tsWithdrawFromToGrpc(\n\twithdrawFrom: Extract<CallArg, { FundsWithdrawal: unknown }>['FundsWithdrawal']['withdrawFrom'],\n): Pick<FundsWithdrawal, 'source' | 'funder' | 'allowance'> {\n\tswitch (withdrawFrom.$kind) {\n\t\tcase 'Sender':\n\t\t\treturn { source: FundsWithdrawal_Source.SENDER };\n\t\tcase 'Sponsor':\n\t\t\treturn { source: FundsWithdrawal_Source.SPONSOR };\n\t\tcase 'SenderAllowance':\n\t\t\treturn {\n\t\t\t\tsource: FundsWithdrawal_Source.SENDER_ALLOWANCE,\n\t\t\t\tfunder: withdrawFrom.SenderAllowance.funder,\n\t\t\t\tallowance: withdrawFrom.SenderAllowance.allowance,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown WithdrawFrom kind: ${JSON.stringify(withdrawFrom)}`);\n\t}\n}\n\nfunction grpcWithdrawFromToTs(\n\twithdrawal: FundsWithdrawal | undefined,\n): Extract<CallArg, { FundsWithdrawal: unknown }>['FundsWithdrawal']['withdrawFrom'] {\n\tswitch (withdrawal?.source) {\n\t\tcase FundsWithdrawal_Source.SPONSOR:\n\t\t\treturn { $kind: 'Sponsor', Sponsor: true };\n\t\tcase FundsWithdrawal_Source.SENDER_ALLOWANCE:\n\t\t\tif (!withdrawal.funder || !withdrawal.allowance) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`SENDER_ALLOWANCE withdrawal is missing funder or allowance: ${JSON.stringify(withdrawal)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t$kind: 'SenderAllowance',\n\t\t\t\tSenderAllowance: { funder: withdrawal.funder, allowance: withdrawal.allowance },\n\t\t\t};\n\t\tdefault:\n\t\t\treturn { $kind: 'Sender', Sender: true };\n\t}\n}\n\n/**\n * Converts a TypeScript Argument to gRPC Argument\n */\nfunction tsArgumentToGrpcArgument(arg: typeof bcs.Argument.$inferInput): Argument {\n\tif ('GasCoin' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.GAS };\n\t} else if ('Input' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.INPUT, input: arg.Input };\n\t} else if ('Result' in arg) {\n\t\treturn { kind: Argument_ArgumentKind.RESULT, result: arg.Result };\n\t} else if ('NestedResult' in arg) {\n\t\treturn {\n\t\t\tkind: Argument_ArgumentKind.RESULT,\n\t\t\tresult: arg.NestedResult[0],\n\t\t\tsubresult: arg.NestedResult[1],\n\t\t};\n\t}\n\tthrow new Error(`Unknown Argument: ${JSON.stringify(arg)}`);\n}\n\n/**\n * Converts TypeScript Command to gRPC Command\n */\nfunction tsCommandToGrpcCommand(cmd: BcsCommand): Command {\n\tswitch (cmd.$kind) {\n\t\tcase 'MoveCall':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'moveCall',\n\t\t\t\t\tmoveCall: {\n\t\t\t\t\t\tpackage: cmd.MoveCall.package,\n\t\t\t\t\t\tmodule: cmd.MoveCall.module,\n\t\t\t\t\t\tfunction: cmd.MoveCall.function,\n\t\t\t\t\t\ttypeArguments: cmd.MoveCall.typeArguments,\n\t\t\t\t\t\targuments: cmd.MoveCall.arguments.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'TransferObjects':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'transferObjects',\n\t\t\t\t\ttransferObjects: {\n\t\t\t\t\t\tobjects: cmd.TransferObjects.objects.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t\taddress: tsArgumentToGrpcArgument(cmd.TransferObjects.address),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'SplitCoins':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'splitCoins',\n\t\t\t\t\tsplitCoins: {\n\t\t\t\t\t\tcoin: tsArgumentToGrpcArgument(cmd.SplitCoins.coin),\n\t\t\t\t\t\tamounts: cmd.SplitCoins.amounts.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'MergeCoins':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'mergeCoins',\n\t\t\t\t\tmergeCoins: {\n\t\t\t\t\t\tcoin: tsArgumentToGrpcArgument(cmd.MergeCoins.destination),\n\t\t\t\t\t\tcoinsToMerge: cmd.MergeCoins.sources.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'Publish':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'publish',\n\t\t\t\t\tpublish: {\n\t\t\t\t\t\t// modules are base64-encoded strings in internal format\n\t\t\t\t\t\tmodules: cmd.Publish.modules.map((m) => fromBase64(m)),\n\t\t\t\t\t\tdependencies: cmd.Publish.dependencies,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'MakeMoveVec':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'makeMoveVector',\n\t\t\t\t\tmakeMoveVector: {\n\t\t\t\t\t\telementType: cmd.MakeMoveVec.type ?? undefined,\n\t\t\t\t\t\telements: cmd.MakeMoveVec.elements.map(tsArgumentToGrpcArgument),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'Upgrade':\n\t\t\treturn {\n\t\t\t\tcommand: {\n\t\t\t\t\toneofKind: 'upgrade',\n\t\t\t\t\tupgrade: {\n\t\t\t\t\t\t// modules are base64-encoded strings in internal format\n\t\t\t\t\t\tmodules: cmd.Upgrade.modules.map((m) => fromBase64(m)),\n\t\t\t\t\t\tdependencies: cmd.Upgrade.dependencies,\n\t\t\t\t\t\tpackage: cmd.Upgrade.package,\n\t\t\t\t\t\tticket: tsArgumentToGrpcArgument(cmd.Upgrade.ticket),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Command kind: ${JSON.stringify(cmd)}`);\n\t}\n}\n\nexport function transactionDataToGrpcTransaction(data: TransactionData): GrpcTransaction {\n\tconst grpcInputs = data.inputs.map(callArgToGrpcInput);\n\n\tconst grpcCommands = data.commands.map(tsCommandToGrpcCommand);\n\n\tconst transaction: GrpcTransaction = {\n\t\tversion: 1,\n\t\tkind: {\n\t\t\tdata: {\n\t\t\t\toneofKind: 'programmableTransaction',\n\t\t\t\tprogrammableTransaction: {\n\t\t\t\t\tinputs: grpcInputs,\n\t\t\t\t\tcommands: grpcCommands,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (data.sender) {\n\t\ttransaction.sender = data.sender;\n\t}\n\n\tconst gasOwner = data.gasData.owner ?? data.sender;\n\n\ttransaction.gasPayment = {\n\t\tobjects: data.gasData.payment\n\t\t\t? data.gasData.payment.map((ref) => ({\n\t\t\t\t\tobjectId: ref.objectId,\n\t\t\t\t\tversion: BigInt(ref.version),\n\t\t\t\t\tdigest: ref.digest,\n\t\t\t\t}))\n\t\t\t: [],\n\t\tprice: data.gasData.price ? BigInt(data.gasData.price) : undefined,\n\t\tbudget: data.gasData.budget ? BigInt(data.gasData.budget) : undefined,\n\t};\n\n\tif (gasOwner) {\n\t\ttransaction.gasPayment.owner = gasOwner;\n\t}\n\n\tif (data.expiration) {\n\t\tif ('None' in data.expiration) {\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind: TransactionExpiration_TransactionExpirationKind.NONE,\n\t\t\t};\n\t\t} else if (data.expiration.$kind === 'Epoch') {\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind: TransactionExpiration_TransactionExpirationKind.EPOCH,\n\t\t\t\tepoch: BigInt(data.expiration.Epoch),\n\t\t\t};\n\t\t} else if (data.expiration.$kind === 'ValidDuring' || data.expiration.$kind === 'Validity') {\n\t\t\tconst validity =\n\t\t\t\tdata.expiration.$kind === 'ValidDuring'\n\t\t\t\t\t? data.expiration.ValidDuring\n\t\t\t\t\t: data.expiration.Validity;\n\t\t\tconst allowedProposers =\n\t\t\t\tdata.expiration.$kind === 'Validity' ? data.expiration.Validity.allowedProposers : null;\n\t\t\ttransaction.expiration = {\n\t\t\t\tkind:\n\t\t\t\t\tdata.expiration.$kind === 'ValidDuring'\n\t\t\t\t\t\t? TransactionExpiration_TransactionExpirationKind.VALID_DURING\n\t\t\t\t\t\t: TransactionExpiration_TransactionExpirationKind.VALIDITY,\n\t\t\t\tminEpoch: validity.minEpoch != null ? BigInt(validity.minEpoch) : undefined,\n\t\t\t\tepoch: validity.maxEpoch != null ? BigInt(validity.maxEpoch) : undefined,\n\t\t\t\tminTimestamp:\n\t\t\t\t\tvalidity.minTimestamp != null\n\t\t\t\t\t\t? millisecondsToGrpcTimestamp(validity.minTimestamp)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tmaxTimestamp:\n\t\t\t\t\tvalidity.maxTimestamp != null\n\t\t\t\t\t\t? millisecondsToGrpcTimestamp(validity.maxTimestamp)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tchain: validity.chain,\n\t\t\t\tnonce: validity.nonce,\n\t\t\t\tallowedProposers: allowedProposers\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tepoch: BigInt(allowedProposers.epoch),\n\t\t\t\t\t\t\tproposers: assertAllowedProposersStrictlyIncreasing(allowedProposers.proposers),\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn transaction;\n}\n\nexport function applyGrpcResolvedTransaction(\n\ttransactionData: TransactionDataBuilder,\n\tresolvedTransaction: GrpcTransaction,\n\toptions?: { onlyTransactionKind?: boolean },\n): void {\n\tconst resolved = grpcTransactionToTransactionData(resolvedTransaction);\n\n\tif (options?.onlyTransactionKind) {\n\t\ttransactionData.applyResolvedData({\n\t\t\t...resolved,\n\t\t\tsender: null,\n\t\t\tgasData: {\n\t\t\t\tbudget: null,\n\t\t\t\towner: null,\n\t\t\t\tpayment: null,\n\t\t\t\tprice: null,\n\t\t\t},\n\t\t\texpiration: null,\n\t\t});\n\t} else {\n\t\ttransactionData.applyResolvedData(resolved);\n\t}\n}\n\n/**\n * Converts an array of ObjectReferences from gRPC format to TypeScript SuiObjectRef format\n */\nexport function grpcObjectReferencesToBcs(refs: ObjectReference[]): {\n\tobjectId: string;\n\tversion: string;\n\tdigest: string;\n}[] {\n\treturn refs.map((ref) => ({\n\t\tobjectId: ref.objectId!,\n\t\tversion: ref.version?.toString()!,\n\t\tdigest: ref.digest!,\n\t}));\n}\n\nexport function transactionToGrpcTransaction(transaction: Transaction) {\n\tconst snapshot = transaction.getData();\n\n\tif (!snapshot.sender) {\n\t\tsnapshot.sender = '0x0000000000000000000000000000000000000000000000000000000000000000';\n\t}\n\n\treturn transactionDataToGrpcTransaction(snapshot);\n}\n\nexport function transactionToGrpcJson(transaction: Transaction): unknown {\n\tconst grpcTransaction = transactionToGrpcTransaction(transaction);\n\treturn GrpcTransactionType.toJson(grpcTransaction);\n}\n\nfunction grpcInputToCallArg(input: Input): CallArg {\n\tswitch (input.kind) {\n\t\tcase Input_InputKind.PURE:\n\t\t\treturn {\n\t\t\t\t$kind: 'Pure',\n\t\t\t\tPure: { bytes: toBase64(input.pure!) },\n\t\t\t};\n\n\t\tcase Input_InputKind.IMMUTABLE_OR_OWNED:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'ImmOrOwnedObject',\n\t\t\t\t\tImmOrOwnedObject: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tversion: input.version!.toString(),\n\t\t\t\t\t\tdigest: input.digest!,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.SHARED:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'SharedObject',\n\t\t\t\t\tSharedObject: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tinitialSharedVersion: input.version!.toString(),\n\t\t\t\t\t\tmutable: input.mutable ?? false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.RECEIVING:\n\t\t\treturn {\n\t\t\t\t$kind: 'Object',\n\t\t\t\tObject: {\n\t\t\t\t\t$kind: 'Receiving',\n\t\t\t\t\tReceiving: {\n\t\t\t\t\t\tobjectId: input.objectId!,\n\t\t\t\t\t\tversion: input.version!.toString(),\n\t\t\t\t\t\tdigest: input.digest!,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase Input_InputKind.FUNDS_WITHDRAWAL:\n\t\t\treturn {\n\t\t\t\t$kind: 'FundsWithdrawal',\n\t\t\t\tFundsWithdrawal: {\n\t\t\t\t\treservation: {\n\t\t\t\t\t\t$kind: 'MaxAmountU64' as const,\n\t\t\t\t\t\tMaxAmountU64: input.fundsWithdrawal?.amount?.toString() ?? '0',\n\t\t\t\t\t},\n\t\t\t\t\ttypeArg: {\n\t\t\t\t\t\t$kind: 'Balance' as const,\n\t\t\t\t\t\tBalance: input.fundsWithdrawal?.coinType ?? '0x2::sui::SUI',\n\t\t\t\t\t},\n\t\t\t\t\twithdrawFrom: grpcWithdrawFromToTs(input.fundsWithdrawal),\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Input kind: ${JSON.stringify(input)}`);\n\t}\n}\n\nfunction grpcArgumentToTsArgument(\n\targ: Argument,\n):\n\t| { $kind: 'GasCoin'; GasCoin: true }\n\t| { $kind: 'Input'; Input: number }\n\t| { $kind: 'Result'; Result: number }\n\t| { $kind: 'NestedResult'; NestedResult: [number, number] } {\n\tswitch (arg.kind) {\n\t\tcase Argument_ArgumentKind.GAS:\n\t\t\treturn { $kind: 'GasCoin', GasCoin: true };\n\t\tcase Argument_ArgumentKind.INPUT:\n\t\t\treturn { $kind: 'Input', Input: arg.input! };\n\t\tcase Argument_ArgumentKind.RESULT:\n\t\t\tif (arg.subresult != null) {\n\t\t\t\treturn { $kind: 'NestedResult', NestedResult: [arg.result!, arg.subresult] };\n\t\t\t}\n\t\t\treturn { $kind: 'Result', Result: arg.result! };\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Argument kind: ${JSON.stringify(arg)}`);\n\t}\n}\n\nfunction grpcCommandToTsCommand(cmd: Command): BcsCommand {\n\tconst command = cmd.command;\n\tif (!command) {\n\t\tthrow new Error('Command is missing');\n\t}\n\n\tswitch (command.oneofKind) {\n\t\tcase 'moveCall':\n\t\t\treturn {\n\t\t\t\t$kind: 'MoveCall',\n\t\t\t\tMoveCall: {\n\t\t\t\t\tpackage: command.moveCall.package!,\n\t\t\t\t\tmodule: command.moveCall.module!,\n\t\t\t\t\tfunction: command.moveCall.function!,\n\t\t\t\t\ttypeArguments: command.moveCall.typeArguments ?? [],\n\t\t\t\t\targuments: command.moveCall.arguments.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'transferObjects':\n\t\t\treturn {\n\t\t\t\t$kind: 'TransferObjects',\n\t\t\t\tTransferObjects: {\n\t\t\t\t\tobjects: command.transferObjects.objects.map(grpcArgumentToTsArgument),\n\t\t\t\t\taddress: grpcArgumentToTsArgument(command.transferObjects.address!),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'splitCoins':\n\t\t\treturn {\n\t\t\t\t$kind: 'SplitCoins',\n\t\t\t\tSplitCoins: {\n\t\t\t\t\tcoin: grpcArgumentToTsArgument(command.splitCoins.coin!),\n\t\t\t\t\tamounts: command.splitCoins.amounts.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'mergeCoins':\n\t\t\treturn {\n\t\t\t\t$kind: 'MergeCoins',\n\t\t\t\tMergeCoins: {\n\t\t\t\t\tdestination: grpcArgumentToTsArgument(command.mergeCoins.coin!),\n\t\t\t\t\tsources: command.mergeCoins.coinsToMerge.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'publish':\n\t\t\treturn {\n\t\t\t\t$kind: 'Publish',\n\t\t\t\tPublish: {\n\t\t\t\t\tmodules: command.publish.modules.map((m) => toBase64(m)),\n\t\t\t\t\tdependencies: command.publish.dependencies ?? [],\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'makeMoveVector':\n\t\t\treturn {\n\t\t\t\t$kind: 'MakeMoveVec',\n\t\t\t\tMakeMoveVec: {\n\t\t\t\t\ttype: command.makeMoveVector.elementType ?? null,\n\t\t\t\t\telements: command.makeMoveVector.elements.map(grpcArgumentToTsArgument),\n\t\t\t\t},\n\t\t\t};\n\n\t\tcase 'upgrade':\n\t\t\treturn {\n\t\t\t\t$kind: 'Upgrade',\n\t\t\t\tUpgrade: {\n\t\t\t\t\tmodules: command.upgrade.modules.map((m) => toBase64(m)),\n\t\t\t\t\tdependencies: command.upgrade.dependencies ?? [],\n\t\t\t\t\tpackage: command.upgrade.package!,\n\t\t\t\t\tticket: grpcArgumentToTsArgument(command.upgrade.ticket!),\n\t\t\t\t},\n\t\t\t};\n\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown Command kind: ${JSON.stringify(command)}`);\n\t}\n}\n\nexport function grpcTransactionToTransactionData(grpcTx: GrpcTransaction): TransactionData {\n\tconst programmableTx = grpcTx.kind?.data;\n\tif (programmableTx?.oneofKind !== 'programmableTransaction') {\n\t\tthrow new Error('Only programmable transactions are supported');\n\t}\n\n\tconst inputs = programmableTx.programmableTransaction.inputs.map(grpcInputToCallArg);\n\tconst commands = programmableTx.programmableTransaction.commands.map(grpcCommandToTsCommand);\n\n\tlet expiration: TransactionData['expiration'] = null;\n\tif (grpcTx.expiration) {\n\t\tswitch (grpcTx.expiration.kind) {\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.NONE:\n\t\t\t\texpiration = { $kind: 'None', None: true };\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.EPOCH:\n\t\t\t\texpiration = { $kind: 'Epoch', Epoch: grpcTx.expiration.epoch!.toString() };\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.VALID_DURING:\n\t\t\t\texpiration = {\n\t\t\t\t\t$kind: 'ValidDuring',\n\t\t\t\t\tValidDuring: {\n\t\t\t\t\t\tminEpoch: grpcTx.expiration.minEpoch?.toString() ?? null,\n\t\t\t\t\t\tmaxEpoch: grpcTx.expiration.epoch?.toString() ?? null,\n\t\t\t\t\t\tminTimestamp: grpcTx.expiration.minTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.minTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tmaxTimestamp: grpcTx.expiration.maxTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.maxTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tchain: grpcTx.expiration.chain ?? '',\n\t\t\t\t\t\tnonce: grpcTx.expiration.nonce ?? 0,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase TransactionExpiration_TransactionExpirationKind.VALIDITY:\n\t\t\t\texpiration = {\n\t\t\t\t\t$kind: 'Validity',\n\t\t\t\t\tValidity: {\n\t\t\t\t\t\tminEpoch: grpcTx.expiration.minEpoch?.toString() ?? null,\n\t\t\t\t\t\tmaxEpoch: grpcTx.expiration.epoch?.toString() ?? null,\n\t\t\t\t\t\tminTimestamp: grpcTx.expiration.minTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.minTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tmaxTimestamp: grpcTx.expiration.maxTimestamp\n\t\t\t\t\t\t\t? grpcTimestampToMilliseconds(grpcTx.expiration.maxTimestamp)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\tchain: grpcTx.expiration.chain ?? '',\n\t\t\t\t\t\tnonce: grpcTx.expiration.nonce ?? 0,\n\t\t\t\t\t\tallowedProposers: grpcTx.expiration.allowedProposers\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tepoch: grpcTx.expiration.allowedProposers.epoch?.toString() ?? '0',\n\t\t\t\t\t\t\t\t\tproposers: assertAllowedProposersNotEmpty(\n\t\t\t\t\t\t\t\t\t\tgrpcTx.expiration.allowedProposers.proposers,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Leaving `expiration` null here would drop a restriction the server did send.\n\t\t\t\tthrow new Error(`Unknown transaction expiration kind: ${grpcTx.expiration.kind}`);\n\t\t}\n\t}\n\n\treturn {\n\t\tversion: 2 as const,\n\t\tsender: grpcTx.sender ?? null,\n\t\texpiration,\n\t\tgasData: {\n\t\t\tbudget: grpcTx.gasPayment?.budget?.toString() ?? null,\n\t\t\towner: grpcTx.gasPayment?.owner ?? null,\n\t\t\tpayment:\n\t\t\t\tgrpcTx.gasPayment?.objects?.map((obj) => ({\n\t\t\t\t\tobjectId: obj.objectId!,\n\t\t\t\t\tversion: obj.version!.toString(),\n\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t})) ?? null,\n\t\t\tprice: grpcTx.gasPayment?.price?.toString() ?? null,\n\t\t},\n\t\tinputs,\n\t\tcommands,\n\t};\n}\n"],"mappings":";;;;;;;AA6BA,SAAS,4BAA4B,OAAwB;CAC5D,MAAM,eAAe,OAAO,MAAM;AAClC,QAAO;EACN,SAAS,eAAe;EACxB,OAAO,OAAO,eAAe,MAAM,GAAG;EACtC;;AAGF,S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ACD;EACD,QAEC,OAAM,IAAI,MAAM,wCAAwC,OAAO,WAAW,OAAO;;AAIpF,QAAO;EACN,SAAS;EACT,QAAQ,OAAO,UAAU;EACzB;EACA,SAAS;GACR,QAAQ,OAAO,YAAY,QAAQ,UAAU,IAAI;GACjD,OAAO,OAAO,YAAY,SAAS;GACnC,SACC,OAAO,YAAY,SAAS,KAAK,SAAS;IACzC,UAAU,IAAI;IACd,SAAS,IAAI,QAAS,UAAU;IAChC,QAAQ,IAAI;IACZ,EAAE,IAAI;GACR,OAAO,OAAO,YAAY,OAAO,UAAU,IAAI;GAC/C;EACD;EACA;EACA"}
|
|
@@ -948,10 +948,49 @@ declare const introspection: {
|
|
|
948
948
|
readonly isDeprecated: false;
|
|
949
949
|
}];
|
|
950
950
|
readonly interfaces: readonly [];
|
|
951
|
+
}, {
|
|
952
|
+
readonly kind: "INPUT_OBJECT";
|
|
953
|
+
readonly name: "BalanceKey";
|
|
954
|
+
readonly inputFields: readonly [{
|
|
955
|
+
readonly name: "address";
|
|
956
|
+
readonly type: {
|
|
957
|
+
readonly kind: "NON_NULL";
|
|
958
|
+
readonly ofType: {
|
|
959
|
+
readonly kind: "SCALAR";
|
|
960
|
+
readonly name: "SuiAddress";
|
|
961
|
+
};
|
|
962
|
+
};
|
|
963
|
+
}, {
|
|
964
|
+
readonly name: "coinType";
|
|
965
|
+
readonly type: {
|
|
966
|
+
readonly kind: "NON_NULL";
|
|
967
|
+
readonly ofType: {
|
|
968
|
+
readonly kind: "SCALAR";
|
|
969
|
+
readonly name: "String";
|
|
970
|
+
};
|
|
971
|
+
};
|
|
972
|
+
}];
|
|
973
|
+
readonly isOneOf: false;
|
|
951
974
|
}, {
|
|
952
975
|
readonly kind: "OBJECT";
|
|
953
976
|
readonly name: "BalanceWithdraw";
|
|
954
977
|
readonly fields: readonly [{
|
|
978
|
+
readonly name: "allowance";
|
|
979
|
+
readonly type: {
|
|
980
|
+
readonly kind: "OBJECT";
|
|
981
|
+
readonly name: "Address";
|
|
982
|
+
};
|
|
983
|
+
readonly args: readonly [];
|
|
984
|
+
readonly isDeprecated: false;
|
|
985
|
+
}, {
|
|
986
|
+
readonly name: "funder";
|
|
987
|
+
readonly type: {
|
|
988
|
+
readonly kind: "OBJECT";
|
|
989
|
+
readonly name: "Address";
|
|
990
|
+
};
|
|
991
|
+
readonly args: readonly [];
|
|
992
|
+
readonly isDeprecated: false;
|
|
993
|
+
}, {
|
|
955
994
|
readonly name: "reservation";
|
|
956
995
|
readonly type: {
|
|
957
996
|
readonly kind: "UNION";
|
|
@@ -9374,6 +9413,38 @@ declare const introspection: {
|
|
|
9374
9413
|
};
|
|
9375
9414
|
}];
|
|
9376
9415
|
readonly isDeprecated: false;
|
|
9416
|
+
}, {
|
|
9417
|
+
readonly name: "multiGetBalances";
|
|
9418
|
+
readonly type: {
|
|
9419
|
+
readonly kind: "NON_NULL";
|
|
9420
|
+
readonly ofType: {
|
|
9421
|
+
readonly kind: "LIST";
|
|
9422
|
+
readonly ofType: {
|
|
9423
|
+
readonly kind: "NON_NULL";
|
|
9424
|
+
readonly ofType: {
|
|
9425
|
+
readonly kind: "OBJECT";
|
|
9426
|
+
readonly name: "Balance";
|
|
9427
|
+
};
|
|
9428
|
+
};
|
|
9429
|
+
};
|
|
9430
|
+
};
|
|
9431
|
+
readonly args: readonly [{
|
|
9432
|
+
readonly name: "keys";
|
|
9433
|
+
readonly type: {
|
|
9434
|
+
readonly kind: "NON_NULL";
|
|
9435
|
+
readonly ofType: {
|
|
9436
|
+
readonly kind: "LIST";
|
|
9437
|
+
readonly ofType: {
|
|
9438
|
+
readonly kind: "NON_NULL";
|
|
9439
|
+
readonly ofType: {
|
|
9440
|
+
readonly kind: "INPUT_OBJECT";
|
|
9441
|
+
readonly name: "BalanceKey";
|
|
9442
|
+
};
|
|
9443
|
+
};
|
|
9444
|
+
};
|
|
9445
|
+
};
|
|
9446
|
+
}];
|
|
9447
|
+
readonly isDeprecated: false;
|
|
9377
9448
|
}, {
|
|
9378
9449
|
readonly name: "multiGetCheckpoints";
|
|
9379
9450
|
readonly type: {
|
|
@@ -11817,6 +11888,9 @@ declare const introspection: {
|
|
|
11817
11888
|
}, {
|
|
11818
11889
|
readonly name: "SPONSOR";
|
|
11819
11890
|
readonly isDeprecated: false;
|
|
11891
|
+
}, {
|
|
11892
|
+
readonly name: "SENDER_ALLOWANCE";
|
|
11893
|
+
readonly isDeprecated: false;
|
|
11820
11894
|
}];
|
|
11821
11895
|
}, {
|
|
11822
11896
|
readonly kind: "OBJECT";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdvanceCheckpointRequest, AdvanceCheckpointResponse, AdvanceClockRequest, AdvanceClockResponse, GetStatusRequest, GetStatusResponse } from "./forking_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/forking/v1alpha/forking_service.client.d.ts
|
|
@@ -37,9 +37,9 @@ interface IForkingServiceClient {
|
|
|
37
37
|
declare class ForkingServiceClient implements IForkingServiceClient, ServiceInfo {
|
|
38
38
|
private readonly _transport;
|
|
39
39
|
typeName: string;
|
|
40
|
-
methods:
|
|
40
|
+
methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
|
|
41
41
|
options: {
|
|
42
|
-
[extensionName: string]:
|
|
42
|
+
[extensionName: string]: _protobuf_ts_runtime5.JsonValue;
|
|
43
43
|
};
|
|
44
44
|
constructor(_transport: RpcTransport);
|
|
45
45
|
/**
|
|
@@ -152,6 +152,19 @@ interface FundsWithdrawal {
|
|
|
152
152
|
* @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal.Source source = 3;
|
|
153
153
|
*/
|
|
154
154
|
source?: FundsWithdrawal_Source;
|
|
155
|
+
/**
|
|
156
|
+
* The address whose balance is debited if `source` is `SENDER_ALLOWANCE`.
|
|
157
|
+
*
|
|
158
|
+
* @generated from protobuf field: optional string funder = 4;
|
|
159
|
+
*/
|
|
160
|
+
funder?: string;
|
|
161
|
+
/**
|
|
162
|
+
* `ObjectId` of the allowance object authorizing the withdrawal if `source`
|
|
163
|
+
* is `SENDER_ALLOWANCE`.
|
|
164
|
+
*
|
|
165
|
+
* @generated from protobuf field: optional string allowance = 5;
|
|
166
|
+
*/
|
|
167
|
+
allowance?: string;
|
|
155
168
|
}
|
|
156
169
|
/**
|
|
157
170
|
* @generated from protobuf enum sui.rpc.v2.FundsWithdrawal.Source
|
|
@@ -168,7 +181,14 @@ declare enum FundsWithdrawal_Source {
|
|
|
168
181
|
/**
|
|
169
182
|
* @generated from protobuf enum value: SPONSOR = 2;
|
|
170
183
|
*/
|
|
171
|
-
SPONSOR = 2
|
|
184
|
+
SPONSOR = 2,
|
|
185
|
+
/**
|
|
186
|
+
* Withdraw from `funder`'s balance under the `allowance` object, granted
|
|
187
|
+
* to the sender of the transaction.
|
|
188
|
+
*
|
|
189
|
+
* @generated from protobuf enum value: SENDER_ALLOWANCE = 3;
|
|
190
|
+
*/
|
|
191
|
+
SENDER_ALLOWANCE = 3
|
|
172
192
|
}
|
|
173
193
|
declare class Input$Type extends MessageType<Input> {
|
|
174
194
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.mts","names":[],"sources":["../../../../../../src/grpc/proto/sui/rpc/v2/input.ts"],"mappings":";;;;;;AAkBA;;;UAAiB,KAAA;EAaT;;;EATP,IAAA,GAAO,eAAA;EA2DQ;;;;;;;;EAlDf,IAAA,GAAO,UAAA;EA2BP;;;;;EArBA,QAAA;EA4CU;;;AAKX;;;;EAzCC,OAAA;EAmDA;;;;;EA7CA,MAAA;EAqEgB;AAKjB;;;;;EAnEC,OAAA;EA+EA;;;;AAaD;;;;EAnFC,UAAA,GAAa,gBAAA;EA2Fb;;;;;EArFA,eAAA,GAAkB,eAAA;
|
|
1
|
+
{"version":3,"file":"input.d.mts","names":[],"sources":["../../../../../../src/grpc/proto/sui/rpc/v2/input.ts"],"mappings":";;;;;;AAkBA;;;UAAiB,KAAA;EAaT;;;EATP,IAAA,GAAO,eAAA;EA2DQ;;;;;;;;EAlDf,IAAA,GAAO,UAAA;EA2BP;;;;;EArBA,QAAA;EA4CU;;;AAKX;;;;EAzCC,OAAA;EAmDA;;;;;EA7CA,MAAA;EAqEgB;AAKjB;;;;;EAnEC,OAAA;EA+EA;;;;AAaD;;;;EAnFC,UAAA,GAAa,gBAAA;EA2Fb;;;;;EArFA,eAAA,GAAkB,eAAA;EAsGT;AAKV;;;;;;EAnGC,OAAA,GAAU,KAAA;AAAA;;;AAuHV;aAlHW,eAAA;;;;EAIX,kBAAA;;;;AAqJD;;EA/IC,IAAA;EA+IiB;;AAAoB;;;EAzIrC,kBAAA;EA2IkC;;;;;EArIlC,MAAA;EAgKwD;;;;;EA1JxD,SAAA;;;;;;EAMA,gBAAA;AAAA;;;;aAKW,gBAAA;;;;EAIX,kBAAA;;;;EAIA,SAAA;;;;EAIA,OAAA;;;;;;;;EAQA,mBAAA;AAAA;;;;UAKgB,eAAA;;;;EAIhB,MAAA;;;;EAIA,QAAA;;;;EAIA,MAAA,GAAS,sBAAA;;;;;;EAMT,MAAA;;;;;;;EAOA,SAAA;AAAA;;;;aAKW,sBAAA;;;;EAIX,cAAA;;;;EAIA,MAAA;;;;EAIA,OAAA;;;;;;;EAOA,gBAAA;AAAA;AAAA,cAGK,UAAA,SAAmB,WAAA,CAAY,KAAA;;;;;;cAqCxB,KAAA,EAAK,UAAA;AAAA,cAEZ,oBAAA,SAA6B,WAAA,CAAY,eAAA;;;;;;cA2BlC,eAAA,EAAe,oBAAA"}
|
|
@@ -84,6 +84,13 @@ let FundsWithdrawal_Source = /* @__PURE__ */ function(FundsWithdrawal_Source$1)
|
|
|
84
84
|
* @generated from protobuf enum value: SPONSOR = 2;
|
|
85
85
|
*/
|
|
86
86
|
FundsWithdrawal_Source$1[FundsWithdrawal_Source$1["SPONSOR"] = 2] = "SPONSOR";
|
|
87
|
+
/**
|
|
88
|
+
* Withdraw from `funder`'s balance under the `allowance` object, granted
|
|
89
|
+
* to the sender of the transaction.
|
|
90
|
+
*
|
|
91
|
+
* @generated from protobuf enum value: SENDER_ALLOWANCE = 3;
|
|
92
|
+
*/
|
|
93
|
+
FundsWithdrawal_Source$1[FundsWithdrawal_Source$1["SENDER_ALLOWANCE"] = 3] = "SENDER_ALLOWANCE";
|
|
87
94
|
return FundsWithdrawal_Source$1;
|
|
88
95
|
}({});
|
|
89
96
|
var Input$Type = class extends MessageType {
|
|
@@ -182,6 +189,20 @@ var FundsWithdrawal$Type = class extends MessageType {
|
|
|
182
189
|
kind: "enum",
|
|
183
190
|
opt: true,
|
|
184
191
|
T: () => ["sui.rpc.v2.FundsWithdrawal.Source", FundsWithdrawal_Source]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
no: 4,
|
|
195
|
+
name: "funder",
|
|
196
|
+
kind: "scalar",
|
|
197
|
+
opt: true,
|
|
198
|
+
T: 9
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
no: 5,
|
|
202
|
+
name: "allowance",
|
|
203
|
+
kind: "scalar",
|
|
204
|
+
opt: true,
|
|
205
|
+
T: 9
|
|
185
206
|
}
|
|
186
207
|
]);
|
|
187
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.mjs","names":[],"sources":["../../../../../../src/grpc/proto/sui/rpc/v2/input.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// @generated by protobuf-ts 2.9.6 with parameter force_server_none,optimize_code_size,ts_nocheck\n// @generated from protobuf file \"sui/rpc/v2/input.proto\" (package \"sui.rpc.v2\", syntax proto3)\n// tslint:disable\n// @ts-nocheck\n//\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\nimport { MessageType } from '@protobuf-ts/runtime';\nimport { Value } from '../../../google/protobuf/struct.js';\n/**\n * An input to a user transaction.\n *\n * @generated from protobuf message sui.rpc.v2.Input\n */\nexport interface Input {\n\t/**\n\t * @generated from protobuf field: optional sui.rpc.v2.Input.InputKind kind = 1;\n\t */\n\tkind?: Input_InputKind;\n\t/**\n\t * A move value serialized as BCS.\n\t *\n\t * For normal operations this is required to be a move primitive type and not contain structs\n\t * or objects.\n\t *\n\t * @generated from protobuf field: optional bytes pure = 2;\n\t */\n\tpure?: Uint8Array;\n\t/**\n\t * `ObjectId` of the object input.\n\t *\n\t * @generated from protobuf field: optional string object_id = 3;\n\t */\n\tobjectId?: string;\n\t/**\n\t * Requested version of the input object when `kind` is `IMMUTABLE_OR_OWNED`\n\t * or `RECEIVING` or if `kind` is `SHARED` this is the initial version of the\n\t * object when it was shared\n\t *\n\t * @generated from protobuf field: optional uint64 version = 4;\n\t */\n\tversion?: bigint;\n\t/**\n\t * The digest of this object.\n\t *\n\t * @generated from protobuf field: optional string digest = 5;\n\t */\n\tdigest?: string;\n\t/**\n\t * Controls whether the caller asks for a mutable reference to the shared\n\t * object.\n\t *\n\t * @generated from protobuf field: optional bool mutable = 6;\n\t */\n\tmutable?: boolean;\n\t/**\n\t * NOTE: For backwards compatibility purposes the addition of the new\n\t * `NON_EXCLUSIVE_WRITE` mutability variant requires providing a new field.\n\t * The old `mutable` field will continue to be populated and respected as an\n\t * input for the time being.\n\t *\n\t * @generated from protobuf field: optional sui.rpc.v2.Input.Mutability mutability = 7;\n\t */\n\tmutability?: Input_Mutability;\n\t/**\n\t * Fund Reservation information if `kind` is `FUNDS_WITHDRAWAL`.\n\t *\n\t * @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal funds_withdrawal = 8;\n\t */\n\tfundsWithdrawal?: FundsWithdrawal;\n\t/**\n\t * A literal value\n\t *\n\t * INPUT ONLY\n\t *\n\t * @generated from protobuf field: optional google.protobuf.Value literal = 1000;\n\t */\n\tliteral?: Value;\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.Input.InputKind\n */\nexport enum Input_InputKind {\n\t/**\n\t * @generated from protobuf enum value: INPUT_KIND_UNKNOWN = 0;\n\t */\n\tINPUT_KIND_UNKNOWN = 0,\n\t/**\n\t * A move value serialized as BCS.\n\t *\n\t * @generated from protobuf enum value: PURE = 1;\n\t */\n\tPURE = 1,\n\t/**\n\t * A Move object that is either immutable or address owned.\n\t *\n\t * @generated from protobuf enum value: IMMUTABLE_OR_OWNED = 2;\n\t */\n\tIMMUTABLE_OR_OWNED = 2,\n\t/**\n\t * A Move object whose owner is \"Shared\".\n\t *\n\t * @generated from protobuf enum value: SHARED = 3;\n\t */\n\tSHARED = 3,\n\t/**\n\t * A Move object that is attempted to be received in this transaction.\n\t *\n\t * @generated from protobuf enum value: RECEIVING = 4;\n\t */\n\tRECEIVING = 4,\n\t/**\n\t * Reservation to withdraw balance from a funds accumulator\n\t *\n\t * @generated from protobuf enum value: FUNDS_WITHDRAWAL = 5;\n\t */\n\tFUNDS_WITHDRAWAL = 5,\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.Input.Mutability\n */\nexport enum Input_Mutability {\n\t/**\n\t * @generated from protobuf enum value: MUTABILITY_UNKNOWN = 0;\n\t */\n\tMUTABILITY_UNKNOWN = 0,\n\t/**\n\t * @generated from protobuf enum value: IMMUTABLE = 1;\n\t */\n\tIMMUTABLE = 1,\n\t/**\n\t * @generated from protobuf enum value: MUTABLE = 2;\n\t */\n\tMUTABLE = 2,\n\t/**\n\t * Non-exclusive write is used to allow multiple transactions to\n\t * simultaneously add disjoint dynamic fields to an object.\n\t * (Currently only used by settlement transactions).\n\t *\n\t * @generated from protobuf enum value: NON_EXCLUSIVE_WRITE = 3;\n\t */\n\tNON_EXCLUSIVE_WRITE = 3,\n}\n/**\n * @generated from protobuf message sui.rpc.v2.FundsWithdrawal\n */\nexport interface FundsWithdrawal {\n\t/**\n\t * @generated from protobuf field: optional uint64 amount = 1;\n\t */\n\tamount?: bigint;\n\t/**\n\t * @generated from protobuf field: optional string coin_type = 2;\n\t */\n\tcoinType?: string;\n\t/**\n\t * @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal.Source source = 3;\n\t */\n\tsource?: FundsWithdrawal_Source;\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.FundsWithdrawal.Source\n */\nexport enum FundsWithdrawal_Source {\n\t/**\n\t * @generated from protobuf enum value: SOURCE_UNKNOWN = 0;\n\t */\n\tSOURCE_UNKNOWN = 0,\n\t/**\n\t * @generated from protobuf enum value: SENDER = 1;\n\t */\n\tSENDER = 1,\n\t/**\n\t * @generated from protobuf enum value: SPONSOR = 2;\n\t */\n\tSPONSOR = 2,\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Input$Type extends MessageType<Input> {\n\tconstructor() {\n\t\tsuper('sui.rpc.v2.Input', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'kind',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.Input.InputKind', Input_InputKind],\n\t\t\t},\n\t\t\t{ no: 2, name: 'pure', kind: 'scalar', opt: true, T: 12 /*ScalarType.BYTES*/ },\n\t\t\t{ no: 3, name: 'object_id', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{\n\t\t\t\tno: 4,\n\t\t\t\tname: 'version',\n\t\t\t\tkind: 'scalar',\n\t\t\t\topt: true,\n\t\t\t\tT: 4 /*ScalarType.UINT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 5, name: 'digest', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{ no: 6, name: 'mutable', kind: 'scalar', opt: true, T: 8 /*ScalarType.BOOL*/ },\n\t\t\t{\n\t\t\t\tno: 7,\n\t\t\t\tname: 'mutability',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.Input.Mutability', Input_Mutability],\n\t\t\t},\n\t\t\t{ no: 8, name: 'funds_withdrawal', kind: 'message', T: () => FundsWithdrawal },\n\t\t\t{ no: 1000, name: 'literal', kind: 'message', T: () => Value },\n\t\t]);\n\t}\n}\n/**\n * @generated MessageType for protobuf message sui.rpc.v2.Input\n */\nexport const Input = new Input$Type();\n// @generated message type with reflection information, may provide speed optimized methods\nclass FundsWithdrawal$Type extends MessageType<FundsWithdrawal> {\n\tconstructor() {\n\t\tsuper('sui.rpc.v2.FundsWithdrawal', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'amount',\n\t\t\t\tkind: 'scalar',\n\t\t\t\topt: true,\n\t\t\t\tT: 4 /*ScalarType.UINT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 2, name: 'coin_type', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{\n\t\t\t\tno: 3,\n\t\t\t\tname: 'source',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.FundsWithdrawal.Source', FundsWithdrawal_Source],\n\t\t\t},\n\t\t]);\n\t}\n}\n/**\n * @generated MessageType for protobuf message sui.rpc.v2.FundsWithdrawal\n */\nexport const FundsWithdrawal = new FundsWithdrawal$Type();\n"],"mappings":";;;;;;;AAsFA,IAAY,8DAAL;;;;AAIN;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAKD,IAAY,gEAAL;;;;AAIN;;;;AAIA;;;;AAIA;;;;;;;;AAQA;;;;;;
|
|
1
|
+
{"version":3,"file":"input.mjs","names":[],"sources":["../../../../../../src/grpc/proto/sui/rpc/v2/input.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// @generated by protobuf-ts 2.9.6 with parameter force_server_none,optimize_code_size,ts_nocheck\n// @generated from protobuf file \"sui/rpc/v2/input.proto\" (package \"sui.rpc.v2\", syntax proto3)\n// tslint:disable\n// @ts-nocheck\n//\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n//\nimport { MessageType } from '@protobuf-ts/runtime';\nimport { Value } from '../../../google/protobuf/struct.js';\n/**\n * An input to a user transaction.\n *\n * @generated from protobuf message sui.rpc.v2.Input\n */\nexport interface Input {\n\t/**\n\t * @generated from protobuf field: optional sui.rpc.v2.Input.InputKind kind = 1;\n\t */\n\tkind?: Input_InputKind;\n\t/**\n\t * A move value serialized as BCS.\n\t *\n\t * For normal operations this is required to be a move primitive type and not contain structs\n\t * or objects.\n\t *\n\t * @generated from protobuf field: optional bytes pure = 2;\n\t */\n\tpure?: Uint8Array;\n\t/**\n\t * `ObjectId` of the object input.\n\t *\n\t * @generated from protobuf field: optional string object_id = 3;\n\t */\n\tobjectId?: string;\n\t/**\n\t * Requested version of the input object when `kind` is `IMMUTABLE_OR_OWNED`\n\t * or `RECEIVING` or if `kind` is `SHARED` this is the initial version of the\n\t * object when it was shared\n\t *\n\t * @generated from protobuf field: optional uint64 version = 4;\n\t */\n\tversion?: bigint;\n\t/**\n\t * The digest of this object.\n\t *\n\t * @generated from protobuf field: optional string digest = 5;\n\t */\n\tdigest?: string;\n\t/**\n\t * Controls whether the caller asks for a mutable reference to the shared\n\t * object.\n\t *\n\t * @generated from protobuf field: optional bool mutable = 6;\n\t */\n\tmutable?: boolean;\n\t/**\n\t * NOTE: For backwards compatibility purposes the addition of the new\n\t * `NON_EXCLUSIVE_WRITE` mutability variant requires providing a new field.\n\t * The old `mutable` field will continue to be populated and respected as an\n\t * input for the time being.\n\t *\n\t * @generated from protobuf field: optional sui.rpc.v2.Input.Mutability mutability = 7;\n\t */\n\tmutability?: Input_Mutability;\n\t/**\n\t * Fund Reservation information if `kind` is `FUNDS_WITHDRAWAL`.\n\t *\n\t * @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal funds_withdrawal = 8;\n\t */\n\tfundsWithdrawal?: FundsWithdrawal;\n\t/**\n\t * A literal value\n\t *\n\t * INPUT ONLY\n\t *\n\t * @generated from protobuf field: optional google.protobuf.Value literal = 1000;\n\t */\n\tliteral?: Value;\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.Input.InputKind\n */\nexport enum Input_InputKind {\n\t/**\n\t * @generated from protobuf enum value: INPUT_KIND_UNKNOWN = 0;\n\t */\n\tINPUT_KIND_UNKNOWN = 0,\n\t/**\n\t * A move value serialized as BCS.\n\t *\n\t * @generated from protobuf enum value: PURE = 1;\n\t */\n\tPURE = 1,\n\t/**\n\t * A Move object that is either immutable or address owned.\n\t *\n\t * @generated from protobuf enum value: IMMUTABLE_OR_OWNED = 2;\n\t */\n\tIMMUTABLE_OR_OWNED = 2,\n\t/**\n\t * A Move object whose owner is \"Shared\".\n\t *\n\t * @generated from protobuf enum value: SHARED = 3;\n\t */\n\tSHARED = 3,\n\t/**\n\t * A Move object that is attempted to be received in this transaction.\n\t *\n\t * @generated from protobuf enum value: RECEIVING = 4;\n\t */\n\tRECEIVING = 4,\n\t/**\n\t * Reservation to withdraw balance from a funds accumulator\n\t *\n\t * @generated from protobuf enum value: FUNDS_WITHDRAWAL = 5;\n\t */\n\tFUNDS_WITHDRAWAL = 5,\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.Input.Mutability\n */\nexport enum Input_Mutability {\n\t/**\n\t * @generated from protobuf enum value: MUTABILITY_UNKNOWN = 0;\n\t */\n\tMUTABILITY_UNKNOWN = 0,\n\t/**\n\t * @generated from protobuf enum value: IMMUTABLE = 1;\n\t */\n\tIMMUTABLE = 1,\n\t/**\n\t * @generated from protobuf enum value: MUTABLE = 2;\n\t */\n\tMUTABLE = 2,\n\t/**\n\t * Non-exclusive write is used to allow multiple transactions to\n\t * simultaneously add disjoint dynamic fields to an object.\n\t * (Currently only used by settlement transactions).\n\t *\n\t * @generated from protobuf enum value: NON_EXCLUSIVE_WRITE = 3;\n\t */\n\tNON_EXCLUSIVE_WRITE = 3,\n}\n/**\n * @generated from protobuf message sui.rpc.v2.FundsWithdrawal\n */\nexport interface FundsWithdrawal {\n\t/**\n\t * @generated from protobuf field: optional uint64 amount = 1;\n\t */\n\tamount?: bigint;\n\t/**\n\t * @generated from protobuf field: optional string coin_type = 2;\n\t */\n\tcoinType?: string;\n\t/**\n\t * @generated from protobuf field: optional sui.rpc.v2.FundsWithdrawal.Source source = 3;\n\t */\n\tsource?: FundsWithdrawal_Source;\n\t/**\n\t * The address whose balance is debited if `source` is `SENDER_ALLOWANCE`.\n\t *\n\t * @generated from protobuf field: optional string funder = 4;\n\t */\n\tfunder?: string;\n\t/**\n\t * `ObjectId` of the allowance object authorizing the withdrawal if `source`\n\t * is `SENDER_ALLOWANCE`.\n\t *\n\t * @generated from protobuf field: optional string allowance = 5;\n\t */\n\tallowance?: string;\n}\n/**\n * @generated from protobuf enum sui.rpc.v2.FundsWithdrawal.Source\n */\nexport enum FundsWithdrawal_Source {\n\t/**\n\t * @generated from protobuf enum value: SOURCE_UNKNOWN = 0;\n\t */\n\tSOURCE_UNKNOWN = 0,\n\t/**\n\t * @generated from protobuf enum value: SENDER = 1;\n\t */\n\tSENDER = 1,\n\t/**\n\t * @generated from protobuf enum value: SPONSOR = 2;\n\t */\n\tSPONSOR = 2,\n\t/**\n\t * Withdraw from `funder`'s balance under the `allowance` object, granted\n\t * to the sender of the transaction.\n\t *\n\t * @generated from protobuf enum value: SENDER_ALLOWANCE = 3;\n\t */\n\tSENDER_ALLOWANCE = 3,\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Input$Type extends MessageType<Input> {\n\tconstructor() {\n\t\tsuper('sui.rpc.v2.Input', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'kind',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.Input.InputKind', Input_InputKind],\n\t\t\t},\n\t\t\t{ no: 2, name: 'pure', kind: 'scalar', opt: true, T: 12 /*ScalarType.BYTES*/ },\n\t\t\t{ no: 3, name: 'object_id', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{\n\t\t\t\tno: 4,\n\t\t\t\tname: 'version',\n\t\t\t\tkind: 'scalar',\n\t\t\t\topt: true,\n\t\t\t\tT: 4 /*ScalarType.UINT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 5, name: 'digest', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{ no: 6, name: 'mutable', kind: 'scalar', opt: true, T: 8 /*ScalarType.BOOL*/ },\n\t\t\t{\n\t\t\t\tno: 7,\n\t\t\t\tname: 'mutability',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.Input.Mutability', Input_Mutability],\n\t\t\t},\n\t\t\t{ no: 8, name: 'funds_withdrawal', kind: 'message', T: () => FundsWithdrawal },\n\t\t\t{ no: 1000, name: 'literal', kind: 'message', T: () => Value },\n\t\t]);\n\t}\n}\n/**\n * @generated MessageType for protobuf message sui.rpc.v2.Input\n */\nexport const Input = new Input$Type();\n// @generated message type with reflection information, may provide speed optimized methods\nclass FundsWithdrawal$Type extends MessageType<FundsWithdrawal> {\n\tconstructor() {\n\t\tsuper('sui.rpc.v2.FundsWithdrawal', [\n\t\t\t{\n\t\t\t\tno: 1,\n\t\t\t\tname: 'amount',\n\t\t\t\tkind: 'scalar',\n\t\t\t\topt: true,\n\t\t\t\tT: 4 /*ScalarType.UINT64*/,\n\t\t\t\tL: 0 /*LongType.BIGINT*/,\n\t\t\t},\n\t\t\t{ no: 2, name: 'coin_type', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{\n\t\t\t\tno: 3,\n\t\t\t\tname: 'source',\n\t\t\t\tkind: 'enum',\n\t\t\t\topt: true,\n\t\t\t\tT: () => ['sui.rpc.v2.FundsWithdrawal.Source', FundsWithdrawal_Source],\n\t\t\t},\n\t\t\t{ no: 4, name: 'funder', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t\t{ no: 5, name: 'allowance', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },\n\t\t]);\n\t}\n}\n/**\n * @generated MessageType for protobuf message sui.rpc.v2.FundsWithdrawal\n */\nexport const FundsWithdrawal = new FundsWithdrawal$Type();\n"],"mappings":";;;;;;;AAsFA,IAAY,8DAAL;;;;AAIN;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAMA;;;;;;AAKD,IAAY,gEAAL;;;;AAIN;;;;AAIA;;;;AAIA;;;;;;;;AAQA;;;;;;AAmCD,IAAY,4EAAL;;;;AAIN;;;;AAIA;;;;AAIA;;;;;;;AAOA;;;AAGD,IAAM,aAAN,cAAyB,YAAmB;CAC3C,cAAc;AACb,QAAM,oBAAoB;GACzB;IACC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,SAAS,CAAC,8BAA8B,gBAAgB;IACxD;GACD;IAAE,IAAI;IAAG,MAAM;IAAQ,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GAC9E;IAAE,IAAI;IAAG,MAAM;IAAa,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GACnF;IACC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,GAAG;IACH,GAAG;IACH;GACD;IAAE,IAAI;IAAG,MAAM;IAAU,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GAChF;IAAE,IAAI;IAAG,MAAM;IAAW,MAAM;IAAU,KAAK;IAAM,GAAG;IAAuB;GAC/E;IACC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,SAAS,CAAC,+BAA+B,iBAAiB;IAC1D;GACD;IAAE,IAAI;IAAG,MAAM;IAAoB,MAAM;IAAW,SAAS;IAAiB;GAC9E;IAAE,IAAI;IAAM,MAAM;IAAW,MAAM;IAAW,SAAS;IAAO;GAC9D,CAAC;;;;;;AAMJ,MAAa,QAAQ,IAAI,YAAY;AAErC,IAAM,uBAAN,cAAmC,YAA6B;CAC/D,cAAc;AACb,QAAM,8BAA8B;GACnC;IACC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,GAAG;IACH,GAAG;IACH;GACD;IAAE,IAAI;IAAG,MAAM;IAAa,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GACnF;IACC,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,SAAS,CAAC,qCAAqC,uBAAuB;IACtE;GACD;IAAE,IAAI;IAAG,MAAM;IAAU,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GAChF;IAAE,IAAI;IAAG,MAAM;IAAa,MAAM;IAAU,KAAK;IAAM,GAAG;IAAyB;GACnF,CAAC;;;;;;AAMJ,MAAa,kBAAkB,IAAI,sBAAsB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface INameServiceClient {
|
|
|
23
23
|
declare class NameServiceClient implements INameServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime6.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|