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,15 +1,16 @@
|
|
1
|
-
import
|
1
|
+
import { Value } from "ox";
|
2
|
+
import * as ox__AbiFunction from "ox/AbiFunction";
|
3
|
+
import * as Bridge from "../../bridge/index.js";
|
2
4
|
import { getCachedChain } from "../../chains/utils.js";
|
3
5
|
import type { ThirdwebClient } from "../../client/client.js";
|
6
|
+
import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
|
7
|
+
import { getContract } from "../../contract/contract.js";
|
8
|
+
import { decimals } from "../../extensions/erc20/read/decimals.js";
|
4
9
|
import type { PrepareTransactionOptions } from "../../transaction/prepare-transaction.js";
|
5
|
-
import { getClientFetch } from "../../utils/fetch.js";
|
6
|
-
import { stringify } from "../../utils/json.js";
|
7
|
-
import { getPayBuyWithCryptoQuoteEndpoint } from "../utils/definitions.js";
|
8
10
|
import type {
|
9
11
|
QuoteApprovalInfo,
|
10
12
|
QuotePaymentToken,
|
11
13
|
QuoteTokenInfo,
|
12
|
-
QuoteTransactionRequest,
|
13
14
|
} from "./commonTypes.js";
|
14
15
|
|
15
16
|
/**
|
@@ -105,44 +106,6 @@ export type GetBuyWithCryptoQuoteParams = {
|
|
105
106
|
}
|
106
107
|
);
|
107
108
|
|
108
|
-
/**
|
109
|
-
* @buyCrypto
|
110
|
-
*/
|
111
|
-
type BuyWithCryptoQuoteRouteResponse = {
|
112
|
-
transactionRequest: QuoteTransactionRequest;
|
113
|
-
approval?: QuoteApprovalInfo;
|
114
|
-
|
115
|
-
fromAddress: string;
|
116
|
-
toAddress: string;
|
117
|
-
|
118
|
-
fromToken: QuoteTokenInfo;
|
119
|
-
toToken: QuoteTokenInfo;
|
120
|
-
|
121
|
-
fromAmountWei: string;
|
122
|
-
fromAmount: string;
|
123
|
-
|
124
|
-
toAmountMinWei: string;
|
125
|
-
toAmountMin: string;
|
126
|
-
toAmountWei: string;
|
127
|
-
toAmount: string;
|
128
|
-
|
129
|
-
paymentTokens: QuotePaymentToken[];
|
130
|
-
processingFees: QuotePaymentToken[];
|
131
|
-
|
132
|
-
estimated: {
|
133
|
-
fromAmountUSDCents: number;
|
134
|
-
toAmountMinUSDCents: number;
|
135
|
-
toAmountUSDCents: number;
|
136
|
-
slippageBPS: number;
|
137
|
-
feesUSDCents: number;
|
138
|
-
gasCostUSDCents?: number;
|
139
|
-
durationSeconds?: number;
|
140
|
-
};
|
141
|
-
|
142
|
-
maxSlippageBPS: number;
|
143
|
-
bridge?: string;
|
144
|
-
};
|
145
|
-
|
146
109
|
/**
|
147
110
|
* @buyCrypto
|
148
111
|
*/
|
@@ -215,76 +178,223 @@ export async function getBuyWithCryptoQuote(
|
|
215
178
|
params: GetBuyWithCryptoQuoteParams,
|
216
179
|
): Promise<BuyWithCryptoQuote> {
|
217
180
|
try {
|
218
|
-
const
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
if (
|
245
|
-
|
181
|
+
const quote = await (async () => {
|
182
|
+
if (params.toAmount) {
|
183
|
+
const destinationTokenContract = getContract({
|
184
|
+
address: params.toTokenAddress,
|
185
|
+
chain: getCachedChain(params.toChainId),
|
186
|
+
client: params.client,
|
187
|
+
});
|
188
|
+
const tokenDecimals =
|
189
|
+
destinationTokenContract.address.toLowerCase() ===
|
190
|
+
NATIVE_TOKEN_ADDRESS
|
191
|
+
? 18
|
192
|
+
: await decimals({
|
193
|
+
contract: destinationTokenContract,
|
194
|
+
});
|
195
|
+
const amount = Value.from(params.toAmount, tokenDecimals);
|
196
|
+
return Bridge.Buy.prepare({
|
197
|
+
sender: params.fromAddress,
|
198
|
+
receiver: params.toAddress,
|
199
|
+
originChainId: params.fromChainId,
|
200
|
+
originTokenAddress: params.fromTokenAddress,
|
201
|
+
destinationChainId: params.toChainId,
|
202
|
+
destinationTokenAddress: params.toTokenAddress,
|
203
|
+
amount: amount,
|
204
|
+
purchaseData: params.purchaseData,
|
205
|
+
client: params.client,
|
206
|
+
});
|
207
|
+
} else if (params.fromAmount) {
|
208
|
+
const originTokenContract = getContract({
|
209
|
+
address: params.fromTokenAddress,
|
210
|
+
chain: getCachedChain(params.fromChainId),
|
211
|
+
client: params.client,
|
212
|
+
});
|
213
|
+
const tokenDecimals = await decimals({
|
214
|
+
contract: originTokenContract,
|
215
|
+
});
|
216
|
+
const amount = Value.from(params.fromAmount, tokenDecimals);
|
217
|
+
return Bridge.Sell.prepare({
|
218
|
+
sender: params.fromAddress,
|
219
|
+
receiver: params.toAddress,
|
220
|
+
originChainId: params.fromChainId,
|
221
|
+
originTokenAddress: params.fromTokenAddress,
|
222
|
+
destinationChainId: params.toChainId,
|
223
|
+
destinationTokenAddress: params.toTokenAddress,
|
224
|
+
amount: amount,
|
225
|
+
purchaseData: params.purchaseData,
|
226
|
+
client: params.client,
|
227
|
+
});
|
246
228
|
}
|
247
|
-
throw new Error(
|
229
|
+
throw new Error(
|
230
|
+
"Invalid quote request, must provide either `fromAmount` or `toAmount`",
|
231
|
+
);
|
232
|
+
})();
|
233
|
+
|
234
|
+
// check if the fromAddress already has approval for the given amount
|
235
|
+
const firstStep = quote.steps[0];
|
236
|
+
if (!firstStep) {
|
237
|
+
throw new Error(
|
238
|
+
"This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.",
|
239
|
+
);
|
240
|
+
}
|
241
|
+
const approvalTxs = firstStep.transactions.filter(
|
242
|
+
(tx) => tx.action === "approval",
|
243
|
+
);
|
244
|
+
if (approvalTxs.length > 1) {
|
245
|
+
throw new Error(
|
246
|
+
"This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.",
|
247
|
+
);
|
248
248
|
}
|
249
|
+
const approvalTx = approvalTxs[0];
|
249
250
|
|
250
|
-
const
|
251
|
-
|
251
|
+
const txs = firstStep.transactions.filter((tx) => tx.action !== "approval");
|
252
|
+
if (txs.length > 1) {
|
253
|
+
throw new Error(
|
254
|
+
"This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.",
|
255
|
+
);
|
256
|
+
}
|
257
|
+
const tx = txs[0];
|
258
|
+
if (!tx) {
|
259
|
+
throw new Error(
|
260
|
+
"This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.",
|
261
|
+
);
|
262
|
+
}
|
252
263
|
|
253
|
-
|
254
|
-
|
264
|
+
let approvalData: QuoteApprovalInfo | undefined;
|
265
|
+
if (approvalTx) {
|
266
|
+
const abiFunction = ox__AbiFunction.from([
|
267
|
+
"function approve(address spender, uint256 amount)",
|
268
|
+
]);
|
269
|
+
const [spender, amount] = ox__AbiFunction.decodeData(
|
270
|
+
abiFunction,
|
271
|
+
approvalTx.data,
|
272
|
+
);
|
273
|
+
approvalData = {
|
274
|
+
chainId: firstStep.originToken.chainId,
|
275
|
+
tokenAddress: firstStep.originToken.address,
|
276
|
+
spenderAddress: spender,
|
277
|
+
amountWei: amount.toString(),
|
278
|
+
};
|
279
|
+
}
|
255
280
|
|
256
281
|
const swapRoute: BuyWithCryptoQuote = {
|
257
282
|
transactionRequest: {
|
258
|
-
|
259
|
-
client: params.client,
|
260
|
-
data: data.transactionRequest.data as Hash,
|
261
|
-
to: data.transactionRequest.to,
|
262
|
-
value: BigInt(data.transactionRequest.value),
|
283
|
+
...tx,
|
263
284
|
extraGas: 50000n, // extra gas buffer
|
264
285
|
},
|
265
286
|
approvalData,
|
266
287
|
swapDetails: {
|
267
|
-
fromAddress:
|
268
|
-
toAddress:
|
269
|
-
|
270
|
-
fromToken:
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
288
|
+
fromAddress: quote.intent.sender,
|
289
|
+
toAddress: quote.intent.receiver,
|
290
|
+
|
291
|
+
fromToken: {
|
292
|
+
tokenAddress: firstStep.originToken.address,
|
293
|
+
chainId: firstStep.originToken.chainId,
|
294
|
+
decimals: firstStep.originToken.decimals,
|
295
|
+
symbol: firstStep.originToken.symbol,
|
296
|
+
name: firstStep.originToken.name,
|
297
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
298
|
+
},
|
299
|
+
toToken: {
|
300
|
+
tokenAddress: firstStep.destinationToken.address,
|
301
|
+
chainId: firstStep.destinationToken.chainId,
|
302
|
+
decimals: firstStep.destinationToken.decimals,
|
303
|
+
symbol: firstStep.destinationToken.symbol,
|
304
|
+
name: firstStep.destinationToken.name,
|
305
|
+
priceUSDCents: firstStep.destinationToken.priceUsd * 100,
|
306
|
+
},
|
307
|
+
|
308
|
+
fromAmount: Value.format(
|
309
|
+
quote.originAmount,
|
310
|
+
firstStep.originToken.decimals,
|
311
|
+
).toString(),
|
312
|
+
fromAmountWei: quote.originAmount.toString(),
|
313
|
+
|
314
|
+
toAmountMinWei: quote.destinationAmount.toString(),
|
315
|
+
toAmountMin: Value.format(
|
316
|
+
quote.destinationAmount,
|
317
|
+
firstStep.destinationToken.decimals,
|
318
|
+
).toString(),
|
319
|
+
|
320
|
+
toAmountWei: quote.destinationAmount.toString(),
|
321
|
+
toAmount: Value.format(
|
322
|
+
quote.destinationAmount,
|
323
|
+
firstStep.destinationToken.decimals,
|
324
|
+
).toString(),
|
325
|
+
estimated: {
|
326
|
+
fromAmountUSDCents:
|
327
|
+
Number(
|
328
|
+
Value.format(quote.originAmount, firstStep.originToken.decimals),
|
329
|
+
) *
|
330
|
+
firstStep.originToken.priceUsd *
|
331
|
+
100,
|
332
|
+
toAmountMinUSDCents:
|
333
|
+
Number(
|
334
|
+
Value.format(
|
335
|
+
quote.destinationAmount,
|
336
|
+
firstStep.destinationToken.decimals,
|
337
|
+
),
|
338
|
+
) *
|
339
|
+
firstStep.destinationToken.priceUsd *
|
340
|
+
100,
|
341
|
+
toAmountUSDCents:
|
342
|
+
Number(
|
343
|
+
Value.format(
|
344
|
+
quote.destinationAmount,
|
345
|
+
firstStep.destinationToken.decimals,
|
346
|
+
),
|
347
|
+
) *
|
348
|
+
firstStep.destinationToken.priceUsd *
|
349
|
+
100,
|
350
|
+
slippageBPS: 0,
|
351
|
+
feesUSDCents: 0,
|
352
|
+
gasCostUSDCents: 0,
|
353
|
+
durationSeconds: firstStep.estimatedExecutionTimeMs / 1000,
|
354
|
+
},
|
355
|
+
|
356
|
+
maxSlippageBPS: 0,
|
284
357
|
},
|
285
358
|
|
286
|
-
paymentTokens:
|
287
|
-
|
359
|
+
paymentTokens: [
|
360
|
+
{
|
361
|
+
token: {
|
362
|
+
tokenAddress: firstStep.originToken.address,
|
363
|
+
chainId: firstStep.originToken.chainId,
|
364
|
+
decimals: firstStep.originToken.decimals,
|
365
|
+
symbol: firstStep.originToken.symbol,
|
366
|
+
name: firstStep.originToken.name,
|
367
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
368
|
+
},
|
369
|
+
amountWei: quote.originAmount.toString(),
|
370
|
+
amount: Value.format(
|
371
|
+
quote.originAmount,
|
372
|
+
firstStep.originToken.decimals,
|
373
|
+
).toString(),
|
374
|
+
amountUSDCents:
|
375
|
+
Number(
|
376
|
+
Value.format(quote.originAmount, firstStep.originToken.decimals),
|
377
|
+
) *
|
378
|
+
firstStep.originToken.priceUsd *
|
379
|
+
100,
|
380
|
+
},
|
381
|
+
],
|
382
|
+
// TODO (UB): add develope and platform fees in API
|
383
|
+
processingFees: [
|
384
|
+
{
|
385
|
+
token: {
|
386
|
+
tokenAddress: firstStep.originToken.address,
|
387
|
+
chainId: firstStep.originToken.chainId,
|
388
|
+
decimals: firstStep.originToken.decimals,
|
389
|
+
symbol: firstStep.originToken.symbol,
|
390
|
+
name: firstStep.originToken.name,
|
391
|
+
priceUSDCents: firstStep.originToken.priceUsd * 100,
|
392
|
+
},
|
393
|
+
amountUSDCents: 0,
|
394
|
+
amountWei: "0",
|
395
|
+
amount: "0",
|
396
|
+
},
|
397
|
+
],
|
288
398
|
client: params.client,
|
289
399
|
};
|
290
400
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
import { type Status, status as bridgeStatus } from "../../bridge/index.js";
|
2
|
+
import type { Token } from "../../bridge/types/Token.js";
|
1
3
|
import type { ThirdwebClient } from "../../client/client.js";
|
2
|
-
import {
|
4
|
+
import type { Hex } from "../../utils/encoding/hex.js";
|
5
|
+
import { toTokens } from "../../utils/units.js";
|
3
6
|
import type {
|
4
7
|
PayOnChainTransactionDetails,
|
5
8
|
PayTokenInfo,
|
6
9
|
} from "../utils/commonTypes.js";
|
7
|
-
import { getPayBuyWithCryptoStatusUrl } from "../utils/definitions.js";
|
8
10
|
|
9
11
|
// TODO: add JSDoc description for all properties
|
10
12
|
|
@@ -123,7 +125,7 @@ export type ValidBuyWithCryptoStatus = Exclude<
|
|
123
125
|
* }});
|
124
126
|
* ```
|
125
127
|
* @returns Object of type [`BuyWithCryptoStatus`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoStatus)
|
126
|
-
* @deprecated
|
128
|
+
* @deprecated use Bridge.status instead
|
127
129
|
* @buyCrypto
|
128
130
|
*/
|
129
131
|
export async function getBuyWithCryptoStatus(
|
@@ -133,26 +135,217 @@ export async function getBuyWithCryptoStatus(
|
|
133
135
|
if (!buyWithCryptoTransaction.transactionHash) {
|
134
136
|
throw new Error("Transaction hash is required");
|
135
137
|
}
|
136
|
-
const
|
137
|
-
transactionHash: buyWithCryptoTransaction.transactionHash,
|
138
|
-
chainId: buyWithCryptoTransaction.chainId
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
138
|
+
const result = await bridgeStatus({
|
139
|
+
transactionHash: buyWithCryptoTransaction.transactionHash as Hex,
|
140
|
+
chainId: buyWithCryptoTransaction.chainId,
|
141
|
+
client: buyWithCryptoTransaction.client,
|
142
|
+
});
|
143
|
+
|
144
|
+
switch (result.status) {
|
145
|
+
case "COMPLETED": {
|
146
|
+
const originTransaction = result.transactions?.find(
|
147
|
+
(tx) => tx.chainId === buyWithCryptoTransaction.chainId,
|
148
|
+
);
|
149
|
+
const destinationTransaction = result.transactions?.find(
|
150
|
+
(tx) => tx.chainId !== buyWithCryptoTransaction.chainId,
|
151
|
+
);
|
151
152
|
|
152
|
-
|
153
|
-
|
153
|
+
return toBuyWithCryptoStatus({
|
154
|
+
originTransaction,
|
155
|
+
destinationTransaction,
|
156
|
+
originAmount: result.originAmount,
|
157
|
+
destinationAmount: result.destinationAmount,
|
158
|
+
originTokenAddress: result.originTokenAddress,
|
159
|
+
destinationTokenAddress: result.destinationTokenAddress,
|
160
|
+
originChainId: result.originChainId,
|
161
|
+
destinationChainId: result.destinationChainId,
|
162
|
+
status: result.status,
|
163
|
+
sender: result.sender,
|
164
|
+
receiver: result.receiver,
|
165
|
+
paymentId: result.paymentId,
|
166
|
+
originToken: result.originToken,
|
167
|
+
destinationToken: result.destinationToken,
|
168
|
+
purchaseData: result.purchaseData as object | undefined,
|
169
|
+
});
|
170
|
+
}
|
171
|
+
case "PENDING": {
|
172
|
+
return toBuyWithCryptoStatus({
|
173
|
+
originAmount: result.originAmount,
|
174
|
+
originTokenAddress: result.originTokenAddress,
|
175
|
+
destinationTokenAddress: result.destinationTokenAddress,
|
176
|
+
originChainId: result.originChainId,
|
177
|
+
destinationChainId: result.destinationChainId,
|
178
|
+
status: result.status,
|
179
|
+
sender: result.sender,
|
180
|
+
receiver: result.receiver,
|
181
|
+
paymentId: result.paymentId,
|
182
|
+
originToken: result.originToken,
|
183
|
+
destinationToken: result.destinationToken,
|
184
|
+
purchaseData: result.purchaseData as object | undefined,
|
185
|
+
});
|
186
|
+
}
|
187
|
+
case "FAILED": {
|
188
|
+
const originTransaction = result.transactions?.find(
|
189
|
+
(tx) => tx.chainId === buyWithCryptoTransaction.chainId,
|
190
|
+
);
|
191
|
+
const destinationTransaction = result.transactions?.find(
|
192
|
+
(tx) => tx.chainId !== buyWithCryptoTransaction.chainId,
|
193
|
+
);
|
194
|
+
return toBuyWithCryptoStatus({
|
195
|
+
originTransaction,
|
196
|
+
destinationTransaction,
|
197
|
+
originAmount: BigInt(0), // TODO: get from API
|
198
|
+
originTokenAddress: "", // TODO: get from API
|
199
|
+
destinationTokenAddress: "", // TODO: get from API
|
200
|
+
originChainId: 0, // TODO: get from API
|
201
|
+
destinationChainId: 0, // TODO: get from API
|
202
|
+
status: result.status,
|
203
|
+
sender: "",
|
204
|
+
receiver: "",
|
205
|
+
paymentId: "",
|
206
|
+
originToken: undefined,
|
207
|
+
destinationToken: undefined,
|
208
|
+
purchaseData: result.purchaseData as object | undefined,
|
209
|
+
});
|
210
|
+
}
|
211
|
+
default: {
|
212
|
+
return {
|
213
|
+
status: "NOT_FOUND",
|
214
|
+
};
|
215
|
+
}
|
216
|
+
}
|
154
217
|
} catch (error) {
|
155
218
|
console.error("Fetch error:", error);
|
156
219
|
throw new Error(`Fetch failed: ${error}`);
|
157
220
|
}
|
158
221
|
}
|
222
|
+
|
223
|
+
function toBuyWithCryptoStatus(args: {
|
224
|
+
originTransaction?: Status["transactions"][number];
|
225
|
+
destinationTransaction?: Status["transactions"][number];
|
226
|
+
originAmount: bigint;
|
227
|
+
originTokenAddress: string;
|
228
|
+
destinationAmount?: bigint;
|
229
|
+
destinationTokenAddress: string;
|
230
|
+
originChainId: number;
|
231
|
+
destinationChainId: number;
|
232
|
+
status: Status["status"];
|
233
|
+
purchaseData?: object;
|
234
|
+
sender: string;
|
235
|
+
receiver: string;
|
236
|
+
paymentId: string;
|
237
|
+
originToken?: Token;
|
238
|
+
destinationToken?: Token;
|
239
|
+
}): BuyWithCryptoStatus {
|
240
|
+
const {
|
241
|
+
originTransaction,
|
242
|
+
destinationTransaction,
|
243
|
+
status,
|
244
|
+
purchaseData,
|
245
|
+
originAmount,
|
246
|
+
destinationAmount,
|
247
|
+
originTokenAddress,
|
248
|
+
destinationTokenAddress,
|
249
|
+
originChainId,
|
250
|
+
destinationChainId,
|
251
|
+
sender,
|
252
|
+
receiver,
|
253
|
+
originToken,
|
254
|
+
destinationToken,
|
255
|
+
} = args;
|
256
|
+
return {
|
257
|
+
fromAddress: sender,
|
258
|
+
toAddress: receiver,
|
259
|
+
quote: {
|
260
|
+
createdAt: new Date().toISOString(),
|
261
|
+
estimated: {
|
262
|
+
fromAmountUSDCents: 0,
|
263
|
+
toAmountMinUSDCents: 0,
|
264
|
+
toAmountUSDCents: 0,
|
265
|
+
slippageBPS: 0,
|
266
|
+
feesUSDCents: 0,
|
267
|
+
gasCostUSDCents: 0,
|
268
|
+
durationSeconds: 0,
|
269
|
+
},
|
270
|
+
fromAmount: originToken
|
271
|
+
? toTokens(originAmount, originToken.decimals).toString()
|
272
|
+
: "",
|
273
|
+
fromAmountWei: originAmount.toString(),
|
274
|
+
toAmount:
|
275
|
+
destinationToken && destinationAmount
|
276
|
+
? toTokens(destinationAmount, destinationToken.decimals).toString()
|
277
|
+
: "",
|
278
|
+
toAmountWei: destinationAmount ? destinationAmount.toString() : "",
|
279
|
+
toAmountMin: destinationToken
|
280
|
+
? toTokens(
|
281
|
+
destinationAmount ?? BigInt(0),
|
282
|
+
destinationToken.decimals,
|
283
|
+
).toString()
|
284
|
+
: "",
|
285
|
+
toAmountMinWei: destinationAmount ? destinationAmount.toString() : "",
|
286
|
+
fromToken: {
|
287
|
+
tokenAddress: originTokenAddress,
|
288
|
+
chainId: originChainId,
|
289
|
+
decimals: originToken?.decimals ?? 18,
|
290
|
+
name: originToken?.name ?? "",
|
291
|
+
symbol: originToken?.symbol ?? "",
|
292
|
+
priceUSDCents: 0,
|
293
|
+
},
|
294
|
+
toToken: {
|
295
|
+
tokenAddress: destinationTokenAddress,
|
296
|
+
chainId: destinationChainId,
|
297
|
+
decimals: destinationToken?.decimals ?? 18,
|
298
|
+
name: destinationToken?.name ?? "",
|
299
|
+
symbol: destinationToken?.symbol ?? "",
|
300
|
+
priceUSDCents: 0,
|
301
|
+
},
|
302
|
+
},
|
303
|
+
swapType:
|
304
|
+
originTransaction?.chainId === destinationTransaction?.chainId
|
305
|
+
? "SAME_CHAIN"
|
306
|
+
: "CROSS_CHAIN", // TODO transfer type?
|
307
|
+
status: status,
|
308
|
+
subStatus: status === "COMPLETED" ? "SUCCESS" : "NONE",
|
309
|
+
purchaseData: purchaseData as object | undefined,
|
310
|
+
bridge: "STARPORT",
|
311
|
+
destination: {
|
312
|
+
amount: destinationToken
|
313
|
+
? toTokens(
|
314
|
+
destinationAmount ?? BigInt(0),
|
315
|
+
destinationToken.decimals,
|
316
|
+
).toString()
|
317
|
+
: "",
|
318
|
+
amountWei: destinationAmount?.toString() ?? "",
|
319
|
+
token: {
|
320
|
+
tokenAddress: destinationTokenAddress,
|
321
|
+
chainId: destinationChainId,
|
322
|
+
decimals: destinationToken?.decimals ?? 18,
|
323
|
+
name: destinationToken?.name ?? "",
|
324
|
+
symbol: destinationToken?.symbol ?? "",
|
325
|
+
priceUSDCents: 0,
|
326
|
+
},
|
327
|
+
amountUSDCents: 0,
|
328
|
+
completedAt: new Date().toISOString(),
|
329
|
+
explorerLink: "",
|
330
|
+
transactionHash: destinationTransaction?.transactionHash ?? "",
|
331
|
+
},
|
332
|
+
source: {
|
333
|
+
amount: originToken
|
334
|
+
? toTokens(originAmount, originToken.decimals).toString()
|
335
|
+
: "",
|
336
|
+
amountWei: originAmount.toString(),
|
337
|
+
token: {
|
338
|
+
tokenAddress: originTokenAddress,
|
339
|
+
chainId: originChainId,
|
340
|
+
decimals: originToken?.decimals ?? 18,
|
341
|
+
name: originToken?.name ?? "",
|
342
|
+
symbol: originToken?.symbol ?? "",
|
343
|
+
priceUSDCents: 0,
|
344
|
+
},
|
345
|
+
amountUSDCents: 0,
|
346
|
+
completedAt: new Date().toISOString(),
|
347
|
+
explorerLink: "",
|
348
|
+
transactionHash: originTransaction?.transactionHash ?? "",
|
349
|
+
},
|
350
|
+
};
|
351
|
+
}
|