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
@@ -1,5 +1,5 @@
|
|
1
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
1
2
|
import { getClientFetch } from "../utils/fetch.js";
|
2
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
3
|
/**
|
4
4
|
* Retrieves a Universal Bridge quote for the provided sell intent. The quote will specify the expected `destinationAmount` that will be received in exchange for the specified `originAmount`, which is specified with the `sellAmountWei` option.
|
5
5
|
*
|
@@ -102,7 +102,7 @@ export async function status(options) {
|
|
102
102
|
const { transactionHash, client } = options;
|
103
103
|
const chainId = "chainId" in options ? options.chainId : options.chain.id;
|
104
104
|
const clientFetch = getClientFetch(client);
|
105
|
-
const url = new URL(`${
|
105
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/status`);
|
106
106
|
url.searchParams.set("transactionHash", transactionHash);
|
107
107
|
url.searchParams.set("chainId", chainId.toString());
|
108
108
|
const response = await clientFetch(url.toString());
|
@@ -114,6 +114,7 @@ export async function status(options) {
|
|
114
114
|
if (data.status === "FAILED") {
|
115
115
|
return {
|
116
116
|
status: "FAILED",
|
117
|
+
paymentId: data.paymentId,
|
117
118
|
transactions: data.transactions,
|
118
119
|
};
|
119
120
|
}
|
@@ -126,11 +127,18 @@ export async function status(options) {
|
|
126
127
|
originTokenAddress: data.originTokenAddress,
|
127
128
|
destinationTokenAddress: data.destinationTokenAddress,
|
128
129
|
transactions: data.transactions,
|
130
|
+
originToken: data.originToken,
|
131
|
+
destinationToken: data.destinationToken,
|
132
|
+
sender: data.sender,
|
133
|
+
receiver: data.receiver,
|
134
|
+
paymentId: data.paymentId,
|
135
|
+
purchaseData: data.purchaseData,
|
129
136
|
};
|
130
137
|
}
|
131
138
|
if (data.status === "NOT_FOUND") {
|
132
139
|
return {
|
133
140
|
status: "NOT_FOUND",
|
141
|
+
paymentId: data.paymentId,
|
134
142
|
transactions: [],
|
135
143
|
};
|
136
144
|
}
|
@@ -143,6 +151,11 @@ export async function status(options) {
|
|
143
151
|
originTokenAddress: data.originTokenAddress,
|
144
152
|
destinationTokenAddress: data.destinationTokenAddress,
|
145
153
|
transactions: data.transactions,
|
154
|
+
originToken: data.originToken,
|
155
|
+
destinationToken: data.destinationToken,
|
156
|
+
sender: data.sender,
|
157
|
+
receiver: data.receiver,
|
158
|
+
paymentId: data.paymentId,
|
146
159
|
purchaseData: data.purchaseData,
|
147
160
|
};
|
148
161
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/bridge/Status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/bridge/Status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,OAAO,GAAG,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IAE1E,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG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ACvC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;QACvC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACjD,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;QACrD,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1,226 @@
|
|
1
|
+
import { defineChain } from "../chains/utils.js";
|
2
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
3
|
+
import { getClientFetch } from "../utils/fetch.js";
|
4
|
+
import { stringify } from "../utils/json.js";
|
5
|
+
/**
|
6
|
+
* Prepares a **finalized** Universal Bridge quote for the provided transfer request with transaction data.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```typescript
|
10
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
11
|
+
*
|
12
|
+
* const quote = await Bridge.Transfer.prepare({
|
13
|
+
* chainId: 1,
|
14
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
15
|
+
* amount: toWei("0.01"),
|
16
|
+
* sender: "0x...",
|
17
|
+
* receiver: "0x...",
|
18
|
+
* client: thirdwebClient,
|
19
|
+
* });
|
20
|
+
* ```
|
21
|
+
*
|
22
|
+
* This will return a quote that might look like:
|
23
|
+
* ```typescript
|
24
|
+
* {
|
25
|
+
* originAmount: 10000026098875381n,
|
26
|
+
* destinationAmount: 10000000000000000n,
|
27
|
+
* blockNumber: 22026509n,
|
28
|
+
* timestamp: 1741730936680,
|
29
|
+
* estimatedExecutionTimeMs: 1000
|
30
|
+
* steps: [
|
31
|
+
* {
|
32
|
+
* originToken: {
|
33
|
+
* chainId: 1,
|
34
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
35
|
+
* symbol: "ETH",
|
36
|
+
* name: "Ethereum",
|
37
|
+
* decimals: 18,
|
38
|
+
* priceUsd: 2000,
|
39
|
+
* iconUri: "https://..."
|
40
|
+
* },
|
41
|
+
* destinationToken: {
|
42
|
+
* chainId: 1,
|
43
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
44
|
+
* symbol: "ETH",
|
45
|
+
* name: "Ethereum",
|
46
|
+
* decimals: 18,
|
47
|
+
* priceUsd: 2000,
|
48
|
+
* iconUri: "https://..."
|
49
|
+
* },
|
50
|
+
* originAmount: 10000026098875381n,
|
51
|
+
* destinationAmount: 10000000000000000n,
|
52
|
+
* estimatedExecutionTimeMs: 1000
|
53
|
+
* transactions: [
|
54
|
+
* {
|
55
|
+
* action: "approval",
|
56
|
+
* id: "0x",
|
57
|
+
* to: "0x...",
|
58
|
+
* data: "0x...",
|
59
|
+
* chainId: 1,
|
60
|
+
* type: "eip1559"
|
61
|
+
* },
|
62
|
+
* {
|
63
|
+
* action: "transfer",
|
64
|
+
* to: "0x...",
|
65
|
+
* value: 10000026098875381n,
|
66
|
+
* data: "0x...",
|
67
|
+
* chainId: 1,
|
68
|
+
* type: "eip1559"
|
69
|
+
* }
|
70
|
+
* ]
|
71
|
+
* }
|
72
|
+
* ],
|
73
|
+
* expiration: 1741730936680,
|
74
|
+
* intent: {
|
75
|
+
* chainId: 1,
|
76
|
+
* tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
77
|
+
* amount: 10000000000000000n,
|
78
|
+
* sender: "0x...",
|
79
|
+
* receiver: "0x..."
|
80
|
+
* }
|
81
|
+
* }
|
82
|
+
* ```
|
83
|
+
*
|
84
|
+
* ## Sending the transactions
|
85
|
+
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that 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:
|
86
|
+
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
|
87
|
+
* - 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.
|
88
|
+
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
89
|
+
*
|
90
|
+
* NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer.
|
91
|
+
*
|
92
|
+
* You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
|
93
|
+
*
|
94
|
+
* You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
|
95
|
+
*
|
96
|
+
* ```ts
|
97
|
+
* const quote = await Bridge.Transfer.prepare({
|
98
|
+
* chainId: 1,
|
99
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
100
|
+
* amount: toWei("0.01"),
|
101
|
+
* sender: "0x...",
|
102
|
+
* receiver: "0x...",
|
103
|
+
* purchaseData: {
|
104
|
+
* reference: "payment-123",
|
105
|
+
* metadata: {
|
106
|
+
* note: "Transfer to Alice"
|
107
|
+
* }
|
108
|
+
* },
|
109
|
+
* client: thirdwebClient,
|
110
|
+
* });
|
111
|
+
* ```
|
112
|
+
*
|
113
|
+
* ## Fees
|
114
|
+
* There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount.
|
115
|
+
*
|
116
|
+
* For example, if you were to request a transfer with `feePayer` set to `receiver`:
|
117
|
+
* ```typescript
|
118
|
+
* const quote = await Bridge.Transfer.prepare({
|
119
|
+
* chainId: 1,
|
120
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
121
|
+
* amount: 100_000_000n, // 100 USDC
|
122
|
+
* sender: "0x...",
|
123
|
+
* receiver: "0x...",
|
124
|
+
* feePayer: "receiver",
|
125
|
+
* client: thirdwebClient,
|
126
|
+
* });
|
127
|
+
* ```
|
128
|
+
*
|
129
|
+
* The returned quote might look like:
|
130
|
+
* ```typescript
|
131
|
+
* {
|
132
|
+
* originAmount: 100_000_000n, // 100 USDC
|
133
|
+
* destinationAmount: 99_970_000n, // 99.97 USDC
|
134
|
+
* ...
|
135
|
+
* }
|
136
|
+
* ```
|
137
|
+
*
|
138
|
+
* If you were to request a transfer with `feePayer` set to `sender`:
|
139
|
+
* ```typescript
|
140
|
+
* const quote = await Bridge.Transfer.prepare({
|
141
|
+
* chainId: 1,
|
142
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
143
|
+
* amount: 100_000_000n, // 100 USDC
|
144
|
+
* sender: "0x...",
|
145
|
+
* receiver: "0x...",
|
146
|
+
* feePayer: "sender",
|
147
|
+
* client: thirdwebClient,
|
148
|
+
* });
|
149
|
+
* ```
|
150
|
+
*
|
151
|
+
* The returned quote might look like:
|
152
|
+
* ```typescript
|
153
|
+
* {
|
154
|
+
* originAmount: 100_030_000n, // 100.03 USDC
|
155
|
+
* destinationAmount: 100_000_000n, // 100 USDC
|
156
|
+
* ...
|
157
|
+
* }
|
158
|
+
* ```
|
159
|
+
*
|
160
|
+
* @param options - The options for the quote.
|
161
|
+
* @param options.chainId - The chain ID of the token.
|
162
|
+
* @param options.tokenAddress - The address of the token.
|
163
|
+
* @param options.amount - The amount of the token to transfer.
|
164
|
+
* @param options.sender - The address of the sender.
|
165
|
+
* @param options.receiver - The address of the recipient.
|
166
|
+
* @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
|
167
|
+
* @param options.client - Your thirdweb client.
|
168
|
+
* @param [options.feePayer] - The address that will pay the fees for the transfer. If not specified, the sender will be used. Values can be "sender" or "receiver".
|
169
|
+
*
|
170
|
+
* @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
|
171
|
+
*
|
172
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
173
|
+
* @bridge Transfer
|
174
|
+
* @beta
|
175
|
+
*/
|
176
|
+
export async function prepare(options) {
|
177
|
+
const { chainId, tokenAddress, sender, receiver, client, amount, purchaseData, feePayer, } = options;
|
178
|
+
const clientFetch = getClientFetch(client);
|
179
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/transfer/prepare`);
|
180
|
+
const response = await clientFetch(url.toString(), {
|
181
|
+
method: "POST",
|
182
|
+
headers: {
|
183
|
+
"Content-Type": "application/json",
|
184
|
+
},
|
185
|
+
body: stringify({
|
186
|
+
transferAmountWei: amount.toString(), // legacy
|
187
|
+
amount: amount.toString(),
|
188
|
+
chainId: chainId.toString(),
|
189
|
+
tokenAddress,
|
190
|
+
sender,
|
191
|
+
receiver,
|
192
|
+
purchaseData,
|
193
|
+
feePayer,
|
194
|
+
}),
|
195
|
+
});
|
196
|
+
if (!response.ok) {
|
197
|
+
const errorJson = await response.json();
|
198
|
+
throw new Error(`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`);
|
199
|
+
}
|
200
|
+
const { data } = await response.json();
|
201
|
+
return {
|
202
|
+
originAmount: BigInt(data.originAmount),
|
203
|
+
destinationAmount: BigInt(data.destinationAmount),
|
204
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
205
|
+
timestamp: data.timestamp,
|
206
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
207
|
+
steps: data.steps.map((step) => ({
|
208
|
+
...step,
|
209
|
+
transactions: step.transactions.map((transaction) => ({
|
210
|
+
...transaction,
|
211
|
+
value: transaction.value ? BigInt(transaction.value) : undefined,
|
212
|
+
client,
|
213
|
+
chain: defineChain(transaction.chainId),
|
214
|
+
})),
|
215
|
+
})),
|
216
|
+
intent: {
|
217
|
+
chainId,
|
218
|
+
tokenAddress,
|
219
|
+
amount,
|
220
|
+
sender,
|
221
|
+
receiver,
|
222
|
+
feePayer,
|
223
|
+
},
|
224
|
+
};
|
225
|
+
}
|
226
|
+
//# sourceMappingURL=Transfer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Transfer.js","sourceRoot":"","sources":["../../../src/bridge/Transfer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0KG;AACH,MAAM,CAAC,KA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AAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QACpE,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;QACvD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC/B,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBACpD,GAAG,WAAW;gBACd,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;gBAChE,MAAM;gBACN,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC;aACxC,CAAC,CAAC;SACJ,CAAC,CAAC;QACH,MAAM,EAAE;YACN,OAAO;YACP,YAAY;YACZ,MAAM;YACN,MAAM;YACN,QAAQ;YACR,QAAQ;SACT;KACF,CAAC;AACJ,CAAC"}
|
package/dist/esm/bridge/index.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
export * as Buy from "./Buy.js";
|
2
2
|
export * as Sell from "./Sell.js";
|
3
|
+
export * as Transfer from "./Transfer.js";
|
4
|
+
export * as Onramp from "./Onramp.js";
|
3
5
|
export { status } from "./Status.js";
|
4
6
|
export { routes } from "./Routes.js";
|
5
7
|
export { chains } from "./Chains.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"BridgeAction.js","sourceRoot":"","sources":["../../../../src/bridge/types/BridgeAction.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../../src/bridge/types/Token.ts"],"names":[],"mappings":""}
|
@@ -3,7 +3,6 @@ import * as ox__Bytes from "ox/Bytes";
|
|
3
3
|
import * as ox__Ens from "ox/Ens";
|
4
4
|
import * as ox__Hash from "ox/Hash";
|
5
5
|
import * as ox__Hex from "ox/Hex";
|
6
|
-
import { keccak256 } from "viem";
|
7
6
|
import { getContract } from "../../contract/contract.js";
|
8
7
|
import { withCache } from "../../utils/promise/withCache.js";
|
9
8
|
import { name } from "./__generated__/L2Resolver/read/name.js";
|
@@ -20,7 +19,6 @@ const convertReverseNodeToBytes = (address, chainId) => {
|
|
20
19
|
const chainCoinType = cointype.toString(16).toLocaleUpperCase();
|
21
20
|
const reverseNode = ox__Ens.namehash(`${chainCoinType.toLocaleUpperCase()}.reverse`);
|
22
21
|
const addressReverseNode = ox__Hash.keccak256(ox__AbiParameters.encodePacked(["bytes32", "bytes32"], [reverseNode, addressNode]));
|
23
|
-
keccak256;
|
24
22
|
return addressReverseNode;
|
25
23
|
};
|
26
24
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolve-l2-name.js","sourceRoot":"","sources":["../../../../src/extensions/ens/resolve-l2-name.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"resolve-l2-name.js","sourceRoot":"","sources":["../../../../src/extensions/ens/resolve-l2-name.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAC;AAY/D;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,CAAC,OAAgB,EAAE,OAAe,EAAE,EAAE;IACtE,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,EAAa,CAAC;IAChE,oFAAoF;IACpF,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CACnC,QAAQ,CAAC,SAAS,CAChB,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAC1D,CACF,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC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Aa;QACb,SAAS,EAAE,EAAE,GAAG,IAAI;KACrB,CACF,CAAC;AACJ,CAAC"}
|
@@ -1,7 +1,10 @@
|
|
1
|
+
import { Value } from "ox";
|
2
|
+
import * as ox__AbiFunction from "ox/AbiFunction";
|
3
|
+
import * as Bridge from "../../bridge/index.js";
|
1
4
|
import { getCachedChain } from "../../chains/utils.js";
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
+
import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
|
6
|
+
import { getContract } from "../../contract/contract.js";
|
7
|
+
import { decimals } from "../../extensions/erc20/read/decimals.js";
|
5
8
|
/**
|
6
9
|
* Get a quote of type [`BuyWithCryptoQuote`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoQuote) to buy any given token with crypto.
|
7
10
|
* This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.
|
@@ -32,65 +35,168 @@ import { getPayBuyWithCryptoQuoteEndpoint } from "../utils/definitions.js";
|
|
32
35
|
*/
|
33
36
|
export async function getBuyWithCryptoQuote(params) {
|
34
37
|
try {
|
35
|
-
const
|
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
|
-
throw errorObj;
|
38
|
+
const quote = await (async () => {
|
39
|
+
if (params.toAmount) {
|
40
|
+
const destinationTokenContract = getContract({
|
41
|
+
address: params.toTokenAddress,
|
42
|
+
chain: getCachedChain(params.toChainId),
|
43
|
+
client: params.client,
|
44
|
+
});
|
45
|
+
const tokenDecimals = destinationTokenContract.address.toLowerCase() ===
|
46
|
+
NATIVE_TOKEN_ADDRESS
|
47
|
+
? 18
|
48
|
+
: await decimals({
|
49
|
+
contract: destinationTokenContract,
|
50
|
+
});
|
51
|
+
const amount = Value.from(params.toAmount, tokenDecimals);
|
52
|
+
return Bridge.Buy.prepare({
|
53
|
+
sender: params.fromAddress,
|
54
|
+
receiver: params.toAddress,
|
55
|
+
originChainId: params.fromChainId,
|
56
|
+
originTokenAddress: params.fromTokenAddress,
|
57
|
+
destinationChainId: params.toChainId,
|
58
|
+
destinationTokenAddress: params.toTokenAddress,
|
59
|
+
amount: amount,
|
60
|
+
purchaseData: params.purchaseData,
|
61
|
+
client: params.client,
|
62
|
+
});
|
61
63
|
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
else if (params.fromAmount) {
|
65
|
+
const originTokenContract = getContract({
|
66
|
+
address: params.fromTokenAddress,
|
67
|
+
chain: getCachedChain(params.fromChainId),
|
68
|
+
client: params.client,
|
69
|
+
});
|
70
|
+
const tokenDecimals = await decimals({
|
71
|
+
contract: originTokenContract,
|
72
|
+
});
|
73
|
+
const amount = Value.from(params.fromAmount, tokenDecimals);
|
74
|
+
return Bridge.Sell.prepare({
|
75
|
+
sender: params.fromAddress,
|
76
|
+
receiver: params.toAddress,
|
77
|
+
originChainId: params.fromChainId,
|
78
|
+
originTokenAddress: params.fromTokenAddress,
|
79
|
+
destinationChainId: params.toChainId,
|
80
|
+
destinationTokenAddress: params.toTokenAddress,
|
81
|
+
amount: amount,
|
82
|
+
purchaseData: params.purchaseData,
|
83
|
+
client: params.client,
|
84
|
+
});
|
85
|
+
}
|
86
|
+
throw new Error("Invalid quote request, must provide either `fromAmount` or `toAmount`");
|
87
|
+
})();
|
66
88
|
// check if the fromAddress already has approval for the given amount
|
67
|
-
const
|
89
|
+
const firstStep = quote.steps[0];
|
90
|
+
if (!firstStep) {
|
91
|
+
throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
|
92
|
+
}
|
93
|
+
const approvalTxs = firstStep.transactions.filter((tx) => tx.action === "approval");
|
94
|
+
if (approvalTxs.length > 1) {
|
95
|
+
throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
|
96
|
+
}
|
97
|
+
const approvalTx = approvalTxs[0];
|
98
|
+
const txs = firstStep.transactions.filter((tx) => tx.action !== "approval");
|
99
|
+
if (txs.length > 1) {
|
100
|
+
throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
|
101
|
+
}
|
102
|
+
const tx = txs[0];
|
103
|
+
if (!tx) {
|
104
|
+
throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
|
105
|
+
}
|
106
|
+
let approvalData;
|
107
|
+
if (approvalTx) {
|
108
|
+
const abiFunction = ox__AbiFunction.from([
|
109
|
+
"function approve(address spender, uint256 amount)",
|
110
|
+
]);
|
111
|
+
const [spender, amount] = ox__AbiFunction.decodeData(abiFunction, approvalTx.data);
|
112
|
+
approvalData = {
|
113
|
+
chainId: firstStep.originToken.chainId,
|
114
|
+
tokenAddress: firstStep.originToken.address,
|
115
|
+
spenderAddress: spender,
|
116
|
+
amountWei: amount.toString(),
|
117
|
+
};
|
118
|
+
}
|
68
119
|
const swapRoute = {
|
69
120
|
transactionRequest: {
|
70
|
-
|
71
|
-
client: params.client,
|
72
|
-
data: data.transactionRequest.data,
|
73
|
-
to: data.transactionRequest.to,
|
74
|
-
value: BigInt(data.transactionRequest.value),
|
121
|
+
...tx,
|
75
122
|
extraGas: 50000n, // extra gas buffer
|
76
123
|
},
|
77
124
|
approvalData,
|
78
125
|
swapDetails: {
|
79
|
-
fromAddress:
|
80
|
-
toAddress:
|
81
|
-
fromToken:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
126
|
+
fromAddress: quote.intent.sender,
|
127
|
+
toAddress: quote.intent.receiver,
|
128
|
+
fromToken: {
|
129
|
+
tokenAddress: firstStep.originToken.address,
|
130
|
+
chainId: firstStep.originToken.chainId,
|
131
|
+
decimals: firstStep.originToken.decimals,
|
132
|
+
symbol: firstStep.originToken.symbol,
|
133
|
+
name: firstStep.originToken.name,
|
134
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
135
|
+
},
|
136
|
+
toToken: {
|
137
|
+
tokenAddress: firstStep.destinationToken.address,
|
138
|
+
chainId: firstStep.destinationToken.chainId,
|
139
|
+
decimals: firstStep.destinationToken.decimals,
|
140
|
+
symbol: firstStep.destinationToken.symbol,
|
141
|
+
name: firstStep.destinationToken.name,
|
142
|
+
priceUSDCents: firstStep.destinationToken.priceUsd * 100,
|
143
|
+
},
|
144
|
+
fromAmount: Value.format(quote.originAmount, firstStep.originToken.decimals).toString(),
|
145
|
+
fromAmountWei: quote.originAmount.toString(),
|
146
|
+
toAmountMinWei: quote.destinationAmount.toString(),
|
147
|
+
toAmountMin: Value.format(quote.destinationAmount, firstStep.destinationToken.decimals).toString(),
|
148
|
+
toAmountWei: quote.destinationAmount.toString(),
|
149
|
+
toAmount: Value.format(quote.destinationAmount, firstStep.destinationToken.decimals).toString(),
|
150
|
+
estimated: {
|
151
|
+
fromAmountUSDCents: Number(Value.format(quote.originAmount, firstStep.originToken.decimals)) *
|
152
|
+
firstStep.originToken.priceUsd *
|
153
|
+
100,
|
154
|
+
toAmountMinUSDCents: Number(Value.format(quote.destinationAmount, firstStep.destinationToken.decimals)) *
|
155
|
+
firstStep.destinationToken.priceUsd *
|
156
|
+
100,
|
157
|
+
toAmountUSDCents: Number(Value.format(quote.destinationAmount, firstStep.destinationToken.decimals)) *
|
158
|
+
firstStep.destinationToken.priceUsd *
|
159
|
+
100,
|
160
|
+
slippageBPS: 0,
|
161
|
+
feesUSDCents: 0,
|
162
|
+
gasCostUSDCents: 0,
|
163
|
+
durationSeconds: firstStep.estimatedExecutionTimeMs / 1000,
|
164
|
+
},
|
165
|
+
maxSlippageBPS: 0,
|
91
166
|
},
|
92
|
-
paymentTokens:
|
93
|
-
|
167
|
+
paymentTokens: [
|
168
|
+
{
|
169
|
+
token: {
|
170
|
+
tokenAddress: firstStep.originToken.address,
|
171
|
+
chainId: firstStep.originToken.chainId,
|
172
|
+
decimals: firstStep.originToken.decimals,
|
173
|
+
symbol: firstStep.originToken.symbol,
|
174
|
+
name: firstStep.originToken.name,
|
175
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
176
|
+
},
|
177
|
+
amountWei: quote.originAmount.toString(),
|
178
|
+
amount: Value.format(quote.originAmount, firstStep.originToken.decimals).toString(),
|
179
|
+
amountUSDCents: Number(Value.format(quote.originAmount, firstStep.originToken.decimals)) *
|
180
|
+
firstStep.originToken.priceUsd *
|
181
|
+
100,
|
182
|
+
},
|
183
|
+
],
|
184
|
+
// TODO (UB): add develope and platform fees in API
|
185
|
+
processingFees: [
|
186
|
+
{
|
187
|
+
token: {
|
188
|
+
tokenAddress: firstStep.originToken.address,
|
189
|
+
chainId: firstStep.originToken.chainId,
|
190
|
+
decimals: firstStep.originToken.decimals,
|
191
|
+
symbol: firstStep.originToken.symbol,
|
192
|
+
name: firstStep.originToken.name,
|
193
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
194
|
+
},
|
195
|
+
amountUSDCents: 0,
|
196
|
+
amountWei: "0",
|
197
|
+
amount: "0",
|
198
|
+
},
|
199
|
+
],
|
94
200
|
client: params.client,
|
95
201
|
};
|
96
202
|
return swapRoute;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/pay/buyWithCrypto/getQuote.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/pay/buyWithCrypto/getQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAC3B,OAAO,KAAK,eAAe,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAA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