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.
- package/dist/cjs/contract/deployment/deploy-with-abi.js +17 -6
- package/dist/cjs/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/cjs/exports/deploys.js +2 -2
- package/dist/cjs/exports/deploys.js.map +1 -1
- package/dist/cjs/exports/extensions/marketplace.js +14 -3
- package/dist/cjs/exports/extensions/marketplace.js.map +1 -1
- package/dist/cjs/exports/react.js +4 -2
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/exports/react.native.js +3 -1
- package/dist/cjs/exports/react.native.js.map +1 -1
- package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js +18 -2
- package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
- package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js +21 -4
- package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
- package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js +18 -2
- package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js +18 -2
- package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -3
- package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js +27 -8
- package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -2
- package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
- package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js +18 -2
- package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-published.js +6 -1
- package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js +110 -23
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/cjs/gas/fee-data.js +2 -2
- package/dist/cjs/gas/fee-data.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAdminAccount.js +23 -0
- package/dist/cjs/react/core/hooks/wallets/useAdminAccount.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +2 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js +7 -5
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
- package/dist/cjs/utils/abi/normalizeFunctionParams.js +6 -6
- package/dist/cjs/utils/abi/normalizeFunctionParams.js.map +1 -1
- package/dist/cjs/utils/any-evm/deploy-metadata.js +2 -1
- package/dist/cjs/utils/any-evm/deploy-metadata.js.map +1 -1
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +2 -2
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/cjs/utils/contract/parse-abi-params.js +3 -0
- package/dist/cjs/utils/contract/parse-abi-params.js.map +1 -1
- package/dist/cjs/utils/extensions/convert-erc20-amount.js +21 -16
- package/dist/cjs/utils/extensions/convert-erc20-amount.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/in-app-account.js +0 -1
- package/dist/cjs/wallets/in-app/web/lib/in-app-account.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +3 -0
- package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/esm/contract/deployment/deploy-with-abi.js +17 -6
- package/dist/esm/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/esm/exports/deploys.js +1 -1
- package/dist/esm/exports/deploys.js.map +1 -1
- package/dist/esm/exports/extensions/marketplace.js +9 -8
- package/dist/esm/exports/extensions/marketplace.js.map +1 -1
- package/dist/esm/exports/react.js +1 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/react.native.js +1 -0
- package/dist/esm/exports/react.native.js.map +1 -1
- package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js +17 -2
- package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
- package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js +20 -4
- package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
- package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js +17 -2
- package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js +17 -2
- package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -4
- package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js +26 -8
- package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -3
- package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
- package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js +17 -2
- package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-published.js +6 -1
- package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/esm/extensions/prebuilts/get-required-transactions.js +108 -22
- package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/esm/gas/fee-data.js +2 -2
- package/dist/esm/gas/fee-data.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAdminAccount.js +20 -0
- package/dist/esm/react/core/hooks/wallets/useAdminAccount.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +2 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js +7 -5
- package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
- package/dist/esm/utils/abi/normalizeFunctionParams.js +6 -6
- package/dist/esm/utils/abi/normalizeFunctionParams.js.map +1 -1
- package/dist/esm/utils/any-evm/deploy-metadata.js +2 -1
- package/dist/esm/utils/any-evm/deploy-metadata.js.map +1 -1
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +1 -1
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/esm/utils/contract/parse-abi-params.js +3 -0
- package/dist/esm/utils/contract/parse-abi-params.js.map +1 -1
- package/dist/esm/utils/extensions/convert-erc20-amount.js +21 -16
- package/dist/esm/utils/extensions/convert-erc20-amount.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/in-app-account.js +0 -1
- package/dist/esm/wallets/in-app/web/lib/in-app-account.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +3 -0
- package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/types/contract/deployment/deploy-with-abi.d.ts.map +1 -1
- package/dist/types/exports/deploys.d.ts +1 -1
- package/dist/types/exports/deploys.d.ts.map +1 -1
- package/dist/types/exports/extensions/marketplace.d.ts +9 -8
- package/dist/types/exports/extensions/marketplace.d.ts.map +1 -1
- package/dist/types/exports/react.d.ts +1 -0
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +1 -0
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts +15 -2
- package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts +13 -0
- package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts +13 -0
- package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts +15 -2
- package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts +15 -2
- package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts +13 -0
- package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts +13 -0
- package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts.map +1 -1
- package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts +13 -0
- package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/get-required-transactions.d.ts +8 -8
- package/dist/types/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAdminAccount.d.ts +7 -0
- package/dist/types/react/core/hooks/wallets/useAdminAccount.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/SignatureScreen.d.ts.map +1 -1
- package/dist/types/utils/abi/normalizeFunctionParams.d.ts.map +1 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts +27 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
- package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts +1 -1
- package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
- package/dist/types/utils/contract/parse-abi-params.d.ts.map +1 -1
- package/dist/types/utils/extensions/convert-erc20-amount.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/in-app-account.d.ts.map +1 -1
- package/dist/types/wallets/interfaces/wallet.d.ts +5 -0
- package/dist/types/wallets/interfaces/wallet.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/contract/deployment/deploy-with-abi.ts +19 -6
- package/src/exports/deploys.ts +1 -1
- package/src/exports/extensions/marketplace.ts +10 -0
- package/src/exports/react.native.ts +1 -0
- package/src/exports/react.ts +1 -0
- package/src/extensions/marketplace/direct-listings/read/getListing.ts +19 -7
- package/src/extensions/marketplace/direct-listings/write/buyFromListing.ts +23 -4
- package/src/extensions/marketplace/direct-listings/write/createListing.ts +18 -2
- package/src/extensions/marketplace/english-auctions/read/getAuction.ts +19 -7
- package/src/extensions/marketplace/english-auctions/read/getWinningBid.ts +21 -8
- package/src/extensions/marketplace/english-auctions/write/bidInAuction.ts +29 -8
- package/src/extensions/marketplace/english-auctions/write/cancelAuction.ts +25 -3
- package/src/extensions/marketplace/english-auctions/write/createAuction.ts +18 -2
- package/src/extensions/prebuilts/deploy-published.ts +7 -1
- package/src/extensions/prebuilts/get-required-transactions.test.ts +13 -11
- package/src/extensions/prebuilts/get-required-transactions.ts +149 -32
- package/src/gas/fee-data.ts +5 -1
- package/src/react/core/hooks/wallets/useAdminAccount.ts +25 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +2 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/usePayerSetup.tsx +0 -2
- package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.tsx +9 -5
- package/src/utils/abi/normalizeFunctionParams.ts +24 -19
- package/src/utils/any-evm/deploy-metadata.ts +33 -2
- package/src/utils/any-evm/get-init-bytecode-with-salt.ts +2 -2
- package/src/utils/contract/parse-abi-params.ts +3 -0
- package/src/utils/extensions/convert-erc20-amount.ts +23 -17
- package/src/version.ts +1 -1
- package/src/wallets/in-app/web/lib/in-app-account.ts +0 -1
- package/src/wallets/interfaces/wallet.ts +6 -0
- 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
|
50
|
+
const wallet = useActiveWallet();
|
51
|
+
const adminWallet = useAdminWallet();
|
50
52
|
const activeAccount = useActiveAccount();
|
51
|
-
const siweAuth = useSiweAuth(
|
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 (
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
);
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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:
|
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 {
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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.
|
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;
|