thirdweb 5.92.3 → 5.93.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.
Files changed (116) hide show
  1. package/dist/cjs/adapters/eip1193/from-eip1193.js +7 -9
  2. package/dist/cjs/adapters/eip1193/from-eip1193.js.map +1 -1
  3. package/dist/cjs/bridge/Buy.js +199 -0
  4. package/dist/cjs/bridge/Buy.js.map +1 -0
  5. package/dist/cjs/bridge/Routes.js +134 -0
  6. package/dist/cjs/bridge/Routes.js.map +1 -0
  7. package/dist/cjs/bridge/Sell.js +199 -0
  8. package/dist/cjs/bridge/Sell.js.map +1 -0
  9. package/dist/cjs/bridge/Status.js +147 -0
  10. package/dist/cjs/bridge/Status.js.map +1 -0
  11. package/dist/cjs/bridge/constants.js +5 -0
  12. package/dist/cjs/bridge/constants.js.map +1 -0
  13. package/dist/cjs/bridge/index.js +10 -0
  14. package/dist/cjs/bridge/index.js.map +1 -0
  15. package/dist/cjs/bridge/types/Quote.js +3 -0
  16. package/dist/cjs/bridge/types/Quote.js.map +1 -0
  17. package/dist/cjs/bridge/types/Route.js +3 -0
  18. package/dist/cjs/bridge/types/Route.js.map +1 -0
  19. package/dist/cjs/bridge/types/Status.js +3 -0
  20. package/dist/cjs/bridge/types/Status.js.map +1 -0
  21. package/dist/cjs/exports/bridge.js +5 -0
  22. package/dist/cjs/exports/bridge.js.map +1 -0
  23. package/dist/cjs/exports/thirdweb.js +6 -2
  24. package/dist/cjs/exports/thirdweb.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/WalletSelector.js +2 -2
  26. package/dist/cjs/react/web/ui/ConnectWallet/WalletSelector.js.map +1 -1
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -2
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js +11 -8
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/adapters/eip1193/from-eip1193.js +7 -9
  35. package/dist/esm/adapters/eip1193/from-eip1193.js.map +1 -1
  36. package/dist/esm/bridge/Buy.js +195 -0
  37. package/dist/esm/bridge/Buy.js.map +1 -0
  38. package/dist/esm/bridge/Routes.js +131 -0
  39. package/dist/esm/bridge/Routes.js.map +1 -0
  40. package/dist/esm/bridge/Sell.js +195 -0
  41. package/dist/esm/bridge/Sell.js.map +1 -0
  42. package/dist/esm/bridge/Status.js +144 -0
  43. package/dist/esm/bridge/Status.js.map +1 -0
  44. package/dist/esm/bridge/constants.js +2 -0
  45. package/dist/esm/bridge/constants.js.map +1 -0
  46. package/dist/esm/bridge/index.js +5 -0
  47. package/dist/esm/bridge/index.js.map +1 -0
  48. package/dist/esm/bridge/types/Quote.js +2 -0
  49. package/dist/esm/bridge/types/Quote.js.map +1 -0
  50. package/dist/esm/bridge/types/Route.js +2 -0
  51. package/dist/esm/bridge/types/Route.js.map +1 -0
  52. package/dist/esm/bridge/types/Status.js +2 -0
  53. package/dist/esm/bridge/types/Status.js.map +1 -0
  54. package/dist/esm/exports/bridge.js +2 -0
  55. package/dist/esm/exports/bridge.js.map +1 -0
  56. package/dist/esm/exports/thirdweb.js +4 -0
  57. package/dist/esm/exports/thirdweb.js.map +1 -1
  58. package/dist/esm/react/web/ui/ConnectWallet/WalletSelector.js +2 -2
  59. package/dist/esm/react/web/ui/ConnectWallet/WalletSelector.js.map +1 -1
  60. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -2
  61. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  62. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js +12 -9
  63. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -1
  64. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +1 -1
  65. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
  66. package/dist/esm/version.js +1 -1
  67. package/dist/types/adapters/eip1193/from-eip1193.d.ts +3 -1
  68. package/dist/types/adapters/eip1193/from-eip1193.d.ts.map +1 -1
  69. package/dist/types/bridge/Buy.d.ts +171 -0
  70. package/dist/types/bridge/Buy.d.ts.map +1 -0
  71. package/dist/types/bridge/Routes.d.ts +116 -0
  72. package/dist/types/bridge/Routes.d.ts.map +1 -0
  73. package/dist/types/bridge/Sell.d.ts +171 -0
  74. package/dist/types/bridge/Sell.d.ts.map +1 -0
  75. package/dist/types/bridge/Status.d.ts +108 -0
  76. package/dist/types/bridge/Status.d.ts.map +1 -0
  77. package/dist/types/bridge/constants.d.ts +2 -0
  78. package/dist/types/bridge/constants.d.ts.map +1 -0
  79. package/dist/types/bridge/index.d.ts +8 -0
  80. package/dist/types/bridge/index.d.ts.map +1 -0
  81. package/dist/types/bridge/types/Quote.d.ts +34 -0
  82. package/dist/types/bridge/types/Quote.d.ts.map +1 -0
  83. package/dist/types/bridge/types/Route.d.ts +20 -0
  84. package/dist/types/bridge/types/Route.d.ts.map +1 -0
  85. package/dist/types/bridge/types/Status.d.ts +35 -0
  86. package/dist/types/bridge/types/Status.d.ts.map +1 -0
  87. package/dist/types/exports/bridge.d.ts +2 -0
  88. package/dist/types/exports/bridge.d.ts.map +1 -0
  89. package/dist/types/exports/thirdweb.d.ts +4 -0
  90. package/dist/types/exports/thirdweb.d.ts.map +1 -1
  91. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
  92. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts +1 -3
  93. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts.map +1 -1
  94. package/dist/types/version.d.ts +1 -1
  95. package/package.json +9 -1
  96. package/src/adapters/eip1193/from-eip1193.ts +10 -10
  97. package/src/bridge/Buy.test.ts +74 -0
  98. package/src/bridge/Buy.ts +267 -0
  99. package/src/bridge/Routes.test.ts +161 -0
  100. package/src/bridge/Routes.ts +160 -0
  101. package/src/bridge/Sell.test.ts +74 -0
  102. package/src/bridge/Sell.ts +267 -0
  103. package/src/bridge/Status.test.ts +38 -0
  104. package/src/bridge/Status.ts +163 -0
  105. package/src/bridge/constants.ts +1 -0
  106. package/src/bridge/index.ts +8 -0
  107. package/src/bridge/types/Quote.ts +42 -0
  108. package/src/bridge/types/Route.ts +20 -0
  109. package/src/bridge/types/Status.ts +39 -0
  110. package/src/exports/bridge.ts +1 -0
  111. package/src/exports/thirdweb.ts +5 -0
  112. package/src/react/web/ui/ConnectWallet/WalletSelector.tsx +2 -0
  113. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -6
  114. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.tsx +14 -35
  115. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.tsx +1 -1
  116. package/src/version.ts +1 -1
@@ -0,0 +1,163 @@
1
+ import type { Hex as ox__Hex } from "ox";
2
+ import type { ThirdwebClient } from "../client/client.js";
3
+ import { getClientFetch } from "../utils/fetch.js";
4
+ import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
5
+ import type { Status } from "./types/Status.js";
6
+
7
+ /**
8
+ * 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.
9
+ *
10
+ + * The returned status will include both the origin and destination transactions and any finalized amounts for the route.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Bridge } from "thirdweb";
15
+ *
16
+ * const status = await Bridge.status({
17
+ * transactionHash: "0xe199ef82a0b6215221536e18ec512813c1aa10b4f5ed0d4dfdfcd703578da56d",
18
+ * chainId: 8453,
19
+ * client: thirdwebClient,
20
+ * });
21
+ * ```
22
+ *
23
+ * If the transaction is complete, a response might look like:
24
+ * ```typescript
25
+ * {
26
+ * status: 'COMPLETED',
27
+ * originAmount: 200000000000000n,
28
+ * destinationAmount: 188625148000000n,
29
+ * originChainId: 8453,
30
+ * destinationChainId: 2741,
31
+ * originTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
32
+ * destinationTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
33
+ * transactions: [
34
+ * {
35
+ * chainId: 8453,
36
+ * transactionHash: '0xe199ef82a0b6215221536e18ec512813c1aa10b4f5ed0d4dfdfcd703578da56d'
37
+ * },
38
+ * {
39
+ * chainId: 2741,
40
+ * transactionHash: '0xa70a82f42330f54be95a542e1fcfe6ed2dd9f07fb8c82ae67afb4342319f7433'
41
+ * }
42
+ * ]
43
+ * }
44
+ * ```
45
+ *
46
+ * If the origin transaction hasn't been mined yet, a response might look like:
47
+ * ```typescript
48
+ * {
49
+ * status: "NOT_FOUND",
50
+ * }
51
+ * ```
52
+ * This is to allow you to poll for the status without catching an error. Be sure your transaction hash and chain are correct though, as this could also represent a legitimate 404 if the transaction doesn't exist.
53
+ *
54
+ * If the transaction is still pending, a response might look like:
55
+ * ```typescript
56
+ * {
57
+ * status: "PENDING",
58
+ * originAmount: 1000000000000000000n,
59
+ * originChainId: 466,
60
+ * destinationChainId: 1,
61
+ * originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
62
+ * destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
63
+ * transactions: [
64
+ * {
65
+ * transactionHash: "0xe199ef82a0b6215221536e18ec512813c1aa10b4f5ed0d4dfdfcd703578da56d",
66
+ * chainId: 466,
67
+ * }
68
+ * ]
69
+ * }
70
+ * ```
71
+ *
72
+ * If the transaction failed, a response might look like:
73
+ * ```typescript
74
+ * {
75
+ * status: "FAILED",
76
+ * transactions: [
77
+ * {
78
+ * transactionHash: "0xe199ef82a0b6215221536e18ec512813c1aa10b4f5ed0d4dfdfcd703578da56d",
79
+ * chainId: 466,
80
+ * }
81
+ * ]
82
+ * }
83
+ * ```
84
+ *
85
+ * This status is for a **single origin transaction only**. If your route involves multiple transactions, you'll need to get the status for each of them individually.
86
+ *
87
+ * If sending multiple dependent sequential transactions, wait until `status` returns `COMPLETED` before sending the next transaction.
88
+ *
89
+ * You can access this function's input and output types with `status.Options` and `status.Result`, respectively.
90
+ *
91
+ * @param options - The options for the quote.
92
+ * @param options.transactionHash - The hash of the origin transaction to get the bridge status for.
93
+ * @param options.chainId - The chain ID of the origin token.
94
+ * @param options.client - Your thirdweb client.
95
+ *
96
+ * @returns A promise that resolves to a status object for the transaction.
97
+ *
98
+ * @throws Will throw an error if there is an issue fetching the status.
99
+ * @bridge
100
+ * @beta
101
+ */
102
+ export async function status(options: status.Options): Promise<status.Result> {
103
+ const { transactionHash, chainId, client } = options;
104
+
105
+ const clientFetch = getClientFetch(client);
106
+ const url = new URL(`${UNIVERSAL_BRIDGE_URL}/status`);
107
+ url.searchParams.set("transactionHash", transactionHash);
108
+ url.searchParams.set("chainId", chainId.toString());
109
+
110
+ const response = await clientFetch(url.toString());
111
+ if (!response.ok) {
112
+ const errorJson = await response.json();
113
+ throw new Error(`${errorJson.code}: ${errorJson.message}`);
114
+ }
115
+
116
+ const { data }: { data: Status } = await response.json();
117
+ if (data.status === "FAILED") {
118
+ return {
119
+ status: "FAILED",
120
+ transactions: data.transactions,
121
+ };
122
+ }
123
+
124
+ if (data.status === "PENDING") {
125
+ return {
126
+ status: "PENDING",
127
+ originAmount: BigInt(data.originAmount),
128
+ originChainId: data.originChainId,
129
+ destinationChainId: data.destinationChainId,
130
+ originTokenAddress: data.originTokenAddress,
131
+ destinationTokenAddress: data.destinationTokenAddress,
132
+ transactions: data.transactions,
133
+ };
134
+ }
135
+
136
+ if (data.status === "NOT_FOUND") {
137
+ return {
138
+ status: "NOT_FOUND",
139
+ transactions: [],
140
+ };
141
+ }
142
+
143
+ return {
144
+ status: "COMPLETED",
145
+ originAmount: BigInt(data.originAmount),
146
+ destinationAmount: BigInt(data.destinationAmount),
147
+ originChainId: data.originChainId,
148
+ destinationChainId: data.destinationChainId,
149
+ originTokenAddress: data.originTokenAddress,
150
+ destinationTokenAddress: data.destinationTokenAddress,
151
+ transactions: data.transactions,
152
+ };
153
+ }
154
+
155
+ export declare namespace status {
156
+ type Options = {
157
+ transactionHash: ox__Hex.Hex;
158
+ chainId: number;
159
+ client: ThirdwebClient;
160
+ };
161
+
162
+ type Result = Status;
163
+ }
@@ -0,0 +1 @@
1
+ export const UNIVERSAL_BRIDGE_URL = "https://bridge.thirdweb.com/v1";
@@ -0,0 +1,8 @@
1
+ export * as Buy from "./Buy.js";
2
+ export * as Sell from "./Sell.js";
3
+ export { status } from "./Status.js";
4
+ export { routes } from "./Routes.js";
5
+
6
+ export type { Status } from "./types/Status.js";
7
+ export type { Route } from "./types/Route.js";
8
+ export type { Quote, PreparedQuote } from "./types/Quote.js";
@@ -0,0 +1,42 @@
1
+ import type { TransactionEnvelopeEip1559 as ox__TransactionEnvelopeEip1559 } from "ox";
2
+
3
+ export type Quote = {
4
+ /**
5
+ * The input amount (in wei) including fees to be paid.
6
+ */
7
+ originAmount: bigint;
8
+ /**
9
+ * The output amount (in wei) to be received.
10
+ */
11
+ destinationAmount: bigint;
12
+ /**
13
+ * The blocknumber this quote was generated at.
14
+ */
15
+ blockNumber?: bigint;
16
+ /**
17
+ * The timestamp this quote was generated at.
18
+ */
19
+ timestamp: number;
20
+ /**
21
+ * The estimated execution time in milliseconds.
22
+ */
23
+ estimatedExecutionTimeMs?: number | undefined;
24
+ };
25
+
26
+ export type PreparedQuote = Quote & {
27
+ /**
28
+ * The expiration timestamp for the quote. All transactions must be executed before this timestamp to guarantee successful execution at the specified price.
29
+ */
30
+ expiration?: number | undefined;
31
+ /**
32
+ * A series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed in sequential order to fulfill the complete route.
33
+ */
34
+ transactions: Array<
35
+ ox__TransactionEnvelopeEip1559.TransactionEnvelopeEip1559<
36
+ false,
37
+ bigint,
38
+ number,
39
+ "eip1559"
40
+ >
41
+ >;
42
+ };
@@ -0,0 +1,20 @@
1
+ import type { Address as ox__Address } from "ox";
2
+
3
+ export type Route = {
4
+ originToken: {
5
+ chainId: number;
6
+ address: ox__Address.Address;
7
+ decimals: number;
8
+ symbol: string;
9
+ name: string;
10
+ iconUri?: string;
11
+ };
12
+ destinationToken: {
13
+ chainId: number;
14
+ address: string;
15
+ decimals: number;
16
+ symbol: string;
17
+ name: string;
18
+ iconUri?: string;
19
+ };
20
+ };
@@ -0,0 +1,39 @@
1
+ import type { Address as ox__Address, Hex as ox__Hex } from "ox";
2
+
3
+ export type Status =
4
+ | {
5
+ status: "COMPLETED";
6
+ originAmount: bigint;
7
+ destinationAmount: bigint;
8
+ originChainId: number;
9
+ destinationChainId: number;
10
+ originTokenAddress: ox__Address.Address;
11
+ destinationTokenAddress: ox__Address.Address;
12
+ transactions: Array<{
13
+ chainId: number;
14
+ transactionHash: ox__Hex.Hex;
15
+ }>;
16
+ }
17
+ | {
18
+ status: "PENDING";
19
+ originAmount: bigint;
20
+ originChainId: number;
21
+ destinationChainId: number;
22
+ originTokenAddress: ox__Address.Address;
23
+ destinationTokenAddress: ox__Address.Address;
24
+ transactions: Array<{
25
+ chainId: number;
26
+ transactionHash: ox__Hex.Hex;
27
+ }>;
28
+ }
29
+ | {
30
+ status: "FAILED";
31
+ transactions: Array<{
32
+ chainId: number;
33
+ transactionHash: ox__Hex.Hex;
34
+ }>;
35
+ }
36
+ | {
37
+ status: "NOT_FOUND";
38
+ transactions: [];
39
+ };
@@ -0,0 +1 @@
1
+ export * from "../bridge/index.js";
@@ -71,6 +71,11 @@ export {
71
71
  type ThirdwebContract,
72
72
  } from "../contract/contract.js";
73
73
 
74
+ /**
75
+ * UNIVERSAL BRIDGE
76
+ */
77
+ export * as Bridge from "../bridge/index.js";
78
+
74
79
  /**
75
80
  * WALLETS
76
81
  */
@@ -183,6 +183,7 @@ const WalletSelectorInner: React.FC<WalletSelectorProps> = (props) => {
183
183
  props.selectWallet(localWalletConfig);
184
184
  }}
185
185
  data-test="continue-as-guest-button"
186
+ disabled={props.meta.requireApproval && !approvedTOS}
186
187
  >
187
188
  {props.connectLocale.continueAsGuest}
188
189
  </Button>
@@ -227,6 +228,7 @@ const WalletSelectorInner: React.FC<WalletSelectorProps> = (props) => {
227
228
  <WalletTypeRowButton
228
229
  client={props.client}
229
230
  icon={OutlineWalletIcon}
231
+ disabled={props.meta.requireApproval && !approvedTOS}
230
232
  onClick={() => {
231
233
  setIsWalletGroupExpanded(true);
232
234
  }}
@@ -90,9 +90,6 @@ export function OnRampScreen(props: {
90
90
  isAutoMode,
91
91
  });
92
92
  const firstStepChainId = state.steps[0]?.step.token.chainId;
93
- const currentStepIndex = state.steps.findIndex(
94
- (step) => step.status === "pending" || step.status === "actionRequired",
95
- );
96
93
  return (
97
94
  <Container p="lg">
98
95
  <ModalHeader title={props.title} onBack={props.onBack} />
@@ -131,9 +128,7 @@ export function OnRampScreen(props: {
131
128
  index={index}
132
129
  />
133
130
  </StepContainer>
134
- {index < state.steps.length - 1 && (
135
- <StepConnectorArrow active={index === currentStepIndex} />
136
- )}
131
+ {index < state.steps.length - 1 && <StepConnectorArrow />}
137
132
  </Container>
138
133
  ))}
139
134
  </Container>
@@ -1,9 +1,8 @@
1
+ import { ChevronDownIcon } from "@radix-ui/react-icons";
1
2
  import { useCustomTheme } from "../../../../../../core/design-system/CustomThemeProvider.js";
2
3
  import { Container } from "../../../../components/basic.js";
3
4
 
4
- export function StepConnectorArrow(props: {
5
- active: boolean;
6
- }) {
5
+ export function StepConnectorArrow() {
7
6
  const theme = useCustomTheme();
8
7
  return (
9
8
  <Container
@@ -11,45 +10,25 @@ export function StepConnectorArrow(props: {
11
10
  center="both"
12
11
  style={{
13
12
  width: "100%",
14
- height: "12px",
15
13
  position: "relative",
16
- marginTop: "-1px",
14
+ marginTop: "-10px",
15
+ marginBottom: "-10px",
17
16
  zIndex: 1000,
18
17
  }}
19
18
  >
20
- <svg
21
- role="presentation"
22
- width="32"
23
- height="16"
24
- viewBox="0 0 32 16"
25
- fill="none"
19
+ <Container
20
+ flex="row"
21
+ center="both"
26
22
  style={{
27
- display: "block",
23
+ borderRadius: "100%",
24
+ width: "30px",
25
+ height: "30px",
26
+ backgroundColor: theme.colors.modalBg,
27
+ border: `1px solid ${theme.colors.borderColor}`,
28
28
  }}
29
29
  >
30
- <path
31
- d="M1 0L16 15L31 0"
32
- fill={theme.colors.tertiaryBg}
33
- stroke={
34
- props.active ? theme.colors.accentText : theme.colors.borderColor
35
- }
36
- strokeWidth="1"
37
- strokeLinecap="square"
38
- strokeLinejoin="miter"
39
- />
40
- <path
41
- d="M8 0L16 7.5L24 0"
42
- fill="none"
43
- stroke={
44
- props.active
45
- ? theme.colors.accentText
46
- : theme.colors.secondaryIconColor
47
- }
48
- strokeWidth="1"
49
- strokeLinecap="square"
50
- strokeLinejoin="miter"
51
- />
52
- </svg>
30
+ <ChevronDownIcon width={16} height={16} />
31
+ </Container>
53
32
  </Container>
54
33
  );
55
34
  }
@@ -64,7 +64,7 @@ export function SwapSummary(props: {
64
64
  />
65
65
  </Container>
66
66
  {/* Connector Icon */}
67
- <StepConnectorArrow active={false} />
67
+ <StepConnectorArrow />
68
68
  {/* Buy */}
69
69
  <Container
70
70
  flex="column"
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.92.3";
1
+ export const version = "5.93.0";