thirdweb 5.83.2-nightly-332536bdee05b6fb3b36d33761381826279b48f6-20250113000321 → 5.84.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/ai/chat.js +29 -0
- package/dist/cjs/ai/chat.js.map +1 -0
- package/dist/cjs/ai/common.js +69 -0
- package/dist/cjs/ai/common.js.map +1 -0
- package/dist/cjs/ai/execute.js +43 -0
- package/dist/cjs/ai/execute.js.map +1 -0
- package/dist/cjs/ai/index.js +8 -0
- package/dist/cjs/ai/index.js.map +1 -0
- package/dist/cjs/auth/is-erc6492-signature.js +2 -2
- package/dist/cjs/auth/is-erc6492-signature.js.map +1 -1
- package/dist/cjs/auth/parse-erc6492-signature.js +10 -4
- package/dist/cjs/auth/parse-erc6492-signature.js.map +1 -1
- package/dist/cjs/auth/verify-hash.js +12 -11
- package/dist/cjs/auth/verify-hash.js.map +1 -1
- package/dist/cjs/auth/verify-signature.js +13 -5
- package/dist/cjs/auth/verify-signature.js.map +1 -1
- package/dist/cjs/auth/verify-typed-data.js +2 -2
- package/dist/cjs/auth/verify-typed-data.js.map +1 -1
- package/dist/cjs/contract/deployment/utils/create-2-factory.js +4 -3
- package/dist/cjs/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/cjs/contract/verification/constructor-params.js +5 -12
- package/dist/cjs/contract/verification/constructor-params.js.map +1 -1
- package/dist/cjs/exports/ai.js +5 -0
- package/dist/cjs/exports/ai.js.map +1 -0
- package/dist/cjs/exports/utils.js +9 -6
- package/dist/cjs/exports/utils.js.map +1 -1
- package/dist/cjs/exports/wallets/engine.js +6 -0
- package/dist/cjs/exports/wallets/engine.js.map +1 -0
- package/dist/cjs/exports/wallets.js +3 -1
- package/dist/cjs/exports/wallets.js.map +1 -1
- package/dist/cjs/extensions/ens/resolve-l2-name.js +10 -3
- package/dist/cjs/extensions/ens/resolve-l2-name.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFTs.js +2 -2
- package/dist/cjs/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/cjs/extensions/erc1155/write/mintTo.js +2 -2
- package/dist/cjs/extensions/erc1155/write/mintTo.js.map +1 -1
- package/dist/cjs/extensions/erc1155/write/mintToBatch.js +2 -2
- package/dist/cjs/extensions/erc1155/write/mintToBatch.js.map +1 -1
- package/dist/cjs/extensions/erc1155/write/sigMint.js +2 -2
- package/dist/cjs/extensions/erc1155/write/sigMint.js.map +1 -1
- package/dist/cjs/extensions/modules/ClaimableERC1155/setClaimConditions.js +3 -2
- package/dist/cjs/extensions/modules/ClaimableERC1155/setClaimConditions.js.map +1 -1
- package/dist/cjs/extensions/modules/MintableERC1155/mintWithRole.js +2 -2
- package/dist/cjs/extensions/modules/MintableERC1155/mintWithRole.js.map +1 -1
- package/dist/cjs/extensions/modules/MintableERC1155/mintWithSignature.js +2 -2
- package/dist/cjs/extensions/modules/MintableERC1155/mintWithSignature.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js +10 -131
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useSendToken.js +2 -1
- package/dist/cjs/react/core/hooks/wallets/useSendToken.js.map +1 -1
- package/dist/cjs/react/native/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/web/hooks/wallets/useAutoConnect.js +1 -1
- package/dist/cjs/react/web/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +2 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/useConnectModal.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
- package/dist/cjs/react/web/wallets/in-app/WalletAuth.js +1 -1
- package/dist/cjs/react/web/wallets/in-app/WalletAuth.js.map +1 -1
- package/dist/cjs/utils/abi/encodeAbiParameters.js +10 -11
- package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/ens/isValidENSName.js +50 -0
- package/dist/cjs/utils/ens/isValidENSName.js.map +1 -0
- package/dist/cjs/utils/extensions/drops/convert-quantity.js +2 -2
- package/dist/cjs/utils/extensions/drops/convert-quantity.js.map +1 -1
- package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +3 -3
- package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
- package/dist/cjs/utils/timeoutPromise.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/connection/autoConnect.js +54 -0
- package/dist/cjs/wallets/connection/autoConnect.js.map +1 -0
- package/dist/cjs/wallets/connection/autoConnectCore.js +135 -0
- package/dist/cjs/wallets/connection/autoConnectCore.js.map +1 -0
- package/dist/cjs/wallets/connection/types.js.map +1 -0
- package/dist/cjs/{react/web/wallets → wallets}/defaultWallets.js +2 -2
- package/dist/cjs/wallets/defaultWallets.js.map +1 -0
- package/dist/cjs/wallets/engine/index.js +143 -0
- package/dist/cjs/wallets/engine/index.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js +1 -1
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/signing.js +1 -1
- package/dist/esm/ai/chat.js +26 -0
- package/dist/esm/ai/chat.js.map +1 -0
- package/dist/esm/ai/common.js +66 -0
- package/dist/esm/ai/common.js.map +1 -0
- package/dist/esm/ai/execute.js +40 -0
- package/dist/esm/ai/execute.js.map +1 -0
- package/dist/esm/ai/index.js +3 -0
- package/dist/esm/ai/index.js.map +1 -0
- package/dist/esm/auth/is-erc6492-signature.js +2 -2
- package/dist/esm/auth/is-erc6492-signature.js.map +1 -1
- package/dist/esm/auth/parse-erc6492-signature.js +10 -4
- package/dist/esm/auth/parse-erc6492-signature.js.map +1 -1
- package/dist/esm/auth/verify-hash.js +12 -11
- package/dist/esm/auth/verify-hash.js.map +1 -1
- package/dist/esm/auth/verify-signature.js +13 -5
- package/dist/esm/auth/verify-signature.js.map +1 -1
- package/dist/esm/auth/verify-typed-data.js +2 -2
- package/dist/esm/auth/verify-typed-data.js.map +1 -1
- package/dist/esm/contract/deployment/utils/create-2-factory.js +4 -3
- package/dist/esm/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/esm/contract/verification/constructor-params.js +5 -12
- package/dist/esm/contract/verification/constructor-params.js.map +1 -1
- package/dist/esm/exports/ai.js +2 -0
- package/dist/esm/exports/ai.js.map +1 -0
- package/dist/esm/exports/utils.js +3 -1
- package/dist/esm/exports/utils.js.map +1 -1
- package/dist/esm/exports/wallets/engine.js +2 -0
- package/dist/esm/exports/wallets/engine.js.map +1 -0
- package/dist/esm/exports/wallets.js +1 -0
- package/dist/esm/exports/wallets.js.map +1 -1
- package/dist/esm/extensions/ens/resolve-l2-name.js +11 -4
- package/dist/esm/extensions/ens/resolve-l2-name.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFTs.js +1 -1
- package/dist/esm/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/esm/extensions/erc1155/write/mintTo.js +1 -1
- package/dist/esm/extensions/erc1155/write/mintTo.js.map +1 -1
- package/dist/esm/extensions/erc1155/write/mintToBatch.js +1 -1
- package/dist/esm/extensions/erc1155/write/mintToBatch.js.map +1 -1
- package/dist/esm/extensions/erc1155/write/sigMint.js +1 -1
- package/dist/esm/extensions/erc1155/write/sigMint.js.map +1 -1
- package/dist/esm/extensions/modules/ClaimableERC1155/setClaimConditions.js +2 -1
- package/dist/esm/extensions/modules/ClaimableERC1155/setClaimConditions.js.map +1 -1
- package/dist/esm/extensions/modules/MintableERC1155/mintWithRole.js +1 -1
- package/dist/esm/extensions/modules/MintableERC1155/mintWithRole.js.map +1 -1
- package/dist/esm/extensions/modules/MintableERC1155/mintWithSignature.js +1 -1
- package/dist/esm/extensions/modules/MintableERC1155/mintWithSignature.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +10 -130
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useSendToken.js +2 -1
- package/dist/esm/react/core/hooks/wallets/useSendToken.js.map +1 -1
- package/dist/esm/react/native/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/web/hooks/wallets/useAutoConnect.js +1 -1
- package/dist/esm/react/web/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +2 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/useConnectModal.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
- package/dist/esm/react/web/wallets/in-app/WalletAuth.js +1 -1
- package/dist/esm/react/web/wallets/in-app/WalletAuth.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js +10 -11
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/ens/isValidENSName.js +47 -0
- package/dist/esm/utils/ens/isValidENSName.js.map +1 -0
- package/dist/esm/utils/extensions/drops/convert-quantity.js +1 -1
- package/dist/esm/utils/extensions/drops/convert-quantity.js.map +1 -1
- package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +1 -1
- package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
- package/dist/esm/utils/timeoutPromise.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/connection/autoConnect.js +50 -0
- package/dist/esm/wallets/connection/autoConnect.js.map +1 -0
- package/dist/esm/wallets/connection/autoConnectCore.js +130 -0
- package/dist/esm/wallets/connection/autoConnectCore.js.map +1 -0
- package/dist/esm/wallets/connection/types.js.map +1 -0
- package/dist/esm/{react/web/wallets → wallets}/defaultWallets.js +2 -2
- package/dist/esm/wallets/defaultWallets.js.map +1 -0
- package/dist/esm/wallets/engine/index.js +140 -0
- package/dist/esm/wallets/engine/index.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js +1 -1
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js.map +1 -1
- package/dist/esm/wallets/smart/lib/signing.js +1 -1
- package/dist/types/ai/chat.d.ts +24 -0
- package/dist/types/ai/chat.d.ts.map +1 -0
- package/dist/types/ai/common.d.ts +22 -0
- package/dist/types/ai/common.d.ts.map +1 -0
- package/dist/types/ai/execute.d.ts +29 -0
- package/dist/types/ai/execute.d.ts.map +1 -0
- package/dist/types/ai/index.d.ts +4 -0
- package/dist/types/ai/index.d.ts.map +1 -0
- package/dist/types/auth/parse-erc6492-signature.d.ts.map +1 -1
- package/dist/types/auth/verify-hash.d.ts +2 -2
- package/dist/types/auth/verify-hash.d.ts.map +1 -1
- package/dist/types/auth/verify-signature.d.ts +6 -3
- package/dist/types/auth/verify-signature.d.ts.map +1 -1
- package/dist/types/auth/verify-typed-data.d.ts +5 -4
- package/dist/types/auth/verify-typed-data.d.ts.map +1 -1
- package/dist/types/contract/deployment/utils/create-2-factory.d.ts.map +1 -1
- package/dist/types/contract/verification/constructor-params.d.ts +2 -2
- package/dist/types/contract/verification/constructor-params.d.ts.map +1 -1
- package/dist/types/event/types.d.ts +3 -2
- package/dist/types/event/types.d.ts.map +1 -1
- package/dist/types/exports/ai.d.ts +2 -0
- package/dist/types/exports/ai.d.ts.map +1 -0
- package/dist/types/exports/react.d.ts +1 -1
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +1 -1
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/exports/utils.d.ts +2 -1
- package/dist/types/exports/utils.d.ts.map +1 -1
- package/dist/types/exports/wallets/engine.d.ts +2 -0
- package/dist/types/exports/wallets/engine.d.ts.map +1 -0
- package/dist/types/exports/wallets.d.ts +2 -0
- package/dist/types/exports/wallets.d.ts.map +1 -1
- package/dist/types/extensions/ens/resolve-l2-name.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/write/mintTo.d.ts +1 -1
- package/dist/types/extensions/erc1155/write/mintTo.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/write/mintToBatch.d.ts +1 -1
- package/dist/types/extensions/erc1155/write/mintToBatch.d.ts.map +1 -1
- package/dist/types/extensions/modules/ClaimableERC1155/setClaimConditions.d.ts.map +1 -1
- package/dist/types/extensions/modules/MintableERC1155/mintWithRole.d.ts +1 -1
- package/dist/types/extensions/modules/MintableERC1155/mintWithRole.d.ts.map +1 -1
- package/dist/types/extensions/modules/MintableERC1155/mintWithSignature.d.ts +1 -1
- package/dist/types/extensions/modules/MintableERC1155/mintWithSignature.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAutoConnect.d.ts +1 -13
- package/dist/types/react/core/hooks/wallets/useAutoConnect.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useSendToken.d.ts.map +1 -1
- package/dist/types/react/native/hooks/wallets/useAutoConnect.d.ts +1 -1
- package/dist/types/react/native/hooks/wallets/useAutoConnect.d.ts.map +1 -1
- package/dist/types/react/native/ui/AutoConnect/AutoConnect.d.ts +1 -1
- package/dist/types/react/web/hooks/wallets/useAutoConnect.d.ts +1 -1
- package/dist/types/react/web/hooks/wallets/useAutoConnect.d.ts.map +1 -1
- package/dist/types/react/web/ui/AutoConnect/AutoConnect.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts +2 -0
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/useConnectModal.d.ts.map +1 -1
- package/dist/types/react/web/wallets/in-app/WalletAuth.d.ts.map +1 -1
- package/dist/types/utils/ens/isValidENSName.d.ts +14 -0
- package/dist/types/utils/ens/isValidENSName.d.ts.map +1 -0
- package/dist/types/utils/timeoutPromise.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/connection/autoConnect.d.ts +27 -0
- package/dist/types/wallets/connection/autoConnect.d.ts.map +1 -0
- package/dist/types/wallets/connection/autoConnectCore.d.ts +32 -0
- package/dist/types/wallets/connection/autoConnectCore.d.ts.map +1 -0
- package/dist/types/{react/core/hooks → wallets}/connection/types.d.ts +5 -5
- package/dist/types/wallets/connection/types.d.ts.map +1 -0
- package/dist/types/wallets/defaultWallets.d.ts +11 -0
- package/dist/types/wallets/defaultWallets.d.ts.map +1 -0
- package/dist/types/wallets/engine/index.d.ts +54 -0
- package/dist/types/wallets/engine/index.d.ts.map +1 -0
- package/dist/types/wallets/smart/lib/signing.d.ts +1 -1
- package/package.json +9 -1
- package/src/ai/chat.test.ts +31 -0
- package/src/ai/chat.ts +26 -0
- package/src/ai/common.ts +114 -0
- package/src/ai/execute.test.ts +43 -0
- package/src/ai/execute.ts +44 -0
- package/src/ai/index.ts +3 -0
- package/src/auth/is-erc6492-signature.ts +2 -2
- package/src/auth/parse-erc6492-signature.ts +10 -4
- package/src/auth/verify-hash.ts +16 -20
- package/src/auth/verify-signature.test.ts +48 -2
- package/src/auth/verify-signature.ts +24 -7
- package/src/auth/verify-typed-data.ts +9 -7
- package/src/contract/deployment/utils/create-2-factory.ts +4 -3
- package/src/contract/verification/constructor-params.ts +8 -15
- package/src/event/types.ts +6 -5
- package/src/exports/ai.ts +1 -0
- package/src/exports/react.native.ts +1 -1
- package/src/exports/react.ts +1 -1
- package/src/exports/utils.ts +4 -1
- package/src/exports/wallets/engine.ts +4 -0
- package/src/exports/wallets.ts +2 -0
- package/src/extensions/ens/resolve-l2-name.ts +21 -5
- package/src/extensions/erc1155/read/getNFTs.ts +1 -1
- package/src/extensions/erc1155/write/mintTo.ts +1 -1
- package/src/extensions/erc1155/write/mintToBatch.ts +1 -1
- package/src/extensions/erc1155/write/sigMint.ts +1 -1
- package/src/extensions/modules/ClaimableERC1155/setClaimConditions.ts +2 -1
- package/src/extensions/modules/MintableERC1155/mintWithRole.ts +1 -1
- package/src/extensions/modules/MintableERC1155/mintWithSignature.ts +1 -1
- package/src/react/core/hooks/wallets/useAutoConnect.ts +12 -158
- package/src/react/core/hooks/wallets/useAutoConnectCore.test.tsx +1 -31
- package/src/react/core/hooks/wallets/useSendToken.ts +2 -1
- package/src/react/native/hooks/wallets/useAutoConnect.ts +1 -1
- package/src/react/native/ui/AutoConnect/AutoConnect.tsx +1 -1
- package/src/react/web/hooks/wallets/useAutoConnect.ts +2 -2
- package/src/react/web/ui/AutoConnect/AutoConnect.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +2 -1
- package/src/react/web/ui/ConnectWallet/screens/WalletSwitcherConnectionScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/useConnectModal.tsx +1 -1
- package/src/react/web/wallets/in-app/WalletAuth.tsx +1 -1
- package/src/utils/abi/encodeAbiParameters.ts +15 -11
- package/src/utils/ens/isValidENSName.test.ts +39 -0
- package/src/utils/ens/isValidENSName.ts +54 -0
- package/src/utils/extensions/drops/convert-quantity.ts +1 -1
- package/src/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.ts +1 -1
- package/src/version.ts +1 -1
- package/src/wallets/connection/autoConnect.test.ts +67 -0
- package/src/wallets/connection/autoConnect.ts +58 -0
- package/src/wallets/connection/autoConnectCore.test.ts +403 -0
- package/src/wallets/connection/autoConnectCore.ts +184 -0
- package/src/{react/core/hooks → wallets}/connection/types.ts +5 -5
- package/src/{react/web/wallets → wallets}/defaultWallets.ts +5 -10
- package/src/wallets/engine/engine-account.test.ts +69 -0
- package/src/wallets/engine/index.ts +198 -0
- package/src/wallets/in-app/web/lib/get-url-token.ts +1 -1
- package/src/wallets/smart/lib/signing.ts +1 -1
- package/src/wallets/smart/smart-wallet-integration.test.ts +1 -0
- package/dist/cjs/react/core/hooks/connection/types.js.map +0 -1
- package/dist/cjs/react/core/utils/timeoutPromise.js.map +0 -1
- package/dist/cjs/react/web/wallets/defaultWallets.js.map +0 -1
- package/dist/esm/react/core/hooks/connection/types.js.map +0 -1
- package/dist/esm/react/core/utils/timeoutPromise.js.map +0 -1
- package/dist/esm/react/web/wallets/defaultWallets.js.map +0 -1
- package/dist/types/react/core/hooks/connection/types.d.ts.map +0 -1
- package/dist/types/react/core/utils/timeoutPromise.d.ts.map +0 -1
- package/dist/types/react/web/wallets/defaultWallets.d.ts +0 -11
- package/dist/types/react/web/wallets/defaultWallets.d.ts.map +0 -1
- /package/dist/cjs/{react/core/utils → utils}/timeoutPromise.js +0 -0
- /package/dist/cjs/{react/core/hooks → wallets}/connection/types.js +0 -0
- /package/dist/esm/{react/core/utils → utils}/timeoutPromise.js +0 -0
- /package/dist/esm/{react/core/hooks → wallets}/connection/types.js +0 -0
- /package/dist/types/{react/core/utils → utils}/timeoutPromise.d.ts +0 -0
- /package/src/{react/core/utils → utils}/timeoutPromise.test.ts +0 -0
- /package/src/{react/core/utils → utils}/timeoutPromise.ts +0 -0
@@ -1,5 +1,10 @@
|
|
1
1
|
import type { Address } from "abitype";
|
2
|
-
import
|
2
|
+
import * as ox__AbiParameters from "ox/AbiParameters";
|
3
|
+
import * as ox__Bytes from "ox/Bytes";
|
4
|
+
import * as ox__Ens from "ox/Ens";
|
5
|
+
import * as ox__Hash from "ox/Hash";
|
6
|
+
import * as ox__Hex from "ox/Hex";
|
7
|
+
import { keccak256 } from "viem";
|
3
8
|
import type { Chain } from "../../chains/types.js";
|
4
9
|
import type { ThirdwebClient } from "../../client/client.js";
|
5
10
|
import { getContract } from "../../contract/contract.js";
|
@@ -23,15 +28,26 @@ export type ResolveL2NameOptions = {
|
|
23
28
|
*/
|
24
29
|
const convertReverseNodeToBytes = (address: Address, chainId: number) => {
|
25
30
|
const addressFormatted = address.toLocaleLowerCase() as Address;
|
26
|
-
|
31
|
+
// We temporarily need to use the raw hashing function from noble due to a bug in ox
|
32
|
+
const addressNode = ox__Hex.fromBytes(
|
33
|
+
ox__Hash.keccak256(
|
34
|
+
ox__Bytes.fromString(addressFormatted.slice(2) as string),
|
35
|
+
),
|
36
|
+
);
|
27
37
|
const cointype = (0x80000000 | chainId) >>> 0;
|
28
38
|
|
29
39
|
const chainCoinType = cointype.toString(16).toLocaleUpperCase();
|
30
|
-
const reverseNode = namehash(
|
40
|
+
const reverseNode = ox__Ens.namehash(
|
41
|
+
`${chainCoinType.toLocaleUpperCase()}.reverse`,
|
42
|
+
);
|
31
43
|
|
32
|
-
const addressReverseNode = keccak256(
|
33
|
-
encodePacked(
|
44
|
+
const addressReverseNode = ox__Hash.keccak256(
|
45
|
+
ox__AbiParameters.encodePacked(
|
46
|
+
["bytes32", "bytes32"],
|
47
|
+
[reverseNode, addressNode],
|
48
|
+
),
|
34
49
|
);
|
50
|
+
keccak256;
|
35
51
|
return addressReverseNode;
|
36
52
|
};
|
37
53
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { maxUint256 } from "ox/Solidity";
|
2
|
+
import { encodePacked } from "viem";
|
2
3
|
import { NATIVE_TOKEN_ADDRESS } from "../../../constants/addresses.js";
|
3
4
|
import { upload } from "../../../storage/upload.js";
|
4
5
|
import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { maxUint256 } from "
|
1
|
+
import { maxUint256 } from "ox/Solidity";
|
2
2
|
import { NATIVE_TOKEN_ADDRESS } from "../../../constants/addresses.js";
|
3
3
|
import type { ThirdwebContract } from "../../../contract/contract.js";
|
4
4
|
import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
@@ -1,26 +1,14 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
4
|
-
import type { Chain } from "../../../../chains/types.js";
|
5
|
-
import type { ThirdwebClient } from "../../../../client/client.js";
|
6
4
|
import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import type { AuthStoredTokenWithCookieReturnType } from "../../../../wallets/in-app/core/authentication/types.js";
|
10
|
-
import { getUrlToken } from "../../../../wallets/in-app/web/lib/get-url-token.js";
|
5
|
+
import { autoConnectCore } from "../../../../wallets/connection/autoConnectCore.js";
|
6
|
+
import type { AutoConnectProps } from "../../../../wallets/connection/types.js";
|
11
7
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
12
|
-
import {
|
13
|
-
getLastConnectedChain,
|
14
|
-
getStoredActiveWalletId,
|
15
|
-
getStoredConnectedWalletIds,
|
16
|
-
} from "../../../../wallets/manager/index.js";
|
17
8
|
import type { WalletId } from "../../../../wallets/wallet-types.js";
|
18
9
|
import { useConnectionManagerCtx } from "../../providers/connection-manager.js";
|
19
10
|
import { setLastAuthProvider } from "../../utils/storage.js";
|
20
|
-
import { timeoutPromise } from "../../utils/timeoutPromise.js";
|
21
|
-
import type { AutoConnectProps } from "../connection/types.js";
|
22
11
|
import { useConnect } from "./useConnect.js";
|
23
|
-
import { useSetActiveWalletConnectionStatus } from "./useSetActiveWalletConnectionStatus.js";
|
24
12
|
|
25
13
|
export function useAutoConnectCore(
|
26
14
|
storage: AsyncStorage,
|
@@ -29,161 +17,27 @@ export function useAutoConnectCore(
|
|
29
17
|
getInstalledWallets?: () => Wallet[],
|
30
18
|
) {
|
31
19
|
const manager = useConnectionManagerCtx("useAutoConnect");
|
32
|
-
const setConnectionStatus = useSetActiveWalletConnectionStatus();
|
33
20
|
const { connect } = useConnect({
|
34
21
|
client: props.client,
|
35
22
|
accountAbstraction: props.accountAbstraction,
|
36
23
|
});
|
37
|
-
const { isAutoConnecting } = manager;
|
38
|
-
const { wallets, onConnect } = props;
|
39
|
-
const timeout = props.timeout ?? 15000;
|
40
|
-
// get the supported wallets from thirdweb provider
|
41
|
-
// check the storage for last connected wallets and connect them all
|
42
|
-
// check the storage for last active wallet and set it as active
|
43
|
-
const autoConnect = async (): Promise<boolean> => {
|
44
|
-
let autoConnected = false;
|
45
|
-
isAutoConnecting.setValue(true);
|
46
|
-
let [lastConnectedWalletIds, lastActiveWalletId] = await Promise.all([
|
47
|
-
getStoredConnectedWalletIds(storage),
|
48
|
-
getStoredActiveWalletId(storage),
|
49
|
-
]);
|
50
|
-
|
51
|
-
const { authResult, walletId, authProvider, authCookie } = getUrlToken();
|
52
|
-
const wallet = wallets.find((w) => w.id === walletId);
|
53
|
-
|
54
|
-
// If an auth cookie is found and this site supports the wallet, we'll set the auth cookie in the client storage
|
55
|
-
if (authCookie && wallet) {
|
56
|
-
const clientStorage = new ClientScopedStorage({
|
57
|
-
storage,
|
58
|
-
clientId: props.client.clientId,
|
59
|
-
ecosystem: isEcosystemWallet(wallet)
|
60
|
-
? {
|
61
|
-
id: wallet.id,
|
62
|
-
partnerId: wallet.getConfig()?.partnerId,
|
63
|
-
}
|
64
|
-
: undefined,
|
65
|
-
});
|
66
|
-
await clientStorage.saveAuthCookie(authCookie);
|
67
|
-
}
|
68
|
-
|
69
|
-
if (walletId) {
|
70
|
-
lastActiveWalletId = walletId;
|
71
|
-
lastConnectedWalletIds = lastConnectedWalletIds?.includes(walletId)
|
72
|
-
? lastConnectedWalletIds
|
73
|
-
: [walletId, ...(lastConnectedWalletIds || [])];
|
74
|
-
}
|
75
|
-
if (authProvider) {
|
76
|
-
await setLastAuthProvider(authProvider, storage);
|
77
|
-
}
|
78
|
-
|
79
|
-
// if no wallets were last connected or we didn't receive an auth token
|
80
|
-
if (!lastConnectedWalletIds) {
|
81
|
-
return autoConnected;
|
82
|
-
}
|
83
|
-
|
84
|
-
// this flow can actually be used for a first connection in the case of a redirect
|
85
|
-
// in that case, we default to the passed chain to connect to
|
86
|
-
const lastConnectedChain =
|
87
|
-
(await getLastConnectedChain(storage)) || props.chain;
|
88
|
-
|
89
|
-
const availableWallets = [...wallets, ...(getInstalledWallets?.() ?? [])];
|
90
|
-
const activeWallet =
|
91
|
-
lastActiveWalletId &&
|
92
|
-
(availableWallets.find((w) => w.id === lastActiveWalletId) ||
|
93
|
-
createWalletFn(lastActiveWalletId));
|
94
|
-
|
95
|
-
if (activeWallet) {
|
96
|
-
try {
|
97
|
-
setConnectionStatus("connecting"); // only set connecting status if we are connecting the last active EOA
|
98
|
-
await timeoutPromise(
|
99
|
-
handleWalletConnection({
|
100
|
-
wallet: activeWallet,
|
101
|
-
client: props.client,
|
102
|
-
lastConnectedChain,
|
103
|
-
authResult,
|
104
|
-
}),
|
105
|
-
{
|
106
|
-
ms: timeout,
|
107
|
-
message: `AutoConnect timeout: ${timeout}ms limit exceeded.`,
|
108
|
-
},
|
109
|
-
).catch((err) => {
|
110
|
-
console.warn(err.message);
|
111
|
-
if (props.onTimeout) {
|
112
|
-
props.onTimeout();
|
113
|
-
}
|
114
|
-
});
|
115
|
-
|
116
|
-
// connected wallet could be activeWallet or smart wallet
|
117
|
-
const connectedWallet = await connect(activeWallet);
|
118
|
-
|
119
|
-
if (connectedWallet) {
|
120
|
-
if (onConnect) {
|
121
|
-
try {
|
122
|
-
onConnect(connectedWallet);
|
123
|
-
autoConnected = true;
|
124
|
-
} catch {
|
125
|
-
// ignore
|
126
|
-
}
|
127
|
-
}
|
128
|
-
} else {
|
129
|
-
setConnectionStatus("disconnected");
|
130
|
-
}
|
131
|
-
} catch (e) {
|
132
|
-
if (e instanceof Error) {
|
133
|
-
console.warn("Error auto connecting wallet:", e.message);
|
134
|
-
}
|
135
|
-
setConnectionStatus("disconnected");
|
136
|
-
}
|
137
|
-
} else {
|
138
|
-
setConnectionStatus("disconnected");
|
139
|
-
}
|
140
|
-
|
141
|
-
// then connect wallets that were last connected but were not set as active
|
142
|
-
const otherWallets = availableWallets.filter(
|
143
|
-
(w) =>
|
144
|
-
w.id !== lastActiveWalletId && lastConnectedWalletIds.includes(w.id),
|
145
|
-
);
|
146
|
-
|
147
|
-
for (const wallet of otherWallets) {
|
148
|
-
try {
|
149
|
-
await handleWalletConnection({
|
150
|
-
wallet,
|
151
|
-
client: props.client,
|
152
|
-
lastConnectedChain,
|
153
|
-
authResult,
|
154
|
-
});
|
155
|
-
manager.addConnectedWallet(wallet);
|
156
|
-
} catch {
|
157
|
-
// no-op
|
158
|
-
}
|
159
|
-
}
|
160
|
-
isAutoConnecting.setValue(false);
|
161
|
-
return autoConnected; // useQuery needs a return value
|
162
|
-
};
|
163
24
|
|
164
25
|
// trigger the auto connect on first mount only
|
165
26
|
const query = useQuery({
|
166
27
|
queryKey: ["autoConnect", props.client.clientId],
|
167
|
-
queryFn:
|
28
|
+
queryFn: () =>
|
29
|
+
autoConnectCore({
|
30
|
+
createWalletFn,
|
31
|
+
manager,
|
32
|
+
props,
|
33
|
+
storage,
|
34
|
+
connectOverride: connect,
|
35
|
+
getInstalledWallets,
|
36
|
+
setLastAuthProvider,
|
37
|
+
}),
|
168
38
|
refetchOnMount: false,
|
169
39
|
refetchOnWindowFocus: false,
|
170
40
|
});
|
171
41
|
|
172
42
|
return query;
|
173
43
|
}
|
174
|
-
|
175
|
-
/**
|
176
|
-
* @internal
|
177
|
-
*/
|
178
|
-
export async function handleWalletConnection(props: {
|
179
|
-
wallet: Wallet;
|
180
|
-
client: ThirdwebClient;
|
181
|
-
authResult: AuthStoredTokenWithCookieReturnType | undefined;
|
182
|
-
lastConnectedChain: Chain | undefined;
|
183
|
-
}) {
|
184
|
-
return props.wallet.autoConnect({
|
185
|
-
client: props.client,
|
186
|
-
chain: props.lastConnectedChain,
|
187
|
-
authResult: props.authResult,
|
188
|
-
});
|
189
|
-
}
|
@@ -6,15 +6,11 @@ import { TEST_CLIENT } from "~test/test-clients.js";
|
|
6
6
|
import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
|
7
7
|
import { createWalletAdapter } from "../../../../adapters/wallet-adapter.js";
|
8
8
|
import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
|
9
|
-
import { isAddress } from "../../../../utils/address.js";
|
10
9
|
import { createConnectionManager } from "../../../../wallets/manager/index.js";
|
11
10
|
import type { WalletId } from "../../../../wallets/wallet-types.js";
|
12
11
|
import { ThirdwebProvider } from "../../../web/providers/thirdweb-provider.js";
|
13
12
|
import { ConnectionManagerCtx } from "../../providers/connection-manager.js";
|
14
|
-
import {
|
15
|
-
handleWalletConnection,
|
16
|
-
useAutoConnectCore,
|
17
|
-
} from "./useAutoConnect.js";
|
13
|
+
import { useAutoConnectCore } from "./useAutoConnect.js";
|
18
14
|
|
19
15
|
describe("useAutoConnectCore", () => {
|
20
16
|
const mockStorage = new MockStorage();
|
@@ -159,29 +155,3 @@ describe("useAutoConnectCore", () => {
|
|
159
155
|
);
|
160
156
|
});
|
161
157
|
});
|
162
|
-
|
163
|
-
describe("handleWalletConnection", () => {
|
164
|
-
const wallet = createWalletAdapter({
|
165
|
-
adaptedAccount: TEST_ACCOUNT_A,
|
166
|
-
client: TEST_CLIENT,
|
167
|
-
chain: ethereum,
|
168
|
-
onDisconnect: () => {},
|
169
|
-
switchChain: () => {},
|
170
|
-
});
|
171
|
-
it("should return the correct result", async () => {
|
172
|
-
const result = await handleWalletConnection({
|
173
|
-
client: TEST_CLIENT,
|
174
|
-
lastConnectedChain: ethereum,
|
175
|
-
authResult: undefined,
|
176
|
-
wallet,
|
177
|
-
});
|
178
|
-
|
179
|
-
expect("address" in result).toBe(true);
|
180
|
-
expect(isAddress(result.address)).toBe(true);
|
181
|
-
expect("sendTransaction" in result).toBe(true);
|
182
|
-
expect(typeof result.sendTransaction).toBe("function");
|
183
|
-
expect("signMessage" in result).toBe(true);
|
184
|
-
expect("signTypedData" in result).toBe(true);
|
185
|
-
expect("signTransaction" in result).toBe(true);
|
186
|
-
});
|
187
|
-
});
|
@@ -6,6 +6,7 @@ import { transfer } from "../../../../extensions/erc20/write/transfer.js";
|
|
6
6
|
import { sendTransaction } from "../../../../transaction/actions/send-transaction.js";
|
7
7
|
import { prepareTransaction } from "../../../../transaction/prepare-transaction.js";
|
8
8
|
import { isAddress } from "../../../../utils/address.js";
|
9
|
+
import { isValidENSName } from "../../../../utils/ens/isValidENSName.js";
|
9
10
|
import { toWei } from "../../../../utils/units.js";
|
10
11
|
import { useActiveWallet } from "./useActiveWallet.js";
|
11
12
|
|
@@ -53,7 +54,7 @@ export function useSendToken(client: ThirdwebClient) {
|
|
53
54
|
// input validation
|
54
55
|
if (
|
55
56
|
!receiverAddress ||
|
56
|
-
(!receiverAddress
|
57
|
+
(!isValidENSName(receiverAddress) && !isAddress(receiverAddress))
|
57
58
|
) {
|
58
59
|
throw new Error("Invalid receiver address");
|
59
60
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { nativeLocalStorage } from "../../../../utils/storage/nativeStorage.js";
|
2
|
+
import type { AutoConnectProps } from "../../../../wallets/connection/types.js";
|
2
3
|
import { createWallet } from "../../../../wallets/native/create-wallet.js";
|
3
|
-
import type { AutoConnectProps } from "../../../core/hooks/connection/types.js";
|
4
4
|
import { useAutoConnectCore } from "../../../core/hooks/wallets/useAutoConnect.js";
|
5
5
|
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
|
6
6
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
2
|
+
import type { AutoConnectProps } from "../../../../wallets/connection/types.js";
|
2
3
|
import { createWallet } from "../../../../wallets/create-wallet.js";
|
4
|
+
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
|
3
5
|
import { getInstalledWalletProviders } from "../../../../wallets/injected/mipdStore.js";
|
4
|
-
import type { AutoConnectProps } from "../../../core/hooks/connection/types.js";
|
5
6
|
import { useAutoConnectCore } from "../../../core/hooks/wallets/useAutoConnect.js";
|
6
|
-
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
|
7
7
|
|
8
8
|
/**
|
9
9
|
* Autoconnect the last previously connected wallet.
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
import styled from "@emotion/styled";
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
5
|
+
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
|
5
6
|
import { iconSize } from "../../../core/design-system/index.js";
|
6
7
|
import { useSiweAuth } from "../../../core/hooks/auth/useSiweAuth.js";
|
7
8
|
import type { ConnectButtonProps } from "../../../core/hooks/connection/ConnectButtonProps.js";
|
@@ -16,7 +17,6 @@ import {
|
|
16
17
|
} from "../../providers/wallet-ui-states-provider.js";
|
17
18
|
import { canFitWideModal } from "../../utils/canFitWideModal.js";
|
18
19
|
import { usePreloadWalletProviders } from "../../utils/usePreloadWalletProviders.js";
|
19
|
-
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
|
20
20
|
import { AutoConnect } from "../AutoConnect/AutoConnect.js";
|
21
21
|
import { Modal } from "../components/Modal.js";
|
22
22
|
import { Spinner } from "../components/Spinner.js";
|
@@ -111,6 +111,8 @@ const TW_CONNECT_WALLET = "tw-connect-wallet";
|
|
111
111
|
* />;
|
112
112
|
* ```
|
113
113
|
*
|
114
|
+
* Note that this prop doesn't affect ecosystem wallets. Ecosystem wallets will only be converted to smart accounts if the ecosystem owner has enabled account abstraction.
|
115
|
+
*
|
114
116
|
* ### Enabling sign in with ethereum (Auth)
|
115
117
|
*
|
116
118
|
* ```tsx
|
@@ -2,6 +2,7 @@
|
|
2
2
|
import { useEffect, useMemo } from "react";
|
3
3
|
import type { Chain } from "../../../../../chains/types.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
5
|
+
import { getDefaultWallets } from "../../../../../wallets/defaultWallets.js";
|
5
6
|
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
|
6
7
|
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
|
7
8
|
import {
|
@@ -21,7 +22,6 @@ import { useConnectionManager } from "../../../../core/providers/connection-mana
|
|
21
22
|
import { WalletUIStatesProvider } from "../../../providers/wallet-ui-states-provider.js";
|
22
23
|
import { canFitWideModal } from "../../../utils/canFitWideModal.js";
|
23
24
|
import { usePreloadWalletProviders } from "../../../utils/usePreloadWalletProviders.js";
|
24
|
-
import { getDefaultWallets } from "../../../wallets/defaultWallets.js";
|
25
25
|
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
|
26
26
|
import { AutoConnect } from "../../AutoConnect/AutoConnect.js";
|
27
27
|
import { DynamicHeight } from "../../components/DynamicHeight.js";
|
@@ -110,6 +110,7 @@ import { useSetupScreen } from "./screen.js";
|
|
110
110
|
* }}
|
111
111
|
* />;
|
112
112
|
* ```
|
113
|
+
* Note that this prop doesn't affect ecosystem wallets. Ecosystem wallets will only be converted to smart accounts if the ecosystem owner has enabled account abstraction.
|
113
114
|
*
|
114
115
|
* ### Enabling sign in with ethereum (Auth)
|
115
116
|
*
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import type { Chain } from "../../../../../chains/types.js";
|
2
2
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
3
|
+
import { getDefaultWallets } from "../../../../../wallets/defaultWallets.js";
|
3
4
|
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
|
4
5
|
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
|
5
6
|
import type { AppMetadata } from "../../../../../wallets/types.js";
|
6
7
|
import type { WalletId } from "../../../../../wallets/wallet-types.js";
|
7
8
|
import { useConnectedWallets } from "../../../../core/hooks/wallets/useConnectedWallets.js";
|
8
|
-
import { getDefaultWallets } from "../../../wallets/defaultWallets.js";
|
9
9
|
import { ConnectModalContent } from "../Modal/ConnectModalContent.js";
|
10
10
|
import { useSetupScreen } from "../Modal/screen.js";
|
11
11
|
import type { ConnectLocale } from "../locale/types.js";
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { useCallback, useContext, useMemo, useState } from "react";
|
2
2
|
import type { Chain } from "../../../../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
|
+
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
|
4
5
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
5
6
|
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
|
6
7
|
import type { AppMetadata } from "../../../../wallets/types.js";
|
@@ -8,7 +9,6 @@ import type { Theme } from "../../../core/design-system/index.js";
|
|
8
9
|
import { SetRootElementContext } from "../../../core/providers/RootElementContext.js";
|
9
10
|
import { WalletUIStatesProvider } from "../../providers/wallet-ui-states-provider.js";
|
10
11
|
import { canFitWideModal } from "../../utils/canFitWideModal.js";
|
11
|
-
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
|
12
12
|
import type { LocaleId } from "../types.js";
|
13
13
|
import ConnectModal from "./Modal/ConnectModal.js";
|
14
14
|
import { getConnectLocale } from "./locale/getConnectLocale.js";
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Suspense, useRef, useState } from "react";
|
2
2
|
import { defineChain } from "../../../../chains/utils.js";
|
3
3
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
|
+
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
|
4
5
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
5
6
|
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
6
7
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
@@ -13,7 +14,6 @@ import type { ConnectLocale } from "../../ui/ConnectWallet/locale/types.js";
|
|
13
14
|
import { Spacer } from "../../ui/components/Spacer.js";
|
14
15
|
import { WalletImage } from "../../ui/components/WalletImage.js";
|
15
16
|
import { Container, ModalHeader } from "../../ui/components/basic.js";
|
16
|
-
import { getDefaultWallets } from "../defaultWallets.js";
|
17
17
|
import { ErrorState } from "../shared/ErrorState.js";
|
18
18
|
import { LoadingScreen } from "../shared/LoadingScreen.js";
|
19
19
|
import { LoadingState } from "../shared/LoadingState.js";
|
@@ -3,7 +3,7 @@ import type {
|
|
3
3
|
AbiParameterToPrimitiveType,
|
4
4
|
AbiParametersToPrimitiveTypes,
|
5
5
|
} from "abitype";
|
6
|
-
import
|
6
|
+
import * as ox__Hex from "ox/Hex";
|
7
7
|
import { isAddress } from "../address.js";
|
8
8
|
import { byteSize } from "../encoding/helpers/byte-size.js";
|
9
9
|
import {
|
@@ -149,7 +149,7 @@ function encodeParams(preparedParams: PreparedParam[]): Hex {
|
|
149
149
|
}
|
150
150
|
|
151
151
|
// 3. Concatenate static and dynamic parts.
|
152
|
-
return concat([...staticParams, ...dynamicParams]);
|
152
|
+
return ox__Hex.concat(...[...staticParams, ...dynamicParams]);
|
153
153
|
}
|
154
154
|
|
155
155
|
/////////////////////////////////////////////////////////////////
|
@@ -200,7 +200,10 @@ function encodeArray<const TParam extends AbiParameter>(
|
|
200
200
|
const length_ = numberToHex(preparedParams.length, { size: 32 });
|
201
201
|
return {
|
202
202
|
dynamic: true,
|
203
|
-
encoded:
|
203
|
+
encoded:
|
204
|
+
preparedParams.length > 0
|
205
|
+
? ox__Hex.concat(...[length_, data])
|
206
|
+
: length_,
|
204
207
|
};
|
205
208
|
}
|
206
209
|
if (dynamicChild) {
|
@@ -209,7 +212,7 @@ function encodeArray<const TParam extends AbiParameter>(
|
|
209
212
|
}
|
210
213
|
return {
|
211
214
|
dynamic: false,
|
212
|
-
encoded: concat(preparedParams.map(({ encoded }) => encoded)),
|
215
|
+
encoded: ox__Hex.concat(...preparedParams.map(({ encoded }) => encoded)),
|
213
216
|
};
|
214
217
|
}
|
215
218
|
|
@@ -231,7 +234,9 @@ function encodeBytes<const TParam extends AbiParameter>(
|
|
231
234
|
}
|
232
235
|
return {
|
233
236
|
dynamic: true,
|
234
|
-
encoded: concat(
|
237
|
+
encoded: ox__Hex.concat(
|
238
|
+
...[padHex(numberToHex(bytesSize, { size: 32 })), value_],
|
239
|
+
),
|
235
240
|
};
|
236
241
|
}
|
237
242
|
if (bytesSize !== Number.parseInt(paramSize)) {
|
@@ -263,17 +268,16 @@ function encodeString(value: string): PreparedParam {
|
|
263
268
|
const parts: Hex[] = [];
|
264
269
|
for (let i = 0; i < partsLength; i++) {
|
265
270
|
parts.push(
|
266
|
-
padHex(slice(hexValue, i * 32, (i + 1) * 32), {
|
271
|
+
padHex(ox__Hex.slice(hexValue, i * 32, (i + 1) * 32), {
|
267
272
|
dir: "right",
|
268
273
|
}),
|
269
274
|
);
|
270
275
|
}
|
271
276
|
return {
|
272
277
|
dynamic: true,
|
273
|
-
encoded: concat(
|
274
|
-
padHex(numberToHex(byteSize(hexValue), { size: 32 })),
|
275
|
-
|
276
|
-
]),
|
278
|
+
encoded: ox__Hex.concat(
|
279
|
+
...[padHex(numberToHex(byteSize(hexValue), { size: 32 })), ...parts],
|
280
|
+
),
|
277
281
|
};
|
278
282
|
}
|
279
283
|
|
@@ -304,7 +308,7 @@ function encodeTuple<
|
|
304
308
|
dynamic,
|
305
309
|
encoded: dynamic
|
306
310
|
? encodeParams(preparedParams)
|
307
|
-
: concat(preparedParams.map(({ encoded }) => encoded)),
|
311
|
+
: ox__Hex.concat(...preparedParams.map(({ encoded }) => encoded)),
|
308
312
|
};
|
309
313
|
}
|
310
314
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { isValidENSName } from "./isValidENSName.js";
|
3
|
+
|
4
|
+
describe("isValidENSName", () => {
|
5
|
+
it("should return true for a valid ENS name", () => {
|
6
|
+
expect(isValidENSName("thirdweb.eth")).toBe(true);
|
7
|
+
expect(isValidENSName("deployer.thirdweb.eth")).toBe(true);
|
8
|
+
expect(isValidENSName("x.eth")).toBe(true);
|
9
|
+
expect(isValidENSName("foo.bar.com")).toBe(true);
|
10
|
+
expect(isValidENSName("foo.com")).toBe(true);
|
11
|
+
expect(isValidENSName("somename.xyz")).toBe(true);
|
12
|
+
expect(isValidENSName("_foo.bar")).toBe(true);
|
13
|
+
expect(isValidENSName("-foo.bar.com")).toBe(true);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should return false for an invalid ENS name", () => {
|
17
|
+
// No TLD
|
18
|
+
expect(isValidENSName("")).toBe(false);
|
19
|
+
expect(isValidENSName("foo")).toBe(false);
|
20
|
+
|
21
|
+
// parts with length < 2
|
22
|
+
expect(isValidENSName(".eth")).toBe(false);
|
23
|
+
expect(isValidENSName("foo..com")).toBe(false);
|
24
|
+
expect(isValidENSName("thirdweb.eth.")).toBe(false);
|
25
|
+
|
26
|
+
// numeric TLD
|
27
|
+
expect(isValidENSName("foo.123")).toBe(false);
|
28
|
+
|
29
|
+
// whitespace in parts
|
30
|
+
expect(isValidENSName("foo .com")).toBe(false);
|
31
|
+
expect(isValidENSName("foo. com")).toBe(false);
|
32
|
+
|
33
|
+
// full-width characters
|
34
|
+
expect(isValidENSName("foo.bar.com")).toBe(false);
|
35
|
+
|
36
|
+
// wildcard characters
|
37
|
+
expect(isValidENSName("foo*bar.com")).toBe(false);
|
38
|
+
});
|
39
|
+
});
|