thirdweb 5.99.2 → 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414
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 +16 -12
- 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/Routes.js +2 -2
- package/dist/cjs/bridge/Routes.js.map +1 -1
- package/dist/cjs/bridge/Sell.js +17 -13
- 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 +2 -1
- package/dist/cjs/bridge/index.js.map +1 -1
- package/dist/cjs/bridge/types/Token.js +3 -0
- package/dist/cjs/bridge/types/Token.js.map +1 -0
- package/dist/cjs/exports/wallets.js +3 -1
- package/dist/cjs/exports/wallets.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/utils/definitions.js +1 -31
- package/dist/cjs/pay/utils/definitions.js.map +1 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +23 -21
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.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/pay-transactions/useBuyTransactionsToShow.js +0 -135
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.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/ExecutingScreen.js +2 -2
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.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/cjs/wallets/injected/mipdStore.js +12 -0
- package/dist/cjs/wallets/injected/mipdStore.js.map +1 -1
- package/dist/esm/bridge/Buy.js +16 -12
- 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/Routes.js +2 -2
- package/dist/esm/bridge/Routes.js.map +1 -1
- package/dist/esm/bridge/Sell.js +17 -13
- 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 +1 -0
- package/dist/esm/bridge/index.js.map +1 -1
- package/dist/esm/bridge/types/Token.js +2 -0
- package/dist/esm/bridge/types/Token.js.map +1 -0
- package/dist/esm/exports/wallets.js +1 -0
- package/dist/esm/exports/wallets.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/utils/definitions.js +0 -25
- package/dist/esm/pay/utils/definitions.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +23 -21
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.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/pay-transactions/useBuyTransactionsToShow.js +1 -134
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.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/ExecutingScreen.js +2 -2
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.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/esm/wallets/injected/mipdStore.js +11 -0
- package/dist/esm/wallets/injected/mipdStore.js.map +1 -1
- package/dist/types/bridge/Buy.d.ts +10 -8
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Sell.d.ts +12 -10
- 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 +1 -0
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/bridge/types/Route.d.ts +3 -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 +10 -0
- package/dist/types/bridge/types/Token.d.ts.map +1 -0
- package/dist/types/exports/wallets.d.ts +1 -0
- package/dist/types/exports/wallets.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/utils/definitions.d.ts +0 -25
- package/dist/types/pay/utils/definitions.d.ts.map +1 -1
- package/dist/types/react/core/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/pay-transactions/useBuyTransactionsToShow.d.ts +2 -13
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.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/MediaRenderer/MediaRenderer.d.ts +1 -1
- package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.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/dist/types/wallets/injected/mipdStore.d.ts +7 -0
- package/dist/types/wallets/injected/mipdStore.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Buy.ts +18 -12
- package/src/bridge/Chains.ts +2 -2
- package/src/bridge/Routes.ts +2 -2
- package/src/bridge/Sell.ts +19 -13
- 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 +1 -0
- package/src/bridge/types/Route.ts +3 -17
- package/src/bridge/types/Status.ts +15 -1
- package/src/bridge/types/Token.ts +10 -0
- package/src/exports/wallets.ts +1 -0
- package/src/extensions/prebuilts/deploy-modular-core.test.ts +2 -1
- 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/utils/definitions.ts +0 -34
- package/src/react/core/hooks/transaction/useSendTransaction.ts +27 -33
- package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +29 -35
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +2 -181
- 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/ExecutingScreen.tsx +0 -2
- 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/src/wallets/injected/mipdStore.ts +14 -0
- 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/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/esm/bridge/constants.js +0 -2
- package/dist/esm/bridge/constants.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/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/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/src/bridge/constants.ts +0 -1
- 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/dist/cjs/bridge/Buy.js
CHANGED
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.quote = quote;
|
4
4
|
exports.prepare = prepare;
|
5
5
|
const utils_js_1 = require("../chains/utils.js");
|
6
|
+
const domains_js_1 = require("../utils/domains.js");
|
6
7
|
const fetch_js_1 = require("../utils/fetch.js");
|
7
8
|
const json_js_1 = require("../utils/json.js");
|
8
|
-
const constants_js_1 = require("./constants.js");
|
9
9
|
/**
|
10
10
|
* Retrieves a Universal Bridge quote for the provided buy intent. The quote will specify the necessary `originAmount` to receive the desired `destinationAmount`, which is specified with the `buyAmountWei` option.
|
11
11
|
*
|
@@ -104,12 +104,13 @@ async function quote(options) {
|
|
104
104
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, client, maxSteps, } = options;
|
105
105
|
const amount = "buyAmountWei" in options ? options.buyAmountWei : options.amount;
|
106
106
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
107
|
-
const url = new URL(`${
|
107
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/buy/quote`);
|
108
108
|
url.searchParams.set("originChainId", originChainId.toString());
|
109
109
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
110
110
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
111
111
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
112
112
|
url.searchParams.set("buyAmountWei", amount.toString());
|
113
|
+
url.searchParams.set("amount", amount.toString());
|
113
114
|
if (maxSteps) {
|
114
115
|
url.searchParams.set("maxSteps", maxSteps.toString());
|
115
116
|
}
|
@@ -156,7 +157,7 @@ async function quote(options) {
|
|
156
157
|
* This will return a quote that might look like:
|
157
158
|
* ```typescript
|
158
159
|
* {
|
159
|
-
* originAmount:
|
160
|
+
* originAmount: 2000030000n,
|
160
161
|
* destinationAmount: 1000000000000000000n,
|
161
162
|
* blockNumber: 22026509n,
|
162
163
|
* timestamp: 1741730936680,
|
@@ -165,11 +166,11 @@ async function quote(options) {
|
|
165
166
|
* {
|
166
167
|
* originToken: {
|
167
168
|
* chainId: 1,
|
168
|
-
* address: "
|
169
|
-
* symbol: "
|
170
|
-
* name: "
|
171
|
-
* decimals:
|
172
|
-
* priceUsd:
|
169
|
+
* address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
170
|
+
* symbol: "USDC",
|
171
|
+
* name: "USDC",
|
172
|
+
* decimals: 6,
|
173
|
+
* priceUsd: 1,
|
173
174
|
* iconUri: "https://..."
|
174
175
|
* },
|
175
176
|
* destinationToken: {
|
@@ -181,7 +182,7 @@ async function quote(options) {
|
|
181
182
|
* priceUsd: 2000,
|
182
183
|
* iconUri: "https://..."
|
183
184
|
* },
|
184
|
-
* originAmount:
|
185
|
+
* originAmount: 2000030000n,
|
185
186
|
* destinationAmount: 1000000000000000000n,
|
186
187
|
* estimatedExecutionTimeMs: 1000
|
187
188
|
* transactions: [
|
@@ -207,7 +208,7 @@ async function quote(options) {
|
|
207
208
|
* expiration: 1741730936680,
|
208
209
|
* intent: {
|
209
210
|
* originChainId: 1,
|
210
|
-
* originTokenAddress: "
|
211
|
+
* originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
211
212
|
* destinationChainId: 10,
|
212
213
|
* destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
213
214
|
* amount: 1000000000000000000n
|
@@ -277,14 +278,15 @@ async function quote(options) {
|
|
277
278
|
async function prepare(options) {
|
278
279
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, sender, receiver, client, amount, purchaseData, maxSteps, } = options;
|
279
280
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
280
|
-
const url = new URL(`${
|
281
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/buy/prepare`);
|
281
282
|
const response = await clientFetch(url.toString(), {
|
282
283
|
method: "POST",
|
283
284
|
headers: {
|
284
285
|
"Content-Type": "application/json",
|
285
286
|
},
|
286
287
|
body: (0, json_js_1.stringify)({
|
287
|
-
buyAmountWei: amount.toString(),
|
288
|
+
buyAmountWei: amount.toString(), // legacy
|
289
|
+
amount: amount.toString(),
|
288
290
|
originChainId: originChainId.toString(),
|
289
291
|
originTokenAddress,
|
290
292
|
destinationChainId: destinationChainId.toString(),
|
@@ -321,6 +323,8 @@ async function prepare(options) {
|
|
321
323
|
destinationChainId,
|
322
324
|
destinationTokenAddress,
|
323
325
|
amount,
|
326
|
+
sender,
|
327
|
+
receiver,
|
324
328
|
},
|
325
329
|
};
|
326
330
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Buy.js","sourceRoot":"","sources":["../../../src/bridge/Buy.ts"],"names":[],"mappings":";;AAsGA,
|
1
|
+
{"version":3,"file":"Buy.js","sourceRoot":"","sources":["../../../src/bridge/Buy.ts"],"names":[],"mappings":";;AAsGA,sBAiDC;AAyKD,0BAsEC;AArYD,iDAAiD;AAEjD,oDAAyD;AACzD,gDAAmD;AACnD,8CAA6C;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACI,KAAK,UAAU,KAAK,CAAC,OAAsB;IAChD,MAAM,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,QAAQ,GACT,GAAG,OAAO,CAAC;IACZ,MAAM,MAAM,GACV,cAAc,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAEpE,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAA,+BAAkB,EAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IACpE,GAAG,CAAC,YAAY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N,MAAM;YACN,QAAQ;SACT;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.chains = chains;
|
4
|
+
const domains_js_1 = require("../utils/domains.js");
|
4
5
|
const fetch_js_1 = require("../utils/fetch.js");
|
5
|
-
const constants_js_1 = require("./constants.js");
|
6
6
|
/**
|
7
7
|
* Retrieves supported Universal Bridge chains.
|
8
8
|
*
|
@@ -53,7 +53,7 @@ const constants_js_1 = require("./constants.js");
|
|
53
53
|
async function chains(options) {
|
54
54
|
const { client } = options;
|
55
55
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
56
|
-
const url = new URL(`${
|
56
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/chains`);
|
57
57
|
const response = await clientFetch(url.toString());
|
58
58
|
if (!response.ok) {
|
59
59
|
const errorJson = await response.json();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Chains.js","sourceRoot":"","sources":["../../../src/bridge/Chains.ts"],"names":[],"mappings":";;AAoDA,wBAcC;AAjED,
|
1
|
+
{"version":3,"file":"Chains.js","sourceRoot":"","sources":["../../../src/bridge/Chains.ts"],"names":[],"mappings":";;AAoDA,wBAcC;AAjED,oDAAyD;AACzD,gDAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACI,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAA,+BAAkB,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAsB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.routes = routes;
|
4
|
+
const domains_js_1 = require("../utils/domains.js");
|
4
5
|
const fetch_js_1 = require("../utils/fetch.js");
|
5
|
-
const constants_js_1 = require("./constants.js");
|
6
6
|
/**
|
7
7
|
* Retrieves supported Universal Bridge routes based on the provided filters.
|
8
8
|
*
|
@@ -121,7 +121,7 @@ const constants_js_1 = require("./constants.js");
|
|
121
121
|
async function routes(options) {
|
122
122
|
const { client, originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, maxSteps, sortBy, limit, offset, } = options;
|
123
123
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
124
|
-
const url = new URL(`${
|
124
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/routes`);
|
125
125
|
if (originChainId) {
|
126
126
|
url.searchParams.set("originChainId", originChainId.toString());
|
127
127
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../../src/bridge/Routes.ts"],"names":[],"mappings":";;AAyHA,wBAgDC;AAvKD,
|
1
|
+
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../../src/bridge/Routes.ts"],"names":[],"mappings":";;AAyHA,wBAgDC;AAvKD,oDAAyD;AACzD,gDAAmD;AAGnD;;;;;;;;;;;;;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CAAC,CAAC;IAClD,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAsB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cjs/bridge/Sell.js
CHANGED
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.quote = quote;
|
4
4
|
exports.prepare = prepare;
|
5
5
|
const utils_js_1 = require("../chains/utils.js");
|
6
|
+
const domains_js_1 = require("../utils/domains.js");
|
6
7
|
const fetch_js_1 = require("../utils/fetch.js");
|
7
8
|
const json_js_1 = require("../utils/json.js");
|
8
|
-
const constants_js_1 = require("./constants.js");
|
9
9
|
/**
|
10
10
|
* 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.
|
11
11
|
*
|
@@ -103,12 +103,13 @@ const constants_js_1 = require("./constants.js");
|
|
103
103
|
async function quote(options) {
|
104
104
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, amount, client, maxSteps, } = options;
|
105
105
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
106
|
-
const url = new URL(`${
|
106
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/sell/quote`);
|
107
107
|
url.searchParams.set("originChainId", originChainId.toString());
|
108
108
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
109
109
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
110
110
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
111
111
|
url.searchParams.set("sellAmountWei", amount.toString());
|
112
|
+
url.searchParams.set("amount", amount.toString());
|
112
113
|
if (typeof maxSteps !== "undefined") {
|
113
114
|
url.searchParams.set("maxSteps", maxSteps.toString());
|
114
115
|
}
|
@@ -154,7 +155,7 @@ async function quote(options) {
|
|
154
155
|
* This will return a quote that might look like:
|
155
156
|
* ```typescript
|
156
157
|
* {
|
157
|
-
* originAmount:
|
158
|
+
* originAmount: 2000000000n,
|
158
159
|
* destinationAmount: 9980000000000000000n,
|
159
160
|
* blockNumber: 22026509n,
|
160
161
|
* timestamp: 1741730936680,
|
@@ -163,11 +164,11 @@ async function quote(options) {
|
|
163
164
|
* {
|
164
165
|
* originToken: {
|
165
166
|
* chainId: 1,
|
166
|
-
* address: "
|
167
|
-
* symbol: "
|
168
|
-
* name: "
|
169
|
-
* decimals:
|
170
|
-
* priceUsd:
|
167
|
+
* address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
168
|
+
* symbol: "USDC",
|
169
|
+
* name: "USDC",
|
170
|
+
* decimals: 6,
|
171
|
+
* priceUsd: 1,
|
171
172
|
* iconUri: "https://..."
|
172
173
|
* },
|
173
174
|
* destinationToken: {
|
@@ -179,7 +180,7 @@ async function quote(options) {
|
|
179
180
|
* priceUsd: 2000,
|
180
181
|
* iconUri: "https://..."
|
181
182
|
* },
|
182
|
-
* originAmount:
|
183
|
+
* originAmount: 2000000000n,
|
183
184
|
* destinationAmount: 9980000000000000000n,
|
184
185
|
* estimatedExecutionTimeMs: 1000
|
185
186
|
* }
|
@@ -205,10 +206,10 @@ async function quote(options) {
|
|
205
206
|
* expiration: 1741730936680,
|
206
207
|
* intent: {
|
207
208
|
* originChainId: 1,
|
208
|
-
* originTokenAddress:
|
209
|
+
* originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
209
210
|
* destinationChainId: 10,
|
210
|
-
* destinationTokenAddress:
|
211
|
-
* amount:
|
211
|
+
* destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
212
|
+
* amount: 2000000000n
|
212
213
|
* }
|
213
214
|
* }
|
214
215
|
* ```
|
@@ -275,7 +276,7 @@ async function quote(options) {
|
|
275
276
|
async function prepare(options) {
|
276
277
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, amount, sender, receiver, client, purchaseData, maxSteps, } = options;
|
277
278
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
278
|
-
const url = new URL(`${
|
279
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/sell/prepare`);
|
279
280
|
const response = await clientFetch(url.toString(), {
|
280
281
|
method: "POST",
|
281
282
|
headers: {
|
@@ -283,6 +284,7 @@ async function prepare(options) {
|
|
283
284
|
},
|
284
285
|
body: (0, json_js_1.stringify)({
|
285
286
|
sellAmountWei: amount.toString(),
|
287
|
+
amount: amount.toString(),
|
286
288
|
originChainId: originChainId.toString(),
|
287
289
|
originTokenAddress,
|
288
290
|
destinationChainId: destinationChainId.toString(),
|
@@ -320,6 +322,8 @@ async function prepare(options) {
|
|
320
322
|
destinationChainId,
|
321
323
|
destinationTokenAddress,
|
322
324
|
amount,
|
325
|
+
sender,
|
326
|
+
receiver,
|
323
327
|
purchaseData,
|
324
328
|
},
|
325
329
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Sell.js","sourceRoot":"","sources":["../../../src/bridge/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CAAC,IAAI,CAAC,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,IAAA,sBAAW,EAAC,WAAW,CAAC,OAAO,CAAC;aACxC,CAAC,CAAC;SACJ,CAAC,CAAC;QACH,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN,aAAa;YACb,kBAAkB;YAClB,kBAAkB;YAClB,uBAAuB;YACvB,MAAM;YACN,MAAM;YACN,QAAQ;YACR,YAAY;SACb;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.status = status;
|
4
|
+
const domains_js_1 = require("../utils/domains.js");
|
4
5
|
const fetch_js_1 = require("../utils/fetch.js");
|
5
|
-
const constants_js_1 = require("./constants.js");
|
6
6
|
/**
|
7
7
|
* 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.
|
8
8
|
*
|
@@ -105,7 +105,7 @@ async function status(options) {
|
|
105
105
|
const { transactionHash, client } = options;
|
106
106
|
const chainId = "chainId" in options ? options.chainId : options.chain.id;
|
107
107
|
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
108
|
-
const url = new URL(`${
|
108
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/status`);
|
109
109
|
url.searchParams.set("transactionHash", transactionHash);
|
110
110
|
url.searchParams.set("chainId", chainId.toString());
|
111
111
|
const response = await clientFetch(url.toString());
|
@@ -117,6 +117,7 @@ async function status(options) {
|
|
117
117
|
if (data.status === "FAILED") {
|
118
118
|
return {
|
119
119
|
status: "FAILED",
|
120
|
+
paymentId: data.paymentId,
|
120
121
|
transactions: data.transactions,
|
121
122
|
};
|
122
123
|
}
|
@@ -129,11 +130,18 @@ async function status(options) {
|
|
129
130
|
originTokenAddress: data.originTokenAddress,
|
130
131
|
destinationTokenAddress: data.destinationTokenAddress,
|
131
132
|
transactions: data.transactions,
|
133
|
+
originToken: data.originToken,
|
134
|
+
destinationToken: data.destinationToken,
|
135
|
+
sender: data.sender,
|
136
|
+
receiver: data.receiver,
|
137
|
+
paymentId: data.paymentId,
|
138
|
+
purchaseData: data.purchaseData,
|
132
139
|
};
|
133
140
|
}
|
134
141
|
if (data.status === "NOT_FOUND") {
|
135
142
|
return {
|
136
143
|
status: "NOT_FOUND",
|
144
|
+
paymentId: data.paymentId,
|
137
145
|
transactions: [],
|
138
146
|
};
|
139
147
|
}
|
@@ -146,6 +154,11 @@ async function status(options) {
|
|
146
154
|
originTokenAddress: data.originTokenAddress,
|
147
155
|
destinationTokenAddress: data.destinationTokenAddress,
|
148
156
|
transactions: data.transactions,
|
157
|
+
originToken: data.originToken,
|
158
|
+
destinationToken: data.destinationToken,
|
159
|
+
sender: data.sender,
|
160
|
+
receiver: data.receiver,
|
161
|
+
paymentId: data.paymentId,
|
149
162
|
purchaseData: data.purchaseData,
|
150
163
|
};
|
151
164
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/bridge/Status.ts"],"names":[],"mappings":";;AAyGA,
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","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Y;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,229 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.prepare = prepare;
|
4
|
+
const utils_js_1 = require("../chains/utils.js");
|
5
|
+
const domains_js_1 = require("../utils/domains.js");
|
6
|
+
const fetch_js_1 = require("../utils/fetch.js");
|
7
|
+
const json_js_1 = require("../utils/json.js");
|
8
|
+
/**
|
9
|
+
* Prepares a **finalized** Universal Bridge quote for the provided transfer request with transaction data.
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* ```typescript
|
13
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
14
|
+
*
|
15
|
+
* const quote = await Bridge.Transfer.prepare({
|
16
|
+
* chainId: 1,
|
17
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
18
|
+
* amount: toWei("0.01"),
|
19
|
+
* sender: "0x...",
|
20
|
+
* receiver: "0x...",
|
21
|
+
* client: thirdwebClient,
|
22
|
+
* });
|
23
|
+
* ```
|
24
|
+
*
|
25
|
+
* This will return a quote that might look like:
|
26
|
+
* ```typescript
|
27
|
+
* {
|
28
|
+
* originAmount: 10000026098875381n,
|
29
|
+
* destinationAmount: 10000000000000000n,
|
30
|
+
* blockNumber: 22026509n,
|
31
|
+
* timestamp: 1741730936680,
|
32
|
+
* estimatedExecutionTimeMs: 1000
|
33
|
+
* steps: [
|
34
|
+
* {
|
35
|
+
* originToken: {
|
36
|
+
* chainId: 1,
|
37
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
38
|
+
* symbol: "ETH",
|
39
|
+
* name: "Ethereum",
|
40
|
+
* decimals: 18,
|
41
|
+
* priceUsd: 2000,
|
42
|
+
* iconUri: "https://..."
|
43
|
+
* },
|
44
|
+
* destinationToken: {
|
45
|
+
* chainId: 1,
|
46
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
47
|
+
* symbol: "ETH",
|
48
|
+
* name: "Ethereum",
|
49
|
+
* decimals: 18,
|
50
|
+
* priceUsd: 2000,
|
51
|
+
* iconUri: "https://..."
|
52
|
+
* },
|
53
|
+
* originAmount: 10000026098875381n,
|
54
|
+
* destinationAmount: 10000000000000000n,
|
55
|
+
* estimatedExecutionTimeMs: 1000
|
56
|
+
* transactions: [
|
57
|
+
* {
|
58
|
+
* action: "approval",
|
59
|
+
* id: "0x",
|
60
|
+
* to: "0x...",
|
61
|
+
* data: "0x...",
|
62
|
+
* chainId: 1,
|
63
|
+
* type: "eip1559"
|
64
|
+
* },
|
65
|
+
* {
|
66
|
+
* action: "transfer",
|
67
|
+
* to: "0x...",
|
68
|
+
* value: 10000026098875381n,
|
69
|
+
* data: "0x...",
|
70
|
+
* chainId: 1,
|
71
|
+
* type: "eip1559"
|
72
|
+
* }
|
73
|
+
* ]
|
74
|
+
* }
|
75
|
+
* ],
|
76
|
+
* expiration: 1741730936680,
|
77
|
+
* intent: {
|
78
|
+
* chainId: 1,
|
79
|
+
* tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
80
|
+
* amount: 10000000000000000n,
|
81
|
+
* sender: "0x...",
|
82
|
+
* receiver: "0x..."
|
83
|
+
* }
|
84
|
+
* }
|
85
|
+
* ```
|
86
|
+
*
|
87
|
+
* ## Sending the transactions
|
88
|
+
* 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:
|
89
|
+
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
|
90
|
+
* - 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.
|
91
|
+
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
92
|
+
*
|
93
|
+
* 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.
|
94
|
+
*
|
95
|
+
* You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
|
96
|
+
*
|
97
|
+
* You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
|
98
|
+
*
|
99
|
+
* ```ts
|
100
|
+
* const quote = await Bridge.Transfer.prepare({
|
101
|
+
* chainId: 1,
|
102
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
103
|
+
* amount: toWei("0.01"),
|
104
|
+
* sender: "0x...",
|
105
|
+
* receiver: "0x...",
|
106
|
+
* purchaseData: {
|
107
|
+
* reference: "payment-123",
|
108
|
+
* metadata: {
|
109
|
+
* note: "Transfer to Alice"
|
110
|
+
* }
|
111
|
+
* },
|
112
|
+
* client: thirdwebClient,
|
113
|
+
* });
|
114
|
+
* ```
|
115
|
+
*
|
116
|
+
* ## Fees
|
117
|
+
* 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.
|
118
|
+
*
|
119
|
+
* For example, if you were to request a transfer with `feePayer` set to `receiver`:
|
120
|
+
* ```typescript
|
121
|
+
* const quote = await Bridge.Transfer.prepare({
|
122
|
+
* chainId: 1,
|
123
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
124
|
+
* amount: 100_000_000n, // 100 USDC
|
125
|
+
* sender: "0x...",
|
126
|
+
* receiver: "0x...",
|
127
|
+
* feePayer: "receiver",
|
128
|
+
* client: thirdwebClient,
|
129
|
+
* });
|
130
|
+
* ```
|
131
|
+
*
|
132
|
+
* The returned quote might look like:
|
133
|
+
* ```typescript
|
134
|
+
* {
|
135
|
+
* originAmount: 100_000_000n, // 100 USDC
|
136
|
+
* destinationAmount: 99_970_000n, // 99.97 USDC
|
137
|
+
* ...
|
138
|
+
* }
|
139
|
+
* ```
|
140
|
+
*
|
141
|
+
* If you were to request a transfer with `feePayer` set to `sender`:
|
142
|
+
* ```typescript
|
143
|
+
* const quote = await Bridge.Transfer.prepare({
|
144
|
+
* chainId: 1,
|
145
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
146
|
+
* amount: 100_000_000n, // 100 USDC
|
147
|
+
* sender: "0x...",
|
148
|
+
* receiver: "0x...",
|
149
|
+
* feePayer: "sender",
|
150
|
+
* client: thirdwebClient,
|
151
|
+
* });
|
152
|
+
* ```
|
153
|
+
*
|
154
|
+
* The returned quote might look like:
|
155
|
+
* ```typescript
|
156
|
+
* {
|
157
|
+
* originAmount: 100_030_000n, // 100.03 USDC
|
158
|
+
* destinationAmount: 100_000_000n, // 100 USDC
|
159
|
+
* ...
|
160
|
+
* }
|
161
|
+
* ```
|
162
|
+
*
|
163
|
+
* @param options - The options for the quote.
|
164
|
+
* @param options.chainId - The chain ID of the token.
|
165
|
+
* @param options.tokenAddress - The address of the token.
|
166
|
+
* @param options.amount - The amount of the token to transfer.
|
167
|
+
* @param options.sender - The address of the sender.
|
168
|
+
* @param options.receiver - The address of the recipient.
|
169
|
+
* @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
|
170
|
+
* @param options.client - Your thirdweb client.
|
171
|
+
* @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".
|
172
|
+
*
|
173
|
+
* @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
|
174
|
+
*
|
175
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
176
|
+
* @bridge Transfer
|
177
|
+
* @beta
|
178
|
+
*/
|
179
|
+
async function prepare(options) {
|
180
|
+
const { chainId, tokenAddress, sender, receiver, client, amount, purchaseData, feePayer, } = options;
|
181
|
+
const clientFetch = (0, fetch_js_1.getClientFetch)(client);
|
182
|
+
const url = new URL(`${(0, domains_js_1.getThirdwebBaseUrl)("bridge")}/v1/transfer/prepare`);
|
183
|
+
const response = await clientFetch(url.toString(), {
|
184
|
+
method: "POST",
|
185
|
+
headers: {
|
186
|
+
"Content-Type": "application/json",
|
187
|
+
},
|
188
|
+
body: (0, json_js_1.stringify)({
|
189
|
+
transferAmountWei: amount.toString(), // legacy
|
190
|
+
amount: amount.toString(),
|
191
|
+
chainId: chainId.toString(),
|
192
|
+
tokenAddress,
|
193
|
+
sender,
|
194
|
+
receiver,
|
195
|
+
purchaseData,
|
196
|
+
feePayer,
|
197
|
+
}),
|
198
|
+
});
|
199
|
+
if (!response.ok) {
|
200
|
+
const errorJson = await response.json();
|
201
|
+
throw new Error(`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`);
|
202
|
+
}
|
203
|
+
const { data } = await response.json();
|
204
|
+
return {
|
205
|
+
originAmount: BigInt(data.originAmount),
|
206
|
+
destinationAmount: BigInt(data.destinationAmount),
|
207
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
208
|
+
timestamp: data.timestamp,
|
209
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
210
|
+
steps: data.steps.map((step) => ({
|
211
|
+
...step,
|
212
|
+
transactions: step.transactions.map((transaction) => ({
|
213
|
+
...transaction,
|
214
|
+
value: transaction.value ? BigInt(transaction.value) : undefined,
|
215
|
+
client,
|
216
|
+
chain: (0, utils_js_1.defineChain)(transaction.chainId),
|
217
|
+
})),
|
218
|
+
})),
|
219
|
+
intent: {
|
220
|
+
chainId,
|
221
|
+
tokenAddress,
|
222
|
+
amount,
|
223
|
+
sender,
|
224
|
+
receiver,
|
225
|
+
feePayer,
|
226
|
+
},
|
227
|
+
};
|
228
|
+
}
|
229
|
+
//# sourceMappingURL=Transfer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Transfer.js","sourceRoot":"","sources":["../../../src/bridge/Transfer.ts"],"names":[],"mappings":";;AAmLA,0BAiEC;AAnPD,iDAAiD;AAEjD,oDAAyD;AACzD,gDAAmD;AACnD,8CAA6C;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0KG;AACI,KAAK,UAAU,OAAO,CAC3B,OAAwB;IAExB,MAAM,EACJ,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,GACT,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAA,+BAAkB,EAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IAE3E,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QACjD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAA,mBAAS,EAAC;YACd,iBAAiB,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS;YAC/C,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;YACzB,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;YAC3B,YAAY;YACZ,MAAM;YACN,QAAQ;YACR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"}
|
package/dist/cjs/bridge/index.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.chains = exports.routes = exports.status = exports.Sell = exports.Buy = void 0;
|
3
|
+
exports.chains = exports.routes = exports.status = exports.Transfer = exports.Sell = exports.Buy = void 0;
|
4
4
|
exports.Buy = require("./Buy.js");
|
5
5
|
exports.Sell = require("./Sell.js");
|
6
|
+
exports.Transfer = require("./Transfer.js");
|
6
7
|
var Status_js_1 = require("./Status.js");
|
7
8
|
Object.defineProperty(exports, "status", { enumerable: true, get: function () { return Status_js_1.status; } });
|
8
9
|
var Routes_js_1 = require("./Routes.js");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":";;;AAAA,kCAAgC;AAChC,oCAAkC;AAClC,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":";;;AAAA,kCAAgC;AAChC,oCAAkC;AAClC,4CAA0C;AAC1C,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../../src/bridge/types/Token.ts"],"names":[],"mappings":""}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
// --- KEEEP IN SYNC with exports/wallets.native.ts ---
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.deploySmartAccount = exports.autoConnect = exports.injectedProvider = exports.EIP1193 = exports.DefaultWalletConnectRequestHandlers = exports.getActiveWalletConnectSessions = exports.disconnectWalletConnectSession = exports.createWalletConnectSession = exports.createWalletConnectClient = exports.createWalletAdapter = exports.getWalletInfo = exports.getAllWalletsList = exports.getUser = exports.unlinkProfile = exports.linkProfile = exports.getProfiles = exports.getUserPhoneNumber = exports.getUserEmail = exports.authenticateWithRedirect = exports.authenticate = exports.preAuthenticate = exports.randomPrivateKey = exports.privateKeyAccount = exports.privateKeyToAccount = exports.generateAccount = exports.getWalletBalance = exports.smartWallet = exports.ecosystemWallet = exports.embeddedWallet = exports.inAppWallet = exports.walletConnect = exports.createWallet = void 0;
|
4
|
+
exports.deploySmartAccount = exports.autoConnect = exports.getInstalledWallets = exports.injectedProvider = exports.EIP1193 = exports.DefaultWalletConnectRequestHandlers = exports.getActiveWalletConnectSessions = exports.disconnectWalletConnectSession = exports.createWalletConnectSession = exports.createWalletConnectClient = exports.createWalletAdapter = exports.getWalletInfo = exports.getAllWalletsList = exports.getUser = exports.unlinkProfile = exports.linkProfile = exports.getProfiles = exports.getUserPhoneNumber = exports.getUserEmail = exports.authenticateWithRedirect = exports.authenticate = exports.preAuthenticate = exports.randomPrivateKey = exports.privateKeyAccount = exports.privateKeyToAccount = exports.generateAccount = exports.getWalletBalance = exports.smartWallet = exports.ecosystemWallet = exports.embeddedWallet = exports.inAppWallet = exports.walletConnect = exports.createWallet = void 0;
|
5
5
|
var create_wallet_js_1 = require("../wallets/create-wallet.js");
|
6
6
|
Object.defineProperty(exports, "createWallet", { enumerable: true, get: function () { return create_wallet_js_1.createWallet; } });
|
7
7
|
Object.defineProperty(exports, "walletConnect", { enumerable: true, get: function () { return create_wallet_js_1.walletConnect; } });
|
@@ -61,6 +61,8 @@ exports.EIP1193 = require("../adapters/eip1193/index.js");
|
|
61
61
|
// injected
|
62
62
|
var mipdStore_js_1 = require("../wallets/injected/mipdStore.js");
|
63
63
|
Object.defineProperty(exports, "injectedProvider", { enumerable: true, get: function () { return mipdStore_js_1.injectedProvider; } });
|
64
|
+
var mipdStore_js_2 = require("../wallets/injected/mipdStore.js");
|
65
|
+
Object.defineProperty(exports, "getInstalledWallets", { enumerable: true, get: function () { return mipdStore_js_2.getInstalledWallets; } });
|
64
66
|
var autoConnect_js_1 = require("../wallets/connection/autoConnect.js");
|
65
67
|
Object.defineProperty(exports, "autoConnect", { enumerable: true, get: function () { return autoConnect_js_1.autoConnect; } });
|
66
68
|
var signing_js_1 = require("../wallets/smart/lib/signing.js");
|