thirdweb 5.99.3 → 5.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bridge/Buy.js +17 -13
- package/dist/cjs/bridge/Buy.js.map +1 -1
- package/dist/cjs/bridge/Chains.js +2 -2
- package/dist/cjs/bridge/Chains.js.map +1 -1
- package/dist/cjs/bridge/Onramp.js +152 -0
- package/dist/cjs/bridge/Onramp.js.map +1 -0
- package/dist/cjs/bridge/OnrampStatus.js +78 -0
- package/dist/cjs/bridge/OnrampStatus.js.map +1 -0
- package/dist/cjs/bridge/Routes.js +2 -2
- package/dist/cjs/bridge/Routes.js.map +1 -1
- package/dist/cjs/bridge/Sell.js +18 -14
- package/dist/cjs/bridge/Sell.js.map +1 -1
- package/dist/cjs/bridge/Status.js +15 -2
- package/dist/cjs/bridge/Status.js.map +1 -1
- package/dist/cjs/bridge/Transfer.js +229 -0
- package/dist/cjs/bridge/Transfer.js.map +1 -0
- package/dist/cjs/bridge/index.js +3 -1
- package/dist/cjs/bridge/index.js.map +1 -1
- package/dist/cjs/bridge/types/BridgeAction.js +3 -0
- package/dist/cjs/bridge/types/BridgeAction.js.map +1 -0
- package/dist/cjs/bridge/types/Token.js +3 -0
- package/dist/cjs/bridge/types/Token.js.map +1 -0
- package/dist/cjs/extensions/ens/resolve-l2-name.js +0 -2
- package/dist/cjs/extensions/ens/resolve-l2-name.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getQuote.js +159 -53
- package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getStatus.js +160 -14
- package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -37
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getQuote.js +129 -33
- package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getStatus.js +71 -20
- package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/cjs/pay/utils/commonTypes.js +1 -1
- package/dist/cjs/pay/utils/commonTypes.js.map +1 -1
- package/dist/cjs/pay/utils/definitions.js +1 -43
- package/dist/cjs/pay/utils/definitions.js.map +1 -1
- package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
- package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +44 -38
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/core/utils/wallet.js +15 -0
- package/dist/cjs/react/core/utils/wallet.js.map +1 -1
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -23
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +0 -177
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -15
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -60
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +4 -4
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +83 -34
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +133 -0
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +9 -1
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/constants.js +1 -0
- package/dist/cjs/utils/any-evm/zksync/constants.js.map +1 -1
- package/dist/cjs/utils/domains.js +3 -0
- package/dist/cjs/utils/domains.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/bridge/Buy.js +17 -13
- package/dist/esm/bridge/Buy.js.map +1 -1
- package/dist/esm/bridge/Chains.js +2 -2
- package/dist/esm/bridge/Chains.js.map +1 -1
- package/dist/esm/bridge/Onramp.js +147 -0
- package/dist/esm/bridge/Onramp.js.map +1 -0
- package/dist/esm/bridge/OnrampStatus.js +75 -0
- package/dist/esm/bridge/OnrampStatus.js.map +1 -0
- package/dist/esm/bridge/Routes.js +2 -2
- package/dist/esm/bridge/Routes.js.map +1 -1
- package/dist/esm/bridge/Sell.js +18 -14
- package/dist/esm/bridge/Sell.js.map +1 -1
- package/dist/esm/bridge/Status.js +15 -2
- package/dist/esm/bridge/Status.js.map +1 -1
- package/dist/esm/bridge/Transfer.js +226 -0
- package/dist/esm/bridge/Transfer.js.map +1 -0
- package/dist/esm/bridge/index.js +2 -0
- package/dist/esm/bridge/index.js.map +1 -1
- package/dist/esm/bridge/types/BridgeAction.js +2 -0
- package/dist/esm/bridge/types/BridgeAction.js.map +1 -0
- package/dist/esm/bridge/types/Token.js +2 -0
- package/dist/esm/bridge/types/Token.js.map +1 -0
- package/dist/esm/extensions/ens/resolve-l2-name.js +0 -2
- package/dist/esm/extensions/ens/resolve-l2-name.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getQuote.js +159 -53
- package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getStatus.js +160 -14
- package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js +95 -37
- package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getQuote.js +129 -33
- package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getStatus.js +71 -20
- package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/esm/pay/utils/commonTypes.js +1 -1
- package/dist/esm/pay/utils/commonTypes.js.map +1 -1
- package/dist/esm/pay/utils/definitions.js +0 -35
- package/dist/esm/pay/utils/definitions.js.map +1 -1
- package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
- package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +44 -38
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/core/utils/wallet.js +15 -0
- package/dist/esm/react/core/utils/wallet.js.map +1 -1
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -23
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/locale/en.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +4 -180
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +2 -16
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -59
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +84 -34
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +130 -0
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +9 -1
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/constants.js +1 -0
- package/dist/esm/utils/any-evm/zksync/constants.js.map +1 -1
- package/dist/esm/utils/domains.js +3 -0
- package/dist/esm/utils/domains.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/bridge/Buy.d.ts +11 -9
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Onramp.d.ts +123 -0
- package/dist/types/bridge/Onramp.d.ts.map +1 -0
- package/dist/types/bridge/OnrampStatus.d.ts +108 -0
- package/dist/types/bridge/OnrampStatus.d.ts.map +1 -0
- package/dist/types/bridge/Sell.d.ts +13 -11
- package/dist/types/bridge/Sell.d.ts.map +1 -1
- package/dist/types/bridge/Status.d.ts.map +1 -1
- package/dist/types/bridge/Transfer.d.ts +199 -0
- package/dist/types/bridge/Transfer.d.ts.map +1 -0
- package/dist/types/bridge/index.d.ts +7 -3
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/bridge/types/BridgeAction.d.ts +2 -0
- package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -0
- package/dist/types/bridge/types/Quote.d.ts +3 -65
- package/dist/types/bridge/types/Quote.d.ts.map +1 -1
- package/dist/types/bridge/types/Route.d.ts +38 -17
- package/dist/types/bridge/types/Route.d.ts.map +1 -1
- package/dist/types/bridge/types/Status.d.ts +15 -0
- package/dist/types/bridge/types/Status.d.ts.map +1 -1
- package/dist/types/bridge/types/Token.d.ts +11 -0
- package/dist/types/bridge/types/Token.d.ts.map +1 -0
- package/dist/types/extensions/ens/resolve-l2-name.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +0 -9
- package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getStatus.d.ts +1 -12
- package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
- package/dist/types/pay/utils/commonTypes.d.ts +1 -1
- package/dist/types/pay/utils/commonTypes.d.ts.map +1 -1
- package/dist/types/pay/utils/definitions.d.ts +0 -35
- package/dist/types/pay/utils/definitions.d.ts.map +1 -1
- package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +1 -0
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
- package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts +1 -30
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +2 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +2 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts +0 -5
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts +1 -3
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +8 -4
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +15 -0
- package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +1 -0
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/constants.d.ts.map +1 -1
- package/dist/types/utils/domains.d.ts +6 -0
- package/dist/types/utils/domains.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/bridge/Buy.ts +19 -13
- package/src/bridge/Chains.ts +2 -2
- package/src/bridge/Onramp.test.ts +118 -0
- package/src/bridge/Onramp.ts +244 -0
- package/src/bridge/OnrampStatus.ts +133 -0
- package/src/bridge/Routes.ts +2 -2
- package/src/bridge/Sell.ts +20 -14
- package/src/bridge/Status.ts +15 -2
- package/src/bridge/Transfer.test.ts +76 -0
- package/src/bridge/Transfer.ts +270 -0
- package/src/bridge/index.ts +12 -3
- package/src/bridge/types/BridgeAction.ts +1 -0
- package/src/bridge/types/Quote.ts +3 -65
- package/src/bridge/types/Route.ts +42 -17
- package/src/bridge/types/Status.ts +15 -1
- package/src/bridge/types/Token.ts +11 -0
- package/src/extensions/ens/resolve-l2-name.ts +0 -2
- package/src/pay/buyWithCrypto/commonTypes.ts +0 -10
- package/src/pay/buyWithCrypto/getQuote.ts +210 -100
- package/src/pay/buyWithCrypto/getStatus.ts +213 -20
- package/src/pay/buyWithCrypto/getTransfer.ts +129 -61
- package/src/pay/buyWithFiat/getQuote.ts +184 -33
- package/src/pay/buyWithFiat/getStatus.ts +101 -42
- package/src/pay/convert/cryptoToFiat.test.ts +7 -5
- package/src/pay/convert/fiatToCrypto.test.ts +6 -4
- package/src/pay/utils/commonTypes.ts +1 -1
- package/src/pay/utils/definitions.ts +0 -48
- package/src/react/core/hooks/pay/useBuyWithFiatStatus.ts +0 -2
- package/src/react/core/hooks/transaction/useSendTransaction.ts +53 -52
- package/src/react/core/utils/wallet.ts +15 -0
- package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +5 -64
- package/src/react/web/ui/ConnectWallet/locale/en.ts +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +3 -510
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +2 -12
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +2 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +19 -20
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -37
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts +1 -95
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts +0 -69
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.ts +1 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +118 -63
- package/src/react/web/ui/TransactionButton/DepositScreen.tsx +295 -0
- package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +4 -5
- package/src/react/web/ui/TransactionButton/TransactionModal.tsx +20 -1
- package/src/utils/any-evm/zksync/constants.ts +1 -0
- package/src/utils/domain.test.ts +1 -0
- package/src/utils/domains.ts +8 -0
- package/src/version.ts +1 -1
- package/dist/cjs/bridge/constants.js +0 -5
- package/dist/cjs/bridge/constants.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -37
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -86
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -25
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -54
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -52
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -81
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -17
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -138
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
- package/dist/esm/bridge/constants.js +0 -2
- package/dist/esm/bridge/constants.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -34
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -83
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -22
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -51
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -48
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -78
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -135
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
- package/dist/types/bridge/constants.d.ts +0 -2
- package/dist/types/bridge/constants.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts +0 -26
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +0 -16
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +0 -23
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +0 -10
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts +0 -9
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +0 -14
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +0 -14
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +0 -21
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +0 -1
- package/src/bridge/constants.ts +0 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +0 -142
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +0 -170
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +0 -63
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +0 -163
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.tsx +0 -127
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +0 -138
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +0 -45
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +0 -191
@@ -0,0 +1,244 @@
|
|
1
|
+
import type { Address as ox__Address } from "ox";
|
2
|
+
import type { ThirdwebClient } from "../client/client.js";
|
3
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
4
|
+
import { getClientFetch } from "../utils/fetch.js";
|
5
|
+
import { stringify } from "../utils/json.js";
|
6
|
+
import type { RouteStep } from "./types/Route.js";
|
7
|
+
import type { Token } from "./types/Token.js";
|
8
|
+
|
9
|
+
// export status within the Onramp module
|
10
|
+
export { status } from "./OnrampStatus.js";
|
11
|
+
|
12
|
+
type OnrampIntent = {
|
13
|
+
onramp: "stripe" | "coinbase" | "transak";
|
14
|
+
chainId: number;
|
15
|
+
tokenAddress: ox__Address.Address;
|
16
|
+
receiver: ox__Address.Address;
|
17
|
+
amount?: string; // Corresponds to buyAmountWei in some other contexts
|
18
|
+
purchaseData?: unknown;
|
19
|
+
sender?: ox__Address.Address;
|
20
|
+
onrampTokenAddress?: ox__Address.Address;
|
21
|
+
onrampChainId?: number;
|
22
|
+
currency?: string;
|
23
|
+
maxSteps?: number;
|
24
|
+
excludeChainIds?: string | string[];
|
25
|
+
};
|
26
|
+
|
27
|
+
type OnrampPrepareQuoteResponseData = {
|
28
|
+
id: string;
|
29
|
+
link: string;
|
30
|
+
currency: string;
|
31
|
+
currencyAmount: number;
|
32
|
+
destinationAmount: bigint;
|
33
|
+
destinationToken: Token;
|
34
|
+
timestamp?: number;
|
35
|
+
expiration?: number;
|
36
|
+
steps: RouteStep[];
|
37
|
+
intent: OnrampIntent;
|
38
|
+
};
|
39
|
+
|
40
|
+
// Explicit type for the API request body
|
41
|
+
interface OnrampApiRequestBody {
|
42
|
+
onramp: "stripe" | "coinbase" | "transak";
|
43
|
+
chainId: number;
|
44
|
+
tokenAddress: ox__Address.Address;
|
45
|
+
receiver: ox__Address.Address;
|
46
|
+
amount?: string;
|
47
|
+
purchaseData?: unknown;
|
48
|
+
sender?: ox__Address.Address;
|
49
|
+
onrampTokenAddress?: ox__Address.Address;
|
50
|
+
onrampChainId?: number;
|
51
|
+
currency?: string;
|
52
|
+
maxSteps?: number;
|
53
|
+
excludeChainIds?: string;
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
|
58
|
+
*
|
59
|
+
* @example
|
60
|
+
* ```typescript
|
61
|
+
* import { Bridge } from "thirdweb";
|
62
|
+
* import { ethereum } from "thirdweb/chains";
|
63
|
+
* import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils";
|
64
|
+
*
|
65
|
+
* const preparedOnramp = await Bridge.Onramp.prepare({
|
66
|
+
* client: thirdwebClient,
|
67
|
+
* onramp: "stripe",
|
68
|
+
* chainId: ethereum.id,
|
69
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
70
|
+
* receiver: "0x...", // receiver's address
|
71
|
+
* amount: toWei("10"), // 10 of the destination token
|
72
|
+
* // Optional params:
|
73
|
+
* // sender: "0x...", // sender's address
|
74
|
+
* // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to
|
75
|
+
* // onrampChainId: 1, // chain to initially onramp to
|
76
|
+
* // currency: "USD",
|
77
|
+
* // maxSteps: 2,
|
78
|
+
* // purchaseData: { customId: "123" }
|
79
|
+
* });
|
80
|
+
*
|
81
|
+
* console.log(preparedOnramp.link); // URL to redirect the user to
|
82
|
+
* console.log(preparedOnramp.currencyAmount); // Amount in fiat the user will pay
|
83
|
+
* ```
|
84
|
+
*
|
85
|
+
* This function returns a quote that might look like:
|
86
|
+
* ```typescript
|
87
|
+
* {
|
88
|
+
* id: "123e4567-e89b-12d3-a456-426614174000",
|
89
|
+
* link: "https://onramp.example.com/session?id=...",
|
90
|
+
* currency: "USD",
|
91
|
+
* currencyAmount: 10.52,
|
92
|
+
* destinationAmount: 10000000000000000000n, // 10 ETH if decimals 18
|
93
|
+
* timestamp: 1689812800,
|
94
|
+
* expiration: 1689842800,
|
95
|
+
* steps: [
|
96
|
+
* // ... further steps if any post-onramp swaps are needed
|
97
|
+
* ],
|
98
|
+
* intent: {
|
99
|
+
* onramp: "stripe",
|
100
|
+
* chainId: 1,
|
101
|
+
* tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
102
|
+
* receiver: "0x...",
|
103
|
+
* amount: "10000000000000000000"
|
104
|
+
* }
|
105
|
+
* }
|
106
|
+
* ```
|
107
|
+
*
|
108
|
+
* @param options - The options for preparing the onramp.
|
109
|
+
* @param options.client - Your thirdweb client.
|
110
|
+
* @param options.onramp - The onramp provider to use (e.g., "stripe", "coinbase", "transak").
|
111
|
+
* @param options.chainId - The destination chain ID.
|
112
|
+
* @param options.tokenAddress - The destination token address.
|
113
|
+
* @param options.receiver - The address that will receive the output token.
|
114
|
+
* @param [options.amount] - The desired token amount in wei.
|
115
|
+
* @param [options.purchaseData] - Arbitrary purchase data.
|
116
|
+
* @param [options.sender] - An optional address to associate as the onramp sender.
|
117
|
+
* @param [options.onrampTokenAddress] - The token to initially onramp to if the destination token is not supported by the provider.
|
118
|
+
* @param [options.onrampChainId] - The chain ID to initially onramp to if the destination chain is not supported.
|
119
|
+
* @param [options.currency] - The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD".
|
120
|
+
* @param [options.maxSteps] - Maximum number of post-onramp steps.
|
121
|
+
* @param [options.excludeChainIds] - Chain IDs to exclude from the route (string or array of strings).
|
122
|
+
*
|
123
|
+
* @returns A promise that resolves to the prepared onramp details, including the link and quote.
|
124
|
+
* @throws Will throw an error if there is an issue preparing the onramp.
|
125
|
+
* @bridge Onramp
|
126
|
+
* @beta
|
127
|
+
*/
|
128
|
+
export async function prepare(
|
129
|
+
options: prepare.Options,
|
130
|
+
): Promise<prepare.Result> {
|
131
|
+
const {
|
132
|
+
client,
|
133
|
+
onramp,
|
134
|
+
chainId,
|
135
|
+
tokenAddress,
|
136
|
+
receiver,
|
137
|
+
amount,
|
138
|
+
purchaseData,
|
139
|
+
sender,
|
140
|
+
onrampTokenAddress,
|
141
|
+
onrampChainId,
|
142
|
+
currency,
|
143
|
+
maxSteps,
|
144
|
+
excludeChainIds,
|
145
|
+
} = options;
|
146
|
+
|
147
|
+
const clientFetch = getClientFetch(client);
|
148
|
+
const url = `${getThirdwebBaseUrl("bridge")}/v1/onramp/prepare`;
|
149
|
+
|
150
|
+
const apiRequestBody: OnrampApiRequestBody = {
|
151
|
+
onramp,
|
152
|
+
chainId: Number(chainId),
|
153
|
+
tokenAddress,
|
154
|
+
receiver,
|
155
|
+
};
|
156
|
+
|
157
|
+
if (amount !== undefined) {
|
158
|
+
apiRequestBody.amount = amount.toString();
|
159
|
+
}
|
160
|
+
if (purchaseData !== undefined) {
|
161
|
+
apiRequestBody.purchaseData = purchaseData;
|
162
|
+
}
|
163
|
+
if (sender !== undefined) {
|
164
|
+
apiRequestBody.sender = sender;
|
165
|
+
}
|
166
|
+
if (onrampTokenAddress !== undefined) {
|
167
|
+
apiRequestBody.onrampTokenAddress = onrampTokenAddress;
|
168
|
+
}
|
169
|
+
if (onrampChainId !== undefined) {
|
170
|
+
apiRequestBody.onrampChainId = Number(onrampChainId);
|
171
|
+
}
|
172
|
+
if (currency !== undefined) {
|
173
|
+
apiRequestBody.currency = currency;
|
174
|
+
}
|
175
|
+
if (maxSteps !== undefined) {
|
176
|
+
apiRequestBody.maxSteps = maxSteps;
|
177
|
+
}
|
178
|
+
if (excludeChainIds !== undefined) {
|
179
|
+
apiRequestBody.excludeChainIds = Array.isArray(excludeChainIds)
|
180
|
+
? excludeChainIds.join(",")
|
181
|
+
: excludeChainIds;
|
182
|
+
}
|
183
|
+
|
184
|
+
const response = await clientFetch(url, {
|
185
|
+
method: "POST",
|
186
|
+
headers: {
|
187
|
+
"Content-Type": "application/json",
|
188
|
+
},
|
189
|
+
body: stringify(apiRequestBody),
|
190
|
+
});
|
191
|
+
|
192
|
+
if (!response.ok) {
|
193
|
+
const errorJson = await response.json();
|
194
|
+
throw new Error(
|
195
|
+
`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`,
|
196
|
+
);
|
197
|
+
}
|
198
|
+
|
199
|
+
const { data }: { data: OnrampPrepareQuoteResponseData } =
|
200
|
+
await response.json();
|
201
|
+
|
202
|
+
// Transform amounts from string to bigint where appropriate
|
203
|
+
const transformedSteps = data.steps.map((step) => ({
|
204
|
+
...step,
|
205
|
+
originAmount: BigInt(step.originAmount),
|
206
|
+
destinationAmount: BigInt(step.destinationAmount),
|
207
|
+
transactions: step.transactions.map((tx) => ({
|
208
|
+
...tx,
|
209
|
+
value: tx.value ? BigInt(tx.value) : undefined,
|
210
|
+
})),
|
211
|
+
}));
|
212
|
+
|
213
|
+
const intentFromResponse = {
|
214
|
+
...data.intent,
|
215
|
+
amount: data.intent.amount ? data.intent.amount : undefined,
|
216
|
+
};
|
217
|
+
|
218
|
+
return {
|
219
|
+
...data,
|
220
|
+
destinationAmount: BigInt(data.destinationAmount),
|
221
|
+
steps: transformedSteps,
|
222
|
+
intent: intentFromResponse,
|
223
|
+
};
|
224
|
+
}
|
225
|
+
|
226
|
+
export declare namespace prepare {
|
227
|
+
export type Options = {
|
228
|
+
client: ThirdwebClient;
|
229
|
+
onramp: "stripe" | "coinbase" | "transak";
|
230
|
+
chainId: number;
|
231
|
+
tokenAddress: ox__Address.Address;
|
232
|
+
receiver: ox__Address.Address;
|
233
|
+
amount?: bigint;
|
234
|
+
purchaseData?: unknown;
|
235
|
+
sender?: ox__Address.Address;
|
236
|
+
onrampTokenAddress?: ox__Address.Address;
|
237
|
+
onrampChainId?: number;
|
238
|
+
currency?: string;
|
239
|
+
maxSteps?: number;
|
240
|
+
excludeChainIds?: string | string[];
|
241
|
+
};
|
242
|
+
|
243
|
+
export type Result = OnrampPrepareQuoteResponseData;
|
244
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import type { Hex as ox__Hex } from "ox";
|
2
|
+
import type { ThirdwebClient } from "../client/client.js";
|
3
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
4
|
+
import { getClientFetch } from "../utils/fetch.js";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Retrieves the status of an Onramp session created via {@link Bridge.Onramp.prepare}. The
|
8
|
+
* status will include any on-chain transactions that have occurred as a result of the onramp
|
9
|
+
* as well as any arbitrary `purchaseData` that was supplied when the onramp was
|
10
|
+
* prepared.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* ```typescript
|
14
|
+
* import { Bridge } from "thirdweb";
|
15
|
+
*
|
16
|
+
* const onrampStatus = await Bridge.Onramp.status({
|
17
|
+
* id: "022218cc-96af-4291-b90c-dadcb47571ec",
|
18
|
+
* client: thirdwebClient,
|
19
|
+
* });
|
20
|
+
*
|
21
|
+
* // Possible results:
|
22
|
+
* // {
|
23
|
+
* // status: "CREATED",
|
24
|
+
* // transactions: [],
|
25
|
+
* // purchaseData: {
|
26
|
+
* // orderId: "abc-123",
|
27
|
+
* // },
|
28
|
+
* // }
|
29
|
+
* //
|
30
|
+
* // or
|
31
|
+
* // {
|
32
|
+
* // status: "PENDING",
|
33
|
+
* // transactions: [],
|
34
|
+
* // purchaseData: {
|
35
|
+
* // orderId: "abc-123",
|
36
|
+
* // },
|
37
|
+
* // }
|
38
|
+
* //
|
39
|
+
* // or
|
40
|
+
* // {
|
41
|
+
* // status: "COMPLETED",
|
42
|
+
* // transactions: [
|
43
|
+
* // {
|
44
|
+
* // chainId: 1,
|
45
|
+
* // transactionHash:
|
46
|
+
* // "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
47
|
+
* // },
|
48
|
+
* // ],
|
49
|
+
* // purchaseData: {
|
50
|
+
* // orderId: "abc-123",
|
51
|
+
* // },
|
52
|
+
* // }
|
53
|
+
* ```
|
54
|
+
*
|
55
|
+
* @param options - The options for fetching the onramp status.
|
56
|
+
* @param options.id - The UUID returned from {@link Bridge.Onramp.prepare}.
|
57
|
+
* @param options.client - Your thirdweb client instance.
|
58
|
+
*
|
59
|
+
* @returns A promise that resolves to the status of the onramp session.
|
60
|
+
*
|
61
|
+
* @throws Will throw an error if there is an issue fetching the status.
|
62
|
+
* @bridge Onramp
|
63
|
+
* @beta
|
64
|
+
*/
|
65
|
+
export async function status(options: status.Options): Promise<status.Result> {
|
66
|
+
const { id, client } = options;
|
67
|
+
|
68
|
+
const clientFetch = getClientFetch(client);
|
69
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/onramp/status`);
|
70
|
+
url.searchParams.set("id", id);
|
71
|
+
|
72
|
+
const response = await clientFetch(url.toString());
|
73
|
+
if (!response.ok) {
|
74
|
+
const errorJson = await response.json();
|
75
|
+
throw new Error(
|
76
|
+
`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`,
|
77
|
+
);
|
78
|
+
}
|
79
|
+
|
80
|
+
const { data }: { data: status.Result } = await response.json();
|
81
|
+
return data;
|
82
|
+
}
|
83
|
+
|
84
|
+
export declare namespace status {
|
85
|
+
/**
|
86
|
+
* Input parameters for {@link Bridge.Onramp.status}.
|
87
|
+
*/
|
88
|
+
export type Options = {
|
89
|
+
/**
|
90
|
+
* The Onramp session ID returned by {@link Bridge.Onramp.prepare}.
|
91
|
+
*/
|
92
|
+
id: string;
|
93
|
+
/** Your {@link ThirdwebClient} instance. */
|
94
|
+
client: ThirdwebClient;
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* The result returned from {@link Bridge.Onramp.status}.
|
99
|
+
*/
|
100
|
+
export type Result =
|
101
|
+
| {
|
102
|
+
status: "COMPLETED";
|
103
|
+
transactions: Array<{
|
104
|
+
chainId: number;
|
105
|
+
transactionHash: ox__Hex.Hex;
|
106
|
+
}>;
|
107
|
+
purchaseData?: unknown;
|
108
|
+
}
|
109
|
+
| {
|
110
|
+
status: "PENDING";
|
111
|
+
transactions: Array<{
|
112
|
+
chainId: number;
|
113
|
+
transactionHash: ox__Hex.Hex;
|
114
|
+
}>;
|
115
|
+
purchaseData?: unknown;
|
116
|
+
}
|
117
|
+
| {
|
118
|
+
status: "CREATED";
|
119
|
+
transactions: Array<{
|
120
|
+
chainId: number;
|
121
|
+
transactionHash: ox__Hex.Hex;
|
122
|
+
}>;
|
123
|
+
purchaseData?: unknown;
|
124
|
+
}
|
125
|
+
| {
|
126
|
+
status: "FAILED";
|
127
|
+
transactions: Array<{
|
128
|
+
chainId: number;
|
129
|
+
transactionHash: ox__Hex.Hex;
|
130
|
+
}>;
|
131
|
+
purchaseData?: unknown;
|
132
|
+
};
|
133
|
+
}
|
package/src/bridge/Routes.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Address as ox__Address, Hex as ox__Hex } from "ox";
|
2
2
|
import type { ThirdwebClient } from "../client/client.js";
|
3
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
3
4
|
import { getClientFetch } from "../utils/fetch.js";
|
4
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
5
5
|
import type { Route } from "./types/Route.js";
|
6
6
|
|
7
7
|
/**
|
@@ -133,7 +133,7 @@ export async function routes(options: routes.Options): Promise<routes.Result> {
|
|
133
133
|
} = options;
|
134
134
|
|
135
135
|
const clientFetch = getClientFetch(client);
|
136
|
-
const url = new URL(`${
|
136
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/routes`);
|
137
137
|
if (originChainId) {
|
138
138
|
url.searchParams.set("originChainId", originChainId.toString());
|
139
139
|
}
|
package/src/bridge/Sell.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { Address as ox__Address } from "ox";
|
2
2
|
import { defineChain } from "../chains/utils.js";
|
3
3
|
import type { ThirdwebClient } from "../client/client.js";
|
4
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
4
5
|
import { getClientFetch } from "../utils/fetch.js";
|
5
6
|
import { stringify } from "../utils/json.js";
|
6
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
7
7
|
import type { PreparedQuote, Quote } from "./types/Quote.js";
|
8
8
|
|
9
9
|
/**
|
@@ -112,12 +112,13 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
|
|
112
112
|
} = options;
|
113
113
|
|
114
114
|
const clientFetch = getClientFetch(client);
|
115
|
-
const url = new URL(`${
|
115
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/sell/quote`);
|
116
116
|
url.searchParams.set("originChainId", originChainId.toString());
|
117
117
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
118
118
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
119
119
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
120
120
|
url.searchParams.set("sellAmountWei", amount.toString());
|
121
|
+
url.searchParams.set("amount", amount.toString());
|
121
122
|
if (typeof maxSteps !== "undefined") {
|
122
123
|
url.searchParams.set("maxSteps", maxSteps.toString());
|
123
124
|
}
|
@@ -190,7 +191,7 @@ export declare namespace quote {
|
|
190
191
|
* This will return a quote that might look like:
|
191
192
|
* ```typescript
|
192
193
|
* {
|
193
|
-
* originAmount:
|
194
|
+
* originAmount: 2000000000n,
|
194
195
|
* destinationAmount: 9980000000000000000n,
|
195
196
|
* blockNumber: 22026509n,
|
196
197
|
* timestamp: 1741730936680,
|
@@ -199,11 +200,11 @@ export declare namespace quote {
|
|
199
200
|
* {
|
200
201
|
* originToken: {
|
201
202
|
* chainId: 1,
|
202
|
-
* address: "
|
203
|
-
* symbol: "
|
204
|
-
* name: "
|
205
|
-
* decimals:
|
206
|
-
* priceUsd:
|
203
|
+
* address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
204
|
+
* symbol: "USDC",
|
205
|
+
* name: "USDC",
|
206
|
+
* decimals: 6,
|
207
|
+
* priceUsd: 1,
|
207
208
|
* iconUri: "https://..."
|
208
209
|
* },
|
209
210
|
* destinationToken: {
|
@@ -215,7 +216,7 @@ export declare namespace quote {
|
|
215
216
|
* priceUsd: 2000,
|
216
217
|
* iconUri: "https://..."
|
217
218
|
* },
|
218
|
-
* originAmount:
|
219
|
+
* originAmount: 2000000000n,
|
219
220
|
* destinationAmount: 9980000000000000000n,
|
220
221
|
* estimatedExecutionTimeMs: 1000
|
221
222
|
* }
|
@@ -241,16 +242,16 @@ export declare namespace quote {
|
|
241
242
|
* expiration: 1741730936680,
|
242
243
|
* intent: {
|
243
244
|
* originChainId: 1,
|
244
|
-
* originTokenAddress:
|
245
|
+
* originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
245
246
|
* destinationChainId: 10,
|
246
|
-
* destinationTokenAddress:
|
247
|
-
* amount:
|
247
|
+
* destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
248
|
+
* amount: 2000000000n
|
248
249
|
* }
|
249
250
|
* }
|
250
251
|
* ```
|
251
252
|
*
|
252
253
|
* ## Sending the transactions
|
253
|
-
* The `transactions` array is a series of
|
254
|
+
* The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
|
254
255
|
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
|
255
256
|
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
|
256
257
|
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
@@ -325,7 +326,7 @@ export async function prepare(
|
|
325
326
|
} = options;
|
326
327
|
|
327
328
|
const clientFetch = getClientFetch(client);
|
328
|
-
const url = new URL(`${
|
329
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/sell/prepare`);
|
329
330
|
|
330
331
|
const response = await clientFetch(url.toString(), {
|
331
332
|
method: "POST",
|
@@ -334,6 +335,7 @@ export async function prepare(
|
|
334
335
|
},
|
335
336
|
body: stringify({
|
336
337
|
sellAmountWei: amount.toString(),
|
338
|
+
amount: amount.toString(),
|
337
339
|
originChainId: originChainId.toString(),
|
338
340
|
originTokenAddress,
|
339
341
|
destinationChainId: destinationChainId.toString(),
|
@@ -374,6 +376,8 @@ export async function prepare(
|
|
374
376
|
destinationChainId,
|
375
377
|
destinationTokenAddress,
|
376
378
|
amount,
|
379
|
+
sender,
|
380
|
+
receiver,
|
377
381
|
purchaseData,
|
378
382
|
},
|
379
383
|
};
|
@@ -400,6 +404,8 @@ export declare namespace prepare {
|
|
400
404
|
destinationChainId: number;
|
401
405
|
destinationTokenAddress: ox__Address.Address;
|
402
406
|
amount: bigint;
|
407
|
+
sender: ox__Address.Address;
|
408
|
+
receiver: ox__Address.Address;
|
403
409
|
purchaseData?: unknown;
|
404
410
|
};
|
405
411
|
};
|
package/src/bridge/Status.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { Hex as ox__Hex } from "ox";
|
2
2
|
import type { Chain } from "../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../client/client.js";
|
4
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
4
5
|
import { getClientFetch } from "../utils/fetch.js";
|
5
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
6
6
|
import type { Status } from "./types/Status.js";
|
7
7
|
|
8
8
|
/**
|
@@ -108,7 +108,7 @@ export async function status(options: status.Options): Promise<status.Result> {
|
|
108
108
|
const chainId = "chainId" in options ? options.chainId : options.chain.id;
|
109
109
|
|
110
110
|
const clientFetch = getClientFetch(client);
|
111
|
-
const url = new URL(`${
|
111
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/status`);
|
112
112
|
url.searchParams.set("transactionHash", transactionHash);
|
113
113
|
url.searchParams.set("chainId", chainId.toString());
|
114
114
|
|
@@ -124,6 +124,7 @@ export async function status(options: status.Options): Promise<status.Result> {
|
|
124
124
|
if (data.status === "FAILED") {
|
125
125
|
return {
|
126
126
|
status: "FAILED",
|
127
|
+
paymentId: data.paymentId,
|
127
128
|
transactions: data.transactions,
|
128
129
|
};
|
129
130
|
}
|
@@ -137,12 +138,19 @@ export async function status(options: status.Options): Promise<status.Result> {
|
|
137
138
|
originTokenAddress: data.originTokenAddress,
|
138
139
|
destinationTokenAddress: data.destinationTokenAddress,
|
139
140
|
transactions: data.transactions,
|
141
|
+
originToken: data.originToken,
|
142
|
+
destinationToken: data.destinationToken,
|
143
|
+
sender: data.sender,
|
144
|
+
receiver: data.receiver,
|
145
|
+
paymentId: data.paymentId,
|
146
|
+
purchaseData: data.purchaseData,
|
140
147
|
};
|
141
148
|
}
|
142
149
|
|
143
150
|
if (data.status === "NOT_FOUND") {
|
144
151
|
return {
|
145
152
|
status: "NOT_FOUND",
|
153
|
+
paymentId: data.paymentId,
|
146
154
|
transactions: [],
|
147
155
|
};
|
148
156
|
}
|
@@ -156,6 +164,11 @@ export async function status(options: status.Options): Promise<status.Result> {
|
|
156
164
|
originTokenAddress: data.originTokenAddress,
|
157
165
|
destinationTokenAddress: data.destinationTokenAddress,
|
158
166
|
transactions: data.transactions,
|
167
|
+
originToken: data.originToken,
|
168
|
+
destinationToken: data.destinationToken,
|
169
|
+
sender: data.sender,
|
170
|
+
receiver: data.receiver,
|
171
|
+
paymentId: data.paymentId,
|
159
172
|
purchaseData: data.purchaseData,
|
160
173
|
};
|
161
174
|
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { toWei } from "src/utils/units.js";
|
2
|
+
import { describe, expect, it } from "vitest";
|
3
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
|
+
import * as Transfer from "./Transfer.js";
|
5
|
+
|
6
|
+
describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Transfer.prepare", () => {
|
7
|
+
it("should get a valid prepared quote", async () => {
|
8
|
+
const quote = await Transfer.prepare({
|
9
|
+
chainId: 1,
|
10
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
11
|
+
amount: toWei("0.01"),
|
12
|
+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
13
|
+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
14
|
+
client: TEST_CLIENT,
|
15
|
+
purchaseData: {
|
16
|
+
reference: "test-transfer",
|
17
|
+
},
|
18
|
+
});
|
19
|
+
|
20
|
+
expect(quote).toBeDefined();
|
21
|
+
expect(quote.intent.amount).toEqual(toWei("0.01"));
|
22
|
+
for (const step of quote.steps) {
|
23
|
+
expect(step.transactions.length).toBeGreaterThan(0);
|
24
|
+
}
|
25
|
+
expect(quote.intent).toBeDefined();
|
26
|
+
});
|
27
|
+
|
28
|
+
it("should surface any errors", async () => {
|
29
|
+
await expect(
|
30
|
+
Transfer.prepare({
|
31
|
+
chainId: 444, // Invalid chain ID
|
32
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
33
|
+
amount: toWei("1000000000"),
|
34
|
+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
35
|
+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
36
|
+
client: TEST_CLIENT,
|
37
|
+
}),
|
38
|
+
).rejects.toThrowError();
|
39
|
+
});
|
40
|
+
|
41
|
+
it("should support the feePayer option", async () => {
|
42
|
+
const senderQuote = await Transfer.prepare({
|
43
|
+
chainId: 1,
|
44
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
45
|
+
amount: toWei("0.01"),
|
46
|
+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
47
|
+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
48
|
+
feePayer: "sender",
|
49
|
+
client: TEST_CLIENT,
|
50
|
+
});
|
51
|
+
|
52
|
+
expect(senderQuote).toBeDefined();
|
53
|
+
expect(senderQuote.intent.feePayer).toBe("sender");
|
54
|
+
|
55
|
+
const receiverQuote = await Transfer.prepare({
|
56
|
+
chainId: 1,
|
57
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
58
|
+
amount: toWei("0.01"),
|
59
|
+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
60
|
+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
61
|
+
feePayer: "receiver",
|
62
|
+
client: TEST_CLIENT,
|
63
|
+
});
|
64
|
+
|
65
|
+
expect(receiverQuote).toBeDefined();
|
66
|
+
expect(receiverQuote.intent.feePayer).toBe("receiver");
|
67
|
+
|
68
|
+
// When receiver pays fees, the destination amount should be less than the requested amount
|
69
|
+
expect(receiverQuote.destinationAmount).toBeLessThan(toWei("0.01"));
|
70
|
+
|
71
|
+
// When sender pays fees, the origin amount should be more than the requested amount
|
72
|
+
// and the destination amount should equal the requested amount
|
73
|
+
expect(senderQuote.originAmount).toBeGreaterThan(toWei("0.01"));
|
74
|
+
expect(senderQuote.destinationAmount).toEqual(toWei("0.01"));
|
75
|
+
});
|
76
|
+
});
|