@lifi/sdk-provider-solana 4.3.7 → 4.3.8
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 +8 -0
- package/dist/cjs/SolanaProvider.d.ts +1 -4
- package/dist/cjs/SolanaProvider.js +1 -2
- package/dist/cjs/SolanaProvider.js.map +1 -1
- package/dist/cjs/actions/getSNSAddress.d.ts +1 -4
- package/dist/cjs/actions/getSNSAddress.js +1 -2
- package/dist/cjs/actions/getSolanaBalance.d.ts +1 -4
- package/dist/cjs/actions/getSolanaBalance.js +1 -2
- package/dist/cjs/actions/lookupSignatureStatus.d.ts +1 -4
- package/dist/cjs/actions/lookupSignatureStatus.js +2 -3
- package/dist/cjs/actions/resolveSolanaAddress.d.ts +1 -4
- package/dist/cjs/actions/resolveSolanaAddress.js +1 -2
- package/dist/cjs/actions/sendAndConfirmBundle.d.ts +1 -4
- package/dist/cjs/actions/sendAndConfirmBundle.js +3 -4
- package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +2 -5
- package/dist/cjs/actions/sendAndConfirmTransaction.js +3 -4
- package/dist/cjs/confirmation/abortableSleep.d.ts +1 -4
- package/dist/cjs/confirmation/abortableSleep.js +1 -2
- package/dist/cjs/confirmation/confirmBundle.d.ts +2 -5
- package/dist/cjs/confirmation/confirmBundle.js +1 -2
- package/dist/cjs/confirmation/confirmSignature.d.ts +2 -5
- package/dist/cjs/confirmation/confirmSignature.js +2 -3
- package/dist/cjs/confirmation/createConfirmationDeadline.d.ts +1 -4
- package/dist/cjs/confirmation/createConfirmationDeadline.js +1 -2
- package/dist/cjs/confirmation/pollUntilDeadline.d.ts +2 -5
- package/dist/cjs/confirmation/pollUntilDeadline.js +1 -2
- package/dist/cjs/confirmation/raceRpcs.d.ts +1 -4
- package/dist/cjs/confirmation/raceRpcs.js +1 -2
- package/dist/cjs/confirmation/raceRpcs.js.map +1 -1
- package/dist/cjs/confirmation/types.d.ts +1 -4
- package/dist/cjs/confirmation/types.js +1 -2
- package/dist/cjs/core/SolanaStepExecutor.d.ts +1 -4
- package/dist/cjs/core/SolanaStepExecutor.js +1 -2
- package/dist/cjs/core/SolanaStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +1 -4
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +4 -5
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.d.ts +1 -4
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +1 -2
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +1 -4
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +4 -5
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.d.ts +1 -4
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js +1 -2
- package/dist/cjs/core/tasks/confirmationError.d.ts +1 -4
- package/dist/cjs/core/tasks/confirmationError.js +1 -2
- package/dist/cjs/core/tasks/readSignature.d.ts +1 -4
- package/dist/cjs/core/tasks/readSignature.js +1 -2
- package/dist/cjs/core/tasks/resumeFromStore.d.ts +2 -5
- package/dist/cjs/core/tasks/resumeFromStore.js +3 -4
- package/dist/cjs/core/tasks/resumeFromStore.js.map +1 -1
- package/dist/cjs/core/tasks/transactionOutcome.d.ts +3 -6
- package/dist/cjs/core/tasks/transactionOutcome.js +3 -4
- package/dist/cjs/core/tasks/transactionOutcome.js.map +1 -1
- package/dist/cjs/errors/parseSolanaErrors.d.ts +1 -4
- package/dist/cjs/errors/parseSolanaErrors.js +1 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/rpc/jito/api/getBundleStatuses.d.ts +1 -4
- package/dist/cjs/rpc/jito/api/getTipAccounts.d.ts +1 -4
- package/dist/cjs/rpc/jito/api/sendBundle.d.ts +1 -4
- package/dist/cjs/rpc/jito/api/simulateBundle.d.ts +1 -4
- package/dist/cjs/rpc/jito/createJitoRpc.d.ts +1 -4
- package/dist/cjs/rpc/jito/createJitoRpc.js +1 -2
- package/dist/cjs/rpc/jito/types.d.ts +1 -4
- package/dist/cjs/rpc/registry.d.ts +1 -4
- package/dist/cjs/rpc/registry.js +1 -2
- package/dist/cjs/rpc/types.d.ts +1 -4
- package/dist/cjs/rpc/utils.d.ts +1 -4
- package/dist/cjs/rpc/utils.js +1 -2
- package/dist/cjs/types.d.ts +1 -4
- package/dist/cjs/types.js +1 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/KeypairWallet.unit.helpers.d.ts +1 -4
- package/dist/cjs/utils/KeypairWallet.unit.helpers.js +1 -2
- package/dist/cjs/utils/KeypairWalletAdapter.d.ts +1 -4
- package/dist/cjs/utils/KeypairWalletAdapter.js +1 -2
- package/dist/cjs/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/cjs/utils/base64ToUint8Array.d.ts +1 -4
- package/dist/cjs/utils/base64ToUint8Array.js +1 -2
- package/dist/cjs/utils/getTransactionLifetime.d.ts +1 -4
- package/dist/cjs/utils/getTransactionLifetime.js +1 -2
- package/dist/cjs/utils/getWalletFeature.d.ts +1 -4
- package/dist/cjs/utils/getWalletFeature.js +1 -2
- package/dist/cjs/utils/getWalletFeature.js.map +1 -1
- package/dist/cjs/utils/solanaErrorCause.d.ts +1 -4
- package/dist/cjs/utils/solanaErrorCause.js +1 -2
- package/dist/cjs/utils/solanaErrorCause.js.map +1 -1
- package/dist/cjs/utils/storedTransactions.d.ts +1 -4
- package/dist/cjs/utils/storedTransactions.js +1 -2
- package/dist/cjs/version.d.ts +1 -4
- package/dist/cjs/version.js +2 -3
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/SolanaProvider.d.ts +0 -2
- package/dist/esm/SolanaProvider.d.ts.map +1 -1
- package/dist/esm/SolanaProvider.js +1 -2
- package/dist/esm/actions/getSNSAddress.d.ts +0 -2
- package/dist/esm/actions/getSNSAddress.d.ts.map +1 -1
- package/dist/esm/actions/getSNSAddress.js +1 -2
- package/dist/esm/actions/getSolanaBalance.d.ts +0 -2
- package/dist/esm/actions/getSolanaBalance.d.ts.map +1 -1
- package/dist/esm/actions/getSolanaBalance.js +1 -2
- package/dist/esm/actions/lookupSignatureStatus.d.ts +0 -2
- package/dist/esm/actions/lookupSignatureStatus.d.ts.map +1 -1
- package/dist/esm/actions/lookupSignatureStatus.js +2 -3
- package/dist/esm/actions/resolveSolanaAddress.d.ts +0 -2
- package/dist/esm/actions/resolveSolanaAddress.d.ts.map +1 -1
- package/dist/esm/actions/resolveSolanaAddress.js +1 -2
- package/dist/esm/actions/sendAndConfirmBundle.d.ts +0 -2
- package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -1
- package/dist/esm/actions/sendAndConfirmBundle.js +3 -4
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts +1 -3
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -1
- package/dist/esm/actions/sendAndConfirmTransaction.js +3 -4
- package/dist/esm/confirmation/abortableSleep.d.ts +0 -2
- package/dist/esm/confirmation/abortableSleep.d.ts.map +1 -1
- package/dist/esm/confirmation/abortableSleep.js +1 -2
- package/dist/esm/confirmation/confirmBundle.d.ts +1 -3
- package/dist/esm/confirmation/confirmBundle.d.ts.map +1 -1
- package/dist/esm/confirmation/confirmBundle.js +1 -2
- package/dist/esm/confirmation/confirmSignature.d.ts +1 -3
- package/dist/esm/confirmation/confirmSignature.d.ts.map +1 -1
- package/dist/esm/confirmation/confirmSignature.js +2 -3
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts +0 -2
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts.map +1 -1
- package/dist/esm/confirmation/createConfirmationDeadline.js +1 -2
- package/dist/esm/confirmation/pollUntilDeadline.d.ts +1 -3
- package/dist/esm/confirmation/pollUntilDeadline.d.ts.map +1 -1
- package/dist/esm/confirmation/pollUntilDeadline.js +1 -2
- package/dist/esm/confirmation/raceRpcs.d.ts +0 -2
- package/dist/esm/confirmation/raceRpcs.d.ts.map +1 -1
- package/dist/esm/confirmation/raceRpcs.js +1 -2
- package/dist/esm/confirmation/raceRpcs.js.map +1 -1
- package/dist/esm/confirmation/types.d.ts +0 -2
- package/dist/esm/confirmation/types.d.ts.map +1 -1
- package/dist/esm/confirmation/types.js +1 -2
- package/dist/esm/core/SolanaStepExecutor.d.ts +0 -2
- package/dist/esm/core/SolanaStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/SolanaStepExecutor.js +1 -2
- package/dist/esm/core/SolanaStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +0 -2
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +4 -5
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts +0 -2
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +1 -2
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +0 -2
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +4 -5
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts +0 -2
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js +1 -2
- package/dist/esm/core/tasks/confirmationError.d.ts +0 -2
- package/dist/esm/core/tasks/confirmationError.d.ts.map +1 -1
- package/dist/esm/core/tasks/confirmationError.js +1 -2
- package/dist/esm/core/tasks/readSignature.d.ts +0 -2
- package/dist/esm/core/tasks/readSignature.d.ts.map +1 -1
- package/dist/esm/core/tasks/readSignature.js +1 -2
- package/dist/esm/core/tasks/resumeFromStore.d.ts +1 -3
- package/dist/esm/core/tasks/resumeFromStore.d.ts.map +1 -1
- package/dist/esm/core/tasks/resumeFromStore.js +3 -4
- package/dist/esm/core/tasks/resumeFromStore.js.map +1 -1
- package/dist/esm/core/tasks/transactionOutcome.d.ts +2 -4
- package/dist/esm/core/tasks/transactionOutcome.d.ts.map +1 -1
- package/dist/esm/core/tasks/transactionOutcome.js +3 -4
- package/dist/esm/core/tasks/transactionOutcome.js.map +1 -1
- package/dist/esm/errors/parseSolanaErrors.d.ts +0 -2
- package/dist/esm/errors/parseSolanaErrors.d.ts.map +1 -1
- package/dist/esm/errors/parseSolanaErrors.js +1 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts +0 -2
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts.map +1 -1
- package/dist/esm/rpc/jito/api/getTipAccounts.d.ts +0 -2
- package/dist/esm/rpc/jito/api/getTipAccounts.d.ts.map +1 -1
- package/dist/esm/rpc/jito/api/sendBundle.d.ts +0 -2
- package/dist/esm/rpc/jito/api/sendBundle.d.ts.map +1 -1
- package/dist/esm/rpc/jito/api/simulateBundle.d.ts +0 -2
- package/dist/esm/rpc/jito/api/simulateBundle.d.ts.map +1 -1
- package/dist/esm/rpc/jito/createJitoRpc.d.ts +0 -2
- package/dist/esm/rpc/jito/createJitoRpc.d.ts.map +1 -1
- package/dist/esm/rpc/jito/createJitoRpc.js +1 -2
- package/dist/esm/rpc/jito/types.d.ts +0 -2
- package/dist/esm/rpc/jito/types.d.ts.map +1 -1
- package/dist/esm/rpc/registry.d.ts +0 -2
- package/dist/esm/rpc/registry.d.ts.map +1 -1
- package/dist/esm/rpc/registry.js +1 -2
- package/dist/esm/rpc/types.d.ts +0 -2
- package/dist/esm/rpc/types.d.ts.map +1 -1
- package/dist/esm/rpc/utils.d.ts +0 -2
- package/dist/esm/rpc/utils.d.ts.map +1 -1
- package/dist/esm/rpc/utils.js +1 -2
- package/dist/esm/types.d.ts +0 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts +0 -2
- package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts.map +1 -1
- package/dist/esm/utils/KeypairWallet.unit.helpers.js +1 -2
- package/dist/esm/utils/KeypairWalletAdapter.d.ts +0 -2
- package/dist/esm/utils/KeypairWalletAdapter.d.ts.map +1 -1
- package/dist/esm/utils/KeypairWalletAdapter.js +1 -2
- package/dist/esm/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/esm/utils/base64ToUint8Array.d.ts +0 -2
- package/dist/esm/utils/base64ToUint8Array.d.ts.map +1 -1
- package/dist/esm/utils/base64ToUint8Array.js +1 -2
- package/dist/esm/utils/getTransactionLifetime.d.ts +0 -2
- package/dist/esm/utils/getTransactionLifetime.d.ts.map +1 -1
- package/dist/esm/utils/getTransactionLifetime.js +1 -2
- package/dist/esm/utils/getWalletFeature.d.ts +0 -2
- package/dist/esm/utils/getWalletFeature.d.ts.map +1 -1
- package/dist/esm/utils/getWalletFeature.js +1 -2
- package/dist/esm/utils/getWalletFeature.js.map +1 -1
- package/dist/esm/utils/solanaErrorCause.d.ts +0 -2
- package/dist/esm/utils/solanaErrorCause.d.ts.map +1 -1
- package/dist/esm/utils/solanaErrorCause.js +1 -2
- package/dist/esm/utils/solanaErrorCause.js.map +1 -1
- package/dist/esm/utils/storedTransactions.d.ts +0 -2
- package/dist/esm/utils/storedTransactions.d.ts.map +1 -1
- package/dist/esm/utils/storedTransactions.js +1 -2
- package/dist/esm/version.d.ts +1 -3
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +2 -3
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
- package/src/confirmation/raceRpcs.ts +4 -3
- package/src/core/tasks/resumeFromStore.ts +1 -1
- package/src/core/tasks/transactionOutcome.ts +1 -1
- package/src/index.ts +1 -5
- package/src/types.ts +1 -2
- package/src/utils/getWalletFeature.ts +1 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaJitoWaitForTransactionTask.js","names":["failureOf","BaseStepExecutionTask","TransactionError","LiFiErrorCode","resumeFromStore","readSignature","getTransactionLifetime","getTxLink","sendAndSettle","canResendStored","sendAndConfirmBundle"],"sources":["../../../../src/core/tasks/SolanaJitoWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature, Transaction } from '@solana/kit'\nimport { sendAndConfirmBundle } from '../../actions/sendAndConfirmBundle.js'\nimport type { BundleConfirmation } from '../../confirmation/confirmBundle.js'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport type { ConfirmationMessages } from './confirmationError.js'\nimport { readSignature } from './readSignature.js'\nimport { resumeFromStore } from './resumeFromStore.js'\nimport {\n canResendStored,\n clearStoredTransactions,\n failureOf,\n getTxLink,\n sendAndSettle,\n} from './transactionOutcome.js'\n\n// The `rpc-unavailable` message is distinct from the empty-list throw inside\n// `sendAndConfirmBundle`: RPCs were configured and every one of them failed.\n// Every read RPC confirms and waits for the one shared submission, so a\n// refused submission fails every branch with the same error.\nconst MESSAGES: ConfirmationMessages = {\n rpcUnavailable:\n 'Unable to confirm bundle: every configured Solana RPC failed.',\n notConfirmed: 'Bundle was not confirmed before the SDK stopped waiting.',\n allRpcsFailed: 'All Solana RPCs failed',\n someRpcsFailed:\n 'Some Solana RPCs failed while the confirmation window was open',\n}\n\n/** The failure of a landed bundle, if any: the first transaction `err`. */\nfunction bundleFailureOf(\n confirmation: BundleConfirmation\n): { err: unknown } | undefined {\n return confirmation.signatureResults.map(failureOf).find(Boolean)\n}\n\nexport class SolanaJitoWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, isBridgeExecution, signedTransactions } =\n context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resume mode: the sign task did not run in this session, so the signed\n // bundle comes from `txHex`, or only the first hash from `txHash`.\n if (!signedTransactions) {\n return resumeFromStore(context, action, {\n messages: MESSAGES,\n // Submitted once, as on the first run.\n send: (stored, lifetimes) =>\n sendSigned(context, action, {\n transactions: stored.transactions,\n signature: stored.signature,\n lifetimes,\n resuming: true,\n }),\n })\n }\n\n if (!signedTransactions.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Signed transactions are not found.'\n )\n }\n\n let txSignature: Signature\n try {\n txSignature = readSignature(signedTransactions[0])\n } catch (error) {\n // Nothing left the SDK: the bytes go, so \"Try again\" signs again.\n clearStoredTransactions(context, action)\n throw error\n }\n\n const lifetimes = await Promise.all(\n signedTransactions.map((transaction) =>\n getTransactionLifetime(transaction)\n )\n )\n\n return sendSigned(context, action, {\n transactions: signedTransactions,\n signature: txSignature,\n lifetimes,\n resuming: false,\n })\n }\n}\n\n/**\n * Submits the signed bundle once, confirms it and applies the result rules\n * of `sendAndSettle`, on the first run and on a resume alike. A Jito bundle\n * lands whole or not at all, so the first transaction's signature stands for\n * it. A sender that is not Jito can land the transactions one by one; a\n * lookup by the first signature then misses a partial landing.\n */\nfunction sendSigned(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n transactions: Transaction[]\n signature: Signature\n lifetimes: TransactionLifetime[]\n /** An earlier run may already have submitted this bundle. */\n resuming: boolean\n }\n): Promise<TaskResult> {\n const { client, step, statusManager } = context\n const { transactions, signature, lifetimes, resuming } = options\n const txLink = getTxLink(context, signature)\n\n return sendAndSettle(context, action, {\n signature,\n send: async (): Promise<RaceResult<BundleConfirmation>> => {\n // Read right before the one submission: a bundle without its own\n // expiry goes out only inside the resend age cap. Past it nothing is\n // sent, and the outcome stays unknown until the dropped rule holds.\n if (!canResendStored(lifetimes, step.execution?.signedAt)) {\n return {\n kind: 'not-confirmed',\n errors: [\n new Error(\n 'The resend age cap has passed; the stored bundle is not sent.'\n ),\n ],\n }\n }\n // An empty Jito RPC list - the configuration gap, as opposed to an\n // outage - throws inside `sendAndConfirmBundle` with its own message,\n // before anything is submitted.\n return sendAndConfirmBundle(client, transactions, {\n onBroadcast: () => {\n // The earliest honest point for both: an RPC has accepted the\n // transaction, so the signature now resolves on chain.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink,\n })\n },\n })\n },\n confirmedFailure: bundleFailureOf,\n resuming,\n messages: MESSAGES,\n })\n}\n"],"mappings":";;;;;;;;AA+BA,MAAM,WAAiC;CACrC,gBACE;CACF,cAAc;CACd,eAAe;CACf,gBACE;AACJ;;AAGA,SAAS,gBACP,cAC8B;CAC9B,OAAO,aAAa,iBAAiB,IAAIA,sCAAAA,SAAS,CAAC,CAAC,KAAK,OAAO;AAClE;AAEA,IAAa,mCAAb,cAAsDC,UAAAA,sBAAsB;CAC1E,MAAM,IAAI,SAAyD;EACjE,MAAM,EAAE,MAAM,eAAe,mBAAmB,uBAC9C;EAEF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAKF,IAAI,CAAC,oBACH,OAAOC,mCAAAA,gBAAgB,SAAS,QAAQ;GACtC,UAAU;GAEV,OAAO,QAAQ,cACb,WAAW,SAAS,QAAQ;IAC1B,cAAc,OAAO;IACrB,WAAW,OAAO;IAClB;IACA,UAAU;GACZ,CAAC;EACL,CAAC;EAGH,IAAI,CAAC,mBAAmB,QACtB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mEACF;EAGF,IAAI;EACJ,IAAI;GACF,cAAcE,iCAAAA,cAAc,mBAAmB,EAAE;EACnD,SAAS,OAAO;
|
|
1
|
+
{"version":3,"file":"SolanaJitoWaitForTransactionTask.js","names":["failureOf","BaseStepExecutionTask","TransactionError","LiFiErrorCode","resumeFromStore","readSignature","clearStoredTransactions","getTransactionLifetime","getTxLink","sendAndSettle","canResendStored","sendAndConfirmBundle"],"sources":["../../../../src/core/tasks/SolanaJitoWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature, Transaction } from '@solana/kit'\nimport { sendAndConfirmBundle } from '../../actions/sendAndConfirmBundle.js'\nimport type { BundleConfirmation } from '../../confirmation/confirmBundle.js'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport type { ConfirmationMessages } from './confirmationError.js'\nimport { readSignature } from './readSignature.js'\nimport { resumeFromStore } from './resumeFromStore.js'\nimport {\n canResendStored,\n clearStoredTransactions,\n failureOf,\n getTxLink,\n sendAndSettle,\n} from './transactionOutcome.js'\n\n// The `rpc-unavailable` message is distinct from the empty-list throw inside\n// `sendAndConfirmBundle`: RPCs were configured and every one of them failed.\n// Every read RPC confirms and waits for the one shared submission, so a\n// refused submission fails every branch with the same error.\nconst MESSAGES: ConfirmationMessages = {\n rpcUnavailable:\n 'Unable to confirm bundle: every configured Solana RPC failed.',\n notConfirmed: 'Bundle was not confirmed before the SDK stopped waiting.',\n allRpcsFailed: 'All Solana RPCs failed',\n someRpcsFailed:\n 'Some Solana RPCs failed while the confirmation window was open',\n}\n\n/** The failure of a landed bundle, if any: the first transaction `err`. */\nfunction bundleFailureOf(\n confirmation: BundleConfirmation\n): { err: unknown } | undefined {\n return confirmation.signatureResults.map(failureOf).find(Boolean)\n}\n\nexport class SolanaJitoWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, isBridgeExecution, signedTransactions } =\n context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resume mode: the sign task did not run in this session, so the signed\n // bundle comes from `txHex`, or only the first hash from `txHash`.\n if (!signedTransactions) {\n return resumeFromStore(context, action, {\n messages: MESSAGES,\n // Submitted once, as on the first run.\n send: (stored, lifetimes) =>\n sendSigned(context, action, {\n transactions: stored.transactions,\n signature: stored.signature,\n lifetimes,\n resuming: true,\n }),\n })\n }\n\n if (!signedTransactions.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Signed transactions are not found.'\n )\n }\n\n let txSignature: Signature\n try {\n txSignature = readSignature(signedTransactions[0])\n } catch (error) {\n // Nothing left the SDK: the bytes go, so \"Try again\" signs again.\n clearStoredTransactions(context, action)\n throw error\n }\n\n const lifetimes = await Promise.all(\n signedTransactions.map((transaction) =>\n getTransactionLifetime(transaction)\n )\n )\n\n return sendSigned(context, action, {\n transactions: signedTransactions,\n signature: txSignature,\n lifetimes,\n resuming: false,\n })\n }\n}\n\n/**\n * Submits the signed bundle once, confirms it and applies the result rules\n * of `sendAndSettle`, on the first run and on a resume alike. A Jito bundle\n * lands whole or not at all, so the first transaction's signature stands for\n * it. A sender that is not Jito can land the transactions one by one; a\n * lookup by the first signature then misses a partial landing.\n */\nfunction sendSigned(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n transactions: Transaction[]\n signature: Signature\n lifetimes: TransactionLifetime[]\n /** An earlier run may already have submitted this bundle. */\n resuming: boolean\n }\n): Promise<TaskResult> {\n const { client, step, statusManager } = context\n const { transactions, signature, lifetimes, resuming } = options\n const txLink = getTxLink(context, signature)\n\n return sendAndSettle(context, action, {\n signature,\n send: async (): Promise<RaceResult<BundleConfirmation>> => {\n // Read right before the one submission: a bundle without its own\n // expiry goes out only inside the resend age cap. Past it nothing is\n // sent, and the outcome stays unknown until the dropped rule holds.\n if (!canResendStored(lifetimes, step.execution?.signedAt)) {\n return {\n kind: 'not-confirmed',\n errors: [\n new Error(\n 'The resend age cap has passed; the stored bundle is not sent.'\n ),\n ],\n }\n }\n // An empty Jito RPC list - the configuration gap, as opposed to an\n // outage - throws inside `sendAndConfirmBundle` with its own message,\n // before anything is submitted.\n return sendAndConfirmBundle(client, transactions, {\n onBroadcast: () => {\n // The earliest honest point for both: an RPC has accepted the\n // transaction, so the signature now resolves on chain.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink,\n })\n },\n })\n },\n confirmedFailure: bundleFailureOf,\n resuming,\n messages: MESSAGES,\n })\n}\n"],"mappings":";;;;;;;;AA+BA,MAAM,WAAiC;CACrC,gBACE;CACF,cAAc;CACd,eAAe;CACf,gBACE;AACJ;;AAGA,SAAS,gBACP,cAC8B;CAC9B,OAAO,aAAa,iBAAiB,IAAIA,sCAAAA,SAAS,CAAC,CAAC,KAAK,OAAO;AAClE;AAEA,IAAa,mCAAb,cAAsDC,UAAAA,sBAAsB;CAC1E,MAAM,IAAI,SAAyD;EACjE,MAAM,EAAE,MAAM,eAAe,mBAAmB,uBAC9C;EAEF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAKF,IAAI,CAAC,oBACH,OAAOC,mCAAAA,gBAAgB,SAAS,QAAQ;GACtC,UAAU;GAEV,OAAO,QAAQ,cACb,WAAW,SAAS,QAAQ;IAC1B,cAAc,OAAO;IACrB,WAAW,OAAO;IAClB;IACA,UAAU;GACZ,CAAC;EACL,CAAC;EAGH,IAAI,CAAC,mBAAmB,QACtB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mEACF;EAGF,IAAI;EACJ,IAAI;GACF,cAAcE,iCAAAA,cAAc,mBAAmB,EAAE;EACnD,SAAS,OAAO;GAEdC,sCAAAA,wBAAwB,SAAS,MAAM;GACvC,MAAM;EACR;EAEA,MAAM,YAAY,MAAM,QAAQ,IAC9B,mBAAmB,KAAK,gBACtBC,qCAAAA,uBAAuB,WAAW,CACpC,CACF;EAEA,OAAO,WAAW,SAAS,QAAQ;GACjC,cAAc;GACd,WAAW;GACX;GACA,UAAU;EACZ,CAAC;CACH;AACF;;;;;;;;AASA,SAAS,WACP,SACA,QACA,SAOqB;CACrB,MAAM,EAAE,QAAQ,MAAM,kBAAkB;CACxC,MAAM,EAAE,cAAc,WAAW,WAAW,aAAa;CACzD,MAAM,SAASC,sCAAAA,UAAU,SAAS,SAAS;CAE3C,OAAOC,sCAAAA,cAAc,SAAS,QAAQ;EACpC;EACA,MAAM,YAAqD;GAIzD,IAAI,CAACC,sCAAAA,gBAAgB,WAAW,KAAK,WAAW,QAAQ,GACtD,OAAO;IACL,MAAM;IACN,QAAQ,iBACN,IAAI,MACF,+DACF,CACF;GACF;GAKF,OAAOC,qCAAAA,qBAAqB,QAAQ,cAAc,EAChD,mBAAmB;IAGjB,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;KACvD,QAAQ;KACR;IACF,CAAC;GACH,EACF,CAAC;EACH;EACA,kBAAkB;EAClB;EACA,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SolanaStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
|
-
//#region src/core/tasks/SolanaSignAndExecuteTask.d.ts
|
|
4
3
|
export declare class SolanaSignAndExecuteTask extends BaseStepExecutionTask {
|
|
5
4
|
run(context: SolanaStepExecutorContext): Promise<TaskResult>;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//# sourceMappingURL=SolanaSignAndExecuteTask.d.ts.map
|
|
5
|
+
}
|
|
@@ -6,7 +6,7 @@ const require_core_tasks_readSignature = require("./readSignature.js");
|
|
|
6
6
|
let _lifi_sdk = require("@lifi/sdk");
|
|
7
7
|
let _solana_kit = require("@solana/kit");
|
|
8
8
|
let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
|
|
9
|
-
|
|
9
|
+
// src/core/tasks/SolanaSignAndExecuteTask.ts
|
|
10
10
|
var SolanaSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
11
11
|
async run(context) {
|
|
12
12
|
const { step, wallet, getWalletAccount, statusManager, executionOptions, isBridgeExecution } = context;
|
|
@@ -47,7 +47,6 @@ var SolanaSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
exports.SolanaSignAndExecuteTask = SolanaSignAndExecuteTask;
|
|
52
51
|
|
|
53
52
|
//# sourceMappingURL=SolanaSignAndExecuteTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getTransactionRequestData","base64ToUint8Array","withTimeout","getWalletFeature","SolanaSignTransaction","CLEARED_TRANSACTION_FIELDS","getTransactionCodec","encodeStoredTransactions"],"sources":["../../../../src/core/tasks/SolanaSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n getTransactionRequestData,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n withTimeout,\n} from '@lifi/sdk'\nimport { getTransactionCodec } from '@solana/kit'\nimport { SolanaSignTransaction } from '@solana/wallet-standard-features'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport { base64ToUint8Array } from '../../utils/base64ToUint8Array.js'\nimport { getWalletFeature } from '../../utils/getWalletFeature.js'\nimport { encodeStoredTransactions } from '../../utils/storedTransactions.js'\nimport { readSignature } from './readSignature.js'\n\nexport class SolanaSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n wallet,\n getWalletAccount,\n statusManager,\n executionOptions,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n // Defence in depth: the selector sends an action with an open\n // transaction to the wait task. Signing here could put a second\n // transaction on chain while the first can still land.\n assertNoOpenTransaction(action)\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resolved here and not in `createContext`: a resume that only waits\n // never signs, so it must not fail because the wallet has not\n // reconnected yet.\n const walletAccount = getWalletAccount(step)\n\n const transactionRequestData = (await getTransactionRequestData(\n step,\n executionOptions\n )) as string | string[]\n\n // The backend returns an array when it produced a Jito bundle and a string\n // for a single transaction. The shape determines how we submit it later:\n // array -> sendBundle, string -> sendTransaction.\n const isBundleExecution = Array.isArray(transactionRequestData)\n\n const transactionDataArray = isBundleExecution\n ? transactionRequestData\n : [transactionRequestData]\n\n const transactionBytesArray = transactionDataArray.map((data) =>\n base64ToUint8Array(data)\n )\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the await above.\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const signedTransactionOutputs = await withTimeout(\n async () => {\n const { signTransaction } = getWalletFeature(\n wallet,\n SolanaSignTransaction\n )\n // Spread the inputs to sign all transactions at once\n return signTransaction(\n ...transactionBytesArray.map((transaction) => ({\n account: walletAccount,\n transaction,\n }))\n )\n },\n {\n // https://solana.com/docs/advanced/confirmation#transaction-expiration\n // Use 2 minutes to account for fluctuations\n timeout: 120_000,\n errorInstance: new TransactionError(\n LiFiErrorCode.TransactionExpired,\n 'Transaction has expired: blockhash is no longer recent enough.'\n ),\n }\n )\n\n // Checked once more after the wallet: a stopped run's late write can\n // merge its transaction into this action while the prompt is open.\n // Nothing awaits from here to the two writes below, so no late write can\n // land between this check and either of them.\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n if (signedTransactionOutputs.length === 0) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'No signed transaction returned from signer.'\n )\n }\n\n // Neither `txHash` nor `txLink` is written here. A signature is fixed at\n // signing, but the transaction does not exist yet: `getTransaction`\n // returns `null` for it, and simulation, the empty-Jito-RPC throw and\n // every send failure all sit between this task and the first broadcast.\n // The wait tasks write both on `onBroadcast`, when an RPC has accepted it.\n //\n // The previous transaction's fields (`CLEARED_TRANSACTION_FIELDS`) are\n // cleared explicitly. Only a final failure reaches this task with them\n // set, and a stale hash would look open again once its `txFinal` is gone.\n // This write runs BEFORE the decode below, which can throw on a malformed\n // wallet output and would otherwise strand the old fields.\n statusManager.updateAction(step, action.type, 'PENDING', {\n ...CLEARED_TRANSACTION_FIELDS,\n signedAt: Date.now(),\n })\n\n const transactionCodec = getTransactionCodec()\n\n // Decode all signed transactions\n const signedTransactions = signedTransactionOutputs.map((output) =>\n transactionCodec.decode(output.signedTransaction)\n )\n\n // Every transaction must carry its fee payer signature before its bytes\n // are stored: an unreadable value would fail every resume the same way.\n // Nothing has been sent yet, so the `TransactionUnprepared` this throws\n // leaves \"Try again\" free to sign again.\n for (const signedTransaction of signedTransactions) {\n readSignature(signedTransaction)\n }\n\n // Stored before any send: a reload from here on resends these bytes\n // instead of asking the wallet again. A bundle stays a JSON array, which\n // is how a resume knows to submit it with `sendBundle`.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHex: encodeStoredTransactions(\n signedTransactionOutputs.map((output) => output.signedTransaction),\n isBundleExecution\n ),\n })\n\n return {\n status: 'COMPLETED',\n context: { signedTransactions, isBundleExecution },\n }\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAM,IAAI,SAAyD;EACjE,MAAM,EACJ,MACA,QACA,kBACA,eACA,kBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;
|
|
1
|
+
{"version":3,"file":"SolanaSignAndExecuteTask.js","names":["BaseStepExecutionTask","assertNoOpenTransaction","TransactionError","LiFiErrorCode","getTransactionRequestData","base64ToUint8Array","withTimeout","getWalletFeature","SolanaSignTransaction","CLEARED_TRANSACTION_FIELDS","getTransactionCodec","readSignature","encodeStoredTransactions"],"sources":["../../../../src/core/tasks/SolanaSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n getTransactionRequestData,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n withTimeout,\n} from '@lifi/sdk'\nimport { getTransactionCodec } from '@solana/kit'\nimport { SolanaSignTransaction } from '@solana/wallet-standard-features'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport { base64ToUint8Array } from '../../utils/base64ToUint8Array.js'\nimport { getWalletFeature } from '../../utils/getWalletFeature.js'\nimport { encodeStoredTransactions } from '../../utils/storedTransactions.js'\nimport { readSignature } from './readSignature.js'\n\nexport class SolanaSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n wallet,\n getWalletAccount,\n statusManager,\n executionOptions,\n isBridgeExecution,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n // Defence in depth: the selector sends an action with an open\n // transaction to the wait task. Signing here could put a second\n // transaction on chain while the first can still land.\n assertNoOpenTransaction(action)\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resolved here and not in `createContext`: a resume that only waits\n // never signs, so it must not fail because the wallet has not\n // reconnected yet.\n const walletAccount = getWalletAccount(step)\n\n const transactionRequestData = (await getTransactionRequestData(\n step,\n executionOptions\n )) as string | string[]\n\n // The backend returns an array when it produced a Jito bundle and a string\n // for a single transaction. The shape determines how we submit it later:\n // array -> sendBundle, string -> sendTransaction.\n const isBundleExecution = Array.isArray(transactionRequestData)\n\n const transactionDataArray = isBundleExecution\n ? transactionRequestData\n : [transactionRequestData]\n\n const transactionBytesArray = transactionDataArray.map((data) =>\n base64ToUint8Array(data)\n )\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the await above.\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const signedTransactionOutputs = await withTimeout(\n async () => {\n const { signTransaction } = getWalletFeature(\n wallet,\n SolanaSignTransaction\n )\n // Spread the inputs to sign all transactions at once\n return signTransaction(\n ...transactionBytesArray.map((transaction) => ({\n account: walletAccount,\n transaction,\n }))\n )\n },\n {\n // https://solana.com/docs/advanced/confirmation#transaction-expiration\n // Use 2 minutes to account for fluctuations\n timeout: 120_000,\n errorInstance: new TransactionError(\n LiFiErrorCode.TransactionExpired,\n 'Transaction has expired: blockhash is no longer recent enough.'\n ),\n }\n )\n\n // Checked once more after the wallet: a stopped run's late write can\n // merge its transaction into this action while the prompt is open.\n // Nothing awaits from here to the two writes below, so no late write can\n // land between this check and either of them.\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n if (signedTransactionOutputs.length === 0) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'No signed transaction returned from signer.'\n )\n }\n\n // Neither `txHash` nor `txLink` is written here. A signature is fixed at\n // signing, but the transaction does not exist yet: `getTransaction`\n // returns `null` for it, and simulation, the empty-Jito-RPC throw and\n // every send failure all sit between this task and the first broadcast.\n // The wait tasks write both on `onBroadcast`, when an RPC has accepted it.\n //\n // The previous transaction's fields (`CLEARED_TRANSACTION_FIELDS`) are\n // cleared explicitly. Only a final failure reaches this task with them\n // set, and a stale hash would look open again once its `txFinal` is gone.\n // This write runs BEFORE the decode below, which can throw on a malformed\n // wallet output and would otherwise strand the old fields.\n statusManager.updateAction(step, action.type, 'PENDING', {\n ...CLEARED_TRANSACTION_FIELDS,\n signedAt: Date.now(),\n })\n\n const transactionCodec = getTransactionCodec()\n\n // Decode all signed transactions\n const signedTransactions = signedTransactionOutputs.map((output) =>\n transactionCodec.decode(output.signedTransaction)\n )\n\n // Every transaction must carry its fee payer signature before its bytes\n // are stored: an unreadable value would fail every resume the same way.\n // Nothing has been sent yet, so the `TransactionUnprepared` this throws\n // leaves \"Try again\" free to sign again.\n for (const signedTransaction of signedTransactions) {\n readSignature(signedTransaction)\n }\n\n // Stored before any send: a reload from here on resends these bytes\n // instead of asking the wallet again. A bundle stays a JSON array, which\n // is how a resume knows to submit it with `sendBundle`.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHex: encodeStoredTransactions(\n signedTransactionOutputs.map((output) => output.signedTransaction),\n isBundleExecution\n ),\n })\n\n return {\n status: 'COMPLETED',\n context: { signedTransactions, isBundleExecution },\n }\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAM,IAAI,SAAyD;EACjE,MAAM,EACJ,MACA,QACA,kBACA,eACA,kBACA,sBACE;EAEJ,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EAKAC,CAAAA,GAAAA,UAAAA,wBAAAA,CAAwB,MAAM;EAE9B,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAMF,MAAM,gBAAgB,iBAAiB,IAAI;EAE3C,MAAM,yBAA0B,OAAA,GAAMC,UAAAA,0BAAAA,CACpC,MACA,gBACF;EAKA,MAAM,oBAAoB,MAAM,QAAQ,sBAAsB;EAM9D,MAAM,yBAJuB,oBACzB,yBACA,CAAC,sBAAsB,EAAA,CAEwB,KAAK,SACtDC,iCAAAA,mBAAmB,IAAI,CACzB;EAIAJ,CAAAA,GAAAA,UAAAA,wBAAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,2BAA2B,OAAA,GAAMK,UAAAA,YAAAA,CACrC,YAAY;GACV,MAAM,EAAE,oBAAoBC,+BAAAA,iBAC1B,QACAC,iCAAAA,qBACF;GAEA,OAAO,gBACL,GAAG,sBAAsB,KAAK,iBAAiB;IAC7C,SAAS;IACT;GACF,EAAE,CACJ;EACF,GACA;GAGE,SAAS;GACT,eAAe,IAAIN,UAAAA,iBACjBC,UAAAA,cAAc,oBACd,gEACF;EACF,CACF;EAMAF,CAAAA,GAAAA,UAAAA,wBAAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,IAAI,yBAAyB,WAAW,GACtC,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,6CACF;EAcF,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GACvD,GAAGM,UAAAA;GACH,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,MAAM,oBAAA,GAAmBC,YAAAA,oBAAAA,CAAoB;EAG7C,MAAM,qBAAqB,yBAAyB,KAAK,WACvD,iBAAiB,OAAO,OAAO,iBAAiB,CAClD;EAMA,KAAK,MAAM,qBAAqB,oBAC9BC,iCAAAA,cAAc,iBAAiB;EAMjC,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW,EACvD,OAAOC,iCAAAA,yBACL,yBAAyB,KAAK,WAAW,OAAO,iBAAiB,GACjE,iBACF,EACF,CAAC;EAED,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAoB;GAAkB;EACnD;CACF;AACF"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SolanaStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
|
-
//#region src/core/tasks/SolanaStandardWaitForTransactionTask.d.ts
|
|
4
3
|
export declare class SolanaStandardWaitForTransactionTask extends BaseStepExecutionTask {
|
|
5
4
|
run(context: SolanaStepExecutorContext): Promise<TaskResult>;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//# sourceMappingURL=SolanaStandardWaitForTransactionTask.d.ts.map
|
|
5
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_actions_sendAndConfirmTransaction = require("../../actions/sendAndConfirmTransaction.js");
|
|
2
3
|
const require_rpc_utils = require("../../rpc/utils.js");
|
|
3
|
-
const require_core_tasks_readSignature = require("./readSignature.js");
|
|
4
4
|
const require_utils_getTransactionLifetime = require("../../utils/getTransactionLifetime.js");
|
|
5
5
|
const require_utils_solanaErrorCause = require("../../utils/solanaErrorCause.js");
|
|
6
|
-
const
|
|
6
|
+
const require_core_tasks_readSignature = require("./readSignature.js");
|
|
7
7
|
const require_core_tasks_resumeFromStore = require("./resumeFromStore.js");
|
|
8
|
-
const
|
|
8
|
+
const require_core_tasks_transactionOutcome = require("./transactionOutcome.js");
|
|
9
9
|
let _lifi_sdk = require("@lifi/sdk");
|
|
10
10
|
let _solana_kit = require("@solana/kit");
|
|
11
|
-
|
|
11
|
+
// src/core/tasks/SolanaStandardWaitForTransactionTask.ts
|
|
12
12
|
const MESSAGES = {
|
|
13
13
|
rpcUnavailable: "Unable to confirm transaction: no Solana RPC returned a usable response.",
|
|
14
14
|
notConfirmed: "Transaction was not confirmed before the SDK stopped waiting.",
|
|
@@ -86,7 +86,6 @@ async function simulate(context, signedTransaction) {
|
|
|
86
86
|
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionSimulationFailed, `Transaction simulation failed: ${cause.message}`, cause);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
//#endregion
|
|
90
89
|
exports.SolanaStandardWaitForTransactionTask = SolanaStandardWaitForTransactionTask;
|
|
91
90
|
|
|
92
91
|
//# sourceMappingURL=SolanaStandardWaitForTransactionTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaStandardWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","resumeFromStore","readSignature","getTransactionLifetime","getTxLink","sendAndSettle","sendAndConfirmTransaction","canResendStored","failureOf","getBase64EncodedWireTransaction","callSolanaRpcsWithRetry","SolanaTransactionDetailsError"],"sources":["../../../../src/core/tasks/SolanaStandardWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport {\n getBase64EncodedWireTransaction,\n type Signature,\n type Transaction,\n} from '@solana/kit'\nimport { sendAndConfirmTransaction } from '../../actions/sendAndConfirmTransaction.js'\nimport { callSolanaRpcsWithRetry } from '../../rpc/utils.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport { SolanaTransactionDetailsError } from '../../utils/solanaErrorCause.js'\nimport type { ConfirmationMessages } from './confirmationError.js'\nimport { readSignature } from './readSignature.js'\nimport { resumeFromStore } from './resumeFromStore.js'\nimport {\n canResendStored,\n clearStoredTransactions,\n failureOf,\n getTxLink,\n sendAndSettle,\n} from './transactionOutcome.js'\n\nconst MESSAGES: ConfirmationMessages = {\n rpcUnavailable:\n 'Unable to confirm transaction: no Solana RPC returned a usable response.',\n notConfirmed: 'Transaction was not confirmed before the SDK stopped waiting.',\n allRpcsFailed: 'All Solana RPCs failed',\n someRpcsFailed:\n 'Some Solana RPCs failed while the confirmation window was open',\n}\n\nexport class SolanaStandardWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, isBridgeExecution, signedTransactions } =\n context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resume mode: the sign task did not run in this session, so the signed\n // bytes come from `txHex`, or only the hash from `txHash`.\n if (!signedTransactions) {\n return resumeFromStore(context, action, {\n messages: MESSAGES,\n send: (stored, lifetimes) =>\n sendSigned(context, action, {\n transaction: stored.transactions[0],\n signature: stored.signature,\n lifetimes,\n resuming: true,\n }),\n })\n }\n\n if (!signedTransactions.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Signed transactions are not found.'\n )\n }\n\n // Use regular transaction submission\n const signedTransaction = signedTransactions[0]\n\n let txSignature: Signature\n let lifetime: TransactionLifetime\n try {\n if (!context.skipSimulation) {\n await simulate(context, signedTransaction)\n }\n txSignature = readSignature(signedTransaction)\n lifetime = await getTransactionLifetime(signedTransaction)\n } catch (error) {\n // Nothing left the SDK: the bytes go, so \"Try again\" signs again\n // instead of resending a transaction that failed before it was sent.\n clearStoredTransactions(context, action)\n throw error\n }\n\n return sendSigned(context, action, {\n transaction: signedTransaction,\n signature: txSignature,\n lifetimes: [lifetime],\n resuming: false,\n })\n }\n}\n\n/**\n * Sends one signed transaction, confirms it and applies the result rules of\n * `sendAndSettle`, on the first run and on a resume alike.\n */\nfunction sendSigned(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n transaction: Transaction\n signature: Signature\n lifetimes: TransactionLifetime[]\n /** An earlier run may already have sent these bytes. */\n resuming: boolean\n }\n): Promise<TaskResult> {\n const { client, step, statusManager } = context\n const { transaction, signature, lifetimes, resuming } = options\n const txLink = getTxLink(context, signature)\n\n return sendAndSettle(context, action, {\n signature,\n send: () =>\n sendAndConfirmTransaction(client, transaction, {\n onBroadcast: () => {\n // The earliest honest point for both: an RPC has accepted the\n // transaction, so the signature now resolves on chain.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink,\n })\n },\n // Read at every send: bytes without their own expiry go out only\n // inside the resend age cap, however long the resend loop runs.\n mayResend: () => canResendStored(lifetimes, step.execution?.signedAt),\n }),\n confirmedFailure: failureOf,\n resuming,\n messages: MESSAGES,\n })\n}\n\n/** First run only: a resend never simulates. */\nasync function simulate(\n context: SolanaStepExecutorContext,\n signedTransaction: Transaction\n): Promise<void> {\n const encodedTransaction = getBase64EncodedWireTransaction(signedTransaction)\n\n const simulationResult = await callSolanaRpcsWithRetry(\n context.client,\n (connection) =>\n connection\n .simulateTransaction(encodedTransaction, {\n commitment: 'confirmed',\n replaceRecentBlockhash: true,\n encoding: 'base64',\n })\n .send()\n )\n\n if (simulationResult.value.err) {\n const cause = new SolanaTransactionDetailsError(\n simulationResult.value.err,\n simulationResult.value.logs\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n `Transaction simulation failed: ${cause.message}`,\n cause\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,WAAiC;CACrC,gBACE;CACF,cAAc;CACd,eAAe;CACf,gBACE;AACJ;AAEA,IAAa,uCAAb,cAA0DA,UAAAA,sBAAsB;CAC9E,MAAM,IAAI,SAAyD;EACjE,MAAM,EAAE,MAAM,eAAe,mBAAmB,uBAC9C;EAEF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAKF,IAAI,CAAC,oBACH,OAAOC,mCAAAA,gBAAgB,SAAS,QAAQ;GACtC,UAAU;GACV,OAAO,QAAQ,cACb,WAAW,SAAS,QAAQ;IAC1B,aAAa,OAAO,aAAa;IACjC,WAAW,OAAO;IAClB;IACA,UAAU;GACZ,CAAC;EACL,CAAC;EAGH,IAAI,CAAC,mBAAmB,QACtB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mEACF;EAIF,MAAM,oBAAoB,mBAAmB;EAE7C,IAAI;EACJ,IAAI;EACJ,IAAI;GACF,IAAI,CAAC,QAAQ,gBACX,MAAM,SAAS,SAAS,iBAAiB;GAE3C,cAAcE,iCAAAA,cAAc,iBAAiB;GAC7C,WAAW,MAAMC,qCAAAA,uBAAuB,iBAAiB;EAC3D,SAAS,OAAO;
|
|
1
|
+
{"version":3,"file":"SolanaStandardWaitForTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","resumeFromStore","readSignature","getTransactionLifetime","clearStoredTransactions","getTxLink","sendAndSettle","sendAndConfirmTransaction","canResendStored","failureOf","getBase64EncodedWireTransaction","callSolanaRpcsWithRetry","SolanaTransactionDetailsError"],"sources":["../../../../src/core/tasks/SolanaStandardWaitForTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport {\n getBase64EncodedWireTransaction,\n type Signature,\n type Transaction,\n} from '@solana/kit'\nimport { sendAndConfirmTransaction } from '../../actions/sendAndConfirmTransaction.js'\nimport { callSolanaRpcsWithRetry } from '../../rpc/utils.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport { SolanaTransactionDetailsError } from '../../utils/solanaErrorCause.js'\nimport type { ConfirmationMessages } from './confirmationError.js'\nimport { readSignature } from './readSignature.js'\nimport { resumeFromStore } from './resumeFromStore.js'\nimport {\n canResendStored,\n clearStoredTransactions,\n failureOf,\n getTxLink,\n sendAndSettle,\n} from './transactionOutcome.js'\n\nconst MESSAGES: ConfirmationMessages = {\n rpcUnavailable:\n 'Unable to confirm transaction: no Solana RPC returned a usable response.',\n notConfirmed: 'Transaction was not confirmed before the SDK stopped waiting.',\n allRpcsFailed: 'All Solana RPCs failed',\n someRpcsFailed:\n 'Some Solana RPCs failed while the confirmation window was open',\n}\n\nexport class SolanaStandardWaitForTransactionTask extends BaseStepExecutionTask {\n async run(context: SolanaStepExecutorContext): Promise<TaskResult> {\n const { step, statusManager, isBridgeExecution, signedTransactions } =\n context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Resume mode: the sign task did not run in this session, so the signed\n // bytes come from `txHex`, or only the hash from `txHash`.\n if (!signedTransactions) {\n return resumeFromStore(context, action, {\n messages: MESSAGES,\n send: (stored, lifetimes) =>\n sendSigned(context, action, {\n transaction: stored.transactions[0],\n signature: stored.signature,\n lifetimes,\n resuming: true,\n }),\n })\n }\n\n if (!signedTransactions.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Signed transactions are not found.'\n )\n }\n\n // Use regular transaction submission\n const signedTransaction = signedTransactions[0]\n\n let txSignature: Signature\n let lifetime: TransactionLifetime\n try {\n if (!context.skipSimulation) {\n await simulate(context, signedTransaction)\n }\n txSignature = readSignature(signedTransaction)\n lifetime = await getTransactionLifetime(signedTransaction)\n } catch (error) {\n // Nothing left the SDK: the bytes go, so \"Try again\" signs again\n // instead of resending a transaction that failed before it was sent.\n clearStoredTransactions(context, action)\n throw error\n }\n\n return sendSigned(context, action, {\n transaction: signedTransaction,\n signature: txSignature,\n lifetimes: [lifetime],\n resuming: false,\n })\n }\n}\n\n/**\n * Sends one signed transaction, confirms it and applies the result rules of\n * `sendAndSettle`, on the first run and on a resume alike.\n */\nfunction sendSigned(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n transaction: Transaction\n signature: Signature\n lifetimes: TransactionLifetime[]\n /** An earlier run may already have sent these bytes. */\n resuming: boolean\n }\n): Promise<TaskResult> {\n const { client, step, statusManager } = context\n const { transaction, signature, lifetimes, resuming } = options\n const txLink = getTxLink(context, signature)\n\n return sendAndSettle(context, action, {\n signature,\n send: () =>\n sendAndConfirmTransaction(client, transaction, {\n onBroadcast: () => {\n // The earliest honest point for both: an RPC has accepted the\n // transaction, so the signature now resolves on chain.\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink,\n })\n },\n // Read at every send: bytes without their own expiry go out only\n // inside the resend age cap, however long the resend loop runs.\n mayResend: () => canResendStored(lifetimes, step.execution?.signedAt),\n }),\n confirmedFailure: failureOf,\n resuming,\n messages: MESSAGES,\n })\n}\n\n/** First run only: a resend never simulates. */\nasync function simulate(\n context: SolanaStepExecutorContext,\n signedTransaction: Transaction\n): Promise<void> {\n const encodedTransaction = getBase64EncodedWireTransaction(signedTransaction)\n\n const simulationResult = await callSolanaRpcsWithRetry(\n context.client,\n (connection) =>\n connection\n .simulateTransaction(encodedTransaction, {\n commitment: 'confirmed',\n replaceRecentBlockhash: true,\n encoding: 'base64',\n })\n .send()\n )\n\n if (simulationResult.value.err) {\n const cause = new SolanaTransactionDetailsError(\n simulationResult.value.err,\n simulationResult.value.logs\n )\n throw new TransactionError(\n LiFiErrorCode.TransactionSimulationFailed,\n `Transaction simulation failed: ${cause.message}`,\n cause\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,WAAiC;CACrC,gBACE;CACF,cAAc;CACd,eAAe;CACf,gBACE;AACJ;AAEA,IAAa,uCAAb,cAA0DA,UAAAA,sBAAsB;CAC9E,MAAM,IAAI,SAAyD;EACjE,MAAM,EAAE,MAAM,eAAe,mBAAmB,uBAC9C;EAEF,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAKF,IAAI,CAAC,oBACH,OAAOC,mCAAAA,gBAAgB,SAAS,QAAQ;GACtC,UAAU;GACV,OAAO,QAAQ,cACb,WAAW,SAAS,QAAQ;IAC1B,aAAa,OAAO,aAAa;IACjC,WAAW,OAAO;IAClB;IACA,UAAU;GACZ,CAAC;EACL,CAAC;EAGH,IAAI,CAAC,mBAAmB,QACtB,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mEACF;EAIF,MAAM,oBAAoB,mBAAmB;EAE7C,IAAI;EACJ,IAAI;EACJ,IAAI;GACF,IAAI,CAAC,QAAQ,gBACX,MAAM,SAAS,SAAS,iBAAiB;GAE3C,cAAcE,iCAAAA,cAAc,iBAAiB;GAC7C,WAAW,MAAMC,qCAAAA,uBAAuB,iBAAiB;EAC3D,SAAS,OAAO;GAGdC,sCAAAA,wBAAwB,SAAS,MAAM;GACvC,MAAM;EACR;EAEA,OAAO,WAAW,SAAS,QAAQ;GACjC,aAAa;GACb,WAAW;GACX,WAAW,CAAC,QAAQ;GACpB,UAAU;EACZ,CAAC;CACH;AACF;;;;;AAMA,SAAS,WACP,SACA,QACA,SAOqB;CACrB,MAAM,EAAE,QAAQ,MAAM,kBAAkB;CACxC,MAAM,EAAE,aAAa,WAAW,WAAW,aAAa;CACxD,MAAM,SAASC,sCAAAA,UAAU,SAAS,SAAS;CAE3C,OAAOC,sCAAAA,cAAc,SAAS,QAAQ;EACpC;EACA,YACEC,0CAAAA,0BAA0B,QAAQ,aAAa;GAC7C,mBAAmB;IAGjB,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;KACvD,QAAQ;KACR;IACF,CAAC;GACH;GAGA,iBAAiBC,sCAAAA,gBAAgB,WAAW,KAAK,WAAW,QAAQ;EACtE,CAAC;EACH,kBAAkBC,sCAAAA;EAClB;EACA,UAAU;CACZ,CAAC;AACH;;AAGA,eAAe,SACb,SACA,mBACe;CACf,MAAM,sBAAA,GAAqBC,YAAAA,gCAAAA,CAAgC,iBAAiB;CAE5E,MAAM,mBAAmB,MAAMC,kBAAAA,wBAC7B,QAAQ,SACP,eACC,WACG,oBAAoB,oBAAoB;EACvC,YAAY;EACZ,wBAAwB;EACxB,UAAU;CACZ,CAAC,CAAC,CACD,KAAK,CACZ;CAEA,IAAI,iBAAiB,MAAM,KAAK;EAC9B,MAAM,QAAQ,IAAIC,+BAAAA,8BAChB,iBAAiB,MAAM,KACvB,iBAAiB,MAAM,IACzB;EACA,MAAM,IAAIb,UAAAA,iBACRC,UAAAA,cAAc,6BACd,kCAAkC,MAAM,WACxC,KACF;CACF;AACF"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SolanaStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
|
-
//#region src/core/tasks/SolanaWaitForTransactionTask.d.ts
|
|
4
3
|
export declare class SolanaWaitForTransactionTask extends BaseStepExecutionTask {
|
|
5
4
|
run(context: SolanaStepExecutorContext): Promise<TaskResult>;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//# sourceMappingURL=SolanaWaitForTransactionTask.d.ts.map
|
|
5
|
+
}
|
|
@@ -3,7 +3,7 @@ const require_utils_storedTransactions = require("../../utils/storedTransactions
|
|
|
3
3
|
const require_core_tasks_SolanaJitoWaitForTransactionTask = require("./SolanaJitoWaitForTransactionTask.js");
|
|
4
4
|
const require_core_tasks_SolanaStandardWaitForTransactionTask = require("./SolanaStandardWaitForTransactionTask.js");
|
|
5
5
|
let _lifi_sdk = require("@lifi/sdk");
|
|
6
|
-
|
|
6
|
+
// src/core/tasks/SolanaWaitForTransactionTask.ts
|
|
7
7
|
/**
|
|
8
8
|
* On a resume the sign task did not run, so the flag is missing and the
|
|
9
9
|
* stored bytes keep the shape instead: a leading `[` marks a bundle. With a
|
|
@@ -21,7 +21,6 @@ var SolanaWaitForTransactionTask = class extends _lifi_sdk.BaseStepExecutionTask
|
|
|
21
21
|
return new require_core_tasks_SolanaStandardWaitForTransactionTask.SolanaStandardWaitForTransactionTask().run(context);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
exports.SolanaWaitForTransactionTask = SolanaWaitForTransactionTask;
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=SolanaWaitForTransactionTask.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UnconfirmedRaceResult } from "../../confirmation/raceRpcs.js";
|
|
2
2
|
import { RPCError, TransactionError } from "@lifi/sdk";
|
|
3
|
-
//#region src/core/tasks/confirmationError.d.ts
|
|
4
3
|
/** Only the nouns differ between the standard and bundle paths. */
|
|
5
4
|
export type ConfirmationMessages = {
|
|
6
5
|
/** Every branch failed: an outage, not a verdict about the transaction. */
|
|
@@ -24,6 +23,4 @@ export type ConfirmationMessages = {
|
|
|
24
23
|
* they call this: only they can run the history lookup and the status API a
|
|
25
24
|
* final "dropped" needs, so the final marker is theirs to add.
|
|
26
25
|
*/
|
|
27
|
-
export declare function confirmationError(result: UnconfirmedRaceResult, messages: ConfirmationMessages): RPCError | TransactionError;
|
|
28
|
-
//#endregion
|
|
29
|
-
//# sourceMappingURL=confirmationError.d.ts.map
|
|
26
|
+
export declare function confirmationError(result: UnconfirmedRaceResult, messages: ConfirmationMessages): RPCError | TransactionError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _lifi_sdk = require("@lifi/sdk");
|
|
3
|
-
|
|
3
|
+
// src/core/tasks/confirmationError.ts
|
|
4
4
|
/** `cause` is the first collected error on purpose: `BaseError` overwrites its
|
|
5
5
|
* stack with `getRootCause(cause).stack`, and an `AggregateError` has no
|
|
6
6
|
* `cause`, so without it the stack would point at this file. */
|
|
@@ -20,7 +20,6 @@ function confirmationError(result, messages) {
|
|
|
20
20
|
if (result.kind === "rpc-unavailable") return new _lifi_sdk.RPCError(_lifi_sdk.LiFiErrorCode.RpcUnavailable, messages.rpcUnavailable, chainErrors(result.errors, messages.allRpcsFailed));
|
|
21
21
|
return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionExpired, messages.notConfirmed, chainErrors(result.errors, messages.someRpcsFailed));
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
exports.confirmationError = confirmationError;
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=confirmationError.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signature, Transaction } from "@solana/kit";
|
|
2
|
-
//#region src/core/tasks/readSignature.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Reads a signed transaction's signature, restating a `@solana/kit` failure as
|
|
5
4
|
* a `TransactionError`.
|
|
@@ -11,6 +10,4 @@ import { Signature, Transaction } from "@solana/kit";
|
|
|
11
10
|
* someone else. Integrator error branching switches on `LiFiErrorCode`, so an
|
|
12
11
|
* unwrapped throw lands in the unknown bucket.
|
|
13
12
|
*/
|
|
14
|
-
export declare function readSignature(transaction: Transaction): Signature;
|
|
15
|
-
//#endregion
|
|
16
|
-
//# sourceMappingURL=readSignature.d.ts.map
|
|
13
|
+
export declare function readSignature(transaction: Transaction): Signature;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _lifi_sdk = require("@lifi/sdk");
|
|
3
3
|
let _solana_kit = require("@solana/kit");
|
|
4
|
-
|
|
4
|
+
// src/core/tasks/readSignature.ts
|
|
5
5
|
/**
|
|
6
6
|
* Reads a signed transaction's signature, restating a `@solana/kit` failure as
|
|
7
7
|
* a `TransactionError`.
|
|
@@ -20,7 +20,6 @@ function readSignature(transaction) {
|
|
|
20
20
|
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. The signed transaction carries no fee payer signature.", error);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
exports.readSignature = readSignature;
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=readSignature.js.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SolanaStepExecutorContext } from "../../types.js";
|
|
2
2
|
import { TransactionLifetime } from "../../utils/getTransactionLifetime.js";
|
|
3
|
-
import { ConfirmationMessages } from "./confirmationError.js";
|
|
4
3
|
import { StoredTransactions } from "../../utils/storedTransactions.js";
|
|
4
|
+
import { ConfirmationMessages } from "./confirmationError.js";
|
|
5
5
|
import { ExecutionAction, TaskResult } from "@lifi/sdk";
|
|
6
|
-
//#region src/core/tasks/resumeFromStore.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Resume mode of both wait tasks: the sign task did not run in this session,
|
|
9
8
|
* so the transaction comes from the action.
|
|
@@ -26,6 +25,4 @@ export declare function resumeFromStore(context: SolanaStepExecutorContext, acti
|
|
|
26
25
|
* run does, but never simulates: a transaction that already landed, or
|
|
27
26
|
* funds it already spent, would fail the simulation falsely. */
|
|
28
27
|
send: (stored: StoredTransactions, lifetimes: TransactionLifetime[]) => Promise<TaskResult>;
|
|
29
|
-
}): Promise<TaskResult>;
|
|
30
|
-
//#endregion
|
|
31
|
-
//# sourceMappingURL=resumeFromStore.d.ts.map
|
|
28
|
+
}): Promise<TaskResult>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_actions_lookupSignatureStatus = require("../../actions/lookupSignatureStatus.js");
|
|
3
3
|
const require_confirmation_types = require("../../confirmation/types.js");
|
|
4
4
|
const require_utils_getTransactionLifetime = require("../../utils/getTransactionLifetime.js");
|
|
5
|
-
const
|
|
5
|
+
const require_utils_storedTransactions = require("../../utils/storedTransactions.js");
|
|
6
6
|
const require_core_tasks_confirmationError = require("./confirmationError.js");
|
|
7
7
|
const require_core_tasks_transactionOutcome = require("./transactionOutcome.js");
|
|
8
8
|
let _lifi_sdk = require("@lifi/sdk");
|
|
9
|
-
|
|
9
|
+
// src/core/tasks/resumeFromStore.ts
|
|
10
10
|
function readResumeSource(context, action) {
|
|
11
11
|
if (action.txHex) {
|
|
12
12
|
const stored = require_utils_storedTransactions.decodeStoredTransactions(action.txHex);
|
|
@@ -75,7 +75,6 @@ async function resumeFromStore(context, action, options) {
|
|
|
75
75
|
failure: require_core_tasks_transactionOutcome.failureOf(status)
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
//#endregion
|
|
79
78
|
exports.resumeFromStore = resumeFromStore;
|
|
80
79
|
|
|
81
80
|
//# sourceMappingURL=resumeFromStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resumeFromStore.js","names":["decodeStoredTransactions","TransactionError","LiFiErrorCode","lookupSignatureStatus","isConfirmedCommitment","recordLanded","failureOf","getTransactionLifetime","canResendStored","confirmationError","resolveUnconfirmed"],"sources":["../../../../src/core/tasks/resumeFromStore.ts"],"sourcesContent":["import {\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature } from '@solana/kit'\nimport { lookupSignatureStatus } from '../../actions/lookupSignatureStatus.js'\nimport { isConfirmedCommitment } from '../../confirmation/types.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport {\n decodeStoredTransactions,\n type StoredTransactions,\n} from '../../utils/storedTransactions.js'\nimport {\n type ConfirmationMessages,\n
|
|
1
|
+
{"version":3,"file":"resumeFromStore.js","names":["decodeStoredTransactions","clearStoredTransactions","TransactionError","LiFiErrorCode","lookupSignatureStatus","isConfirmedCommitment","recordLanded","failureOf","getTransactionLifetime","canResendStored","confirmationError","resolveUnconfirmed"],"sources":["../../../../src/core/tasks/resumeFromStore.ts"],"sourcesContent":["import {\n type ExecutionAction,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature } from '@solana/kit'\nimport { lookupSignatureStatus } from '../../actions/lookupSignatureStatus.js'\nimport { isConfirmedCommitment } from '../../confirmation/types.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport {\n getTransactionLifetime,\n type TransactionLifetime,\n} from '../../utils/getTransactionLifetime.js'\nimport {\n decodeStoredTransactions,\n type StoredTransactions,\n} from '../../utils/storedTransactions.js'\nimport {\n confirmationError,\n type ConfirmationMessages,\n} from './confirmationError.js'\nimport {\n canResendStored,\n clearStoredTransactions,\n failureOf,\n recordLanded,\n resolveUnconfirmed,\n} from './transactionOutcome.js'\n\n/** What a resumed wait task can work from. */\ntype ResumeSource =\n /** Signed bytes that may still need to be sent. */\n | { kind: 'bytes'; stored: StoredTransactions }\n /** A broadcast signature alone: a route stored before the upgrade, or\n * bytes that no longer decode. */\n | { kind: 'hash'; signature: Signature }\n /** Bytes whose first signature is not the stored txHash (damaged\n * storage). They prove nothing about that transaction, and they may have\n * been sent: nothing is sent and nothing is dropped. */\n | { kind: 'mismatch'; signature: Signature }\n\nfunction readResumeSource(\n context: SolanaStepExecutorContext,\n action: ExecutionAction\n): ResumeSource {\n if (action.txHex) {\n const stored = decodeStoredTransactions(action.txHex)\n if (stored) {\n if (action.txHash && action.txHash !== stored.signature) {\n return { kind: 'mismatch', signature: action.txHash as Signature }\n }\n return { kind: 'bytes', stored }\n }\n // The sign task stores only bytes that decode, so these were damaged\n // after the write - by the integrator's storage, say. They would fail\n // every resume the same way.\n clearStoredTransactions(context, action)\n }\n\n if (action.txHash) {\n return { kind: 'hash', signature: action.txHash as Signature }\n }\n\n // Without a hash no RPC ever accepted a send - `txHash` is written on the\n // first accepted one - so nothing can land. No final marker: \"Try again\"\n // signs again.\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Signed transactions are not found.'\n )\n}\n\n/**\n * Resume mode of both wait tasks: the sign task did not run in this session,\n * so the transaction comes from the action.\n *\n * 1. Look the signature up on every RPC. A confirmed status goes straight to\n * the result rules: the transaction may have landed after the page closed.\n * This look only has to find, so it asks for no canary.\n * 2. Otherwise resend the stored bytes through `send` when that is allowed -\n * the task's normal send path, without simulation.\n * 3. Otherwise - a hash alone, or bytes past the resend age cap - nothing is\n * sent, and only the dropped rule can make the outcome final.\n *\n * Bytes that are not the stored txHash's transaction are never sent, and the\n * dropped rule never runs for them: the outcome stays unknown unless the\n * lookup by txHash finds it confirmed.\n */\nexport async function resumeFromStore(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n messages: ConfirmationMessages\n /** Sends the stored bytes and applies the result rules, as the first\n * run does, but never simulates: a transaction that already landed, or\n * funds it already spent, would fail the simulation falsely. */\n send: (\n stored: StoredTransactions,\n lifetimes: TransactionLifetime[]\n ) => Promise<TaskResult>\n }\n): Promise<TaskResult> {\n const { client, step } = context\n const source = readResumeSource(context, action)\n const signature =\n source.kind === 'bytes' ? source.stored.signature : source.signature\n\n const lookup = await lookupSignatureStatus(client, signature)\n if (\n lookup.kind === 'found' &&\n isConfirmedCommitment(lookup.status.confirmationStatus)\n ) {\n return recordLanded(context, action, {\n signature,\n failure: failureOf(lookup.status),\n })\n }\n\n const lifetimes =\n source.kind === 'bytes'\n ? await Promise.all(\n source.stored.transactions.map((transaction) =>\n getTransactionLifetime(transaction)\n )\n )\n : []\n\n // A `processed` status resends too: a signature executes at most once.\n if (\n source.kind === 'bytes' &&\n canResendStored(lifetimes, step.execution?.signedAt)\n ) {\n return options.send(source.stored, lifetimes)\n }\n\n // No RPC answered at all: an outage, as today. Otherwise the transaction\n // was simply not seen.\n const silent = lookup.kind === 'unknown' && !lookup.answered\n const error = confirmationError(\n silent\n ? { kind: 'rpc-unavailable', errors: lookup.errors }\n : { kind: 'not-confirmed', errors: [] },\n options.messages\n )\n if (source.kind === 'mismatch') {\n // Damaged storage: no dropped rule, so the outcome stays unknown.\n throw error\n }\n const status = await resolveUnconfirmed(context, action, {\n signature,\n error,\n expiredAtSlot: undefined,\n messages: options.messages,\n })\n return recordLanded(context, action, {\n signature,\n failure: failureOf(status),\n })\n}\n"],"mappings":";;;;;;;;;AA0CA,SAAS,iBACP,SACA,QACc;CACd,IAAI,OAAO,OAAO;EAChB,MAAM,SAASA,iCAAAA,yBAAyB,OAAO,KAAK;EACpD,IAAI,QAAQ;GACV,IAAI,OAAO,UAAU,OAAO,WAAW,OAAO,WAC5C,OAAO;IAAE,MAAM;IAAY,WAAW,OAAO;GAAoB;GAEnE,OAAO;IAAE,MAAM;IAAS;GAAO;EACjC;EAIAC,sCAAAA,wBAAwB,SAAS,MAAM;CACzC;CAEA,IAAI,OAAO,QACT,OAAO;EAAE,MAAM;EAAQ,WAAW,OAAO;CAAoB;CAM/D,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,mEACF;AACF;;;;;;;;;;;;;;;;;AAkBA,eAAsB,gBACpB,SACA,QACA,SAUqB;CACrB,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,SAAS,iBAAiB,SAAS,MAAM;CAC/C,MAAM,YACJ,OAAO,SAAS,UAAU,OAAO,OAAO,YAAY,OAAO;CAE7D,MAAM,SAAS,MAAMC,sCAAAA,sBAAsB,QAAQ,SAAS;CAC5D,IACE,OAAO,SAAS,WAChBC,2BAAAA,sBAAsB,OAAO,OAAO,kBAAkB,GAEtD,OAAOC,sCAAAA,aAAa,SAAS,QAAQ;EACnC;EACA,SAASC,sCAAAA,UAAU,OAAO,MAAM;CAClC,CAAC;CAGH,MAAM,YACJ,OAAO,SAAS,UACZ,MAAM,QAAQ,IACZ,OAAO,OAAO,aAAa,KAAK,gBAC9BC,qCAAAA,uBAAuB,WAAW,CACpC,CACF,IACA,CAAC;CAGP,IACE,OAAO,SAAS,WAChBC,sCAAAA,gBAAgB,WAAW,KAAK,WAAW,QAAQ,GAEnD,OAAO,QAAQ,KAAK,OAAO,QAAQ,SAAS;CAK9C,MAAM,SAAS,OAAO,SAAS,aAAa,CAAC,OAAO;CACpD,MAAM,QAAQC,qCAAAA,kBACZ,SACI;EAAE,MAAM;EAAmB,QAAQ,OAAO;CAAO,IACjD;EAAE,MAAM;EAAiB,QAAQ,CAAC;CAAE,GACxC,QAAQ,QACV;CACA,IAAI,OAAO,SAAS,YAElB,MAAM;CAER,MAAM,SAAS,MAAMC,sCAAAA,mBAAmB,SAAS,QAAQ;EACvD;EACA;EACA,eAAe,KAAA;EACf,UAAU,QAAQ;CACpB,CAAC;CACD,OAAOL,sCAAAA,aAAa,SAAS,QAAQ;EACnC;EACA,SAASC,sCAAAA,UAAU,MAAM;CAC3B,CAAC;AACH"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RaceResult } from "../../confirmation/raceRpcs.js";
|
|
2
2
|
import { SignatureStatus } from "../../confirmation/types.js";
|
|
3
|
+
import { SolanaStepExecutorContext } from "../../types.js";
|
|
3
4
|
import { TransactionLifetime } from "../../utils/getTransactionLifetime.js";
|
|
4
|
-
import { RaceResult } from "../../confirmation/raceRpcs.js";
|
|
5
5
|
import { ConfirmationMessages } from "./confirmationError.js";
|
|
6
6
|
import { ExecutionAction, TaskResult } from "@lifi/sdk";
|
|
7
7
|
import { Signature } from "@solana/kit";
|
|
8
|
-
//#region src/core/tasks/transactionOutcome.d.ts
|
|
9
8
|
/** Explorer link for a signature, as both wait tasks write it. */
|
|
10
9
|
export declare function getTxLink(context: Pick<SolanaStepExecutorContext, "fromChain">, signature: string): string;
|
|
11
10
|
/**
|
|
@@ -102,6 +101,4 @@ export declare function sendAndSettle<T>(context: SolanaStepExecutorContext, act
|
|
|
102
101
|
/** An earlier run may already have sent these bytes. */
|
|
103
102
|
resuming: boolean;
|
|
104
103
|
messages: ConfirmationMessages;
|
|
105
|
-
}): Promise<TaskResult>;
|
|
106
|
-
//#endregion
|
|
107
|
-
//# sourceMappingURL=transactionOutcome.d.ts.map
|
|
104
|
+
}): Promise<TaskResult>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_confirmation_types = require("../../confirmation/types.js");
|
|
3
2
|
const require_actions_lookupSignatureStatus = require("../../actions/lookupSignatureStatus.js");
|
|
4
|
-
const
|
|
3
|
+
const require_confirmation_types = require("../../confirmation/types.js");
|
|
5
4
|
const require_utils_solanaErrorCause = require("../../utils/solanaErrorCause.js");
|
|
5
|
+
const require_core_tasks_confirmationError = require("./confirmationError.js");
|
|
6
6
|
let _lifi_sdk = require("@lifi/sdk");
|
|
7
|
-
|
|
7
|
+
// src/core/tasks/transactionOutcome.ts
|
|
8
8
|
/** Explorer link for a signature, as both wait tasks write it. */
|
|
9
9
|
function getTxLink(context, signature) {
|
|
10
10
|
return `${context.fromChain.metamask.blockExplorerUrls[0]}tx/${signature}`;
|
|
@@ -145,7 +145,6 @@ async function sendAndSettle(context, action, options) {
|
|
|
145
145
|
});
|
|
146
146
|
return settleUnconfirmed(require_core_tasks_confirmationError.confirmationError(result, messages), result.kind === "expired" ? result.slot : void 0);
|
|
147
147
|
}
|
|
148
|
-
//#endregion
|
|
149
148
|
exports.canResendStored = canResendStored;
|
|
150
149
|
exports.cannotLandAnymore = cannotLandAnymore;
|
|
151
150
|
exports.clearStoredTransactions = clearStoredTransactions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionOutcome.js","names":["isResendAllowed","isOldEnoughToDrop","SolanaTransactionDetailsError","TransactionError","LiFiErrorCode","lookupSignatureStatus","CLOCK_SKEW_MARGIN_MS","isConfirmedCommitment","isKnownToStatusApi","confirmationError"],"sources":["../../../../src/core/tasks/transactionOutcome.ts"],"sourcesContent":["import {\n CLOCK_SKEW_MARGIN_MS,\n type ExecutionAction,\n isKnownToStatusApi,\n isOldEnoughToDrop,\n isResendAllowed,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature } from '@solana/kit'\nimport { lookupSignatureStatus } from '../../actions/lookupSignatureStatus.js'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\nimport {\n isConfirmedCommitment,\n type SignatureStatus,\n} from '../../confirmation/types.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport type { TransactionLifetime } from '../../utils/getTransactionLifetime.js'\nimport { SolanaTransactionDetailsError } from '../../utils/solanaErrorCause.js'\nimport {\n type ConfirmationMessages,\n confirmationError,\n} from './confirmationError.js'\n\n/** Explorer link for a signature, as both wait tasks write it. */\nexport function getTxLink(\n context: Pick<SolanaStepExecutorContext, 'fromChain'>,\n signature: string\n): string {\n return `${context.fromChain.metamask.blockExplorerUrls[0]}tx/${signature}`\n}\n\n/**\n * May stored bytes be sent (again)? A blockhash transaction always: the\n * chain rejects it once the blockhash dies, and the deadline's probe tells\n * when. Anything else - a durable nonce, a lifetime that did not decode -\n * only inside the resend age cap, so a page load hours later cannot execute\n * a swap on an old quote.\n */\nexport function canResendStored(\n lifetimes: TransactionLifetime[],\n signedAt: number | undefined,\n now?: number\n): boolean {\n const expiresOnItsOwn =\n lifetimes.length > 0 &&\n lifetimes.every((lifetime) => lifetime.kind === 'blockhash')\n return expiresOnItsOwn || isResendAllowed(signedAt, now)\n}\n\n/**\n * Condition (a) of the dropped rule in `resolveUnconfirmed`: the chain says\n * the transaction can no longer land.\n *\n * - An `expired` verdict: the blockhash probe saw it dead.\n * - Without a verdict, `isOldEnoughToDrop` for every lifetime. For a\n * blockhash transaction that is the five-minute time fallback. For a\n * durable nonce or an undecodable lifetime it is the age cap passed plus a\n * margin: sends stop at the cap, and the three minutes after it put the\n * lookup's current-slot head safely past any slot the transaction could\n * still land in.\n *\n * An unknown signing time never holds by time.\n */\nexport function cannotLandAnymore(options: {\n expired: boolean\n signedAt: number | undefined\n now?: number\n}): boolean {\n return options.expired || isOldEnoughToDrop(options.signedAt, options.now)\n}\n\n/** Drops the stored bytes: never sent, landed, or final. */\nexport function clearStoredTransactions(\n context: SolanaStepExecutorContext,\n action: ExecutionAction\n): void {\n context.statusManager.updateAction(context.step, action.type, 'PENDING', {\n txHex: undefined,\n })\n}\n\n/** A signature status's `err` as the failure `recordLanded` takes. */\nexport function failureOf(\n status: Pick<SignatureStatus, 'err'>\n): { err: unknown } | undefined {\n return status.err ? { err: status.err } : undefined\n}\n\n/**\n * Result rule for a transaction the chain has: writes `txHash` and `txLink`,\n * clears the stored bytes, then completes - or throws the final\n * `TransactionFailed` for one that failed on chain.\n *\n * The hash is written for a failed transaction too: it exists on chain, and\n * a resume that found it by lookup has no `txHash` yet.\n */\nexport function recordLanded(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: { signature: Signature; failure: { err: unknown } | undefined }\n): TaskResult {\n const { step, statusManager, isBridgeExecution } = context\n const { signature, failure } = options\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink: getTxLink(context, signature),\n txHex: undefined,\n })\n\n if (failure) {\n const cause = new SolanaTransactionDetailsError(failure.err)\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n `Transaction failed: ${cause.message}`,\n cause,\n { final: true }\n )\n }\n\n if (isBridgeExecution) {\n statusManager.updateAction(step, action.type, 'DONE')\n }\n\n return { status: 'COMPLETED' }\n}\n\n/**\n * Decides what a transaction that did not confirm is: landed after all\n * (returns its status), dropped (throws a final `TransactionExpired`), or\n * unknown (rethrows `error`, the error the task built for today's outcome).\n *\n * Dropped (see the resume rules in `transactionState.ts`) = (a)\n * `cannotLandAnymore`, AND (b) a lookup that proves the absence - a covering\n * RPC whose head is past the landing window answered `null` in the same\n * response, and no RPC has the transaction - AND (c) the status API does not\n * know the hash. The status API only vetoes: it answers 404 for landed\n * transactions it does not index too, so a miss there proves nothing.\n */\nexport async function resolveUnconfirmed(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n signature: Signature\n /** What the integrator sees when the outcome stays unknown. */\n error: unknown\n /** The slot of the `expired` verdict; `undefined` without one. */\n expiredAtSlot: bigint | undefined\n messages: ConfirmationMessages\n }\n): Promise<SignatureStatus> {\n const { client, step } = context\n const { signature, error, expiredAtSlot } = options\n const signedAt = step.execution?.signedAt\n\n // (a) The local check runs first, so a young transaction costs no request.\n if (!cannotLandAnymore({ expired: expiredAtSlot !== undefined, signedAt })) {\n throw error\n }\n // Without a signing time there is no anchor, so no canary can prove that a\n // node's history covers the transaction.\n if (signedAt === undefined) {\n throw error\n }\n\n // (b) Absence, proven by the same response that proves coverage and head.\n // Every other lookup result - also `unknown` with `answered: false`, an\n // outage - keeps the outcome unknown.\n const lookup = await lookupSignatureStatus(client, signature, {\n anchor: signedAt - CLOCK_SKEW_MARGIN_MS,\n expiredAtSlot,\n })\n if (\n lookup.kind === 'found' &&\n isConfirmedCommitment(lookup.status.confirmationStatus)\n ) {\n return lookup.status\n }\n if (lookup.kind !== 'not-found') {\n throw error\n }\n\n // (c) The veto.\n if (await isKnownToStatusApi(client, step, signature)) {\n throw error\n }\n\n clearStoredTransactions(context, action)\n // Today's expiry code and text: only the marker is new.\n throw new TransactionError(\n LiFiErrorCode.TransactionExpired,\n options.messages.notConfirmed,\n error instanceof Error ? error : undefined,\n { final: true }\n )\n}\n\n/**\n * The send-and-settle tail both wait tasks share: runs `send`, then applies\n * the result rules to what it reports.\n *\n * - A confirmation goes to `recordLanded`, with `confirmedFailure` reading\n * its on-chain failure.\n * - Every other result - `rpc-unavailable` included - goes to\n * `resolveUnconfirmed`. Only an `expired` verdict passes its slot: the\n * dropped check reads any defined slot as a verdict.\n * - A rejection comes before the first send of this run. On the first run\n * nothing ever left the SDK, so the bytes are cleared and the error is\n * rethrown: \"Try again\" signs again. On a resume an earlier run may have\n * sent the same bytes: they stay, and only the chain can make the outcome\n * final.\n */\nexport async function sendAndSettle<T>(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n signature: Signature\n /** Sends and races the confirmation. Rejects only before its first\n * send; the race itself never rejects. */\n send: () => Promise<RaceResult<T>>\n /** The on-chain failure of a confirmed value. */\n confirmedFailure: (value: T) => { err: unknown } | undefined\n /** An earlier run may already have sent these bytes. */\n resuming: boolean\n messages: ConfirmationMessages\n }\n): Promise<TaskResult> {\n const { signature, messages } = options\n\n /** `resolveUnconfirmed` throws for an unknown or dropped outcome, so only\n * a confirmed status reaches `recordLanded`. */\n const settleUnconfirmed = async (\n error: unknown,\n expiredAtSlot: bigint | undefined\n ): Promise<TaskResult> => {\n const status = await resolveUnconfirmed(context, action, {\n signature,\n error,\n expiredAtSlot,\n messages,\n })\n return recordLanded(context, action, {\n signature,\n failure: failureOf(status),\n })\n }\n\n let result: RaceResult<T>\n try {\n result = await options.send()\n } catch (error) {\n if (!options.resuming) {\n clearStoredTransactions(context, action)\n throw error\n }\n return settleUnconfirmed(error, undefined)\n }\n\n if (result.kind === 'confirmed') {\n return recordLanded(context, action, {\n signature,\n failure: options.confirmedFailure(result.value),\n })\n }\n\n return settleUnconfirmed(\n confirmationError(result, messages),\n // The head a covering RPC has to reach before its `null` counts.\n result.kind === 'expired' ? result.slot : undefined\n )\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"transactionOutcome.js","names":["isResendAllowed","isOldEnoughToDrop","SolanaTransactionDetailsError","TransactionError","LiFiErrorCode","lookupSignatureStatus","CLOCK_SKEW_MARGIN_MS","isConfirmedCommitment","isKnownToStatusApi","confirmationError"],"sources":["../../../../src/core/tasks/transactionOutcome.ts"],"sourcesContent":["import {\n CLOCK_SKEW_MARGIN_MS,\n type ExecutionAction,\n isKnownToStatusApi,\n isOldEnoughToDrop,\n isResendAllowed,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Signature } from '@solana/kit'\nimport { lookupSignatureStatus } from '../../actions/lookupSignatureStatus.js'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\nimport {\n isConfirmedCommitment,\n type SignatureStatus,\n} from '../../confirmation/types.js'\nimport type { SolanaStepExecutorContext } from '../../types.js'\nimport type { TransactionLifetime } from '../../utils/getTransactionLifetime.js'\nimport { SolanaTransactionDetailsError } from '../../utils/solanaErrorCause.js'\nimport {\n confirmationError,\n type ConfirmationMessages,\n} from './confirmationError.js'\n\n/** Explorer link for a signature, as both wait tasks write it. */\nexport function getTxLink(\n context: Pick<SolanaStepExecutorContext, 'fromChain'>,\n signature: string\n): string {\n return `${context.fromChain.metamask.blockExplorerUrls[0]}tx/${signature}`\n}\n\n/**\n * May stored bytes be sent (again)? A blockhash transaction always: the\n * chain rejects it once the blockhash dies, and the deadline's probe tells\n * when. Anything else - a durable nonce, a lifetime that did not decode -\n * only inside the resend age cap, so a page load hours later cannot execute\n * a swap on an old quote.\n */\nexport function canResendStored(\n lifetimes: TransactionLifetime[],\n signedAt: number | undefined,\n now?: number\n): boolean {\n const expiresOnItsOwn =\n lifetimes.length > 0 &&\n lifetimes.every((lifetime) => lifetime.kind === 'blockhash')\n return expiresOnItsOwn || isResendAllowed(signedAt, now)\n}\n\n/**\n * Condition (a) of the dropped rule in `resolveUnconfirmed`: the chain says\n * the transaction can no longer land.\n *\n * - An `expired` verdict: the blockhash probe saw it dead.\n * - Without a verdict, `isOldEnoughToDrop` for every lifetime. For a\n * blockhash transaction that is the five-minute time fallback. For a\n * durable nonce or an undecodable lifetime it is the age cap passed plus a\n * margin: sends stop at the cap, and the three minutes after it put the\n * lookup's current-slot head safely past any slot the transaction could\n * still land in.\n *\n * An unknown signing time never holds by time.\n */\nexport function cannotLandAnymore(options: {\n expired: boolean\n signedAt: number | undefined\n now?: number\n}): boolean {\n return options.expired || isOldEnoughToDrop(options.signedAt, options.now)\n}\n\n/** Drops the stored bytes: never sent, landed, or final. */\nexport function clearStoredTransactions(\n context: SolanaStepExecutorContext,\n action: ExecutionAction\n): void {\n context.statusManager.updateAction(context.step, action.type, 'PENDING', {\n txHex: undefined,\n })\n}\n\n/** A signature status's `err` as the failure `recordLanded` takes. */\nexport function failureOf(\n status: Pick<SignatureStatus, 'err'>\n): { err: unknown } | undefined {\n return status.err ? { err: status.err } : undefined\n}\n\n/**\n * Result rule for a transaction the chain has: writes `txHash` and `txLink`,\n * clears the stored bytes, then completes - or throws the final\n * `TransactionFailed` for one that failed on chain.\n *\n * The hash is written for a failed transaction too: it exists on chain, and\n * a resume that found it by lookup has no `txHash` yet.\n */\nexport function recordLanded(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: { signature: Signature; failure: { err: unknown } | undefined }\n): TaskResult {\n const { step, statusManager, isBridgeExecution } = context\n const { signature, failure } = options\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n txHash: signature,\n txLink: getTxLink(context, signature),\n txHex: undefined,\n })\n\n if (failure) {\n const cause = new SolanaTransactionDetailsError(failure.err)\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n `Transaction failed: ${cause.message}`,\n cause,\n { final: true }\n )\n }\n\n if (isBridgeExecution) {\n statusManager.updateAction(step, action.type, 'DONE')\n }\n\n return { status: 'COMPLETED' }\n}\n\n/**\n * Decides what a transaction that did not confirm is: landed after all\n * (returns its status), dropped (throws a final `TransactionExpired`), or\n * unknown (rethrows `error`, the error the task built for today's outcome).\n *\n * Dropped (see the resume rules in `transactionState.ts`) = (a)\n * `cannotLandAnymore`, AND (b) a lookup that proves the absence - a covering\n * RPC whose head is past the landing window answered `null` in the same\n * response, and no RPC has the transaction - AND (c) the status API does not\n * know the hash. The status API only vetoes: it answers 404 for landed\n * transactions it does not index too, so a miss there proves nothing.\n */\nexport async function resolveUnconfirmed(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n signature: Signature\n /** What the integrator sees when the outcome stays unknown. */\n error: unknown\n /** The slot of the `expired` verdict; `undefined` without one. */\n expiredAtSlot: bigint | undefined\n messages: ConfirmationMessages\n }\n): Promise<SignatureStatus> {\n const { client, step } = context\n const { signature, error, expiredAtSlot } = options\n const signedAt = step.execution?.signedAt\n\n // (a) The local check runs first, so a young transaction costs no request.\n if (!cannotLandAnymore({ expired: expiredAtSlot !== undefined, signedAt })) {\n throw error\n }\n // Without a signing time there is no anchor, so no canary can prove that a\n // node's history covers the transaction.\n if (signedAt === undefined) {\n throw error\n }\n\n // (b) Absence, proven by the same response that proves coverage and head.\n // Every other lookup result - also `unknown` with `answered: false`, an\n // outage - keeps the outcome unknown.\n const lookup = await lookupSignatureStatus(client, signature, {\n anchor: signedAt - CLOCK_SKEW_MARGIN_MS,\n expiredAtSlot,\n })\n if (\n lookup.kind === 'found' &&\n isConfirmedCommitment(lookup.status.confirmationStatus)\n ) {\n return lookup.status\n }\n if (lookup.kind !== 'not-found') {\n throw error\n }\n\n // (c) The veto.\n if (await isKnownToStatusApi(client, step, signature)) {\n throw error\n }\n\n clearStoredTransactions(context, action)\n // Today's expiry code and text: only the marker is new.\n throw new TransactionError(\n LiFiErrorCode.TransactionExpired,\n options.messages.notConfirmed,\n error instanceof Error ? error : undefined,\n { final: true }\n )\n}\n\n/**\n * The send-and-settle tail both wait tasks share: runs `send`, then applies\n * the result rules to what it reports.\n *\n * - A confirmation goes to `recordLanded`, with `confirmedFailure` reading\n * its on-chain failure.\n * - Every other result - `rpc-unavailable` included - goes to\n * `resolveUnconfirmed`. Only an `expired` verdict passes its slot: the\n * dropped check reads any defined slot as a verdict.\n * - A rejection comes before the first send of this run. On the first run\n * nothing ever left the SDK, so the bytes are cleared and the error is\n * rethrown: \"Try again\" signs again. On a resume an earlier run may have\n * sent the same bytes: they stay, and only the chain can make the outcome\n * final.\n */\nexport async function sendAndSettle<T>(\n context: SolanaStepExecutorContext,\n action: ExecutionAction,\n options: {\n signature: Signature\n /** Sends and races the confirmation. Rejects only before its first\n * send; the race itself never rejects. */\n send: () => Promise<RaceResult<T>>\n /** The on-chain failure of a confirmed value. */\n confirmedFailure: (value: T) => { err: unknown } | undefined\n /** An earlier run may already have sent these bytes. */\n resuming: boolean\n messages: ConfirmationMessages\n }\n): Promise<TaskResult> {\n const { signature, messages } = options\n\n /** `resolveUnconfirmed` throws for an unknown or dropped outcome, so only\n * a confirmed status reaches `recordLanded`. */\n const settleUnconfirmed = async (\n error: unknown,\n expiredAtSlot: bigint | undefined\n ): Promise<TaskResult> => {\n const status = await resolveUnconfirmed(context, action, {\n signature,\n error,\n expiredAtSlot,\n messages,\n })\n return recordLanded(context, action, {\n signature,\n failure: failureOf(status),\n })\n }\n\n let result: RaceResult<T>\n try {\n result = await options.send()\n } catch (error) {\n if (!options.resuming) {\n clearStoredTransactions(context, action)\n throw error\n }\n return settleUnconfirmed(error, undefined)\n }\n\n if (result.kind === 'confirmed') {\n return recordLanded(context, action, {\n signature,\n failure: options.confirmedFailure(result.value),\n })\n }\n\n return settleUnconfirmed(\n confirmationError(result, messages),\n // The head a covering RPC has to reach before its `null` counts.\n result.kind === 'expired' ? result.slot : undefined\n )\n}\n"],"mappings":"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"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { ExecutionAction, LiFiStep, SDKError } from "@lifi/sdk";
|
|
2
|
-
|
|
3
|
-
export declare const parseSolanaErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
4
|
-
//#endregion
|
|
5
|
-
//# sourceMappingURL=parseSolanaErrors.d.ts.map
|
|
2
|
+
export declare const parseSolanaErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _lifi_sdk = require("@lifi/sdk");
|
|
3
|
-
|
|
3
|
+
// src/errors/parseSolanaErrors.ts
|
|
4
4
|
const parseSolanaErrors = async (e, step, action) => {
|
|
5
5
|
if (e instanceof _lifi_sdk.SDKError) {
|
|
6
6
|
e.step = e.step ?? step;
|
|
@@ -27,7 +27,6 @@ const handleSpecificErrors = (e) => {
|
|
|
27
27
|
if (e instanceof _lifi_sdk.BaseError) return e;
|
|
28
28
|
return new _lifi_sdk.UnknownError(e.message || _lifi_sdk.ErrorMessage.UnknownError, e);
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
exports.parseSolanaErrors = parseSolanaErrors;
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=parseSolanaErrors.js.map
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SolanaProviderOptions, SolanaSDKProvider, isSolanaProvider } from "./types.js";
|
|
2
1
|
import { SolanaProvider } from "./SolanaProvider.js";
|
|
2
|
+
import { SolanaProviderOptions, SolanaSDKProvider, isSolanaProvider } from "./types.js";
|
|
3
3
|
import { KeypairWalletAdapter } from "./utils/KeypairWalletAdapter.js";
|
|
4
4
|
import { SolanaTransactionDetailsError } from "./utils/solanaErrorCause.js";
|
|
5
5
|
import { address as toAddress } from "@solana/kit";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_solanaErrorCause = require("./utils/solanaErrorCause.js");
|
|
3
2
|
const require_SolanaProvider = require("./SolanaProvider.js");
|
|
4
3
|
const require_types = require("./types.js");
|
|
5
4
|
const require_utils_KeypairWalletAdapter = require("./utils/KeypairWalletAdapter.js");
|
|
5
|
+
const require_utils_solanaErrorCause = require("./utils/solanaErrorCause.js");
|
|
6
6
|
let _solana_kit = require("@solana/kit");
|
|
7
7
|
exports.KeypairWalletAdapter = require_utils_KeypairWalletAdapter.KeypairWalletAdapter;
|
|
8
8
|
exports.SolanaProvider = require_SolanaProvider.SolanaProvider;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JitoRegion } from "../types.js";
|
|
2
2
|
import { Signature } from "@solana/kit";
|
|
3
|
-
//#region src/rpc/jito/api/getBundleStatuses.d.ts
|
|
4
3
|
type BundleStatus = {
|
|
5
4
|
bundle_id: string;
|
|
6
5
|
/** Optional: unvalidated wire data, so the reader must handle its absence. */
|
|
@@ -23,6 +22,4 @@ export type GetBundleStatusesApi = {
|
|
|
23
22
|
*/
|
|
24
23
|
getBundleStatuses(bundleIds: string[], region?: JitoRegion): GetBundleStatusesResponse;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=getBundleStatuses.d.ts.map
|
|
25
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JitoRegion } from "../types.js";
|
|
2
|
-
//#region src/rpc/jito/api/getTipAccounts.d.ts
|
|
3
2
|
/** Array of tip account addresses (Solana public keys) */
|
|
4
3
|
type GetTipAccountsResponse = string[];
|
|
5
4
|
export type GetTipAccountsApi = {
|
|
@@ -10,6 +9,4 @@ export type GetTipAccountsApi = {
|
|
|
10
9
|
*/
|
|
11
10
|
getTipAccounts(region?: JitoRegion): GetTipAccountsResponse;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=getTipAccounts.d.ts.map
|
|
12
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JitoRegion } from "../types.js";
|
|
2
2
|
import { Base64EncodedWireTransaction } from "@solana/kit";
|
|
3
|
-
//#region src/rpc/jito/api/sendBundle.d.ts
|
|
4
3
|
/** Bundle ID returned on successful submission */
|
|
5
4
|
type SendBundleResponse = string;
|
|
6
5
|
export type SendBundleApi = {
|
|
@@ -17,6 +16,4 @@ export type SendBundleApi = {
|
|
|
17
16
|
*/
|
|
18
17
|
sendBundle(transactions: Array<Base64EncodedWireTransaction>, region?: JitoRegion): SendBundleResponse;
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=sendBundle.d.ts.map
|
|
19
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Base64EncodedWireTransaction } from "@solana/kit";
|
|
2
|
-
//#region src/rpc/jito/api/simulateBundle.d.ts
|
|
3
2
|
type AccountConfig = {
|
|
4
3
|
accountIndex: number;
|
|
5
4
|
addresses: string[];
|
|
@@ -56,6 +55,4 @@ export type SimulateBundleApi = {
|
|
|
56
55
|
postExecutionAccountsConfigs?: AccountConfig[];
|
|
57
56
|
}>): SimulateBundleResponse;
|
|
58
57
|
};
|
|
59
|
-
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=simulateBundle.d.ts.map
|
|
58
|
+
export {};
|
|
@@ -3,10 +3,7 @@ import { GetTipAccountsApi } from "./api/getTipAccounts.js";
|
|
|
3
3
|
import { SendBundleApi } from "./api/sendBundle.js";
|
|
4
4
|
import { SimulateBundleApi } from "./api/simulateBundle.js";
|
|
5
5
|
import { ClusterUrl, Rpc, RpcTransport, SolanaRpcApi, createDefaultRpcTransport } from "@solana/kit";
|
|
6
|
-
//#region src/rpc/jito/createJitoRpc.d.ts
|
|
7
6
|
export type JitoBundleApi = GetBundleStatusesApi & GetTipAccountsApi & SendBundleApi & SimulateBundleApi;
|
|
8
7
|
export type JitoRpcApi = JitoBundleApi & SolanaRpcApi;
|
|
9
8
|
export declare function createJitoRpcFromTransport<TTransport extends RpcTransport>(transport: TTransport): Rpc<JitoRpcApi>;
|
|
10
|
-
export declare function createJitoRpc<TClusterUrl extends ClusterUrl>(clusterUrl: TClusterUrl, config?: Omit<Parameters<typeof createDefaultRpcTransport<TClusterUrl>>[0], "url">): Rpc<JitoRpcApi>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//# sourceMappingURL=createJitoRpc.d.ts.map
|
|
9
|
+
export declare function createJitoRpc<TClusterUrl extends ClusterUrl>(clusterUrl: TClusterUrl, config?: Omit<Parameters<typeof createDefaultRpcTransport<TClusterUrl>>[0], "url">): Rpc<JitoRpcApi>;
|