thirdweb 5.55.0 → 5.56.0-nightly-07b949dd8c07ffdeda40a5549c31ad4b09abbbf1-20240916000437

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 (193) hide show
  1. package/dist/cjs/contract/deployment/deploy-with-abi.js +17 -6
  2. package/dist/cjs/contract/deployment/deploy-with-abi.js.map +1 -1
  3. package/dist/cjs/exports/deploys.js +2 -2
  4. package/dist/cjs/exports/deploys.js.map +1 -1
  5. package/dist/cjs/exports/extensions/marketplace.js +14 -3
  6. package/dist/cjs/exports/extensions/marketplace.js.map +1 -1
  7. package/dist/cjs/exports/react.js +4 -2
  8. package/dist/cjs/exports/react.js.map +1 -1
  9. package/dist/cjs/exports/react.native.js +3 -1
  10. package/dist/cjs/exports/react.native.js.map +1 -1
  11. package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js +18 -2
  12. package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
  13. package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js +21 -4
  14. package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
  15. package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js +18 -2
  16. package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
  17. package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js +18 -2
  18. package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
  19. package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -3
  20. package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
  21. package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js +27 -8
  22. package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
  23. package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -2
  24. package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
  25. package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js +18 -2
  26. package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
  27. package/dist/cjs/extensions/prebuilts/deploy-published.js +6 -1
  28. package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
  29. package/dist/cjs/extensions/prebuilts/get-required-transactions.js +110 -23
  30. package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
  31. package/dist/cjs/gas/fee-data.js +2 -2
  32. package/dist/cjs/gas/fee-data.js.map +1 -1
  33. package/dist/cjs/react/core/hooks/wallets/useAdminAccount.js +23 -0
  34. package/dist/cjs/react/core/hooks/wallets/useAdminAccount.js.map +1 -0
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +2 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js +0 -1
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js +7 -5
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
  43. package/dist/cjs/utils/abi/normalizeFunctionParams.js +6 -6
  44. package/dist/cjs/utils/abi/normalizeFunctionParams.js.map +1 -1
  45. package/dist/cjs/utils/any-evm/deploy-metadata.js +2 -1
  46. package/dist/cjs/utils/any-evm/deploy-metadata.js.map +1 -1
  47. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +2 -2
  48. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  49. package/dist/cjs/utils/contract/parse-abi-params.js +3 -0
  50. package/dist/cjs/utils/contract/parse-abi-params.js.map +1 -1
  51. package/dist/cjs/utils/extensions/convert-erc20-amount.js +21 -16
  52. package/dist/cjs/utils/extensions/convert-erc20-amount.js.map +1 -1
  53. package/dist/cjs/version.js +1 -1
  54. package/dist/cjs/version.js.map +1 -1
  55. package/dist/cjs/wallets/in-app/web/lib/in-app-account.js +0 -1
  56. package/dist/cjs/wallets/in-app/web/lib/in-app-account.js.map +1 -1
  57. package/dist/cjs/wallets/smart/smart-wallet.js +3 -0
  58. package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
  59. package/dist/esm/contract/deployment/deploy-with-abi.js +17 -6
  60. package/dist/esm/contract/deployment/deploy-with-abi.js.map +1 -1
  61. package/dist/esm/exports/deploys.js +1 -1
  62. package/dist/esm/exports/deploys.js.map +1 -1
  63. package/dist/esm/exports/extensions/marketplace.js +9 -8
  64. package/dist/esm/exports/extensions/marketplace.js.map +1 -1
  65. package/dist/esm/exports/react.js +1 -0
  66. package/dist/esm/exports/react.js.map +1 -1
  67. package/dist/esm/exports/react.native.js +1 -0
  68. package/dist/esm/exports/react.native.js.map +1 -1
  69. package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js +17 -2
  70. package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
  71. package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js +20 -4
  72. package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
  73. package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js +17 -2
  74. package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
  75. package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js +17 -2
  76. package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
  77. package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -4
  78. package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
  79. package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js +26 -8
  80. package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
  81. package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -3
  82. package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
  83. package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js +17 -2
  84. package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
  85. package/dist/esm/extensions/prebuilts/deploy-published.js +6 -1
  86. package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
  87. package/dist/esm/extensions/prebuilts/get-required-transactions.js +108 -22
  88. package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
  89. package/dist/esm/gas/fee-data.js +2 -2
  90. package/dist/esm/gas/fee-data.js.map +1 -1
  91. package/dist/esm/react/core/hooks/wallets/useAdminAccount.js +20 -0
  92. package/dist/esm/react/core/hooks/wallets/useAdminAccount.js.map +1 -0
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +2 -1
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js +0 -1
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js.map +1 -1
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js +7 -5
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
  101. package/dist/esm/utils/abi/normalizeFunctionParams.js +6 -6
  102. package/dist/esm/utils/abi/normalizeFunctionParams.js.map +1 -1
  103. package/dist/esm/utils/any-evm/deploy-metadata.js +2 -1
  104. package/dist/esm/utils/any-evm/deploy-metadata.js.map +1 -1
  105. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +1 -1
  106. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  107. package/dist/esm/utils/contract/parse-abi-params.js +3 -0
  108. package/dist/esm/utils/contract/parse-abi-params.js.map +1 -1
  109. package/dist/esm/utils/extensions/convert-erc20-amount.js +21 -16
  110. package/dist/esm/utils/extensions/convert-erc20-amount.js.map +1 -1
  111. package/dist/esm/version.js +1 -1
  112. package/dist/esm/version.js.map +1 -1
  113. package/dist/esm/wallets/in-app/web/lib/in-app-account.js +0 -1
  114. package/dist/esm/wallets/in-app/web/lib/in-app-account.js.map +1 -1
  115. package/dist/esm/wallets/smart/smart-wallet.js +3 -0
  116. package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
  117. package/dist/types/contract/deployment/deploy-with-abi.d.ts.map +1 -1
  118. package/dist/types/exports/deploys.d.ts +1 -1
  119. package/dist/types/exports/deploys.d.ts.map +1 -1
  120. package/dist/types/exports/extensions/marketplace.d.ts +9 -8
  121. package/dist/types/exports/extensions/marketplace.d.ts.map +1 -1
  122. package/dist/types/exports/react.d.ts +1 -0
  123. package/dist/types/exports/react.d.ts.map +1 -1
  124. package/dist/types/exports/react.native.d.ts +1 -0
  125. package/dist/types/exports/react.native.d.ts.map +1 -1
  126. package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts +15 -2
  127. package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts.map +1 -1
  128. package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts +13 -0
  129. package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts.map +1 -1
  130. package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts +13 -0
  131. package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts.map +1 -1
  132. package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts +15 -2
  133. package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts.map +1 -1
  134. package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts +15 -2
  135. package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts.map +1 -1
  136. package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts +13 -0
  137. package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts.map +1 -1
  138. package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts +13 -0
  139. package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts.map +1 -1
  140. package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts +13 -0
  141. package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts.map +1 -1
  142. package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
  143. package/dist/types/extensions/prebuilts/get-required-transactions.d.ts +8 -8
  144. package/dist/types/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
  145. package/dist/types/react/core/hooks/wallets/useAdminAccount.d.ts +7 -0
  146. package/dist/types/react/core/hooks/wallets/useAdminAccount.d.ts.map +1 -0
  147. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.d.ts.map +1 -1
  148. package/dist/types/react/web/ui/ConnectWallet/screens/SignatureScreen.d.ts.map +1 -1
  149. package/dist/types/utils/abi/normalizeFunctionParams.d.ts.map +1 -1
  150. package/dist/types/utils/any-evm/deploy-metadata.d.ts +27 -1
  151. package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
  152. package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts +1 -1
  153. package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
  154. package/dist/types/utils/contract/parse-abi-params.d.ts.map +1 -1
  155. package/dist/types/utils/extensions/convert-erc20-amount.d.ts.map +1 -1
  156. package/dist/types/version.d.ts +1 -1
  157. package/dist/types/version.d.ts.map +1 -1
  158. package/dist/types/wallets/in-app/web/lib/in-app-account.d.ts.map +1 -1
  159. package/dist/types/wallets/interfaces/wallet.d.ts +5 -0
  160. package/dist/types/wallets/interfaces/wallet.d.ts.map +1 -1
  161. package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
  162. package/package.json +2 -2
  163. package/src/contract/deployment/deploy-with-abi.ts +19 -6
  164. package/src/exports/deploys.ts +1 -1
  165. package/src/exports/extensions/marketplace.ts +10 -0
  166. package/src/exports/react.native.ts +1 -0
  167. package/src/exports/react.ts +1 -0
  168. package/src/extensions/marketplace/direct-listings/read/getListing.ts +19 -7
  169. package/src/extensions/marketplace/direct-listings/write/buyFromListing.ts +23 -4
  170. package/src/extensions/marketplace/direct-listings/write/createListing.ts +18 -2
  171. package/src/extensions/marketplace/english-auctions/read/getAuction.ts +19 -7
  172. package/src/extensions/marketplace/english-auctions/read/getWinningBid.ts +21 -8
  173. package/src/extensions/marketplace/english-auctions/write/bidInAuction.ts +29 -8
  174. package/src/extensions/marketplace/english-auctions/write/cancelAuction.ts +25 -3
  175. package/src/extensions/marketplace/english-auctions/write/createAuction.ts +18 -2
  176. package/src/extensions/prebuilts/deploy-published.ts +7 -1
  177. package/src/extensions/prebuilts/get-required-transactions.test.ts +13 -11
  178. package/src/extensions/prebuilts/get-required-transactions.ts +149 -32
  179. package/src/gas/fee-data.ts +5 -1
  180. package/src/react/core/hooks/wallets/useAdminAccount.ts +25 -0
  181. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +2 -1
  182. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +1 -1
  183. package/src/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.tsx +0 -2
  184. package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.tsx +9 -5
  185. package/src/utils/abi/normalizeFunctionParams.ts +24 -19
  186. package/src/utils/any-evm/deploy-metadata.ts +33 -2
  187. package/src/utils/any-evm/get-init-bytecode-with-salt.ts +2 -2
  188. package/src/utils/contract/parse-abi-params.ts +3 -0
  189. package/src/utils/extensions/convert-erc20-amount.ts +23 -17
  190. package/src/version.ts +1 -1
  191. package/src/wallets/in-app/web/lib/in-app-account.ts +0 -1
  192. package/src/wallets/interfaces/wallet.ts +6 -0
  193. package/src/wallets/smart/smart-wallet.ts +3 -0
@@ -13,6 +13,7 @@ import { useSiweAuth } from "../../../../core/hooks/auth/useSiweAuth.js";
13
13
  import type { ConnectButtonProps } from "../../../../core/hooks/connection/ConnectButtonProps.js";
14
14
  import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
15
15
  import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
16
+ import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminAccount.js";
16
17
  import { useDisconnect } from "../../../../core/hooks/wallets/useDisconnect.js";
17
18
  import { wait } from "../../../../core/utils/wait.js";
18
19
  import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
@@ -46,12 +47,12 @@ export const SignatureScreen: React.FC<{
46
47
  connectLocale,
47
48
  } = props;
48
49
 
49
- const activeWallet = useActiveWallet();
50
+ const wallet = useActiveWallet();
51
+ const adminWallet = useAdminWallet();
50
52
  const activeAccount = useActiveAccount();
51
- const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
53
+ const siweAuth = useSiweAuth(wallet, activeAccount, props.auth);
52
54
  const [status, setStatus] = useState<Status>("idle");
53
55
  const { disconnect } = useDisconnect();
54
- const wallet = useActiveWallet();
55
56
  const locale = connectLocale.signatureScreen;
56
57
 
57
58
  const signIn = useCallback(async () => {
@@ -66,12 +67,15 @@ export const SignatureScreen: React.FC<{
66
67
  }
67
68
  }, [onDone, siweAuth]);
68
69
 
69
- // this should not happen
70
70
  if (!wallet) {
71
71
  return <LoadingScreen />;
72
72
  }
73
73
 
74
- if (wallet.id === "inApp" || wallet.id === "embedded") {
74
+ if (
75
+ wallet.id === "inApp" ||
76
+ wallet.id === "embedded" ||
77
+ (wallet.id === "smart" && adminWallet?.id === "inApp")
78
+ ) {
75
79
  return (
76
80
  <HeadlessSignIn
77
81
  signIn={signIn}
@@ -1,4 +1,5 @@
1
1
  import type { AbiConstructor, AbiFunction } from "abitype";
2
+ import { parseAbiParams } from "../contract/parse-abi-params.js";
2
3
 
3
4
  export function normalizeFunctionParams(
4
5
  abiFunction: AbiFunction | AbiConstructor | undefined,
@@ -7,23 +8,27 @@ export function normalizeFunctionParams(
7
8
  if (!abiFunction) {
8
9
  return [];
9
10
  }
10
- if (abiFunction.inputs?.length !== Object.keys(params).length) {
11
- throw new Error(
12
- `Expected ${abiFunction.inputs?.length || 0} parameters, but got ${Object.keys(params).length}`,
13
- );
14
- }
15
- return abiFunction.inputs.map((input, index) => {
16
- const value = input.name;
17
- if (value === undefined) {
18
- throw new Error(
19
- `Missing named parameter for ${"name" in abiFunction ? abiFunction.name : "constructor"} at index ${index}`,
20
- );
21
- }
22
- const valueWithoutUnderscore = value.replace(/^_+/, "");
23
- const normalizedValue = params[value] ?? params[valueWithoutUnderscore]; // handle _name, _symbol, etc passed without underscore in the keys
24
- if (normalizedValue === undefined) {
25
- throw new Error(`Missing value for parameter ${value} at index ${index}`);
26
- }
27
- return normalizedValue;
28
- });
11
+
12
+ return parseAbiParams(
13
+ abiFunction.inputs.map((i) => i.type),
14
+ abiFunction.inputs.map((input, index) => {
15
+ const value = input.name;
16
+ if (value === undefined) {
17
+ throw new Error(
18
+ `Missing named parameter for ${"name" in abiFunction ? abiFunction.name : "constructor"} at index ${index}`,
19
+ );
20
+ }
21
+ const valueWithoutUnderscore = value.replace(/^_+/, "");
22
+ const normalizedValue =
23
+ valueWithoutUnderscore in params
24
+ ? params[valueWithoutUnderscore]
25
+ : params[value]; // handle _name, _symbol, etc passed without underscore in the keys
26
+ if (normalizedValue === undefined) {
27
+ throw new Error(
28
+ `Missing value for parameter ${value} at index ${index}`,
29
+ );
30
+ }
31
+ return normalizedValue;
32
+ }),
33
+ );
29
34
  }
@@ -48,6 +48,7 @@ export async function fetchDeployMetadata(
48
48
  return {
49
49
  ...rawMeta,
50
50
  ...parsedMeta,
51
+ version: rawMeta.version,
51
52
  bytecode: deployBytecode,
52
53
  };
53
54
  }
@@ -69,7 +70,7 @@ async function fetchAndParseCompilerMetadata(
69
70
  `Could not resolve metadata for contract at ${options.uri}`,
70
71
  );
71
72
  }
72
- return formatCompilerMetadata(metadata);
73
+ return { ...metadata, ...formatCompilerMetadata(metadata) };
73
74
  }
74
75
 
75
76
  // types
@@ -87,7 +88,37 @@ type RawCompilerMetadata = {
87
88
  type ParsedCompilerMetadata = {
88
89
  name: string;
89
90
  abi: Abi;
90
- metadata: Record<string, unknown>;
91
+ metadata: {
92
+ compiler: {
93
+ version: string;
94
+ };
95
+ language: string;
96
+ output: {
97
+ abi: Abi;
98
+ devdoc: Record<string, unknown>;
99
+ userdoc: Record<string, unknown>;
100
+ };
101
+ settings: {
102
+ compilationTarget: Record<string, unknown>;
103
+ evmVersion: string;
104
+ libraries: Record<string, string>;
105
+ optimizer: Record<string, unknown>;
106
+ remappings: string[];
107
+ };
108
+ sources: Record<
109
+ string,
110
+ { keccak256: string } & (
111
+ | {
112
+ content: string;
113
+ }
114
+ | {
115
+ urls: string[];
116
+ license?: string;
117
+ }
118
+ )
119
+ >;
120
+ [key: string]: unknown;
121
+ };
91
122
  info: {
92
123
  title?: string;
93
124
  author?: string;
@@ -1,6 +1,6 @@
1
- import { type Hex, encodePacked } from "viem";
1
+ import { encodePacked } from "viem/utils";
2
2
  import { ensureBytecodePrefix } from "../bytecode/prefix.js";
3
- import { uint8ArrayToHex } from "../encoding/hex.js";
3
+ import { type Hex, uint8ArrayToHex } from "../encoding/hex.js";
4
4
  import { getSaltHash } from "./get-salt-hash.js";
5
5
  import { keccakId } from "./keccak-id.js";
6
6
 
@@ -79,6 +79,9 @@ export function parseAbiParams(
79
79
  return value;
80
80
  }
81
81
  if (type.startsWith("uint") || type.startsWith("int")) {
82
+ if (typeof value === "bigint") {
83
+ return value;
84
+ }
82
85
  if (typeof value !== "string" && typeof value !== "number") {
83
86
  throw new Error(`Cannot convert type ${typeof value} to BigInt`);
84
87
  }
@@ -22,24 +22,30 @@ export async function convertErc20Amount(
22
22
  } & AmountOrAmountInWei
23
23
  >,
24
24
  ): Promise<bigint> {
25
- if ("amount" in options) {
26
- // for native token, we know decimals are 18
27
- if (!options.erc20Address || isNativeTokenAddress(options.erc20Address)) {
28
- return toUnits(options.amount.toString(), 18);
25
+ try {
26
+ if ("amount" in options) {
27
+ // for native token, we know decimals are 18
28
+ if (!options.erc20Address || isNativeTokenAddress(options.erc20Address)) {
29
+ return toUnits(options.amount.toString(), 18);
30
+ }
31
+ // otherwise get the decimals of the currency
32
+ const currencyContract = getContract({
33
+ client: options.client,
34
+ chain: options.chain,
35
+ address: options.erc20Address,
36
+ });
37
+ const { decimals } = await import(
38
+ "../../extensions/erc20/read/decimals.js"
39
+ );
40
+ const currencyDecimals = await decimals({
41
+ contract: currencyContract,
42
+ });
43
+ return toUnits(options.amount.toString(), currencyDecimals);
29
44
  }
30
- // otherwise get the decimals of the currency
31
- const currencyContract = getContract({
32
- client: options.client,
33
- chain: options.chain,
34
- address: options.erc20Address,
35
- });
36
- const { decimals } = await import(
37
- "../../extensions/erc20/read/decimals.js"
45
+ return options.amountInWei;
46
+ } catch (e) {
47
+ throw new Error(
48
+ `Failed to convert ERC20 amount for token: ${options.erc20Address}: ${e}`,
38
49
  );
39
- const currencyDecimals = await decimals({
40
- contract: currencyContract,
41
- });
42
- return toUnits(options.amount.toString(), currencyDecimals);
43
50
  }
44
- return options.amountInWei;
45
51
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.55.0";
1
+ export const version = "5.56.0-nightly-07b949dd8c07ffdeda40a5549c31ad4b09abbbf1-20240916000437";
@@ -305,7 +305,6 @@ export class IFrameWallet {
305
305
  return signedMessage as Hex;
306
306
  },
307
307
  async signTypedData(_typedData) {
308
- console.log("signTypedData", _typedData);
309
308
  const parsedTypedData = parseTypedData(_typedData);
310
309
  // deleting EIP712 Domain as it results in ambiguous primary type on some cases
311
310
  // this happens when going from viem to ethers via the iframe
@@ -141,6 +141,12 @@ export type Wallet<TWalletId extends WalletId = WalletId> = {
141
141
  * Can be used to execute any pre-connection actions like showing a modal, etc.
142
142
  */
143
143
  onConnectRequested?: () => Promise<void>;
144
+
145
+ /**
146
+ * Get the admin account of this wallet
147
+ * This is useful for smart wallets to get the underlying personal account
148
+ */
149
+ getAdminAccount?: () => Account | undefined;
144
150
  };
145
151
 
146
152
  /**
@@ -102,6 +102,7 @@ export function smartWallet(
102
102
  ): Wallet<"smart"> {
103
103
  const emitter = createWalletEmitter<"smart">();
104
104
  let account: Account | undefined = undefined;
105
+ let adminAccount: Account | undefined = undefined;
105
106
  let chain: Chain | undefined = undefined;
106
107
  let lastConnectOptions: WalletConnectionOption<"smart"> | undefined;
107
108
 
@@ -118,6 +119,7 @@ export function smartWallet(
118
119
  },
119
120
  getConfig: () => createOptions,
120
121
  getAccount: () => account,
122
+ getAdminAccount: () => adminAccount,
121
123
  autoConnect: async (options) => {
122
124
  const { connectSmartWallet } = await import("./index.js");
123
125
  const [connectedAccount, connectedChain] = await connectSmartWallet(
@@ -145,6 +147,7 @@ export function smartWallet(
145
147
  createOptions,
146
148
  );
147
149
  // set the states
150
+ adminAccount = options.personalAccount;
148
151
  lastConnectOptions = options;
149
152
  account = connectedAccount;
150
153
  chain = connectedChain;