import {z} from 'zod' export type CoreTransactionDestinationAccount = {accountId: string, type: 'Account'}; export type CoreTransactionDestinationAddress = {address: string, type: 'Address'}; export type CoreTransactionDestinationEndpoint = {endpointId: string, type: 'Endpoint'}; export type CoreTransactionDestination = CoreTransactionDestinationAccount | CoreTransactionDestinationAddress | CoreTransactionDestinationEndpoint; export type CoreAlgorandOperation = {destination: CoreTransactionDestination, amount: string, type: 'Payment'}; export type CoreFeePriority = 'High' | 'Medium' | 'Low'; export type CoreAlgorandFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersAlgorand = {operation: CoreAlgorandOperation, note?: string | undefined, feeStrategy: CoreAlgorandFeeStrategy, maximumFee?: string | undefined, type: 'Algorand'}; export type CoreBitcoinOutputParameters = {destination: CoreTransactionDestination, amount: string, paysFee?: boolean | undefined}; export type CoreBitcoinFeeStrategyPriority = {priority: CoreFeePriority, type: 'Priority'}; export type CoreBitcoinFeeStrategySpecifiedRate = {satoshiPerVbyte: string, type: 'SpecifiedRate'}; export type CoreBitcoinFeeStrategy = CoreBitcoinFeeStrategyPriority | CoreBitcoinFeeStrategySpecifiedRate; export type CoreBitcoinResourceStrategy = {transactionOrderId: string, reason?: string | undefined, type: 'OrderReplacement'}; export type CoreAddressForChange = 'GenerateNewAddress' | 'PrimaryAddress'; export type CoreTransactionOrderParametersBitcoin = {outputs: Array, feeStrategy: CoreBitcoinFeeStrategy, maximumFee?: string | undefined, resourceStrategy?: CoreBitcoinResourceStrategy | undefined, addressForChange?: CoreAddressForChange | undefined, type: 'Bitcoin'}; export type CoreTransactionOrderParametersBitcoinRedirect = {transferIds: Array, outputs: Array, feeStrategy: CoreBitcoinFeeStrategy, maximumFee?: string | undefined, type: 'BitcoinRedirect'}; export type CoreDelegateRepresentativeParameters = {type: 'AlwaysAbstain'}; export type CoreCardanoOperationDelegateRepresentative = {parameters: CoreDelegateRepresentativeParameters, type: 'DelegateRepresentative'}; export type CoreCardanoOperationDelegateStaking = {poolId: string, type: 'DelegateStaking'}; export type CoreCardanoOperationRegisterStaking = {type: 'RegisterStaking'}; export type CoreCardanoOutputParameters = {destination: CoreTransactionDestination, amount: string, paysFee?: boolean | undefined}; export type CoreCardanoOperationTransfer = {outputs: Array, type: 'Transfer'}; export type CoreCardanoOperationUnregisterStaking = {type: 'UnregisterStaking'}; export type CoreCardanoOperationWithdrawRewards = {amount: string, type: 'WithdrawRewards'}; export type CoreCardanoOperation = CoreCardanoOperationDelegateRepresentative | CoreCardanoOperationDelegateStaking | CoreCardanoOperationRegisterStaking | CoreCardanoOperationTransfer | CoreCardanoOperationUnregisterStaking | CoreCardanoOperationWithdrawRewards; export type CoreCardanoFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersCardano = {operation: CoreCardanoOperation, feeStrategy: CoreCardanoFeeStrategy, maximumFee?: string | undefined, type: 'Cardano'}; export type CoreEthereumFeeStrategyPriority = {priority: CoreFeePriority, type: 'Priority'}; export type CoreEthereumFeeStrategySpecifiedRate = {gasPrice: string, type: 'SpecifiedRate'}; export type CoreEthereumFeeStrategySpecifiedRateEIP1559 = {maxFeePerGas: string, maxPriorityFeePerGas: string, type: 'SpecifiedRateEIP1559'}; export type CoreEthereumFeeStrategy = CoreEthereumFeeStrategyPriority | CoreEthereumFeeStrategySpecifiedRate | CoreEthereumFeeStrategySpecifiedRateEIP1559; export type CoreEthereumResourceStrategy = {transactionOrderId: string, reason?: string | undefined, type: 'OrderReplacement'}; export type CoreTransactionOrderParametersEthereum = {destination?: CoreTransactionDestination | undefined, amount: string, feeStrategy: CoreEthereumFeeStrategy, maximumFee?: string | undefined, data?: string | undefined, resourceStrategy?: CoreEthereumResourceStrategy | undefined, type: 'Ethereum'}; export type CoreHederaOperationAccountUpdate = {maxAutomaticTokenAssociations: number, type: 'AccountUpdate'}; export type CoreTokenDestinationTicker = {tickerId: string, type: 'Ticker'}; export type CoreTokenDestinationTokenId = {tokenId: string, type: 'TokenId'}; export type CoreTokenDestination = CoreTokenDestinationTicker | CoreTokenDestinationTokenId; export type CoreHederaOperationTokenAssociate = {tokens: Array, type: 'TokenAssociate'}; export type CoreHederaOperationTokenDissociate = {tokens: Array, type: 'TokenDissociate'}; export type CoreHederaTransferOutput = {destination: CoreTransactionDestination, amount: string}; export type CoreTokenOutputHederaFungibleTokenOutput = {token: CoreTokenDestination, destination: CoreTransactionDestination, amount: string, type: 'HederaFungibleTokenOutput'}; export type CoreNonFungibleTokenDestinationNftTokenId = {tokenId: string, serialNumber: number, type: 'NftTokenId'}; export type CoreNonFungibleTokenDestinationTicker = {tickerId: string, type: 'Ticker'}; export type CoreNonFungibleTokenDestination = CoreNonFungibleTokenDestinationNftTokenId | CoreNonFungibleTokenDestinationTicker; export type CoreTokenOutputHederaNonFungibleTokenOutput = {token: CoreNonFungibleTokenDestination, destination: CoreTransactionDestination, type: 'HederaNonFungibleTokenOutput'}; export type CoreTokenOutput = CoreTokenOutputHederaFungibleTokenOutput | CoreTokenOutputHederaNonFungibleTokenOutput; export type CoreHederaOperationTransfer = {outputs?: Array | undefined, tokenOutputs?: Array | undefined, type: 'Transfer'}; export type CoreHederaOperation = CoreHederaOperationAccountUpdate | CoreHederaOperationTokenAssociate | CoreHederaOperationTokenDissociate | CoreHederaOperationTransfer; export type CoreHederaFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersHedera = {operation: CoreHederaOperation, memo?: string | undefined, feeStrategy: CoreHederaFeeStrategy, maximumFee?: string | undefined, type: 'Hedera'}; export type CoreSolanaMintAccountDestination = {destination: CoreTransactionDestination, type: 'Destination'}; export type CoreSolanaMintAccountTicker = {tickerId: string, type: 'Ticker'}; export type CoreSolanaMintAccount = CoreSolanaMintAccountDestination | CoreSolanaMintAccountTicker; export type CoreSolanaOperationBurn = {mintAccount: CoreSolanaMintAccount, amount: string, type: 'Burn'}; export type CoreSolanaOperationCreateNonceAccount = {createOnAccount: string, type: 'CreateNonceAccount'}; export type CoreSolanaOperationFundAtaAccount = {destination?: CoreTransactionDestination | undefined, mintAccount: CoreSolanaMintAccount, type: 'FundAtaAccount'}; export type CoreSolanaTokenType = 'SPL' | 'SPL2022'; export type CoreSolanaOperationInitializeMint = {mintAccount: string, decimals: number, tokenType: CoreSolanaTokenType, type: 'InitializeMint'}; export type CoreSolanaOperationMintTo = {destination: CoreTransactionDestination, mintAccount: CoreSolanaMintAccount, amount: string, type: 'MintTo'}; export type CoreSolanaTransferOutput = {destination: CoreTransactionDestination, amount: string}; export type CoreSolanaOperationTransfer = {outputs: Array, type: 'Transfer'}; export type CoreSolanaOperationTransferToken = {outputs: Array, mintAccount: CoreSolanaMintAccount, type: 'TransferToken'}; export type CoreSolanaOperation = CoreSolanaOperationBurn | CoreSolanaOperationCreateNonceAccount | CoreSolanaOperationFundAtaAccount | CoreSolanaOperationInitializeMint | CoreSolanaOperationMintTo | CoreSolanaOperationTransfer | CoreSolanaOperationTransferToken; export type CoreSolanaFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersSolana = {operation: CoreSolanaOperation, memos: Array, feeStrategy: CoreSolanaFeeStrategy, maximumFee?: string | undefined, nonceAccount?: CoreTransactionDestination | undefined, type: 'Solana'}; export type CoreStellarOperationAccountMerge = {destination: CoreTransactionDestination, type: 'AccountMerge'}; export type CoreStellarAsset = {code: string, issuer: string}; export type CoreStellarOperationChangeTrust = {limit: string, asset: CoreStellarAsset, type: 'ChangeTrust'}; export type CoreStellarOperationCreateAccount = {destination: CoreTransactionDestination, startingBalance: string, type: 'CreateAccount'}; export type CoreStellarOperationPayment = {destination: CoreTransactionDestination, amount: string, asset?: CoreStellarAsset | undefined, type: 'Payment'}; export type CoreStellarOptionOptionHomeDomain = {homeDomain: string, type: 'OptionHomeDomain'}; export type CoreStellarOptionFlag = 'AuthImmutable'; export type CoreStellarOptionOptionSetFlag = {setFlag: CoreStellarOptionFlag, type: 'OptionSetFlag'}; export type CoreStellarOption = CoreStellarOptionOptionHomeDomain | CoreStellarOptionOptionSetFlag; export type CoreStellarOperationSetOptions = {option: CoreStellarOption, type: 'SetOptions'}; export type CoreStellarOperation = CoreStellarOperationAccountMerge | CoreStellarOperationChangeTrust | CoreStellarOperationCreateAccount | CoreStellarOperationPayment | CoreStellarOperationSetOptions; export type CoreStellarMemoHash = {value: string, type: 'Hash'}; export type CoreStellarMemoId = {value: string, type: 'Id'}; export type CoreStellarMemoReturn = {value: string, type: 'Return'}; export type CoreStellarMemoText = {value: string, type: 'Text'}; export type CoreStellarMemo = CoreStellarMemoHash | CoreStellarMemoId | CoreStellarMemoReturn | CoreStellarMemoText; export type CoreStellarFeeStrategyPriority = {priority: CoreFeePriority, type: 'Priority'}; export type CoreStellarFeeStrategySpecifiedRate = {baseFee: string, type: 'SpecifiedRate'}; export type CoreStellarFeeStrategy = CoreStellarFeeStrategyPriority | CoreStellarFeeStrategySpecifiedRate; export type CoreTransactionOrderParametersStellar = {operation: CoreStellarOperation, memo?: CoreStellarMemo | undefined, feeStrategy: CoreStellarFeeStrategy, maximumFee?: string | undefined, type: 'Stellar'}; export type CoreSubstrateBalancesMethod = {destination: CoreTransactionDestination, amount: string, type: 'TransferKeepAlive'}; export type CoreSubstratePalletBalances = {method: CoreSubstrateBalancesMethod, type: 'Balances'}; export type CoreSubstrateStakingPayeeAccount = {destination: CoreTransactionDestination, type: 'Account'}; export type CoreSubstrateStakingPayeeController = {type: 'Controller'}; export type CoreSubstrateStakingPayeeStaked = {type: 'Staked'}; export type CoreSubstrateStakingPayeeStash = {type: 'Stash'}; export type CoreSubstrateStakingPayee = CoreSubstrateStakingPayeeAccount | CoreSubstrateStakingPayeeController | CoreSubstrateStakingPayeeStaked | CoreSubstrateStakingPayeeStash; export type CoreSubstrateStakingMethodBond = {controller?: CoreTransactionDestination | undefined, value: string, payee: CoreSubstrateStakingPayee, type: 'Bond'}; export type CoreSubstrateStakingMethodBondExtra = {maxAdditional: string, type: 'BondExtra'}; export type CoreSubstrateStakingMethodChill = {type: 'Chill'}; export type CoreSubstrateStakingMethodNominate = {targets: Array, type: 'Nominate'}; export type CoreSubstrateStakingMethodRebond = {value: string, type: 'Rebond'}; export type CoreSubstrateStakingMethodSetController = {controller?: CoreTransactionDestination | undefined, type: 'SetController'}; export type CoreSubstrateStakingMethodSetPayee = {payee: CoreSubstrateStakingPayee, type: 'SetPayee'}; export type CoreSubstrateStakingMethodUnbond = {value: string, type: 'Unbond'}; export type CoreSubstrateStakingMethodWithdrawUnbonded = {numSlashingSpans: number, type: 'WithdrawUnbonded'}; export type CoreSubstrateStakingMethod = CoreSubstrateStakingMethodBond | CoreSubstrateStakingMethodBondExtra | CoreSubstrateStakingMethodChill | CoreSubstrateStakingMethodNominate | CoreSubstrateStakingMethodRebond | CoreSubstrateStakingMethodSetController | CoreSubstrateStakingMethodSetPayee | CoreSubstrateStakingMethodUnbond | CoreSubstrateStakingMethodWithdrawUnbonded; export type CoreSubstratePalletStaking = {method: CoreSubstrateStakingMethod, type: 'Staking'}; export type CoreSubstratePallet = CoreSubstratePalletBalances | CoreSubstratePalletStaking; export type CoreSubstrateFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersSubstrate = {pallet: CoreSubstratePallet, feeStrategy: CoreSubstrateFeeStrategy, maximumFee?: string | undefined, type: 'Substrate'}; export type CoreTezosOperationDelegation = {destination: CoreTransactionDestination, type: 'Delegation'}; export type CoreTezosOperationReveal = {type: 'Reveal'}; export type CoreContractParameters = {value: string, type: 'Raw'}; export type CoreTezosOperationTransaction = {destination: CoreTransactionDestination, amount: string, contractParameters?: CoreContractParameters | undefined, type: 'Transaction'}; export type CoreTezosOperationUndelegation = {type: 'Undelegation'}; export type CoreTezosOperation = CoreTezosOperationDelegation | CoreTezosOperationReveal | CoreTezosOperationTransaction | CoreTezosOperationUndelegation; export type CoreTezosFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTransactionOrderParametersTezos = {operation: CoreTezosOperation, feeStrategy: CoreTezosFeeStrategy, maximumFee?: string | undefined, type: 'Tezos'}; export type CoreTronFeeStrategy = {priority: CoreFeePriority, type: 'Priority'}; export type CoreTronOperationNativeTransfer = {destination: CoreTransactionDestination, amount: string, type: 'NativeTransfer'}; export type CoreTronOperationTRC20Transfer = {destination: CoreTransactionDestination, amount: string, contractAddress: string, type: 'TRC20Transfer'}; export type CoreTronOperation = CoreTronOperationNativeTransfer | CoreTronOperationTRC20Transfer; export type CoreTransactionOrderParametersTron = {feeStrategy: CoreTronFeeStrategy, maximumFee?: string | undefined, operation: CoreTronOperation, type: 'Tron'}; export type CoreXrplFeeStrategyPriority = {priority: CoreFeePriority, type: 'Priority'}; export type CoreXrplFeeStrategySpecifiedAdditionalFee = {drops: string, type: 'SpecifiedAdditionalFee'}; export type CoreXrplFeeStrategy = CoreXrplFeeStrategyPriority | CoreXrplFeeStrategySpecifiedAdditionalFee; export type CoreXrplMemo = {memoData?: string | undefined, memoFormat?: string | undefined, memoType?: string | undefined}; export type CoreXrplAccountSetFlag = 'asfGlobalFreeze' | 'asfNoFreeze' | 'asfRequireAuth' | 'asfAllowTrustLineClawback' | 'asfAccountTxnID' | 'asfDepositAuth' | 'asfRequireDest' | 'asfDefaultRipple'; export type CoreXrplOperationAccountSet = {setFlag?: CoreXrplAccountSetFlag | undefined, clearFlag?: CoreXrplAccountSetFlag | undefined, transferRate?: number | undefined, type: 'AccountSet'}; export type CoreXrplClawbackCurrencyCurrency = {code: string, issuer: string, type: 'Currency'}; export type CoreXrplClawbackCurrencyMultiPurposeToken = {issuanceId: string, type: 'MultiPurposeToken'}; export type CoreXrplClawbackCurrencyTickerId = {tickerId: string, type: 'TickerId'}; export type CoreXrplClawbackCurrency = CoreXrplClawbackCurrencyCurrency | CoreXrplClawbackCurrencyMultiPurposeToken | CoreXrplClawbackCurrencyTickerId; export type CoreXrplOperationClawback = {currency: CoreXrplClawbackCurrency, holder: CoreTransactionDestination, value: string, type: 'Clawback'}; export type CoreXrplOperationDepositPreauth = {authorize?: CoreTransactionDestination | undefined, unauthorize?: CoreTransactionDestination | undefined, type: 'DepositPreauth'}; export type CoreXrplOperationEscrowFinish = {owner: CoreTransactionDestination, offerSequence: number, condition?: string | undefined, credentialIds?: Array | undefined, fulfillment?: string | undefined, type: 'EscrowFinish'}; export type CoreXrplMPTokenIdentifierMPTokenIssuanceId = {issuanceId: string, type: 'MPTokenIssuanceId'}; export type CoreXrplMPTokenIdentifierTickerId = {tickerId: string, type: 'TickerId'}; export type CoreXrplMPTokenIdentifier = CoreXrplMPTokenIdentifierMPTokenIssuanceId | CoreXrplMPTokenIdentifierTickerId; export type CoreXrplMPTokenAuthorizeFlag = 'tfMPTUnauthorize'; export type CoreXrplOperationMPTokenAuthorize = {tokenIdentifier: CoreXrplMPTokenIdentifier, flags: Array, holder?: CoreTransactionDestination | undefined, type: 'MPTokenAuthorize'}; export type CoreXrplMPTokenIssuanceCreateFlag = 'tfMPTRequireAuth' | 'tfMPTCanClawback' | 'tfMPTCanTransfer' | 'tfMPTCanEscrow' | 'tfMPTCanLock' | 'tfMPTCanTrade'; export type CoreMPTokenIssuanceMetadata = {value: string, type: 'HexEncodedMetadata'}; export type CoreXrplOperationMPTokenIssuanceCreate = {flags: Array, assetScale?: number | undefined, transferFee?: number | undefined, maximumAmount?: string | undefined, metadata?: CoreMPTokenIssuanceMetadata | undefined, type: 'MPTokenIssuanceCreate'}; export type CoreXrplOperationMPTokenIssuanceDestroy = {tokenIdentifier: CoreXrplMPTokenIdentifier, type: 'MPTokenIssuanceDestroy'}; export type CoreXrplMPTokenIssuanceSetFlag = 'tfMPTLock' | 'tfMPTUnlock'; export type CoreXrplOperationMPTokenIssuanceSet = {tokenIdentifier: CoreXrplMPTokenIdentifier, holder?: CoreTransactionDestination | undefined, flags: Array, type: 'MPTokenIssuanceSet'}; export type CoreXrplOfferCreateFlag = 'tfImmediateOrCancel' | 'tfFillOrKill' | 'tfSell'; export type CoreXrplIouCurrencyCurrency = {code: string, issuer: string, type: 'Currency'}; export type CoreXrplIouCurrencyTickerId = {tickerId: string, type: 'TickerId'}; export type CoreXrplIouCurrency = CoreXrplIouCurrencyCurrency | CoreXrplIouCurrencyTickerId; export type CoreXrplAssetQuantity = {currency?: CoreXrplIouCurrency | undefined, amount: string}; export type CoreXrplOperationOfferCreate = {flags: Array, takerGets: CoreXrplAssetQuantity, takerPays: CoreXrplAssetQuantity, type: 'OfferCreate'}; export type CoreXrplPaymentCurrencyCurrency = {code: string, issuer: string, type: 'Currency'}; export type CoreXrplPaymentCurrencyMultiPurposeToken = {issuanceId: string, type: 'MultiPurposeToken'}; export type CoreXrplPaymentCurrencyTickerId = {tickerId: string, type: 'TickerId'}; export type CoreXrplPaymentCurrency = CoreXrplPaymentCurrencyCurrency | CoreXrplPaymentCurrencyMultiPurposeToken | CoreXrplPaymentCurrencyTickerId; export type CoreXrplOperationPayment = {destination: CoreTransactionDestination, amount: string, destinationTag?: number | undefined, currency?: CoreXrplPaymentCurrency | undefined, type: 'Payment'}; export type CoreXrplTrustSetFlag = 'tfSetFreeze' | 'tfClearFreeze' | 'tfSetfAuth'; export type CoreXrplLimitAmount = {currency: CoreXrplIouCurrency, value: string}; export type CoreXrplOperationTrustSet = {flags: Array, limitAmount: CoreXrplLimitAmount, enableRippling?: boolean | undefined, type: 'TrustSet'}; export type CoreXrplOperation = CoreXrplOperationAccountSet | CoreXrplOperationClawback | CoreXrplOperationDepositPreauth | CoreXrplOperationEscrowFinish | CoreXrplOperationMPTokenAuthorize | CoreXrplOperationMPTokenIssuanceCreate | CoreXrplOperationMPTokenIssuanceDestroy | CoreXrplOperationMPTokenIssuanceSet | CoreXrplOperationOfferCreate | CoreXrplOperationPayment | CoreXrplOperationTrustSet; export type CoreTransactionOrderParametersXRPL = {destination?: CoreTransactionDestination | undefined, amount?: string | undefined, feeStrategy: CoreXrplFeeStrategy, maximumFee?: string | undefined, sourceTag?: number | undefined, destinationTag?: number | undefined, memos: Array, operation?: CoreXrplOperation | undefined, type: 'XRPL'}; export type CoreTransactionOrderParameters = CoreTransactionOrderParametersAlgorand | CoreTransactionOrderParametersBitcoin | CoreTransactionOrderParametersBitcoinRedirect | CoreTransactionOrderParametersCardano | CoreTransactionOrderParametersEthereum | CoreTransactionOrderParametersHedera | CoreTransactionOrderParametersSolana | CoreTransactionOrderParametersStellar | CoreTransactionOrderParametersSubstrate | CoreTransactionOrderParametersTezos | CoreTransactionOrderParametersTron | CoreTransactionOrderParametersXRPL; export type CoreDryRunTransactionParameters = {accountId: string, ledgerId?: string | undefined, parameters: CoreTransactionOrderParameters}; export type CreateApiV1DomainsDomainIdTransactionsDryRunArgs = {domainId: string, body: CoreDryRunTransactionParameters}; export type CreateApiV1DomainsDomainIdTransactionsDryRunOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const coreApiDryRunTransactionProcessingHint = z.enum(["AccountAlreadyActivatedOnLedger", "AccountNotReadyOnLedger", "BroadcastExpired", "CurrentlyFeesTooLarge", "CurrentlyFeesTooSmall", "CurrentlyFundsTooFragmented", "CurrentlyNotEnoughFunds", "CurrentlyUnusableDestination", "InternalError", "InvalidAccountStateOnLedger", "InvalidAmount", "InvalidContractParameters", "InvalidDestination", "InvalidUserPayload", "LockedDestination", "OnLedgerFailure", "ReplacementTransactionFeesTooLow", "TransactionEstimationFailure", "TransactionNotEligibleForReplacement", "TransactionRejected", "TransientIssue"]); export const coreTransactionDryRunResultFailure = z.object({hint: coreApiDryRunTransactionProcessingHint, reason: z.string(), type: z.literal("Failure")}); export const coreTransactionDryRunResultSuccess = z.object({type: z.literal("Success")}); export const coreTransactionDryRunResult = z.discriminatedUnion("type", [coreTransactionDryRunResultFailure, coreTransactionDryRunResultSuccess]); export const coreTransactionEstimateAlgorand = z.object({fee: z.string(), type: z.literal("Algorand")}); export const coreTransactionEstimateBitcoin = z.object({vbytes: z.string(), fee: z.string(), feeEstimationMargin: z.string(), type: z.literal("Bitcoin")}); export const coreTransactionEstimateCardano = z.object({fee: z.string(), type: z.literal("Cardano")}); export const coreTransactionEstimateEthereum = z.object({gas: z.string(), defaultedToBlockGasLimit: z.boolean(), nodeErrorMessage: z.string().optional(), type: z.literal("Ethereum")}); export const coreTransactionEstimateFailure = z.object({hint: coreApiDryRunTransactionProcessingHint, reason: z.string(), type: z.literal("Failure")}); export const coreTokenFee = z.object({fee: z.string(), tickerId: z.string(), paidByRecipient: z.boolean()}); export const coreTransactionEstimateHedera = z.object({fee: z.string(), tokenFees: z.array(coreTokenFee).optional(), type: z.literal("Hedera")}); export const coreTransactionEstimateSolana = z.object({fee: z.string(), type: z.literal("Solana")}); export const coreTransactionEstimateStellar = z.object({fee: z.string(), type: z.literal("Stellar")}); export const coreTransactionEstimateSubstrate = z.object({fee: z.string(), type: z.literal("Substrate")}); export const coreTransactionEstimateTezos = z.object({minimalFee: z.string(), fee: z.string(), type: z.literal("Tezos")}); export const coreTransactionEstimateTron = z.object({fee: z.string(), type: z.literal("Tron")}); export const coreTransactionEstimateXRPL = z.object({minimumCostInDrops: z.string(), fee: z.string(), totalReserveRequired: z.string().optional(), type: z.literal("XRPL")}); export const coreTransactionEstimate = z.discriminatedUnion("type", [coreTransactionEstimateAlgorand, coreTransactionEstimateBitcoin, coreTransactionEstimateCardano, coreTransactionEstimateEthereum, coreTransactionEstimateFailure, coreTransactionEstimateHedera, coreTransactionEstimateSolana, coreTransactionEstimateStellar, coreTransactionEstimateSubstrate, coreTransactionEstimateTezos, coreTransactionEstimateTron, coreTransactionEstimateXRPL]); export const coreTransactionDryRun = z.object({result: coreTransactionDryRunResult, estimate: coreTransactionEstimate}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Dry run a transaction order * * POST /v1/domains/{domainId}/transactions/dry-run */ export const createApiV1DomainsDomainIdTransactionsDryRun = async (args: CreateApiV1DomainsDomainIdTransactionsDryRunArgs, options: CreateApiV1DomainsDomainIdTransactionsDryRunOptions) => { const {baseUrl, fetch: fetchFn = fetch, httpAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (httpAuth !== undefined) headers.set('authorization', `Bearer ${httpAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/domains/${encodeURIComponent(String(args.domainId))}/transactions/dry-run${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(coreTransactionDryRun, await res.json()) };