@lifi/sdk-provider-solana 4.0.1-alpha.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +88 -5
- package/dist/cjs/SolanaProvider.d.ts +7 -2
- package/dist/cjs/SolanaProvider.js +31 -34
- package/dist/cjs/SolanaProvider.js.map +1 -1
- package/dist/cjs/actions/getSNSAddress.d.ts +5 -1
- package/dist/cjs/actions/getSNSAddress.js +16 -22
- package/dist/cjs/actions/getSNSAddress.js.map +1 -1
- package/dist/cjs/actions/getSolanaBalance.d.ts +7 -3
- package/dist/cjs/actions/getSolanaBalance.js +70 -79
- package/dist/cjs/actions/getSolanaBalance.js.map +1 -1
- package/dist/cjs/actions/resolveSolanaAddress.d.ts +5 -1
- package/dist/cjs/actions/resolveSolanaAddress.js +7 -5
- package/dist/cjs/actions/resolveSolanaAddress.js.map +1 -1
- package/dist/cjs/actions/sendAndConfirmBundle.d.ts +29 -17
- package/dist/cjs/actions/sendAndConfirmBundle.js +64 -84
- package/dist/cjs/actions/sendAndConfirmBundle.js.map +1 -1
- package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +26 -15
- package/dist/cjs/actions/sendAndConfirmTransaction.js +73 -97
- package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/cjs/core/SolanaStepExecutor.d.ts +17 -0
- package/dist/cjs/core/SolanaStepExecutor.js +49 -0
- package/dist/cjs/core/SolanaStepExecutor.js.map +1 -0
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +35 -0
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.d.ts +10 -0
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +37 -0
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -0
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +46 -0
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.d.ts +10 -0
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js +18 -0
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js.map +1 -0
- package/dist/cjs/errors/parseSolanaErrors.d.ts +7 -2
- package/dist/cjs/errors/parseSolanaErrors.js +18 -28
- package/dist/cjs/errors/parseSolanaErrors.js.map +1 -1
- package/dist/cjs/index.d.ts +6 -5
- package/dist/cjs/index.js +16 -12
- package/dist/cjs/rpc/jito/api/getBundleStatuses.d.ts +22 -14
- package/dist/cjs/rpc/jito/api/getBundleStatuses.js +0 -3
- package/dist/cjs/rpc/jito/api/getTipAccounts.d.ts +14 -4
- package/dist/cjs/rpc/jito/api/getTipAccounts.js +0 -3
- package/dist/cjs/rpc/jito/api/sendBundle.d.ts +21 -5
- package/dist/cjs/rpc/jito/api/sendBundle.js +0 -3
- package/dist/cjs/rpc/jito/api/simulateBundle.d.ts +49 -41
- package/dist/cjs/rpc/jito/api/simulateBundle.js +0 -3
- package/dist/cjs/rpc/jito/createJitoRpc.d.ts +14 -10
- package/dist/cjs/rpc/jito/createJitoRpc.js +16 -11
- package/dist/cjs/rpc/jito/createJitoRpc.js.map +1 -1
- package/dist/cjs/rpc/jito/types.d.ts +8 -1
- package/dist/cjs/rpc/jito/types.js +0 -3
- package/dist/cjs/rpc/registry.d.ts +21 -5
- package/dist/cjs/rpc/registry.js +47 -35
- package/dist/cjs/rpc/registry.js.map +1 -1
- package/dist/cjs/rpc/types.d.ts +9 -4
- package/dist/cjs/rpc/types.js +0 -3
- package/dist/cjs/rpc/utils.d.ts +67 -4
- package/dist/cjs/rpc/utils.js +79 -22
- package/dist/cjs/rpc/utils.js.map +1 -1
- package/dist/cjs/types.d.ts +25 -9
- package/dist/cjs/types.js +7 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/KeypairWallet.unit.helpers.d.ts +7 -3
- package/dist/cjs/utils/KeypairWallet.unit.helpers.js +15 -17
- package/dist/cjs/utils/KeypairWallet.unit.helpers.js.map +1 -1
- package/dist/cjs/utils/KeypairWalletAdapter.d.ts +29 -16
- package/dist/cjs/utils/KeypairWalletAdapter.js +80 -83
- package/dist/cjs/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/cjs/utils/base64ToUint8Array.d.ts +5 -1
- package/dist/cjs/utils/base64ToUint8Array.js +10 -10
- package/dist/cjs/utils/base64ToUint8Array.js.map +1 -1
- package/dist/cjs/utils/getWalletFeature.d.ts +28 -8
- package/dist/cjs/utils/getWalletFeature.js +23 -8
- package/dist/cjs/utils/getWalletFeature.js.map +1 -1
- package/dist/cjs/utils/shouldUseJitoBundle.d.ts +8 -0
- package/dist/cjs/utils/shouldUseJitoBundle.js +12 -0
- package/dist/cjs/utils/shouldUseJitoBundle.js.map +1 -0
- package/dist/cjs/utils/solanaErrorCause.d.ts +15 -0
- package/dist/cjs/utils/solanaErrorCause.js +24 -0
- package/dist/cjs/utils/solanaErrorCause.js.map +1 -0
- package/dist/cjs/version.d.ts +6 -2
- package/dist/cjs/version.js +8 -5
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/SolanaProvider.d.ts +7 -2
- package/dist/esm/SolanaProvider.d.ts.map +1 -0
- package/dist/esm/SolanaProvider.js +31 -32
- package/dist/esm/SolanaProvider.js.map +1 -1
- package/dist/esm/actions/getSNSAddress.d.ts +5 -1
- package/dist/esm/actions/getSNSAddress.d.ts.map +1 -0
- package/dist/esm/actions/getSNSAddress.js +17 -23
- package/dist/esm/actions/getSNSAddress.js.map +1 -1
- package/dist/esm/actions/getSolanaBalance.d.ts +7 -3
- package/dist/esm/actions/getSolanaBalance.d.ts.map +1 -0
- package/dist/esm/actions/getSolanaBalance.js +70 -78
- package/dist/esm/actions/getSolanaBalance.js.map +1 -1
- package/dist/esm/actions/resolveSolanaAddress.d.ts +5 -1
- package/dist/esm/actions/resolveSolanaAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveSolanaAddress.js +7 -3
- package/dist/esm/actions/resolveSolanaAddress.js.map +1 -1
- package/dist/esm/actions/sendAndConfirmBundle.d.ts +28 -24
- package/dist/esm/actions/sendAndConfirmBundle.d.ts.map +1 -0
- package/dist/esm/actions/sendAndConfirmBundle.js +63 -97
- package/dist/esm/actions/sendAndConfirmBundle.js.map +1 -1
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts +25 -21
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -0
- package/dist/esm/actions/sendAndConfirmTransaction.js +72 -111
- package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/esm/core/SolanaStepExecutor.d.ts +17 -0
- package/dist/esm/core/SolanaStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/SolanaStepExecutor.js +48 -0
- package/dist/esm/core/SolanaStepExecutor.js.map +1 -0
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +34 -0
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts +10 -0
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +36 -0
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -0
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +45 -0
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -0
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts +10 -0
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js +17 -0
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js.map +1 -0
- package/dist/esm/errors/parseSolanaErrors.d.ts +7 -2
- package/dist/esm/errors/parseSolanaErrors.d.ts.map +1 -0
- package/dist/esm/errors/parseSolanaErrors.js +18 -25
- package/dist/esm/errors/parseSolanaErrors.js.map +1 -1
- package/dist/esm/index.d.ts +6 -5
- package/dist/esm/index.js +6 -6
- package/dist/esm/package.json +1 -1
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts +22 -22
- package/dist/esm/rpc/jito/api/getBundleStatuses.d.ts.map +1 -0
- package/dist/esm/rpc/jito/api/getBundleStatuses.js +0 -1
- package/dist/esm/rpc/jito/api/getTipAccounts.d.ts +13 -11
- package/dist/esm/rpc/jito/api/getTipAccounts.d.ts.map +1 -0
- package/dist/esm/rpc/jito/api/getTipAccounts.js +0 -1
- package/dist/esm/rpc/jito/api/sendBundle.d.ts +20 -20
- package/dist/esm/rpc/jito/api/sendBundle.d.ts.map +1 -0
- package/dist/esm/rpc/jito/api/sendBundle.js +0 -1
- package/dist/esm/rpc/jito/api/simulateBundle.d.ts +49 -50
- package/dist/esm/rpc/jito/api/simulateBundle.d.ts.map +1 -0
- package/dist/esm/rpc/jito/api/simulateBundle.js +0 -1
- package/dist/esm/rpc/jito/createJitoRpc.d.ts +14 -10
- package/dist/esm/rpc/jito/createJitoRpc.d.ts.map +1 -0
- package/dist/esm/rpc/jito/createJitoRpc.js +16 -12
- package/dist/esm/rpc/jito/createJitoRpc.js.map +1 -1
- package/dist/esm/rpc/jito/types.d.ts +7 -3
- package/dist/esm/rpc/jito/types.d.ts.map +1 -0
- package/dist/esm/rpc/jito/types.js +0 -1
- package/dist/esm/rpc/registry.d.ts +18 -13
- package/dist/esm/rpc/registry.d.ts.map +1 -0
- package/dist/esm/rpc/registry.js +44 -47
- package/dist/esm/rpc/registry.js.map +1 -1
- package/dist/esm/rpc/types.d.ts +9 -4
- package/dist/esm/rpc/types.d.ts.map +1 -0
- package/dist/esm/rpc/types.js +0 -1
- package/dist/esm/rpc/utils.d.ts +64 -57
- package/dist/esm/rpc/utils.d.ts.map +1 -0
- package/dist/esm/rpc/utils.js +73 -75
- package/dist/esm/rpc/utils.js.map +1 -1
- package/dist/esm/types.d.ts +25 -9
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +7 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts +7 -3
- package/dist/esm/utils/KeypairWallet.unit.helpers.d.ts.map +1 -0
- package/dist/esm/utils/KeypairWallet.unit.helpers.js +16 -16
- package/dist/esm/utils/KeypairWallet.unit.helpers.js.map +1 -1
- package/dist/esm/utils/KeypairWalletAdapter.d.ts +28 -23
- package/dist/esm/utils/KeypairWalletAdapter.d.ts.map +1 -0
- package/dist/esm/utils/KeypairWalletAdapter.js +79 -89
- package/dist/esm/utils/KeypairWalletAdapter.js.map +1 -1
- package/dist/esm/utils/base64ToUint8Array.d.ts +5 -1
- package/dist/esm/utils/base64ToUint8Array.d.ts.map +1 -0
- package/dist/esm/utils/base64ToUint8Array.js +10 -8
- package/dist/esm/utils/base64ToUint8Array.js.map +1 -1
- package/dist/esm/utils/getWalletFeature.d.ts +27 -23
- package/dist/esm/utils/getWalletFeature.d.ts.map +1 -0
- package/dist/esm/utils/getWalletFeature.js +22 -23
- package/dist/esm/utils/getWalletFeature.js.map +1 -1
- package/dist/esm/utils/shouldUseJitoBundle.d.ts +8 -0
- package/dist/esm/utils/shouldUseJitoBundle.d.ts.map +1 -0
- package/dist/esm/utils/shouldUseJitoBundle.js +11 -0
- package/dist/esm/utils/shouldUseJitoBundle.js.map +1 -0
- package/dist/esm/utils/solanaErrorCause.d.ts +15 -0
- package/dist/esm/utils/solanaErrorCause.d.ts.map +1 -0
- package/dist/esm/utils/solanaErrorCause.js +22 -0
- package/dist/esm/utils/solanaErrorCause.js.map +1 -0
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +9 -8
- package/src/SolanaProvider.ts +2 -1
- package/src/actions/getSNSAddress.ts +3 -1
- package/src/actions/getSolanaBalance.ts +25 -18
- package/src/actions/sendAndConfirmBundle.ts +11 -1
- package/src/actions/sendAndConfirmTransaction.ts +13 -1
- package/src/core/SolanaStepExecutor.ts +102 -0
- package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +86 -0
- package/src/core/tasks/SolanaSignAndExecuteTask.ts +99 -0
- package/src/core/tasks/SolanaStandardWaitForTransactionTask.ts +112 -0
- package/src/core/tasks/SolanaWaitForTransactionTask.ts +23 -0
- package/src/index.ts +1 -0
- package/src/rpc/registry.ts +28 -18
- package/src/rpc/utils.ts +10 -2
- package/src/types.ts +17 -1
- package/src/utils/KeypairWallet.unit.helpers.ts +4 -1
- package/src/utils/base64ToUint8Array.ts +1 -1
- package/src/utils/shouldUseJitoBundle.ts +18 -0
- package/src/utils/solanaErrorCause.ts +24 -0
- package/src/version.ts +1 -1
- package/dist/cjs/SolanaStepExecutor.d.ts +0 -9
- package/dist/cjs/SolanaStepExecutor.js +0 -177
- package/dist/cjs/SolanaStepExecutor.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/rpc/jito/api/getBundleStatuses.js.map +0 -1
- package/dist/cjs/rpc/jito/api/getTipAccounts.js.map +0 -1
- package/dist/cjs/rpc/jito/api/sendBundle.js.map +0 -1
- package/dist/cjs/rpc/jito/api/simulateBundle.js.map +0 -1
- package/dist/cjs/rpc/jito/types.js.map +0 -1
- package/dist/cjs/rpc/types.js.map +0 -1
- package/dist/cjs/utils/withTimeout.d.ts +0 -7
- package/dist/cjs/utils/withTimeout.js +0 -35
- package/dist/cjs/utils/withTimeout.js.map +0 -1
- package/dist/esm/SolanaStepExecutor.d.ts +0 -9
- package/dist/esm/SolanaStepExecutor.js +0 -185
- package/dist/esm/SolanaStepExecutor.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/rpc/jito/api/getBundleStatuses.js.map +0 -1
- package/dist/esm/rpc/jito/api/getTipAccounts.js.map +0 -1
- package/dist/esm/rpc/jito/api/sendBundle.js.map +0 -1
- package/dist/esm/rpc/jito/api/simulateBundle.js.map +0 -1
- package/dist/esm/rpc/jito/types.js.map +0 -1
- package/dist/esm/rpc/types.js.map +0 -1
- package/dist/esm/utils/withTimeout.d.ts +0 -16
- package/dist/esm/utils/withTimeout.js +0 -41
- package/dist/esm/utils/withTimeout.js.map +0 -1
- package/dist/types/SolanaProvider.d.ts +0 -3
- package/dist/types/SolanaProvider.d.ts.map +0 -1
- package/dist/types/SolanaStepExecutor.d.ts +0 -10
- package/dist/types/SolanaStepExecutor.d.ts.map +0 -1
- package/dist/types/actions/getSNSAddress.d.ts +0 -2
- package/dist/types/actions/getSNSAddress.d.ts.map +0 -1
- package/dist/types/actions/getSolanaBalance.d.ts +0 -4
- package/dist/types/actions/getSolanaBalance.d.ts.map +0 -1
- package/dist/types/actions/resolveSolanaAddress.d.ts +0 -2
- package/dist/types/actions/resolveSolanaAddress.d.ts.map +0 -1
- package/dist/types/actions/sendAndConfirmBundle.d.ts +0 -29
- package/dist/types/actions/sendAndConfirmBundle.d.ts.map +0 -1
- package/dist/types/actions/sendAndConfirmTransaction.d.ts +0 -27
- package/dist/types/actions/sendAndConfirmTransaction.d.ts.map +0 -1
- package/dist/types/errors/parseSolanaErrors.d.ts +0 -3
- package/dist/types/errors/parseSolanaErrors.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/rpc/jito/api/getBundleStatuses.d.ts +0 -28
- package/dist/types/rpc/jito/api/getBundleStatuses.d.ts.map +0 -1
- package/dist/types/rpc/jito/api/getTipAccounts.d.ts +0 -15
- package/dist/types/rpc/jito/api/getTipAccounts.d.ts.map +0 -1
- package/dist/types/rpc/jito/api/sendBundle.d.ts +0 -24
- package/dist/types/rpc/jito/api/sendBundle.d.ts.map +0 -1
- package/dist/types/rpc/jito/api/simulateBundle.d.ts +0 -59
- package/dist/types/rpc/jito/api/simulateBundle.d.ts.map +0 -1
- package/dist/types/rpc/jito/createJitoRpc.d.ts +0 -11
- package/dist/types/rpc/jito/createJitoRpc.d.ts.map +0 -1
- package/dist/types/rpc/jito/types.d.ts +0 -5
- package/dist/types/rpc/jito/types.d.ts.map +0 -1
- package/dist/types/rpc/registry.d.ts +0 -17
- package/dist/types/rpc/registry.d.ts.map +0 -1
- package/dist/types/rpc/types.d.ts +0 -5
- package/dist/types/rpc/types.d.ts.map +0 -1
- package/dist/types/rpc/utils.d.ts +0 -61
- package/dist/types/rpc/utils.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -13
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/KeypairWallet.unit.helpers.d.ts +0 -5
- package/dist/types/utils/KeypairWallet.unit.helpers.d.ts.map +0 -1
- package/dist/types/utils/KeypairWalletAdapter.d.ts +0 -26
- package/dist/types/utils/KeypairWalletAdapter.d.ts.map +0 -1
- package/dist/types/utils/base64ToUint8Array.d.ts +0 -2
- package/dist/types/utils/base64ToUint8Array.d.ts.map +0 -1
- package/dist/types/utils/getWalletFeature.d.ts +0 -27
- package/dist/types/utils/getWalletFeature.d.ts.map +0 -1
- package/dist/types/utils/withTimeout.d.ts +0 -17
- package/dist/types/utils/withTimeout.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -3
- package/dist/types/version.d.ts.map +0 -1
- package/src/SolanaStepExecutor.ts +0 -346
- package/src/utils/withTimeout.ts +0 -50
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @lifi/sdk-provider-solana
|
|
2
|
+
|
|
3
|
+
## 4.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#402](https://github.com/lifinance/sdk/pull/402) [`bf3d047`](https://github.com/lifinance/sdk/commit/bf3d047ebdc9a8b3a5a6362f65d25aa1eb652ffa) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: @lifi/types to 17.85.0, viem to 2.52.2, @solana/kit to 6.10.0 (with @solana/wallet-standard-features and @wallet-standard/base), @mysten/sui to 2.19.0, and @tronweb3/tronwallet-abstract-adapter to 1.2.0.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`bf3d047`](https://github.com/lifinance/sdk/commit/bf3d047ebdc9a8b3a5a6362f65d25aa1eb652ffa)]:
|
|
10
|
+
- @lifi/sdk@4.0.1
|
|
11
|
+
|
|
12
|
+
## 4.0.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#387](https://github.com/lifinance/sdk/pull/387) [`12ee1f1`](https://github.com/lifinance/sdk/commit/12ee1f1bf7e79b67842d4d8ca606a80fe0913653) Thanks [@chybisov](https://github.com/chybisov)! - Preserve Solana RPC error details on failed transactions. The structured `err` payload (and `logs`, for simulation failures) from a failed simulation or confirmation is now attached to the thrown `TransactionError`'s `cause` as a new `SolanaTransactionDetailsError`, so consumers can inspect the original error and logs directly without re-simulating. `SolanaTransactionDetailsError` is exported from the package root.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies []:
|
|
19
|
+
- @lifi/sdk@4.0.0
|
|
20
|
+
|
|
21
|
+
## 4.0.0-beta.12
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#387](https://github.com/lifinance/sdk/pull/387) [`12ee1f1`](https://github.com/lifinance/sdk/commit/12ee1f1bf7e79b67842d4d8ca606a80fe0913653) Thanks [@chybisov](https://github.com/chybisov)! - Preserve Solana RPC error details on failed transactions. The structured `err` payload (and `logs`, for simulation failures) from a failed simulation or confirmation is now attached to the thrown `TransactionError`'s `cause` as a new `SolanaTransactionDetailsError`, so consumers can inspect the original error and logs directly without re-simulating. `SolanaTransactionDetailsError` is exported from the package root.
|
package/README.md
CHANGED
|
@@ -13,18 +13,23 @@
|
|
|
13
13
|
|
|
14
14
|
[**LI.FI SDK**](https://docs.li.fi/sdk/overview) features include:
|
|
15
15
|
|
|
16
|
+
- **Modular architecture** - Install only the provider packages you need for your supported blockchain ecosystems (EVM, Solana, Bitcoin, Sui, Tron)
|
|
16
17
|
- All ecosystems, chains, bridges, exchanges, and solvers that [LI.FI](https://docs.li.fi/introduction/chains) supports
|
|
17
18
|
- Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
|
|
18
19
|
- Easy tracking of the route and quote execution through the robust event and hooks handling
|
|
19
20
|
- Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
|
|
20
21
|
- Supports widely adopted industry standards, including [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792), [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612), [EIP-712](https://eips.ethereum.org/EIPS/eip-712), and [Permit2](https://github.com/Uniswap/permit2)
|
|
21
|
-
- SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/), [
|
|
22
|
+
- SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/) for EVM, [Solana Kit](https://github.com/solana-labs/solana-web3.js) for Solana, [Bigmi](https://github.com/lifinance/bigmi) for Bitcoin, [Mysten Sui SDK](https://github.com/MystenLabs/sui/tree/main/sdk) for Sui, [TronWeb](https://tronweb.network/) for Tron)
|
|
22
23
|
- Support for arbitrary contract calls on the destination chain
|
|
23
24
|
- Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
|
|
24
25
|
- Compatibility tested with Node.js and popular front-end tools like Vite
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
27
28
|
|
|
29
|
+
The LI.FI SDK follows a modular architecture. Install the core SDK package and the provider packages for the blockchain ecosystems you need:
|
|
30
|
+
|
|
31
|
+
### Core SDK
|
|
32
|
+
|
|
28
33
|
```bash
|
|
29
34
|
pnpm add @lifi/sdk
|
|
30
35
|
```
|
|
@@ -35,17 +40,95 @@ or
|
|
|
35
40
|
npm install --save @lifi/sdk
|
|
36
41
|
```
|
|
37
42
|
|
|
43
|
+
### Provider Packages
|
|
44
|
+
|
|
45
|
+
Install provider packages based on the blockchain ecosystems you want to support:
|
|
46
|
+
|
|
47
|
+
**EVM Chains (Ethereum, Polygon, Arbitrum, Optimism, etc.)**
|
|
48
|
+
```bash
|
|
49
|
+
pnpm add @lifi/sdk-provider-ethereum
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Solana**
|
|
53
|
+
```bash
|
|
54
|
+
pnpm add @lifi/sdk-provider-solana
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Bitcoin**
|
|
58
|
+
```bash
|
|
59
|
+
pnpm add @lifi/sdk-provider-bitcoin
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Sui**
|
|
63
|
+
```bash
|
|
64
|
+
pnpm add @lifi/sdk-provider-sui
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Tron**
|
|
68
|
+
```bash
|
|
69
|
+
pnpm add @lifi/sdk-provider-tron
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Architecture
|
|
73
|
+
|
|
74
|
+
The LI.FI SDK uses a modular provider architecture:
|
|
75
|
+
|
|
76
|
+
- **`@lifi/sdk`** - Core SDK package containing shared functionality, actions, and execution logic
|
|
77
|
+
- **Provider packages** - Ecosystem-specific packages that handle wallet interactions and transaction execution for different blockchain types
|
|
78
|
+
|
|
79
|
+
This architecture allows you to:
|
|
80
|
+
- Install only the providers you need, reducing bundle size
|
|
81
|
+
- Use ecosystem-specific libraries optimized for each blockchain
|
|
82
|
+
- Maintain clean separation between core SDK logic and blockchain-specific implementations
|
|
83
|
+
|
|
38
84
|
## Quick Start
|
|
39
85
|
|
|
40
86
|
### Set up the SDK
|
|
41
87
|
|
|
42
|
-
|
|
88
|
+
Create SDK config with your integrator string and configure the providers for the blockchain ecosystems you want to support.
|
|
43
89
|
|
|
90
|
+
**For EVM chains:**
|
|
44
91
|
```ts
|
|
45
|
-
import {
|
|
92
|
+
import { createClient } from '@lifi/sdk'
|
|
93
|
+
import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
|
|
94
|
+
import { createWalletClient, http } from 'viem'
|
|
95
|
+
import { mainnet } from 'viem/chains'
|
|
96
|
+
|
|
97
|
+
// Add your account (e.g. privateKeyToAccount, mnemonicToAccount)
|
|
98
|
+
const walletClient = createWalletClient({
|
|
99
|
+
account,
|
|
100
|
+
chain: mainnet,
|
|
101
|
+
transport: http(),
|
|
102
|
+
})
|
|
46
103
|
|
|
47
|
-
|
|
104
|
+
const client = createClient({
|
|
105
|
+
integrator: 'Your dApp/company name',
|
|
106
|
+
providers: [
|
|
107
|
+
EthereumProvider({
|
|
108
|
+
getWalletClient: () => Promise.resolve(walletClient),
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**For multiple ecosystems:**
|
|
115
|
+
```ts
|
|
116
|
+
import { createClient } from '@lifi/sdk'
|
|
117
|
+
import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
|
|
118
|
+
import { SolanaProvider } from '@lifi/sdk-provider-solana'
|
|
119
|
+
import { BitcoinProvider } from '@lifi/sdk-provider-bitcoin'
|
|
120
|
+
import { SuiProvider } from '@lifi/sdk-provider-sui'
|
|
121
|
+
import { TronProvider } from '@lifi/sdk-provider-tron'
|
|
122
|
+
|
|
123
|
+
const client = createClient({
|
|
48
124
|
integrator: 'Your dApp/company name',
|
|
125
|
+
providers: [
|
|
126
|
+
EthereumProvider({ /* options */ }),
|
|
127
|
+
SolanaProvider({ /* options */ }),
|
|
128
|
+
BitcoinProvider({ /* options */ }),
|
|
129
|
+
SuiProvider({ /* options */ }),
|
|
130
|
+
TronProvider({ /* options */ }),
|
|
131
|
+
],
|
|
49
132
|
})
|
|
50
133
|
```
|
|
51
134
|
|
|
@@ -56,7 +139,7 @@ Now you can interact with the SDK and for example request a quote.
|
|
|
56
139
|
```ts
|
|
57
140
|
import { ChainId, getQuote } from '@lifi/sdk'
|
|
58
141
|
|
|
59
|
-
const quote = await getQuote({
|
|
142
|
+
const quote = await getQuote(client, {
|
|
60
143
|
fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
61
144
|
fromChain: ChainId.ARB,
|
|
62
145
|
toChain: ChainId.OPT,
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SolanaProviderOptions, SolanaSDKProvider } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/SolanaProvider.d.ts
|
|
4
|
+
declare function SolanaProvider(options?: SolanaProviderOptions): SolanaSDKProvider;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { SolanaProvider };
|
|
7
|
+
//# sourceMappingURL=SolanaProvider.d.ts.map
|
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const SolanaStepExecutor_js_1 = require("./SolanaStepExecutor.js");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_actions_getSolanaBalance = require("./actions/getSolanaBalance.js");
|
|
3
|
+
const require_actions_resolveSolanaAddress = require("./actions/resolveSolanaAddress.js");
|
|
4
|
+
const require_core_SolanaStepExecutor = require("./core/SolanaStepExecutor.js");
|
|
5
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
6
|
+
let _solana_kit = require("@solana/kit");
|
|
7
|
+
//#region src/SolanaProvider.ts
|
|
9
8
|
function SolanaProvider(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
setOptions(options) {
|
|
33
|
-
Object.assign(_options, options);
|
|
34
|
-
},
|
|
35
|
-
};
|
|
9
|
+
const _options = options ?? {};
|
|
10
|
+
return {
|
|
11
|
+
get type() {
|
|
12
|
+
return _lifi_sdk.ChainType.SVM;
|
|
13
|
+
},
|
|
14
|
+
isAddress: _solana_kit.isAddress,
|
|
15
|
+
resolveAddress: require_actions_resolveSolanaAddress.resolveSolanaAddress,
|
|
16
|
+
getBalance: require_actions_getSolanaBalance.getSolanaBalance,
|
|
17
|
+
async getStepExecutor(options) {
|
|
18
|
+
if (!_options.getWallet) throw new _lifi_sdk.ProviderError(_lifi_sdk.LiFiErrorCode.ConfigError, "SolanaProvider requires a getWallet function");
|
|
19
|
+
return new require_core_SolanaStepExecutor.SolanaStepExecutor({
|
|
20
|
+
wallet: await _options.getWallet(),
|
|
21
|
+
routeId: options.routeId,
|
|
22
|
+
skipSimulation: _options.skipSimulation,
|
|
23
|
+
executionOptions: { ...options.executionOptions }
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
setOptions(options) {
|
|
27
|
+
Object.assign(_options, options);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
36
30
|
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.SolanaProvider = SolanaProvider;
|
|
33
|
+
|
|
37
34
|
//# sourceMappingURL=SolanaProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaProvider.js","
|
|
1
|
+
{"version":3,"file":"SolanaProvider.js","names":["ChainType","resolveSolanaAddress","getSolanaBalance","ProviderError","LiFiErrorCode","SolanaStepExecutor"],"sources":["../../src/SolanaProvider.ts"],"sourcesContent":["import {\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type StepExecutorOptions,\n} from '@lifi/sdk'\nimport { isAddress } from '@solana/kit'\nimport { getSolanaBalance } from './actions/getSolanaBalance.js'\nimport { resolveSolanaAddress } from './actions/resolveSolanaAddress.js'\nimport { SolanaStepExecutor } from './core/SolanaStepExecutor.js'\nimport type { SolanaProviderOptions, SolanaSDKProvider } from './types.js'\n\nexport function SolanaProvider(\n options?: SolanaProviderOptions\n): SolanaSDKProvider {\n const _options: SolanaProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.SVM\n },\n isAddress,\n resolveAddress: resolveSolanaAddress,\n getBalance: getSolanaBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<SolanaStepExecutor> {\n if (!_options.getWallet) {\n throw new ProviderError(\n LiFiErrorCode.ConfigError,\n 'SolanaProvider requires a getWallet function'\n )\n }\n\n const wallet = await _options.getWallet()\n\n const executor = new SolanaStepExecutor({\n wallet,\n routeId: options.routeId,\n skipSimulation: _options.skipSimulation,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: SolanaProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,eACd,SACmB;CACnB,MAAM,WAAkC,WAAW,CAAC;CACpD,OAAO;EACL,IAAI,OAAO;GACT,OAAOA,UAAAA,UAAU;EACnB;EACA,WAAA,YAAA;EACA,gBAAgBC,qCAAAA;EAChB,YAAYC,iCAAAA;EACZ,MAAM,gBACJ,SAC6B;GAC7B,IAAI,CAAC,SAAS,WACZ,MAAM,IAAIC,UAAAA,cACRC,UAAAA,cAAc,aACd,8CACF;GAcF,OAAO,IATcC,gCAAAA,mBAAmB;IACtC,QAAA,MAHmB,SAAS,UAAU;IAItC,SAAS,QAAQ;IACjB,gBAAgB,SAAS;IACzB,kBAAkB,EAChB,GAAG,QAAQ,iBACb;GACF,CAEc;EAChB;EACA,WAAW,SAAgC;GACzC,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/actions/getSNSAddress.d.ts
|
|
2
|
+
declare const getSNSAddress: (name: string) => Promise<string | undefined>;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { getSNSAddress };
|
|
5
|
+
//# sourceMappingURL=getSNSAddress.d.ts.map
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const kit_1 = require("@solana/kit");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _solana_kit = require("@solana/kit");
|
|
3
|
+
//#region src/actions/getSNSAddress.ts
|
|
5
4
|
const getSNSAddress = async (name) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return data.result;
|
|
20
|
-
}
|
|
21
|
-
catch (_) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
5
|
+
try {
|
|
6
|
+
if (!name.endsWith(".sol")) return;
|
|
7
|
+
const snsWorkerUrl = `https://sns-sdk-proxy.bonfida.workers.dev/resolve/${name}`;
|
|
8
|
+
const response = await fetch(snsWorkerUrl);
|
|
9
|
+
if (!response.ok) return;
|
|
10
|
+
const data = await response.json();
|
|
11
|
+
if (!(0, _solana_kit.isAddress)(data.result)) return;
|
|
12
|
+
return data.result;
|
|
13
|
+
} catch (_) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
24
16
|
};
|
|
17
|
+
//#endregion
|
|
25
18
|
exports.getSNSAddress = getSNSAddress;
|
|
19
|
+
|
|
26
20
|
//# sourceMappingURL=getSNSAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSNSAddress.js","
|
|
1
|
+
{"version":3,"file":"getSNSAddress.js","names":[],"sources":["../../../src/actions/getSNSAddress.ts"],"sourcesContent":["import { isAddress } from '@solana/kit'\n\ninterface SNSResult {\n s: 'ok' | 'error'\n result: string\n}\n\n// Subject to change\n// https://github.com/Bonfida/sns-sdk?tab=readme-ov-file#sdk-proxy\nexport const getSNSAddress = async (\n name: string\n): Promise<string | undefined> => {\n try {\n if (!name.endsWith('.sol')) {\n return\n }\n const snsWorkerUrl = `https://sns-sdk-proxy.bonfida.workers.dev/resolve/${name}`\n const response: Response = await fetch(snsWorkerUrl)\n if (!response.ok) {\n return\n }\n\n const data: SNSResult = await response.json()\n\n if (!isAddress(data.result)) {\n return\n }\n\n return data.result\n } catch (_) {\n // ignore\n return\n }\n}\n"],"mappings":";;;AASA,MAAa,gBAAgB,OAC3B,SACgC;CAChC,IAAI;EACF,IAAI,CAAC,KAAK,SAAS,MAAM,GACvB;EAEF,MAAM,eAAe,qDAAqD;EAC1E,MAAM,WAAqB,MAAM,MAAM,YAAY;EACnD,IAAI,CAAC,SAAS,IACZ;EAGF,MAAM,OAAkB,MAAM,SAAS,KAAK;EAE5C,IAAI,EAAA,GAAA,YAAA,UAAA,CAAW,KAAK,MAAM,GACxB;EAGF,OAAO,KAAK;CACd,SAAS,GAAG;EAEV;CACF;AACF"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SDKClient, Token, TokenAmount } from "@lifi/sdk";
|
|
2
|
+
|
|
3
|
+
//#region src/actions/getSolanaBalance.d.ts
|
|
4
|
+
declare const getSolanaBalance: (client: SDKClient, walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { getSolanaBalance };
|
|
7
|
+
//# sourceMappingURL=getSolanaBalance.d.ts.map
|
|
@@ -1,84 +1,75 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const Token2022ProgramId = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rpc_utils = require("../rpc/utils.js");
|
|
3
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
4
|
+
let _solana_kit = require("@solana/kit");
|
|
5
|
+
//#region src/actions/getSolanaBalance.ts
|
|
6
|
+
const SolSystemProgram = "11111111111111111111111111111111";
|
|
7
|
+
const TokenProgramId = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
8
|
+
const Token2022ProgramId = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
10
9
|
const getSolanaBalance = async (client, walletAddress, tokens) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (const token of tokens) {
|
|
16
|
-
if (token.chainId !== chainId) {
|
|
17
|
-
console.warn('Requested tokens have to be on the same chain.');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return getSolanaBalanceDefault(client, chainId, tokens, walletAddress);
|
|
10
|
+
if (tokens.length === 0) return [];
|
|
11
|
+
const { chainId } = tokens[0];
|
|
12
|
+
for (const token of tokens) if (token.chainId !== chainId) console.warn("Requested tokens have to be on the same chain.");
|
|
13
|
+
return getSolanaBalanceDefault(client, chainId, tokens, walletAddress);
|
|
21
14
|
};
|
|
22
|
-
exports.getSolanaBalance = getSolanaBalance;
|
|
23
15
|
const getSolanaBalanceDefault = async (client, _chainId, tokens, walletAddress) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
blockNumber,
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
return tokenAmounts;
|
|
16
|
+
const accountAddress = (0, _solana_kit.address)(walletAddress);
|
|
17
|
+
const tokenProgramAddress = (0, _solana_kit.address)(TokenProgramId);
|
|
18
|
+
const token2022ProgramAddress = (0, _solana_kit.address)(Token2022ProgramId);
|
|
19
|
+
const [slot, balance, tokenAccountsByOwner, token2022AccountsByOwner] = await Promise.allSettled([
|
|
20
|
+
(0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getSlot({ commitment: "confirmed" }).send()), { id: `${getSolanaBalanceDefault.name}.getSlot` }),
|
|
21
|
+
(0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getBalance(accountAddress, { commitment: "confirmed" }).send()), { id: `${getSolanaBalanceDefault.name}.getBalance` }),
|
|
22
|
+
(0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getTokenAccountsByOwner(accountAddress, { programId: tokenProgramAddress }, {
|
|
23
|
+
commitment: "confirmed",
|
|
24
|
+
encoding: "jsonParsed"
|
|
25
|
+
}).send()), { id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${TokenProgramId}` }),
|
|
26
|
+
(0, _lifi_sdk.withDedupe)(() => require_rpc_utils.callSolanaRpcsWithRetry(client, (rpc) => rpc.getTokenAccountsByOwner(accountAddress, { programId: token2022ProgramAddress }, {
|
|
27
|
+
commitment: "confirmed",
|
|
28
|
+
encoding: "jsonParsed"
|
|
29
|
+
}).send()), { id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${Token2022ProgramId}` })
|
|
30
|
+
]);
|
|
31
|
+
const blockNumber = slot.status === "fulfilled" ? BigInt(slot.value) : 0n;
|
|
32
|
+
const nativeBalanceOk = balance.status === "fulfilled";
|
|
33
|
+
const solBalance = nativeBalanceOk ? BigInt(balance.value.value) : 0n;
|
|
34
|
+
const tokenProgramOk = tokenAccountsByOwner.status === "fulfilled";
|
|
35
|
+
const token2022ProgramOk = token2022AccountsByOwner.status === "fulfilled";
|
|
36
|
+
const walletTokenAmounts = [...tokenProgramOk ? tokenAccountsByOwner.value.value : [], ...token2022ProgramOk ? token2022AccountsByOwner.value.value : []].reduce((tokenAmounts, value) => {
|
|
37
|
+
const tokenAccount = value.account.data.parsed.info;
|
|
38
|
+
const amount = BigInt(tokenAccount.tokenAmount.amount);
|
|
39
|
+
if (amount > 0n) tokenAmounts[tokenAccount.mint] = (tokenAmounts[tokenAccount.mint] ?? 0n) + amount;
|
|
40
|
+
return tokenAmounts;
|
|
41
|
+
}, {});
|
|
42
|
+
const splZeroIsKnown = tokenProgramOk && token2022ProgramOk;
|
|
43
|
+
return tokens.map((token) => {
|
|
44
|
+
if (token.address === SolSystemProgram) {
|
|
45
|
+
if (!nativeBalanceOk) return {
|
|
46
|
+
...token,
|
|
47
|
+
blockNumber
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
...token,
|
|
51
|
+
amount: solBalance,
|
|
52
|
+
blockNumber
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const found = walletTokenAmounts[token.address];
|
|
56
|
+
if (found !== void 0) return {
|
|
57
|
+
...token,
|
|
58
|
+
amount: found,
|
|
59
|
+
blockNumber
|
|
60
|
+
};
|
|
61
|
+
if (splZeroIsKnown) return {
|
|
62
|
+
...token,
|
|
63
|
+
amount: 0n,
|
|
64
|
+
blockNumber
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
...token,
|
|
68
|
+
blockNumber
|
|
69
|
+
};
|
|
70
|
+
});
|
|
83
71
|
};
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.getSolanaBalance = getSolanaBalance;
|
|
74
|
+
|
|
84
75
|
//# sourceMappingURL=getSolanaBalance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSolanaBalance.js","
|
|
1
|
+
{"version":3,"file":"getSolanaBalance.js","names":["callSolanaRpcsWithRetry"],"sources":["../../../src/actions/getSolanaBalance.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type ChainId,\n type Token,\n type TokenAmount,\n withDedupe,\n} from '@lifi/sdk'\nimport { address, type JsonParsedTokenAccount } from '@solana/kit'\n\nimport { callSolanaRpcsWithRetry } from '../rpc/utils.js'\n\nconst SolSystemProgram = '11111111111111111111111111111111'\nconst TokenProgramId = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'\nconst Token2022ProgramId = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'\n\nexport const getSolanaBalance = async (\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]> => {\n if (tokens.length === 0) {\n return []\n }\n const { chainId } = tokens[0]\n for (const token of tokens) {\n if (token.chainId !== chainId) {\n console.warn('Requested tokens have to be on the same chain.')\n }\n }\n\n return getSolanaBalanceDefault(client, chainId, tokens, walletAddress)\n}\n\nconst getSolanaBalanceDefault = async (\n client: SDKClient,\n _chainId: ChainId,\n tokens: Token[],\n walletAddress: string\n): Promise<TokenAmount[]> => {\n // Convert addresses to Solana Kit's address type\n const accountAddress = address(walletAddress)\n const tokenProgramAddress = address(TokenProgramId)\n const token2022ProgramAddress = address(Token2022ProgramId)\n\n // Use Solana Kit's RPC API with the retry wrapper\n const [slot, balance, tokenAccountsByOwner, token2022AccountsByOwner] =\n await Promise.allSettled([\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc.getSlot({ commitment: 'confirmed' }).send()\n ),\n { id: `${getSolanaBalanceDefault.name}.getSlot` }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc.getBalance(accountAddress, { commitment: 'confirmed' }).send()\n ),\n { id: `${getSolanaBalanceDefault.name}.getBalance` }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc\n .getTokenAccountsByOwner(\n accountAddress,\n {\n programId: tokenProgramAddress,\n },\n {\n commitment: 'confirmed',\n encoding: 'jsonParsed',\n }\n )\n .send()\n ),\n {\n id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${TokenProgramId}`,\n }\n ),\n withDedupe(\n () =>\n callSolanaRpcsWithRetry(client, (rpc) =>\n rpc\n .getTokenAccountsByOwner(\n accountAddress,\n {\n programId: token2022ProgramAddress,\n },\n {\n commitment: 'confirmed',\n encoding: 'jsonParsed',\n }\n )\n .send()\n ),\n {\n id: `${getSolanaBalanceDefault.name}.getTokenAccountsByOwner.${Token2022ProgramId}`,\n }\n ),\n ])\n const blockNumber = slot.status === 'fulfilled' ? BigInt(slot.value) : 0n\n const nativeBalanceOk = balance.status === 'fulfilled'\n const solBalance = nativeBalanceOk ? BigInt(balance.value.value) : 0n\n const tokenProgramOk = tokenAccountsByOwner.status === 'fulfilled'\n const token2022ProgramOk = token2022AccountsByOwner.status === 'fulfilled'\n\n const walletTokenAmounts = [\n ...(tokenProgramOk ? tokenAccountsByOwner.value.value : []),\n ...(token2022ProgramOk ? token2022AccountsByOwner.value.value : []),\n ].reduce(\n (tokenAmounts: Record<string, bigint>, value) => {\n const tokenAccount: JsonParsedTokenAccount =\n value.account.data.parsed.info\n const amount = BigInt(tokenAccount.tokenAmount.amount)\n if (amount > 0n) {\n tokenAmounts[tokenAccount.mint] =\n (tokenAmounts[tokenAccount.mint] ?? 0n) + amount\n }\n return tokenAmounts\n },\n {} as Record<string, bigint>\n )\n\n // We can only confidently report 0n for an SPL mint when both Token and\n // Token2022 program queries succeeded — otherwise the mint may live in the\n // program whose query failed (e.g. PYUSD on Token2022).\n const splZeroIsKnown = tokenProgramOk && token2022ProgramOk\n\n const tokenAmounts: TokenAmount[] = tokens.map((token) => {\n const isNative = token.address === SolSystemProgram\n if (isNative) {\n if (!nativeBalanceOk) {\n return { ...token, blockNumber }\n }\n return { ...token, amount: solBalance, blockNumber }\n }\n const found = walletTokenAmounts[token.address]\n if (found !== undefined) {\n return { ...token, amount: found, blockNumber }\n }\n if (splZeroIsKnown) {\n return { ...token, amount: 0n, blockNumber }\n }\n return { ...token, blockNumber }\n })\n return tokenAmounts\n}\n"],"mappings":";;;;;AAWA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAE3B,MAAa,mBAAmB,OAC9B,QACA,eACA,WAC2B;CAC3B,IAAI,OAAO,WAAW,GACpB,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,OAAO;CAC3B,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,YAAY,SACpB,QAAQ,KAAK,gDAAgD;CAIjE,OAAO,wBAAwB,QAAQ,SAAS,QAAQ,aAAa;AACvE;AAEA,MAAM,0BAA0B,OAC9B,QACA,UACA,QACA,kBAC2B;CAE3B,MAAM,kBAAA,GAAA,YAAA,QAAA,CAAyB,aAAa;CAC5C,MAAM,uBAAA,GAAA,YAAA,QAAA,CAA8B,cAAc;CAClD,MAAM,2BAAA,GAAA,YAAA,QAAA,CAAkC,kBAAkB;CAG1D,MAAM,CAAC,MAAM,SAAS,sBAAsB,4BAC1C,MAAM,QAAQ,WAAW;kCAGnBA,kBAAAA,wBAAwB,SAAS,QAC/B,IAAI,QAAQ,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC,KAAK,CAChD,GACF,EAAE,IAAI,GAAG,wBAAwB,KAAK,UAAU,CAClD;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IAAI,WAAW,gBAAgB,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC,KAAK,CACnE,GACF,EAAE,IAAI,GAAG,wBAAwB,KAAK,aAAa,CACrD;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IACG,wBACC,gBACA,EACE,WAAW,oBACb,GACA;GACE,YAAY;GACZ,UAAU;EACZ,CACF,CAAC,CACA,KAAK,CACV,GACF,EACE,IAAI,GAAG,wBAAwB,KAAK,2BAA2B,iBACjE,CACF;kCAGIA,kBAAAA,wBAAwB,SAAS,QAC/B,IACG,wBACC,gBACA,EACE,WAAW,wBACb,GACA;GACE,YAAY;GACZ,UAAU;EACZ,CACF,CAAC,CACA,KAAK,CACV,GACF,EACE,IAAI,GAAG,wBAAwB,KAAK,2BAA2B,qBACjE,CACF;CACF,CAAC;CACH,MAAM,cAAc,KAAK,WAAW,cAAc,OAAO,KAAK,KAAK,IAAI;CACvE,MAAM,kBAAkB,QAAQ,WAAW;CAC3C,MAAM,aAAa,kBAAkB,OAAO,QAAQ,MAAM,KAAK,IAAI;CACnE,MAAM,iBAAiB,qBAAqB,WAAW;CACvD,MAAM,qBAAqB,yBAAyB,WAAW;CAE/D,MAAM,qBAAqB,CACzB,GAAI,iBAAiB,qBAAqB,MAAM,QAAQ,CAAC,GACzD,GAAI,qBAAqB,yBAAyB,MAAM,QAAQ,CAAC,CACnE,CAAC,CAAC,QACC,cAAsC,UAAU;EAC/C,MAAM,eACJ,MAAM,QAAQ,KAAK,OAAO;EAC5B,MAAM,SAAS,OAAO,aAAa,YAAY,MAAM;EACrD,IAAI,SAAS,IACX,aAAa,aAAa,SACvB,aAAa,aAAa,SAAS,MAAM;EAE9C,OAAO;CACT,GACA,CAAC,CACH;CAKA,MAAM,iBAAiB,kBAAkB;CAmBzC,OAjBoC,OAAO,KAAK,UAAU;EAExD,IADiB,MAAM,YAAY,kBACrB;GACZ,IAAI,CAAC,iBACH,OAAO;IAAE,GAAG;IAAO;GAAY;GAEjC,OAAO;IAAE,GAAG;IAAO,QAAQ;IAAY;GAAY;EACrD;EACA,MAAM,QAAQ,mBAAmB,MAAM;EACvC,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE,GAAG;GAAO,QAAQ;GAAO;EAAY;EAEhD,IAAI,gBACF,OAAO;GAAE,GAAG;GAAO,QAAQ;GAAI;EAAY;EAE7C,OAAO;GAAE,GAAG;GAAO;EAAY;CACjC,CACkB;AACpB"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/actions/resolveSolanaAddress.d.ts
|
|
2
|
+
declare function resolveSolanaAddress(name: string): Promise<string | undefined>;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { resolveSolanaAddress };
|
|
5
|
+
//# sourceMappingURL=resolveSolanaAddress.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const getSNSAddress_js_1 = require("./getSNSAddress.js");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_actions_getSNSAddress = require("./getSNSAddress.js");
|
|
3
|
+
//#region src/actions/resolveSolanaAddress.ts
|
|
5
4
|
async function resolveSolanaAddress(name) {
|
|
6
|
-
|
|
5
|
+
return await require_actions_getSNSAddress.getSNSAddress(name);
|
|
7
6
|
}
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.resolveSolanaAddress = resolveSolanaAddress;
|
|
9
|
+
|
|
8
10
|
//# sourceMappingURL=resolveSolanaAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSolanaAddress.js","
|
|
1
|
+
{"version":3,"file":"resolveSolanaAddress.js","names":["getSNSAddress"],"sources":["../../../src/actions/resolveSolanaAddress.ts"],"sourcesContent":["import { getSNSAddress } from './getSNSAddress.js'\n\nexport async function resolveSolanaAddress(\n name: string\n): Promise<string | undefined> {\n return await getSNSAddress(name)\n}\n"],"mappings":";;;AAEA,eAAsB,qBACpB,MAC6B;CAC7B,OAAO,MAAMA,8BAAAA,cAAc,IAAI;AACjC"}
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SDKClient } from "@lifi/sdk";
|
|
2
|
+
import { Commitment, Signature, Transaction, TransactionError } from "@solana/kit";
|
|
3
|
+
|
|
4
|
+
//#region src/actions/sendAndConfirmBundle.d.ts
|
|
3
5
|
type SignatureStatus = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
slot: bigint;
|
|
7
|
+
confirmations: bigint | null;
|
|
8
|
+
err: TransactionError | null;
|
|
9
|
+
confirmationStatus: Commitment | null;
|
|
10
|
+
status: Readonly<{
|
|
11
|
+
Err: TransactionError;
|
|
12
|
+
}> | Readonly<{
|
|
13
|
+
Ok: null;
|
|
14
|
+
}>;
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
type BundleResult = {
|
|
17
|
+
bundleId: string;
|
|
18
|
+
txSignatures: Signature[];
|
|
19
|
+
signatureResults: (SignatureStatus | null)[];
|
|
18
20
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Send and confirm a bundle of transactions using Jito.
|
|
23
|
+
* Automatically selects a Jito-enabled RPC connection and polls for confirmation
|
|
24
|
+
* across multiple Jito RPCs in parallel.
|
|
25
|
+
* @param client - The SDK client.
|
|
26
|
+
* @param signedTransactions - Array of signed transactions to bundle.
|
|
27
|
+
* @returns BundleResult containing Bundle ID, transaction signatures, and confirmation results.
|
|
28
|
+
*/
|
|
29
|
+
declare function sendAndConfirmBundle(client: SDKClient, signedTransactions: Transaction[]): Promise<BundleResult>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { BundleResult, sendAndConfirmBundle };
|
|
32
|
+
//# sourceMappingURL=sendAndConfirmBundle.d.ts.map
|