thirdweb 5.36.1-nightly-af4acc4319fdfb323778694bd8843bd695e52d6b-20240719161043 → 5.37.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.
- package/dist/cjs/extensions/erc4337/account/addSessionKey.js +1 -0
- package/dist/cjs/extensions/erc4337/account/addSessionKey.js.map +1 -1
- package/dist/cjs/react/core/utils/socialIcons.js +1 -0
- package/dist/cjs/react/core/utils/socialIcons.js.map +1 -1
- package/dist/cjs/react/native/ui/components/WalletImage.js +2 -0
- package/dist/cjs/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectModal.js +2 -2
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js +4 -3
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/cjs/react/native/ui/icons/svgs.js +8 -1
- package/dist/cjs/react/native/ui/icons/svgs.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +11 -4
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +4 -3
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.js +9 -0
- package/dist/cjs/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +3 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js +7 -6
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js.map +1 -1
- package/dist/cjs/react/web/ui/components/Modal.js +1 -4
- package/dist/cjs/react/web/ui/components/Modal.js.map +1 -1
- package/dist/cjs/react/web/ui/components/Tabs.js +8 -9
- package/dist/cjs/react/web/ui/components/Tabs.js.map +1 -1
- package/dist/cjs/react/web/ui/components/WalletImage.js +3 -0
- package/dist/cjs/react/web/ui/components/WalletImage.js.map +1 -1
- package/dist/cjs/react/web/ui/components/buttons.js +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +17 -3
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js +12 -1
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/en.js +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/en.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/es.js +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/es.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/ja.js +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/ja.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/tl.js +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/tl.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/vi.js +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/vi.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/openOauthSignInWindow.js +11 -2
- package/dist/cjs/react/web/wallets/shared/openOauthSignInWindow.js.map +1 -1
- package/dist/cjs/transaction/actions/encode.js +55 -10
- package/dist/cjs/transaction/actions/encode.js.map +1 -1
- package/dist/cjs/transaction/actions/estimate-gas.js +1 -1
- package/dist/cjs/transaction/actions/estimate-gas.js.map +1 -1
- package/dist/cjs/transaction/prepare-contract-call.js +17 -0
- package/dist/cjs/transaction/prepare-contract-call.js.map +1 -1
- package/dist/cjs/transaction/prepare-transaction.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/core/authentication/getLoginPath.js +17 -0
- package/dist/cjs/wallets/in-app/core/authentication/getLoginPath.js.map +1 -0
- package/dist/cjs/wallets/in-app/core/authentication/type.js +2 -0
- package/dist/cjs/wallets/in-app/core/authentication/type.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/auth/native-auth.js +11 -2
- package/dist/cjs/wallets/in-app/native/auth/native-auth.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/helpers/auth/middleware.js +4 -1
- package/dist/cjs/wallets/in-app/native/helpers/auth/middleware.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/helpers/constants.js +10 -4
- package/dist/cjs/wallets/in-app/native/helpers/constants.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/helpers/wallet/recoveryCode.js +47 -5
- package/dist/cjs/wallets/in-app/native/helpers/wallet/recoveryCode.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/native-connector.js +1 -0
- package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/constants.js +5 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/constants.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/discord.js +72 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/discord.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/utils.js +18 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/utils.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js +10 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/cjs/wallets/types.js +7 -0
- package/dist/cjs/wallets/types.js.map +1 -1
- package/dist/esm/extensions/erc4337/account/addSessionKey.js +1 -0
- package/dist/esm/extensions/erc4337/account/addSessionKey.js.map +1 -1
- package/dist/esm/react/core/utils/socialIcons.js +1 -0
- package/dist/esm/react/core/utils/socialIcons.js.map +1 -1
- package/dist/esm/react/native/ui/components/WalletImage.js +3 -1
- package/dist/esm/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectModal.js +2 -2
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js +5 -4
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/esm/react/native/ui/icons/svgs.js +7 -0
- package/dist/esm/react/native/ui/icons/svgs.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +12 -5
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +4 -3
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.js +5 -0
- package/dist/esm/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +3 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js +7 -6
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js.map +1 -1
- package/dist/esm/react/web/ui/components/Modal.js +1 -4
- package/dist/esm/react/web/ui/components/Modal.js.map +1 -1
- package/dist/esm/react/web/ui/components/Tabs.js +9 -10
- package/dist/esm/react/web/ui/components/Tabs.js.map +1 -1
- package/dist/esm/react/web/ui/components/WalletImage.js +4 -1
- package/dist/esm/react/web/ui/components/WalletImage.js.map +1 -1
- package/dist/esm/react/web/ui/components/buttons.js +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +17 -3
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js +12 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/en.js +1 -0
- package/dist/esm/react/web/wallets/shared/locale/en.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/es.js +1 -0
- package/dist/esm/react/web/wallets/shared/locale/es.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/ja.js +1 -0
- package/dist/esm/react/web/wallets/shared/locale/ja.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/tl.js +1 -0
- package/dist/esm/react/web/wallets/shared/locale/tl.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/vi.js +1 -0
- package/dist/esm/react/web/wallets/shared/locale/vi.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/openOauthSignInWindow.js +11 -2
- package/dist/esm/react/web/wallets/shared/openOauthSignInWindow.js.map +1 -1
- package/dist/esm/transaction/actions/encode.js +53 -10
- package/dist/esm/transaction/actions/encode.js.map +1 -1
- package/dist/esm/transaction/actions/estimate-gas.js +1 -1
- package/dist/esm/transaction/actions/estimate-gas.js.map +1 -1
- package/dist/esm/transaction/prepare-contract-call.js +17 -0
- package/dist/esm/transaction/prepare-contract-call.js.map +1 -1
- package/dist/esm/transaction/prepare-transaction.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/core/authentication/getLoginPath.js +13 -0
- package/dist/esm/wallets/in-app/core/authentication/getLoginPath.js.map +1 -0
- package/dist/esm/wallets/in-app/core/authentication/type.js +2 -0
- package/dist/esm/wallets/in-app/core/authentication/type.js.map +1 -1
- package/dist/esm/wallets/in-app/native/auth/native-auth.js +11 -2
- package/dist/esm/wallets/in-app/native/auth/native-auth.js.map +1 -1
- package/dist/esm/wallets/in-app/native/helpers/auth/middleware.js +5 -2
- package/dist/esm/wallets/in-app/native/helpers/auth/middleware.js.map +1 -1
- package/dist/esm/wallets/in-app/native/helpers/constants.js +9 -3
- package/dist/esm/wallets/in-app/native/helpers/constants.js.map +1 -1
- package/dist/esm/wallets/in-app/native/helpers/wallet/recoveryCode.js +46 -6
- package/dist/esm/wallets/in-app/native/helpers/wallet/recoveryCode.js.map +1 -1
- package/dist/esm/wallets/in-app/native/native-connector.js +1 -0
- package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/constants.js +2 -0
- package/dist/esm/wallets/in-app/web/lib/auth/constants.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/auth/discord.js +69 -0
- package/dist/esm/wallets/in-app/web/lib/auth/discord.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/auth/utils.js +14 -0
- package/dist/esm/wallets/in-app/web/lib/auth/utils.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js +10 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/wallets/types.js +6 -1
- package/dist/esm/wallets/types.js.map +1 -1
- package/dist/types/extensions/erc4337/account/addSessionKey.d.ts +2 -1
- package/dist/types/extensions/erc4337/account/addSessionKey.d.ts.map +1 -1
- package/dist/types/react/core/utils/socialIcons.d.ts +1 -0
- package/dist/types/react/core/utils/socialIcons.d.ts.map +1 -1
- package/dist/types/react/core/utils/storage.d.ts +1 -1
- package/dist/types/react/core/utils/storage.d.ts.map +1 -1
- package/dist/types/react/native/ui/components/WalletImage.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts.map +1 -1
- package/dist/types/react/native/ui/icons/svgs.d.ts +1 -0
- package/dist/types/react/native/ui/icons/svgs.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/TransactionsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.d.ts +3 -0
- package/dist/types/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/Modal.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/Tabs.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/WalletImage.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts +1 -1
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/SocialLogin.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/en.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/en.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/es.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/es.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/ja.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/ja.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/tl.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/tl.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/types.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/types.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/vi.d.ts +1 -0
- package/dist/types/react/web/wallets/shared/locale/vi.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/openOauthSignInWindow.d.ts +8 -1
- package/dist/types/react/web/wallets/shared/openOauthSignInWindow.d.ts.map +1 -1
- package/dist/types/transaction/actions/encode.d.ts +13 -0
- package/dist/types/transaction/actions/encode.d.ts.map +1 -1
- package/dist/types/transaction/prepare-contract-call.d.ts +17 -0
- package/dist/types/transaction/prepare-contract-call.d.ts.map +1 -1
- package/dist/types/transaction/prepare-transaction.d.ts +1 -0
- package/dist/types/transaction/prepare-transaction.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/core/authentication/getLoginPath.d.ts +4 -0
- package/dist/types/wallets/in-app/core/authentication/getLoginPath.d.ts.map +1 -0
- package/dist/types/wallets/in-app/core/authentication/type.d.ts +3 -2
- package/dist/types/wallets/in-app/core/authentication/type.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/auth/native-auth.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/helpers/auth/middleware.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/helpers/constants.d.ts +18 -14
- package/dist/types/wallets/in-app/native/helpers/constants.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/helpers/wallet/recoveryCode.d.ts +3 -1
- package/dist/types/wallets/in-app/native/helpers/wallet/recoveryCode.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/constants.d.ts +2 -0
- package/dist/types/wallets/in-app/web/lib/auth/constants.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/auth/discord.d.ts +10 -0
- package/dist/types/wallets/in-app/web/lib/auth/discord.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/auth/utils.d.ts +6 -0
- package/dist/types/wallets/in-app/web/lib/auth/utils.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/dist/types/wallets/types.d.ts +2 -1
- package/dist/types/wallets/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/extensions/erc4337/account/addSessionKey.ts +2 -1
- package/src/react/core/utils/socialIcons.ts +1 -0
- package/src/react/core/utils/wait.test.ts +1 -1
- package/src/react/native/ui/components/WalletImage.tsx +3 -0
- package/src/react/native/ui/connect/ConnectModal.tsx +2 -2
- package/src/react/native/ui/connect/InAppWalletUI.tsx +9 -6
- package/src/react/native/ui/icons/svgs.ts +8 -0
- package/src/react/web/ui/ConnectWallet/Details.tsx +15 -5
- package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +23 -23
- package/src/react/web/ui/ConnectWallet/icons/ShuffleIconLucide.tsx +24 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +3 -2
- package/src/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.tsx +19 -23
- package/src/react/web/ui/components/Modal.tsx +1 -4
- package/src/react/web/ui/components/Tabs.tsx +23 -18
- package/src/react/web/ui/components/WalletImage.tsx +4 -0
- package/src/react/web/ui/components/buttons.tsx +1 -1
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +23 -9
- package/src/react/web/wallets/shared/SocialLogin.tsx +12 -1
- package/src/react/web/wallets/shared/locale/en.ts +1 -0
- package/src/react/web/wallets/shared/locale/es.ts +1 -0
- package/src/react/web/wallets/shared/locale/ja.ts +1 -0
- package/src/react/web/wallets/shared/locale/tl.ts +1 -0
- package/src/react/web/wallets/shared/locale/types.ts +1 -0
- package/src/react/web/wallets/shared/locale/vi.ts +1 -0
- package/src/react/web/wallets/shared/openOauthSignInWindow.ts +28 -5
- package/src/transaction/actions/encode.test.ts +152 -3
- package/src/transaction/actions/encode.ts +59 -10
- package/src/transaction/actions/estimate-gas.ts +1 -1
- package/src/transaction/actions/to-serializable-transaction.test.ts +16 -0
- package/src/transaction/prepare-contract-call.test.ts +3 -5
- package/src/transaction/prepare-contract-call.ts +17 -0
- package/src/transaction/prepare-transaction.ts +1 -0
- package/src/utils/promise/wait.test.ts +1 -1
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/authentication/getLoginPath.ts +18 -0
- package/src/wallets/in-app/core/authentication/type.ts +3 -1
- package/src/wallets/in-app/native/auth/native-auth.ts +16 -6
- package/src/wallets/in-app/native/helpers/auth/middleware.ts +8 -2
- package/src/wallets/in-app/native/helpers/constants.ts +12 -3
- package/src/wallets/in-app/native/helpers/wallet/recoveryCode.ts +75 -8
- package/src/wallets/in-app/native/native-connector.ts +1 -0
- package/src/wallets/in-app/web/lib/auth/constants.ts +1 -0
- package/src/wallets/in-app/web/lib/auth/discord.ts +92 -0
- package/src/wallets/in-app/web/lib/auth/utils.ts +19 -0
- package/src/wallets/in-app/web/lib/web-connector.ts +11 -0
- package/src/wallets/types.ts +7 -1
@@ -46,43 +46,39 @@ export function WalletTransactionHistory(props: {
|
|
46
46
|
fullHeight
|
47
47
|
style={{
|
48
48
|
minHeight: "250px",
|
49
|
-
maxHeight: "
|
49
|
+
maxHeight: "350px",
|
50
|
+
paddingBottom: spacing.lg,
|
50
51
|
}}
|
51
52
|
>
|
52
|
-
<Container
|
53
|
-
|
54
|
-
gap="xs"
|
55
|
-
style={{ paddingBottom: "24px" }}
|
56
|
-
expand
|
57
|
-
>
|
58
|
-
{transactions.length === 0 && (
|
53
|
+
<Container flex="column" gap="xs" expand>
|
54
|
+
{transactions.length === 0 ? (
|
59
55
|
<Container
|
60
56
|
flex="column"
|
61
57
|
gap="md"
|
62
58
|
center="both"
|
63
59
|
color="secondaryText"
|
64
60
|
style={{
|
65
|
-
|
61
|
+
flex: "1",
|
66
62
|
}}
|
67
63
|
>
|
68
64
|
<CrossCircledIcon width={iconSize.xl} height={iconSize.xl} />
|
69
65
|
<Text>No Transactions</Text>
|
70
66
|
</Container>
|
67
|
+
) : (
|
68
|
+
<Container animate="fadein" flex="column" gap="xs">
|
69
|
+
{transactions.map((tx) => {
|
70
|
+
return (
|
71
|
+
<TransactionButton
|
72
|
+
key={tx.transactionHash}
|
73
|
+
explorerUrl={chainExplorers.explorers[0]?.url}
|
74
|
+
client={props.client}
|
75
|
+
hash={tx.transactionHash}
|
76
|
+
chainId={tx.chainId}
|
77
|
+
/>
|
78
|
+
);
|
79
|
+
})}
|
80
|
+
</Container>
|
71
81
|
)}
|
72
|
-
|
73
|
-
<Container animate="fadein" flex="column" gap="xs">
|
74
|
-
{transactions.map((tx) => {
|
75
|
-
return (
|
76
|
-
<TransactionButton
|
77
|
-
key={tx.transactionHash}
|
78
|
-
explorerUrl={chainExplorers.explorers[0]?.url}
|
79
|
-
client={props.client}
|
80
|
-
hash={tx.transactionHash}
|
81
|
-
chainId={tx.chainId}
|
82
|
-
/>
|
83
|
-
);
|
84
|
-
})}
|
85
|
-
</Container>
|
86
82
|
</Container>
|
87
83
|
</Container>
|
88
84
|
);
|
@@ -138,10 +138,7 @@ export const CrossContainer = /* @__PURE__ */ StyledDiv({
|
|
138
138
|
position: "absolute",
|
139
139
|
top: spacing.lg,
|
140
140
|
right: spacing.lg,
|
141
|
-
transform: "translateX(
|
142
|
-
[media.mobile]: {
|
143
|
-
right: spacing.md,
|
144
|
-
},
|
141
|
+
transform: "translateX(6px)",
|
145
142
|
});
|
146
143
|
|
147
144
|
const modalAnimationDesktop = keyframes`
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
2
|
+
import { radius, spacing } from "../../../core/design-system/index.js";
|
2
3
|
import { Text } from "../components/text.js";
|
3
|
-
import {
|
4
|
+
import { Spacer } from "./Spacer.js";
|
5
|
+
import { Container } from "./basic.js";
|
6
|
+
import { Button } from "./buttons.js";
|
4
7
|
|
5
8
|
export default function Tabs({
|
6
9
|
selected,
|
@@ -15,42 +18,44 @@ export default function Tabs({
|
|
15
18
|
}) {
|
16
19
|
const theme = useCustomTheme();
|
17
20
|
return (
|
18
|
-
<
|
19
|
-
<Container
|
21
|
+
<div>
|
22
|
+
<Container
|
23
|
+
flex="row"
|
24
|
+
center="y"
|
25
|
+
style={{ width: "100%", borderRadius: radius.lg }}
|
26
|
+
p="xxs"
|
27
|
+
bg="secondaryButtonBg"
|
28
|
+
>
|
20
29
|
{options.map((option) => (
|
21
|
-
<
|
30
|
+
<Button
|
31
|
+
variant="accent"
|
22
32
|
type="button"
|
23
33
|
key={option}
|
24
34
|
onClick={() => onSelect(option)}
|
25
35
|
style={{
|
26
36
|
flex: 1,
|
27
|
-
|
37
|
+
paddingBlock: spacing.sm,
|
28
38
|
display: "flex",
|
29
39
|
alignItems: "center",
|
30
40
|
justifyContent: "center",
|
31
41
|
position: "relative",
|
42
|
+
borderRadius: radius.md,
|
43
|
+
backgroundColor:
|
44
|
+
option === selected ? theme.colors.modalBg : "transparent",
|
32
45
|
}}
|
33
46
|
>
|
34
47
|
<Text
|
35
48
|
color={option === selected ? "primaryText" : "secondaryText"}
|
36
49
|
style={{ textAlign: "center" }}
|
50
|
+
size="sm"
|
37
51
|
>
|
38
52
|
{option}
|
39
53
|
</Text>
|
40
|
-
|
41
|
-
style={{
|
42
|
-
position: "absolute",
|
43
|
-
bottom: 0,
|
44
|
-
left: 0,
|
45
|
-
width: "100%",
|
46
|
-
backgroundColor:
|
47
|
-
option === selected ? "white" : theme.colors.separatorLine,
|
48
|
-
}}
|
49
|
-
/>
|
50
|
-
</button>
|
54
|
+
</Button>
|
51
55
|
))}
|
52
56
|
</Container>
|
53
|
-
<
|
54
|
-
|
57
|
+
<Spacer y="sm" />
|
58
|
+
{children}
|
59
|
+
</div>
|
55
60
|
);
|
56
61
|
}
|
@@ -9,6 +9,7 @@ import type { WalletId } from "../../../../wallets/wallet-types.js";
|
|
9
9
|
import { radius } from "../../../core/design-system/index.js";
|
10
10
|
import {
|
11
11
|
appleIconUri,
|
12
|
+
discordIconUri,
|
12
13
|
emailIcon,
|
13
14
|
facebookIconUri,
|
14
15
|
genericWalletIcon,
|
@@ -73,6 +74,9 @@ export function WalletImage(props: {
|
|
73
74
|
case "passkey":
|
74
75
|
image = passkeyIcon;
|
75
76
|
break;
|
77
|
+
case "discord":
|
78
|
+
image = discordIconUri;
|
79
|
+
break;
|
76
80
|
}
|
77
81
|
} else {
|
78
82
|
const mipdImage = getInstalledWalletProviders().find(
|
@@ -141,7 +141,7 @@ export const IconButton = /* @__PURE__ */ StyledButton((_) => {
|
|
141
141
|
display: "inline-flex",
|
142
142
|
alignItems: "center",
|
143
143
|
justifyContent: "center",
|
144
|
-
borderRadius: radius.
|
144
|
+
borderRadius: radius.sm,
|
145
145
|
WebkitTapHighlightColor: "transparent",
|
146
146
|
color: theme.colors.secondaryIconColor,
|
147
147
|
padding: "2px",
|
@@ -8,9 +8,10 @@ import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
|
8
8
|
import { getEcosystemWalletAuthOptions } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
9
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
10
|
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
|
11
|
-
import
|
12
|
-
AuthOption,
|
13
|
-
SocialAuthOption,
|
11
|
+
import {
|
12
|
+
type AuthOption,
|
13
|
+
type SocialAuthOption,
|
14
|
+
socialAuthOptions,
|
14
15
|
} from "../../../../wallets/types.js";
|
15
16
|
import type { EcosystemWalletId } from "../../../../wallets/wallet-types.js";
|
16
17
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
@@ -88,6 +89,7 @@ export const ConnectWalletSocialOptions = (
|
|
88
89
|
google: locale.signInWithGoogle,
|
89
90
|
facebook: locale.signInWithFacebook,
|
90
91
|
apple: locale.signInWithApple,
|
92
|
+
discord: locale.signInWithDiscord,
|
91
93
|
};
|
92
94
|
|
93
95
|
const { data: ecosystemAuthOptions, isLoading } = useQuery({
|
@@ -148,16 +150,27 @@ export const ConnectWalletSocialOptions = (
|
|
148
150
|
type = "tel";
|
149
151
|
}
|
150
152
|
|
151
|
-
const socialLogins = authOptions.filter(
|
152
|
-
(
|
153
|
+
const socialLogins = authOptions.filter((o) =>
|
154
|
+
socialAuthOptions.includes(o as SocialAuthOption),
|
153
155
|
);
|
154
156
|
|
155
157
|
const hasSocialLogins = socialLogins.length > 0;
|
158
|
+
const ecosystemInfo = isEcosystemWallet(wallet)
|
159
|
+
? {
|
160
|
+
id: wallet.id,
|
161
|
+
partnerId: wallet.getConfig()?.partnerId,
|
162
|
+
}
|
163
|
+
: undefined;
|
156
164
|
|
157
165
|
// Need to trigger login on button click to avoid popup from being blocked
|
158
166
|
const handleSocialLogin = async (strategy: SocialAuthOption) => {
|
159
167
|
try {
|
160
|
-
const socialLoginWindow = openOauthSignInWindow(
|
168
|
+
const socialLoginWindow = openOauthSignInWindow({
|
169
|
+
authOption: strategy,
|
170
|
+
themeObj,
|
171
|
+
client: props.client,
|
172
|
+
ecosystem: ecosystemInfo,
|
173
|
+
});
|
161
174
|
if (!socialLoginWindow) {
|
162
175
|
throw new Error("Failed to open login window");
|
163
176
|
}
|
@@ -236,16 +249,17 @@ export const ConnectWalletSocialOptions = (
|
|
236
249
|
variant={"outline"}
|
237
250
|
fullWidth={!showOnlyIcons}
|
238
251
|
onClick={() => {
|
239
|
-
handleSocialLogin(loginMethod);
|
252
|
+
handleSocialLogin(loginMethod as SocialAuthOption);
|
240
253
|
}}
|
241
254
|
>
|
242
255
|
<Img
|
243
|
-
src={socialIcons[loginMethod]}
|
256
|
+
src={socialIcons[loginMethod as SocialAuthOption]}
|
244
257
|
width={imgIconSize}
|
245
258
|
height={imgIconSize}
|
246
259
|
client={props.client}
|
247
260
|
/>
|
248
|
-
{!showOnlyIcons &&
|
261
|
+
{!showOnlyIcons &&
|
262
|
+
loginMethodsLabel[loginMethod as SocialAuthOption]}
|
249
263
|
</SocialButton>
|
250
264
|
);
|
251
265
|
})}
|
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import type { Chain } from "../../../../chains/types.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
5
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
6
|
+
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
6
7
|
import type { InAppWalletSocialAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
7
8
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
8
9
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
@@ -42,7 +43,17 @@ export function SocialLogin(props: {
|
|
42
43
|
|
43
44
|
const handleSocialLogin = async () => {
|
44
45
|
try {
|
45
|
-
const socialWindow = openOauthSignInWindow(
|
46
|
+
const socialWindow = openOauthSignInWindow({
|
47
|
+
authOption: props.socialAuth,
|
48
|
+
themeObj,
|
49
|
+
client: props.client,
|
50
|
+
ecosystem: isEcosystemWallet(wallet)
|
51
|
+
? {
|
52
|
+
id: wallet.id,
|
53
|
+
partnerId: wallet.getConfig()?.partnerId,
|
54
|
+
}
|
55
|
+
: undefined,
|
56
|
+
});
|
46
57
|
|
47
58
|
if (!socialWindow) {
|
48
59
|
throw new Error(`Failed to open ${props.socialAuth} login window`);
|
@@ -4,6 +4,7 @@ export default {
|
|
4
4
|
signInWithGoogle: "Iniciar sesión con Google",
|
5
5
|
signInWithFacebook: "Iniciar sesión con Facebook",
|
6
6
|
signInWithApple: "Iniciar sesión con Apple",
|
7
|
+
signInWithDiscord: "Iniciar sesión con Discord",
|
7
8
|
emailPlaceholder: "Ingresa tu dirección de correo electrónico",
|
8
9
|
submitEmail: "Continuar",
|
9
10
|
signIn: "Iniciar sesión",
|
@@ -4,6 +4,7 @@ export default {
|
|
4
4
|
signInWithGoogle: "Mag-sign in gamit ang Google",
|
5
5
|
signInWithFacebook: "Mag-sign in gamit ang Facebook",
|
6
6
|
signInWithApple: "Mag-sign in gamit ang Apple",
|
7
|
+
signInWithDiscord: "Mag-sign in gamit ang Discord",
|
7
8
|
emailPlaceholder: "Ilagay ang iyong email address",
|
8
9
|
submitEmail: "Magpatuloy",
|
9
10
|
signIn: "Mag-sign in",
|
@@ -1,4 +1,7 @@
|
|
1
|
+
import type { ThirdwebClient } from "../../../../client/client.js";
|
2
|
+
import { getDiscordLoginPath } from "../../../../wallets/in-app/core/authentication/getLoginPath.js";
|
1
3
|
import type { InAppWalletSocialAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
4
|
+
import type { Ecosystem } from "../../../../wallets/in-app/web/types.js";
|
2
5
|
import type { Theme } from "../../../core/design-system/index.js";
|
3
6
|
|
4
7
|
function getBodyTitle(authOption: InAppWalletSocialAuth) {
|
@@ -21,21 +24,41 @@ function getWidthAndHeight(authOption: InAppWalletSocialAuth) {
|
|
21
24
|
}
|
22
25
|
}
|
23
26
|
|
27
|
+
function getOauthLoginPath(
|
28
|
+
authOption: InAppWalletSocialAuth,
|
29
|
+
client: ThirdwebClient,
|
30
|
+
ecosystem?: Ecosystem,
|
31
|
+
) {
|
32
|
+
switch (authOption) {
|
33
|
+
case "discord":
|
34
|
+
return getDiscordLoginPath(client, ecosystem);
|
35
|
+
default:
|
36
|
+
return "";
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
24
40
|
/**
|
25
41
|
*
|
26
42
|
* @internal
|
27
43
|
*/
|
28
|
-
export function openOauthSignInWindow(
|
29
|
-
authOption
|
30
|
-
themeObj
|
31
|
-
|
44
|
+
export function openOauthSignInWindow({
|
45
|
+
authOption,
|
46
|
+
themeObj,
|
47
|
+
client,
|
48
|
+
ecosystem,
|
49
|
+
}: {
|
50
|
+
authOption: InAppWalletSocialAuth;
|
51
|
+
themeObj: Theme;
|
52
|
+
client: ThirdwebClient;
|
53
|
+
ecosystem?: Ecosystem;
|
54
|
+
}) {
|
32
55
|
// open the popup in the center of the screen
|
33
56
|
const { height, width } = getWidthAndHeight(authOption);
|
34
57
|
const top = (window.innerHeight - height) / 2;
|
35
58
|
const left = (window.innerWidth - width) / 2;
|
36
59
|
|
37
60
|
const win = window.open(
|
38
|
-
|
61
|
+
getOauthLoginPath(authOption, client, ecosystem),
|
39
62
|
undefined,
|
40
63
|
`width=${width}, height=${height}, top=${top}, left=${left}`,
|
41
64
|
);
|
@@ -1,14 +1,26 @@
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
2
|
-
import { TEST_WALLET_A } from "~test/addresses.js";
|
2
|
+
import { TEST_WALLET_A, TEST_WALLET_B } from "~test/addresses.js";
|
3
|
+
import { FORKED_ETHEREUM_CHAIN } from "~test/chains.js";
|
4
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
3
5
|
import { USDT_CONTRACT, USDT_CONTRACT_WITH_ABI } from "~test/test-contracts.js";
|
4
|
-
import {
|
5
|
-
|
6
|
+
import { concatHex } from "../../utils/encoding/helpers/concat-hex.js";
|
7
|
+
import { toHex } from "../../utils/encoding/hex.js";
|
8
|
+
import { toWei } from "../../utils/units.js";
|
6
9
|
import { prepareContractCall } from "../prepare-contract-call.js";
|
10
|
+
import { prepareTransaction } from "../prepare-transaction.js";
|
7
11
|
import { resolveMethod } from "../resolve-method.js";
|
12
|
+
import { encode, getDataFromTx, getExtraCallDataFromTx } from "./encode.js";
|
8
13
|
|
9
14
|
const USDC_TRANSFER_ENCODE_RESULT =
|
10
15
|
"0xa9059cbb00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064";
|
11
16
|
|
17
|
+
const extraCallDataMsg = "Hello, World";
|
18
|
+
const extraCallData = toHex(extraCallDataMsg);
|
19
|
+
const expectedFinalData = concatHex([
|
20
|
+
USDC_TRANSFER_ENCODE_RESULT,
|
21
|
+
extraCallData,
|
22
|
+
]);
|
23
|
+
|
12
24
|
describe("transaction: encode", () => {
|
13
25
|
it("should encode correctly (human-readable)", async () => {
|
14
26
|
const tx = prepareContractCall({
|
@@ -58,4 +70,141 @@ describe("transaction: encode", () => {
|
|
58
70
|
const encoded = await encode(tx);
|
59
71
|
expect(encoded).toEqual(USDC_TRANSFER_ENCODE_RESULT);
|
60
72
|
});
|
73
|
+
|
74
|
+
// Repeat the same test cases above but now with extraCallData
|
75
|
+
|
76
|
+
it("extraCallData | should encode correctly (human-readable)", async () => {
|
77
|
+
const tx = prepareContractCall({
|
78
|
+
contract: USDT_CONTRACT,
|
79
|
+
method: "function transfer(address, uint256) returns (bool)",
|
80
|
+
params: [TEST_WALLET_A, 100n],
|
81
|
+
extraCallData,
|
82
|
+
});
|
83
|
+
const encoded = await encode(tx);
|
84
|
+
expect(encoded).toEqual(expectedFinalData);
|
85
|
+
});
|
86
|
+
|
87
|
+
it("extraCallData | should encode correctly (transaction abi)", async () => {
|
88
|
+
const tx = prepareContractCall({
|
89
|
+
contract: USDT_CONTRACT,
|
90
|
+
method: {
|
91
|
+
inputs: [
|
92
|
+
{ internalType: "address", name: "to", type: "address" },
|
93
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
94
|
+
],
|
95
|
+
name: "transfer",
|
96
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
97
|
+
stateMutability: "nonpayable",
|
98
|
+
type: "function",
|
99
|
+
},
|
100
|
+
params: [TEST_WALLET_A, 100n],
|
101
|
+
extraCallData,
|
102
|
+
});
|
103
|
+
const encoded = await encode(tx);
|
104
|
+
expect(encoded).toEqual(expectedFinalData);
|
105
|
+
});
|
106
|
+
|
107
|
+
it("extraCallData | should encode correctly (contract abi)", async () => {
|
108
|
+
const tx = prepareContractCall({
|
109
|
+
contract: USDT_CONTRACT_WITH_ABI,
|
110
|
+
method: "transfer",
|
111
|
+
params: [TEST_WALLET_A, 100n],
|
112
|
+
extraCallData,
|
113
|
+
});
|
114
|
+
const encoded = await encode(tx);
|
115
|
+
expect(encoded).toEqual(expectedFinalData);
|
116
|
+
});
|
117
|
+
it("extraCallData | should encode correctly (auto-abi)", async () => {
|
118
|
+
const tx = prepareContractCall({
|
119
|
+
contract: USDT_CONTRACT,
|
120
|
+
method: resolveMethod("transfer"),
|
121
|
+
params: [TEST_WALLET_A, 100n],
|
122
|
+
extraCallData,
|
123
|
+
});
|
124
|
+
const encoded = await encode(tx);
|
125
|
+
expect(encoded).toEqual(expectedFinalData);
|
126
|
+
});
|
127
|
+
|
128
|
+
it("extraCallData - should work with prepareTransaction", async () => {
|
129
|
+
const tx = prepareTransaction({
|
130
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
131
|
+
client: TEST_CLIENT,
|
132
|
+
to: TEST_WALLET_B,
|
133
|
+
value: toWei("0.1"),
|
134
|
+
});
|
135
|
+
const encoded = await encode(tx);
|
136
|
+
|
137
|
+
const txWithExtraData = prepareTransaction({
|
138
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
139
|
+
client: TEST_CLIENT,
|
140
|
+
to: TEST_WALLET_B,
|
141
|
+
value: toWei("0.1"),
|
142
|
+
extraCallData,
|
143
|
+
});
|
144
|
+
|
145
|
+
const encoded2 = await encode(txWithExtraData);
|
146
|
+
expect(encoded2).toBe(concatHex([encoded, extraCallData]));
|
147
|
+
});
|
148
|
+
|
149
|
+
it("internal func: getDataFromTx | should return `0x` if no data is attached", async () => {
|
150
|
+
const tx = prepareTransaction({
|
151
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
152
|
+
client: TEST_CLIENT,
|
153
|
+
to: TEST_WALLET_B,
|
154
|
+
value: toWei("0.1"),
|
155
|
+
});
|
156
|
+
const _hex = await getDataFromTx(tx);
|
157
|
+
expect(_hex).toBe("0x");
|
158
|
+
});
|
159
|
+
|
160
|
+
it("internal func: getDataFromTx | should return correctly encoded data", async () => {
|
161
|
+
const tx = prepareTransaction({
|
162
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
163
|
+
client: TEST_CLIENT,
|
164
|
+
to: TEST_WALLET_B,
|
165
|
+
value: toWei("0.1"),
|
166
|
+
data: extraCallData,
|
167
|
+
});
|
168
|
+
const _hex = await getDataFromTx(tx);
|
169
|
+
expect(_hex).toBe(extraCallData);
|
170
|
+
});
|
171
|
+
|
172
|
+
it("internal func: getExtraCallDataFromTx | should return `undefined` if no data is attached", async () => {
|
173
|
+
const tx = prepareTransaction({
|
174
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
175
|
+
client: TEST_CLIENT,
|
176
|
+
to: TEST_WALLET_B,
|
177
|
+
value: toWei("0.1"),
|
178
|
+
});
|
179
|
+
const result = await getExtraCallDataFromTx(tx);
|
180
|
+
expect(result).toBe(undefined);
|
181
|
+
});
|
182
|
+
|
183
|
+
it("internal func: getExtraCallDataFromTx | should return correct extraCallData", async () => {
|
184
|
+
const tx = prepareTransaction({
|
185
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
186
|
+
client: TEST_CLIENT,
|
187
|
+
to: TEST_WALLET_B,
|
188
|
+
value: toWei("0.1"),
|
189
|
+
data: toHex("getExtraCallDataFromTx-should-not-return-this"),
|
190
|
+
extraCallData,
|
191
|
+
});
|
192
|
+
const result = await getExtraCallDataFromTx(tx);
|
193
|
+
expect(result).toBe(extraCallData);
|
194
|
+
});
|
195
|
+
|
196
|
+
it("internal func: getExtraCallDataFromTx | should throw error if extraCallData is not hex-encoded", async () => {
|
197
|
+
const tx = prepareTransaction({
|
198
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
199
|
+
client: TEST_CLIENT,
|
200
|
+
to: TEST_WALLET_B,
|
201
|
+
value: toWei("0.1"),
|
202
|
+
data: toHex("getExtraCallDataFromTx-should-not-return-this"),
|
203
|
+
// @ts-ignore Intentionally for the test purpose
|
204
|
+
extraCallData: "I'm a cat",
|
205
|
+
});
|
206
|
+
await expect(() => getExtraCallDataFromTx(tx)).rejects.toThrowError(
|
207
|
+
"Invalid extra calldata - must be a hex string",
|
208
|
+
);
|
209
|
+
});
|
61
210
|
});
|
@@ -26,18 +26,67 @@ export async function encode<abi extends Abi, abiFn extends AbiFunction>(
|
|
26
26
|
return encodeWeakMap.get(transaction)!;
|
27
27
|
}
|
28
28
|
const promise = (async () => {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
return data;
|
29
|
+
const [data, extraData, { concatHex }] = await Promise.all([
|
30
|
+
getDataFromTx(transaction),
|
31
|
+
getExtraCallDataFromTx(transaction),
|
32
|
+
import("../../utils/encoding/helpers/concat-hex.js"),
|
33
|
+
]);
|
34
|
+
if (extraData) {
|
35
|
+
return concatHex([data, extraData]);
|
38
36
|
}
|
39
|
-
return
|
37
|
+
return data;
|
40
38
|
})();
|
41
39
|
encodeWeakMap.set(transaction, promise);
|
42
40
|
return promise;
|
43
41
|
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Get the transaction.data (from a PreparedTransaction)
|
45
|
+
* If the transaction does not have `data`, we default to "0x"
|
46
|
+
* @internal
|
47
|
+
*/
|
48
|
+
export async function getDataFromTx<abi extends Abi, abiFn extends AbiFunction>(
|
49
|
+
transaction: PreparedTransaction<abi, abiFn>,
|
50
|
+
): Promise<Hex> {
|
51
|
+
if (transaction.data === undefined) {
|
52
|
+
return "0x";
|
53
|
+
}
|
54
|
+
if (typeof transaction.data === "function") {
|
55
|
+
const data = await transaction.data();
|
56
|
+
if (!data) {
|
57
|
+
return "0x";
|
58
|
+
}
|
59
|
+
return data;
|
60
|
+
}
|
61
|
+
return transaction.data;
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Get the extraCallData from a PreparedTransaction
|
66
|
+
* @internal
|
67
|
+
* If extraCallData is "0x", we will return `undefined`
|
68
|
+
* to simplify the code, since concatenating "0x" doesn't do anything
|
69
|
+
*/
|
70
|
+
export async function getExtraCallDataFromTx<
|
71
|
+
abi extends Abi,
|
72
|
+
abiFn extends AbiFunction,
|
73
|
+
>(transaction: PreparedTransaction<abi, abiFn>): Promise<Hex | undefined> {
|
74
|
+
if (!transaction.extraCallData) {
|
75
|
+
return undefined;
|
76
|
+
}
|
77
|
+
if (typeof transaction.extraCallData === "function") {
|
78
|
+
const extraData = await transaction.extraCallData();
|
79
|
+
if (!extraData) return undefined;
|
80
|
+
if (!extraData.startsWith("0x")) {
|
81
|
+
throw Error("Invalid extra calldata - must be a hex string");
|
82
|
+
}
|
83
|
+
if (extraData === "0x") {
|
84
|
+
return undefined;
|
85
|
+
}
|
86
|
+
return extraData;
|
87
|
+
}
|
88
|
+
if (!transaction.extraCallData.startsWith("0x")) {
|
89
|
+
throw Error("Invalid extra calldata - must be a hex string");
|
90
|
+
}
|
91
|
+
return transaction.extraCallData;
|
92
|
+
}
|
@@ -69,7 +69,7 @@ export async function estimateGas(
|
|
69
69
|
const promise = (async () => {
|
70
70
|
const predefinedGas = await resolvePromisedValue(options.transaction.gas);
|
71
71
|
// if we have a predefined gas value in the TX -> always use that
|
72
|
-
if (predefinedGas) {
|
72
|
+
if (predefinedGas !== undefined) {
|
73
73
|
return predefinedGas;
|
74
74
|
}
|
75
75
|
|
@@ -254,6 +254,22 @@ describe("toSerializableTransaction", () => {
|
|
254
254
|
}),
|
255
255
|
).not.toThrow();
|
256
256
|
});
|
257
|
+
|
258
|
+
test("should respect a 0 gas value", async () => {
|
259
|
+
const serializableTransaction = await toSerializableTransaction({
|
260
|
+
transaction: {
|
261
|
+
...transaction,
|
262
|
+
gas: async () => Promise.resolve(0n),
|
263
|
+
},
|
264
|
+
});
|
265
|
+
|
266
|
+
expect(() =>
|
267
|
+
serializeTransaction({
|
268
|
+
transaction: serializableTransaction,
|
269
|
+
}),
|
270
|
+
).not.toThrow();
|
271
|
+
expect(serializableTransaction.gas).toBe(0n);
|
272
|
+
});
|
257
273
|
});
|
258
274
|
|
259
275
|
describe("extraGas override", () => {
|