Compare commits

...
Author SHA1 Message Date
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
b62dc4abb3 Version Packages (#2820)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-04-23 21:58:09 +12:00
Joaquim VergesandGitHub be8541054e fix: erc1155 sigmint with additional supply (#2834) 2024-04-23 21:11:12 +12:00
Manan TankandGitHub 38f3b2eb21 Fix Smart Wallet + In-app wallet connection (#2831) 2024-04-22 21:33:12 +00:00
Joaquim VergesandGitHub 493bf8d2db fix: jsdoc for useConnect (#2830) 2024-04-23 08:21:23 +12:00
a919b27c7a Add extension: multicall3 (#2822)
Signed-off-by: Jonas Daniels <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2024-04-22 17:46:01 +00:00
FirekeeperandGitHub 0ca69a9234 Unity 4.12.2 (#2824) 2024-04-22 17:17:57 +00:00
github-actions[bot]GitHubgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
6d6e0ac694 chore(chains): update chains (#2819)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-04-20 12:38:18 -07:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
8516fc11f9 Version Packages (#2817)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-19 14:36:14 -07:00
github-actions[bot]GitHubgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
b4e7c74ce5 chore(chains): update chains (#2812)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-04-19 11:11:44 -07:00
Jonas DanielsandGitHub d6646475e2 refactor(viem): explicitly type walletClient return type (#2816) 2024-04-19 17:30:13 +00:00
Jonas DanielsandGitHub 4dbcbd13db feat(react): initial auth for <ConnectButton /> (#2793)
Co-authored-by: Manan Tank <[email protected]>
2024-04-19 10:36:11 -07:00
78 changed files with 3732 additions and 49 deletions
+14
View File
@@ -1,5 +1,19 @@
# @thirdweb-dev/auth
## 4.1.65
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.5.7
## 4.1.64
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.5.6
## 4.1.63
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "4.1.63",
"version": "4.1.65",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+12
View File
@@ -1,5 +1,17 @@
# @thirdweb-dev/chains
## 0.1.98
### Patch Changes
- [#2819](https://github.com/thirdweb-dev/js/pull/2819) [`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.97
### Patch Changes
- [#2812](https://github.com/thirdweb-dev/js/pull/2812) [`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.96
### Patch Changes
+31
View File
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"chain": "IOTA EVM",
"chainId": 1075,
"explorers": [],
"faucets": [
"https://evm-toolkit.evm.testnet.iotaledger.net"
],
"icon": {
"url": "ipfs://bafkreibky2sy6qhi6arktayvologkrgu5kudpgdxfkx4uosbvmstz7v4di",
"width": 720,
"height": 720,
"format": "png"
},
"infoURL": "https://www.iota.org",
"name": "IOTA EVM Testnet",
"nativeCurrency": {
"name": "IOTA",
"symbol": "IOTA",
"decimals": 18
},
"networkId": 1075,
"rpc": [
"https://1075.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://json-rpc.evm.testnet.iotaledger.net"
],
"shortName": "iotaevm-testnet",
"slug": "iota-evm-testnet",
"testnet": true,
"title": "IOTA EVM Testnet"
} as const satisfies Chain;
+40
View File
@@ -0,0 +1,40 @@
import type { Chain } from "../src/types";
export default {
"chain": "MOS",
"chainId": 1188,
"explorers": [
{
"name": "mosscan",
"url": "https://www.mosscan.com",
"standard": "none",
"icon": {
"url": "ipfs://QmczQf61mZmg3NmmGnwseDxzH1AqapA252KCTT85GuNG96",
"width": 51,
"height": 50,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmczQf61mZmg3NmmGnwseDxzH1AqapA252KCTT85GuNG96",
"width": 51,
"height": 50,
"format": "png"
},
"infoURL": "https://www.mosscan.com",
"name": "ClubMos Mainnet",
"nativeCurrency": {
"name": "ClubMos",
"symbol": "MOS",
"decimals": 18
},
"networkId": 1188,
"rpc": [
"https://1188.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.mosscan.com"
],
"shortName": "MOS",
"slug": "clubmos",
"testnet": false
} as const satisfies Chain;
+28
View File
@@ -0,0 +1,28 @@
import type { Chain } from "../src/types";
export default {
"chain": "ETH",
"chainId": 1221,
"explorers": [],
"faucets": [],
"icon": {
"url": "ipfs://QmeC4mKGbBpwmLfFxUSsareWkSWJomevUmex8ajjxo1zHx",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://www.cyclenetwork.io/",
"name": "Cycle Network Testnet",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"networkId": 1221,
"rpc": [
"https://1221.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc-testnet.cyclenetwork.io"
],
"shortName": "Cycle",
"slug": "cycle-network-testnet",
"testnet": true
} as const satisfies Chain;
+46
View File
@@ -0,0 +1,46 @@
import type { Chain } from "../src/types";
export default {
"chain": "MagApe",
"chainId": 141319,
"explorers": [
{
"name": "etherscan",
"url": "http://testnet-api.magape.io:81",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmPsxWMvnxnZ9dZcRJJMaE24o34dQsnsAMCJh3kVDrE1aB",
"width": 1000,
"height": 1000,
"format": "png"
}
}
],
"faucets": [],
"features": [
{
"name": "EIP155"
}
],
"icon": {
"url": "ipfs://QmPsxWMvnxnZ9dZcRJJMaE24o34dQsnsAMCJh3kVDrE1aB",
"width": 1000,
"height": 1000,
"format": "png"
},
"infoURL": "https://magape.io",
"name": "MagApe Testnet",
"nativeCurrency": {
"name": "MagApe",
"symbol": "MAG",
"decimals": 18
},
"networkId": 141319,
"rpc": [
"https://141319.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet-api.magape.io/chain/"
],
"shortName": "mag",
"slug": "magape-testnet",
"testnet": true,
"title": "MagApeChain"
} as const satisfies Chain;
+30
View File
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "ETH",
"chainId": 167000,
"explorers": [],
"faucets": [],
"icon": {
"url": "ipfs://QmcHdmVr5VRUJq13jnM6tgah5Ge7hn3Dm14eY6vwivJ5ui",
"width": 288,
"height": 258,
"format": "png"
},
"infoURL": "https://taiko.xyz",
"name": "Taiko Mainnet",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"networkId": 167000,
"rpc": [
"https://167000.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.taiko.xyz",
"wss://ws.taiko.xyz"
],
"shortName": "tko-mainnet",
"slug": "taiko",
"status": "incubating",
"testnet": false
} as const satisfies Chain;
+1 -1
View File
@@ -29,7 +29,7 @@ export default {
"rpc": [
"https://167008.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.katla.taiko.xyz",
"wss://rpc.katla.taiko.xyz",
"wss://ws.katla.taiko.xyz",
"https://taiko-katla.drpc.org",
"wss://taiko-katla.drpc.org"
],
+22
View File
@@ -0,0 +1,22 @@
import type { Chain } from "../src/types";
export default {
"chain": "UPBEth",
"chainId": 1918,
"explorers": [],
"faucets": [],
"infoURL": "https://mobylab.docs.crescdi.pub.ro/blog/UPB-CRESCDI-Testnet",
"name": "UPB CRESCDI Testnet",
"nativeCurrency": {
"name": "UPBEth",
"symbol": "UPBEth",
"decimals": 18
},
"networkId": 1918,
"rpc": [
"https://1918.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet.crescdi.pub.ro"
],
"shortName": "UPBEth",
"slug": "upb-crescdi-testnet",
"testnet": true
} as const satisfies Chain;
+22
View File
@@ -0,0 +1,22 @@
import type { Chain } from "../src/types";
export default {
"chain": "GitAGI",
"chainId": 210049,
"explorers": [],
"faucets": [],
"infoURL": "https://gitagi.org/",
"name": "GitAGI Atlas Testnet",
"nativeCurrency": {
"name": "GitAGI",
"symbol": "tGAGI",
"decimals": 18
},
"networkId": 210049,
"rpc": [
"https://210049.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.gitagi.org"
],
"shortName": "atlas",
"slug": "gitagi-atlas-testnet",
"testnet": true
} as const satisfies Chain;
+2 -2
View File
@@ -16,8 +16,8 @@ export default {
},
{
"name": "ankrscan-neura",
"url": "https://testnet.neuraprotocol.io/explorer",
"standard": "none",
"url": "https://testnet.explorer.neuraprotocol.io",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmWdpK5WFKrosaCSpJRCvU7uXeKk2qVeCckTxh6Zw2JrK8",
"width": 600,
+3 -2
View File
@@ -4,7 +4,7 @@ export default {
"chainId": 4200,
"explorers": [
{
"name": "blockscout",
"name": "L2scan",
"url": "https://scan.merlinchain.io",
"standard": "EIP3091",
"icon": {
@@ -32,7 +32,8 @@ export default {
"networkId": 4200,
"rpc": [
"https://4200.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.merlinchain.io"
"https://rpc.merlinchain.io",
"https://merlin-mainnet-enterprise.unifra.io"
],
"shortName": "Merlin-Mainnet",
"slug": "merlin",
+12 -6
View File
@@ -1,11 +1,17 @@
import type { Chain } from "../src/types";
export default {
"chain": "EVMCC",
"chain": "TANGO",
"chainId": 5678,
"explorers": [],
"explorers": [
{
"name": "BlockScout",
"url": "https://3001-blockscout.a.dancebox.tanssi.network",
"standard": "EIP3091"
}
],
"faucets": [],
"infoURL": "https://tanssi.network",
"name": "Tanssi EVM ContainerChain",
"infoURL": "https://docs.tanssi.network/builders/tanssi-network/networks/dancebox/demo-evm-containerchain",
"name": "Tanssi Demo",
"nativeCurrency": {
"name": "TANGO",
"symbol": "TANGO",
@@ -17,7 +23,7 @@ export default {
"https://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network",
"wss://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network"
],
"shortName": "TanssiCC",
"slug": "tanssi-evm-containerchain",
"shortName": "tango",
"slug": "tanssi-demo",
"testnet": false
} as const satisfies Chain;
+30
View File
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 58316,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "QaUser1943 Testnet",
"nativeCurrency": {
"name": "QaUser1943 Testnet Token",
"symbol": "JAI",
"decimals": 18
},
"networkId": 58316,
"redFlags": [],
"rpc": [
"https://58316.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
],
"shortName": "QaUser1943 Testnet",
"slug": "qauser1943-testnet",
"testnet": true
} as const satisfies Chain;
+28
View File
@@ -0,0 +1,28 @@
import type { Chain } from "../src/types";
export default {
"chain": "Planq",
"chainId": 7077,
"explorers": [],
"faucets": [],
"icon": {
"url": "ipfs://QmWEy9xK5BoqxPuVs7T48WM4exJrxzkEFt45iHcxWqUy8D",
"width": 256,
"height": 256,
"format": "png"
},
"infoURL": "https://planq.network",
"name": "Planq Atlas Testnet",
"nativeCurrency": {
"name": "Planq",
"symbol": "tPLQ",
"decimals": 18
},
"networkId": 7077,
"rpc": [
"https://7077.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://evm-rpc-atlas.planq.network"
],
"shortName": "planq-atlas-testnet",
"slug": "planq-atlas-testnet",
"testnet": true
} as const satisfies Chain;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.96",
"version": "0.1.98",
"main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js",
"exports": {
File diff suppressed because one or more lines are too long
+20
View File
@@ -1,5 +1,25 @@
# thirdweb
## 0.13.73
### Patch Changes
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
- @thirdweb-dev/wallets@2.5.7
- @thirdweb-dev/auth@4.1.65
## 0.13.72
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
- @thirdweb-dev/wallets@2.5.6
- @thirdweb-dev/auth@4.1.64
## 0.13.71
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/cli",
"main": "dist/cli/index.js",
"version": "0.13.71",
"version": "0.13.73",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+20
View File
@@ -1,5 +1,25 @@
# @thirdweb-dev/react-core
## 4.6.6
### Patch Changes
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
- @thirdweb-dev/wallets@2.5.7
- @thirdweb-dev/auth@4.1.65
## 4.6.5
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
- @thirdweb-dev/wallets@2.5.6
- @thirdweb-dev/auth@4.1.64
## 4.6.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "4.6.4",
"version": "4.6.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,5 +1,9 @@
# @thirdweb-dev/react-native-compat
## 0.7.38
## 0.7.37
## 0.7.36
## 0.7.35
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.7.36",
"version": "0.7.38",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native-compat",
"license": "Apache-2.0",
+20
View File
@@ -1,5 +1,25 @@
# @thirdweb-dev/react-native
## 0.7.38
### Patch Changes
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
- @thirdweb-dev/react-core@4.6.6
- @thirdweb-dev/wallets@2.5.7
## 0.7.37
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
- @thirdweb-dev/react-core@4.6.5
- @thirdweb-dev/wallets@2.5.6
## 0.7.36
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.7.36",
"version": "0.7.38",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+20
View File
@@ -1,5 +1,25 @@
# @thirdweb-dev/react
## 4.6.6
### Patch Changes
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
- @thirdweb-dev/react-core@4.6.6
- @thirdweb-dev/wallets@2.5.7
## 4.6.5
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
- @thirdweb-dev/react-core@4.6.5
- @thirdweb-dev/wallets@2.5.6
## 4.6.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "4.6.4",
"version": "4.6.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
Binary file not shown.
+16
View File
@@ -1,5 +1,21 @@
# @thirdweb-dev/sdk
## 4.0.67
### Patch Changes
- Updated dependencies [[`be85410`](https://github.com/thirdweb-dev/js/commit/be8541054e392a12678ffee534284e7d1b203ad4), [`a919b27`](https://github.com/thirdweb-dev/js/commit/a919b27c7af41dc003ddb643eb0641eaa8aefc07), [`38f3b2e`](https://github.com/thirdweb-dev/js/commit/38f3b2eb21e74e5947f03cc594dee22c96099f8b), [`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- thirdweb@5.10.0
- @thirdweb-dev/chains@0.1.98
## 4.0.66
### Patch Changes
- Updated dependencies [[`4dbcbd1`](https://github.com/thirdweb-dev/js/commit/4dbcbd13dbd388454993aee7e67b43bb9d9249aa), [`d664647`](https://github.com/thirdweb-dev/js/commit/d6646475e2715c666316174e1c035a035a075ab1), [`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- thirdweb@5.9.0
- @thirdweb-dev/chains@0.1.97
## 4.0.65
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "4.0.65",
"version": "4.0.67",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
"license": "Apache-2.0",
Binary file not shown.
@@ -1,5 +1,27 @@
# @thirdweb-dev/unity-js-bridge
## 0.6.16
### Patch Changes
- [#2824](https://github.com/thirdweb-dev/js/pull/2824) [`0ca69a9`](https://github.com/thirdweb-dev/js/commit/0ca69a92341d6711991ca7462d2dbbd7eca261a9) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - Unity 4.12.2
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
- @thirdweb-dev/wallets@2.5.7
- @thirdweb-dev/auth@4.1.65
## 0.6.15
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
- @thirdweb-dev/wallets@2.5.6
- @thirdweb-dev/auth@4.1.64
## 0.6.14
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.6.14",
"version": "0.6.16",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
@@ -171,7 +171,7 @@ class ThirdwebBridge implements TWBridge {
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_PLATFORM = "unity";
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_VERSION = "4.12.1";
(globalThis as any).X_SDK_VERSION = "4.12.2";
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
}
+16
View File
@@ -1,5 +1,21 @@
# @thirdweb-dev/wallets
## 2.5.7
### Patch Changes
- Updated dependencies [[`6d6e0ac`](https://github.com/thirdweb-dev/js/commit/6d6e0ac69453d5a448ab771084976928313662ab)]:
- @thirdweb-dev/chains@0.1.98
- @thirdweb-dev/sdk@4.0.67
## 2.5.6
### Patch Changes
- Updated dependencies [[`b4e7c74`](https://github.com/thirdweb-dev/js/commit/b4e7c74ce5ddc88a1aa3169ea89ff139d185a648)]:
- @thirdweb-dev/chains@0.1.97
- @thirdweb-dev/sdk@4.0.66
## 2.5.5
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "2.5.5",
"version": "2.5.7",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"browser": {
+54
View File
@@ -1,5 +1,59 @@
# thirdweb
## 5.10.0
### Minor Changes
- [#2822](https://github.com/thirdweb-dev/js/pull/2822) [`a919b27`](https://github.com/thirdweb-dev/js/commit/a919b27c7af41dc003ddb643eb0641eaa8aefc07) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add multicall3 extension
### Patch Changes
- [#2834](https://github.com/thirdweb-dev/js/pull/2834) [`be85410`](https://github.com/thirdweb-dev/js/commit/be8541054e392a12678ffee534284e7d1b203ad4) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - fix: erc1155 sigmint with additional supply
- [#2831](https://github.com/thirdweb-dev/js/pull/2831) [`38f3b2e`](https://github.com/thirdweb-dev/js/commit/38f3b2eb21e74e5947f03cc594dee22c96099f8b) Thanks [@MananTank](https://github.com/MananTank)! - Fix In-App + Smart wallet Connection issue
## 5.9.0
### Minor Changes
- [#2793](https://github.com/thirdweb-dev/js/pull/2793) [`4dbcbd1`](https://github.com/thirdweb-dev/js/commit/4dbcbd13dbd388454993aee7e67b43bb9d9249aa) Thanks [@jnsdls](https://github.com/jnsdls)! - **thirdweb/react**
Add a new optional `auth` prop to `<ConnectButton />` to allow specifying a SIWE auth flow after users connect their wallets.
```jsx
<ConnectButton
client={client}
auth={{
isLoggedIn: async (address) => {
// check if the user is logged in by calling your server, etc.
// then return a boolean value
return true || false;
},
getLoginPayload: async ({ address, chainId }) => {
// send the address (and optional chainId) to your server to generate the login payload for the user to sign
// you can use the `generatePayload` function from `thirdweb/auth` to generate the payload
// once you have retrieved the payload return it from this function
return; // <the login payload here>
},
doLogin: async (loginParams) => {
// send the login params to your server where you can validate them using the `verifyPayload` function
// from `thirdweb/auth`
// you can then set a cookie or return a token to save in local storage, etc
// `isLoggedIn` will automatically get called again after this function resolves
},
doLogout: async () => {
// do anything you need to do such as clearing cookies, etc when the user should be logged out
// `isLoggedIn` will automatically get called again after this function resolves
},
}}
/>
```
### Patch Changes
- [#2816](https://github.com/thirdweb-dev/js/pull/2816) [`d664647`](https://github.com/thirdweb-dev/js/commit/d6646475e2715c666316174e1c035a035a075ab1) Thanks [@jnsdls](https://github.com/jnsdls)! - adapters(viem): explicitly type walletClient return type
## 5.8.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "thirdweb",
"version": "5.8.0",
"version": "5.10.0",
"repository": {
"type": "git",
"url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -0,0 +1,440 @@
[
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "aggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes[]",
"name": "returnData",
"type": "bytes[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bool",
"name": "allowFailure",
"type": "bool"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call3[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "aggregate3",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bool",
"name": "allowFailure",
"type": "bool"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call3Value[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "aggregate3Value",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "blockAndAggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
},
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "getBasefee",
"outputs": [
{
"internalType": "uint256",
"name": "basefee",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "getBlockHash",
"outputs": [
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getBlockNumber",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getChainId",
"outputs": [
{
"internalType": "uint256",
"name": "chainid",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockCoinbase",
"outputs": [
{
"internalType": "address",
"name": "coinbase",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockDifficulty",
"outputs": [
{
"internalType": "uint256",
"name": "difficulty",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockGasLimit",
"outputs": [
{
"internalType": "uint256",
"name": "gaslimit",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockTimestamp",
"outputs": [
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "getEthBalance",
"outputs": [
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getLastBlockHash",
"outputs": [
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "requireSuccess",
"type": "bool"
},
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "tryAggregate",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "requireSuccess",
"type": "bool"
},
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "tryBlockAndAggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
},
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall3.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "payable",
"type": "function"
}
]
@@ -55,6 +55,19 @@ describe("walletClient.toViem", () => {
throw new Error("Account not found");
}
const txHash = await walletClient.sendTransaction({
account: walletClient.account,
chain: {
id: ANVIL_CHAIN.id,
name: ANVIL_CHAIN.name || "",
rpcUrls: {
default: { http: [ANVIL_CHAIN.rpc] },
},
nativeCurrency: {
name: ANVIL_CHAIN.nativeCurrency?.name || "Ether",
symbol: ANVIL_CHAIN.nativeCurrency?.symbol || "ETH",
decimals: ANVIL_CHAIN.nativeCurrency?.decimals || 18,
},
},
to: zeroAddress,
value: 0n,
});
+1 -1
View File
@@ -170,7 +170,7 @@ type ToViemWalletClientOptions = {
chain: Chain;
};
function toViemWalletClient(options: ToViemWalletClientOptions) {
function toViemWalletClient(options: ToViemWalletClientOptions): WalletClient {
const { account, chain, client } = options;
if (!account) {
throw new Error("Wallet not connected.");
@@ -0,0 +1,43 @@
// READ
export { getBasefee } from "../../extensions/multicall3/__generated__/IMulticall3/read/getBasefee.js";
export {
getBlockHash,
type GetBlockHashParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/read/getBlockHash.js";
export { getBlockNumber } from "../../extensions/multicall3/__generated__/IMulticall3/read/getBlockNumber.js";
export { getChainId } from "../../extensions/multicall3/__generated__/IMulticall3/read/getChainId.js";
export { getCurrentBlockCoinbase } from "../../extensions/multicall3/__generated__/IMulticall3/read/getCurrentBlockCoinbase.js";
export { getCurrentBlockDifficulty } from "../../extensions/multicall3/__generated__/IMulticall3/read/getCurrentBlockDifficulty.js";
export { getCurrentBlockGasLimit } from "../../extensions/multicall3/__generated__/IMulticall3/read/getCurrentBlockGasLimit.js";
export { getCurrentBlockTimestamp } from "../../extensions/multicall3/__generated__/IMulticall3/read/getCurrentBlockTimestamp.js";
export {
getEthBalance,
type GetEthBalanceParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/read/getEthBalance.js";
export { getLastBlockHash } from "../../extensions/multicall3/__generated__/IMulticall3/read/getLastBlockHash.js";
// WRITE
export {
aggregate,
type AggregateParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/aggregate.js";
export {
aggregate3,
type Aggregate3Params,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/aggregate3.js";
export {
aggregate3Value,
type Aggregate3ValueParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/aggregate3Value.js";
export {
blockAndAggregate,
type BlockAndAggregateParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/blockAndAggregate.js";
export {
tryAggregate,
type TryAggregateParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/tryAggregate.js";
export {
tryBlockAndAggregate,
type TryBlockAndAggregateParams,
} from "../../extensions/multicall3/__generated__/IMulticall3/write/tryBlockAndAggregate.js";
+3
View File
@@ -96,3 +96,6 @@ export {
AutoConnect,
type AutoConnectProps,
} from "../react/core/hooks/connection/useAutoConnect.js";
// auth
export { type SiweAuthOptions } from "../react/core/hooks/auth/useSiweAuth.js";
@@ -123,7 +123,9 @@ export async function generateMintSignature(
uid,
pricePerToken,
tokenId:
"tokenId" in mintRequest ? mintRequest.tokenId || maxUint256 : maxUint256,
"tokenId" in mintRequest && mintRequest.tokenId !== undefined
? mintRequest.tokenId
: maxUint256,
quantity: mintRequest.quantity,
to: mintRequest.to,
royaltyRecipient: mintRequest.royaltyRecipient || account.address,
@@ -1,3 +1,4 @@
import { maxUint256 } from "viem";
import { beforeAll, describe, expect, it } from "vitest";
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
@@ -14,6 +15,7 @@ import { sendTransaction } from "../../../transaction/actions/send-transaction.j
import { toHex } from "../../../utils/encoding/hex.js";
import { deployERC20Contract } from "../../prebuilts/deploy-erc20.js";
import { deployERC1155Contract } from "../../prebuilts/deploy-erc1155.js";
import { getNFT } from "../read/getNFT.js";
import { generateMintSignature, mintWithSignature } from "./sigMint.js";
// skip this test suite if there is no secret key available to test with
@@ -78,6 +80,46 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
account: TEST_ACCOUNT_A,
});
expect(transactionHash.length).toBe(66);
const nft = await getNFT({
contract: erc1155Contract,
tokenId: 0n,
});
if (nft.type !== "ERC1155") throw new Error("Expected ERC1155 NFT");
expect(nft.id).toBe(0n);
expect(nft.supply).toBe(10n);
expect(nft.metadata.name).toBe("My NFT");
expect(nft.metadata.description).toBe("This is my NFT");
});
it("should mint additional supply", async () => {
const { payload, signature } = await generateMintSignature({
mintRequest: {
to: TEST_ACCOUNT_B.address,
quantity: 5n,
tokenId: 0n,
},
account: TEST_ACCOUNT_A,
contract: erc1155Contract,
});
const transaction = mintWithSignature({
contract: erc1155Contract,
payload,
signature,
});
const { transactionHash } = await sendTransaction({
transaction,
account: TEST_ACCOUNT_A,
});
expect(transactionHash.length).toBe(66);
const nft = await getNFT({
contract: erc1155Contract,
tokenId: 0n,
});
if (nft.type !== "ERC1155") throw new Error("Expected ERC1155 NFT");
expect(nft.id).toBe(0n);
expect(nft.supply).toBe(15n);
expect(nft.metadata.name).toBe("My NFT");
expect(nft.metadata.description).toBe("This is my NFT");
});
it("should generate a mint signature with default values", async () => {
@@ -92,6 +134,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
});
expect(payload.to).toBe(TEST_ACCOUNT_B.address);
expect(payload.tokenId).toBe(maxUint256);
expect(payload.royaltyRecipient).toBe(TEST_ACCOUNT_A.address);
expect(payload.royaltyBps).toBe(0n);
expect(payload.primarySaleRecipient).toBe(TEST_ACCOUNT_A.address);
@@ -125,7 +168,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
royaltyRecipient: TEST_ACCOUNT_B.address,
royaltyBps: 500,
primarySaleRecipient: TEST_ACCOUNT_A.address,
metadata: "https://example.com/token",
tokenId: 0n,
pricePerToken: "0.2",
currency: erc20TokenContract.address,
validityStartTimestamp: new Date(1635724800),
@@ -137,10 +180,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
});
expect(payload.to).toBe(TEST_ACCOUNT_B.address);
expect(payload.tokenId).toBe(0n);
expect(payload.royaltyRecipient).toBe(TEST_ACCOUNT_B.address);
expect(payload.royaltyBps).toBe(500n);
expect(payload.primarySaleRecipient).toBe(TEST_ACCOUNT_A.address);
expect(payload.uri).toBe("https://example.com/token");
expect(payload.uri).toBe("");
expect(payload.pricePerToken).toBe(200000000000000000n);
expect(payload.quantity).toBe(10n);
expect(payload.currency).toBe(erc20TokenContract.address);
@@ -35,7 +35,6 @@ export function executeSale(
contract: options.contract,
auctionId: options.auctionId,
});
console.log("*** winning bid", winningBid);
if (!winningBid) {
throw new Error("Auction is still active");
}
@@ -0,0 +1,72 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x3e64a696" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "basefee",
type: "uint256",
},
] as const;
/**
* Checks if the `getBasefee` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getBasefee` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetBasefeeSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetBasefeeSupported(contract);
* ```
*/
export async function isGetBasefeeSupported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getBasefee function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetBasefeeResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetBasefeeResult("...");
* ```
*/
export function decodeGetBasefeeResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getBasefee" function on the contract.
* @param options - The options for the getBasefee function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getBasefee } from "thirdweb/extensions/multicall3";
*
* const result = await getBasefee();
*
* ```
*/
export async function getBasefee(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,133 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "getBlockHash" function.
*/
export type GetBlockHashParams = {
blockNumber: AbiParameterToPrimitiveType<{
internalType: "uint256";
name: "blockNumber";
type: "uint256";
}>;
};
export const FN_SELECTOR = "0xee82ac5e" as const;
const FN_INPUTS = [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256",
},
] as const;
const FN_OUTPUTS = [
{
internalType: "bytes32",
name: "blockHash",
type: "bytes32",
},
] as const;
/**
* Checks if the `getBlockHash` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getBlockHash` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetBlockHashSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetBlockHashSupported(contract);
* ```
*/
export async function isGetBlockHashSupported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "getBlockHash" function.
* @param options - The options for the getBlockHash function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeGetBlockHashParams } "thirdweb/extensions/multicall3";
* const result = encodeGetBlockHashParams({
* blockNumber: ...,
* });
* ```
*/
export function encodeGetBlockHashParams(options: GetBlockHashParams) {
return encodeAbiParameters(FN_INPUTS, [options.blockNumber]);
}
/**
* Encodes the "getBlockHash" function into a Hex string with its parameters.
* @param options - The options for the getBlockHash function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeGetBlockHash } "thirdweb/extensions/multicall3";
* const result = encodeGetBlockHash({
* blockNumber: ...,
* });
* ```
*/
export function encodeGetBlockHash(options: GetBlockHashParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeGetBlockHashParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Decodes the result of the getBlockHash function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetBlockHashResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetBlockHashResult("...");
* ```
*/
export function decodeGetBlockHashResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getBlockHash" function on the contract.
* @param options - The options for the getBlockHash function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getBlockHash } from "thirdweb/extensions/multicall3";
*
* const result = await getBlockHash({
* blockNumber: ...,
* });
*
* ```
*/
export async function getBlockHash(
options: BaseTransactionOptions<GetBlockHashParams>,
) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [options.blockNumber],
});
}
@@ -0,0 +1,74 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x42cbb15c" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256",
},
] as const;
/**
* Checks if the `getBlockNumber` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getBlockNumber` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetBlockNumberSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetBlockNumberSupported(contract);
* ```
*/
export async function isGetBlockNumberSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getBlockNumber function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetBlockNumberResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetBlockNumberResult("...");
* ```
*/
export function decodeGetBlockNumberResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getBlockNumber" function on the contract.
* @param options - The options for the getBlockNumber function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getBlockNumber } from "thirdweb/extensions/multicall3";
*
* const result = await getBlockNumber();
*
* ```
*/
export async function getBlockNumber(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,72 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x3408e470" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "chainid",
type: "uint256",
},
] as const;
/**
* Checks if the `getChainId` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getChainId` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetChainIdSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetChainIdSupported(contract);
* ```
*/
export async function isGetChainIdSupported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getChainId function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetChainIdResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetChainIdResult("...");
* ```
*/
export function decodeGetChainIdResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getChainId" function on the contract.
* @param options - The options for the getChainId function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getChainId } from "thirdweb/extensions/multicall3";
*
* const result = await getChainId();
*
* ```
*/
export async function getChainId(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,74 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0xa8b0574e" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "address",
name: "coinbase",
type: "address",
},
] as const;
/**
* Checks if the `getCurrentBlockCoinbase` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getCurrentBlockCoinbase` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetCurrentBlockCoinbaseSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetCurrentBlockCoinbaseSupported(contract);
* ```
*/
export async function isGetCurrentBlockCoinbaseSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getCurrentBlockCoinbase function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetCurrentBlockCoinbaseResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetCurrentBlockCoinbaseResult("...");
* ```
*/
export function decodeGetCurrentBlockCoinbaseResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getCurrentBlockCoinbase" function on the contract.
* @param options - The options for the getCurrentBlockCoinbase function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getCurrentBlockCoinbase } from "thirdweb/extensions/multicall3";
*
* const result = await getCurrentBlockCoinbase();
*
* ```
*/
export async function getCurrentBlockCoinbase(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,76 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x72425d9d" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "difficulty",
type: "uint256",
},
] as const;
/**
* Checks if the `getCurrentBlockDifficulty` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getCurrentBlockDifficulty` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetCurrentBlockDifficultySupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetCurrentBlockDifficultySupported(contract);
* ```
*/
export async function isGetCurrentBlockDifficultySupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getCurrentBlockDifficulty function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetCurrentBlockDifficultyResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetCurrentBlockDifficultyResult("...");
* ```
*/
export function decodeGetCurrentBlockDifficultyResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getCurrentBlockDifficulty" function on the contract.
* @param options - The options for the getCurrentBlockDifficulty function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getCurrentBlockDifficulty } from "thirdweb/extensions/multicall3";
*
* const result = await getCurrentBlockDifficulty();
*
* ```
*/
export async function getCurrentBlockDifficulty(
options: BaseTransactionOptions,
) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,74 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x86d516e8" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "gaslimit",
type: "uint256",
},
] as const;
/**
* Checks if the `getCurrentBlockGasLimit` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getCurrentBlockGasLimit` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetCurrentBlockGasLimitSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetCurrentBlockGasLimitSupported(contract);
* ```
*/
export async function isGetCurrentBlockGasLimitSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getCurrentBlockGasLimit function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetCurrentBlockGasLimitResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetCurrentBlockGasLimitResult("...");
* ```
*/
export function decodeGetCurrentBlockGasLimitResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getCurrentBlockGasLimit" function on the contract.
* @param options - The options for the getCurrentBlockGasLimit function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getCurrentBlockGasLimit } from "thirdweb/extensions/multicall3";
*
* const result = await getCurrentBlockGasLimit();
*
* ```
*/
export async function getCurrentBlockGasLimit(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,76 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x0f28c97d" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "timestamp",
type: "uint256",
},
] as const;
/**
* Checks if the `getCurrentBlockTimestamp` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getCurrentBlockTimestamp` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetCurrentBlockTimestampSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetCurrentBlockTimestampSupported(contract);
* ```
*/
export async function isGetCurrentBlockTimestampSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getCurrentBlockTimestamp function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetCurrentBlockTimestampResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetCurrentBlockTimestampResult("...");
* ```
*/
export function decodeGetCurrentBlockTimestampResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getCurrentBlockTimestamp" function on the contract.
* @param options - The options for the getCurrentBlockTimestamp function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getCurrentBlockTimestamp } from "thirdweb/extensions/multicall3";
*
* const result = await getCurrentBlockTimestamp();
*
* ```
*/
export async function getCurrentBlockTimestamp(
options: BaseTransactionOptions,
) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,135 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "getEthBalance" function.
*/
export type GetEthBalanceParams = {
addr: AbiParameterToPrimitiveType<{
internalType: "address";
name: "addr";
type: "address";
}>;
};
export const FN_SELECTOR = "0x4d2301cc" as const;
const FN_INPUTS = [
{
internalType: "address",
name: "addr",
type: "address",
},
] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "balance",
type: "uint256",
},
] as const;
/**
* Checks if the `getEthBalance` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getEthBalance` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetEthBalanceSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetEthBalanceSupported(contract);
* ```
*/
export async function isGetEthBalanceSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "getEthBalance" function.
* @param options - The options for the getEthBalance function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeGetEthBalanceParams } "thirdweb/extensions/multicall3";
* const result = encodeGetEthBalanceParams({
* addr: ...,
* });
* ```
*/
export function encodeGetEthBalanceParams(options: GetEthBalanceParams) {
return encodeAbiParameters(FN_INPUTS, [options.addr]);
}
/**
* Encodes the "getEthBalance" function into a Hex string with its parameters.
* @param options - The options for the getEthBalance function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeGetEthBalance } "thirdweb/extensions/multicall3";
* const result = encodeGetEthBalance({
* addr: ...,
* });
* ```
*/
export function encodeGetEthBalance(options: GetEthBalanceParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeGetEthBalanceParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Decodes the result of the getEthBalance function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetEthBalanceResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetEthBalanceResult("...");
* ```
*/
export function decodeGetEthBalanceResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getEthBalance" function on the contract.
* @param options - The options for the getEthBalance function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getEthBalance } from "thirdweb/extensions/multicall3";
*
* const result = await getEthBalance({
* addr: ...,
* });
*
* ```
*/
export async function getEthBalance(
options: BaseTransactionOptions<GetEthBalanceParams>,
) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [options.addr],
});
}
@@ -0,0 +1,74 @@
import { readContract } from "../../../../../transaction/read-contract.js";
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
import { decodeAbiParameters } from "viem";
import type { Hex } from "../../../../../utils/encoding/hex.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
export const FN_SELECTOR = "0x27e86d6e" as const;
const FN_INPUTS = [] as const;
const FN_OUTPUTS = [
{
internalType: "bytes32",
name: "blockHash",
type: "bytes32",
},
] as const;
/**
* Checks if the `getLastBlockHash` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `getLastBlockHash` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isGetLastBlockHashSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isGetLastBlockHashSupported(contract);
* ```
*/
export async function isGetLastBlockHashSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Decodes the result of the getLastBlockHash function call.
* @param result - The hexadecimal result to decode.
* @returns The decoded result as per the FN_OUTPUTS definition.
* @extension MULTICALL3
* @example
* ```ts
* import { decodeGetLastBlockHashResult } from "thirdweb/extensions/multicall3";
* const result = decodeGetLastBlockHashResult("...");
* ```
*/
export function decodeGetLastBlockHashResult(result: Hex) {
return decodeAbiParameters(FN_OUTPUTS, result)[0];
}
/**
* Calls the "getLastBlockHash" function on the contract.
* @param options - The options for the getLastBlockHash function.
* @returns The parsed result of the function call.
* @extension MULTICALL3
* @example
* ```ts
* import { getLastBlockHash } from "thirdweb/extensions/multicall3";
*
* const result = await getLastBlockHash();
*
* ```
*/
export async function getLastBlockHash(options: BaseTransactionOptions) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: [],
});
}
@@ -0,0 +1,158 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "aggregate" function.
*/
export type AggregateParams = WithOverrides<{
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0x252dba42" as const;
const FN_INPUTS = [
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256",
},
{
internalType: "bytes[]",
name: "returnData",
type: "bytes[]",
},
] as const;
/**
* Checks if the `aggregate` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `aggregate` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isAggregateSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isAggregateSupported(contract);
* ```
*/
export async function isAggregateSupported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "aggregate" function.
* @param options - The options for the aggregate function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregateParams } "thirdweb/extensions/multicall3";
* const result = encodeAggregateParams({
* calls: ...,
* });
* ```
*/
export function encodeAggregateParams(options: AggregateParams) {
return encodeAbiParameters(FN_INPUTS, [options.calls]);
}
/**
* Encodes the "aggregate" function into a Hex string with its parameters.
* @param options - The options for the aggregate function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregate } "thirdweb/extensions/multicall3";
* const result = encodeAggregate({
* calls: ...,
* });
* ```
*/
export function encodeAggregate(options: AggregateParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeAggregateParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "aggregate" function on the contract.
* @param options - The options for the "aggregate" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { aggregate } from "thirdweb/extensions/multicall3";
*
* const transaction = aggregate({
* contract,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function aggregate(
options: BaseTransactionOptions<
| AggregateParams
| {
asyncParams: () => Promise<AggregateParams>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,171 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "aggregate3" function.
*/
export type Aggregate3Params = WithOverrides<{
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bool"; name: "allowFailure"; type: "bool" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call3[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0x82ad56cb" as const;
const FN_INPUTS = [
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bool",
name: "allowFailure",
type: "bool",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call3[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
components: [
{
internalType: "bool",
name: "success",
type: "bool",
},
{
internalType: "bytes",
name: "returnData",
type: "bytes",
},
],
internalType: "struct Multicall3.Result[]",
name: "returnData",
type: "tuple[]",
},
] as const;
/**
* Checks if the `aggregate3` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `aggregate3` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isAggregate3Supported } from "thirdweb/extensions/multicall3";
*
* const supported = await isAggregate3Supported(contract);
* ```
*/
export async function isAggregate3Supported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "aggregate3" function.
* @param options - The options for the aggregate3 function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregate3Params } "thirdweb/extensions/multicall3";
* const result = encodeAggregate3Params({
* calls: ...,
* });
* ```
*/
export function encodeAggregate3Params(options: Aggregate3Params) {
return encodeAbiParameters(FN_INPUTS, [options.calls]);
}
/**
* Encodes the "aggregate3" function into a Hex string with its parameters.
* @param options - The options for the aggregate3 function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregate3 } "thirdweb/extensions/multicall3";
* const result = encodeAggregate3({
* calls: ...,
* });
* ```
*/
export function encodeAggregate3(options: Aggregate3Params) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeAggregate3Params(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "aggregate3" function on the contract.
* @param options - The options for the "aggregate3" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { aggregate3 } from "thirdweb/extensions/multicall3";
*
* const transaction = aggregate3({
* contract,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function aggregate3(
options: BaseTransactionOptions<
| Aggregate3Params
| {
asyncParams: () => Promise<Aggregate3Params>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,179 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "aggregate3Value" function.
*/
export type Aggregate3ValueParams = WithOverrides<{
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bool"; name: "allowFailure"; type: "bool" },
{ internalType: "uint256"; name: "value"; type: "uint256" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call3Value[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0x174dea71" as const;
const FN_INPUTS = [
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bool",
name: "allowFailure",
type: "bool",
},
{
internalType: "uint256",
name: "value",
type: "uint256",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call3Value[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
components: [
{
internalType: "bool",
name: "success",
type: "bool",
},
{
internalType: "bytes",
name: "returnData",
type: "bytes",
},
],
internalType: "struct Multicall3.Result[]",
name: "returnData",
type: "tuple[]",
},
] as const;
/**
* Checks if the `aggregate3Value` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `aggregate3Value` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isAggregate3ValueSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isAggregate3ValueSupported(contract);
* ```
*/
export async function isAggregate3ValueSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "aggregate3Value" function.
* @param options - The options for the aggregate3Value function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregate3ValueParams } "thirdweb/extensions/multicall3";
* const result = encodeAggregate3ValueParams({
* calls: ...,
* });
* ```
*/
export function encodeAggregate3ValueParams(options: Aggregate3ValueParams) {
return encodeAbiParameters(FN_INPUTS, [options.calls]);
}
/**
* Encodes the "aggregate3Value" function into a Hex string with its parameters.
* @param options - The options for the aggregate3Value function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeAggregate3Value } "thirdweb/extensions/multicall3";
* const result = encodeAggregate3Value({
* calls: ...,
* });
* ```
*/
export function encodeAggregate3Value(options: Aggregate3ValueParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeAggregate3ValueParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "aggregate3Value" function on the contract.
* @param options - The options for the "aggregate3Value" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { aggregate3Value } from "thirdweb/extensions/multicall3";
*
* const transaction = aggregate3Value({
* contract,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function aggregate3Value(
options: BaseTransactionOptions<
| Aggregate3ValueParams
| {
asyncParams: () => Promise<Aggregate3ValueParams>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,179 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "blockAndAggregate" function.
*/
export type BlockAndAggregateParams = WithOverrides<{
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0xc3077fa9" as const;
const FN_INPUTS = [
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256",
},
{
internalType: "bytes32",
name: "blockHash",
type: "bytes32",
},
{
components: [
{
internalType: "bool",
name: "success",
type: "bool",
},
{
internalType: "bytes",
name: "returnData",
type: "bytes",
},
],
internalType: "struct Multicall3.Result[]",
name: "returnData",
type: "tuple[]",
},
] as const;
/**
* Checks if the `blockAndAggregate` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `blockAndAggregate` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isBlockAndAggregateSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isBlockAndAggregateSupported(contract);
* ```
*/
export async function isBlockAndAggregateSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "blockAndAggregate" function.
* @param options - The options for the blockAndAggregate function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeBlockAndAggregateParams } "thirdweb/extensions/multicall3";
* const result = encodeBlockAndAggregateParams({
* calls: ...,
* });
* ```
*/
export function encodeBlockAndAggregateParams(
options: BlockAndAggregateParams,
) {
return encodeAbiParameters(FN_INPUTS, [options.calls]);
}
/**
* Encodes the "blockAndAggregate" function into a Hex string with its parameters.
* @param options - The options for the blockAndAggregate function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeBlockAndAggregate } "thirdweb/extensions/multicall3";
* const result = encodeBlockAndAggregate({
* calls: ...,
* });
* ```
*/
export function encodeBlockAndAggregate(options: BlockAndAggregateParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeBlockAndAggregateParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "blockAndAggregate" function on the contract.
* @param options - The options for the "blockAndAggregate" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { blockAndAggregate } from "thirdweb/extensions/multicall3";
*
* const transaction = blockAndAggregate({
* contract,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function blockAndAggregate(
options: BaseTransactionOptions<
| BlockAndAggregateParams
| {
asyncParams: () => Promise<BlockAndAggregateParams>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,181 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "tryAggregate" function.
*/
export type TryAggregateParams = WithOverrides<{
requireSuccess: AbiParameterToPrimitiveType<{
internalType: "bool";
name: "requireSuccess";
type: "bool";
}>;
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0xbce38bd7" as const;
const FN_INPUTS = [
{
internalType: "bool",
name: "requireSuccess",
type: "bool",
},
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
components: [
{
internalType: "bool",
name: "success",
type: "bool",
},
{
internalType: "bytes",
name: "returnData",
type: "bytes",
},
],
internalType: "struct Multicall3.Result[]",
name: "returnData",
type: "tuple[]",
},
] as const;
/**
* Checks if the `tryAggregate` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `tryAggregate` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isTryAggregateSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isTryAggregateSupported(contract);
* ```
*/
export async function isTryAggregateSupported(contract: ThirdwebContract<any>) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "tryAggregate" function.
* @param options - The options for the tryAggregate function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeTryAggregateParams } "thirdweb/extensions/multicall3";
* const result = encodeTryAggregateParams({
* requireSuccess: ...,
* calls: ...,
* });
* ```
*/
export function encodeTryAggregateParams(options: TryAggregateParams) {
return encodeAbiParameters(FN_INPUTS, [
options.requireSuccess,
options.calls,
]);
}
/**
* Encodes the "tryAggregate" function into a Hex string with its parameters.
* @param options - The options for the tryAggregate function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeTryAggregate } "thirdweb/extensions/multicall3";
* const result = encodeTryAggregate({
* requireSuccess: ...,
* calls: ...,
* });
* ```
*/
export function encodeTryAggregate(options: TryAggregateParams) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeTryAggregateParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "tryAggregate" function on the contract.
* @param options - The options for the "tryAggregate" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { tryAggregate } from "thirdweb/extensions/multicall3";
*
* const transaction = tryAggregate({
* contract,
* requireSuccess: ...,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function tryAggregate(
options: BaseTransactionOptions<
| TryAggregateParams
| {
asyncParams: () => Promise<TryAggregateParams>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.requireSuccess, resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,197 @@
import type { AbiParameterToPrimitiveType } from "abitype";
import type {
BaseTransactionOptions,
WithOverrides,
} from "../../../../../transaction/types.js";
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
import { once } from "../../../../../utils/promise/once.js";
import type { ThirdwebContract } from "../../../../../contract/contract.js";
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
/**
* Represents the parameters for the "tryBlockAndAggregate" function.
*/
export type TryBlockAndAggregateParams = WithOverrides<{
requireSuccess: AbiParameterToPrimitiveType<{
internalType: "bool";
name: "requireSuccess";
type: "bool";
}>;
calls: AbiParameterToPrimitiveType<{
components: [
{ internalType: "address"; name: "target"; type: "address" },
{ internalType: "bytes"; name: "callData"; type: "bytes" },
];
internalType: "struct Multicall3.Call[]";
name: "calls";
type: "tuple[]";
}>;
}>;
export const FN_SELECTOR = "0x399542e9" as const;
const FN_INPUTS = [
{
internalType: "bool",
name: "requireSuccess",
type: "bool",
},
{
components: [
{
internalType: "address",
name: "target",
type: "address",
},
{
internalType: "bytes",
name: "callData",
type: "bytes",
},
],
internalType: "struct Multicall3.Call[]",
name: "calls",
type: "tuple[]",
},
] as const;
const FN_OUTPUTS = [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256",
},
{
internalType: "bytes32",
name: "blockHash",
type: "bytes32",
},
{
components: [
{
internalType: "bool",
name: "success",
type: "bool",
},
{
internalType: "bytes",
name: "returnData",
type: "bytes",
},
],
internalType: "struct Multicall3.Result[]",
name: "returnData",
type: "tuple[]",
},
] as const;
/**
* Checks if the `tryBlockAndAggregate` method is supported by the given contract.
* @param contract The ThirdwebContract.
* @returns A promise that resolves to a boolean indicating if the `tryBlockAndAggregate` method is supported.
* @extension MULTICALL3
* @example
* ```ts
* import { isTryBlockAndAggregateSupported } from "thirdweb/extensions/multicall3";
*
* const supported = await isTryBlockAndAggregateSupported(contract);
* ```
*/
export async function isTryBlockAndAggregateSupported(
contract: ThirdwebContract<any>,
) {
return detectMethod({
contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
});
}
/**
* Encodes the parameters for the "tryBlockAndAggregate" function.
* @param options - The options for the tryBlockAndAggregate function.
* @returns The encoded ABI parameters.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeTryBlockAndAggregateParams } "thirdweb/extensions/multicall3";
* const result = encodeTryBlockAndAggregateParams({
* requireSuccess: ...,
* calls: ...,
* });
* ```
*/
export function encodeTryBlockAndAggregateParams(
options: TryBlockAndAggregateParams,
) {
return encodeAbiParameters(FN_INPUTS, [
options.requireSuccess,
options.calls,
]);
}
/**
* Encodes the "tryBlockAndAggregate" function into a Hex string with its parameters.
* @param options - The options for the tryBlockAndAggregate function.
* @returns The encoded hexadecimal string.
* @extension MULTICALL3
* @example
* ```ts
* import { encodeTryBlockAndAggregate } "thirdweb/extensions/multicall3";
* const result = encodeTryBlockAndAggregate({
* requireSuccess: ...,
* calls: ...,
* });
* ```
*/
export function encodeTryBlockAndAggregate(
options: TryBlockAndAggregateParams,
) {
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
// we can do this because we know the specific formats of the values
return (FN_SELECTOR +
encodeTryBlockAndAggregateParams(options).slice(
2,
)) as `${typeof FN_SELECTOR}${string}`;
}
/**
* Calls the "tryBlockAndAggregate" function on the contract.
* @param options - The options for the "tryBlockAndAggregate" function.
* @returns A prepared transaction object.
* @extension MULTICALL3
* @example
* ```ts
* import { tryBlockAndAggregate } from "thirdweb/extensions/multicall3";
*
* const transaction = tryBlockAndAggregate({
* contract,
* requireSuccess: ...,
* calls: ...,
* });
*
* // Send the transaction
* ...
*
* ```
*/
export function tryBlockAndAggregate(
options: BaseTransactionOptions<
| TryBlockAndAggregateParams
| {
asyncParams: () => Promise<TryBlockAndAggregateParams>;
}
>,
) {
const asyncOptions = once(async () => {
return "asyncParams" in options ? await options.asyncParams() : options;
});
return prepareContractCall({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
params: async () => {
const resolvedOptions = await asyncOptions();
return [resolvedOptions.requireSuccess, resolvedOptions.calls] as const;
},
value: async () => (await asyncOptions()).overrides?.value,
});
}
@@ -0,0 +1,139 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { LoginPayload } from "../../../../auth/core/types.js";
import type { VerifyLoginPayloadParams } from "../../../../auth/core/verify-login-payload.js";
import { useActiveWallet } from "../../../core/hooks/wallets/wallet-hooks.js";
/**
* Options for Setting up SIWE (Sign in with Ethereum) Authentication
* @auth
*/
export type SiweAuthOptions = {
// we pass address and chainId and retrieve a login payload (we do not care how)
/**
* Method to get the login payload for given address and chainId
* @param params - The parameters to get the login payload for.
*/
getLoginPayload: (params: {
address: string;
chainId: number;
}) => Promise<LoginPayload>;
// we pass the login payload and signature and the developer passes this to the auth server however they want
/**
* Method to login with the signed login payload
* @param params
*/
doLogin: (params: VerifyLoginPayloadParams) => Promise<void>;
// we call this internally when a user explicitly disconnects their wallet
/**
* Method to logout the user
*/
doLogout: () => Promise<void>;
// the developer specifies how to check if the user is logged in, this is called internally by the component
/**
* Method to check if the user is logged in or not
* @param address
*/
isLoggedIn: (address: string) => Promise<boolean>;
};
/**
* @internal
*/
export function useSiweAuth(authOptions?: SiweAuthOptions) {
const activeWallet = useActiveWallet();
const activeAccount = activeWallet?.getAccount();
const requiresAuth = !!authOptions;
const queryClient = useQueryClient();
const isLoggedInQuery = useQuery({
queryKey: ["siwe_auth", "isLoggedIn", activeAccount?.address],
enabled: requiresAuth && !!activeAccount?.address,
queryFn: () => {
// these cases should never be hit but just in case...
if (!authOptions || !activeAccount?.address) {
return false;
}
return authOptions.isLoggedIn(activeAccount.address);
},
});
const loginMutation = useMutation({
mutationFn: async () => {
if (!authOptions) {
throw new Error("No auth options provided");
}
if (!activeWallet) {
throw new Error("No active wallet");
}
const chain = activeWallet.getChain();
if (!chain) {
throw new Error("No active chain");
}
if (!activeAccount) {
throw new Error("No active account");
}
const [payload, { signLoginPayload }] = await Promise.all([
authOptions.getLoginPayload({
address: activeAccount.address,
chainId: chain.id,
}),
// we lazy-load this because it's only needed when logging in
import("../../../../auth/core/sign-login-payload.js"),
]);
const signedPayload = await signLoginPayload({
payload,
account: activeAccount,
});
return await authOptions.doLogin(signedPayload);
},
onSettled: () => {
return queryClient.invalidateQueries({
queryKey: ["siwe_auth", "isLoggedIn"],
});
},
});
const logoutMutation = useMutation({
mutationFn: async () => {
if (!authOptions) {
throw new Error("No auth options provided");
}
return await authOptions.doLogout();
},
onSettled: () => {
return queryClient.invalidateQueries({
queryKey: ["siwe_auth", "isLoggedIn"],
});
},
});
return {
// is auth even enabled
requiresAuth,
// login
doLogin: loginMutation.mutateAsync,
isLoggingIn: loginMutation.isPending,
// logout
doLogout: logoutMutation.mutateAsync,
isLoggingOut: logoutMutation.isPending,
// checking if logged in
isLoggedIn: isLoggedInQuery.data,
isLoading: isLoggedInQuery.isLoading,
};
}
@@ -268,7 +268,7 @@ export function AutoConnect(props: AutoConnectProps) {
(async () => {
isAutoConnecting.setValue(true);
startAutoConnect();
await startAutoConnect();
isAutoConnecting.setValue(false);
})();
});
@@ -109,7 +109,7 @@ export function useSetActiveWallet() {
* @example
* ```jsx
* import { useConnect } from "thirdweb/react";
* import { metamaskWallet } from "thirdweb/wallets";
* import { createWallet } from "thirdweb/wallets";
*
* function Example() {
* const { connect, isConnecting, error } = useConnect();
@@ -118,7 +118,7 @@ export function useSetActiveWallet() {
* onClick={() =>
* connect(async () => {
* // instantiate wallet
* const wallet = metamaskWallet();
* const wallet = createWallet("io.metamask");
* // connect wallet
* await wallet.connect();
* // return the wallet
@@ -7,6 +7,7 @@ import type { AppMetadata } from "../../../wallets/types.js";
import type { ConnectButton_connectModalOptions } from "../../web/ui/ConnectWallet/ConnectWalletProps.js";
import type { ConnectLocale } from "../../web/ui/ConnectWallet/locale/types.js";
import type { LocaleId } from "../../web/ui/types.js";
import type { SiweAuthOptions } from "../hooks/auth/useSiweAuth.js";
export const ConnectUIContext = /* @__PURE__ */ createContext<{
wallets: Wallet[];
@@ -27,4 +28,5 @@ export const ConnectUIContext = /* @__PURE__ */ createContext<{
connectModal: Omit<ConnectButton_connectModalOptions, "size"> & {
size: "compact" | "wide";
};
auth?: SiweAuthOptions;
} | null>(null);
@@ -1,5 +1,6 @@
import styled from "@emotion/styled";
import { useMemo } from "react";
import { useEffect, useMemo, useState } from "react";
import { useSiweAuth } from "../../../core/hooks/auth/useSiweAuth.js";
import { AutoConnect } from "../../../core/hooks/connection/useAutoConnect.js";
import {
useActiveAccount,
@@ -12,15 +13,20 @@ import {
} from "../../providers/wallet-ui-states-provider.js";
import { canFitWideModal } from "../../utils/canFitWideModal.js";
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
import { Modal } from "../components/Modal.js";
import { Spinner } from "../components/Spinner.js";
import { Container } from "../components/basic.js";
import { Button } from "../components/buttons.js";
import { fadeInAnimation } from "../design-system/animations.js";
import { iconSize } from "../design-system/index.js";
import type { ConnectButtonProps } from "./ConnectWalletProps.js";
import { ConnectedWalletDetails } from "./Details.js";
import ConnectModal from "./Modal/ConnectModal.js";
import { defaultTokens } from "./defaultTokens.js";
import { LockIcon } from "./icons/LockIcon.js";
import { useConnectLocale } from "./locale/getConnectLocale.js";
import type { ConnectLocale } from "./locale/types.js";
import { SignatureScreen } from "./screens/SignatureScreen.js";
const TW_CONNECT_WALLET = "tw-connect-wallet";
@@ -40,7 +46,10 @@ const TW_CONNECT_WALLET = "tw-connect-wallet";
* @component
*/
export function ConnectButton(props: ConnectButtonProps) {
const wallets = props.wallets || getDefaultWallets();
const wallets = useMemo(
() => props.wallets || getDefaultWallets(),
[props.wallets],
);
const localeQuery = useConnectLocale(props.locale || "en_US");
const autoConnectComp = props.autoConnect !== false && (
@@ -100,6 +109,7 @@ export function ConnectButton(props: ConnectButtonProps) {
: props.connectModal?.size || "wide",
},
onConnect: props.onConnect,
auth: props.auth,
}}
>
<WalletUIStatesProvider theme={props.theme}>
@@ -117,6 +127,16 @@ function ConnectButtonInner(
},
) {
const activeAccount = useActiveAccount();
const siweAuth = useSiweAuth(props.auth);
const [showSignatureModal, setShowSignatureModal] = useState(false);
// if wallet gets disconnected suddently, close the signature modal if it's open
useEffect(() => {
if (!activeAccount) {
setShowSignatureModal(false);
}
}, [activeAccount]);
const theme = props.theme || "dark";
const connectionStatus = useActiveWalletConnectionStatus();
const locale = props.connectLocale;
@@ -180,6 +200,73 @@ function ConnectButtonInner(
);
}
if (siweAuth.requiresAuth) {
// loading state if loading
// TODO: figure out a way to consolidate the loading states with the ones from locale loading
if (siweAuth.isLoading) {
return (
<AnimatedButton
disabled={true}
className={`${
props.connectButton?.className || ""
} ${TW_CONNECT_WALLET}`}
variant="primary"
type="button"
style={{
minWidth: "140px",
...props.connectButton?.style,
}}
>
<Spinner size="sm" color="primaryButtonText" />
</AnimatedButton>
);
}
// sign in button + modal if *not* loading and *not* logged in
if (!siweAuth.isLoggedIn) {
return (
<>
<Button
variant="primary"
type="button"
onClick={() => {
setShowSignatureModal(true);
}}
className={props.signInButton?.className}
style={{
minWidth: "140px",
...props.signInButton?.style,
}}
>
{siweAuth.isLoggingIn ? (
<Spinner size="sm" color="primaryButtonText" />
) : (
<Container flex="row" center="y" gap="sm">
<LockIcon size={iconSize.sm} />
<span> {props.signInButton?.label || locale.signIn} </span>
</Container>
)}
</Button>
<Modal
size="compact"
open={showSignatureModal}
setOpen={setShowSignatureModal}
>
<SignatureScreen
client={props.client}
connectLocale={locale}
modalSize="compact"
termsOfServiceUrl={props.connectModal?.termsOfServiceUrl}
privacyPolicyUrl={props.connectModal?.privacyPolicyUrl}
onDone={() => setShowSignatureModal(false)}
auth={props.auth}
/>
</Modal>
</>
);
}
// otherwise, show the details button
}
return (
<ConnectedWalletDetails
theme={theme}
@@ -187,7 +274,10 @@ function ConnectButtonInner(
detailsModal={props.detailsModal}
supportedTokens={supportedTokens}
onDisconnect={() => {
// no op
// logout on explicit disconnect!
if (siweAuth.requiresAuth) {
siweAuth.doLogout();
}
}}
chains={props?.chains || []}
chain={props.chain}
@@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
import type { AppMetadata } from "../../../../wallets/types.js";
import type { SiweAuthOptions } from "../../../core/hooks/auth/useSiweAuth.js";
import type { Theme } from "../design-system/index.js";
import type { LocaleId } from "../types.js";
import type { NetworkSelectorProps } from "./NetworkSelector.js";
@@ -495,6 +496,23 @@ export type ConnectButtonProps = {
className?: string;
};
signInButton?: {
/**
* Set a custom label for the sign-in button
*/
label?: string;
/**
* CSS styles to apply to the sign-in button element
*/
style?: React.CSSProperties;
/**
* CSS class to apply to the sign-in button element
*/
className?: string;
};
/**
* Configurations for the `ConnectButton`'s Modal that is shown for connecting a wallet
* Refer to the [`ConnectButton_connectModalOptions`](https://portal.thirdweb.com/references/typescript/v5/ConnectButton_connectModalOptions) type for more details
@@ -622,4 +640,12 @@ export type ConnectButtonProps = {
* You can disable this button by setting `showAllWallets` prop to `false`
*/
showAllWallets?: boolean;
/**
* Enable SIWE (Sign in with Ethererum) by passing an object of type `SiweAuthOptions` to
* enforce the users to sign a message after connecting their wallet to authenticate themselves.
*
* Refer to the [`SiweAuthOptions`](https://portal.thirdweb.com/references/typescript/v5/SiweAuthOptions) for more details
*/
auth?: SiweAuthOptions;
};
@@ -1,8 +1,11 @@
import { useEffect } from "react";
import type { Chain } from "../../../../../chains/types.js";
import type { ThirdwebClient } from "../../../../../client/client.js";
import type { SiweAuthOptions } from "../../../../../exports/react.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
import type { AppMetadata } from "../../../../../wallets/types.js";
import { useSiweAuth } from "../../../../core/hooks/auth/useSiweAuth.js";
import { AutoConnect } from "../../../../core/hooks/connection/useAutoConnect.js";
import {
useActiveAccount,
@@ -21,6 +24,7 @@ import type { LocaleId } from "../../types.js";
import {
modalMaxWidthCompact,
modalMaxWidthWide,
reservedScreens,
wideModalMaxHeight,
} from "../constants.js";
import { useConnectLocale } from "../locale/getConnectLocale.js";
@@ -304,6 +308,14 @@ export type ConnectEmbedProps = {
* Note that if the screen width can not fit the wide modal, the `compact` version will be shown regardless of this `modalSize` options provided
*/
modalSize?: "compact" | "wide";
/**
* Enable SIWE (Sign in with Ethererum) by passing an object of type `SiweAuthOptions` to
* enforce the users to sign a message after connecting their wallet to authenticate themselves.
*
* Refer to the [`SiweAuthOptions`](https://portal.thirdweb.com/references/typescript/v5/SiweAuthOptions) for more details
*/
auth?: SiweAuthOptions;
};
/**
@@ -330,7 +342,9 @@ export type ConnectEmbedProps = {
*/
export function ConnectEmbed(props: ConnectEmbedProps) {
const activeAccount = useActiveAccount();
const show = !activeAccount;
const siweAuth = useSiweAuth(props.auth);
const show =
!activeAccount || (siweAuth.requiresAuth && !siweAuth.isLoggedIn);
const wallets = props.wallets || getDefaultWallets();
const localeId = props.locale || "en_US";
@@ -346,6 +360,7 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
appMetadata={props.appMetadata}
client={props.client}
wallets={wallets}
accountAbstraction={props.accountAbstraction}
timeout={
typeof props.autoConnect === "boolean"
? undefined
@@ -388,6 +403,7 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
termsOfServiceUrl: props.termsOfServiceUrl,
},
onConnect: props.onConnect,
auth: props.auth,
}}
>
<WalletUIStatesProvider theme={props.theme}>
@@ -412,11 +428,19 @@ const ConnectEmbedContent = (
// const requiresSignIn = false;
const screenSetup = useSetupScreen();
const { setScreen, initialScreen } = screenSetup;
const siweAuth = useSiweAuth(props.auth);
const activeAccount = useActiveAccount();
const isAutoConnecting = useIsAutoConnecting();
let content = null;
useEffect(() => {
if (siweAuth.requiresAuth && !siweAuth.isLoggedIn && activeAccount) {
setScreen(reservedScreens.signIn);
}
}, [siweAuth, setScreen, activeAccount]);
const modalSize = !canFitWideModal()
? "compact"
: props.modalSize || ("compact" as const);
@@ -1,10 +1,12 @@
import { Suspense, lazy, useCallback } from "react";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import { useSiweAuth } from "../../../../core/hooks/auth/useSiweAuth.js";
import { useConnectUI } from "../../../../core/hooks/others/useWalletConnectionCtx.js";
import { useConnect } from "../../../../core/hooks/wallets/wallet-hooks.js";
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
import { WalletSelector } from "../WalletSelector.js";
import { onModalUnmount, reservedScreens } from "../constants.js";
import { SignatureScreen } from "../screens/SignatureScreen.js";
import { StartScreen } from "../screens/StartScreen.js";
import { AnyWalletConnectUI } from "./AnyWalletConnectUI.js";
import {
@@ -27,10 +29,20 @@ export const ConnectModalContent = (props: {
}) => {
const { setModalVisibility, onClose } = props;
const { screen, setScreen, initialScreen } = props.screenSetup;
const { wallets, accountAbstraction } = useConnectUI();
const { onConnect, connectModal, connectLocale } = useConnectUI();
const {
wallets,
accountAbstraction,
auth,
onConnect,
connectModal,
connectLocale,
client,
} = useConnectUI();
const { connect } = useConnect();
const siweAuth = useSiweAuth(auth);
const showSignatureScreen = siweAuth.requiresAuth && !siweAuth.isLoggedIn;
const handleConnected = useCallback(
(wallet: Wallet) => {
connect(wallet);
@@ -43,9 +55,21 @@ export const ConnectModalContent = (props: {
setModalVisibility(true);
});
onClose();
// show sign in screen if required
if (showSignatureScreen) {
setScreen(reservedScreens.signIn);
} else {
onClose();
}
},
[setModalVisibility, onClose, onConnect, connect],
[
setModalVisibility,
onClose,
onConnect,
connect,
showSignatureScreen,
setScreen,
],
);
const handleBack = useCallback(() => {
@@ -65,6 +89,7 @@ export const ConnectModalContent = (props: {
}}
done={handleConnected}
goBack={wallets.length > 1 ? handleBack : undefined}
setModalVisibility={setModalVisibility}
/>
);
@@ -107,6 +132,18 @@ export const ConnectModalContent = (props: {
);
};
const signatureScreen = (
<SignatureScreen
onDone={onClose}
modalSize={connectModal.size}
termsOfServiceUrl={connectModal.termsOfServiceUrl}
privacyPolicyUrl={connectModal.privacyPolicyUrl}
auth={auth}
client={client}
connectLocale={connectLocale}
/>
);
return (
<ScreenSetupContext.Provider value={props.screenSetup}>
{connectModal.size === "wide" ? (
@@ -114,7 +151,7 @@ export const ConnectModalContent = (props: {
left={walletList}
right={
<>
{/* {screen === reservedScreens.signIn && signatureScreen} */}
{screen === reservedScreens.signIn && signatureScreen}
{screen === reservedScreens.main && getStarted}
{screen === reservedScreens.getStarted && getStarted}
{screen === reservedScreens.showAll && showAll}
@@ -124,7 +161,7 @@ export const ConnectModalContent = (props: {
/>
) : (
<ConnectModalCompactLayout>
{/* {screen === reservedScreens.signIn && signatureScreen} */}
{screen === reservedScreens.signIn && signatureScreen}
{screen === reservedScreens.main && walletList}
{screen === reservedScreens.getStarted && getStarted}
{screen === reservedScreens.showAll && showAll}
@@ -27,6 +27,7 @@ import { Text } from "../components/text.js";
import { useCustomTheme } from "../design-system/CustomThemeProvider.js";
import { StyledDiv, StyledUl } from "../design-system/elements.js";
import { fontSize, iconSize, radius, spacing } from "../design-system/index.js";
import { SmartConnectUI } from "./Modal/SmartWalletConnectUI.js";
import { TOS } from "./Modal/TOS.js";
import { PoweredByThirdweb } from "./PoweredByTW.js";
import { WalletButton, WalletEntryButton } from "./WalletEntryButton.js";
@@ -39,10 +40,7 @@ const InAppWalletSelectionUI = /* @__PURE__ */ lazy(
// const localWalletId = "local";
const inAppWalletId: WalletId = "inApp";
/**
* @internal
*/
export const WalletSelector: React.FC<{
type WalletSelectorProps = {
wallets: Wallet[];
selectWallet: (wallet: Wallet) => void;
onGetStarted: () => void;
@@ -50,7 +48,46 @@ export const WalletSelector: React.FC<{
done: (wallet: Wallet) => void;
goBack?: () => void;
onShowAll: () => void;
}> = (props) => {
setModalVisibility: (value: boolean) => void;
};
/**
* @internal
*/
export function WalletSelector(props: WalletSelectorProps) {
const { accountAbstraction } = useConnectUI();
const [personalWallet, setPersonalWallet] = useState<Wallet | null>(null);
if (!accountAbstraction) {
return <WalletSelectorInner {...props} />;
}
if (personalWallet) {
return (
<SmartConnectUI
accountAbstraction={accountAbstraction}
done={props.done}
personalWallet={personalWallet}
setModalVisibility={props.setModalVisibility}
onBack={props.goBack}
/>
);
}
return (
<WalletSelectorInner
{...props}
done={(w) => {
setPersonalWallet(w);
}}
/>
);
}
/**
* @internal
*/
const WalletSelectorInner: React.FC<WalletSelectorProps> = (props) => {
const { connectModal, isEmbed, client } = useConnectUI();
const isCompact = connectModal.size === "compact";
const [isWalletGroupExpanded, setIsWalletGroupExpanded] = useState(false);
@@ -0,0 +1,321 @@
import { keyframes } from "@emotion/react";
import { ReloadIcon } from "@radix-ui/react-icons";
import { useCallback, useEffect, useRef, useState } from "react";
import type { ThirdwebClient } from "../../../../../client/client.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import { useSiweAuth } from "../../../../core/hooks/auth/useSiweAuth.js";
import {
useActiveWallet,
useDisconnect,
} from "../../../../core/hooks/wallets/wallet-hooks.js";
import { wait } from "../../../../core/utils/wait.js";
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
import { Spacer } from "../../components/Spacer.js";
import { Spinner } from "../../components/Spinner.js";
import { WalletImage } from "../../components/WalletImage.js";
import { Container, ModalHeader } from "../../components/basic.js";
import { Button } from "../../components/buttons.js";
import { Text } from "../../components/text.js";
import { useCustomTheme } from "../../design-system/CustomThemeProvider.js";
import { StyledDiv } from "../../design-system/elements.js";
import { iconSize, radius, spacing } from "../../design-system/index.js";
import type { ConnectButtonProps } from "../ConnectWalletProps.js";
import { TOS } from "../Modal/TOS.js";
import type { ConnectLocale } from "../locale/types.js";
import { WalletLogoSpinner } from "./WalletLogoSpinner.js";
type Status = "signing" | "failed" | "idle";
export const SignatureScreen: React.FC<{
onDone: () => void;
modalSize: "compact" | "wide";
termsOfServiceUrl?: string;
privacyPolicyUrl?: string;
connectLocale: ConnectLocale;
client: ThirdwebClient;
auth: ConnectButtonProps["auth"];
}> = (props) => {
const {
onDone,
modalSize,
termsOfServiceUrl,
privacyPolicyUrl,
connectLocale,
} = props;
const siweAuth = useSiweAuth(props.auth);
const [status, setStatus] = useState<Status>("idle");
const { disconnect } = useDisconnect();
const wallet = useActiveWallet();
const locale = connectLocale.signatureScreen;
const signIn = useCallback(async () => {
try {
setStatus("signing");
await siweAuth.doLogin();
onDone();
} catch (err) {
await wait(1000);
setStatus("failed");
console.error("failed to log in", err);
}
}, [onDone, siweAuth]);
// this should not happen
if (!wallet) {
return <LoadingScreen />;
}
if (wallet.id === "inApp" || wallet.id === "embedded") {
return (
<HeadlessSignIn
signIn={signIn}
status={status}
connectLocale={connectLocale}
wallet={wallet}
/>
);
}
const handleRetry = () => {
signIn();
};
return (
<Container animate="fadein" fullHeight flex="column">
<Container
p="lg"
style={{
paddingBottom: 0,
}}
>
<ModalHeader title={locale.instructionScreen.title} />
</Container>
<Container
style={{
paddingTop: 0,
paddingBottom: spacing.xl,
}}
flex="column"
px={modalSize === "compact" ? "lg" : "xxl"}
center="y"
expand
>
{status === "idle" ? (
<>
<Container flex="row" center="x" animate="fadein" py="3xl">
<PulsatingContainer>
<WalletImage id={wallet.id} client={props.client} size={"80"} />
</PulsatingContainer>
</Container>
<Text center multiline balance>
{locale.instructionScreen.instruction}
</Text>
<Spacer y="lg" />
<Button
fullWidth
variant="accent"
onClick={signIn}
style={{
alignItems: "center",
padding: spacing.md,
}}
>
{connectLocale.signatureScreen.instructionScreen.signInButton}
</Button>
<Spacer y="sm" />
<Button
fullWidth
variant="secondary"
onClick={() => {
disconnect(wallet);
}}
style={{
alignItems: "center",
padding: spacing.md,
}}
>
{connectLocale.signatureScreen.instructionScreen.disconnectWallet}
</Button>
</>
) : (
<>
<Container py="3xl">
<WalletLogoSpinner error={status === "failed"} id={wallet.id} />
</Container>
<Container flex="column" gap="md" animate="fadein" key={status}>
<Text size="lg" center color="primaryText">
{status === "failed"
? locale.signingScreen.failedToSignIn
: locale.signingScreen.inProgress}
</Text>
{status === "signing" && (
<Text center multiline balance>
{connectLocale.signatureScreen.signingScreen.prompt}
</Text>
)}
{status === "failed" && (
<Container>
<Spacer y="sm" />
<Button
fullWidth
variant="accent"
onClick={handleRetry}
style={{
gap: spacing.xs,
alignItems: "center",
padding: spacing.md,
}}
>
<ReloadIcon width={iconSize.sm} height={iconSize.sm} />
{locale.signingScreen.tryAgain}
</Button>
<Spacer y="sm" />
<Button
fullWidth
variant="secondary"
onClick={() => {
disconnect(wallet);
}}
style={{
alignItems: "center",
padding: spacing.md,
}}
>
{locale.instructionScreen.disconnectWallet}
</Button>
</Container>
)}
</Container>
</>
)}
</Container>
{(termsOfServiceUrl || privacyPolicyUrl) && (
<Container p="md" animate="fadein">
<TOS
termsOfServiceUrl={termsOfServiceUrl}
privacyPolicyUrl={privacyPolicyUrl}
/>
</Container>
)}
</Container>
);
};
function HeadlessSignIn({
signIn,
status,
connectLocale,
wallet,
}: {
signIn: () => void;
status: Status;
connectLocale: ConnectLocale;
wallet: Wallet;
}) {
const locale = connectLocale.signatureScreen;
const mounted = useRef(false);
const { disconnect } = useDisconnect();
useEffect(() => {
if (mounted.current) {
return;
}
mounted.current = true;
signIn();
}, [signIn]);
return (
<Container p="lg" fullHeight flex="column" animate="fadein">
<ModalHeader title={locale.signingScreen.title} />
<Container
expand
flex="row"
center="both"
style={{
minHeight: "250px",
}}
>
{status === "signing" && <Spinner size="xl" color="accentText" />}
{status === "failed" && (
<>
<Container>
<Spacer y="lg" />
<Text size="lg" center color="danger">
{locale.signingScreen.failedToSignIn}
</Text>
<Spacer y="lg" />
<Button
fullWidth
variant="accent"
onClick={() => {
signIn();
}}
style={{
gap: spacing.xs,
alignItems: "center",
padding: spacing.md,
}}
>
<ReloadIcon width={iconSize.sm} height={iconSize.sm} />
{locale.signingScreen.tryAgain}
</Button>
<Spacer y="sm" />
<Button
fullWidth
variant="secondary"
onClick={() => {
disconnect(wallet);
}}
style={{
alignItems: "center",
padding: spacing.md,
}}
>
{locale.instructionScreen.disconnectWallet}
</Button>
</Container>
</>
)}
</Container>
</Container>
);
}
const pulseAnimation = keyframes`
0% {
transform: scale(0.9);
}
100% {
opacity: 0;
transform: scale(1.4);
}
`;
const PulsatingContainer = /* @__PURE__ */ StyledDiv(() => {
const theme = useCustomTheme();
return {
position: "relative",
"&::before": {
content: '""',
display: "block",
position: "absolute",
left: 0,
top: 0,
bottom: 0,
right: 0,
background: theme.colors.accentText,
animation: `${pulseAnimation} 2s cubic-bezier(0.175, 0.885, 0.32, 1.1) infinite`,
zIndex: -1,
borderRadius: radius.xl,
},
};
});
Binary file not shown.