thirdweb 5.102.3-nightly-f44d6ba2827d7d7391425a5ddb2d49cafdc934bb-20250531000435 → 5.102.4-nightly-283dc289fca1ad16a9296e610d293b73a7123709-20250602000433
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bridge/Token.js +153 -0
- package/dist/cjs/bridge/Token.js.map +1 -0
- package/dist/cjs/bridge/index.js +3 -1
- package/dist/cjs/bridge/index.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFTs.js +9 -2
- package/dist/cjs/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/cjs/extensions/erc721/read/getNFTs.js +9 -2
- package/dist/cjs/extensions/erc721/read/getNFTs.js.map +1 -1
- package/dist/cjs/insight/get-tokens.js +5 -6
- package/dist/cjs/insight/get-tokens.js.map +1 -1
- package/dist/cjs/pay/convert/cryptoToFiat.js +6 -38
- package/dist/cjs/pay/convert/cryptoToFiat.js.map +1 -1
- package/dist/cjs/pay/convert/fiatToCrypto.js +6 -38
- package/dist/cjs/pay/convert/fiatToCrypto.js.map +1 -1
- package/dist/cjs/pay/convert/get-token.js +19 -0
- package/dist/cjs/pay/convert/get-token.js.map +1 -0
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +2 -2
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/core/utils/wallet.js +0 -48
- package/dist/cjs/react/core/utils/wallet.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectedModal.js +5 -5
- package/dist/cjs/react/native/ui/connect/ConnectedModal.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +7 -7
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +28 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +2 -2
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/manager/index.js +1 -2
- package/dist/cjs/wallets/manager/index.js.map +1 -1
- package/dist/cjs/wallets/smart/is-smart-wallet.js +62 -5
- package/dist/cjs/wallets/smart/is-smart-wallet.js.map +1 -1
- package/dist/esm/bridge/Token.js +150 -0
- package/dist/esm/bridge/Token.js.map +1 -0
- package/dist/esm/bridge/index.js +1 -0
- package/dist/esm/bridge/index.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFTs.js +9 -2
- package/dist/esm/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/esm/extensions/erc721/read/getNFTs.js +9 -2
- package/dist/esm/extensions/erc721/read/getNFTs.js.map +1 -1
- package/dist/esm/insight/get-tokens.js +5 -6
- package/dist/esm/insight/get-tokens.js.map +1 -1
- package/dist/esm/pay/convert/cryptoToFiat.js +6 -38
- package/dist/esm/pay/convert/cryptoToFiat.js.map +1 -1
- package/dist/esm/pay/convert/fiatToCrypto.js +6 -38
- package/dist/esm/pay/convert/fiatToCrypto.js.map +1 -1
- package/dist/esm/pay/convert/get-token.js +16 -0
- package/dist/esm/pay/convert/get-token.js.map +1 -0
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/core/utils/wallet.js +0 -47
- package/dist/esm/react/core/utils/wallet.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectedModal.js +5 -5
- package/dist/esm/react/native/ui/connect/ConnectedModal.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +7 -7
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +28 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +1 -1
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/manager/index.js +1 -2
- package/dist/esm/wallets/manager/index.js.map +1 -1
- package/dist/esm/wallets/smart/is-smart-wallet.js +61 -5
- package/dist/esm/wallets/smart/is-smart-wallet.js.map +1 -1
- package/dist/types/bridge/Token.d.ts +140 -0
- package/dist/types/bridge/Token.d.ts.map +1 -0
- package/dist/types/bridge/index.d.ts +1 -0
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getNFTs.d.ts.map +1 -1
- package/dist/types/insight/get-tokens.d.ts +2 -2
- package/dist/types/insight/get-tokens.d.ts.map +1 -1
- package/dist/types/pay/convert/cryptoToFiat.d.ts.map +1 -1
- package/dist/types/pay/convert/fiatToCrypto.d.ts.map +1 -1
- package/dist/types/pay/convert/get-token.d.ts +3 -0
- package/dist/types/pay/convert/get-token.d.ts.map +1 -0
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/core/utils/wallet.d.ts +1 -5
- package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/ConnectedModal.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/manager/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/is-smart-wallet.d.ts +5 -1
- package/dist/types/wallets/smart/is-smart-wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Token.test.ts +90 -0
- package/src/bridge/Token.ts +184 -0
- package/src/bridge/index.ts +1 -0
- package/src/extensions/erc1155/read/getNFTs.ts +8 -2
- package/src/extensions/erc721/read/getNFTs.ts +8 -2
- package/src/insight/get-tokens.ts +13 -11
- package/src/pay/convert/cryptoToFiat.test.ts +1 -18
- package/src/pay/convert/cryptoToFiat.ts +6 -52
- package/src/pay/convert/fiatToCrypto.test.ts +1 -18
- package/src/pay/convert/fiatToCrypto.ts +6 -51
- package/src/pay/convert/get-token.ts +24 -0
- package/src/react/core/hooks/transaction/useSendTransaction.ts +1 -1
- package/src/react/core/utils/wallet.ts +1 -49
- package/src/react/native/ui/connect/ConnectedModal.tsx +5 -5
- package/src/react/web/ui/ConnectWallet/Details.tsx +7 -7
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +32 -8
- package/src/react/web/ui/TransactionButton/DepositScreen.tsx +1 -1
- package/src/version.ts +1 -1
- package/src/wallets/manager/index.ts +1 -2
- package/src/wallets/smart/is-smart-wallet.test.ts +163 -1
- package/src/wallets/smart/is-smart-wallet.ts +62 -5
- package/dist/cjs/react/core/utils/isSmartWallet.js +0 -12
- package/dist/cjs/react/core/utils/isSmartWallet.js.map +0 -1
- package/dist/cjs/wallets/smart/get-smart-wallet-config.js +0 -23
- package/dist/cjs/wallets/smart/get-smart-wallet-config.js.map +0 -1
- package/dist/esm/react/core/utils/isSmartWallet.js +0 -9
- package/dist/esm/react/core/utils/isSmartWallet.js.map +0 -1
- package/dist/esm/wallets/smart/get-smart-wallet-config.js +0 -20
- package/dist/esm/wallets/smart/get-smart-wallet-config.js.map +0 -1
- package/dist/types/react/core/utils/isSmartWallet.d.ts +0 -3
- package/dist/types/react/core/utils/isSmartWallet.d.ts.map +0 -1
- package/dist/types/wallets/smart/get-smart-wallet-config.d.ts +0 -13
- package/dist/types/wallets/smart/get-smart-wallet-config.d.ts.map +0 -1
- package/src/react/core/utils/isSmartWallet.test.ts +0 -19
- package/src/react/core/utils/isSmartWallet.ts +0 -12
- package/src/react/core/utils/wallet.test.ts +0 -77
- package/src/wallets/smart/get-smart-wallet-config.test.ts +0 -67
- package/src/wallets/smart/get-smart-wallet-config.ts +0 -24
@@ -1,77 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import type { Wallet } from "../../../wallets/interfaces/wallet";
|
3
|
-
import { hasSponsoredTransactionsEnabled } from "./wallet";
|
4
|
-
|
5
|
-
describe("hasSponsoredTransactionsEnabled", () => {
|
6
|
-
it("should return false for undefined wallet", () => {
|
7
|
-
expect(hasSponsoredTransactionsEnabled(undefined)).toBe(false);
|
8
|
-
});
|
9
|
-
|
10
|
-
it("should handle smart wallet with sponsorGas config", () => {
|
11
|
-
const mockSmartWallet = {
|
12
|
-
id: "smart",
|
13
|
-
getConfig: () => ({ sponsorGas: true }),
|
14
|
-
} as Wallet;
|
15
|
-
expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
|
16
|
-
|
17
|
-
const mockSmartWalletDisabled = {
|
18
|
-
id: "smart",
|
19
|
-
getConfig: () => ({ sponsorGas: false }),
|
20
|
-
} as Wallet;
|
21
|
-
expect(hasSponsoredTransactionsEnabled(mockSmartWalletDisabled)).toBe(
|
22
|
-
false,
|
23
|
-
);
|
24
|
-
});
|
25
|
-
|
26
|
-
it("should handle smart wallet with gasless config", () => {
|
27
|
-
const mockSmartWallet = {
|
28
|
-
id: "smart",
|
29
|
-
getConfig: () => ({ gasless: true }),
|
30
|
-
} as Wallet;
|
31
|
-
expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
|
32
|
-
});
|
33
|
-
|
34
|
-
it("should handle inApp wallet with smartAccount config", () => {
|
35
|
-
const mockInAppWallet = {
|
36
|
-
id: "inApp",
|
37
|
-
getConfig: () => ({
|
38
|
-
smartAccount: {
|
39
|
-
sponsorGas: true,
|
40
|
-
},
|
41
|
-
}),
|
42
|
-
} as Wallet;
|
43
|
-
expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
|
44
|
-
|
45
|
-
const mockInAppWalletDisabled = {
|
46
|
-
id: "inApp",
|
47
|
-
getConfig: () => ({
|
48
|
-
smartAccount: {
|
49
|
-
sponsorGas: false,
|
50
|
-
},
|
51
|
-
}),
|
52
|
-
} as Wallet;
|
53
|
-
expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
|
54
|
-
false,
|
55
|
-
);
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should handle inApp wallet with gasless config", () => {
|
59
|
-
const mockInAppWallet = {
|
60
|
-
id: "inApp",
|
61
|
-
getConfig: () => ({
|
62
|
-
smartAccount: {
|
63
|
-
gasless: true,
|
64
|
-
},
|
65
|
-
}),
|
66
|
-
} as Wallet;
|
67
|
-
expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
|
68
|
-
});
|
69
|
-
|
70
|
-
it("should return false for regular wallet without smart account config", () => {
|
71
|
-
const mockRegularWallet = {
|
72
|
-
id: "inApp",
|
73
|
-
getConfig: () => ({}),
|
74
|
-
} as Wallet;
|
75
|
-
expect(hasSponsoredTransactionsEnabled(mockRegularWallet)).toBe(false);
|
76
|
-
});
|
77
|
-
});
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import { optimism } from "../../chains/chain-definitions/optimism.js";
|
3
|
-
import type { Wallet } from "../interfaces/wallet.js";
|
4
|
-
import { getSmartWallet } from "./get-smart-wallet-config.js";
|
5
|
-
import type { SmartWalletOptions } from "./types.js";
|
6
|
-
|
7
|
-
describe("getSmartWallet", () => {
|
8
|
-
const mockSmartWalletConfig: SmartWalletOptions = {
|
9
|
-
chain: optimism,
|
10
|
-
sponsorGas: false,
|
11
|
-
};
|
12
|
-
|
13
|
-
it("should return config for smart wallet ID", () => {
|
14
|
-
const wallet = {
|
15
|
-
id: "smart",
|
16
|
-
getConfig: () => mockSmartWalletConfig,
|
17
|
-
} as Wallet<"smart">;
|
18
|
-
|
19
|
-
expect(getSmartWallet(wallet)).toBe(mockSmartWalletConfig);
|
20
|
-
});
|
21
|
-
|
22
|
-
it("should return smartAccount config for wallet with smartAccount", () => {
|
23
|
-
const wallet = {
|
24
|
-
id: "inApp",
|
25
|
-
getConfig: () => ({
|
26
|
-
smartAccount: mockSmartWalletConfig,
|
27
|
-
}),
|
28
|
-
} as Wallet;
|
29
|
-
|
30
|
-
expect(getSmartWallet(wallet)).toBe(mockSmartWalletConfig);
|
31
|
-
});
|
32
|
-
|
33
|
-
it("should throw error for non-smart wallet", () => {
|
34
|
-
const wallet = {
|
35
|
-
id: "inApp",
|
36
|
-
getConfig: () => ({}),
|
37
|
-
} as Wallet;
|
38
|
-
|
39
|
-
expect(() => getSmartWallet(wallet)).toThrow(
|
40
|
-
"Wallet is not a smart wallet",
|
41
|
-
);
|
42
|
-
});
|
43
|
-
|
44
|
-
it("should throw error when getConfig returns null", () => {
|
45
|
-
const wallet = {
|
46
|
-
id: "inApp",
|
47
|
-
getConfig: () => null,
|
48
|
-
// biome-ignore lint/suspicious/noExplicitAny: Testing invalid config
|
49
|
-
} as any as Wallet;
|
50
|
-
|
51
|
-
expect(() => getSmartWallet(wallet)).toThrow(
|
52
|
-
"Wallet is not a smart wallet",
|
53
|
-
);
|
54
|
-
});
|
55
|
-
|
56
|
-
it("should throw error when smartAccount is null", () => {
|
57
|
-
const wallet = {
|
58
|
-
id: "inApp",
|
59
|
-
getConfig: () => ({ smartAccount: null }),
|
60
|
-
// biome-ignore lint/suspicious/noExplicitAny: Testing invalid config
|
61
|
-
} as any as Wallet;
|
62
|
-
|
63
|
-
expect(() => getSmartWallet(wallet)).toThrow(
|
64
|
-
"Wallet is not a smart wallet",
|
65
|
-
);
|
66
|
-
});
|
67
|
-
});
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { Wallet } from "../interfaces/wallet.js";
|
2
|
-
import type { SmartWalletOptions } from "./types.js";
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Gets the smart wallet configuration for a given wallet.
|
6
|
-
*
|
7
|
-
* @param {Wallet} wallet - The wallet to check.
|
8
|
-
* @returns {SmartWalletOptions} The smart wallet configuration.
|
9
|
-
*
|
10
|
-
* @throws {Error} If the wallet is not a smart wallet.
|
11
|
-
* @internal
|
12
|
-
*/
|
13
|
-
export function getSmartWallet(wallet: Wallet): SmartWalletOptions {
|
14
|
-
if (wallet.id === "smart") {
|
15
|
-
return (wallet as Wallet<"smart">).getConfig();
|
16
|
-
}
|
17
|
-
|
18
|
-
const config = wallet.getConfig();
|
19
|
-
if (!!config && "smartAccount" in config && !!config?.smartAccount) {
|
20
|
-
return config.smartAccount;
|
21
|
-
}
|
22
|
-
|
23
|
-
throw new Error("Wallet is not a smart wallet");
|
24
|
-
}
|