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,35 @@
1
+ import type { Address as ox__Address, Hex as ox__Hex } from "ox";
2
+ export type Status = {
3
+ status: "COMPLETED";
4
+ originAmount: bigint;
5
+ destinationAmount: bigint;
6
+ originChainId: number;
7
+ destinationChainId: number;
8
+ originTokenAddress: ox__Address.Address;
9
+ destinationTokenAddress: ox__Address.Address;
10
+ transactions: Array<{
11
+ chainId: number;
12
+ transactionHash: ox__Hex.Hex;
13
+ }>;
14
+ } | {
15
+ status: "PENDING";
16
+ originAmount: bigint;
17
+ originChainId: number;
18
+ destinationChainId: number;
19
+ originTokenAddress: ox__Address.Address;
20
+ destinationTokenAddress: ox__Address.Address;
21
+ transactions: Array<{
22
+ chainId: number;
23
+ transactionHash: ox__Hex.Hex;
24
+ }>;
25
+ } | {
26
+ status: "FAILED";
27
+ transactions: Array<{
28
+ chainId: number;
29
+ transactionHash: ox__Hex.Hex;
30
+ }>;
31
+ } | {
32
+ status: "NOT_FOUND";
33
+ transactions: [];
34
+ };
35
+ //# sourceMappingURL=Status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../../src/bridge/types/Status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,IAAI,CAAC;AAEjE,MAAM,MAAM,MAAM,GACd;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC;IACxC,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7C,YAAY,EAAE,KAAK,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;CACJ,GACD;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC;IACxC,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7C,YAAY,EAAE,KAAK,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;CACJ,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;CACJ,GACD;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,EAAE,CAAC;CAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "../bridge/index.js";
2
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/exports/bridge.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -44,6 +44,10 @@ export { eth_sendRawTransaction } from "../rpc/actions/eth_sendRawTransaction.js
44
44
  * CONTRACT
45
45
  */
46
46
  export { getContract, type ContractOptions, type ThirdwebContract, } from "../contract/contract.js";
47
+ /**
48
+ * UNIVERSAL BRIDGE
49
+ */
50
+ export * as Bridge from "../bridge/index.js";
47
51
  /**
48
52
  * WALLETS
49
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"thirdweb.d.ts","sourceRoot":"","sources":["../../../src/exports/thirdweb.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,QAAQ;QACvB,WAAW,EAAE,MAAM,CAAC;KACrB;CACF;AAED;;GAEG;AACH,OAAO;AACL;;GAEG;AACH,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AAEH,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,gBAA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,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,OAAO,EACP,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG1D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKpD,OAAO,EACL,UAAU,EACV,SAAS,EACT,KAAK,OAAO,EACZ,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EACL,KAAK,qBAAqB,EAC1B,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"thirdweb.d.ts","sourceRoot":"","sources":["../../../src/exports/thirdweb.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,QAAQ;QACvB,WAAW,EAAE,MAAM,CAAC;KACrB;CACF;AAED;;GAEG;AACH,OAAO;AACL;;GAEG;AACH,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,cAAc,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react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,mDAAmD,CAAC;AAkC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAe7C,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,eAAe,EAAE,MAAM,CAAC;CACzB,8CAiHA"}
1
+ {"version":3,"file":"OnRampScreen.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,mDAAmD,CAAC;AAkC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAe7C,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,eAAe,EAAE,MAAM,CAAC;CACzB,8CA4GA"}
@@ -1,4 +1,2 @@
1
- export declare function StepConnectorArrow(props: {
2
- active: boolean;
3
- }): import("react/jsx-runtime.js").JSX.Element;
1
+ export declare function StepConnectorArrow(): import("react/jsx-runtime.js").JSX.Element;
4
2
  //# sourceMappingURL=StepConnector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StepConnector.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.tsx"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,MAAM,EAAE,OAAO,CAAC;CACjB,8CAiDA"}
1
+ {"version":3,"file":"StepConnector.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.tsx"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,+CA6BjC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.92.3";
1
+ export declare const version = "5.93.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.92.3",
3
+ "version": "5.93.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -128,6 +128,11 @@
128
128
  "import": "./dist/esm/exports/ai.js",
129
129
  "default": "./dist/cjs/exports/ai.js"
130
130
  },
131
+ "./bridge": {
132
+ "types": "./dist/types/exports/bridge.d.ts",
133
+ "import": "./dist/esm/exports/bridge.js",
134
+ "default": "./dist/cjs/exports/bridge.js"
135
+ },
131
136
  "./package.json": "./package.json"
132
137
  },
133
138
  "typesVersions": {
@@ -188,6 +193,9 @@
188
193
  ],
189
194
  "ai": [
190
195
  "./dist/types/exports/ai.d.ts"
196
+ ],
197
+ "bridge": [
198
+ "./dist/types/exports/bridge.d.ts"
191
199
  ]
192
200
  }
193
201
  },
@@ -15,7 +15,9 @@ import type { EIP1193Provider } from "./types.js";
15
15
  * Options for creating an EIP-1193 provider adapter.
16
16
  */
17
17
  export type FromEip1193AdapterOptions = {
18
- provider: EIP1193Provider | (() => Promise<EIP1193Provider>);
18
+ provider:
19
+ | EIP1193Provider
20
+ | ((params?: { chainId?: number }) => Promise<EIP1193Provider>);
19
21
  walletId?: WalletId;
20
22
  };
21
23
 
@@ -63,13 +65,11 @@ export function fromProvider(options: FromEip1193AdapterOptions): Wallet {
63
65
  let account: Account | undefined = undefined;
64
66
  let chain: Chain | undefined = undefined;
65
67
  let provider: EIP1193Provider | undefined = undefined;
66
- const getProvider = async () => {
67
- if (!provider) {
68
- provider =
69
- typeof options.provider === "function"
70
- ? await options.provider()
71
- : options.provider;
72
- }
68
+ const getProvider = async (params?: { chainId?: number }) => {
69
+ provider =
70
+ typeof options.provider === "function"
71
+ ? await options.provider(params)
72
+ : options.provider;
73
73
  return provider;
74
74
  };
75
75
 
@@ -118,7 +118,7 @@ export function fromProvider(options: FromEip1193AdapterOptions): Wallet {
118
118
  const [connectedAccount, connectedChain, doDisconnect, doSwitchChain] =
119
119
  await connectEip1193Wallet({
120
120
  id,
121
- provider: await getProvider(),
121
+ provider: await getProvider({ chainId: connectOptions.chain?.id }),
122
122
  client: connectOptions.client,
123
123
  chain: connectOptions.chain,
124
124
  emitter,
@@ -141,7 +141,7 @@ export function fromProvider(options: FromEip1193AdapterOptions): Wallet {
141
141
  const [connectedAccount, connectedChain, doDisconnect, doSwitchChain] =
142
142
  await autoConnectEip1193Wallet({
143
143
  id,
144
- provider: await getProvider(),
144
+ provider: await getProvider({ chainId: connectOptions.chain?.id }),
145
145
  emitter,
146
146
  chain: connectOptions.chain,
147
147
  client: connectOptions.client,
@@ -0,0 +1,74 @@
1
+ import { toWei } from "src/utils/units.js";
2
+ import { describe, expect, it } from "vitest";
3
+ import { TEST_CLIENT } from "~test/test-clients.js";
4
+ import * as Buy from "./Buy.js";
5
+
6
+ describe("Bridge.Buy.quote", () => {
7
+ it("should get a valid quote", async () => {
8
+ const quote = await Buy.quote({
9
+ originChainId: 1,
10
+ originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
11
+ destinationChainId: 10,
12
+ destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
13
+ buyAmountWei: toWei("0.01"),
14
+ client: TEST_CLIENT,
15
+ });
16
+
17
+ expect(quote).toBeDefined();
18
+ expect(quote.destinationAmount).toEqual(toWei("0.01"));
19
+ expect(quote.intent).toBeDefined();
20
+ });
21
+
22
+ it("should surface any errors", async () => {
23
+ await expect(
24
+ Buy.quote({
25
+ originChainId: 1,
26
+ originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
27
+ destinationChainId: 10,
28
+ destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
29
+ buyAmountWei: toWei("1000000000"),
30
+ client: TEST_CLIENT,
31
+ }),
32
+ ).rejects.toThrowErrorMatchingInlineSnapshot(
33
+ `[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
34
+ );
35
+ });
36
+ });
37
+
38
+ describe("Bridge.Buy.prepare", () => {
39
+ it("should get a valid prepared quote", async () => {
40
+ const quote = await Buy.prepare({
41
+ originChainId: 1,
42
+ originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
43
+ destinationChainId: 10,
44
+ destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
45
+ buyAmountWei: toWei("0.01"),
46
+ sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
47
+ receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
48
+ client: TEST_CLIENT,
49
+ });
50
+
51
+ expect(quote).toBeDefined();
52
+ expect(quote.destinationAmount).toEqual(toWei("0.01"));
53
+ expect(quote.transactions).toBeDefined();
54
+ expect(quote.transactions.length).toBeGreaterThan(0);
55
+ expect(quote.intent).toBeDefined();
56
+ });
57
+
58
+ it("should surface any errors", async () => {
59
+ await expect(
60
+ Buy.prepare({
61
+ originChainId: 1,
62
+ originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
63
+ destinationChainId: 10,
64
+ destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
65
+ buyAmountWei: toWei("1000000000"),
66
+ sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
67
+ receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
68
+ client: TEST_CLIENT,
69
+ }),
70
+ ).rejects.toThrowErrorMatchingInlineSnapshot(
71
+ `[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
72
+ );
73
+ });
74
+ });
@@ -0,0 +1,267 @@
1
+ import type { Address as ox__Address } 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 { PreparedQuote, Quote } from "./types/Quote.js";
6
+
7
+ /**
8
+ * 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.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
13
+ *
14
+ * const quote = await Bridge.Buy.quote({
15
+ * originChainId: 1,
16
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
17
+ * destinationChainId: 10,
18
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
19
+ * buyAmountWei: toWei("0.01"),
20
+ * client: thirdwebClient,
21
+ * });
22
+ * ```
23
+ *
24
+ * This will return a quote that might look like:
25
+ * ```typescript
26
+ * {
27
+ * originAmount: 10000026098875381n,
28
+ * destinationAmount: 1000000000000000000n,
29
+ * blockNumber: 22026509n,
30
+ * timestamp: 1741730936680,
31
+ * estimatedExecutionTimeMs: 1000
32
+ * intent: {
33
+ * originChainId: 1,
34
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
35
+ * destinationChainId: 10,
36
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
37
+ * buyAmountWei: 1000000000000000000n
38
+ * }
39
+ * }
40
+ * ```
41
+ *
42
+ * The quote is an **estimate** for how much you would expect to pay for a specific buy. This quote is not guaranteed and you should use `Buy.prepare` to get a finalized quote with transaction data ready for execution.
43
+ * So why use `quote`? The quote function is sometimes slightly faster than `prepare`, and can be used before the user connects their wallet.
44
+ *
45
+ * You can access this functions input and output types with `Buy.quote.Options` and `Buy.quote.Result`, respectively.
46
+ *
47
+ * @param options - The options for the quote.
48
+ * @param options.originChainId - The chain ID of the origin token.
49
+ * @param options.originTokenAddress - The address of the origin token.
50
+ * @param options.destinationChainId - The chain ID of the destination token.
51
+ * @param options.destinationTokenAddress - The address of the destination token.
52
+ * @param options.buyAmountWei - The amount of the origin token to buy.
53
+ * @param options.client - Your thirdweb client.
54
+ *
55
+ * @returns A promise that resolves to a non-finalized quote for the requested buy.
56
+ *
57
+ * @throws Will throw an error if there is an issue fetching the quote.
58
+ * @bridge
59
+ * @beta
60
+ */
61
+ export async function quote(options: quote.Options): Promise<quote.Result> {
62
+ const {
63
+ originChainId,
64
+ originTokenAddress,
65
+ destinationChainId,
66
+ destinationTokenAddress,
67
+ buyAmountWei,
68
+ client,
69
+ } = options;
70
+
71
+ const clientFetch = getClientFetch(client);
72
+ const url = new URL(`${UNIVERSAL_BRIDGE_URL}/buy/quote`);
73
+ url.searchParams.set("originChainId", originChainId.toString());
74
+ url.searchParams.set("originTokenAddress", originTokenAddress);
75
+ url.searchParams.set("destinationChainId", destinationChainId.toString());
76
+ url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
77
+ url.searchParams.set("buyAmountWei", buyAmountWei.toString());
78
+
79
+ const response = await clientFetch(url.toString());
80
+ if (!response.ok) {
81
+ const errorJson = await response.json();
82
+ throw new Error(`${errorJson.code} | ${errorJson.message}`);
83
+ }
84
+
85
+ const { data }: { data: Quote } = await response.json();
86
+ return {
87
+ originAmount: BigInt(data.originAmount),
88
+ destinationAmount: BigInt(data.destinationAmount),
89
+ blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
90
+ timestamp: data.timestamp,
91
+ estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
92
+ intent: {
93
+ originChainId,
94
+ originTokenAddress,
95
+ destinationChainId,
96
+ destinationTokenAddress,
97
+ buyAmountWei,
98
+ },
99
+ };
100
+ }
101
+
102
+ export declare namespace quote {
103
+ type Options = {
104
+ originChainId: number;
105
+ originTokenAddress: ox__Address.Address;
106
+ destinationChainId: number;
107
+ destinationTokenAddress: ox__Address.Address;
108
+ buyAmountWei: bigint;
109
+ client: ThirdwebClient;
110
+ };
111
+
112
+ type Result = Quote & {
113
+ intent: {
114
+ originChainId: number;
115
+ originTokenAddress: ox__Address.Address;
116
+ destinationChainId: number;
117
+ destinationTokenAddress: ox__Address.Address;
118
+ buyAmountWei: bigint;
119
+ };
120
+ };
121
+ }
122
+
123
+ /**
124
+ * Prepares a **finalized** Universal Bridge quote for the provided buy request with transaction data. This function will return everything `quote` does, with the addition of a series of prepared transactions and the associated expiration timestamp.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
129
+ *
130
+ * const quote = await Bridge.Buy.prepare({
131
+ * originChainId: 1,
132
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
133
+ * destinationChainId: 10,
134
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
135
+ * buyAmountWei: toWei("0.01"),
136
+ * client: thirdwebClient,
137
+ * });
138
+ * ```
139
+ *
140
+ * This will return a quote that might look like:
141
+ * ```typescript
142
+ * {
143
+ * originAmount: 10000026098875381n,
144
+ * destinationAmount: 1000000000000000000n,
145
+ * blockNumber: 22026509n,
146
+ * timestamp: 1741730936680,
147
+ * estimatedExecutionTimeMs: 1000
148
+ * transactions: [
149
+ * {
150
+ * to: NATIVE_TOKEN_ADDRESS,
151
+ * value: 10000026098875381n,
152
+ * data: "0x",
153
+ * chainId: 10,
154
+ * type: "eip1559"
155
+ * }
156
+ * ],
157
+ * expiration: 1741730936680,
158
+ * intent: {
159
+ * originChainId: 1,
160
+ * originTokenAddress: NATIVE_TOKEN_ADDRESS,
161
+ * destinationChainId: 10,
162
+ * destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
163
+ * buyAmountWei: 1000000000000000000n
164
+ * }
165
+ * }
166
+ * ```
167
+ *
168
+ * ## Sending the transactions
169
+ * 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:
170
+ * - Approvals and other preparation transactions are not included in the transactions array.
171
+ * - 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.
172
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
173
+ *
174
+ * NOTE: To get the status of each transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
175
+ *
176
+ * You can access this functions input and output types with `Buy.prepare.Options` and `Buy.prepare.Result`, respectively.
177
+ *
178
+ * @param options - The options for the quote.
179
+ * @param options.originChainId - The chain ID of the origin token.
180
+ * @param options.originTokenAddress - The address of the origin token.
181
+ * @param options.destinationChainId - The chain ID of the destination token.
182
+ * @param options.destinationTokenAddress - The address of the destination token.
183
+ * @param options.buyAmountWei - The amount of the origin token to buy.
184
+ * @param options.sender - The address of the sender.
185
+ * @param options.receiver - The address of the recipient.
186
+ * @param options.client - Your thirdweb client.
187
+ *
188
+ * @returns A promise that resolves to a non-finalized quote for the requested buy.
189
+ *
190
+ * @throws Will throw an error if there is an issue fetching the quote.
191
+ * @bridge
192
+ * @beta
193
+ */
194
+ export async function prepare(
195
+ options: prepare.Options,
196
+ ): Promise<prepare.Result> {
197
+ const {
198
+ originChainId,
199
+ originTokenAddress,
200
+ destinationChainId,
201
+ destinationTokenAddress,
202
+ buyAmountWei,
203
+ sender,
204
+ receiver,
205
+ client,
206
+ } = options;
207
+
208
+ const clientFetch = getClientFetch(client);
209
+ const url = new URL(`${UNIVERSAL_BRIDGE_URL}/buy/prepare`);
210
+ url.searchParams.set("originChainId", originChainId.toString());
211
+ url.searchParams.set("originTokenAddress", originTokenAddress);
212
+ url.searchParams.set("destinationChainId", destinationChainId.toString());
213
+ url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
214
+ url.searchParams.set("buyAmountWei", buyAmountWei.toString());
215
+ url.searchParams.set("sender", sender);
216
+ url.searchParams.set("receiver", receiver);
217
+
218
+ const response = await clientFetch(url.toString());
219
+ if (!response.ok) {
220
+ const errorJson = await response.json();
221
+ throw new Error(`${errorJson.code} | ${errorJson.message}`);
222
+ }
223
+
224
+ const { data }: { data: PreparedQuote } = await response.json();
225
+ return {
226
+ originAmount: BigInt(data.originAmount),
227
+ destinationAmount: BigInt(data.destinationAmount),
228
+ blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
229
+ timestamp: data.timestamp,
230
+ estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
231
+ transactions: data.transactions.map((transaction) => ({
232
+ ...transaction,
233
+ value: transaction.value ? BigInt(transaction.value) : undefined,
234
+ })),
235
+ expiration: data.expiration,
236
+ intent: {
237
+ originChainId,
238
+ originTokenAddress,
239
+ destinationChainId,
240
+ destinationTokenAddress,
241
+ buyAmountWei,
242
+ },
243
+ };
244
+ }
245
+
246
+ export declare namespace prepare {
247
+ type Options = {
248
+ originChainId: number;
249
+ originTokenAddress: ox__Address.Address;
250
+ destinationChainId: number;
251
+ destinationTokenAddress: ox__Address.Address;
252
+ buyAmountWei: bigint;
253
+ sender: ox__Address.Address;
254
+ receiver: ox__Address.Address;
255
+ client: ThirdwebClient;
256
+ };
257
+
258
+ type Result = PreparedQuote & {
259
+ intent: {
260
+ originChainId: number;
261
+ originTokenAddress: ox__Address.Address;
262
+ destinationChainId: number;
263
+ destinationTokenAddress: ox__Address.Address;
264
+ buyAmountWei: bigint;
265
+ };
266
+ };
267
+ }