thirdweb 5.105.4 → 5.105.6-nightly-9f88b5c2beedd51730dbe4f2dfdd15e6bcb6e967-20250703000433
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.map +1 -1
- package/dist/cjs/bridge/Onramp.js.map +1 -1
- package/dist/cjs/bridge/OnrampStatus.js.map +1 -1
- package/dist/cjs/bridge/Sell.js.map +1 -1
- package/dist/cjs/bridge/Transfer.js.map +1 -1
- package/dist/cjs/chains/chain-definitions/core-mainnet.js +23 -0
- package/dist/cjs/chains/chain-definitions/core-mainnet.js.map +1 -0
- package/dist/cjs/chains/chain-definitions/core-testnet.js +24 -0
- package/dist/cjs/chains/chain-definitions/core-testnet.js.map +1 -0
- package/dist/cjs/chains/chain-definitions/somniaTestnet.js +21 -0
- package/dist/cjs/chains/chain-definitions/somniaTestnet.js.map +1 -0
- package/dist/cjs/exports/chains.js +8 -2
- package/dist/cjs/exports/chains.js.map +1 -1
- package/dist/cjs/extensions/erc7702/account/createSessionKey.js +1 -1
- package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getStatus.js +1 -1
- package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getStatus.js +1 -1
- package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/cjs/pay/types.js +3 -0
- package/dist/cjs/pay/types.js.map +1 -0
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/FundWallet.js +2 -1
- package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/common/TokenAndChain.js +2 -2
- package/dist/cjs/react/web/ui/Bridge/common/TokenAndChain.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +3 -3
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/utils/formatNumber.js +37 -0
- package/dist/cjs/utils/formatNumber.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.map +1 -1
- package/dist/esm/bridge/Onramp.js.map +1 -1
- package/dist/esm/bridge/OnrampStatus.js.map +1 -1
- package/dist/esm/bridge/Sell.js.map +1 -1
- package/dist/esm/bridge/Transfer.js.map +1 -1
- package/dist/esm/chains/chain-definitions/core-mainnet.js +20 -0
- package/dist/esm/chains/chain-definitions/core-mainnet.js.map +1 -0
- package/dist/esm/chains/chain-definitions/core-testnet.js +21 -0
- package/dist/esm/chains/chain-definitions/core-testnet.js.map +1 -0
- package/dist/esm/chains/chain-definitions/somniaTestnet.js +18 -0
- package/dist/esm/chains/chain-definitions/somniaTestnet.js.map +1 -0
- package/dist/esm/exports/chains.js +3 -0
- package/dist/esm/exports/chains.js.map +1 -1
- package/dist/esm/extensions/erc7702/account/createSessionKey.js +1 -1
- package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getStatus.js +1 -1
- package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getStatus.js +1 -1
- package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
- package/dist/esm/pay/types.js +2 -0
- package/dist/esm/pay/types.js.map +1 -0
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/FundWallet.js +2 -1
- package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/common/TokenAndChain.js +2 -2
- package/dist/esm/react/web/ui/Bridge/common/TokenAndChain.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +3 -3
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/utils/formatNumber.js +36 -0
- package/dist/esm/utils/formatNumber.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 +3 -2
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Onramp.d.ts +3 -2
- package/dist/types/bridge/Onramp.d.ts.map +1 -1
- package/dist/types/bridge/OnrampStatus.d.ts +5 -4
- package/dist/types/bridge/OnrampStatus.d.ts.map +1 -1
- package/dist/types/bridge/Sell.d.ts +3 -2
- package/dist/types/bridge/Sell.d.ts.map +1 -1
- package/dist/types/bridge/Transfer.d.ts +3 -2
- package/dist/types/bridge/Transfer.d.ts.map +1 -1
- package/dist/types/bridge/types/Status.d.ts +4 -3
- package/dist/types/bridge/types/Status.d.ts.map +1 -1
- package/dist/types/chains/chain-definitions/core-mainnet.d.ts +7 -0
- package/dist/types/chains/chain-definitions/core-mainnet.d.ts.map +1 -0
- package/dist/types/chains/chain-definitions/core-testnet.d.ts +7 -0
- package/dist/types/chains/chain-definitions/core-testnet.d.ts.map +1 -0
- package/dist/types/chains/chain-definitions/somniaTestnet.d.ts +7 -0
- package/dist/types/chains/chain-definitions/somniaTestnet.d.ts.map +1 -0
- package/dist/types/exports/chains.d.ts +3 -0
- package/dist/types/exports/chains.d.ts.map +1 -1
- package/dist/types/extensions/erc7702/account/createSessionKey.d.ts +1 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts +2 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts +2 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts +2 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getQuote.d.ts +2 -1
- package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getStatus.d.ts +2 -1
- package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
- package/dist/types/pay/types.d.ts +2 -0
- package/dist/types/pay/types.d.ts.map +1 -0
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +2 -1
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +2 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts +2 -1
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts +2 -1
- package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts +2 -1
- package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts +2 -1
- package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts +2 -1
- package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/DirectPayment.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/FundWallet.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts.map +1 -1
- package/dist/types/utils/formatNumber.d.ts +5 -0
- package/dist/types/utils/formatNumber.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 +1 -1
- package/src/bridge/Buy.ts +3 -2
- package/src/bridge/Onramp.ts +4 -3
- package/src/bridge/OnrampStatus.ts +5 -4
- package/src/bridge/Sell.ts +3 -2
- package/src/bridge/Transfer.ts +3 -2
- package/src/bridge/types/Status.ts +4 -3
- package/src/chains/chain-definitions/core-mainnet.ts +20 -0
- package/src/chains/chain-definitions/core-testnet.ts +21 -0
- package/src/chains/chain-definitions/somniaTestnet.ts +18 -0
- package/src/exports/chains.ts +4 -0
- package/src/extensions/erc7702/account/createSessionKey.ts +1 -1
- package/src/pay/buyWithCrypto/getQuote.ts +2 -1
- package/src/pay/buyWithCrypto/getStatus.ts +7 -6
- package/src/pay/buyWithCrypto/getTransfer.ts +2 -1
- package/src/pay/buyWithFiat/getQuote.ts +2 -1
- package/src/pay/buyWithFiat/getStatus.ts +4 -3
- package/src/pay/types.ts +1 -0
- package/src/react/core/hooks/connection/ConnectButtonProps.ts +2 -1
- package/src/react/core/hooks/transaction/useSendTransaction.ts +2 -1
- package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +2 -1
- package/src/react/web/ui/Bridge/BuyWidget.tsx +2 -1
- package/src/react/web/ui/Bridge/CheckoutWidget.tsx +2 -1
- package/src/react/web/ui/Bridge/FundWallet.tsx +4 -3
- package/src/react/web/ui/Bridge/QuoteLoader.tsx +3 -2
- package/src/react/web/ui/Bridge/TransactionWidget.tsx +2 -1
- package/src/react/web/ui/Bridge/common/TokenAndChain.tsx +2 -2
- package/src/react/web/ui/PayEmbed.tsx +3 -0
- package/src/utils/format-number.test.ts +50 -1
- package/src/utils/formatNumber.ts +40 -0
- package/src/version.ts +1 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { Hex as ox__Hex } from "ox";
|
2
2
|
import type { ThirdwebClient } from "../client/client.js";
|
3
|
+
import type { PurchaseData } from "../pay/types.js";
|
3
4
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
4
5
|
import { getClientFetch } from "../utils/fetch.js";
|
5
6
|
import { ApiError } from "./types/Errors.js";
|
@@ -108,7 +109,7 @@ export declare namespace status {
|
|
108
109
|
chainId: number;
|
109
110
|
transactionHash: ox__Hex.Hex;
|
110
111
|
}>;
|
111
|
-
purchaseData?:
|
112
|
+
purchaseData?: PurchaseData;
|
112
113
|
}
|
113
114
|
| {
|
114
115
|
status: "PENDING";
|
@@ -116,7 +117,7 @@ export declare namespace status {
|
|
116
117
|
chainId: number;
|
117
118
|
transactionHash: ox__Hex.Hex;
|
118
119
|
}>;
|
119
|
-
purchaseData?:
|
120
|
+
purchaseData?: PurchaseData;
|
120
121
|
}
|
121
122
|
| {
|
122
123
|
status: "CREATED";
|
@@ -124,7 +125,7 @@ export declare namespace status {
|
|
124
125
|
chainId: number;
|
125
126
|
transactionHash: ox__Hex.Hex;
|
126
127
|
}>;
|
127
|
-
purchaseData?:
|
128
|
+
purchaseData?: PurchaseData;
|
128
129
|
}
|
129
130
|
| {
|
130
131
|
status: "FAILED";
|
@@ -132,6 +133,6 @@ export declare namespace status {
|
|
132
133
|
chainId: number;
|
133
134
|
transactionHash: ox__Hex.Hex;
|
134
135
|
}>;
|
135
|
-
purchaseData?:
|
136
|
+
purchaseData?: PurchaseData;
|
136
137
|
};
|
137
138
|
}
|
package/src/bridge/Sell.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Address as ox__Address } from "ox";
|
2
2
|
import { defineChain } from "../chains/utils.js";
|
3
3
|
import type { ThirdwebClient } from "../client/client.js";
|
4
|
+
import type { PurchaseData } from "../pay/types.js";
|
4
5
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
5
6
|
import { getClientFetch } from "../utils/fetch.js";
|
6
7
|
import { stringify } from "../utils/json.js";
|
@@ -402,7 +403,7 @@ export declare namespace prepare {
|
|
402
403
|
sender: ox__Address.Address;
|
403
404
|
receiver: ox__Address.Address;
|
404
405
|
client: ThirdwebClient;
|
405
|
-
purchaseData?:
|
406
|
+
purchaseData?: PurchaseData;
|
406
407
|
maxSteps?: number;
|
407
408
|
/**
|
408
409
|
* @hidden
|
@@ -419,7 +420,7 @@ export declare namespace prepare {
|
|
419
420
|
amount: bigint;
|
420
421
|
sender: ox__Address.Address;
|
421
422
|
receiver: ox__Address.Address;
|
422
|
-
purchaseData?:
|
423
|
+
purchaseData?: PurchaseData;
|
423
424
|
};
|
424
425
|
};
|
425
426
|
}
|
package/src/bridge/Transfer.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Address as ox__Address } from "ox";
|
2
2
|
import { defineChain } from "../chains/utils.js";
|
3
3
|
import type { ThirdwebClient } from "../client/client.js";
|
4
|
+
import type { PurchaseData } from "../pay/types.js";
|
4
5
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
5
6
|
import { getClientFetch } from "../utils/fetch.js";
|
6
7
|
import { stringify } from "../utils/json.js";
|
@@ -258,7 +259,7 @@ export declare namespace prepare {
|
|
258
259
|
receiver: ox__Address.Address;
|
259
260
|
amount: bigint;
|
260
261
|
client: ThirdwebClient;
|
261
|
-
purchaseData?:
|
262
|
+
purchaseData?: PurchaseData;
|
262
263
|
feePayer?: "sender" | "receiver";
|
263
264
|
/**
|
264
265
|
* @hidden
|
@@ -273,7 +274,7 @@ export declare namespace prepare {
|
|
273
274
|
amount: bigint;
|
274
275
|
sender: ox__Address.Address;
|
275
276
|
receiver: ox__Address.Address;
|
276
|
-
purchaseData?:
|
277
|
+
purchaseData?: PurchaseData;
|
277
278
|
feePayer?: "sender" | "receiver";
|
278
279
|
};
|
279
280
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Address as ox__Address, Hex as ox__Hex } from "ox";
|
2
|
+
import type { PurchaseData } from "../../pay/types.js";
|
2
3
|
import type { Token } from "./Token.js";
|
3
4
|
export type Status =
|
4
5
|
| {
|
@@ -18,7 +19,7 @@ export type Status =
|
|
18
19
|
chainId: number;
|
19
20
|
transactionHash: ox__Hex.Hex;
|
20
21
|
}>;
|
21
|
-
purchaseData?:
|
22
|
+
purchaseData?: PurchaseData;
|
22
23
|
}
|
23
24
|
| {
|
24
25
|
status: "PENDING";
|
@@ -36,7 +37,7 @@ export type Status =
|
|
36
37
|
chainId: number;
|
37
38
|
transactionHash: ox__Hex.Hex;
|
38
39
|
}>;
|
39
|
-
purchaseData?:
|
40
|
+
purchaseData?: PurchaseData;
|
40
41
|
}
|
41
42
|
| {
|
42
43
|
status: "FAILED";
|
@@ -45,7 +46,7 @@ export type Status =
|
|
45
46
|
chainId: number;
|
46
47
|
transactionHash: ox__Hex.Hex;
|
47
48
|
}>;
|
48
|
-
purchaseData?:
|
49
|
+
purchaseData?: PurchaseData;
|
49
50
|
}
|
50
51
|
| {
|
51
52
|
status: "NOT_FOUND";
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineChain } from "../utils.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @chain
|
5
|
+
*/
|
6
|
+
export const coreMainnet = /* @__PURE__ */ defineChain({
|
7
|
+
blockExplorers: [
|
8
|
+
{
|
9
|
+
name: "Core Scan",
|
10
|
+
url: "https://scan.coredao.org/",
|
11
|
+
},
|
12
|
+
],
|
13
|
+
id: 1116,
|
14
|
+
name: "Core",
|
15
|
+
nativeCurrency: {
|
16
|
+
decimals: 18,
|
17
|
+
name: "Ether",
|
18
|
+
symbol: "ETH",
|
19
|
+
},
|
20
|
+
});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from "../utils.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @chain
|
5
|
+
*/
|
6
|
+
export const coreTestnet = /* @__PURE__ */ defineChain({
|
7
|
+
blockExplorers: [
|
8
|
+
{
|
9
|
+
name: "Core Testnet Scan",
|
10
|
+
url: "https://scan.test2.btcs.network/",
|
11
|
+
},
|
12
|
+
],
|
13
|
+
id: 1114,
|
14
|
+
name: "Core Testnet",
|
15
|
+
nativeCurrency: {
|
16
|
+
decimals: 18,
|
17
|
+
name: "Ether",
|
18
|
+
symbol: "ETH",
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { defineChain } from "../utils.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @chain
|
5
|
+
*/
|
6
|
+
export const somniaTestnet = /*@__PURE__*/ defineChain({
|
7
|
+
blockExplorers: [
|
8
|
+
{
|
9
|
+
apiUrl: "https://shannon-explorer.somnia.network/api",
|
10
|
+
name: "Somnia Testnet Explorer",
|
11
|
+
url: "https://shannon-explorer.somnia.network/",
|
12
|
+
},
|
13
|
+
],
|
14
|
+
id: 50312,
|
15
|
+
name: "Somnia Testnet",
|
16
|
+
nativeCurrency: { decimals: 18, name: "Somnia Testnet Token", symbol: "STT" },
|
17
|
+
testnet: true,
|
18
|
+
});
|
package/src/exports/chains.ts
CHANGED
@@ -24,6 +24,8 @@ export { bsc } from "../chains/chain-definitions/bsc.js";
|
|
24
24
|
export { bscTestnet } from "../chains/chain-definitions/bsc-testnet.js";
|
25
25
|
export { celo } from "../chains/chain-definitions/celo.js";
|
26
26
|
export { celoAlfajoresTestnet } from "../chains/chain-definitions/celo-alfajores-testnet.js";
|
27
|
+
export { coreMainnet } from "../chains/chain-definitions/core-mainnet.js";
|
28
|
+
export { coreTestnet } from "../chains/chain-definitions/core-testnet.js";
|
27
29
|
export { cronos } from "../chains/chain-definitions/cronos.js";
|
28
30
|
export { degen } from "../chains/chain-definitions/degen.js";
|
29
31
|
// mainnet = alias for ethereum
|
@@ -68,6 +70,7 @@ export { scroll } from "../chains/chain-definitions/scroll.js";
|
|
68
70
|
export { scrollAlphaTestnet } from "../chains/chain-definitions/scroll-alpha-testnet.js";
|
69
71
|
export { scrollSepoliaTestnet } from "../chains/chain-definitions/scroll-sepolia-testnet.js";
|
70
72
|
export { sepolia } from "../chains/chain-definitions/sepolia.js";
|
73
|
+
export { somniaTestnet } from "../chains/chain-definitions/somniaTestnet.js";
|
71
74
|
export { soneiumMinato } from "../chains/chain-definitions/soneium-minato.js";
|
72
75
|
export { treasure } from "../chains/chain-definitions/treasure.js";
|
73
76
|
export { treasureTopaz } from "../chains/chain-definitions/treasureTopaz.js";
|
@@ -78,6 +81,7 @@ export { zkSync } from "../chains/chain-definitions/zksync.js";
|
|
78
81
|
export { zkSyncSepolia } from "../chains/chain-definitions/zksync-sepolia.js";
|
79
82
|
export { zora } from "../chains/chain-definitions/zora.js";
|
80
83
|
export { zoraSepolia } from "../chains/chain-definitions/zora-sepolia.js";
|
84
|
+
|
81
85
|
export type { Chain, ChainMetadata, ChainOptions } from "../chains/types.js";
|
82
86
|
// define chain, chainMetadata
|
83
87
|
export {
|
@@ -52,7 +52,7 @@ export type CreateSessionKeyOptions = {
|
|
52
52
|
* @returns The transaction object to be sent.
|
53
53
|
* @example
|
54
54
|
* ```ts
|
55
|
-
* import { createSessionKey } from 'thirdweb/
|
55
|
+
* import { createSessionKey } from 'thirdweb/wallets/in-app';
|
56
56
|
* import { sendTransaction } from 'thirdweb';
|
57
57
|
*
|
58
58
|
* const transaction = createSessionKey({
|
@@ -7,6 +7,7 @@ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
|
|
7
7
|
import { getContract } from "../../contract/contract.js";
|
8
8
|
import { decimals } from "../../extensions/erc20/read/decimals.js";
|
9
9
|
import type { PrepareTransactionOptions } from "../../transaction/prepare-transaction.js";
|
10
|
+
import type { PurchaseData } from "../types.js";
|
10
11
|
import type {
|
11
12
|
QuoteApprovalInfo,
|
12
13
|
QuotePaymentToken,
|
@@ -76,7 +77,7 @@ export type GetBuyWithCryptoQuoteParams = {
|
|
76
77
|
*
|
77
78
|
* This details will be stored with the purchase and can be retrieved later via the status API or Webhook
|
78
79
|
*/
|
79
|
-
purchaseData?:
|
80
|
+
purchaseData?: PurchaseData;
|
80
81
|
|
81
82
|
/**
|
82
83
|
* The maximum slippage in basis points (bps) allowed for the swap.
|
@@ -3,6 +3,7 @@ import type { Token } from "../../bridge/types/Token.js";
|
|
3
3
|
import type { ThirdwebClient } from "../../client/client.js";
|
4
4
|
import type { Hex } from "../../utils/encoding/hex.js";
|
5
5
|
import { toTokens } from "../../utils/units.js";
|
6
|
+
import type { PurchaseData } from "../types.js";
|
6
7
|
import type {
|
7
8
|
PayOnChainTransactionDetails,
|
8
9
|
PayTokenInfo,
|
@@ -80,7 +81,7 @@ export type BuyWithCryptoStatus =
|
|
80
81
|
toAddress: string;
|
81
82
|
failureMessage?: string;
|
82
83
|
bridge?: string;
|
83
|
-
purchaseData?:
|
84
|
+
purchaseData?: PurchaseData;
|
84
85
|
};
|
85
86
|
|
86
87
|
export type ValidBuyWithCryptoStatus = Exclude<
|
@@ -162,7 +163,7 @@ export async function getBuyWithCryptoStatus(
|
|
162
163
|
originTokenAddress: result.originTokenAddress,
|
163
164
|
originTransaction,
|
164
165
|
paymentId: result.paymentId,
|
165
|
-
purchaseData: result.purchaseData
|
166
|
+
purchaseData: result.purchaseData,
|
166
167
|
receiver: result.receiver,
|
167
168
|
sender: result.sender,
|
168
169
|
status: result.status,
|
@@ -178,7 +179,7 @@ export async function getBuyWithCryptoStatus(
|
|
178
179
|
originToken: result.originToken,
|
179
180
|
originTokenAddress: result.originTokenAddress,
|
180
181
|
paymentId: result.paymentId,
|
181
|
-
purchaseData: result.purchaseData
|
182
|
+
purchaseData: result.purchaseData,
|
182
183
|
receiver: result.receiver,
|
183
184
|
sender: result.sender,
|
184
185
|
status: result.status,
|
@@ -202,7 +203,7 @@ export async function getBuyWithCryptoStatus(
|
|
202
203
|
originTokenAddress: "",
|
203
204
|
originTransaction,
|
204
205
|
paymentId: "",
|
205
|
-
purchaseData: result.purchaseData
|
206
|
+
purchaseData: result.purchaseData,
|
206
207
|
receiver: "",
|
207
208
|
sender: "",
|
208
209
|
status: result.status,
|
@@ -230,7 +231,7 @@ function toBuyWithCryptoStatus(args: {
|
|
230
231
|
originChainId: number;
|
231
232
|
destinationChainId: number;
|
232
233
|
status: Status["status"];
|
233
|
-
purchaseData?:
|
234
|
+
purchaseData?: PurchaseData;
|
234
235
|
sender: string;
|
235
236
|
receiver: string;
|
236
237
|
paymentId: string;
|
@@ -277,7 +278,7 @@ function toBuyWithCryptoStatus(args: {
|
|
277
278
|
transactionHash: destinationTransaction?.transactionHash ?? "",
|
278
279
|
},
|
279
280
|
fromAddress: sender,
|
280
|
-
purchaseData: purchaseData
|
281
|
+
purchaseData: purchaseData,
|
281
282
|
quote: {
|
282
283
|
createdAt: new Date().toISOString(),
|
283
284
|
estimated: {
|
@@ -7,6 +7,7 @@ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
|
|
7
7
|
import { getContract } from "../../contract/contract.js";
|
8
8
|
import { decimals } from "../../extensions/erc20/read/decimals.js";
|
9
9
|
import type { PrepareTransactionOptions } from "../../transaction/prepare-transaction.js";
|
10
|
+
import type { PurchaseData } from "../types.js";
|
10
11
|
import type { QuoteApprovalInfo, QuotePaymentToken } from "./commonTypes.js";
|
11
12
|
|
12
13
|
/**
|
@@ -54,7 +55,7 @@ export type GetBuyWithCryptoTransferParams = {
|
|
54
55
|
*
|
55
56
|
* This details will be stored with the purchase and can be retrieved later via the status API or Webhook
|
56
57
|
*/
|
57
|
-
purchaseData?:
|
58
|
+
purchaseData?: PurchaseData;
|
58
59
|
|
59
60
|
/**
|
60
61
|
* For direct transfers, specify who will pay for the transfer fee. Can be "sender" or "receiver".
|
@@ -6,6 +6,7 @@ import { getContract } from "../../contract/contract.js";
|
|
6
6
|
import { decimals } from "../../extensions/erc20/read/decimals.js";
|
7
7
|
import type { CurrencyMeta } from "../../react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js";
|
8
8
|
import { toTokens, toUnits } from "../../utils/units.js";
|
9
|
+
import type { PurchaseData } from "../types.js";
|
9
10
|
import type { FiatProvider, PayTokenInfo } from "../utils/commonTypes.js";
|
10
11
|
/**
|
11
12
|
* Parameters for [`getBuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatQuote) function
|
@@ -80,7 +81,7 @@ export type GetBuyWithFiatQuoteParams = {
|
|
80
81
|
*
|
81
82
|
* This details will be stored with the purchase and can be retrieved later via the status API or Webhook
|
82
83
|
*/
|
83
|
-
purchaseData?:
|
84
|
+
purchaseData?: PurchaseData;
|
84
85
|
|
85
86
|
/**
|
86
87
|
* Optional parameter to onramp gas with the purchase
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { status as onrampStatus } from "../../bridge/OnrampStatus.js";
|
2
2
|
import type { ThirdwebClient } from "../../client/client.js";
|
3
|
+
import type { PurchaseData } from "../types.js";
|
3
4
|
import type {
|
4
5
|
PayOnChainTransactionDetails,
|
5
6
|
PayTokenInfo,
|
@@ -109,7 +110,7 @@ export type BuyWithFiatStatus =
|
|
109
110
|
/**
|
110
111
|
* Arbitrary data sent at the time of fetching the quote
|
111
112
|
*/
|
112
|
-
purchaseData?:
|
113
|
+
purchaseData?: PurchaseData;
|
113
114
|
};
|
114
115
|
|
115
116
|
/**
|
@@ -202,7 +203,7 @@ function buildPlaceholderStatus(args: {
|
|
202
203
|
| "PENDING_PAYMENT"
|
203
204
|
| "PAYMENT_FAILED"
|
204
205
|
| "ON_RAMP_TRANSFER_COMPLETED";
|
205
|
-
purchaseData?:
|
206
|
+
purchaseData?: PurchaseData;
|
206
207
|
}): BuyWithFiatStatus {
|
207
208
|
const { intentId, status, purchaseData } = args;
|
208
209
|
|
@@ -253,7 +254,7 @@ function buildPlaceholderStatus(args: {
|
|
253
254
|
const base: Exclude<BuyWithFiatStatus, { status: "NOT_FOUND" }> = {
|
254
255
|
fromAddress: "",
|
255
256
|
intentId,
|
256
|
-
purchaseData
|
257
|
+
purchaseData,
|
257
258
|
quote,
|
258
259
|
status,
|
259
260
|
toAddress: "",
|
package/src/pay/types.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export type PurchaseData = Record<string, unknown>;
|
@@ -4,6 +4,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
4
4
|
import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js";
|
5
5
|
import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js";
|
6
6
|
import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
|
7
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
7
8
|
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js";
|
8
9
|
import type { AssetTabs } from "../../../../react/web/ui/ConnectWallet/screens/ViewAssets.js";
|
9
10
|
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
@@ -117,7 +118,7 @@ export type PayUIOptions = Prettify<
|
|
117
118
|
*
|
118
119
|
* This details will be stored with the purchase and can be retrieved later via the status API or Webhook
|
119
120
|
*/
|
120
|
-
purchaseData?:
|
121
|
+
purchaseData?: PurchaseData;
|
121
122
|
|
122
123
|
/**
|
123
124
|
* Callback to be called when the user successfully completes the purchase.
|
@@ -6,6 +6,7 @@ import * as Bridge from "../../../../bridge/index.js";
|
|
6
6
|
import type { Chain } from "../../../../chains/types.js";
|
7
7
|
import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js";
|
8
8
|
import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js";
|
9
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
9
10
|
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js";
|
10
11
|
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
|
11
12
|
import { sendTransaction } from "../../../../transaction/actions/send-transaction.js";
|
@@ -65,7 +66,7 @@ export type SendTransactionPayModalConfig =
|
|
65
66
|
testMode?: boolean;
|
66
67
|
preferredProvider?: FiatProvider;
|
67
68
|
};
|
68
|
-
purchaseData?:
|
69
|
+
purchaseData?: PurchaseData;
|
69
70
|
/**
|
70
71
|
* Callback to be called when the user successfully completes the purchase.
|
71
72
|
*/
|
@@ -2,6 +2,7 @@
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
3
3
|
import type { Token } from "../../../../bridge/types/Token.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
5
6
|
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
6
7
|
import type { Address } from "../../../../utils/address.js";
|
7
8
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
@@ -102,7 +103,7 @@ export interface BridgeOrchestratorProps {
|
|
102
103
|
/**
|
103
104
|
* Optional purchase data for the payment
|
104
105
|
*/
|
105
|
-
purchaseData
|
106
|
+
purchaseData?: PurchaseData;
|
106
107
|
|
107
108
|
/**
|
108
109
|
* Optional payment link ID for the payment
|
@@ -7,6 +7,7 @@ import type { Chain } from "../../../../chains/types.js";
|
|
7
7
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
8
8
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
9
9
|
import { getToken } from "../../../../pay/convert/get-token.js";
|
10
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
10
11
|
import {
|
11
12
|
type Address,
|
12
13
|
checksumAddress,
|
@@ -139,7 +140,7 @@ export type BuyWidgetProps = {
|
|
139
140
|
/**
|
140
141
|
* Arbitrary data to be included in the returned status and webhook events.
|
141
142
|
*/
|
142
|
-
purchaseData?:
|
143
|
+
purchaseData?: PurchaseData;
|
143
144
|
|
144
145
|
/**
|
145
146
|
* Callback triggered when the purchase is successful.
|
@@ -7,6 +7,7 @@ import type { Chain } from "../../../../chains/types.js";
|
|
7
7
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
8
8
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
9
9
|
import { getToken } from "../../../../pay/convert/get-token.js";
|
10
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
10
11
|
import { type Address, checksumAddress } from "../../../../utils/address.js";
|
11
12
|
import { stringify } from "../../../../utils/json.js";
|
12
13
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
@@ -145,7 +146,7 @@ export type CheckoutWidgetProps = {
|
|
145
146
|
/**
|
146
147
|
* Arbitrary data to be included in the returned status and webhook events.
|
147
148
|
*/
|
148
|
-
purchaseData?:
|
149
|
+
purchaseData?: PurchaseData;
|
149
150
|
|
150
151
|
/**
|
151
152
|
* Callback triggered when the purchase is successful.
|
@@ -3,6 +3,7 @@ import { useRef, useState } from "react";
|
|
3
3
|
import type { Token } from "../../../../bridge/types/Token.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
5
|
import { type Address, getAddress } from "../../../../utils/address.js";
|
6
|
+
import { numberToPlainString } from "../../../../utils/formatNumber.js";
|
6
7
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
7
8
|
import {
|
8
9
|
fontSize,
|
@@ -112,9 +113,9 @@ export function FundWallet({
|
|
112
113
|
// Convert USD amount to token amount using token price
|
113
114
|
const tokenAmount = usdAmount / uiOptions.destinationToken.priceUsd;
|
114
115
|
// Format to reasonable decimal places (up to 6 decimals, remove trailing zeros)
|
115
|
-
const formattedAmount =
|
116
|
-
tokenAmount.toFixed(6),
|
117
|
-
)
|
116
|
+
const formattedAmount = numberToPlainString(
|
117
|
+
Number.parseFloat(tokenAmount.toFixed(6)),
|
118
|
+
);
|
118
119
|
setAmount(formattedAmount);
|
119
120
|
};
|
120
121
|
|
@@ -4,6 +4,7 @@ import { useEffect } from "react";
|
|
4
4
|
import { trackPayEvent } from "../../../../analytics/track/pay.js";
|
5
5
|
import type { Token } from "../../../../bridge/types/Token.js";
|
6
6
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
7
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
7
8
|
import { toUnits } from "../../../../utils/units.js";
|
8
9
|
import {
|
9
10
|
type BridgePrepareRequest,
|
@@ -69,7 +70,7 @@ interface QuoteLoaderProps {
|
|
69
70
|
/**
|
70
71
|
* Optional purchase data for the payment
|
71
72
|
*/
|
72
|
-
purchaseData?:
|
73
|
+
purchaseData?: PurchaseData;
|
73
74
|
|
74
75
|
/**
|
75
76
|
* Optional payment link ID for the payment
|
@@ -175,7 +176,7 @@ function getBridgeParams(args: {
|
|
175
176
|
client: ThirdwebClient;
|
176
177
|
sender?: string;
|
177
178
|
feePayer?: "sender" | "receiver";
|
178
|
-
purchaseData?:
|
179
|
+
purchaseData?: PurchaseData;
|
179
180
|
paymentLinkId?: string;
|
180
181
|
}): UseBridgePrepareParams {
|
181
182
|
const { paymentMethod, amount, destinationToken, receiver, client, sender } =
|
@@ -7,6 +7,7 @@ import type { Chain } from "../../../../chains/types.js";
|
|
7
7
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
8
8
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
9
9
|
import { getToken } from "../../../../pay/convert/get-token.js";
|
10
|
+
import type { PurchaseData } from "../../../../pay/types.js";
|
10
11
|
import {
|
11
12
|
type PreparedTransaction,
|
12
13
|
prepareTransaction,
|
@@ -143,7 +144,7 @@ export type TransactionWidgetProps = {
|
|
143
144
|
/**
|
144
145
|
* Arbitrary data to be included in the returned status and webhook events.
|
145
146
|
*/
|
146
|
-
purchaseData?:
|
147
|
+
purchaseData?: PurchaseData;
|
147
148
|
|
148
149
|
/**
|
149
150
|
* Callback triggered when the purchase is successful.
|
@@ -138,10 +138,10 @@ function TokenIconWithFallback(props: {
|
|
138
138
|
border: `1px solid ${theme.colors.borderColor}`,
|
139
139
|
borderRadius: "50%",
|
140
140
|
display: "flex",
|
141
|
-
height: `${iconSize.
|
141
|
+
height: `${iconSize[props.size]}px`,
|
142
142
|
justifyContent: "center",
|
143
143
|
padding: spacing.xs,
|
144
|
-
width: `${iconSize.
|
144
|
+
width: `${iconSize[props.size]}px`,
|
145
145
|
}}
|
146
146
|
>
|
147
147
|
<Text
|
@@ -363,6 +363,7 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
363
363
|
? ["card"]
|
364
364
|
: ["crypto", "card"]
|
365
365
|
}
|
366
|
+
purchaseData={props.payOptions?.purchaseData}
|
366
367
|
theme={theme}
|
367
368
|
title={metadata?.name || "Buy"}
|
368
369
|
tokenAddress={
|
@@ -387,6 +388,7 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
387
388
|
? ["crypto"]
|
388
389
|
: ["crypto", "card"]
|
389
390
|
}
|
391
|
+
purchaseData={props.payOptions?.purchaseData}
|
390
392
|
seller={props.payOptions.paymentInfo.sellerAddress as Address}
|
391
393
|
theme={theme}
|
392
394
|
tokenAddress={
|
@@ -408,6 +410,7 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
408
410
|
? ["crypto"]
|
409
411
|
: ["crypto", "card"]
|
410
412
|
}
|
413
|
+
purchaseData={props.payOptions?.purchaseData}
|
411
414
|
theme={theme}
|
412
415
|
title={metadata?.name}
|
413
416
|
transaction={props.payOptions.transaction}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { expect, test } from "vitest";
|
2
|
-
import { formatNumber } from "./formatNumber.js";
|
2
|
+
import { formatNumber, numberToPlainString } from "./formatNumber.js";
|
3
3
|
|
4
4
|
test("formatNumber", () => {
|
5
5
|
// no decimals
|
@@ -27,3 +27,52 @@ test("formatNumber", () => {
|
|
27
27
|
expect(formatNumber(0.00000000000009, 3)).toEqual(0.001);
|
28
28
|
expect(formatNumber(0.00000000000001, 3)).toEqual(0.001);
|
29
29
|
});
|
30
|
+
|
31
|
+
test("numberToPlainString", () => {
|
32
|
+
// Numbers without exponential notation (should return as-is)
|
33
|
+
expect(numberToPlainString(123)).toEqual("123");
|
34
|
+
expect(numberToPlainString(0.123)).toEqual("0.123");
|
35
|
+
expect(numberToPlainString(0)).toEqual("0");
|
36
|
+
expect(numberToPlainString(-456)).toEqual("-456");
|
37
|
+
expect(numberToPlainString(-0.789)).toEqual("-0.789");
|
38
|
+
|
39
|
+
// Small numbers with negative exponents
|
40
|
+
expect(numberToPlainString(1e-1)).toEqual("0.1");
|
41
|
+
expect(numberToPlainString(1e-2)).toEqual("0.01");
|
42
|
+
expect(numberToPlainString(1e-3)).toEqual("0.001");
|
43
|
+
expect(numberToPlainString(1.23e-4)).toEqual("0.000123");
|
44
|
+
expect(numberToPlainString(1.2345e-6)).toEqual("0.0000012345");
|
45
|
+
expect(numberToPlainString(5e-10)).toEqual("0.0000000005");
|
46
|
+
expect(numberToPlainString(-5e-10)).toEqual("-0.0000000005");
|
47
|
+
|
48
|
+
// Large numbers with positive exponents - zerosNeeded >= 0
|
49
|
+
expect(numberToPlainString(1e1)).toEqual("10");
|
50
|
+
expect(numberToPlainString(1e2)).toEqual("100");
|
51
|
+
expect(numberToPlainString(1.23e3)).toEqual("1230");
|
52
|
+
expect(numberToPlainString(1.23e5)).toEqual("123000");
|
53
|
+
expect(numberToPlainString(5.67e10)).toEqual("56700000000");
|
54
|
+
|
55
|
+
// Large numbers with positive exponents - zerosNeeded < 0 (decimal point insertion)
|
56
|
+
expect(numberToPlainString(1.2345e2)).toEqual("123.45");
|
57
|
+
expect(numberToPlainString(1.23e1)).toEqual("12.3");
|
58
|
+
expect(numberToPlainString(9.876e2)).toEqual("987.6");
|
59
|
+
expect(numberToPlainString(1.23456e3)).toEqual("1234.56");
|
60
|
+
expect(numberToPlainString(5.4321e1)).toEqual("54.321");
|
61
|
+
|
62
|
+
// Edge cases where exponent equals decimal length
|
63
|
+
expect(numberToPlainString(1.23e2)).toEqual("123");
|
64
|
+
expect(numberToPlainString(1.234e3)).toEqual("1234");
|
65
|
+
|
66
|
+
// Negative numbers
|
67
|
+
expect(numberToPlainString(-1.2345e2)).toEqual("-123.45");
|
68
|
+
expect(numberToPlainString(-1.23e-4)).toEqual("-0.000123");
|
69
|
+
|
70
|
+
// Very large numbers (JavaScript precision limits apply)
|
71
|
+
expect(numberToPlainString(1.0523871386385944e21)).toEqual(
|
72
|
+
"1052387138638594400000",
|
73
|
+
);
|
74
|
+
|
75
|
+
// Numbers that would normally show exponential notation
|
76
|
+
expect(numberToPlainString(0.0000001)).toEqual("0.0000001");
|
77
|
+
expect(numberToPlainString(10000000)).toEqual("10000000");
|
78
|
+
});
|