diff --git a/.changeset/brave-actors-refuse.md b/.changeset/brave-actors-refuse.md deleted file mode 100644 index 37694c690b5..00000000000 --- a/.changeset/brave-actors-refuse.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch ---- - -Get the native token balance of a wallet address on the `activeChain` network set in the `ThirdwebProvider` - -```ts -const balanceQuery = useBalanceForAddress(walletAddress); - -console.log(balanceQuery.data); -``` diff --git a/.changeset/brave-ducks-jog.md b/.changeset/brave-ducks-jog.md deleted file mode 100644 index 648133cce72..00000000000 --- a/.changeset/brave-ducks-jog.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch -"@thirdweb-dev/wallets": patch -"@thirdweb-dev/react": patch ---- - -Add Rabby browser extension diff --git a/.changeset/cuddly-kings-melt.md b/.changeset/cuddly-kings-melt.md deleted file mode 100644 index 9b4db3e711c..00000000000 --- a/.changeset/cuddly-kings-melt.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Propagate isPartialAbi diff --git a/.changeset/forty-ducks-talk.md b/.changeset/forty-ducks-talk.md deleted file mode 100644 index 98edaeadd4d..00000000000 --- a/.changeset/forty-ducks-talk.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch ---- - -Don't disconnect wallet if connecting diff --git a/.changeset/forty-vans-switch.md b/.changeset/forty-vans-switch.md deleted file mode 100644 index e50b3a7e555..00000000000 --- a/.changeset/forty-vans-switch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Fix undefined error for unknown chains diff --git a/.changeset/giant-jars-visit.md b/.changeset/giant-jars-visit.md deleted file mode 100644 index f67c29c648c..00000000000 --- a/.changeset/giant-jars-visit.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@thirdweb-dev/react-native": patch -"@thirdweb-dev/react-core": patch ---- - -Share WalletConnectHandler between React and RN to support wallets as receivers diff --git a/.changeset/gorgeous-dogs-warn.md b/.changeset/gorgeous-dogs-warn.md deleted file mode 100644 index 85517dc8269..00000000000 --- a/.changeset/gorgeous-dogs-warn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/chains": patch ---- - -add & update chains diff --git a/.changeset/long-eels-shout.md b/.changeset/long-eels-shout.md deleted file mode 100644 index 7bffb3e7be9..00000000000 --- a/.changeset/long-eels-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Enable deployments for older AccountFactories diff --git a/.changeset/lovely-turtles-kneel.md b/.changeset/lovely-turtles-kneel.md deleted file mode 100644 index 18228ea4073..00000000000 --- a/.changeset/lovely-turtles-kneel.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Add missing roles from new contracts diff --git a/.changeset/orange-bobcats-brush.md b/.changeset/orange-bobcats-brush.md deleted file mode 100644 index be83228499c..00000000000 --- a/.changeset/orange-bobcats-brush.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Don't fetch metadata from CDN for local nodes diff --git a/.changeset/perfect-cups-attack.md b/.changeset/perfect-cups-attack.md new file mode 100644 index 00000000000..4e6346a0850 --- /dev/null +++ b/.changeset/perfect-cups-attack.md @@ -0,0 +1,13 @@ +--- +"@thirdweb-dev/react-native": patch +--- + +Adds the ability to login with any arbitrary login payload + +```typescript +await embeddedWallet.authenticate({ + strategy: "auth_endpoint", + payload: "SOME_STRING", + encryptionKey: "", +}); +``` diff --git a/.changeset/polite-candles-rule.md b/.changeset/polite-candles-rule.md new file mode 100644 index 00000000000..f62642a728c --- /dev/null +++ b/.changeset/polite-candles-rule.md @@ -0,0 +1,6 @@ +--- +"@thirdweb-dev/react-native": patch +"@thirdweb-dev/react-core": patch +--- + +Better comments diff --git a/.changeset/polite-waves-unite.md b/.changeset/polite-waves-unite.md deleted file mode 100644 index 2886ddefd41..00000000000 --- a/.changeset/polite-waves-unite.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/sdk": patch ---- - -Fix code comment diff --git a/.changeset/serious-pugs-return.md b/.changeset/serious-pugs-return.md deleted file mode 100644 index 32538a19600..00000000000 --- a/.changeset/serious-pugs-return.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch -"@thirdweb-dev/react": patch ---- - -- Fixes issue #1708 -- Fixes smart wallet icon shown even after clicking on "Switch to Personal wallet" in ConnectWallet dropdown diff --git a/.changeset/wicked-ladybugs-repeat.md b/.changeset/wicked-ladybugs-repeat.md deleted file mode 100644 index 2c3a6a35a7d..00000000000 --- a/.changeset/wicked-ladybugs-repeat.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch -"@thirdweb-dev/wallets": patch -"@thirdweb-dev/react": patch ---- - -Add Crypto.com Defi wallet diff --git a/.changeset/wild-tigers-design.md b/.changeset/wild-tigers-design.md deleted file mode 100644 index 662ff27207a..00000000000 --- a/.changeset/wild-tigers-design.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@thirdweb-dev/react-core": patch ---- - -Fix auto-connecting a personal wallet for smart/safe wallet diff --git a/package.json b/package.json index 6926177221d..7c33e63ac30 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "test": "turbo run test --filter=./packages/*", "e2e": "turbo run e2e", "build": "turbo run build --filter=./packages/*", + "typedoc": "turbo run typedoc", "build:release": "turbo run build --force --filter=./packages/*", "dev": "turbo run dev --no-cache --parallel --continue", "fix:repo": "manypkg fix", diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index 68576a73b57..9a2113349dd 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,40 @@ # @thirdweb-dev/auth +## 4.1.17 + +### Patch Changes + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + +## 4.1.16 + +### Patch Changes + +- Updated dependencies []: + - @thirdweb-dev/wallets@2.2.1 + +## 4.1.15 + +### Patch Changes + +- Updated dependencies [[`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/wallets@2.2.0 + +## 4.1.14 + +### Patch Changes + +- Updated dependencies [[`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e)]: + - @thirdweb-dev/wallets@2.1.11 + +## 4.1.13 + +### Patch Changes + +- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]: + - @thirdweb-dev/wallets@2.1.10 + ## 4.1.12 ### Patch Changes diff --git a/packages/auth/package.json b/packages/auth/package.json index a7de4e31d49..ff7ad66ed9c 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/auth", - "version": "4.1.12", + "version": "4.1.17", "main": "dist/thirdweb-dev-auth.cjs.js", "module": "dist/thirdweb-dev-auth.esm.js", "browser": { diff --git a/packages/chains/CHANGELOG.md b/packages/chains/CHANGELOG.md index 75a0585cd0a..413f46d7434 100644 --- a/packages/chains/CHANGELOG.md +++ b/packages/chains/CHANGELOG.md @@ -1,5 +1,21 @@ # @thirdweb-dev/chains +## 0.1.61 + +### Patch Changes + +- [#2066](https://github.com/thirdweb-dev/js/pull/2066) [`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Updatechains + +## 0.1.60 + +### Patch Changes + +- [#2019](https://github.com/thirdweb-dev/js/pull/2019) [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a) Thanks [@jnsdls](https://github.com/jnsdls)! - add & update chains + +- [#2024](https://github.com/thirdweb-dev/js/pull/2024) [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Base Sepolia to defaultChains + +- [#2023](https://github.com/thirdweb-dev/js/pull/2023) [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Eth Sepolia to defaultChains + ## 0.1.59 ### Patch Changes diff --git a/packages/chains/chains/1072.ts b/packages/chains/chains/1072.ts index 44c4c77b442..fcecf0c1e19 100644 --- a/packages/chains/chains/1072.ts +++ b/packages/chains/chains/1072.ts @@ -20,20 +20,17 @@ export default { "format": "png" }, "infoURL": "https://shimmer.network", - "name": "ShimmerEVM Testnet", + "name": "ShimmerEVM Testnet Deprecated 1072", "nativeCurrency": { "name": "SMR", "symbol": "SMR", "decimals": 6 }, "networkId": 1072, - "rpc": [ - "https://shimmerevm-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://1072.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://json-rpc.evm.testnet.shimmer.network" - ], - "shortName": "shimmerevm-testnet", - "slug": "shimmerevm-testnet", + "rpc": [], + "shortName": "shimmerevm-testnet-deprecated-1072", + "slug": "shimmerevm-testnet-deprecated-1072", + "status": "deprecated", "testnet": true, - "title": "ShimmerEVM Testnet" + "title": "ShimmerEVM Testnet Deprecated 1072" } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/1073.ts b/packages/chains/chains/1073.ts new file mode 100644 index 00000000000..d52bb3d9eb0 --- /dev/null +++ b/packages/chains/chains/1073.ts @@ -0,0 +1,39 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "ShimmerEVM", + "chainId": 1073, + "explorers": [ + { + "name": "explorer", + "url": "https://explorer.evm.testnet.shimmer.network", + "standard": "EIP3091" + } + ], + "faucets": [ + "https://evm-toolkit.evm.testnet.shimmer.network", + "https://evm-faucet.testnet.shimmer.network" + ], + "icon": { + "url": "ipfs://bafkreibky2sy6qhi6arktayvologkrgu5kudpgdxfkx4uosbvmstz7v4di", + "width": 720, + "height": 720, + "format": "png" + }, + "infoURL": "https://shimmer.network", + "name": "ShimmerEVM Testnet", + "nativeCurrency": { + "name": "SMR", + "symbol": "SMR", + "decimals": 6 + }, + "networkId": 1073, + "rpc": [ + "https://shimmerevm-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://1073.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://json-rpc.evm.testnet.shimmer.network" + ], + "shortName": "shimmerevm-testnet", + "slug": "shimmerevm-testnet", + "testnet": true, + "title": "ShimmerEVM Testnet" +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/11155420.ts b/packages/chains/chains/11155420.ts new file mode 100644 index 00000000000..0843274aef9 --- /dev/null +++ b/packages/chains/chains/11155420.ts @@ -0,0 +1,37 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "ETH", + "chainId": 11155420, + "explorers": [ + { + "name": "opscout", + "url": "https://optimism-sepolia.blockscout.com", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", + "width": 551, + "height": 540, + "format": "png" + } + } + ], + "faucets": [ + "https://app.optimism.io/faucet" + ], + "infoURL": "https://optimism.io", + "name": "OP Sepolia Testnet", + "nativeCurrency": { + "name": "Sepolia Ether", + "symbol": "ETH", + "decimals": 18 + }, + "networkId": 11155420, + "rpc": [ + "https://op-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://11155420.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://sepolia.optimism.io" + ], + "shortName": "opsep", + "slug": "op-sepolia-testnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/1127469.ts b/packages/chains/chains/1127469.ts new file mode 100644 index 00000000000..2e524ed0750 --- /dev/null +++ b/packages/chains/chains/1127469.ts @@ -0,0 +1,33 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "TILTYARD", + "chainId": 1127469, + "explorers": [ + { + "name": "TILTYARD Explorer", + "url": "http://testnet-explorer.tiltyard.gg", + "standard": "EIP3091" + } + ], + "faucets": [], + "features": [ + { + "name": "EIP1559" + } + ], + "name": "Tiltyard Subnet", + "nativeCurrency": { + "name": "Tiltyard Token", + "symbol": "TILTG", + "decimals": 18 + }, + "networkId": 1127469, + "rpc": [ + "https://tiltyard-subnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://1127469.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avax.network/tiltyard/testnet/rpc" + ], + "shortName": "tiltyard", + "slug": "tiltyard-subnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/12035.ts b/packages/chains/chains/12035.ts new file mode 100644 index 00000000000..7eb029fdccc --- /dev/null +++ b/packages/chains/chains/12035.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 12035, + "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": "QI M 11272", + "nativeCurrency": { + "name": "QI M 11272 Token", + "symbol": "JZW", + "decimals": 18 + }, + "networkId": 12035, + "redFlags": [], + "rpc": [ + "https://qi-m-11272.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://12035.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-dev.io/b19c9e32-f359-451f-ad15-7ec784625c04" + ], + "shortName": "QI M 11272", + "slug": "qi-m-11272", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/1273227453.ts b/packages/chains/chains/1273227453.ts index 0645e43b693..f625c45f01c 100644 --- a/packages/chains/chains/1273227453.ts +++ b/packages/chains/chains/1273227453.ts @@ -6,13 +6,7 @@ export default { { "name": "Blockscout", "url": "https://wan-red-ain.explorer.mainnet.skalenodes.com", - "standard": "EIP3091", - "icon": { - "url": "ipfs://QmT5KKrpNt6duU8QfwaYw3xf4ifTBPtjahpWsMi3gsFmcS", - "width": 440, - "height": 600, - "format": "png" - } + "standard": "EIP3091" } ], "faucets": [ diff --git a/packages/chains/chains/131419.ts b/packages/chains/chains/131419.ts index 919ba8b3b50..483b5454e7a 100644 --- a/packages/chains/chains/131419.ts +++ b/packages/chains/chains/131419.ts @@ -6,22 +6,10 @@ export default { { "name": "etndscan", "url": "https://scan.etnd.pro", - "standard": "none", - "icon": { - "url": "ipfs://Qmd26eRJxPb1jJg5Q4mC2M4kD9Jrs5vmcnr5LczHFMGwSD", - "width": 128, - "height": 128, - "format": "png" - } + "standard": "none" } ], "faucets": [], - "icon": { - "url": "ipfs://Qmd26eRJxPb1jJg5Q4mC2M4kD9Jrs5vmcnr5LczHFMGwSD", - "width": 128, - "height": 128, - "format": "png" - }, "infoURL": "https://www.etnd.pro", "name": "ETND Chain Mainnets", "nativeCurrency": { diff --git a/packages/chains/chains/13473.ts b/packages/chains/chains/13473.ts new file mode 100644 index 00000000000..93bf2ad9631 --- /dev/null +++ b/packages/chains/chains/13473.ts @@ -0,0 +1,43 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Immutable zkEVM", + "chainId": 13473, + "explorers": [ + { + "name": "Immutable Testnet explorer", + "url": "https://explorer.testnet.immutable.com", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw", + "width": 1168, + "height": 1168, + "format": "png" + } + } + ], + "faucets": [ + "https://docs.immutable.com/docs/zkEVM/guides/faucet" + ], + "icon": { + "url": "ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw", + "width": 1168, + "height": 1168, + "format": "png" + }, + "infoURL": "https://www.immutable.com", + "name": "Immutable zkEVM Testnet", + "nativeCurrency": { + "name": "Test IMX", + "symbol": "tIMX", + "decimals": 18 + }, + "networkId": 13473, + "rpc": [ + "https://immutable-zkevm-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://13473.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.testnet.immutable.com" + ], + "shortName": "imx-testnet", + "slug": "immutable-zkevm-testnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/15003.ts b/packages/chains/chains/15003.ts new file mode 100644 index 00000000000..fe238de382f --- /dev/null +++ b/packages/chains/chains/15003.ts @@ -0,0 +1,43 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Immutable zkEVM", + "chainId": 15003, + "explorers": [ + { + "name": "Immutable Devnet explorer", + "url": "https://explorer.dev.immutable.com", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw", + "width": 1168, + "height": 1168, + "format": "png" + } + } + ], + "faucets": [ + "https://docs.immutable.com/docs/zkEVM/guides/faucet" + ], + "icon": { + "url": "ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw", + "width": 1168, + "height": 1168, + "format": "png" + }, + "infoURL": "https://www.immutable.com", + "name": "Immutable zkEVM Devnet", + "nativeCurrency": { + "name": "Dev IMX", + "symbol": "dIMX", + "decimals": 18 + }, + "networkId": 15003, + "rpc": [ + "https://immutable-zkevm-devnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://15003.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.dev.immutable.com" + ], + "shortName": "imx-devnet", + "slug": "immutable-zkevm-devnet", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/17026.ts b/packages/chains/chains/17026.ts new file mode 100644 index 00000000000..2d306c2ed1f --- /dev/null +++ b/packages/chains/chains/17026.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 17026, + "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": "QI1204I3", + "nativeCurrency": { + "name": "QI1204I3 Token", + "symbol": "BHOX", + "decimals": 18 + }, + "networkId": 17026, + "redFlags": [], + "rpc": [ + "https://qi1204i3.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://17026.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-test.io/e7aeac38-06b2-4aaa-87b4-2c2da10fa43e" + ], + "shortName": "QI1204I3", + "slug": "qi1204i3", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/1748.ts b/packages/chains/chains/1748.ts index b2aa33a81a9..74d693e5f0a 100644 --- a/packages/chains/chains/1748.ts +++ b/packages/chains/chains/1748.ts @@ -12,7 +12,7 @@ export default { "format": ".png" }, "infoURL": "https://tryroll.com/", - "name": "Roll Testnet", + "name": "Form Testnet", "nativeCurrency": { "name": "Ether", "symbol": "ETH", @@ -20,13 +20,9 @@ export default { }, "networkId": 1748, "redFlags": [], - "rpc": [ - "https://roll-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://1748.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://roll.calderachain.xyz/http" - ], + "rpc": [], "shortName": "Roll", - "slug": "roll-testnet", + "slug": "form-testnet", "testnet": true, "title": "Roll Testnet" } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/18159.ts b/packages/chains/chains/18159.ts index dcc45ef63d8..18046741f70 100644 --- a/packages/chains/chains/18159.ts +++ b/packages/chains/chains/18159.ts @@ -10,12 +10,6 @@ export default { } ], "faucets": [], - "icon": { - "url": "ipfs://QmePhfibWz9jnGUqF9Rven4x734br1h3LxrChYTEjbbQvo", - "width": 256, - "height": 256, - "format": "png" - }, "infoURL": "https://proofofmemes.org", "name": "Proof Of Memes", "nativeCurrency": { diff --git a/packages/chains/chains/1909.ts b/packages/chains/chains/1909.ts new file mode 100644 index 00000000000..9ce6234b56d --- /dev/null +++ b/packages/chains/chains/1909.ts @@ -0,0 +1,35 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "MRK", + "chainId": 1909, + "explorers": [ + { + "name": "blockscout", + "url": "https://merklescan.com", + "standard": "none" + } + ], + "faucets": [], + "icon": { + "url": "ipfs://QmZocJpCSLoQqoYFkF1kn7uKDuAiFRNTK8P5PoVeiigDBU", + "width": 114, + "height": 132, + "format": "png" + }, + "infoURL": "https://merklescan.com", + "name": "Merkle Scan", + "nativeCurrency": { + "name": "Merkle", + "symbol": "MRK", + "decimals": 18 + }, + "networkId": 1909, + "rpc": [ + "https://merkle-scan.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://1909.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://marklechain-rpc.merklescan.com" + ], + "shortName": "MRK", + "slug": "merkle-scan", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/19683.ts b/packages/chains/chains/19683.ts new file mode 100644 index 00000000000..98e90537117 --- /dev/null +++ b/packages/chains/chains/19683.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 19683, + "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": "ST 12-07 V1", + "nativeCurrency": { + "name": "ST 12-07 V1 Token", + "symbol": "XRL", + "decimals": 18 + }, + "networkId": 19683, + "redFlags": [], + "rpc": [ + "https://st-12-07-v1.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://19683.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-test.io/d26b972e-1832-4d3a-bf7b-d0ce1f4331c2" + ], + "shortName": "ST 12-07 V1", + "slug": "st-12-07-v1", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/202212.ts b/packages/chains/chains/202212.ts new file mode 100644 index 00000000000..693dc7bf8d5 --- /dev/null +++ b/packages/chains/chains/202212.ts @@ -0,0 +1,35 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "X1", + "chainId": 202212, + "explorers": [ + { + "name": "Blockscout", + "url": "https://explorer.x1-devnet.xen.network", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", + "width": 551, + "height": 540, + "format": "png" + } + } + ], + "faucets": [], + "infoURL": "https://docs.xen.network/x1/", + "name": "X1 Devnet", + "nativeCurrency": { + "name": "XN", + "symbol": "XN", + "decimals": 18 + }, + "networkId": 202212, + "rpc": [ + "https://x1-devnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://202212.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://x1-devnet.xen.network" + ], + "shortName": "x1-devnet", + "slug": "x1-devnet", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/204005.ts b/packages/chains/chains/204005.ts new file mode 100644 index 00000000000..a14026902e6 --- /dev/null +++ b/packages/chains/chains/204005.ts @@ -0,0 +1,35 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "X1", + "chainId": 204005, + "explorers": [ + { + "name": "Blockscout", + "url": "https://explorer.x1-testnet.xen.network", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", + "width": 551, + "height": 540, + "format": "png" + } + } + ], + "faucets": [], + "infoURL": "https://docs.xen.network/go-x1/", + "name": "X1 Network", + "nativeCurrency": { + "name": "XN", + "symbol": "XN", + "decimals": 18 + }, + "networkId": 204005, + "rpc": [ + "https://x1-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://204005.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://x1-testnet.xen.network" + ], + "shortName": "x1-testnet", + "slug": "x1-network", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/21912.ts b/packages/chains/chains/21912.ts new file mode 100644 index 00000000000..69834734f20 --- /dev/null +++ b/packages/chains/chains/21912.ts @@ -0,0 +1,30 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "BSL", + "chainId": 21912, + "explorers": [ + { + "name": "BSL Mainnet Explorer", + "url": "https://scan.nftruth.io", + "standard": "EIP3091" + } + ], + "faucets": [], + "infoURL": "https://bsquarelab.com/", + "name": "BSL Mainnet", + "nativeCurrency": { + "name": "Origin NFT", + "symbol": "ONF", + "decimals": 18 + }, + "networkId": 21912, + "rpc": [ + "https://bsl.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://21912.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "http://rpc-mainnet.nftruth.io:8545", + "ws://rpc-mainnet.nftruth.io:8645" + ], + "shortName": "onf", + "slug": "bsl", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/2306.ts b/packages/chains/chains/2306.ts new file mode 100644 index 00000000000..bbb68771244 --- /dev/null +++ b/packages/chains/chains/2306.ts @@ -0,0 +1,23 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "ebro", + "chainId": 2306, + "explorers": [], + "faucets": [], + "infoURL": "https://www.ebrochain.com", + "name": "Ebro Network", + "nativeCurrency": { + "name": "Ebro", + "symbol": "ebro", + "decimals": 18 + }, + "networkId": 2306, + "rpc": [ + "https://ebro-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://2306.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://greendinoswap.com" + ], + "shortName": "ebro", + "slug": "ebro-network", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/245022926.ts b/packages/chains/chains/245022926.ts index 9f6f7e8cccd..981b22de374 100644 --- a/packages/chains/chains/245022926.ts +++ b/packages/chains/chains/245022926.ts @@ -14,11 +14,6 @@ export default { "format": "png" } }, - { - "name": "native", - "url": "https://devnet.explorer.neon-labs.org", - "standard": "EIP3091" - }, { "name": "neonscan", "url": "https://devnet.neonscan.org", @@ -35,7 +30,7 @@ export default { "format": "png" }, "infoURL": "https://neon-labs.org", - "name": "Neon EVM DevNet", + "name": "Neon EVM Devnet", "nativeCurrency": { "name": "Neon", "symbol": "NEON", diff --git a/packages/chains/chains/245022934.ts b/packages/chains/chains/245022934.ts index b118745f791..7e33044b4b9 100644 --- a/packages/chains/chains/245022934.ts +++ b/packages/chains/chains/245022934.ts @@ -22,14 +22,18 @@ export default { "format": "png" }, "infoURL": "https://neonevm.org", - "name": "Neon EVM MainNet", + "name": "Neon EVM Mainnet", "nativeCurrency": { "name": "Neon", "symbol": "NEON", "decimals": 18 }, "networkId": 245022934, - "rpc": [], + "rpc": [ + "https://neon-evm.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://245022934.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://neon-proxy-mainnet.solana.p2p.org" + ], "shortName": "neonevm-mainnet", "slug": "neon-evm", "testnet": false diff --git a/packages/chains/chains/245022940.ts b/packages/chains/chains/245022940.ts index 2eab3cd0094..cf5368d1f12 100644 --- a/packages/chains/chains/245022940.ts +++ b/packages/chains/chains/245022940.ts @@ -36,5 +36,6 @@ export default { ], "shortName": "neonevm-testnet", "slug": "neon-evm-testnet", + "status": "deprecated", "testnet": true } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/25.ts b/packages/chains/chains/25.ts index 3e80ad71f44..5a9cdb1fbaf 100644 --- a/packages/chains/chains/25.ts +++ b/packages/chains/chains/25.ts @@ -5,7 +5,7 @@ export default { "explorers": [ { "name": "Cronos Explorer", - "url": "https://cronoscan.com", + "url": "https://explorer.cronos.org", "standard": "none" } ], diff --git a/packages/chains/chains/252.ts b/packages/chains/chains/252.ts new file mode 100644 index 00000000000..a2c6b5e61e9 --- /dev/null +++ b/packages/chains/chains/252.ts @@ -0,0 +1,28 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "FRAX", + "chainId": 252, + "explorers": [], + "faucets": [], + "features": [], + "icon": { + "url": "ipfs://QmQLJk5G7zF8ZDxSxkRcpHqEqcifrJEhGmEKC6zwyPXWAw/fraxchain.png", + "width": 512, + "height": 512, + "format": "PNG" + }, + "infoURL": "https://mainnet.frax.com", + "name": "Fraxchain Mainnet", + "nativeCurrency": { + "name": "Frax Ether", + "symbol": "frxETH", + "decimals": 18 + }, + "networkId": 252, + "redFlags": [], + "rpc": [], + "shortName": "fraxchain", + "slug": "fraxchain", + "status": "incubating", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/2522.ts b/packages/chains/chains/2522.ts new file mode 100644 index 00000000000..115629f4080 --- /dev/null +++ b/packages/chains/chains/2522.ts @@ -0,0 +1,32 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "FRAX", + "chainId": 2522, + "explorers": [], + "faucets": [], + "features": [], + "icon": { + "url": "ipfs://QmQLJk5G7zF8ZDxSxkRcpHqEqcifrJEhGmEKC6zwyPXWAw/fraxchain.png", + "width": 512, + "height": 512, + "format": "PNG" + }, + "infoURL": "https://testnet.frax.com", + "name": "Fraxchain Testnet", + "nativeCurrency": { + "name": "Frax Ether", + "symbol": "frxETH", + "decimals": 18 + }, + "networkId": 2522, + "redFlags": [], + "rpc": [ + "https://fraxchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://2522.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.testnet.frax.com" + ], + "shortName": "fraxchain-testnet", + "slug": "fraxchain-testnet", + "status": "active", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/2710.ts b/packages/chains/chains/2710.ts index f5999f7a483..e082e452092 100644 --- a/packages/chains/chains/2710.ts +++ b/packages/chains/chains/2710.ts @@ -4,14 +4,14 @@ export default { "chainId": 2710, "explorers": [ { - "name": "Morphism Testnet Explorer", - "url": "https://explorer-testnet.morphism.xyz", + "name": "Morph Testnet Explorer", + "url": "https://explorer-testnet.morphl2.io", "standard": "EIP3091" } ], "faucets": [], - "infoURL": "https://morphism.xyz", - "name": "Morphism Testnet", + "infoURL": "https://morphl2.io", + "name": "Morph Testnet", "nativeCurrency": { "name": "Ether", "symbol": "ETH", @@ -23,16 +23,16 @@ export default { "chain": "eip155-1", "bridges": [ { - "url": "https://bridge-testnet.morphism.xyz" + "url": "https://bridge-testnet.morphl2.io" } ] }, "rpc": [ - "https://morphism-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://morph-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://2710.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://rpc-testnet.morphism.xyz" + "https://rpc-testnet.morphl2.io" ], "shortName": "tmorph", - "slug": "morphism-testnet", + "slug": "morph-testnet", "testnet": true } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/280.ts b/packages/chains/chains/280.ts index e58ae536a70..503fc2fdfa4 100644 --- a/packages/chains/chains/280.ts +++ b/packages/chains/chains/280.ts @@ -15,17 +15,15 @@ export default { } } ], - "faucets": [ - "https://goerli.portal.zksync.io/faucet" - ], + "faucets": [], "icon": { "url": "ipfs://QmRkhUD6J3B9WhT4hEWLrcFVTrBhx3CQgNC783aJsrwxSN", "width": 512, "height": 512, "format": "svg" }, - "infoURL": "https://era.zksync.io/docs/", - "name": "zkSync Era Testnet", + "infoURL": "https://zksync.io/", + "name": "zkSync Era Goerli Testnet (deprecated)", "nativeCurrency": { "name": "Ether", "symbol": "ETH", @@ -37,16 +35,17 @@ export default { "chain": "eip155-1", "bridges": [ { - "url": "https://goerli.portal.zksync.io/bridge" + "url": "https://bridge.zksync.io/" } ] }, "rpc": [ - "https://zksync-era-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://zksync-era-goerli-testnet-deprecated.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://280.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://testnet.era.zksync.dev" ], "shortName": "zksync-goerli", - "slug": "zksync-era-testnet", + "slug": "zksync-era-goerli-testnet-deprecated", + "status": "deprecated", "testnet": true } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/300.ts b/packages/chains/chains/300.ts index 290bc7a26b1..57a3b261555 100644 --- a/packages/chains/chains/300.ts +++ b/packages/chains/chains/300.ts @@ -1,20 +1,53 @@ import type { Chain } from "../src/types"; export default { - "chain": "OGC", + "chain": "ETH", "chainId": 300, - "explorers": [], + "explorers": [ + { + "name": "zkSync Block Explorer", + "url": "https://sepolia.explorer.zksync.io", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmRkhUD6J3B9WhT4hEWLrcFVTrBhx3CQgNC783aJsrwxSN", + "width": 512, + "height": 512, + "format": "svg" + } + } + ], "faucets": [], - "infoURL": "https://docs.gnosischain.com", - "name": "(deprecated) Optimism on GC", + "icon": { + "url": "ipfs://QmRkhUD6J3B9WhT4hEWLrcFVTrBhx3CQgNC783aJsrwxSN", + "width": 512, + "height": 512, + "format": "svg" + }, + "infoURL": "https://zksync.io/", + "name": "zkSync Sepolia Testnet", "nativeCurrency": { - "name": "xDAI", - "symbol": "xDAI", + "name": "Ether", + "symbol": "ETH", "decimals": 18 }, "networkId": 300, - "rpc": [], - "shortName": "ogc", - "slug": "deprecated-optimism-on-gc", - "status": "deprecated", - "testnet": false + "parent": { + "type": "L2", + "chain": "eip155-1", + "bridges": [ + { + "url": "https://bridge.zksync.io/" + } + ] + }, + "redFlags": [ + "reusedChainId" + ], + "rpc": [ + "https://zksync-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://300.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://sepolia.era.zksync.dev" + ], + "shortName": "zksync-sepolia", + "slug": "zksync-sepolia-testnet", + "testnet": true } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/324.ts b/packages/chains/chains/324.ts index 624d4631483..aa10ad0a837 100644 --- a/packages/chains/chains/324.ts +++ b/packages/chains/chains/324.ts @@ -23,7 +23,7 @@ export default { "format": "svg" }, "infoURL": "https://zksync.io/", - "name": "zkSync Era Mainnet", + "name": "zkSync Mainnet", "nativeCurrency": { "name": "Ether", "symbol": "ETH", @@ -40,11 +40,11 @@ export default { ] }, "rpc": [ - "https://zksync-era.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://zksync.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://324.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://mainnet.era.zksync.io" ], "shortName": "zksync", - "slug": "zksync-era", + "slug": "zksync", "testnet": false } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/35730.ts b/packages/chains/chains/35730.ts new file mode 100644 index 00000000000..f21a1c54039 --- /dev/null +++ b/packages/chains/chains/35730.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 35730, + "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": "QR1129I1", + "nativeCurrency": { + "name": "QR1129I1 Token", + "symbol": "YXAX", + "decimals": 18 + }, + "networkId": 35730, + "redFlags": [], + "rpc": [ + "https://qr1129i1.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://35730.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avax.network/qr1129i1/testnet/rpc" + ], + "shortName": "QR1129I1", + "slug": "qr1129i1", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/36908.ts b/packages/chains/chains/36908.ts new file mode 100644 index 00000000000..eeeeb1a9db5 --- /dev/null +++ b/packages/chains/chains/36908.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 36908, + "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": "QR1205s1", + "nativeCurrency": { + "name": "QR1205s1 Token", + "symbol": "MDN", + "decimals": 18 + }, + "networkId": 36908, + "redFlags": [], + "rpc": [ + "https://qr1205s1.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://36908.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avax.network/qr1205s1/testnet/rpc" + ], + "shortName": "QR1205s1", + "slug": "qr1205s1", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/3885.ts b/packages/chains/chains/3885.ts new file mode 100644 index 00000000000..5b4ba4399e2 --- /dev/null +++ b/packages/chains/chains/3885.ts @@ -0,0 +1,24 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Firechain", + "chainId": 3885, + "explorers": [], + "faucets": [], + "infoURL": "https://docs.thefirechain.com/", + "name": "Firechain zkEVM Ghostrider", + "nativeCurrency": { + "name": "Ether", + "symbol": "ETH", + "decimals": 18 + }, + "networkId": 3885, + "rpc": [ + "https://firechain-zkevm-ghostrider.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://3885.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.zkevm.ghostrider.thefirechain.com" + ], + "shortName": "firechain-zkEVM-ghostrider", + "slug": "firechain-zkevm-ghostrider", + "testnet": false, + "title": "Firechain zkEVM Ghostrider" +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/4003.ts b/packages/chains/chains/4003.ts new file mode 100644 index 00000000000..6e0ef6f9a07 --- /dev/null +++ b/packages/chains/chains/4003.ts @@ -0,0 +1,35 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "X1", + "chainId": 4003, + "explorers": [ + { + "name": "Blockscout", + "url": "https://explorer.x1-fastnet.xen.network", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", + "width": 551, + "height": 540, + "format": "png" + } + } + ], + "faucets": [], + "infoURL": "https://docs.xen.network/go-x1/", + "name": "X1 Fastnet", + "nativeCurrency": { + "name": "XN", + "symbol": "XN", + "decimals": 18 + }, + "networkId": 4003, + "rpc": [ + "https://x1-fastnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://4003.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://x1-fastnet.xen.network" + ], + "shortName": "x1-fastnet", + "slug": "x1-fastnet", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/4157.ts b/packages/chains/chains/4157.ts new file mode 100644 index 00000000000..d01a0768f6f --- /dev/null +++ b/packages/chains/chains/4157.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "XFI", + "chainId": 4157, + "explorers": [ + { + "name": "Scan Testnet", + "url": "https://scan.testnet.ms/", + "standard": "EIP1559" + } + ], + "faucets": [], + "features": [], + "name": "CrossFi Testnet", + "nativeCurrency": { + "name": "XFI", + "symbol": "XFI", + "decimals": 18 + }, + "networkId": 4157, + "redFlags": [], + "rpc": [ + "https://crossfi-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://4157.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.testnet.ms/" + ], + "shortName": "XFI", + "slug": "crossfi-testnet", + "testnet": true, + "title": "https://scan.testnet.ms/" +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/43851.ts b/packages/chains/chains/43851.ts new file mode 100644 index 00000000000..8f4833e098a --- /dev/null +++ b/packages/chains/chains/43851.ts @@ -0,0 +1,49 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "ETH", + "chainId": 43851, + "explorers": [ + { + "name": "ZKFair Testnet Info", + "url": "https://testnet-scan.zkfair.io", + "standard": "EIP3091", + "icon": { + "url": "ipfs://QmVb682D4mUXkKNP28xxJDNgSYbDLvEc3kVYx7TQxEa6Cw", + "width": 400, + "height": 400, + "format": "jpg" + } + } + ], + "faucets": [], + "features": [ + { + "name": "EIP155" + }, + { + "name": "EIP1559" + } + ], + "icon": { + "url": "ipfs://QmVb682D4mUXkKNP28xxJDNgSYbDLvEc3kVYx7TQxEa6Cw", + "width": 400, + "height": 400, + "format": "jpg" + }, + "infoURL": "https://zkfair.io", + "name": "ZKFair Testnet", + "nativeCurrency": { + "name": "USDC Token", + "symbol": "USDC", + "decimals": 18 + }, + "networkId": 43851, + "rpc": [ + "https://zkfair-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://43851.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://testnet-rpc.zkfair.io" + ], + "shortName": "ZKFair-Testnet", + "slug": "zkfair-testnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/463.ts b/packages/chains/chains/463.ts new file mode 100644 index 00000000000..e74e024532e --- /dev/null +++ b/packages/chains/chains/463.ts @@ -0,0 +1,35 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Areon", + "chainId": 463, + "explorers": [ + { + "name": "AreonScan", + "url": "https://areonscan.com", + "standard": "none" + } + ], + "faucets": [], + "icon": { + "url": "ipfs://bafkreihs2nrnizpcuzjmuu2yi7wrtwd7qlqje46qnil5bnntfbfkb2roea", + "width": 1000, + "height": 1000, + "format": "png" + }, + "infoURL": "https://areon.network", + "name": "Areon Network Mainnet", + "nativeCurrency": { + "name": "Areon", + "symbol": "AREA", + "decimals": 18 + }, + "networkId": 463, + "rpc": [ + "https://areon-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://463.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://mainnet-rpc.areon.network" + ], + "shortName": "area", + "slug": "areon-network", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/534351.ts b/packages/chains/chains/534351.ts index 1739447f942..63b4b8de4e3 100644 --- a/packages/chains/chains/534351.ts +++ b/packages/chains/chains/534351.ts @@ -5,7 +5,7 @@ export default { "explorers": [ { "name": "Scroll Sepolia Etherscan", - "url": "https://sepolia.scrollscan.dev", + "url": "https://sepolia.scrollscan.com", "standard": "EIP3091" }, { @@ -28,7 +28,7 @@ export default { "chain": "eip155-11155111", "bridges": [ { - "url": "https://scroll.io/bridge" + "url": "https://sepolia.scroll.io/bridge" } ] }, diff --git a/packages/chains/chains/56914.ts b/packages/chains/chains/56914.ts new file mode 100644 index 00000000000..37324849bef --- /dev/null +++ b/packages/chains/chains/56914.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 56914, + "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": "KK1223", + "nativeCurrency": { + "name": "KK1223 Token", + "symbol": "KLK", + "decimals": 18 + }, + "networkId": 56914, + "redFlags": [], + "rpc": [ + "https://kk1223.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://56914.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-dev.io/bf540c23-4601-4768-9e26-f2e5f0f89c18" + ], + "shortName": "KK1223", + "slug": "kk1223", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/59971.ts b/packages/chains/chains/59971.ts new file mode 100644 index 00000000000..3f5535fdd10 --- /dev/null +++ b/packages/chains/chains/59971.ts @@ -0,0 +1,41 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "GCODE", + "chainId": 59971, + "explorers": [ + { + "name": "Genesys Scan", + "url": "https://genesysscan.io", + "standard": "none", + "icon": { + "url": "ipfs://bafkreihgmpaceze7rxpajv7yrlx3cb6daqubippkpvgryzairtaubsjjoe", + "width": 512, + "height": 512, + "format": "png" + } + } + ], + "faucets": [], + "icon": { + "url": "ipfs://bafkreihgmpaceze7rxpajv7yrlx3cb6daqubippkpvgryzairtaubsjjoe", + "width": 512, + "height": 512, + "format": "png" + }, + "infoURL": "https://genesyscode.io", + "name": "Genesys Code Mainnet", + "nativeCurrency": { + "name": "GenesysCode", + "symbol": "GCODE", + "decimals": 18 + }, + "networkId": 59971, + "rpc": [ + "https://genesys-code.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://59971.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://mainnet.genesyscode.io/" + ], + "shortName": "gcode", + "slug": "genesys-code", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/622277.ts b/packages/chains/chains/622277.ts index 54a11f8cad8..6a9f83ffde9 100644 --- a/packages/chains/chains/622277.ts +++ b/packages/chains/chains/622277.ts @@ -1,11 +1,11 @@ import type { Chain } from "../src/types"; export default { - "chain": "RTH", + "chain": "HYP", "chainId": 622277, "explorers": [ { - "name": "rethereum", - "url": "https://explorer.rethereum.org", + "name": "hypra", + "url": "https://explorer.hypra.network", "standard": "EIP3091", "icon": { "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", @@ -30,22 +30,23 @@ export default { "height": 830, "format": "png" }, - "infoURL": "https://www.rethereum.org", - "name": "Rethereum Mainnet", + "infoURL": "https://www.hypra.network", + "name": "Hypra Mainnet", "nativeCurrency": { - "name": "Rethereum", - "symbol": "RTH", + "name": "Hypra", + "symbol": "HYP", "decimals": 18 }, "networkId": 622277, "rpc": [ - "https://rethereum.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://hypra.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://622277.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.hypra.network", "https://rpc.rethereum.org", "https://rethereum.rpc.restratagem.com", "https://rpc.rthcentral.org" ], - "shortName": "rth", - "slug": "rethereum", + "shortName": "hyp", + "slug": "hypra", "testnet": false } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/65010000.ts b/packages/chains/chains/65010001.ts similarity index 70% rename from packages/chains/chains/65010000.ts rename to packages/chains/chains/65010001.ts index 2afad8b90bc..01e7d4f12d1 100644 --- a/packages/chains/chains/65010000.ts +++ b/packages/chains/chains/65010001.ts @@ -1,7 +1,7 @@ import type { Chain } from "../src/types"; export default { "chain": "AUT", - "chainId": 65010000, + "chainId": 65010001, "explorers": [ { "name": "autonity-blockscout", @@ -19,20 +19,20 @@ export default { "format": "png" }, "infoURL": "https://autonity.org/", - "name": "Autonity Bakerloo (Thames) Testnet", + "name": "Autonity Bakerloo (Barada) Testnet", "nativeCurrency": { "name": "Bakerloo Auton", "symbol": "ATN", "decimals": 18 }, - "networkId": 65010000, + "networkId": 65010001, "rpc": [ - "https://autonity-bakerloo-thames-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://65010000.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://autonity-bakerloo-barada-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://65010001.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://rpc1.bakerloo.autonity.org/", "wss://rpc1.bakerloo.autonity.org/ws/" ], - "shortName": "bakerloo-0", - "slug": "autonity-bakerloo-thames-testnet", + "shortName": "bakerloo-01", + "slug": "autonity-bakerloo-barada-testnet", "testnet": true } as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/653.ts b/packages/chains/chains/653.ts new file mode 100644 index 00000000000..159795e5303 --- /dev/null +++ b/packages/chains/chains/653.ts @@ -0,0 +1,29 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Kalichain", + "chainId": 653, + "explorers": [ + { + "name": "kalichain explorer", + "url": "https://explorer.kalichain.com", + "standard": "EIP3091" + } + ], + "faucets": [], + "infoURL": "https://kalichain.com", + "name": "Kalichain Mainnet", + "nativeCurrency": { + "name": "kalis", + "symbol": "KALIS", + "decimals": 18 + }, + "networkId": 653, + "rpc": [ + "https://kalichain.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://653.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.kalichain.com" + ], + "shortName": "kalichain", + "slug": "kalichain", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/660868.ts b/packages/chains/chains/660868.ts new file mode 100644 index 00000000000..02800dde796 --- /dev/null +++ b/packages/chains/chains/660868.ts @@ -0,0 +1,27 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "OCASH", + "chainId": 660868, + "explorers": [], + "faucets": [], + "features": [], + "icon": { + "url": "https://ipfs.io/ipfs/QmbwuoezvkfZBY9nrZ65n3iHGyhJG6yDRyhPjqE6k3uCiM", + "width": 350, + "height": 350, + "format": "PNG" + }, + "infoURL": "https://www.overline.network", + "name": "Ocash testnet", + "nativeCurrency": { + "name": "OCASH", + "symbol": "OCASH", + "decimals": 18 + }, + "networkId": 660868, + "redFlags": [], + "rpc": [], + "shortName": "ocash", + "slug": "ocash-testnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/69740.ts b/packages/chains/chains/69740.ts new file mode 100644 index 00000000000..04addf977d0 --- /dev/null +++ b/packages/chains/chains/69740.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 69740, + "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": "Will's Testnet", + "nativeCurrency": { + "name": "Will's Testnet Token", + "symbol": "WLDVNT", + "decimals": 18 + }, + "networkId": 69740, + "redFlags": [], + "rpc": [ + "https://will-s-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://69740.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc" + ], + "shortName": "Will's Testnet", + "slug": "will-s-testnet", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/70466.ts b/packages/chains/chains/70466.ts new file mode 100644 index 00000000000..b1aa5c2d7b9 --- /dev/null +++ b/packages/chains/chains/70466.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 70466, + "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": "Cohan test3", + "nativeCurrency": { + "name": "Cohan test3 Token", + "symbol": "HYN", + "decimals": 18 + }, + "networkId": 70466, + "redFlags": [], + "rpc": [ + "https://cohan-test3.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://70466.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-dev.io/f44b72ee-0574-44d2-a10b-363a74964145" + ], + "shortName": "Cohan test3", + "slug": "cohan-test3", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/727.ts b/packages/chains/chains/727.ts new file mode 100644 index 00000000000..27b110dffa8 --- /dev/null +++ b/packages/chains/chains/727.ts @@ -0,0 +1,24 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "BLU", + "chainId": 727, + "explorers": [], + "faucets": [], + "infoURL": "https://www.blucrates.com", + "name": "Blucrates", + "nativeCurrency": { + "name": "Blucrates", + "symbol": "BLU", + "decimals": 18 + }, + "networkId": 727, + "rpc": [ + "https://blucrates.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://727.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://data.bluchain.pro" + ], + "shortName": "blu", + "slip44": 727, + "slug": "blucrates", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/80182.ts b/packages/chains/chains/80182.ts new file mode 100644 index 00000000000..f9d9c0c5cb6 --- /dev/null +++ b/packages/chains/chains/80182.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 80182, + "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": "QI M 12051", + "nativeCurrency": { + "name": "QI M 12051 Token", + "symbol": "VTV", + "decimals": 18 + }, + "networkId": 80182, + "redFlags": [], + "rpc": [ + "https://qi-m-12051.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://80182.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avacloud-dev.io/b19c9e32-f359-451f-ad15-7ec784625c04" + ], + "shortName": "QI M 12051", + "slug": "qi-m-12051", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/81041.ts b/packages/chains/chains/81041.ts new file mode 100644 index 00000000000..d92b0ba6bae --- /dev/null +++ b/packages/chains/chains/81041.ts @@ -0,0 +1,29 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Nordek", + "chainId": 81041, + "explorers": [ + { + "name": "nordek", + "url": "https://nordekscan.com", + "standard": "EIP3091" + } + ], + "faucets": [], + "infoURL": "https://nordekscan.com", + "name": "Nordek Mainnet", + "nativeCurrency": { + "name": "NRK", + "symbol": "NRK", + "decimals": 18 + }, + "networkId": 81041, + "rpc": [ + "https://nordek.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://81041.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://mainnet-rpc.nordekscan.com" + ], + "shortName": "nordek", + "slug": "nordek", + "testnet": false +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/814.ts b/packages/chains/chains/814.ts new file mode 100644 index 00000000000..eea570ef32b --- /dev/null +++ b/packages/chains/chains/814.ts @@ -0,0 +1,39 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Firechain", + "chainId": 814, + "explorers": [], + "faucets": [], + "icon": { + "url": "ipfs://QmYjuztyURb3Fc6ZTLgCbwQa64CcVoigF5j9cafzuSbqgf", + "width": 512, + "height": 512, + "format": "png" + }, + "infoURL": "https://docs.thefirechain.com/", + "name": "Firechain zkEVM", + "nativeCurrency": { + "name": "Ether", + "symbol": "ETH", + "decimals": 18 + }, + "networkId": 814, + "parent": { + "type": "L2", + "chain": "eip155-1", + "bridges": [ + { + "url": "https://zkevm.bridge.rpc.thefirechain.com" + } + ] + }, + "rpc": [ + "https://firechain-zkevm.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://814.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://rpc.zkevm.thefirechain.com" + ], + "shortName": "firechan-zkEVM", + "slug": "firechain-zkevm", + "testnet": false, + "title": "Firechain zkEVM" +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/8194.ts b/packages/chains/chains/8194.ts index 51b1f6477cc..3cbb5e05d03 100644 --- a/packages/chains/chains/8194.ts +++ b/packages/chains/chains/8194.ts @@ -5,7 +5,7 @@ export default { "explorers": [ { "name": "blockscout", - "url": "https://testnet.torusscan.com", + "url": "https://testnet.toruscan.com", "standard": "EIP3091", "icon": { "url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM", diff --git a/packages/chains/chains/88883.ts b/packages/chains/chains/88883.ts new file mode 100644 index 00000000000..67df35318a2 --- /dev/null +++ b/packages/chains/chains/88883.ts @@ -0,0 +1,31 @@ +import type { Chain } from "../src/types"; +export default { + "chain": "Avalanche", + "chainId": 88883, + "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": "Proj Orc Testnet Alpha", + "nativeCurrency": { + "name": "Proj Orc Testnet Alpha Token", + "symbol": "STX", + "decimals": 18 + }, + "networkId": 88883, + "redFlags": [], + "rpc": [ + "https://proj-orc-testnet-alpha.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://88883.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://subnets.avax.network/projorctes/testnet/rpc" + ], + "shortName": "Proj Orc Testnet Alpha", + "slug": "proj-orc-testnet-alpha", + "testnet": true +} as const satisfies Chain; \ No newline at end of file diff --git a/packages/chains/chains/8899.ts b/packages/chains/chains/8899.ts index 4a1b1318d3e..b20a6a76ced 100644 --- a/packages/chains/chains/8899.ts +++ b/packages/chains/chains/8899.ts @@ -29,7 +29,8 @@ export default { "rpc": [ "https://jibchain-l1.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://8899.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://rpc-l1.jibchain.net" + "https://rpc-l1.jibchain.net", + "https://jib-rpc.inan.in.th" ], "shortName": "jbc", "slug": "jibchain-l1", diff --git a/packages/chains/chains/970.ts b/packages/chains/chains/970.ts index 77a0017c725..aad696a5a70 100644 --- a/packages/chains/chains/970.ts +++ b/packages/chains/chains/970.ts @@ -2,12 +2,24 @@ import type { Chain } from "../src/types"; export default { "chain": "Oort Mainnet", "chainId": 970, - "explorers": [], + "explorers": [ + { + "name": "Oort Mainnet Explorer", + "url": "https://mainnet-scan.oortech.com", + "standard": "none", + "icon": { + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, + "format": "png" + } + } + ], "faucets": [], "icon": { - "url": "ipfs://QmZ1jbxFZcuotj3eZ6iKFrg9ZXnaV8AK6sGRa7ELrceWyD", - "width": 1043, - "height": 1079, + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, "format": "png" }, "infoURL": "https://oortech.com", @@ -21,7 +33,7 @@ export default { "rpc": [ "https://oort.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://970.rpc.thirdweb.com/${THIRDWEB_API_KEY}", - "https://rpc.oortech.com" + "https://mainnet-rpc.oortech.com" ], "shortName": "ccn", "slug": "oort", diff --git a/packages/chains/chains/9700.ts b/packages/chains/chains/9700.ts index fc112468cdd..89ae5fe11de 100644 --- a/packages/chains/chains/9700.ts +++ b/packages/chains/chains/9700.ts @@ -2,12 +2,24 @@ import type { Chain } from "../src/types"; export default { "chain": "MainnetDev", "chainId": 9700, - "explorers": [], + "explorers": [ + { + "name": "Oort MainnetDev Scan", + "url": "https://dev-scan.oortech.com", + "standard": "none", + "icon": { + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, + "format": "png" + } + } + ], "faucets": [], "icon": { - "url": "ipfs://QmZ1jbxFZcuotj3eZ6iKFrg9ZXnaV8AK6sGRa7ELrceWyD", - "width": 1043, - "height": 1079, + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, "format": "png" }, "infoURL": "https://oortech.com", @@ -18,7 +30,11 @@ export default { "decimals": 18 }, "networkId": 9700, - "rpc": [], + "rpc": [ + "https://oort-dev.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://9700.rpc.thirdweb.com/${THIRDWEB_API_KEY}", + "https://dev-rpc.oortech.com" + ], "shortName": "MainnetDev", "slug": "oort-dev", "testnet": false, diff --git a/packages/chains/chains/972.ts b/packages/chains/chains/972.ts index a62999ef2e6..476245d0491 100644 --- a/packages/chains/chains/972.ts +++ b/packages/chains/chains/972.ts @@ -2,12 +2,24 @@ import type { Chain } from "../src/types"; export default { "chain": "Ascraeus", "chainId": 972, - "explorers": [], + "explorers": [ + { + "name": "Oort Ascraeus Explorer", + "url": "https://ascraeus-scan.oortech.com", + "standard": "none", + "icon": { + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, + "format": "png" + } + } + ], "faucets": [], "icon": { - "url": "ipfs://QmZ1jbxFZcuotj3eZ6iKFrg9ZXnaV8AK6sGRa7ELrceWyD", - "width": 1043, - "height": 1079, + "url": "ipfs://bafkreidrbvklkb52sgmg7cmy42fhf7vqpig7qj7bnrq24ijdwywkzr2tfy", + "width": 1440, + "height": 1440, "format": "png" }, "infoURL": "https://oortech.com", diff --git a/packages/chains/package.json b/packages/chains/package.json index f0a2c49f474..7d1535d5567 100644 --- a/packages/chains/package.json +++ b/packages/chains/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/chains", - "version": "0.1.59", + "version": "0.1.61", "main": "dist/thirdweb-dev-chains.cjs.js", "module": "dist/thirdweb-dev-chains.esm.js", "exports": { diff --git a/packages/chains/src/index.ts b/packages/chains/src/index.ts index 1bbee5fc984..e3ff4c9c9fa 100644 --- a/packages/chains/src/index.ts +++ b/packages/chains/src/index.ts @@ -184,6 +184,7 @@ import c242 from "../chains/242"; import c246 from "../chains/246"; import c248 from "../chains/248"; import c250 from "../chains/250"; +import c252 from "../chains/252"; import c255 from "../chains/255"; import c256 from "../chains/256"; import c258 from "../chains/258"; @@ -236,6 +237,7 @@ import c443 from "../chains/443"; import c444 from "../chains/444"; import c456 from "../chains/456"; import c462 from "../chains/462"; +import c463 from "../chains/463"; import c499 from "../chains/499"; import c500 from "../chains/500"; import c501 from "../chains/501"; @@ -263,6 +265,7 @@ import c614 from "../chains/614"; import c634 from "../chains/634"; import c647 from "../chains/647"; import c648 from "../chains/648"; +import c653 from "../chains/653"; import c666 from "../chains/666"; import c667 from "../chains/667"; import c668 from "../chains/668"; @@ -274,6 +277,7 @@ import c708 from "../chains/708"; import c710 from "../chains/710"; import c719 from "../chains/719"; import c721 from "../chains/721"; +import c727 from "../chains/727"; import c740 from "../chains/740"; import c741 from "../chains/741"; import c742 from "../chains/742"; @@ -288,6 +292,7 @@ import c800 from "../chains/800"; import c803 from "../chains/803"; import c808 from "../chains/808"; import c813 from "../chains/813"; +import c814 from "../chains/814"; import c818 from "../chains/818"; import c820 from "../chains/820"; import c821 from "../chains/821"; @@ -343,6 +348,7 @@ import c1038 from "../chains/1038"; import c1039 from "../chains/1039"; import c1071 from "../chains/1071"; import c1072 from "../chains/1072"; +import c1073 from "../chains/1073"; import c1079 from "../chains/1079"; import c1080 from "../chains/1080"; import c1088 from "../chains/1088"; @@ -439,6 +445,7 @@ import c1898 from "../chains/1898"; import c1904 from "../chains/1904"; import c1907 from "../chains/1907"; import c1908 from "../chains/1908"; +import c1909 from "../chains/1909"; import c1945 from "../chains/1945"; import c1951 from "../chains/1951"; import c1954 from "../chains/1954"; @@ -499,6 +506,7 @@ import c2222 from "../chains/2222"; import c2223 from "../chains/2223"; import c2241 from "../chains/2241"; import c2300 from "../chains/2300"; +import c2306 from "../chains/2306"; import c2309 from "../chains/2309"; import c2323 from "../chains/2323"; import c2330 from "../chains/2330"; @@ -509,6 +517,7 @@ import c2399 from "../chains/2399"; import c2400 from "../chains/2400"; import c2415 from "../chains/2415"; import c2484 from "../chains/2484"; +import c2522 from "../chains/2522"; import c2559 from "../chains/2559"; import c2569 from "../chains/2569"; import c2606 from "../chains/2606"; @@ -552,6 +561,7 @@ import c3699 from "../chains/3699"; import c3701 from "../chains/3701"; import c3737 from "../chains/3737"; import c3797 from "../chains/3797"; +import c3885 from "../chains/3885"; import c3888 from "../chains/3888"; import c3889 from "../chains/3889"; import c3912 from "../chains/3912"; @@ -562,6 +572,7 @@ import c3999 from "../chains/3999"; import c4000 from "../chains/4000"; import c4001 from "../chains/4001"; import c4002 from "../chains/4002"; +import c4003 from "../chains/4003"; import c4051 from "../chains/4051"; import c4061 from "../chains/4061"; import c4062 from "../chains/4062"; @@ -571,6 +582,7 @@ import c4099 from "../chains/4099"; import c4102 from "../chains/4102"; import c4139 from "../chains/4139"; import c4141 from "../chains/4141"; +import c4157 from "../chains/4157"; import c4181 from "../chains/4181"; import c4201 from "../chains/4201"; import c4242 from "../chains/4242"; @@ -737,6 +749,7 @@ import c11612 from "../chains/11612"; import c11888 from "../chains/11888"; import c11891 from "../chains/11891"; import c12009 from "../chains/12009"; +import c12035 from "../chains/12035"; import c12051 from "../chains/12051"; import c12052 from "../chains/12052"; import c12123 from "../chains/12123"; @@ -750,9 +763,11 @@ import c13000 from "../chains/13000"; import c13308 from "../chains/13308"; import c13337 from "../chains/13337"; import c13381 from "../chains/13381"; +import c13473 from "../chains/13473"; import c13812 from "../chains/13812"; import c14000 from "../chains/14000"; import c14853 from "../chains/14853"; +import c15003 from "../chains/15003"; import c15535 from "../chains/15535"; import c15551 from "../chains/15551"; import c15555 from "../chains/15555"; @@ -765,6 +780,7 @@ import c16718 from "../chains/16718"; import c16888 from "../chains/16888"; import c17000 from "../chains/17000"; import c17001 from "../chains/17001"; +import c17026 from "../chains/17026"; import c17171 from "../chains/17171"; import c17180 from "../chains/17180"; import c17777 from "../chains/17777"; @@ -774,12 +790,14 @@ import c18159 from "../chains/18159"; import c18181 from "../chains/18181"; import c18686 from "../chains/18686"; import c19011 from "../chains/19011"; +import c19683 from "../chains/19683"; import c19845 from "../chains/19845"; import c20001 from "../chains/20001"; import c20729 from "../chains/20729"; import c20736 from "../chains/20736"; import c21337 from "../chains/21337"; import c21816 from "../chains/21816"; +import c21912 from "../chains/21912"; import c22023 from "../chains/22023"; import c22040 from "../chains/22040"; import c22222 from "../chains/22222"; @@ -820,6 +838,8 @@ import c34443 from "../chains/34443"; import c35011 from "../chains/35011"; import c35441 from "../chains/35441"; import c35443 from "../chains/35443"; +import c35730 from "../chains/35730"; +import c36908 from "../chains/36908"; import c38400 from "../chains/38400"; import c38401 from "../chains/38401"; import c39797 from "../chains/39797"; @@ -837,6 +857,7 @@ import c43110 from "../chains/43110"; import c43113 from "../chains/43113"; import c43114 from "../chains/43114"; import c43288 from "../chains/43288"; +import c43851 from "../chains/43851"; import c44444 from "../chains/44444"; import c44787 from "../chains/44787"; import c45000 from "../chains/45000"; @@ -858,10 +879,12 @@ import c55555 from "../chains/55555"; import c55556 from "../chains/55556"; import c56288 from "../chains/56288"; import c56789 from "../chains/56789"; +import c56914 from "../chains/56914"; import c57000 from "../chains/57000"; import c58008 from "../chains/58008"; import c59140 from "../chains/59140"; import c59144 from "../chains/59144"; +import c59971 from "../chains/59971"; import c60000 from "../chains/60000"; import c60001 from "../chains/60001"; import c60002 from "../chains/60002"; @@ -881,10 +904,12 @@ import c67390 from "../chains/67390"; import c67588 from "../chains/67588"; import c68770 from "../chains/68770"; import c69420 from "../chains/69420"; +import c69740 from "../chains/69740"; import c70000 from "../chains/70000"; import c70001 from "../chains/70001"; import c70002 from "../chains/70002"; import c70103 from "../chains/70103"; +import c70466 from "../chains/70466"; import c71111 from "../chains/71111"; import c71393 from "../chains/71393"; import c71401 from "../chains/71401"; @@ -903,6 +928,8 @@ import c78431 from "../chains/78431"; import c78432 from "../chains/78432"; import c79879 from "../chains/79879"; import c80001 from "../chains/80001"; +import c80182 from "../chains/80182"; +import c81041 from "../chains/81041"; import c81341 from "../chains/81341"; import c81342 from "../chains/81342"; import c81343 from "../chains/81343"; @@ -921,6 +948,7 @@ import c85449 from "../chains/85449"; import c88002 from "../chains/88002"; import c88880 from "../chains/88880"; import c88882 from "../chains/88882"; +import c88883 from "../chains/88883"; import c88888 from "../chains/88888"; import c90210 from "../chains/90210"; import c91002 from "../chains/91002"; @@ -974,7 +1002,9 @@ import c201018 from "../chains/201018"; import c201030 from "../chains/201030"; import c201804 from "../chains/201804"; import c202020 from "../chains/202020"; +import c202212 from "../chains/202212"; import c202624 from "../chains/202624"; +import c204005 from "../chains/204005"; import c210425 from "../chains/210425"; import c220315 from "../chains/220315"; import c221230 from "../chains/221230"; @@ -1029,6 +1059,7 @@ import c535037 from "../chains/535037"; import c622277 from "../chains/622277"; import c641230 from "../chains/641230"; import c651940 from "../chains/651940"; +import c660868 from "../chains/660868"; import c666666 from "../chains/666666"; import c666888 from "../chains/666888"; import c751230 from "../chains/751230"; @@ -1048,6 +1079,7 @@ import c923018 from "../chains/923018"; import c955305 from "../chains/955305"; import c988207 from "../chains/988207"; import c993535 from "../chains/993535"; +import c1127469 from "../chains/1127469"; import c1261120 from "../chains/1261120"; import c1313114 from "../chains/1313114"; import c1313500 from "../chains/1313500"; @@ -1082,6 +1114,7 @@ import c9322253 from "../chains/9322253"; import c10067275 from "../chains/10067275"; import c10101010 from "../chains/10101010"; import c11155111 from "../chains/11155111"; +import c11155420 from "../chains/11155420"; import c13371337 from "../chains/13371337"; import c14288640 from "../chains/14288640"; import c16658437 from "../chains/16658437"; @@ -1098,7 +1131,7 @@ import c31415926 from "../chains/31415926"; import c35855456 from "../chains/35855456"; import c43214913 from "../chains/43214913"; import c61717561 from "../chains/61717561"; -import c65010000 from "../chains/65010000"; +import c65010001 from "../chains/65010001"; import c65100000 from "../chains/65100000"; import c68840142 from "../chains/68840142"; import c88888888 from "../chains/88888888"; @@ -1340,6 +1373,7 @@ export { default as Plinga } from "../chains/242" export { default as EnergyWebChain } from "../chains/246" export { default as Oasys } from "../chains/248" export { default as Fantom } from "../chains/250" +export { default as Fraxchain } from "../chains/252" export { default as Kroma } from "../chains/255" export { default as HuobiEcoChainTestnet } from "../chains/256" export { default as Setheum } from "../chains/258" @@ -1348,14 +1382,14 @@ export { default as SurBlockchainNetwork } from "../chains/262" export { default as HighPerformanceBlockchain } from "../chains/269" export { default as Egoncoin } from "../chains/271" export { default as LachainLachain } from "../chains/274" -export { default as ZksyncEraTestnet } from "../chains/280" +export { default as ZksyncEraGoerliTestnetDeprecated } from "../chains/280" export { default as BobaNetwork } from "../chains/288" export { default as Orderly } from "../chains/291" export { default as Hedera } from "../chains/295" export { default as HederaTestnet } from "../chains/296" export { default as HederaPreviewnet } from "../chains/297" export { default as HederaLocalnet } from "../chains/298" -export { default as DeprecatedOptimismOnGc } from "../chains/300" +export { default as ZksyncSepoliaTestnet } from "../chains/300" export { default as Bobaopera } from "../chains/301" export { default as NeurochainTestnet } from "../chains/303" export { default as WyzthTestnet } from "../chains/309" @@ -1364,7 +1398,7 @@ export { default as Neurochain } from "../chains/313" export { default as Filecoin } from "../chains/314" export { default as Kcc } from "../chains/321" export { default as KccTestnet } from "../chains/322" -export { default as ZksyncEra } from "../chains/324" +export { default as Zksync } from "../chains/324" export { default as Web3q } from "../chains/333" export { default as DfkChainTest } from "../chains/335" export { default as Shiden } from "../chains/336" @@ -1392,6 +1426,7 @@ export { default as ObscuroTestnet } from "../chains/443" export { default as SynapseChainTestnet } from "../chains/444" export { default as ArzioChain } from "../chains/456" export { default as AreonNetworkTestnet } from "../chains/462" +export { default as AreonNetwork } from "../chains/463" export { default as Rupaya } from "../chains/499" export { default as CaminoCChain } from "../chains/500" export { default as ColumbusTestNetwork } from "../chains/501" @@ -1419,6 +1454,7 @@ export { default as GraphlinqBlockchain } from "../chains/614" export { default as Avocado } from "../chains/634" export { default as SxNetworkTestnet } from "../chains/647" export { default as EnduranceSmartChain } from "../chains/648" +export { default as Kalichain } from "../chains/653" export { default as PixieChainTestnet } from "../chains/666" export { default as LaosArrakis } from "../chains/667" export { default as Juncachain } from "../chains/668" @@ -1430,6 +1466,7 @@ export { default as BlockchainStationTestnet } from "../chains/708" export { default as Highbury } from "../chains/710" export { default as ShibariumBeta } from "../chains/719" export { default as LycanChain } from "../chains/721" +export { default as Blucrates } from "../chains/727" export { default as CantoTestnet } from "../chains/740" export { default as VentionSmartChainTestnet } from "../chains/741" export { default as ScriptTestnet } from "../chains/742" @@ -1444,6 +1481,7 @@ export { default as LucidBlockchain } from "../chains/800" export { default as Haic } from "../chains/803" export { default as PortalFantasyChainTest } from "../chains/808" export { default as Qitmeer } from "../chains/813" +export { default as FirechainZkevm } from "../chains/814" export { default as BeoneChain } from "../chains/818" export { default as Callisto } from "../chains/820" export { default as CallistoTestnetDeprecated } from "../chains/821" @@ -1498,7 +1536,8 @@ export { default as ProxyNetworkTestnet } from "../chains/1031" export { default as BronosTestnet } from "../chains/1038" export { default as Bronos } from "../chains/1039" export { default as ShimmerevmTestnetDeprecated } from "../chains/1071" -export { default as ShimmerevmTestnet } from "../chains/1072" +export { default as ShimmerevmTestnetDeprecated1072 } from "../chains/1072" +export { default as ShimmerevmTestnet } from "../chains/1073" export { default as MintaraTestnet } from "../chains/1079" export { default as Mintara } from "../chains/1080" export { default as MetisAndromeda } from "../chains/1088" @@ -1579,7 +1618,7 @@ export { default as AnytypeEvmChain } from "../chains/1701" export { default as Tbsi } from "../chains/1707" export { default as TbsiTestnet } from "../chains/1708" export { default as PaletteChain } from "../chains/1718" -export { default as RollTestnet } from "../chains/1748" +export { default as FormTestnet } from "../chains/1748" export { default as Partychain } from "../chains/1773" export { default as Gauss } from "../chains/1777" export { default as Kerleano } from "../chains/1804" @@ -1595,6 +1634,7 @@ export { default as BonNetwork } from "../chains/1898" export { default as SportsChainNetwork } from "../chains/1904" export { default as Bitcichain } from "../chains/1907" export { default as BitcichainTestnet } from "../chains/1908" +export { default as MerkleScan } from "../chains/1909" export { default as OnusChainTestnet } from "../chains/1945" export { default as DChain } from "../chains/1951" export { default as DexillaTestnet } from "../chains/1954" @@ -1655,6 +1695,7 @@ export { default as Kava } from "../chains/2222" export { default as Vchain } from "../chains/2223" export { default as KrestNetwork } from "../chains/2241" export { default as BombChain } from "../chains/2300" +export { default as EbroNetwork } from "../chains/2306" export { default as Arevia } from "../chains/2309" export { default as SomaNetworkTestnet } from "../chains/2323" export { default as Altcoinchain } from "../chains/2330" @@ -1665,6 +1706,7 @@ export { default as BombChainTestnet } from "../chains/2399" export { default as TcgVerse } from "../chains/2400" export { default as Xodex } from "../chains/2415" export { default as UnicornUltraNebulasTestnet } from "../chains/2484" +export { default as FraxchainTestnet } from "../chains/2522" export { default as Kortho } from "../chains/2559" export { default as Techpay } from "../chains/2569" export { default as Pocrnet } from "../chains/2606" @@ -1672,7 +1714,7 @@ export { default as RedlightChain } from "../chains/2611" export { default as EzchainCChain } from "../chains/2612" export { default as EzchainCChainTestnet } from "../chains/2613" export { default as WhitebitNetworkTestnet } from "../chains/2625" -export { default as MorphismTestnet } from "../chains/2710" +export { default as MorphTestnet } from "../chains/2710" export { default as KLaos } from "../chains/2718" export { default as BobaNetworkGoerliTestnet } from "../chains/2888" export { default as Bityuan } from "../chains/2999" @@ -1708,6 +1750,7 @@ export { default as Senjepowers } from "../chains/3699" export { default as XplaTestnetXplatest } from "../chains/3701" export { default as Crossbell } from "../chains/3737" export { default as Alveychain } from "../chains/3797" +export { default as FirechainZkevmGhostrider } from "../chains/3885" export { default as Kalychain } from "../chains/3888" export { default as KalychainTestnet } from "../chains/3889" export { default as DracNetwork } from "../chains/3912" @@ -1718,6 +1761,7 @@ export { default as Yuanchain } from "../chains/3999" export { default as OzoneChain } from "../chains/4000" export { default as PeperiumChainTestnet } from "../chains/4001" export { default as FantomTestnet } from "../chains/4002" +export { default as X1Fastnet } from "../chains/4003" export { default as BobaoperaTestnet } from "../chains/4051" export { default as Nahmii3 } from "../chains/4061" export { default as Nahmii3Testnet } from "../chains/4062" @@ -1727,6 +1771,7 @@ export { default as Bitindi } from "../chains/4099" export { default as AiozNetworkTestnet } from "../chains/4102" export { default as HumansAiTestnet } from "../chains/4139" export { default as TipboxcoinTestnet } from "../chains/4141" +export { default as CrossfiTestnet } from "../chains/4157" export { default as PhiNetworkV1 } from "../chains/4181" export { default as LuksoTestnet } from "../chains/4201" export { default as Nexi } from "../chains/4242" @@ -1893,6 +1938,7 @@ export { default as SardisTestnet } from "../chains/11612" export { default as SanrChain } from "../chains/11888" export { default as PolygonSupernetArianee } from "../chains/11891" export { default as Satoshichain } from "../chains/12009" +export { default as QiM11272 } from "../chains/12035" export { default as SingularityZeroTestnet } from "../chains/12051" export { default as SingularityZero } from "../chains/12052" export { default as BrcChain } from "../chains/12123" @@ -1906,9 +1952,11 @@ export { default as Sps } from "../chains/13000" export { default as CreditSmartChainCredit } from "../chains/13308" export { default as BeamTestnet } from "../chains/13337" export { default as Phoenix } from "../chains/13381" +export { default as ImmutableZkevmTestnet } from "../chains/13473" export { default as Susono } from "../chains/13812" export { default as SpsTestnet } from "../chains/14000" export { default as HumanodeTestnet5Israfel } from "../chains/14853" +export { default as ImmutableZkevmDevnet } from "../chains/15003" export { default as QiM11271 } from "../chains/15535" export { default as Loopnetwork } from "../chains/15551" export { default as TrustEvmTestnet } from "../chains/15555" @@ -1921,6 +1969,7 @@ export { default as Airdao } from "../chains/16718" export { default as IvarChainTestnet } from "../chains/16888" export { default as Holesky } from "../chains/17000" export { default as RedstoneHoleskyTestnet } from "../chains/17001" +export { default as Qi1204i3 } from "../chains/17026" export { default as G8chain } from "../chains/17171" export { default as PaletteChainTestnet } from "../chains/17180" export { default as EosEvmNetwork } from "../chains/17777" @@ -1930,12 +1979,14 @@ export { default as ProofOfMemes } from "../chains/18159" export { default as G8chainTestnet } from "../chains/18181" export { default as MxcZkevm } from "../chains/18686" export { default as HomeVerse } from "../chains/19011" +export { default as St1207V1 } from "../chains/19683" export { default as BtcixNetwork } from "../chains/19845" export { default as Camelark } from "../chains/20001" export { default as CallistoTestnet } from "../chains/20729" export { default as P12Chain } from "../chains/20736" export { default as CennznetAzalea } from "../chains/21337" export { default as Omchain } from "../chains/21816" +export { default as Bsl } from "../chains/21912" export { default as Taycan } from "../chains/22023" export { default as AirdaoTestnet } from "../chains/22040" export { default as Nautilus } from "../chains/22222" @@ -1976,6 +2027,8 @@ export { default as Mode } from "../chains/34443" export { default as J2oTaro } from "../chains/35011" export { default as Q } from "../chains/35441" export { default as QTestnet } from "../chains/35443" +export { default as Qr1129i1 } from "../chains/35730" +export { default as Qr1205s1 } from "../chains/36908" export { default as Connectormanager } from "../chains/38400" export { default as ConnectormanagerRobin } from "../chains/38401" export { default as Energi } from "../chains/39797" @@ -1993,6 +2046,7 @@ export { default as Athereum } from "../chains/43110" export { default as AvalancheFuji } from "../chains/43113" export { default as Avalanche } from "../chains/43114" export { default as BobaAvax } from "../chains/43288" +export { default as ZkfairTestnet } from "../chains/43851" export { default as Frenchain } from "../chains/44444" export { default as CeloAlfajoresTestnet } from "../chains/44787" export { default as AutobahnNetwork } from "../chains/45000" @@ -2014,10 +2068,12 @@ export { default as ReiChain } from "../chains/55555" export { default as ReiChainTestnet } from "../chains/55556" export { default as BobaBnb } from "../chains/56288" export { default as VeloLabs } from "../chains/56789" +export { default as Kk1223 } from "../chains/56914" export { default as RolluxTestnet } from "../chains/57000" export { default as SepoliaPgnPublicGoodsNetwork } from "../chains/58008" export { default as LineaTestnet } from "../chains/59140" export { default as Linea } from "../chains/59144" +export { default as GenesysCode } from "../chains/59971" export { default as ThinkiumTestnetChain0 } from "../chains/60000" export { default as ThinkiumTestnetChain1 } from "../chains/60001" export { default as ThinkiumTestnetChain2 } from "../chains/60002" @@ -2037,10 +2093,12 @@ export { default as Siriusnet } from "../chains/67390" export { default as CosmicChain } from "../chains/67588" export { default as Dm2Verse } from "../chains/68770" export { default as Condrieu } from "../chains/69420" +export { default as WillSTestnet } from "../chains/69740" export { default as ThinkiumChain0 } from "../chains/70000" export { default as ThinkiumChain1 } from "../chains/70001" export { default as ThinkiumChain2 } from "../chains/70002" export { default as ThinkiumChain103 } from "../chains/70103" +export { default as CohanTest3 } from "../chains/70466" export { default as Guapcoinx } from "../chains/71111" export { default as PolyjuiceTestnet } from "../chains/71393" export { default as GodwokenTestnetV1 } from "../chains/71401" @@ -2059,6 +2117,8 @@ export { default as BulletinSubnet } from "../chains/78431" export { default as ConduitSubnet } from "../chains/78432" export { default as GoldSmartChainTestnet } from "../chains/79879" export { default as Mumbai } from "../chains/80001" +export { default as QiM12051 } from "../chains/80182" +export { default as Nordek } from "../chains/81041" export { default as AmanaTestnet } from "../chains/81341" export { default as AmanaMixnet } from "../chains/81342" export { default as AmanaPrivnet } from "../chains/81343" @@ -2077,6 +2137,7 @@ export { default as Cybertrust } from "../chains/85449" export { default as NautilusProteusTestnet } from "../chains/88002" export { default as ChilizScovilleTestnet } from "../chains/88880" export { default as SpicyChain } from "../chains/88882" +export { default as ProjOrcTestnetAlpha } from "../chains/88883" export { default as ChilizChain } from "../chains/88888" export { default as BeverlyHills } from "../chains/90210" export { default as NautilusTritionChain } from "../chains/91002" @@ -2130,7 +2191,9 @@ export { default as Alaya } from "../chains/201018" export { default as AlayaDevTestnet } from "../chains/201030" export { default as MythicalChain } from "../chains/201804" export { default as DecimalSmartChainTestnet } from "../chains/202020" +export { default as X1Devnet } from "../chains/202212" export { default as Jellie } from "../chains/202624" +export { default as X1Network } from "../chains/204005" export { default as Platon } from "../chains/210425" export { default as Mas } from "../chains/220315" export { default as Reapchain } from "../chains/221230" @@ -2182,9 +2245,10 @@ export { default as ScrollAlphaTestnet } from "../chains/534353" export { default as ScrollPreAlphaTestnet } from "../chains/534354" export { default as ShinariumBeta } from "../chains/534849" export { default as BeanecoSmartchain } from "../chains/535037" -export { default as Rethereum } from "../chains/622277" +export { default as Hypra } from "../chains/622277" export { default as BearNetworkChain } from "../chains/641230" export { default as All } from "../chains/651940" +export { default as OcashTestnet } from "../chains/660868" export { default as VisionVpioneerTestChain } from "../chains/666666" export { default as HelaOfficialRuntimeTestnet } from "../chains/666888" export { default as BearNetworkChainTestnet } from "../chains/751230" @@ -2204,6 +2268,7 @@ export { default as FncyTestnet } from "../chains/923018" export { default as EluvioContentFabric } from "../chains/955305" export { default as EcroxChain } from "../chains/988207" export { default as Qr1120y1 } from "../chains/993535" +export { default as TiltyardSubnet } from "../chains/1127469" export { default as Zkatana } from "../chains/1261120" export { default as EthoProtocol } from "../chains/1313114" export { default as Xerom } from "../chains/1313500" @@ -2238,6 +2303,7 @@ export { default as Milvine } from "../chains/9322253" export { default as PlianTestnetSubchain1 } from "../chains/10067275" export { default as Soverun } from "../chains/10101010" export { default as Sepolia } from "../chains/11155111" +export { default as OpSepoliaTestnet } from "../chains/11155420" export { default as PepchainChurchill } from "../chains/13371337" export { default as Anduschain } from "../chains/14288640" export { default as PlianTestnetMain } from "../chains/16658437" @@ -2254,7 +2320,7 @@ export { default as FilecoinLocalTestnet } from "../chains/31415926" export { default as JoysDigital } from "../chains/35855456" export { default as Maistestsubnet } from "../chains/43214913" export { default as Aquachain } from "../chains/61717561" -export { default as AutonityBakerlooThamesTestnet } from "../chains/65010000" +export { default as AutonityBakerlooBaradaTestnet } from "../chains/65010001" export { default as AutonityPiccadillyThamesTestnet } from "../chains/65100000" export { default as FrameTestnet } from "../chains/68840142" export { default as TEAMBlockchain } from "../chains/88888888" @@ -2317,7 +2383,7 @@ export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c4216 * @deprecated use `fetchChains()` instead */ // @ts-expect-error - TODO: fix this later -export const allChains: Chain[] = [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50, c51, c52, c53, c54, c55, c56, c57, c58, c59, c60, c61, c62, c63, c64, c65, c66, c67, c68, c69, c70, c71, c72, c73, c74, c75, c76, c77, c78, c79, c80, c81, c82, c83, c84, c85, c86, c87, c88, c89, c90, c91, c92, c93, c94, c95, c96, c97, c98, c99, c100, c101, c102, c103, c104, c105, c106, c107, c108, c109, c110, c111, c112, c113, c114, c115, c116, c117, c118, c119, c120, c121, c122, c123, c124, c125, c126, c127, c128, c134, c135, c136, c137, c138, c139, c141, c142, c144, c148, c150, c151, c152, c153, c154, c155, c156, c160, c161, c162, c163, c165, c167, c168, c169, c170, c172, c180, c186, c188, c189, c193, c195, c196, c197, c198, c199, c200, c201, c204, c206, c207, c208, c210, c211, c212, c214, c217, c218, c222, c225, c226, c230, c236, c242, c246, c248, c250, c255, c256, c258, c259, c262, c269, c271, c274, c280, c288, c291, c295, c296, c297, c298, c300, c301, c303, c309, c311, c313, c314, c321, c322, c324, c333, c335, c336, c338, c345, c361, c363, c364, c365, c369, c371, c385, c399, c400, c401, c408, c411, c416, c418, c420, c424, c427, c428, c443, c444, c456, c462, c499, c500, c501, c512, c513, c516, c520, c529, c530, c534, c542, c555, c558, c568, c570, c588, c592, c595, c596, c597, c599, c600, c601, c614, c634, c647, c648, c666, c667, c668, c669, c686, c700, c707, c708, c710, c719, c721, c740, c741, c742, c766, c776, c777, c786, c787, c788, c789, c800, c803, c808, c813, c818, c820, c821, c841, c842, c859, c868, c876, c877, c880, c888, c900, c901, c902, c903, c909, c910, c917, c919, c927, c940, c941, c942, c943, c956, c963, c970, c971, c972, c977, c980, c985, c989, c990, c997, c998, c999, c1000, c1001, c1003, c1004, c1007, c1008, c1010, c1012, c1022, c1023, c1024, c1028, c1030, c1031, c1038, c1039, c1071, c1072, c1079, c1080, c1088, c1089, c1099, c1101, c1107, c1108, c1111, c1112, c1115, c1116, c1117, c1130, c1131, c1133, c1138, c1139, c1140, c1149, c1170, c1177, c1197, c1201, c1202, c1213, c1214, c1229, c1230, c1231, c1234, c1243, c1244, c1246, c1252, c1280, c1284, c1285, c1286, c1287, c1288, c1291, c1294, c1297, c1311, c1314, c1319, c1320, c1337, c1338, c1339, c1343, c1353, c1369, c1379, c1388, c1392, c1402, c1422, c1433, c1440, c1442, c1452, c1455, c1501, c1506, c1507, c1515, c1559, c1582, c1618, c1620, c1657, c1662, c1663, c1688, c1701, c1707, c1708, c1718, c1748, c1773, c1777, c1804, c1807, c1818, c1819, c1856, c1875, c1881, c1890, c1891, c1898, c1904, c1907, c1908, c1945, c1951, c1954, c1967, c1969, c1970, c1971, c1975, c1984, c1985, c1986, c1987, c1994, c1995, c2000, c2001, c2002, c2008, c2009, c2016, c2018, c2019, c2020, c2021, c2022, c2023, c2025, c2031, c2032, c2037, c2038, c2043, c2044, c2047, c2048, c2049, c2077, c2088, c2089, c2100, c2101, c2109, c2121, c2122, c2124, c2137, c2138, c2151, c2152, c2153, c2154, c2199, c2202, c2203, c2213, c2221, c2222, c2223, c2241, c2300, c2309, c2323, c2330, c2332, c2357, c2358, c2399, c2400, c2415, c2484, c2559, c2569, c2606, c2611, c2612, c2613, c2625, c2710, c2718, c2888, c2999, c3000, c3001, c3003, c3011, c3031, c3068, c3100, c3102, c3141, c3269, c3270, c3306, c3331, c3333, c3334, c3400, c3434, c3500, c3501, c3601, c3602, c3636, c3637, c3639, c3666, c3690, c3693, c3698, c3699, c3701, c3737, c3797, c3888, c3889, c3912, c3939, c3966, c3967, c3999, c4000, c4001, c4002, c4051, c4061, c4062, c4090, c4096, c4099, c4102, c4139, c4141, c4181, c4201, c4242, c4328, c4337, c4400, c4444, c4460, c4689, c4690, c4759, c4777, c4893, c4918, c4919, c4999, c5000, c5001, c5002, c5003, c5005, c5165, c5177, c5197, c5234, c5290, c5315, c5353, c5522, c5551, c5553, c5555, c5611, c5616, c5678, c5700, c5729, c5758, c5777, c5851, c5869, c6065, c6066, c6102, c6118, c6119, c6363, c6502, c6552, c6565, c6626, c6688, c6789, c6969, c6999, c7000, c7001, c7027, c7070, c7171, c7331, c7332, c7341, c7484, c7518, c7575, c7576, c7668, c7672, c7700, c7701, c7771, c7777, c7860, c7878, c7895, c7979, c8000, c8001, c8029, c8080, c8081, c8082, c8086, c8098, c8131, c8132, c8133, c8134, c8135, c8136, c8181, c8192, c8194, c8217, c8272, c8285, c8387, c8453, c8654, c8655, c8668, c8723, c8724, c8738, c8768, c8848, c8880, c8881, c8882, c8883, c8888, c8889, c8898, c8899, c8989, c8995, c9000, c9001, c9012, c9100, c9170, c9223, c9339, c9527, c9528, c9559, c9700, c9728, c9768, c9779, c9790, c9792, c9818, c9819, c9977, c9990, c9996, c9997, c9999, c10000, c10001, c10024, c10081, c10086, c10101, c10200, c10201, c10243, c10248, c10395, c10507, c10508, c10823, c10946, c10947, c11110, c11111, c11115, c11119, c11235, c11437, c11612, c11888, c11891, c12009, c12051, c12052, c12123, c12306, c12321, c12345, c12611, c12715, c12890, c13000, c13308, c13337, c13381, c13812, c14000, c14853, c15535, c15551, c15555, c15557, c16000, c16001, c16507, c16688, c16718, c16888, c17000, c17001, c17171, c17180, c17777, c18000, c18122, c18159, c18181, c18686, c19011, c19845, c20001, c20729, c20736, c21337, c21816, c22023, c22040, c22222, c22776, c23006, c23118, c23294, c23295, c23934, c24484, c24734, c25888, c25925, c26026, c26600, c26863, c28528, c29548, c30067, c30103, c30891, c31102, c31223, c31224, c31337, c31415, c32520, c32659, c32769, c32990, c33101, c33210, c33333, c33385, c33469, c33909, c34443, c35011, c35441, c35443, c38400, c38401, c39797, c39815, c41500, c42069, c42161, c42170, c42220, c42261, c42262, c42801, c42888, c43110, c43113, c43114, c43288, c44444, c44787, c45000, c46688, c47805, c49049, c49088, c49797, c50001, c50021, c51178, c51712, c52014, c53935, c54211, c54321, c55004, c55555, c55556, c56288, c56789, c57000, c58008, c59140, c59144, c60000, c60001, c60002, c60103, c61800, c61803, c61916, c62278, c62320, c62621, c63000, c63001, c63079, c65450, c66988, c67390, c67588, c68770, c69420, c70000, c70001, c70002, c70103, c71111, c71393, c71401, c71402, c72605, c73799, c73927, c75000, c77238, c77612, c77777, c78110, c78281, c78430, c78431, c78432, c79879, c80001, c81341, c81342, c81343, c81351, c81352, c81353, c81361, c81362, c81363, c81720, c82807, c84531, c84532, c84886, c85449, c88002, c88880, c88882, c88888, c90210, c91002, c91003, c92001, c96970, c97288, c99099, c99998, c99999, c100000, c100001, c100002, c100003, c100004, c100005, c100006, c100007, c100008, c100009, c100010, c100100, c101010, c103090, c108801, c110000, c110001, c110002, c110003, c110004, c110005, c110006, c110007, c110008, c111000, c111111, c112358, c123456, c131419, c142857, c167004, c167005, c167006, c167007, c188710, c188881, c200101, c200202, c200625, c201018, c201030, c201804, c202020, c202624, c210425, c220315, c221230, c221231, c224168, c230315, c234666, c246529, c246785, c247253, c256256, c266256, c271271, c281121, c314159, c330844, c331769, c331771, c333331, c333333, c333666, c333777, c333888, c333999, c355113, c363636, c373737, c381931, c381932, c404040, c420420, c420666, c420692, c421611, c421613, c421614, c424242, c431140, c432201, c432204, c444900, c471100, c474142, c512512, c513100, c534351, c534352, c534353, c534354, c534849, c535037, c622277, c641230, c651940, c666666, c666888, c751230, c761412, c776877, c800001, c827431, c846000, c855456, c888888, c894538, c900000, c910000, c920000, c920001, c923018, c955305, c988207, c993535, c1261120, c1313114, c1313500, c1337702, c1337802, c1337803, c1440001, c2021398, c2099156, c2203181, c2206132, c2611555, c3141592, c3441005, c4000003, c4281033, c5167003, c5201420, c5555555, c5555558, c7225878, c7355310, c7668378, c7762959, c7777777, c8007736, c8794598, c8888881, c8888888, c9322252, c9322253, c10067275, c10101010, c11155111, c13371337, c14288640, c16658437, c18289463, c20180430, c20181205, c20201022, c22052002, c27082017, c27082022, c28945486, c29032022, c31415926, c35855456, c43214913, c61717561, c65010000, c65100000, c68840142, c88888888, c99415706, c192837465, c222000222, c245022926, c245022934, c245022940, c278611351, c311752642, c333000333, c344106930, c356256156, c476158412, c486217935, c503129905, c999999999, c1122334455, c1146703430, c1273227453, c1313161554, c1313161555, c1313161556, c1350216234, c1351057110, c1380996178, c1482601649, c1517929550, c1564830818, c1666600000, c1666600001, c1666600002, c1666600003, c1666700000, c1666700001, c1666900000, c1666900001, c2021121117, c2046399126, c2863311531, c3125659152, c4216137055, c11297108099, c11297108109, c47279324479, c111222333444, c197710212030, c197710212031, c383414847825, c666301171999, c6022140761023, c868455272153094]; +export const allChains: Chain[] = [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50, c51, c52, c53, c54, c55, c56, c57, c58, c59, c60, c61, c62, c63, c64, c65, c66, c67, c68, c69, c70, c71, c72, c73, c74, c75, c76, c77, c78, c79, c80, c81, c82, c83, c84, c85, c86, c87, c88, c89, c90, c91, c92, c93, c94, c95, c96, c97, c98, c99, c100, c101, c102, c103, c104, c105, c106, c107, c108, c109, c110, c111, c112, c113, c114, c115, c116, c117, c118, c119, c120, c121, c122, c123, c124, c125, c126, c127, c128, c134, c135, c136, c137, c138, c139, c141, c142, c144, c148, c150, c151, c152, c153, c154, c155, c156, c160, c161, c162, c163, c165, c167, c168, c169, c170, c172, c180, c186, c188, c189, c193, c195, c196, c197, c198, c199, c200, c201, c204, c206, c207, c208, c210, c211, c212, c214, c217, c218, c222, c225, c226, c230, c236, c242, c246, c248, c250, c252, c255, c256, c258, c259, c262, c269, c271, c274, c280, c288, c291, c295, c296, c297, c298, c300, c301, c303, c309, c311, c313, c314, c321, c322, c324, c333, c335, c336, c338, c345, c361, c363, c364, c365, c369, c371, c385, c399, c400, c401, c408, c411, c416, c418, c420, c424, c427, c428, c443, c444, c456, c462, c463, c499, c500, c501, c512, c513, c516, c520, c529, c530, c534, c542, c555, c558, c568, c570, c588, c592, c595, c596, c597, c599, c600, c601, c614, c634, c647, c648, c653, c666, c667, c668, c669, c686, c700, c707, c708, c710, c719, c721, c727, c740, c741, c742, c766, c776, c777, c786, c787, c788, c789, c800, c803, c808, c813, c814, c818, c820, c821, c841, c842, c859, c868, c876, c877, c880, c888, c900, c901, c902, c903, c909, c910, c917, c919, c927, c940, c941, c942, c943, c956, c963, c970, c971, c972, c977, c980, c985, c989, c990, c997, c998, c999, c1000, c1001, c1003, c1004, c1007, c1008, c1010, c1012, c1022, c1023, c1024, c1028, c1030, c1031, c1038, c1039, c1071, c1072, c1073, c1079, c1080, c1088, c1089, c1099, c1101, c1107, c1108, c1111, c1112, c1115, c1116, c1117, c1130, c1131, c1133, c1138, c1139, c1140, c1149, c1170, c1177, c1197, c1201, c1202, c1213, c1214, c1229, c1230, c1231, c1234, c1243, c1244, c1246, c1252, c1280, c1284, c1285, c1286, c1287, c1288, c1291, c1294, c1297, c1311, c1314, c1319, c1320, c1337, c1338, c1339, c1343, c1353, c1369, c1379, c1388, c1392, c1402, c1422, c1433, c1440, c1442, c1452, c1455, c1501, c1506, c1507, c1515, c1559, c1582, c1618, c1620, c1657, c1662, c1663, c1688, c1701, c1707, c1708, c1718, c1748, c1773, c1777, c1804, c1807, c1818, c1819, c1856, c1875, c1881, c1890, c1891, c1898, c1904, c1907, c1908, c1909, c1945, c1951, c1954, c1967, c1969, c1970, c1971, c1975, c1984, c1985, c1986, c1987, c1994, c1995, c2000, c2001, c2002, c2008, c2009, c2016, c2018, c2019, c2020, c2021, c2022, c2023, c2025, c2031, c2032, c2037, c2038, c2043, c2044, c2047, c2048, c2049, c2077, c2088, c2089, c2100, c2101, c2109, c2121, c2122, c2124, c2137, c2138, c2151, c2152, c2153, c2154, c2199, c2202, c2203, c2213, c2221, c2222, c2223, c2241, c2300, c2306, c2309, c2323, c2330, c2332, c2357, c2358, c2399, c2400, c2415, c2484, c2522, c2559, c2569, c2606, c2611, c2612, c2613, c2625, c2710, c2718, c2888, c2999, c3000, c3001, c3003, c3011, c3031, c3068, c3100, c3102, c3141, c3269, c3270, c3306, c3331, c3333, c3334, c3400, c3434, c3500, c3501, c3601, c3602, c3636, c3637, c3639, c3666, c3690, c3693, c3698, c3699, c3701, c3737, c3797, c3885, c3888, c3889, c3912, c3939, c3966, c3967, c3999, c4000, c4001, c4002, c4003, c4051, c4061, c4062, c4090, c4096, c4099, c4102, c4139, c4141, c4157, c4181, c4201, c4242, c4328, c4337, c4400, c4444, c4460, c4689, c4690, c4759, c4777, c4893, c4918, c4919, c4999, c5000, c5001, c5002, c5003, c5005, c5165, c5177, c5197, c5234, c5290, c5315, c5353, c5522, c5551, c5553, c5555, c5611, c5616, c5678, c5700, c5729, c5758, c5777, c5851, c5869, c6065, c6066, c6102, c6118, c6119, c6363, c6502, c6552, c6565, c6626, c6688, c6789, c6969, c6999, c7000, c7001, c7027, c7070, c7171, c7331, c7332, c7341, c7484, c7518, c7575, c7576, c7668, c7672, c7700, c7701, c7771, c7777, c7860, c7878, c7895, c7979, c8000, c8001, c8029, c8080, c8081, c8082, c8086, c8098, c8131, c8132, c8133, c8134, c8135, c8136, c8181, c8192, c8194, c8217, c8272, c8285, c8387, c8453, c8654, c8655, c8668, c8723, c8724, c8738, c8768, c8848, c8880, c8881, c8882, c8883, c8888, c8889, c8898, c8899, c8989, c8995, c9000, c9001, c9012, c9100, c9170, c9223, c9339, c9527, c9528, c9559, c9700, c9728, c9768, c9779, c9790, c9792, c9818, c9819, c9977, c9990, c9996, c9997, c9999, c10000, c10001, c10024, c10081, c10086, c10101, c10200, c10201, c10243, c10248, c10395, c10507, c10508, c10823, c10946, c10947, c11110, c11111, c11115, c11119, c11235, c11437, c11612, c11888, c11891, c12009, c12035, c12051, c12052, c12123, c12306, c12321, c12345, c12611, c12715, c12890, c13000, c13308, c13337, c13381, c13473, c13812, c14000, c14853, c15003, c15535, c15551, c15555, c15557, c16000, c16001, c16507, c16688, c16718, c16888, c17000, c17001, c17026, c17171, c17180, c17777, c18000, c18122, c18159, c18181, c18686, c19011, c19683, c19845, c20001, c20729, c20736, c21337, c21816, c21912, c22023, c22040, c22222, c22776, c23006, c23118, c23294, c23295, c23934, c24484, c24734, c25888, c25925, c26026, c26600, c26863, c28528, c29548, c30067, c30103, c30891, c31102, c31223, c31224, c31337, c31415, c32520, c32659, c32769, c32990, c33101, c33210, c33333, c33385, c33469, c33909, c34443, c35011, c35441, c35443, c35730, c36908, c38400, c38401, c39797, c39815, c41500, c42069, c42161, c42170, c42220, c42261, c42262, c42801, c42888, c43110, c43113, c43114, c43288, c43851, c44444, c44787, c45000, c46688, c47805, c49049, c49088, c49797, c50001, c50021, c51178, c51712, c52014, c53935, c54211, c54321, c55004, c55555, c55556, c56288, c56789, c56914, c57000, c58008, c59140, c59144, c59971, c60000, c60001, c60002, c60103, c61800, c61803, c61916, c62278, c62320, c62621, c63000, c63001, c63079, c65450, c66988, c67390, c67588, c68770, c69420, c69740, c70000, c70001, c70002, c70103, c70466, c71111, c71393, c71401, c71402, c72605, c73799, c73927, c75000, c77238, c77612, c77777, c78110, c78281, c78430, c78431, c78432, c79879, c80001, c80182, c81041, c81341, c81342, c81343, c81351, c81352, c81353, c81361, c81362, c81363, c81720, c82807, c84531, c84532, c84886, c85449, c88002, c88880, c88882, c88883, c88888, c90210, c91002, c91003, c92001, c96970, c97288, c99099, c99998, c99999, c100000, c100001, c100002, c100003, c100004, c100005, c100006, c100007, c100008, c100009, c100010, c100100, c101010, c103090, c108801, c110000, c110001, c110002, c110003, c110004, c110005, c110006, c110007, c110008, c111000, c111111, c112358, c123456, c131419, c142857, c167004, c167005, c167006, c167007, c188710, c188881, c200101, c200202, c200625, c201018, c201030, c201804, c202020, c202212, c202624, c204005, c210425, c220315, c221230, c221231, c224168, c230315, c234666, c246529, c246785, c247253, c256256, c266256, c271271, c281121, c314159, c330844, c331769, c331771, c333331, c333333, c333666, c333777, c333888, c333999, c355113, c363636, c373737, c381931, c381932, c404040, c420420, c420666, c420692, c421611, c421613, c421614, c424242, c431140, c432201, c432204, c444900, c471100, c474142, c512512, c513100, c534351, c534352, c534353, c534354, c534849, c535037, c622277, c641230, c651940, c660868, c666666, c666888, c751230, c761412, c776877, c800001, c827431, c846000, c855456, c888888, c894538, c900000, c910000, c920000, c920001, c923018, c955305, c988207, c993535, c1127469, c1261120, c1313114, c1313500, c1337702, c1337802, c1337803, c1440001, c2021398, c2099156, c2203181, c2206132, c2611555, c3141592, c3441005, c4000003, c4281033, c5167003, c5201420, c5555555, c5555558, c7225878, c7355310, c7668378, c7762959, c7777777, c8007736, c8794598, c8888881, c8888888, c9322252, c9322253, c10067275, c10101010, c11155111, c11155420, c13371337, c14288640, c16658437, c18289463, c20180430, c20181205, c20201022, c22052002, c27082017, c27082022, c28945486, c29032022, c31415926, c35855456, c43214913, c61717561, c65010001, c65100000, c68840142, c88888888, c99415706, c192837465, c222000222, c245022926, c245022934, c245022940, c278611351, c311752642, c333000333, c344106930, c356256156, c476158412, c486217935, c503129905, c999999999, c1122334455, c1146703430, c1273227453, c1313161554, c1313161555, c1313161556, c1350216234, c1351057110, c1380996178, c1482601649, c1517929550, c1564830818, c1666600000, c1666600001, c1666600002, c1666600003, c1666700000, c1666700001, c1666900000, c1666900001, c2021121117, c2046399126, c2863311531, c3125659152, c4216137055, c11297108099, c11297108109, c47279324479, c111222333444, c197710212030, c197710212031, c383414847825, c666301171999, c6022140761023, c868455272153094]; type ChainsById = { 1: typeof c1, @@ -2506,6 +2572,7 @@ type ChainsById = { 246: typeof c246, 248: typeof c248, 250: typeof c250, +252: typeof c252, 255: typeof c255, 256: typeof c256, 258: typeof c258, @@ -2558,6 +2625,7 @@ type ChainsById = { 444: typeof c444, 456: typeof c456, 462: typeof c462, +463: typeof c463, 499: typeof c499, 500: typeof c500, 501: typeof c501, @@ -2585,6 +2653,7 @@ type ChainsById = { 634: typeof c634, 647: typeof c647, 648: typeof c648, +653: typeof c653, 666: typeof c666, 667: typeof c667, 668: typeof c668, @@ -2596,6 +2665,7 @@ type ChainsById = { 710: typeof c710, 719: typeof c719, 721: typeof c721, +727: typeof c727, 740: typeof c740, 741: typeof c741, 742: typeof c742, @@ -2610,6 +2680,7 @@ type ChainsById = { 803: typeof c803, 808: typeof c808, 813: typeof c813, +814: typeof c814, 818: typeof c818, 820: typeof c820, 821: typeof c821, @@ -2665,6 +2736,7 @@ type ChainsById = { 1039: typeof c1039, 1071: typeof c1071, 1072: typeof c1072, +1073: typeof c1073, 1079: typeof c1079, 1080: typeof c1080, 1088: typeof c1088, @@ -2761,6 +2833,7 @@ type ChainsById = { 1904: typeof c1904, 1907: typeof c1907, 1908: typeof c1908, +1909: typeof c1909, 1945: typeof c1945, 1951: typeof c1951, 1954: typeof c1954, @@ -2821,6 +2894,7 @@ type ChainsById = { 2223: typeof c2223, 2241: typeof c2241, 2300: typeof c2300, +2306: typeof c2306, 2309: typeof c2309, 2323: typeof c2323, 2330: typeof c2330, @@ -2831,6 +2905,7 @@ type ChainsById = { 2400: typeof c2400, 2415: typeof c2415, 2484: typeof c2484, +2522: typeof c2522, 2559: typeof c2559, 2569: typeof c2569, 2606: typeof c2606, @@ -2874,6 +2949,7 @@ type ChainsById = { 3701: typeof c3701, 3737: typeof c3737, 3797: typeof c3797, +3885: typeof c3885, 3888: typeof c3888, 3889: typeof c3889, 3912: typeof c3912, @@ -2884,6 +2960,7 @@ type ChainsById = { 4000: typeof c4000, 4001: typeof c4001, 4002: typeof c4002, +4003: typeof c4003, 4051: typeof c4051, 4061: typeof c4061, 4062: typeof c4062, @@ -2893,6 +2970,7 @@ type ChainsById = { 4102: typeof c4102, 4139: typeof c4139, 4141: typeof c4141, +4157: typeof c4157, 4181: typeof c4181, 4201: typeof c4201, 4242: typeof c4242, @@ -3059,6 +3137,7 @@ type ChainsById = { 11888: typeof c11888, 11891: typeof c11891, 12009: typeof c12009, +12035: typeof c12035, 12051: typeof c12051, 12052: typeof c12052, 12123: typeof c12123, @@ -3072,9 +3151,11 @@ type ChainsById = { 13308: typeof c13308, 13337: typeof c13337, 13381: typeof c13381, +13473: typeof c13473, 13812: typeof c13812, 14000: typeof c14000, 14853: typeof c14853, +15003: typeof c15003, 15535: typeof c15535, 15551: typeof c15551, 15555: typeof c15555, @@ -3087,6 +3168,7 @@ type ChainsById = { 16888: typeof c16888, 17000: typeof c17000, 17001: typeof c17001, +17026: typeof c17026, 17171: typeof c17171, 17180: typeof c17180, 17777: typeof c17777, @@ -3096,12 +3178,14 @@ type ChainsById = { 18181: typeof c18181, 18686: typeof c18686, 19011: typeof c19011, +19683: typeof c19683, 19845: typeof c19845, 20001: typeof c20001, 20729: typeof c20729, 20736: typeof c20736, 21337: typeof c21337, 21816: typeof c21816, +21912: typeof c21912, 22023: typeof c22023, 22040: typeof c22040, 22222: typeof c22222, @@ -3142,6 +3226,8 @@ type ChainsById = { 35011: typeof c35011, 35441: typeof c35441, 35443: typeof c35443, +35730: typeof c35730, +36908: typeof c36908, 38400: typeof c38400, 38401: typeof c38401, 39797: typeof c39797, @@ -3159,6 +3245,7 @@ type ChainsById = { 43113: typeof c43113, 43114: typeof c43114, 43288: typeof c43288, +43851: typeof c43851, 44444: typeof c44444, 44787: typeof c44787, 45000: typeof c45000, @@ -3180,10 +3267,12 @@ type ChainsById = { 55556: typeof c55556, 56288: typeof c56288, 56789: typeof c56789, +56914: typeof c56914, 57000: typeof c57000, 58008: typeof c58008, 59140: typeof c59140, 59144: typeof c59144, +59971: typeof c59971, 60000: typeof c60000, 60001: typeof c60001, 60002: typeof c60002, @@ -3203,10 +3292,12 @@ type ChainsById = { 67588: typeof c67588, 68770: typeof c68770, 69420: typeof c69420, +69740: typeof c69740, 70000: typeof c70000, 70001: typeof c70001, 70002: typeof c70002, 70103: typeof c70103, +70466: typeof c70466, 71111: typeof c71111, 71393: typeof c71393, 71401: typeof c71401, @@ -3225,6 +3316,8 @@ type ChainsById = { 78432: typeof c78432, 79879: typeof c79879, 80001: typeof c80001, +80182: typeof c80182, +81041: typeof c81041, 81341: typeof c81341, 81342: typeof c81342, 81343: typeof c81343, @@ -3243,6 +3336,7 @@ type ChainsById = { 88002: typeof c88002, 88880: typeof c88880, 88882: typeof c88882, +88883: typeof c88883, 88888: typeof c88888, 90210: typeof c90210, 91002: typeof c91002, @@ -3296,7 +3390,9 @@ type ChainsById = { 201030: typeof c201030, 201804: typeof c201804, 202020: typeof c202020, +202212: typeof c202212, 202624: typeof c202624, +204005: typeof c204005, 210425: typeof c210425, 220315: typeof c220315, 221230: typeof c221230, @@ -3351,6 +3447,7 @@ type ChainsById = { 622277: typeof c622277, 641230: typeof c641230, 651940: typeof c651940, +660868: typeof c660868, 666666: typeof c666666, 666888: typeof c666888, 751230: typeof c751230, @@ -3370,6 +3467,7 @@ type ChainsById = { 955305: typeof c955305, 988207: typeof c988207, 993535: typeof c993535, +1127469: typeof c1127469, 1261120: typeof c1261120, 1313114: typeof c1313114, 1313500: typeof c1313500, @@ -3404,6 +3502,7 @@ type ChainsById = { 10067275: typeof c10067275, 10101010: typeof c10101010, 11155111: typeof c11155111, +11155420: typeof c11155420, 13371337: typeof c13371337, 14288640: typeof c14288640, 16658437: typeof c16658437, @@ -3420,7 +3519,7 @@ type ChainsById = { 35855456: typeof c35855456, 43214913: typeof c43214913, 61717561: typeof c61717561, -65010000: typeof c65010000, +65010001: typeof c65010001, 65100000: typeof c65100000, 68840142: typeof c68840142, 88888888: typeof c88888888, @@ -3663,6 +3762,7 @@ type ChainIdsBySlug = { "energy-web-chain": 246, "oasys": 248, "fantom": 250, +"fraxchain": 252, "kroma": 255, "huobi-eco-chain-testnet": 256, "setheum": 258, @@ -3671,14 +3771,14 @@ type ChainIdsBySlug = { "high-performance-blockchain": 269, "egoncoin": 271, "lachain-lachain": 274, -"zksync-era-testnet": 280, +"zksync-era-goerli-testnet-deprecated": 280, "boba-network": 288, "orderly": 291, "hedera": 295, "hedera-testnet": 296, "hedera-previewnet": 297, "hedera-localnet": 298, -"deprecated-optimism-on-gc": 300, +"zksync-sepolia-testnet": 300, "bobaopera": 301, "neurochain-testnet": 303, "wyzth-testnet": 309, @@ -3687,7 +3787,7 @@ type ChainIdsBySlug = { "filecoin": 314, "kcc": 321, "kcc-testnet": 322, -"zksync-era": 324, +"zksync": 324, "web3q": 333, "dfk-chain-test": 335, "shiden": 336, @@ -3715,6 +3815,7 @@ type ChainIdsBySlug = { "synapse-chain-testnet": 444, "arzio-chain": 456, "areon-network-testnet": 462, +"areon-network": 463, "rupaya": 499, "camino-c-chain": 500, "columbus-test-network": 501, @@ -3742,6 +3843,7 @@ type ChainIdsBySlug = { "avocado": 634, "sx-network-testnet": 647, "endurance-smart-chain": 648, +"kalichain": 653, "pixie-chain-testnet": 666, "laos-arrakis": 667, "juncachain": 668, @@ -3753,6 +3855,7 @@ type ChainIdsBySlug = { "highbury": 710, "shibarium-beta": 719, "lycan-chain": 721, +"blucrates": 727, "canto-testnet": 740, "vention-smart-chain-testnet": 741, "script-testnet": 742, @@ -3767,6 +3870,7 @@ type ChainIdsBySlug = { "haic": 803, "portal-fantasy-chain-test": 808, "qitmeer": 813, +"firechain-zkevm": 814, "beone-chain": 818, "callisto": 820, "callisto-testnet-deprecated": 821, @@ -3821,7 +3925,8 @@ type ChainIdsBySlug = { "bronos-testnet": 1038, "bronos": 1039, "shimmerevm-testnet-deprecated": 1071, -"shimmerevm-testnet": 1072, +"shimmerevm-testnet-deprecated-1072": 1072, +"shimmerevm-testnet": 1073, "mintara-testnet": 1079, "mintara": 1080, "metis-andromeda": 1088, @@ -3902,7 +4007,7 @@ type ChainIdsBySlug = { "tbsi": 1707, "tbsi-testnet": 1708, "palette-chain": 1718, -"roll-testnet": 1748, +"form-testnet": 1748, "partychain": 1773, "gauss": 1777, "kerleano": 1804, @@ -3918,6 +4023,7 @@ type ChainIdsBySlug = { "sports-chain-network": 1904, "bitcichain": 1907, "bitcichain-testnet": 1908, +"merkle-scan": 1909, "onus-chain-testnet": 1945, "d-chain": 1951, "dexilla-testnet": 1954, @@ -3978,6 +4084,7 @@ type ChainIdsBySlug = { "vchain": 2223, "krest-network": 2241, "bomb-chain": 2300, +"ebro-network": 2306, "arevia": 2309, "soma-network-testnet": 2323, "altcoinchain": 2330, @@ -3988,6 +4095,7 @@ type ChainIdsBySlug = { "tcg-verse": 2400, "xodex": 2415, "unicorn-ultra-nebulas-testnet": 2484, +"fraxchain-testnet": 2522, "kortho": 2559, "techpay": 2569, "pocrnet": 2606, @@ -3995,7 +4103,7 @@ type ChainIdsBySlug = { "ezchain-c-chain": 2612, "ezchain-c-chain-testnet": 2613, "whitebit-network-testnet": 2625, -"morphism-testnet": 2710, +"morph-testnet": 2710, "k-laos": 2718, "boba-network-goerli-testnet": 2888, "bityuan": 2999, @@ -4031,6 +4139,7 @@ type ChainIdsBySlug = { "xpla-testnet-xplatest": 3701, "crossbell": 3737, "alveychain": 3797, +"firechain-zkevm-ghostrider": 3885, "kalychain": 3888, "kalychain-testnet": 3889, "drac-network": 3912, @@ -4041,6 +4150,7 @@ type ChainIdsBySlug = { "ozone-chain": 4000, "peperium-chain-testnet": 4001, "fantom-testnet": 4002, +"x1-fastnet": 4003, "bobaopera-testnet": 4051, "nahmii-3": 4061, "nahmii-3-testnet": 4062, @@ -4050,6 +4160,7 @@ type ChainIdsBySlug = { "aioz-network-testnet": 4102, "humans-ai-testnet": 4139, "tipboxcoin-testnet": 4141, +"crossfi-testnet": 4157, "phi-network-v1": 4181, "lukso-testnet": 4201, "nexi": 4242, @@ -4216,6 +4327,7 @@ type ChainIdsBySlug = { "sanr-chain": 11888, "polygon-supernet-arianee": 11891, "satoshichain": 12009, +"qi-m-11272": 12035, "singularity-zero-testnet": 12051, "singularity-zero": 12052, "brc-chain": 12123, @@ -4229,9 +4341,11 @@ type ChainIdsBySlug = { "credit-smart-chain-credit": 13308, "beam-testnet": 13337, "phoenix": 13381, +"immutable-zkevm-testnet": 13473, "susono": 13812, "sps-testnet": 14000, "humanode-testnet-5-israfel": 14853, +"immutable-zkevm-devnet": 15003, "qi-m-11271": 15535, "loopnetwork": 15551, "trust-evm-testnet": 15555, @@ -4244,6 +4358,7 @@ type ChainIdsBySlug = { "ivar-chain-testnet": 16888, "holesky": 17000, "redstone-holesky-testnet": 17001, +"qi1204i3": 17026, "g8chain": 17171, "palette-chain-testnet": 17180, "eos-evm-network": 17777, @@ -4253,12 +4368,14 @@ type ChainIdsBySlug = { "g8chain-testnet": 18181, "mxc-zkevm": 18686, "home-verse": 19011, +"st-12-07-v1": 19683, "btcix-network": 19845, "camelark": 20001, "callisto-testnet": 20729, "p12-chain": 20736, "cennznet-azalea": 21337, "omchain": 21816, +"bsl": 21912, "taycan": 22023, "airdao-testnet": 22040, "nautilus": 22222, @@ -4299,6 +4416,8 @@ type ChainIdsBySlug = { "j2o-taro": 35011, "q": 35441, "q-testnet": 35443, +"qr1129i1": 35730, +"qr1205s1": 36908, "connectormanager": 38400, "connectormanager-robin": 38401, "energi": 39797, @@ -4316,6 +4435,7 @@ type ChainIdsBySlug = { "avalanche-fuji": 43113, "avalanche": 43114, "boba-avax": 43288, +"zkfair-testnet": 43851, "frenchain": 44444, "celo-alfajores-testnet": 44787, "autobahn-network": 45000, @@ -4337,10 +4457,12 @@ type ChainIdsBySlug = { "rei-chain-testnet": 55556, "boba-bnb": 56288, "velo-labs": 56789, +"kk1223": 56914, "rollux-testnet": 57000, "sepolia-pgn-public-goods-network": 58008, "linea-testnet": 59140, "linea": 59144, +"genesys-code": 59971, "thinkium-testnet-chain-0": 60000, "thinkium-testnet-chain-1": 60001, "thinkium-testnet-chain-2": 60002, @@ -4360,10 +4482,12 @@ type ChainIdsBySlug = { "cosmic-chain": 67588, "dm2-verse": 68770, "condrieu": 69420, +"will-s-testnet": 69740, "thinkium-chain-0": 70000, "thinkium-chain-1": 70001, "thinkium-chain-2": 70002, "thinkium-chain-103": 70103, +"cohan-test3": 70466, "guapcoinx": 71111, "polyjuice-testnet": 71393, "godwoken-testnet-v1": 71401, @@ -4382,6 +4506,8 @@ type ChainIdsBySlug = { "conduit-subnet": 78432, "gold-smart-chain-testnet": 79879, "mumbai": 80001, +"qi-m-12051": 80182, +"nordek": 81041, "amana-testnet": 81341, "amana-mixnet": 81342, "amana-privnet": 81343, @@ -4400,6 +4526,7 @@ type ChainIdsBySlug = { "nautilus-proteus-testnet": 88002, "chiliz-scoville-testnet": 88880, "spicy-chain": 88882, +"proj-orc-testnet-alpha": 88883, "chiliz-chain": 88888, "beverly-hills": 90210, "nautilus-trition-chain": 91002, @@ -4453,7 +4580,9 @@ type ChainIdsBySlug = { "alaya-dev-testnet": 201030, "mythical-chain": 201804, "decimal-smart-chain-testnet": 202020, +"x1-devnet": 202212, "jellie": 202624, +"x1-network": 204005, "platon": 210425, "mas": 220315, "reapchain": 221230, @@ -4505,9 +4634,10 @@ type ChainIdsBySlug = { "scroll-pre-alpha-testnet": 534354, "shinarium-beta": 534849, "beaneco-smartchain": 535037, -"rethereum": 622277, +"hypra": 622277, "bear-network-chain": 641230, "all": 651940, +"ocash-testnet": 660868, "vision-vpioneer-test-chain": 666666, "hela-official-runtime-testnet": 666888, "bear-network-chain-testnet": 751230, @@ -4527,6 +4657,7 @@ type ChainIdsBySlug = { "eluvio-content-fabric": 955305, "ecrox-chain": 988207, "qr1120y1": 993535, +"tiltyard-subnet": 1127469, "zkatana": 1261120, "etho-protocol": 1313114, "xerom": 1313500, @@ -4561,6 +4692,7 @@ type ChainIdsBySlug = { "plian-testnet-subchain-1": 10067275, "soverun": 10101010, "sepolia": 11155111, +"op-sepolia-testnet": 11155420, "pepchain-churchill": 13371337, "anduschain": 14288640, "plian-testnet-main": 16658437, @@ -4577,7 +4709,7 @@ type ChainIdsBySlug = { "joys-digital": 35855456, "maistestsubnet": 43214913, "aquachain": 61717561, -"autonity-bakerloo-thames-testnet": 65010000, +"autonity-bakerloo-barada-testnet": 65010001, "autonity-piccadilly-thames-testnet": 65100000, "frame-testnet": 68840142, "t-e-a-m-blockchain": 88888888, diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 3f81a74e8be..d899c2fe150 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,53 @@ # thirdweb +## 0.13.25 + +### Patch Changes + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + - @thirdweb-dev/auth@4.1.17 + +## 0.13.24 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + - @thirdweb-dev/wallets@2.2.1 + - @thirdweb-dev/auth@4.1.16 + +## 0.13.23 + +### Patch Changes + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf), [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + - @thirdweb-dev/wallets@2.2.0 + - @thirdweb-dev/auth@4.1.15 + +## 0.13.22 + +### Patch Changes + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + - @thirdweb-dev/storage@2.0.7 + - @thirdweb-dev/wallets@2.1.11 + - @thirdweb-dev/auth@4.1.14 + +## 0.13.21 + +### Patch Changes + +- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]: + - @thirdweb-dev/wallets@2.1.10 + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + - @thirdweb-dev/storage@2.0.6 + - @thirdweb-dev/auth@4.1.13 + ## 0.13.20 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 37c4f867d3c..c6add2ff6ae 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "thirdweb", "main": "dist/cli/index.js", - "version": "0.13.20", + "version": "0.13.25", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli", "author": "thirdweb eng ", "license": "Apache-2.0", diff --git a/packages/merkletree/package.json b/packages/merkletree/package.json index ac2e3f6daa5..21b5f3fc9de 100644 --- a/packages/merkletree/package.json +++ b/packages/merkletree/package.json @@ -39,7 +39,14 @@ "@types/treeify": "^1.0.2", "benchmark": "^2.1.4", "eslint-config-thirdweb": "workspace:*", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "circomlibjs": "^0.1.7", + "crypto": "0.0.3", + "ethereum-cryptography": "^1.0.3", + "ethereumjs-util": "^7.0.9", + "keccak256": "^1.0.6", + "sha1": "^1.1.1", + "tape": "^4.9.2" }, "scripts": { "format": "prettier --write 'src/**/*'", @@ -48,7 +55,7 @@ "clean": "rm -rf dist/", "build": "tsc && preconstruct build", "push": "yalc push", - "test": "bun test", + "test": "bun test && node test/MerkleTree.js", "benchmark:aes-encrypt": "bun benchmark/aes-encrypt.ts", "benchmark:aes-decrypt": "bun benchmark/aes-decrypt.ts", "benchmark:sha256": "bun benchmark/sha256.ts", diff --git a/packages/merkletree/test/MerkleTree.js b/packages/merkletree/test/MerkleTree.js new file mode 100644 index 00000000000..a1c00ae770a --- /dev/null +++ b/packages/merkletree/test/MerkleTree.js @@ -0,0 +1,1627 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint camelcase: 0 */ +const test = require("tape"); +const keccak256 = require("keccak256"); +const { keccak256: ethjskeccak256 } = require("ethereumjs-util"); +const crypto = require("crypto"); +//** REMOVED - removed crypto-js support **// +// const CryptoJS = require("crypto-js"); +//** REMOVED - removed crypto-js support **// +// const SHA256 = require("crypto-js/sha256"); +//** REMOVED - removed crypto-js support **// +// const SHA3 = require("crypto-js/sha3"); +const sha1 = require("sha1"); +const { + keccak256: ethCryptoKeccak256, +} = require("ethereum-cryptography/keccak"); +const { buildPoseidon } = require("circomlibjs"); + +const { MerkleTree } = require("../"); + +const sha256 = (data) => crypto.createHash("sha256").update(data).digest(); + +test("sha256 with keccak256 leaves", (t) => { + t.plan(3); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.equal( + tree.getHexRoot(), + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + ); + t.deepEqual(tree.getHexLeaves(), [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); + t.deepEqual(tree.getHexLayers(), [ + [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ], + [ + "0x176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ], + ["0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae"], + ]); +}); + +test("sha256 with ethjs-keccak256 leaves", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map((v) => ethjskeccak256(Buffer.from(v))); + const tree = new MerkleTree(leaves, sha256); + t.equal( + tree.getHexRoot(), + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + ); +}); + +test("sha256 with keccak256 leaves with duplicate odd option", (t) => { + t.plan(3); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256, { duplicateOdd: true }); + + t.equal( + tree.getHexRoot(), + "0xbcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1", + ); + t.deepEqual(tree.getHexLeaves(), [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); + t.deepEqual(tree.getHexLayers(), [ + [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ], + [ + "0x176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1", + "0x43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358", + ], + ["0xbcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1"], + ]); +}); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - sha256", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map(keccak256); +// const tree = new MerkleTree(leaves, SHA256); +// const root = +// "311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +test("sha256 with sort pairs option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { sortPairs: true }); + const root = + "a30ba95a1a5dc397fe45ea20105363b08d682b864a28f4940419a29349a28325"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +// ** REMOVED - removed functionality ** // +// test("sha256 - static verify", (t) => { +// t.plan(2); + +// const leaves = ["a", "b", "c"].map(sha256); +// const tree = new MerkleTree(leaves, sha256); +// const leaf = sha256(Buffer.from("a")); +// const badLeaf = sha256(Buffer.from("o")); +// const proof = tree.getProof(leaf); +// const badProof = tree.getProof(badLeaf); +// const root = tree.getRoot(); + +// t.true(MerkleTree.verify(proof, leaf, root, sha256)); +// t.false(MerkleTree.verify(badProof, leaf, root, sha256)); +// }); + +test("sha256 verify with positional hex proof and no pairSort", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { sortPairs: false }); + + t.true( + tree.verify( + tree.getPositionalHexProof(leaves[1], 1), + leaves[1], + tree.getHexRoot(), + ), + ); +}); + +test("sha256 verify with non-hex proof and no pairSort", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { sortPairs: false }); + + t.true( + tree.verify(tree.getProof(leaves[1], 1), leaves[1], tree.getHexRoot()), + ); +}); + +test("sha256 verify with hex proof and pairSort", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { sortPairs: true }); + + t.true( + tree.verify(tree.getHexProof(leaves[1], 1), leaves[1], tree.getHexRoot()), + ); +}); + +test("keccak256 with sort leaves and sort pairs option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"].map((v) => + keccak256(Buffer.from(v)), + ); + const tree = new MerkleTree(leaves, keccak256, { + sortLeaves: true, + sortPairs: true, + }); + const root = + "60219f87561939610b484575e45c6e81156a53b86d7cd16640d930d14f21758e"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("keccak256 with sort option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"].map((v) => + keccak256(Buffer.from(v)), + ); + const tree = new MerkleTree(leaves, keccak256, { sort: true }); + const root = + "60219f87561939610b484575e45c6e81156a53b86d7cd16640d930d14f21758e"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("sha256 with sha256 leaves and sort pairs option and duplicate odd option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { + sortPairs: true, + duplicateOdd: true, + }); + const root = + "a5260b2a7ec31584e5d5689a5628c2b3d949e2397334fd71c107478e5f887eaf"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("sha256 with hash leaves option", (t) => { + t.plan(2); + + const expectedRoot = + "0x1f7379539707bcaea00564168d1d4d626b09b73f8a2a365234c62d763f854da2"; + + const leaves = ["a", "b", "c", "d", "e", "f"]; + const tree1 = new MerkleTree(leaves, sha256, { hashLeaves: true }); + t.equal(tree1.getHexRoot(), expectedRoot); + + const hashedLeaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree2 = new MerkleTree(hashedLeaves, sha256); + t.equal(tree2.getHexRoot(), expectedRoot); +}); + +test("sha256 with hash leaves option and duplicate odd option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"]; + const tree = new MerkleTree(leaves, sha256, { + hashLeaves: true, + duplicateOdd: true, + }); + const root = + "44205acec5156114821f1f71d87c72e0de395633cd1589def6d4444cc79f8103"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - sha256 with sha256 leaves", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map(SHA256); +// const tree = new MerkleTree(leaves, SHA256); +// const root = +// "7075152d03a5cd92104887b476862778ec0c87be5c2fa1c0a90f87c49fad6eff"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - sha256 with keccak256 leaves and duplicate odd option", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map(keccak256); +// const tree = new MerkleTree(leaves, SHA256, { duplicateOdd: true }); +// const root = +// "bcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - SHA256 with SHA256 leaves and duplicate odd option", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map(SHA256); +// const tree = new MerkleTree(leaves, SHA256, { duplicateOdd: true }); +// const root = +// "d31a37ef6ac14a2db1470c4316beb5592e6afd4465022339adafda76a18ffabe"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - SHA256 with SHA3 leaves", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map((v) => SHA3(v)); +// const tree = new MerkleTree(leaves, SHA256); + +// const root = +// "57e9ee696a291f8a51d224a6d64ba4a0693920a63f1e0329efe96c02a5f28849"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js - SHA256 with keccak256 leaves and duplicate odd option", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c"].map(keccak256); +// const tree = new MerkleTree(leaves, SHA256, { duplicateOdd: true }); +// const root = +// "bcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1"; + +// t.equal(tree.getRoot().toString("hex"), root); +// }); + +test("solidity keccak256", (t) => { + t.plan(20); + + const leaves = ["a", "b", "c"].map(keccak256); + + const a_hash = + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb"; + const b_hash = + "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510"; + const c_hash = + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2"; + + t.deepEqual( + leaves.map((v) => v.toString("hex")), + [a_hash, b_hash, c_hash], + ); + + const tree = new MerkleTree(leaves, keccak256); + + const layers = tree.getLayers().slice(1); // no leaves + + const layer_1 = keccak256(Buffer.concat([leaves[0], leaves[1]])).toString( + "hex", + ); + + t.equal(layers[0][0].toString("hex"), layer_1); + t.equal(layers[0][1].toString("hex"), c_hash); + + const root = Buffer.from( + "aff1208e69c9e8be9b584b07ebac4e48a1ee9d15ce3afe20b77a4d29e4175aa3", + "hex", + ); + t.equal(tree.getRoot().toString("hex"), root.toString("hex")); + + const proof_0 = tree.getProof(leaves[0]); + t.equal(proof_0.length, 2); + t.equal(proof_0[0].position, "right"); + t.equal(proof_0[0].data.toString("hex"), b_hash); + t.equal(proof_0[1].position, "right"); + t.equal(proof_0[1].data.toString("hex"), c_hash); + + t.true(tree.verify(proof_0, leaves[0], root)); + + const proof_1 = tree.getProof(leaves[1]); + t.equal(proof_1.length, 2); + t.equal(proof_1[0].position, "left"); + t.equal(proof_1[0].data.toString("hex"), a_hash); + t.equal(proof_1[1].position, "right"); + t.equal(proof_1[1].data.toString("hex"), c_hash); + + t.true(tree.verify(proof_1, leaves[1], root)); + + const proof_2 = tree.getProof(leaves[2]); + t.equal(proof_2.length, 1); + t.equal(proof_2[0].position, "left"); + t.equal(proof_2[0].data.toString("hex"), layer_1); + + t.true(tree.verify(proof_2, leaves[2], root)); +}); + +test("solidity keccak256 with duplicate odd option", (t) => { + t.plan(20); + + const leaves = ["a", "b", "c"].map(keccak256); + + const a_hash = + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb"; + const b_hash = + "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510"; + const c_hash = + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2"; + + t.deepEqual( + leaves.map((v) => v.toString("hex")), + [a_hash, b_hash, c_hash], + ); + + const tree = new MerkleTree(leaves, keccak256, { duplicateOdd: true }); + const layers = tree.getLayers().slice(1); // no leaves + const layer_1 = keccak256(Buffer.concat([leaves[0], leaves[1]])).toString( + "hex", + ); + const layer_2 = keccak256(Buffer.concat([leaves[2], leaves[2]])).toString( + "hex", + ); + t.equal(layers[0][0].toString("hex"), layer_1); + t.equal(layers[0][1].toString("hex"), layer_2); + + const root = Buffer.from( + "905b17edcf8b6fb1415b32cdbab3e02c2c93f80a345de80ea2bbf9feba9f5a55", + "hex", + ); + t.equal(tree.getRoot().toString("hex"), root.toString("hex")); + + const proof_0 = tree.getProof(leaves[0]); + t.equal(proof_0.length, 2); + t.equal(proof_0[0].position, "right"); + t.equal(proof_0[0].data.toString("hex"), b_hash); + t.equal(proof_0[1].position, "right"); + t.equal(proof_0[1].data.toString("hex"), layer_2); + + t.true(tree.verify(proof_0, leaves[0], root)); + + const proof_1 = tree.getProof(leaves[1]); + t.equal(proof_1.length, 2); + t.equal(proof_1[0].position, "left"); + t.equal(proof_1[0].data.toString("hex"), a_hash); + t.equal(proof_1[1].position, "right"); + t.equal(proof_1[1].data.toString("hex"), layer_2); + + t.true(tree.verify(proof_1, leaves[1], root)); + + const proof_2 = tree.getProof(leaves[2]); + t.equal(proof_2.length, 1); + t.equal(proof_2[0].position, "left"); + t.equal(proof_2[0].data.toString("hex"), layer_1); + + t.true(tree.verify(proof_2, layer_2, root)); +}); + +test("solidity keccak256 with duplicate leaves", (t) => { + t.plan(5); + + const leaves = ["a", "b", "a"].map(keccak256); + + const a_hash = + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb"; + const b_hash = + "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510"; + + const tree = new MerkleTree(leaves, keccak256); + + t.deepEqual( + leaves.map((v) => v.toString("hex")), + [a_hash, b_hash, a_hash], + ); + + const root = Buffer.from( + "b8912f7269068901f231a965adfefbc10f0eedcfa61852b103efd54dac7db3d7", + "hex", + ); + t.equal(tree.getRoot().toString("hex"), root.toString("hex")); + + const layer_1 = keccak256(Buffer.concat([leaves[0], leaves[1]])).toString( + "hex", + ); + + const proof_0 = tree.getProof(leaves[2], 2); + t.equal(proof_0.length, 1); + t.equal(proof_0[0].position, "left"); + t.equal(proof_0[0].data.toString("hex"), layer_1); +}); + +test("sha-256 with option.isBitcoinTree", (t) => { + t.plan(100); + + /* Derived from: + * http://www.righto.com/2014/02/bitcoin-mining-hard-way-algorithms.html + */ + const txHashes = [ + "00baf6626abc2df808da36a518c69f09b0d2ed0a79421ccfde4f559d2e42128b", + "91c5e9f288437262f218c60f986e8bc10fb35ab3b9f6de477ff0eb554da89dea", + "46685c94b82b84fa05b6a0f36de6ff46475520113d5cb8c6fb060e043a0dbc5c", + "ba7ed2544c78ad793ef5bb0ebe0b1c62e8eb9404691165ffcb08662d1733d7a8", + "b8dc1b7b7ed847c3595e7b02dbd7372aa221756b718c5f2943c75654faf48589", + "25074ef168a061fcc8663b4554a31b617683abc33b72d2e2834f9329c93f8214", + "0fb8e311bffffadc6dc4928d7da9e142951d3ba726c8bde2cf1489b62fb9ebc5", + "c67c79204e681c8bb453195db8ca7d61d4692f0098514ca198ccfd1b59dbcee3", + "bd27570a6cbd8ad026bfdb8909fdae9321788f0643dea195f39cd84a60a1901b", + "41a06e53ffc5108358ddcec05b029763d714ae9f33c5403735e8dee78027fe74", + "cc2696b44cb07612c316f24c07092956f7d8b6e0d48f758572e0d611d1da6fb9", + "8fc508772c60ace7bfeb3f5f3a507659285ea6f351ac0474a0a9710c7673d4fd", + "62fed508c095446d971580099f976428fc069f32e966a40a991953b798b28684", + "928eadbc39196b95147416eedf6f635dcff818916da65419904df8fde977d5db", + "b137e685df7c1dffe031fb966a0923bb5d0e56f381e730bc01c6d5244cfe47c1", + "b92207cee1f9e0bfbd797b05a738fab9de9c799b74f54f6b922f20bd5ec23dd6", + "29d6f37ada0481375b6903c6480a81f8deaf2dcdba03411ed9e8d3e5684d02dd", + "48158deb116e4fd0429fbbbae61e8e68cb6d0e0c4465ff9a6a990037f88c489c", + "be64ea86960864cc0a0236bbb11f232faf5b19ae6e2c85518628f5fae37ec1ca", + "081363552e9fff7461f1fc6663e1abd0fb2dd1c54931e177479a18c4c26260e8", + "eb87c25dd2b2537b1ff3dbabc420e422e2a801f1bededa6fa49ef7980feaef70", + "339e16fcc11deb61ccb548239270af43f5ad34c321416bada4b8d66467b1c697", + "4ad6417a3a04179482ed2e4b7251c396e38841c6fba8d2ce9543337ab7c93c02", + "c28a45cded020bf424b400ffc9cb6f2f85601934f18c34a4f78283247192056a", + "882037cc9e3ee6ddc2d3eba86b7ca163533b5d3cbb16eaa38696bb0a2ea1137e", + "179bb936305b46bb0a9df330f8701984c725a60e063ad5892fa97461570b5c04", + "9517c585d1578cb327b7988f38e1a15c663955ea288a2292b40d27f232fbb980", + "2c7e07d0cf42e5520bcbfe2f5ef63761a9ab9d7ccb00ea346195eae030f3b86f", + "534f631fc42ae2d309670e01c7a0890e4bfb65bae798522ca14df09c81b09734", + "104643385619adb848593eb668a8066d1f32650edf35e74b0fc3306cb6719448", + "87ac990808239c768182a752f4f71cd98558397072883c7e137efb49d22b9231", + "9b3e2f1c47d59a444e9b6dc725f0ac6baf160d22f3a9d399434e5e65b14eccb0", + "fbe123066ae5add633a542f151663db4eb5a7053e388faadb40240671ae1b09b", + "1dd07e92e20b3cb9208af040031f7cfc4efd46cc31ec27be20a1047965a42849", + "2709bb9ed27353c1fd76b9240cab7576a44de68945e256ad44b2cb8d849a8060", + "d0174db2c712573432a7869c1508f371f3a1058aeedddc1b53a7e04d7c56c725", + "b4a16f724cddb8f77ddf3d2146a12c4be13d503885eaba3518a03da005009f62", + "2aa706d75decbe57745e01d46f9f5d30a08dedaf3288cee14cc4948e3684e1d4", + "ee49c5f6a5129ccaf2abebbc1d6d07a402a600af6221476b89aafaa683ca95b7", + "bea1011c77874845e9b4c876ed2ceebd530d428dd4a564ad003d9211d40bb091", + "f1e88ffc2b1de2aa4827002f06943ce5468735f7433f960bf01e75885b9f832b", + "19247d017e002fb9143d1a89eb921222a94f8a3d0faaf2e05b0f594989edc4c4", + "13f714ff62ee7d26b6d69ca980c141ebc54e9f71d2697083fe6c5efc1b02bd0f", + "0c78cbb8246572f015fbdc53dc9798fa54d1119ec77c1f07ac310bcbcc40dbf8", + "4bcde0ef92a6d24a2be7be50ac5e5299d776df2e6229ba5d475c2491da94f255", + "0cfd7d1058502730cf0b2ffa880c78ef534651e06832b5d87c0d7eb84eac5b0c", + "3a168f794d6e0c614429ad874317cc4cd67a8177214880ff6ea1704d29228c2f", + "f9a555d817334397b402518d6fd959dc73d981ee7f5fe67969b63974ebbef127", + "24b52691f66eaed4ce391a473902e309018257c98b9f02aaa33b399c9e6f3168", + "a37b5e623dc26a180d9e2c9510d06885b014e86e533adb63ec40511e10b55046", + "9dbaeb485e51d9e25a5621dc46e0bc0aaf51fb26be5acc4e370b96f62c469b80", + "a6431d3d39f6c38c5df48405090752cab03bfdf5c77cf881b18a946807fba74a", + "faa77e309f125373acf19855dd496fffe2f74962e545420844557a3adc7ebc11", + "3523f52543ecfea2f78486dc91550fad0e6467d46d9d9c82ca63b2e0230bfa71", + "a0583e358e42d77d18d1fd0533ff0a65615fc3b3112061ef92f168a00bf640c1", + "42ae900888d5e5dde59c8e3d06e13db9e84ef05d27726d4b67fd00c50cd9406a", + "154940777d3ff78f592ef02790131a59263c36b4958bbc836f9a767ea1a9f178", + "6a0337de6ac75eecf748306e8ebc5bfe5c811a1481ae50f6956a9e7f26a679f5", + "c99530c2148e09688d0b88795625943371183bf1f5d56c7446c6ed51ea133589", + "626421dbe8ad6a0fd0d622d5dd3308a1cdc00b98575a41a91fe01a439e6f40bd", + "b2f3a559f605a158cc395126c3cf394a7e92a53b7514c75157e1dc43a6c7f93e", + "dffe06d1bea81f2a01c76786404bb867258f9e68013bf25454097ce935090738", + "0860159ec7a2a51ce107c182a988c40b4bc2057a734354a1219b6c65e72640ed", + "a405ff1bb51846b1867acc0b0da17f6f9616e592a0a7ff5ef3297c1ecfd60911", + "a7d451924263284765f6343bca8a21b79b89ebfe611c7355dd88e0ec1c29e232", + "41c758d08a4d3fe4d90645711589b832a2cd54dd25bd5b66e463e5d389a53aff", + "a05c1a93a521fa5dbc1790cfbb808893453a428a65f2c6b2d51249fbb12db309", + "90997920aa9786e10f513cfdd14e294feee6739cee1ab61b3fb1e3f42e7a915d", + "99fcb9cb62c20a3135484a70bd3f73983f8f3b7b26266dad34f3993958a7642c", + "e05f9a668b37e5f78bd3b9d047f29f92b33a87f11dd48390410006f858188b7b", + "56dbc65895f7992da4a6985e7edba4d1c00879f1b28442c644c8a07658ceab27", + "5e9004fe262b829563d0804656ba68b1de1690401f08a1915273230d8c902fc0", + "1ea9ed3717523c5e304b7a7ac8058a87fb4f3fed8c6004769f226c9bb67e79c5", + "f0f1a4c009b3f1b2729e89898e2f5c0fcdc312edea5df884a9c897cb90e4c566", + "b5bb4ddf04863e6a60f33cb96c20dac8175d3bae55f335781503143c97a50e43", + "f14cc97a20c6f627b4b78301352ae35463bc359362589cd178a06c0fa90850b7", + "628801c8f614015c0fa0ccb2768cccc3e7b9d41ceed06071ce2534d31f7236d6", + "3be1013c8f8da150e2195408093153b55b08b037fd92db8bb5e803f4c2538aae", + "c9e1f8777685f54ba65c4e02915fd649ee1edcbf9c77ddf584b943d27efb86c3", + "4274e92ed3bd02eb101baa5fb8ff7b96236830762d08273749fbb5166db8ab0b", + "aa84c955bea04c7cee8f5bbbec97d25930fcaca363eed1b8cad37b931556d3e3", + "d6a29c948677fb1f71aaf16debc3d071a4dd349458eb9e056dce3a000ff853da", + "ba84bdb3d78367ca365016ac4bff9269576eb010f874c2967af73e0de5638de0", + "1546c79951e3b541bc64d1957b565b7a2850fc87192c7b374aee6cfc69b9805e", + "f119227d492ebe27fe9aae321980802454dfa64b2691efbe796c5075d5b07f62", + "b8cf13d64818b32f96bbb585998b1bc9505f6a94055488e5a71fee9479c6f2a9", + "1aaf459705b6afef2d7b83e3f181f1af55be0813daf55edce104cc59abc28ed7", + "61ac185c8f520b5e3134953dc52ff292a40e1e96b088dab259558a9d240ec02f", + "2da96e3154d7ec2329f787b73cb8a436b92d64cf3cc28e920d073279ea73b5f8", + "1c4d72ce733b971b9ec4e24f37d733355f6f2ea635cc67ffb3e22748484df446", + "2a6f89769f3272ac8c7a36a42a57627eca6b260ab2c76d8046a27d44d4034893", + "f8d11df51a2cc113698ebf39a958fe81179d7d973d2044322771c0fe63f4d7c9", + "f2287f17a4fa232dca5715c24a92f7112402a8101b9a7b276fb8c8f617376b90", + "bb5ee510a4fda29cae30c97e7eee80569d3ec3598465f2d7e0674c395e0256e9", + "647ab8c84365620d60f2523505d14bd230b5e650c96dee48be47770063ee7461", + "34b06018fcc33ba6ebb01198d785b0629fbdc5d1948f688059158f053093f08b", + "ff58b258dab0d7f36a2908e6c75229ce308d34806289c912a1a5f39a5aa71f9f", + "232fc124803668a9f23b1c3bcb1134274303f5c0e1b0e27c9b6c7db59f0e2a4d", + "27a0797cc5b042ba4c11e72a9555d13a67f00161550b32ede0511718b22dbc2c", + ]; + + const leaves = txHashes.map((v) => Buffer.from(v, "hex")); + + const tree = new MerkleTree(leaves, sha256, { isBitcoinTree: true }); + const root = Buffer.from( + "871714dcbae6c8193a2bb9b2a69fe1c0440399f38d94b3a0f1b447275a29978a", + "hex", + ); + t.equal(tree.getRoot().toString("hex"), root.toString("hex")); + + for (let i = 0; i < leaves.length; i++) { + const proof = tree.getProof(leaves[i]); + t.true(tree.verify(proof, leaves[i], root), "proof verification for " + i); + } +}); + +test("keccak256 - hex strings", (t) => { + t.plan(1); + const leaves = ["a", "b", "c"].map(keccak256); + //** SWITCHED TO native sha256 (removed crypto-js support) **// + const tree = new MerkleTree(leaves, sha256); + const root = + "311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae"; + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("sha256 - no leaves", (t) => { + t.plan(1); + + const leaves = []; + const tree = new MerkleTree(leaves, sha256); + + const root = ""; + t.equal(tree.getRoot().toString("hex"), root); +}); + +test.skip("sha256 - 1,000,000 leaves", (t) => { + t.plan(1); + + const values = []; + for (let i = 0; i < 1e6; i++) { + values.push(`${i}`); + } + + const leaves = values.map(sha256); + const tree = new MerkleTree(leaves, sha256); + const root = + "101dd357df60384d254330fe118e3046871767c2748ebd62ce031c117df483da"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("sha256 getHexLeaves", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + t.deepEqual(tree.getHexLeaves(), [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); +}); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js SHA3 leaves SHA256", (t) => { +// t.plan(2); + +// const leaves = ["a", "b", "c", "d"].map(SHA3); +// const tree = new MerkleTree(leaves, SHA256); +// t.deepEqual(tree.getLeaves(), leaves.map(MerkleTree.bufferify)); +// const root = tree.getRoot(); + +// const verifications = leaves.map((leaf) => { +// const proof = tree.getProof(leaf); +// return tree.verify(proof, leaf, root); +// }); + +// t.true(verifications.every(Boolean)); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js SHA3 1 leaf SHA256", (t) => { +// t.plan(4); + +// const leaves = ["a"].map(SHA3); +// const tree = new MerkleTree(leaves, SHA256); +// t.deepEqual(tree.getLeaves(), leaves.map(MerkleTree.bufferify)); +// const root = tree.getRoot(); + +// const leaf = leaves[0]; +// const proof = tree.getProof(leaf); +// t.equal(proof.length, 0); +// t.equal(MerkleTree.bufferify(leaf).toString("hex"), root.toString("hex")); +// t.true(tree.verify(proof, leaf, root)); +// }); + +//** REMOVED - removed crypto-js support **// +// test("crypto-js bufferify", (t) => { +// t.plan(1); + +// const leaves = ["a", "b", "c", "d"].map(SHA3); + +// const bufferifyCryptoJS = (v) => +// Buffer.from(v.toString(CryptoJS.enc.Hex), "hex"); + +// t.deepEqual(leaves.map(MerkleTree.bufferify), leaves.map(bufferifyCryptoJS)); +// }); + +test("bufferify", (t) => { + t.plan(1); + + t.deepEqual(MerkleTree.bufferify("0x1234"), Buffer.from("1234", "hex")); +}); + +test("isHexString", (t) => { + t.plan(1); + + t.deepEqual(MerkleTree.isHexString("0x1234"), true); +}); + +test("sha1", (t) => { + t.plan(2); + + const leaves = [ + "d89f84d948796605a413e196f40bce1d6294175d", + "32f04c7f572bf75a266268c6f4d8c92731dc3b7f", + "b80b52d80f5fe940ac2c987044bc439e4218ac94", + "1553c75a1d637961827f4904a0955e57915d8310", + ]; + + const tree = new MerkleTree(leaves, sha1, { + sortLeaves: true, + sortPairs: true, + }); + + const root = tree.getHexRoot(); + const leaf = "d89f84d948796605a413e196f40bce1d6294175d"; + const proof = tree.getHexProof(leaf); + + t.deepEqual(proof, [ + "0xb80b52d80f5fe940ac2c987044bc439e4218ac94", + "0x59f544ee5de8d761b124ccd4e1285d3b02a2a539", + ]); + + t.true(tree.verify(proof, leaf, root)); +}); + +test("sha56 getHexLayers", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + const layers = tree.getHexLayers(); + + t.deepEqual(layers, [ + [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ], + [ + "0x176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ], + ["0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae"], + ]); +}); + +test("getLayersAsObject", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + const obj = tree.getLayersAsObject(); + + t.deepEqual(obj, { + "311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae": { + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2": { + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2": + null, + }, + "176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1": { + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb": + null, + b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510: null, + }, + }, + }); +}); + +test("getLayersAsObject with duplicate odd option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256, { duplicateOdd: true }); + const obj = tree.getLayersAsObject(); + + t.deepEqual(obj, { + bcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1: { + "176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1": { + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb": + null, + b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510: null, + }, + "43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358": { + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2": + null, + }, + }, + }); +}); + +test("sha256 getHexLayersFlat", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + const layers = tree.getHexLayersFlat(); + t.deepEqual(layers, [ + "0x00", + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + "0x176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); +}); + +test("print", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.equal( + tree.toString(), + `└─ 311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae + ├─ 176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1 + │ ├─ 3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb + │ └─ b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510 + └─ 0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2 + └─ 0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2 +`, + ); +}); + +test("print with duplicate odd option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256, { duplicateOdd: true }); + + t.equal( + tree.toString(), + `└─ bcdd0f60308db788712205115fe4273bfda49fa0925611fee765a63df9ab96a1 + ├─ 176f0f307632fdd5831875eb709e2f68d770b102262998b214ddeb3f04164ae1 + │ ├─ 3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb + │ └─ b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510 + └─ 43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358 + └─ 0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2 +`, + ); +}); + +test("sha256 getMultiProof + verifyMultiProof", (t) => { + t.plan(3); + + const leaves = Array(16) + .fill(0) + .map((x, i) => { + const b = Buffer.alloc(32); + b.writeUIntLE(i, 31, 1); + return b; + }); + + const tree = new MerkleTree(leaves, sha256); + + const root = tree.getHexRoot(); + t.equal( + root, + "0xc1ebc5b83154907160d73863bdae7eb86fe1888495a83cb8daadb1603b8aeaf5", + ); + + const n = 100; + const proofIndices = Array(16) + .fill(0) + .map((x, j) => j) + .filter((j) => (n >> j) % 2 === 1); + + const proof = tree.getMultiProof(proofIndices); + + t.deepEqual( + proof.map((v) => v.toString("hex")), + [ + "0000000000000000000000000000000000000000000000000000000000000007", + "0000000000000000000000000000000000000000000000000000000000000004", + "0000000000000000000000000000000000000000000000000000000000000003", + "90f4b39548df55ad6187a1d20d731ecee78c545b94afd16f42ef7592d99cd365", + "6b41dc65d0df2bb4b8c2f1fe48e85b7ba8f9b876113ec410fe612bae61a19eaf", + ], + ); + + const proofLeaves = proofIndices.map((i) => leaves[i]); + t.true( + tree.verifyMultiProof( + root, + proofIndices, + proofLeaves, + leaves.length, + proof, + ), + ); +}); + +test("keccak256 verifyMultiProofWithFlags", (t) => { + t.plan(4); + + const leaves = ["a", "b", "c", "d", "e", "f"] + .map(keccak256) + .sort(Buffer.compare); + + const tree = new MerkleTree(leaves, keccak256, { sort: true }); + const root = tree.getHexRoot(); + t.equal( + root, + "0x1b404f199ea828ec5771fb30139c222d8417a82175fefad5cd42bc3a189bd8d5", + ); + + const proofLeaves = [keccak256("b"), keccak256("d"), keccak256("f")].sort( + Buffer.compare, + ); + t.deepEqual( + proofLeaves.map((v) => v.toString("hex")), + [ + "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "d1e8aeb79500496ef3dc2e57ba746a8315d048b7a664a2bf948db4fa91960483", + "f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3", + ], + ); + + const proof = tree.getMultiProof(proofLeaves); + t.deepEqual( + proof.map((v) => v.toString("hex")), + [ + "a8982c89d80987fb9a510e25981ee9170206be21af3c8e0eb312ef1d3382e761", + "7dea550f679f3caab547cbbc5ee1a4c978c8c039b572ba00af1baa6481b88360", + ], + ); + const proofFlags = tree.getProofFlags(proofLeaves, proof); + t.true(tree.verifyMultiProofWithFlags(root, proofLeaves, proof, proofFlags)); +}); + +test("keccak256 getMultiProof uneven tree", (t) => { + t.plan(3); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256); + const root = tree.getRoot(); + t.equal( + root.toString("hex"), + "1f7379539707bcaea00564168d1d4d626b09b73f8a2a365234c62d763f854da2", + ); + const indicesToProve = [3, 4]; + const leavesToProve = indicesToProve.map((index) => leaves[index]); + const proof = tree.getMultiProof(indicesToProve); + t.deepEqual( + proof.map((v) => v.toString("hex")), + [ + "2e7d2c03a9507ae265ecf5b5356885a53393a2029d241394997265a1a25aefc6", + "252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111", + "e5a01fee14e0ed5c48714f22180f25ad8365b53f9779f79dc4a3d7e93963f94a", + ], + ); + t.true( + tree.verifyMultiProof( + root, + indicesToProve, + leavesToProve, + leaves.length, + proof, + ), + ); +}); + +test("sha256 getMultiProof with pairs sorted", (t) => { + t.plan(1); + + const leaves = Array(16) + .fill(0) + .map((x, i) => { + const b = Buffer.alloc(32); + b.writeUIntLE(i, 31, 1); + return b; + }); + + const tree = new MerkleTree(leaves, sha256, { sortPairs: true }); + const root = tree.getHexRoot(); + + const n = 100; + const proofIndices = Array(16) + .fill(0) + .map((x, j) => j) + .filter((j) => (n >> j) % 2 === 1); + + const proof = tree.getMultiProof(proofIndices); + const proofLeaves = proofIndices.map((i) => leaves[i]); + + t.true( + tree.verifyMultiProof( + root, + proofIndices, + proofLeaves, + leaves.length, + proof, + ), + ); +}); + +test("sha256 getMultiProof using tree array", (t) => { + t.plan(5); + + const leaves = Array(16) + .fill(0) + .map((x, i) => { + const b = Buffer.alloc(32); + b.writeUIntLE(i, 31, 1); + return b; + }); + + const tree = new MerkleTree(leaves, sha256); + + const root = tree.getHexRoot(); + t.equal( + root, + "0xc1ebc5b83154907160d73863bdae7eb86fe1888495a83cb8daadb1603b8aeaf5", + ); + + const treeFlat = tree.getLayersFlat(); + + t.deepEqual( + treeFlat.map((v) => v.toString("hex")), + [ + "00", + "c1ebc5b83154907160d73863bdae7eb86fe1888495a83cb8daadb1603b8aeaf5", + "32e0fe0539aeca5782542f7232d32185eebec2e6dc258177456dcdebbbf18f8b", + "6b41dc65d0df2bb4b8c2f1fe48e85b7ba8f9b876113ec410fe612bae61a19eaf", + "d1d79b01cacccaa40e6a3825db8ff96f38858092ea71689ce31dc6df3cf31df2", + "564ad5882547f199bbe82f40f4e5ddbd3836859c2e5caf3ff5b0989caf614af0", + "5ef82769b7a6ea72894663fd3ed0736e7084beb596edeac229d4ae598d19aa2b", + "446c09a38396a1f51846548cc4a87bddd73bdcce9cf86c65f9ac6c153a92a562", + "90f4b39548df55ad6187a1d20d731ecee78c545b94afd16f42ef7592d99cd365", + "a774c351cf3882b36b2c541586b0b59c6dfd119ae831ef3c6b2e269f7a6be220", + "b023893dc819559da606f81778f566532801f428570db5fd3d3088491bb292c2", + "277752261a13c9c81c37ea894efe5dc3af8b7ffecbedce75d0ec09862e74a2cb", + "4c1f763d4f27669f41e511f15268e6396a66f7750c6128d68210a1dfbeb0cbc3", + "856b7aa12bb3a7fb591ac8cfb8051bb89c4b57cb7faf852fdc5d226076423d04", + "719cf2e4468492fde20372b704eca4a67397bba60d7513bb08f199887636027f", + "cec448f4862209fa531a43a65ec850a6327f02f518ef55f4d347510a5cf5d1cf", + "0000000000000000000000000000000000000000000000000000000000000000", + "0000000000000000000000000000000000000000000000000000000000000001", + "0000000000000000000000000000000000000000000000000000000000000002", + "0000000000000000000000000000000000000000000000000000000000000003", + "0000000000000000000000000000000000000000000000000000000000000004", + "0000000000000000000000000000000000000000000000000000000000000005", + "0000000000000000000000000000000000000000000000000000000000000006", + "0000000000000000000000000000000000000000000000000000000000000007", + "0000000000000000000000000000000000000000000000000000000000000008", + "0000000000000000000000000000000000000000000000000000000000000009", + "000000000000000000000000000000000000000000000000000000000000000a", + "000000000000000000000000000000000000000000000000000000000000000b", + "000000000000000000000000000000000000000000000000000000000000000c", + "000000000000000000000000000000000000000000000000000000000000000d", + "000000000000000000000000000000000000000000000000000000000000000e", + "000000000000000000000000000000000000000000000000000000000000000f", + ], + ); + + const proofIndices = [2, 5, 6]; + const proof = tree.getMultiProof(treeFlat, proofIndices); + + t.deepEqual( + proof.map((v) => v.toString("hex")), + [ + "0000000000000000000000000000000000000000000000000000000000000007", + "0000000000000000000000000000000000000000000000000000000000000004", + "0000000000000000000000000000000000000000000000000000000000000003", + "90f4b39548df55ad6187a1d20d731ecee78c545b94afd16f42ef7592d99cd365", + "6b41dc65d0df2bb4b8c2f1fe48e85b7ba8f9b876113ec410fe612bae61a19eaf", + ], + ); + + const depth = tree.getDepth(); + t.equal(depth, Math.ceil(Math.log2(treeFlat.length / 2))); + + const treeRoot = treeFlat[1]; + const proofLeaves = proofIndices.map((i) => leaves[i]); + t.true( + tree.verifyMultiProof( + treeRoot, + proofIndices, + proofLeaves, + leaves.length, + proof, + ), + ); +}); + +test("sha256 getMultiProof", (t) => { + t.plan(3); + + const leaves = Array(16) + .fill(0) + .map((x, i) => { + const b = Buffer.alloc(32); + b.writeUIntLE(i, 31, 1); + return b; + }); + + const tree = new MerkleTree(leaves, sha256, { + sortPairs: true, + singleOdd: true, + }); + + const root = tree.getHexRoot(); + t.equal( + root, + "0xc336787ec1a678cbbb3391bd0146e0c11e62dac39f84fe9a404a882094c00273", + ); + + const treeFlat = tree.getLayersFlat(); + + const proofIndices = [0, 1]; + const proof = tree.getMultiProof(treeFlat, proofIndices); + const proofLeaves = proofIndices.map((i) => leaves[i]); + + t.deepEqual( + proof.map((v) => v.toString("hex")), + [ + "a774c351cf3882b36b2c541586b0b59c6dfd119ae831ef3c6b2e269f7a6be220", + "de44f8fbe261b8ed52c606670f9c73e428a997908df7452806d6123829d50adc", + "44f76d663f391971ba8bd22469061c70aa63c176bc29b651336db7587b6f5a6c", + ], + ); + + const proofFlags = tree.getProofFlags(proofLeaves, proof); + t.deepEqual(proofFlags, [true, false, false, false]); +}); + +test("sha256 getProofFlag with indices", (t) => { + t.plan(3); + + const leaves = ["a", "b", "c", "d"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { sortPairs: true }); + const root = tree.getHexRoot(); + t.equal( + root, + "0x4c6aae040ffada3d02598207b8485fcbe161c03f4cb3f660e4d341e7496ff3b2", + ); + + const proofIndices = [2, 1]; + const proof = tree.getMultiProof(proofIndices); + const proofFlags = tree.getProofFlags(proofIndices, proof); + t.deepEqual(proofFlags, [false, false, true]); + t.ok( + tree.verifyMultiProofWithFlags( + root, + proofIndices.map((i) => leaves[i]), + proof, + proofFlags, + ), + ); +}); + +test("sha256 getMultiProof - statusim", (t) => { + t.plan(5); + + const elements = ["a", "b", "c", "d", "e", "f"].map((v) => Buffer.from(v)); + + const tree = new MerkleTree(elements, keccak256, { + hashLeaves: true, + sortLeaves: true, + sortPairs: true, + }); + + t.equal( + tree.getHexRoot(), + "0x1b404f199ea828ec5771fb30139c222d8417a82175fefad5cd42bc3a189bd8d5", + ); + t.deepEqual(tree.getHexLeaves(), [ + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xa8982c89d80987fb9a510e25981ee9170206be21af3c8e0eb312ef1d3382e761", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0xd1e8aeb79500496ef3dc2e57ba746a8315d048b7a664a2bf948db4fa91960483", + "0xf1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3", + ]); + + const leaves = tree.getLeaves(["d", "a"].map((v) => Buffer.from(v))); + const proof = tree.getMultiProof(leaves); + const proofFlags = tree.getProofFlags(leaves, proof); + + t.deepEqual( + leaves.map((v) => v.toString("hex")), + [ + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "f1918e8562236eb17adc8502332f4c9c82bc14e19bfc0aa10ab674ff75b3d2f3", + ], + ); + t.deepEqual(tree.getHexMultiProof(leaves), [ + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + "0xd1e8aeb79500496ef3dc2e57ba746a8315d048b7a664a2bf948db4fa91960483", + "0x434d51cfeb80272378f4c3a8fd2824561c2cad9fce556ea600d46f20550976a6", + ]); + t.deepEqual(proofFlags, [false, false, false, true]); +}); + +test("marshal leaves", (t) => { + t.plan(5); + + const leaves = ["a", "b", "c"].map(keccak256); + const jsonLeaves = MerkleTree.marshalLeaves(leaves); + t.equal(typeof jsonLeaves, "string"); + + const parsed = JSON.parse(jsonLeaves); + t.equal(parsed.length, 3); + t.equal( + parsed[0], + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + ); + t.equal( + parsed[1], + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + ); + t.equal( + parsed[2], + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ); +}); + +test("unmarshal leaves", (t) => { + t.plan(4); + + const json = `[ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2" + ]`; + + const leaves = MerkleTree.unmarshalLeaves(json); + t.equal(leaves.length, 3); + t.equal( + leaves[0].toString("hex"), + "3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + ); + t.equal( + leaves[1].toString("hex"), + "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + ); + t.equal( + leaves[2].toString("hex"), + "0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ); +}); + +//** REMOVED functinality **// +// test("marshal proof", (t) => { +// t.plan(5); + +// const leaves = ["a", "b", "c"].map(keccak256); +// const tree = new MerkleTree(leaves, sha256, { duplicateOdd: true }); +// const proof = tree.getProof(leaves[0]); + +// const jsonProof = MerkleTree.marshalProof(proof); +// t.equal(typeof jsonProof, "string"); + +// const parsed = JSON.parse(jsonProof); +// t.equal(parsed.length, 2); +// t.equal( +// parsed[0].data, +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", +// ); +// t.equal( +// parsed[1].data, +// "0x43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358", +// ); + +// t.true(tree.verify(parsed, leaves[0], tree.getRoot())); +// }); + +//** REMOVED functinality **// +// test("unmarshal proof", (t) => { +// t.plan(3); + +// const json = `[ +// { +// "position": "right", +// "data": "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510" +// }, +// { +// "position": "right", +// "data": "0x43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358" +// } +// ]`; + +// const proof = MerkleTree.unmarshalProof(json); + +// t.equal(proof.length, 2); +// t.equal( +// proof[0].data.toString("hex"), +// "b5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", +// ); +// t.equal( +// proof[1].data.toString("hex"), +// "43e061172b1177f25d0f156b2d2ed11728006fade8e167ff3d1b9dbc979a3358", +// ); +// }); + +//** REMOVED functinality **// +// test("marshal tree", (t) => { +// t.plan(7); + +// const leaves = ["a", "b", "c"].map(keccak256); +// const tree = new MerkleTree(leaves, keccak256, { sort: true }); +// const jsonTree = MerkleTree.marshalTree(tree); +// t.equal(typeof jsonTree, "string"); + +// const parsed = JSON.parse(jsonTree); +// t.deepEqual(parsed.options, { +// complete: false, +// isBitcoinTree: false, +// hashLeaves: false, +// sortLeaves: true, +// sortPairs: true, +// sort: true, +// fillDefaultHash: null, +// duplicateOdd: false, +// }); +// t.equal( +// parsed.root, +// "0xc3b537cc8a2c6dcb3657718e1f3505ff751ff8c2eba2a70460df2cbee2b1413a", +// ); +// t.equal(parsed.leaves.length, 3); +// t.deepEqual(parsed.leaves, [ +// "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", +// "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", +// ]); +// t.equal(parsed.layers.length, 3); +// t.deepEqual(parsed.layers, [ +// [ +// "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", +// "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", +// ], +// [ +// "0x7dea550f679f3caab547cbbc5ee1a4c978c8c039b572ba00af1baa6481b88360", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", +// ], +// ["0xc3b537cc8a2c6dcb3657718e1f3505ff751ff8c2eba2a70460df2cbee2b1413a"], +// ]); +// }); + +//** REMOVED functinality **// +// test("unmarshal tree", (t) => { +// t.plan(4); + +// const json = `{ +// "options": { +// "complete": false, +// "isBitcoinTree": false, +// "hashLeaves": false, +// "sortLeaves": true, +// "sortPairs": true, +// "sort": true, +// "fillDefaultHash": null, +// "duplicateOdd": false +// }, +// "root": "0xc3b537cc8a2c6dcb3657718e1f3505ff751ff8c2eba2a70460df2cbee2b1413a", +// "layers": [ +// [ +// "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", +// "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510" +// ], +// [ +// "0x7dea550f679f3caab547cbbc5ee1a4c978c8c039b572ba00af1baa6481b88360", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510" +// ], +// [ +// "0xc3b537cc8a2c6dcb3657718e1f3505ff751ff8c2eba2a70460df2cbee2b1413a" +// ] +// ], +// "leaves": [ +// "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", +// "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", +// "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510" +// ] +// }`; + +// const parsed = JSON.parse(json); +// const tree = MerkleTree.unmarshalTree(json, keccak256); + +// t.equal(tree.getHexRoot(), parsed.root); +// t.deepEqual(tree.getOptions(), parsed.options); +// t.deepEqual(tree.getHexLeaves(), parsed.leaves); +// t.deepEqual(tree.getHexLayers(), parsed.layers); +// }); + +test("getOptions", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f"].map(sha256); + const tree = new MerkleTree(leaves, sha256, { + sortPairs: true, + sortLeaves: true, + }); + + t.deepEqual(tree.getOptions(), { + complete: false, + isBitcoinTree: false, + hashLeaves: false, + sortLeaves: true, + sortPairs: true, + sort: false, + fillDefaultHash: null, + duplicateOdd: false, + }); +}); + +test("fillDefaultHashes", (t) => { + t.plan(1); + + const leaves = [...Array(9)].map((x, i) => { + return keccak256(Buffer.from([i])); + }); + + const tree = new MerkleTree(leaves, keccak256, { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + fillDefaultHash: (idx, hashFn) => { + return keccak256(Buffer.alloc(32)); + }, + }); + + t.equal( + tree.getHexRoot(), + "0x11f470d712bb3a84f0b01cb7c73493ec7d06eda480f567c99b9a6dc773679a72", + ); +}); + +test("getLeafIndex", (t) => { + t.plan(5); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.equal( + tree.getHexRoot(), + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + ); + t.equal(tree.getLeafIndex(leaves[1]), 1); + t.equal(tree.getLeafIndex(keccak256(Buffer.from("b"))), 1); + t.equal(tree.getLeafIndex(leaves[2]), 2); + t.equal(tree.getLeafIndex(Buffer.from("invalid")), -1); +}); + +test("getleafCount", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.equal(tree.getLeafCount(), 3); +}); + +test("getleaf", (t) => { + t.plan(5); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.deepEqual(tree.getLeaf(-1), Buffer.from([])); + t.deepEqual(tree.getLeaf(0), leaves[0]); + t.deepEqual(tree.getLeaf(1), leaves[1]); + t.deepEqual(tree.getLeaf(2), leaves[2]); + t.deepEqual(tree.getLeaf(3), Buffer.from([])); +}); + +test("addLeaf", (t) => { + t.plan(2); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree([], sha256); + tree.addLeaf(leaves[0]); + tree.addLeaf(leaves[1]); + tree.addLeaf(leaves[2]); + + t.equal( + tree.getHexRoot(), + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + ); + t.deepEqual(tree.getHexLeaves(), [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); +}); + +test("addLeaves", (t) => { + t.plan(3); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree([], sha256); + tree.addLeaves(leaves); + + t.equal( + tree.getHexRoot(), + "0x311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae", + ); + t.deepEqual(tree.getHexLeaves(), [ + "0x3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1cb", + "0xb5553de315e0edf504d9150af82dafa5c4667fa618ed0a6f19c69b41166c5510", + "0x0b42b6393c1f53060fe3ddbfcd7aadcca894465a5a438f69c87d790b2299b9b2", + ]); + + const moreLeaves = ["d", "e", "f"].map(keccak256); + tree.addLeaves(moreLeaves); + t.equal( + tree.getHexRoot(), + "0xb9a721d82428976e0d500f97646bf273ec1dd9c2104b9328873a94fc3897aec6", + ); +}); + +test("resetTree", (t) => { + t.plan(2); + + const leaves = ["a", "b", "c"].map(keccak256); + const tree = new MerkleTree(leaves, sha256); + + t.equal(tree.getLeafCount(), 3); + + tree.resetTree(); + + t.equal(tree.getLeafCount(), 0); +}); + +test("ethereum-cryptography/keccak256", (t) => { + t.plan(2); + + const expectedRoot = + "0xaff1208e69c9e8be9b584b07ebac4e48a1ee9d15ce3afe20b77a4d29e4175aa3"; + + const leaves = ["a", "b", "c"].map((v) => Buffer.from(v)); + const hashedLeaves = leaves.map(ethCryptoKeccak256); + const tree1 = new MerkleTree(hashedLeaves, ethCryptoKeccak256); + t.equal(tree1.getHexRoot(), expectedRoot); + + const tree2 = new MerkleTree(leaves, ethCryptoKeccak256, { + hashLeaves: true, + }); + t.equal(tree2.getHexRoot(), expectedRoot); +}); + +test("keccak256 with complete option", (t) => { + t.plan(1); + + const leaves = ["a", "b", "c", "d", "e", "f", "g", "h", "i"].map((v) => + keccak256(Buffer.from(v)), + ); + const tree = new MerkleTree(leaves, keccak256, { complete: true }); + + const root = + "581ddb9a48c5ec60fd5a0023d4673e2b33c256f8886342bef35a8eebeda51b44"; + + t.equal(tree.getRoot().toString("hex"), root); +}); + +test("complete option with incompatible options", (t) => { + t.plan(2); + + const leaves = ["a", "b", "c"].map((v) => keccak256(Buffer.from(v))); + t.throws( + () => + new MerkleTree(leaves, keccak256, { + complete: true, + isBitcoinTree: true, + }), + /option "complete" is incompatible with "isBitcoinTree"/, + ); + t.throws( + () => + new MerkleTree(leaves, keccak256, { complete: true, duplicateOdd: true }), + /option "complete" is incompatible with "duplicateOdd"/, + ); +}); + +test("simple bad proof", (t) => { + t.plan(2); + + const leaves = ["d", "e", "f"]; + //** CHANGE - have to explicitly pass hash fn **// + const tree = new MerkleTree(leaves, sha256); + + const proof = tree.getHexProof(leaves[0]); + t.equal(proof.length, 1); + t.equal( + proof[0], + "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + ); +}); + +test.skip("1M leaves keccak256", (t) => { + t.plan(3); + + const leaves = []; + const max = 1000000; + for (let i = 0; i < max; i++) { + leaves.push(keccak256(`${i}`)); + } + + console.time("1MLeavesConstructor"); + const tree = new MerkleTree(leaves, keccak256, { sort: true }); + console.timeEnd("1MLeavesConstructor"); + + console.time("1MLeavesProof"); + const proof = tree.getHexProof(keccak256(`${max - 1}`)); + console.timeEnd("1MLeavesProof"); + t.equal(tree.getLeafCount(), max); + t.true(tree.verify(proof, keccak256(`${max - 1}`), tree.getRoot())); + t.false(tree.verify(proof, keccak256(`${max + 1}`), tree.getRoot())); +}); + +test("poseidon hash", async (t) => { + t.plan(4); + + const poseidon = await buildPoseidon(); + const poseidonHash = (inputs) => { + const hash = poseidon(inputs.map(MerkleTree.bigNumberify)); + const bn = MerkleTree.bigNumberify(poseidon.F.toString(hash)); + return MerkleTree.bufferify(bn); + }; + + const result1 = poseidonHash([1, 2]); + t.equal( + result1.toString("hex"), + "115cc0f5e7d690413df64c6b9662e9cf2a3617f2743245519e19607a4417189a", + ); + + const result2 = poseidonHash([1, 2, 3, 4]); + t.equal( + result2.toString("hex"), + "299c867db6c1fdd79dcefa40e4510b9837e60ebb1ce0663dbaa525df65250465", + ); + + const leaves = [1, 2, 3, 4].map((x) => poseidonHash([x])); + const tree = new MerkleTree(leaves, poseidonHash, { + concatenator: (hashes) => hashes, + }); + t.equal( + tree.getHexRoot(), + "0xd24e045226875e22b37ce607ea2af7a9fbb137ee128caa0ce3663615350245", + ); + + const proof = tree.getProof(leaves[2]); + t.true(tree.verify(proof, leaves[2], tree.getHexRoot())); +}); diff --git a/packages/react-core/CHANGELOG.md b/packages/react-core/CHANGELOG.md index 3292d1a7dbe..c199bba0ee7 100644 --- a/packages/react-core/CHANGELOG.md +++ b/packages/react-core/CHANGELOG.md @@ -1,5 +1,87 @@ # @thirdweb-dev/react-core +## 4.1.15 + +### Patch Changes + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + - @thirdweb-dev/auth@4.1.17 + +## 4.1.14 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + - @thirdweb-dev/wallets@2.2.1 + - @thirdweb-dev/auth@4.1.16 + +## 4.1.13 + +### Patch Changes + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf), [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + - @thirdweb-dev/wallets@2.2.0 + - @thirdweb-dev/auth@4.1.15 + +## 4.1.12 + +### Patch Changes + +- [#2043](https://github.com/thirdweb-dev/js/pull/2043) [`34546c24`](https://github.com/thirdweb-dev/js/commit/34546c24c74f4e9e1f5e94567ebe1017ad63aea5) Thanks [@MananTank](https://github.com/MananTank)! - when user clicks on "Switch to personal wallet" when they are connected to smart wallet and reloads the page, auto-connect to smart wallet + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +- [#1938](https://github.com/thirdweb-dev/js/pull/1938) [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add OneKey wallet + +- [#2042](https://github.com/thirdweb-dev/js/pull/2042) [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and Type exports + +- [#2039](https://github.com/thirdweb-dev/js/pull/2039) [`cd87be4a`](https://github.com/thirdweb-dev/js/commit/cd87be4a24a9a3a552fbc4f33da6fcb08b7da88b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Remove barrel files + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + - @thirdweb-dev/storage@2.0.7 + - @thirdweb-dev/wallets@2.1.11 + - @thirdweb-dev/auth@4.1.14 + +## 4.1.11 + +### Patch Changes + +- [#2007](https://github.com/thirdweb-dev/js/pull/2007) [`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Get the native token balance of a wallet address on the `activeChain` network set in the `ThirdwebProvider` + + ```ts + const balanceQuery = useBalanceForAddress(walletAddress); + + console.log(balanceQuery.data); + ``` + +- [#1926](https://github.com/thirdweb-dev/js/pull/1926) [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Rabby browser extension + +- [#2001](https://github.com/thirdweb-dev/js/pull/2001) [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6) Thanks [@iketw](https://github.com/iketw)! - Don't disconnect wallet if connecting + +- [#2016](https://github.com/thirdweb-dev/js/pull/2016) [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8) Thanks [@iketw](https://github.com/iketw)! - Share WalletConnectHandler between React and RN to support wallets as receivers + +- [#1997](https://github.com/thirdweb-dev/js/pull/1997) [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819) Thanks [@MananTank](https://github.com/MananTank)! - - Fixes issue #1708 + + - Fixes smart wallet icon shown even after clicking on "Switch to Personal wallet" in ConnectWallet dropdown + +- [#1987](https://github.com/thirdweb-dev/js/pull/1987) [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and type exports + +- [#1928](https://github.com/thirdweb-dev/js/pull/1928) [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Crypto.com Defi wallet + +- [#2015](https://github.com/thirdweb-dev/js/pull/2015) [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314) Thanks [@MananTank](https://github.com/MananTank)! - Fix auto-connecting a personal wallet for smart/safe wallet + +- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]: + - @thirdweb-dev/wallets@2.1.10 + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + - @thirdweb-dev/storage@2.0.6 + - @thirdweb-dev/auth@4.1.13 + ## 4.1.10 ### Patch Changes diff --git a/packages/react-core/package.json b/packages/react-core/package.json index 97e3782bc81..f40bdf0d052 100644 --- a/packages/react-core/package.json +++ b/packages/react-core/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/react-core", - "version": "4.1.10", + "version": "4.1.15", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core", "author": "thirdweb eng ", "license": "Apache-2.0", @@ -52,7 +52,8 @@ "generate-docs:evm": "api-extractor run --local --config ./config/api-extractor-evm.json && api-documenter markdown -i ./temp -o ./docs/evm && rm -rf ./temp-evm && mv ./temp ./temp-evm", "generate-snippets": "node ./scripts/generate-snippets-evm.mjs && node ./scripts/generate-feature-snippets-evm.mjs", "build": "tsc && preconstruct build", - "push": "yalc push" + "push": "yalc push", + "typedoc": "node scripts/typedoc.mjs" }, "sideEffects:": false, "devDependencies": { @@ -83,7 +84,8 @@ "ethers": "^5.7.2", "prettier": "^3.0.0", "react": "^18.2.0", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "typedoc-gen": "workspace:*" }, "dependencies": { "@tanstack/react-query": "^4.33.0", diff --git a/packages/react-core/scripts/typedoc.mjs b/packages/react-core/scripts/typedoc.mjs new file mode 100644 index 00000000000..b5a69338813 --- /dev/null +++ b/packages/react-core/scripts/typedoc.mjs @@ -0,0 +1,14 @@ +// @ts-check +/* eslint-disable better-tree-shaking/no-top-level-side-effects */ + +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: [ + "**/packages/sdk/**", + "**/packages/wallets/**", + "**/packages/chains/**", + ], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/react-core/src/core/hooks/useNetwork.ts b/packages/react-core/src/core/hooks/useNetwork.ts index df2372affa7..5bf77bd01b9 100644 --- a/packages/react-core/src/core/hooks/useNetwork.ts +++ b/packages/react-core/src/core/hooks/useNetwork.ts @@ -29,10 +29,12 @@ type NetworkMetadata = { /** * - * @deprecated - use `useChain`, `useSwitchChain`, `useChainId` instead * * Hook for getting metadata about the network the current wallet is connected to and switching networks * + * It's important to note that some wallet apps do not support programmatic network switching and switchNetwork will be undefined. + * For those situations, you can typically switch networks in the wallet app this hook will still work. + * * @example * ```javascript * import { useNetwork } from "@thirdweb-dev/react"; @@ -47,12 +49,9 @@ type NetworkMetadata = { * * ); * }; -``` + * ``` * - * It's important to note that some wallet apps do not support programmatic network switching and switchNetwork will be undefined. - * For those situations, you can typically switch networks in the wallet app this hook will still work. - * - * @public + * @deprecated - use `useChain`, `useSwitchChain`, `useChainId` instead */ export function useNetwork(): [NetworkMetadata, SwitchNetwork | undefined] { const chain = useChain(); diff --git a/packages/react-core/src/core/hooks/wallet-hooks.ts b/packages/react-core/src/core/hooks/wallet-hooks.ts index d531691c691..3aa03f1bea7 100644 --- a/packages/react-core/src/core/hooks/wallet-hooks.ts +++ b/packages/react-core/src/core/hooks/wallet-hooks.ts @@ -12,6 +12,7 @@ import type { MagicLink, MetaMaskWallet, OKXWallet, + OneKeyWallet, PaperWallet, PhantomWallet, RabbyWallet, @@ -47,6 +48,7 @@ type WalletIdToWalletTypeMap = { phantom: PhantomWallet; walletConnectV1: WalletConnect; okx: OKXWallet; + oneKey: OneKeyWallet; cryptoDefiWallet: CryptoDefiWallet; rabby: RabbyWallet; }; diff --git a/packages/react-core/src/core/providers/query-client.tsx b/packages/react-core/src/core/providers/query-client.tsx index 227c1dc2779..c6d26cabfbb 100644 --- a/packages/react-core/src/core/providers/query-client.tsx +++ b/packages/react-core/src/core/providers/query-client.tsx @@ -3,6 +3,9 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { useMemo } from "react"; export interface QueryClientProviderProps { + /** + * If you are using React Query and have your own `QueryClient`, you can pass it as the queryClient prop to use that instead of the SDK's default client. + */ queryClient?: QueryClient; } diff --git a/packages/react-core/src/core/providers/theme-context.tsx b/packages/react-core/src/core/providers/theme-context.tsx index 50b4c83c5d9..19b5b8ca1f9 100644 --- a/packages/react-core/src/core/providers/theme-context.tsx +++ b/packages/react-core/src/core/providers/theme-context.tsx @@ -1,5 +1,8 @@ import { createContext } from "react"; +/** + * @internal + */ export const ThirdwebThemeContext = /* @__PURE__ */ createContext< "light" | "dark" | undefined >(undefined); diff --git a/packages/react-core/src/core/providers/thirdweb-provider.tsx b/packages/react-core/src/core/providers/thirdweb-provider.tsx index f85146e64e6..03041b8f7a4 100644 --- a/packages/react-core/src/core/providers/thirdweb-provider.tsx +++ b/packages/react-core/src/core/providers/thirdweb-provider.tsx @@ -56,6 +56,9 @@ export interface ThirdwebProviderCoreProps theme?: "light" | "dark"; + /** + * @internal + */ createWalletStorage?: CreateAsyncStorage; /** @@ -68,18 +71,23 @@ export interface ThirdwebProviderCoreProps * * If wallet fails to connect in this time, it will stop trying to connect and user will have to manually connect * - * @defaultValue 15000 + * By default, it is set to `15000` milliseconds (15 seconds) */ autoConnectTimeout?: number; + /** + * @internal + */ signerWallet?: WalletConfig; } -export const ThirdwebProviderCore = ({ - createWalletStorage = createAsyncLocalStorage, - ...props -}: React.PropsWithChildren>) => { - const { activeChain } = props; +/** + * @internal + */ +export const ThirdwebProviderCore = ( + props: React.PropsWithChildren>, +) => { + const { activeChain, createWalletStorage = createAsyncLocalStorage } = props; const supportedChains = (props.supportedChains || defaultChains) as Chain[]; diff --git a/packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx b/packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx index 44c53cf96f4..68ebb7fe0ba 100644 --- a/packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx +++ b/packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx @@ -303,12 +303,14 @@ export function ThirdwebWalletProvider( // Auto Connect useEffect(() => { - // do not auto connect if signerWallet is given - if (props.signerWallet) { + if (autoConnectTriggered.current) { return; } - if (autoConnectTriggered.current) { + autoConnectTriggered.current = true; + + // do not auto connect if signerWallet is given + if (props.signerWallet) { return; } @@ -329,8 +331,6 @@ export function ThirdwebWalletProvider( return; } - autoConnectTriggered.current = true; - async function autoconnect() { const walletInfo = await getLastConnectedWalletInfo(); @@ -339,7 +339,7 @@ export function ThirdwebWalletProvider( return; } - let walletObj = props.supportedWallets.find( + const walletObj = props.supportedWallets.find( (W) => W.id === walletInfo.walletId, ); @@ -351,23 +351,15 @@ export function ThirdwebWalletProvider( let _personalWalletInfo = walletInfo.connectParams?.personalWallet; - // when connecting to magicLink with social login, it redirects to other page - // before redirecting, we save the walletInfo to local storage so that we can auto connect after redirect back to current page - // when using smartWallet + magicLink combination - the walletInfo will only contain info about magicLink and not smartWallet because it was never connected - // so if smartWallet + magicLink combination is used, we need to connect magicLink first and then connect smartWallet - if ( - walletInfo.walletId === walletIds.magicLink && - walletInfo.connectParams && - "oauthProvider" in walletInfo.connectParams - ) { - // if the wallet requires a personal wallet (like smartWallet), but the saved data does not have it - if (walletObj.personalWallets && !_personalWalletInfo) { - // fix the connectParams by adding the personal wallet info - _personalWalletInfo = { - walletId: walletInfo.walletId, - connectParams: walletInfo.connectParams, - }; - } + // if the wallet requires a personal wallet (like smartWallet), but the saved data does not have it + // this can happen when user clicks on "switch to personal wallet" and reloads the page + // OR when user clicks on magic link social login + if (walletObj.personalWallets && !_personalWalletInfo) { + // fix the connectParams by adding the personal wallet info + _personalWalletInfo = { + walletId: walletInfo.walletId, + connectParams: walletInfo.connectParams, + }; } const personalWalletInfo = _personalWalletInfo; @@ -410,19 +402,6 @@ export function ThirdwebWalletProvider( setConnectionStatus("disconnected"); return; } - } else { - // if walletObj requires a personal wallet, but the saved data does not have it - // connect to personal wallet only ( this happens when user switches to personal wallet and reloads the page ) - if (walletObj.personalWallets) { - // connect the personal wallet instead - walletObj = walletObj.personalWallets.find( - (w) => w.id === walletInfo.walletId, - ); - if (!walletObj) { - setConnectionStatus("disconnected"); - return; - } - } } // create a wallet instance and auto connect it @@ -605,6 +584,9 @@ export function ThirdwebWalletProvider( ); } +/** + * @internal + */ export function useWalletContext() { const ctx = useContext(ThirdwebWalletContext); if (!ctx) { diff --git a/packages/react-core/src/core/query-utils/query-key.ts b/packages/react-core/src/core/query-utils/query-key.ts index f0c4dbbd01a..4be479276c8 100644 --- a/packages/react-core/src/core/query-utils/query-key.ts +++ b/packages/react-core/src/core/query-utils/query-key.ts @@ -18,6 +18,9 @@ export function neverPersist(key: TKey) { return [...key, NEVER_PERSIST_QUERY_POSTFIX] as const; } +/** + * @internal + */ export function shouldNeverPersistQuery( key: TKey, ): boolean { diff --git a/packages/react-core/src/core/query-utils/required-param.ts b/packages/react-core/src/core/query-utils/required-param.ts index 4d5a0e5d222..0a5b58d55bb 100644 --- a/packages/react-core/src/core/query-utils/required-param.ts +++ b/packages/react-core/src/core/query-utils/required-param.ts @@ -2,8 +2,7 @@ import invariant from "tiny-invariant"; /** * Makes a parameter required to be passed, but still allows it to be null or undefined. - * - * @beta + * @internal */ export type RequiredParam = T | null | undefined; diff --git a/packages/react-core/src/core/types/wallet.ts b/packages/react-core/src/core/types/wallet.ts index 6e2e7ed30bc..4d41bd6ff17 100644 --- a/packages/react-core/src/core/types/wallet.ts +++ b/packages/react-core/src/core/types/wallet.ts @@ -43,13 +43,15 @@ export type WalletConfig = { /** * If true, this wallet will be tagged as "recommended" in ConnectWallet Modal and will be shown at the top of the list - * @defaultValue false + * + * By default is set to `false` */ recommended?: boolean; /** * If the wallet can sign transactions without user interaction, set this to true. - * @defaultValue false + * + * By default is set to `false` */ isHeadless?: boolean; }; diff --git a/packages/react-core/src/core/utils/ipfs.ts b/packages/react-core/src/core/utils/ipfs.ts index 8bf4ee8754c..0715264b0b2 100644 --- a/packages/react-core/src/core/utils/ipfs.ts +++ b/packages/react-core/src/core/utils/ipfs.ts @@ -5,6 +5,9 @@ export interface IPFSResolverOptions { gatewayUrl: string; } +/** + * @internal + */ export async function resolveMimeType(url?: string) { if (!url) { return undefined; diff --git a/packages/react-core/src/evm/contexts/ThirdwebAuthProvider.tsx b/packages/react-core/src/evm/contexts/ThirdwebAuthProvider.tsx index 79ee5b0db03..9401d42b79a 100644 --- a/packages/react-core/src/evm/contexts/ThirdwebAuthProvider.tsx +++ b/packages/react-core/src/evm/contexts/ThirdwebAuthProvider.tsx @@ -7,9 +7,12 @@ import { import { useQueryClient } from "@tanstack/react-query"; import { useWallet } from "../../core/hooks/wallet-hooks"; import { WalletData } from "@thirdweb-dev/wallets"; -import { useLogout } from "../hooks/auth"; +import { useLogout } from "../hooks/auth/useLogout"; import { useSwitchAccount } from "../hooks/auth/useSwitchAccount"; +/** + * @internal + */ export const ThirdwebAuthProvider: React.FC< PropsWithChildren<{ value?: ThirdwebAuthConfig }> > = ({ value, children }) => { diff --git a/packages/react-core/src/evm/contexts/thirdweb-auth.tsx b/packages/react-core/src/evm/contexts/thirdweb-auth.tsx index ad5be59e858..8a4e9d4c99e 100644 --- a/packages/react-core/src/evm/contexts/thirdweb-auth.tsx +++ b/packages/react-core/src/evm/contexts/thirdweb-auth.tsx @@ -1,5 +1,10 @@ import { createContext, useContext } from "react"; +/** + * Secure storage interface for storing auth tokens. + * + * The implementation of this interface should provide a secure way to store values. Either by encrypting the values or by storing them in a secure location. + */ export interface ISecureStorage { getItem(key: string): Promise; setItem(key: string, value: string): Promise; @@ -7,9 +12,8 @@ export interface ISecureStorage { } /** - * The configuration to use the react SDK with an [auth](https://portal.thirdweb.com/auth) server. + * The configuration to use by the React and React Native SDKs with an [auth](https://portal.thirdweb.com/auth) server. * - * @beta */ export interface ThirdwebAuthConfig { /** diff --git a/packages/react-core/src/evm/contexts/thirdweb-config.tsx b/packages/react-core/src/evm/contexts/thirdweb-config.tsx index 3ad16b392d4..006095cf8f9 100644 --- a/packages/react-core/src/evm/contexts/thirdweb-config.tsx +++ b/packages/react-core/src/evm/contexts/thirdweb-config.tsx @@ -11,6 +11,9 @@ export const ThirdwebConfigContext = /* @__PURE__ */ createContext< ThirdwebConfigContext | undefined >(undefined); +/** + * @internal + */ export const ThirdwebConfigProvider: React.FC< PropsWithChildren<{ value: ThirdwebConfigContext; @@ -21,6 +24,9 @@ export const ThirdwebConfigProvider: React.FC< ); +/** + * @internal + */ export function useThirdwebConfigContext() { const context = useContext(ThirdwebConfigContext); invariant( diff --git a/packages/react-core/src/evm/contexts/thirdweb-wallet.tsx b/packages/react-core/src/evm/contexts/thirdweb-wallet.tsx index 564b9b0f8d0..c5375031b74 100644 --- a/packages/react-core/src/evm/contexts/thirdweb-wallet.tsx +++ b/packages/react-core/src/evm/contexts/thirdweb-wallet.tsx @@ -31,6 +31,9 @@ export const ThirdwebConnectedWalletContext = /* @__PURE__ */ createContext< ThirdwebConnectedWalletContext | undefined >(undefined); +/** + * @internal + */ export const ThirdwebConnectedWalletProvider: React.FC< PropsWithChildren<{ signer?: Signer }> > = ({ signer, children }) => { diff --git a/packages/react-core/src/evm/hooks/async/account-factory.ts b/packages/react-core/src/evm/hooks/async/account-factory.ts index 7e80895812d..34d5bf43479 100644 --- a/packages/react-core/src/evm/hooks/async/account-factory.ts +++ b/packages/react-core/src/evm/hooks/async/account-factory.ts @@ -34,7 +34,6 @@ import invariant from "tiny-invariant"; * @returns a response object that includes an array of all accounts with their associated admin * @twfeature AccountFactory * @see {@link https://portal.thirdweb.com/react/react.useaccounts?utm_source=sdk | Documentation} - * @beta */ export function useAccounts( contract: RequiredParam, @@ -66,7 +65,6 @@ export function useAccounts( * @returns a response object that includes an array of all accounts associated with the address * @twfeature AccountFactory * @see {@link https://portal.thirdweb.com/react/react.useaccountsforaddress?utm_source=sdk | Documentation} - * @beta */ export function useAccountsForAddress( contract: RequiredParam, @@ -102,7 +100,6 @@ export function useAccountsForAddress( * @returns a boolean indicating if a account has been deployed for the given admin * @twfeature AccountFactory * @see {@link https://portal.thirdweb.com/react/react.useisaccountdeployed?utm_source=sdk | Documentation} - * @beta */ export function useIsAccountDeployed( contract: RequiredParam, @@ -160,7 +157,6 @@ export function useIsAccountDeployed( * @returns a mutation object that can be used to create a account * @twfeature AccountFactory * @see {@link https://portal.thirdweb.com/react/react.usecreateaccount?utm_source=sdk | Documentation} - * @beta */ export function useCreateAccount(contract: RequiredParam) { const activeChainId = useSDKChainId(); diff --git a/packages/react-core/src/evm/hooks/async/account.ts b/packages/react-core/src/evm/hooks/async/account.ts index 892d6f3156c..282a7ea8d18 100644 --- a/packages/react-core/src/evm/hooks/async/account.ts +++ b/packages/react-core/src/evm/hooks/async/account.ts @@ -35,7 +35,6 @@ import { useWallet } from "../../../core/hooks/wallet-hooks"; * @returns a response object that includes an array of all signers of the provided account * @twfeature Account * @see {@link https://portal.thirdweb.com/react/react.useaccountsigners?utm_source=sdk | Documentation} - * @beta */ export function useAccountSigners( contract: RequiredParam, @@ -67,7 +66,6 @@ export function useAccountSigners( * @returns a response object that includes an array of all admins of the provided account * @twfeature Account * @see {@link https://portal.thirdweb.com/react/react.useaccountadmins?utm_source=sdk | Documentation} - * @beta */ export function useAccountAdmins( contract: RequiredParam, @@ -99,7 +97,6 @@ export function useAccountAdmins( * @returns a response object that includes an array of all admins of the provided account * @twfeature Account * @see {@link https://portal.thirdweb.com/react/react.useaccountadmins?utm_source=sdk | Documentation} - * @beta */ export function useAccountAdminsAndSigners( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/app.ts b/packages/react-core/src/evm/hooks/async/app.ts index 5fa732ee708..5ec6814e6da 100644 --- a/packages/react-core/src/evm/hooks/async/app.ts +++ b/packages/react-core/src/evm/hooks/async/app.ts @@ -28,7 +28,6 @@ import invariant from "tiny-invariant"; * @param contract - the {@link SmartContract} instance of the contract to get the appURI of * @returns a response object that includes the appURI of the contract * @twfeature AppURI - * @beta */ export function useAppURI( contract: RequiredParam, @@ -75,7 +74,6 @@ export function useAppURI( * @param contract - an instance of a {@link SmartContract} * @returns a mutation object that can be used to update the appURI of a contract * @twfeature AppUR - * @beta */ export function useSetAppURI( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/claim-conditions.ts b/packages/react-core/src/evm/hooks/async/claim-conditions.ts index 4b8aaa0bf46..13cbf84a692 100644 --- a/packages/react-core/src/evm/hooks/async/claim-conditions.ts +++ b/packages/react-core/src/evm/hooks/async/claim-conditions.ts @@ -30,7 +30,6 @@ import invariant from "tiny-invariant"; /** * The options to be passed as the second parameter to the {@link useClaimIneligibilityReasons} hook. * - * @beta */ export type ClaimIneligibilityParams = { // the wallet address to check claim eligibility for @@ -42,7 +41,6 @@ export type ClaimIneligibilityParams = { /** * The params for the {@link useSetClaimConditions} hook mutation. * - * @beta */ export type SetClaimConditionsParams = { phases: ClaimConditionInput[]; @@ -66,7 +64,6 @@ export type SetClaimConditionsParams = { * @returns a response object with the currently active claim condition * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useactiveclaimcondition?utm_source=sdk | Documentation} - * @beta */ export function useActiveClaimCondition( contract: RequiredParam, @@ -122,7 +119,6 @@ export function useActiveClaimCondition( * @returns a response object with the snapshot for the provided address * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useclaimerproofs?utm_source=sdk | Documentation} - * @beta */ export function useClaimerProofs( contract: RequiredParam, @@ -186,7 +182,6 @@ export function useClaimerProofs( * @returns a response object with the list of claim conditions * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useclaimconditions?utm_source=sdk | Documentation} - * @beta */ export function useClaimConditions( contract: RequiredParam, @@ -241,7 +236,6 @@ export function useClaimConditions( * @returns a response object with the reasons for the claim ineligibility * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useclaimineligibilityreasons?utm_source=sdk | Documentation} - * @beta */ export function useClaimIneligibilityReasons( contract: RequiredParam, @@ -311,7 +305,6 @@ export function useClaimIneligibilityReasons( * @returns the active claim condition for the wallet address or null if there is no active claim condition * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useactiveclaimconditionforwallet?utm_source=sdk | Documentation} - * @beta */ export function useActiveClaimConditionForWallet( contract: RequiredParam, @@ -467,7 +460,6 @@ export function useActiveClaimConditionForWallet( * @returns a mutation object that can be used to set claim conditions * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.usesetclaimconditions?utm_source=sdk | Documentation} - * @beta */ export function useSetClaimConditions( contract: RequiredParam, @@ -546,7 +538,6 @@ export function useSetClaimConditions( * @param contract - an instance of a {@link DropContract} * @returns a mutation object that can be used to reset claim conditions * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 - * @beta */ export function useResetClaimConditions( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/contract-settings.ts b/packages/react-core/src/evm/hooks/async/contract-settings.ts index e1e425e63b7..fe0fa3e56ac 100644 --- a/packages/react-core/src/evm/hooks/async/contract-settings.ts +++ b/packages/react-core/src/evm/hooks/async/contract-settings.ts @@ -37,7 +37,6 @@ import invariant from "tiny-invariant"; * @returns the wallet address of the primary sales recipient * @twfeature PrimarySale * @see {@link https://portal.thirdweb.com/react/react.useprimarysalerecipient?utm_source=sdk | Documentation} - * @beta */ export function usePrimarySaleRecipient( contract: RequiredParam, @@ -89,7 +88,6 @@ export function usePrimarySaleRecipient( * @returns a mutation object that can be used to update the primary sales recipient * @twfeature PrimarySale * @see {@link https://portal.thirdweb.com/react/react.useupdateprimarysalerecipient?utm_source=sdk | Documentation} - * @beta */ export function useUpdatePrimarySaleRecipient( contract: RequiredParam, @@ -140,7 +138,6 @@ export function useUpdatePrimarySaleRecipient( * @returns an object containing recipient address and the royalty basis points * @twfeature Royalty * @see {@link https://portal.thirdweb.com/react/react.useroyaltysettings?utm_source=sdk | Documentation} - * @beta */ export function useRoyaltySettings( contract: RequiredParam, @@ -192,7 +189,6 @@ export function useRoyaltySettings( * @returns a mutation object that can be used to update the royalty settings * @twfeature Royalty * @see {@link https://portal.thirdweb.com/react/react.useupdateroyaltysettings?utm_source=sdk | Documentation} - * @beta */ export function useUpdateRoyaltySettings( contract: RequiredParam, @@ -239,7 +235,6 @@ export function useUpdateRoyaltySettings( * @returns an object containing the platform fee basis points and the fee recipient address * @twfeature PlatformFee * @see {@link https://portal.thirdweb.com/react/react.useplatformfees?utm_source=sdk | Documentation} - * @beta */ export function usePlatformFees( contract: RequiredParam, @@ -290,7 +285,6 @@ export function usePlatformFees( * @returns a mutation object that can be used to update the platform fees settings * @twfeature PlatformFee * @see {@link https://portal.thirdweb.com/react/react.useupdateplatformfees?utm_source=sdk | Documentation} - * @beta */ export function useUpdatePlatformFees( contract: RequiredParam, @@ -336,7 +330,6 @@ export function useUpdatePlatformFees( * @param contract - an instance of a {@link SmartContract} * @returns a {@link CustomContractMetadata} object containing the metadata * @see {@link https://portal.thirdweb.com/react/react.usemetadata?utm_source=sdk | Documentation} - * @beta */ export function useMetadata( contract: RequiredParam, @@ -390,7 +383,6 @@ export function useMetadata( * @param contract - an instance of a {@link SmartContract} * @returns a mutation object that can be used to update the metadata * @see {@link https://portal.thirdweb.com/react/react.useupdatemetadata?utm_source=sdk | Documentation} - * @beta */ export function useUpdateMetadata( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/contracts.ts b/packages/react-core/src/evm/hooks/async/contracts.ts index 6153dca275b..4221a2e0b79 100644 --- a/packages/react-core/src/evm/hooks/async/contracts.ts +++ b/packages/react-core/src/evm/hooks/async/contracts.ts @@ -73,6 +73,9 @@ export function useContractType( ); } +/** + * @internal + */ export const contractType = { cacheKey: ( contractAddress: RequiredParam, @@ -121,6 +124,9 @@ export function useCompilerMetadata( ); } +/** + * @internal + */ export const compilerMetadata = { cacheKey: ( contractAddress: RequiredParam, @@ -307,7 +313,6 @@ export function useContract( * @param contract - the {@link ValidContractInstance} instance of the contract to get the metadata for * @returns a response object that includes the contract metadata of the deployed contract * @twfeature ContractMetadata - * @beta */ export function useContractMetadata( contract: RequiredParam, @@ -359,7 +364,6 @@ export function useContractMetadata( * @param contract - the {@link ValidContractInstance} instance of the contract to get the metadata for * @returns a response object that includes the contract metadata of the deployed contract * @twfeature ContractMetadata - * @beta */ export function useContractMetadataUpdate( contract: RequiredParam, @@ -417,7 +421,6 @@ export function useContractMetadataUpdate( * @param options - options includes the filters ({@link QueryAllEvents}) for the query as well as if you want to subscribe to real-time updates (default: true) * @returns a response object that includes the contract events * @see {@link https://portal.thirdweb.com/react/react.usecontractevents?utm_source=sdk | Documentation} - * @beta */ export function useContractEvents( contract: RequiredParam, @@ -515,7 +518,6 @@ export function useContractEvents( * @param args - The arguments to pass to the function (if any), with optional call arguments as the last parameter * @returns a response object that includes the data returned by the function call * @see {@link https://portal.thirdweb.com/react/react.usecontractread?utm_source=sdk | Documentation} - * @beta */ export function useContractRead< TContractAddress extends GeneratedContractAddress | ContractAddress, @@ -592,7 +594,6 @@ export function useContractRead< * @param functionName - the name of the function to call * @returns a response object that includes the write function to call * @see {@link https://portal.thirdweb.com/react/react.usecontractwrite?utm_source=sdk | Documentation} - * @beta */ export function useContractWrite< TContractAddress extends GeneratedContractAddress | ContractAddress, diff --git a/packages/react-core/src/evm/hooks/async/drop.ts b/packages/react-core/src/evm/hooks/async/drop.ts index 13b01f1c31b..6fa88a22afa 100644 --- a/packages/react-core/src/evm/hooks/async/drop.ts +++ b/packages/react-core/src/evm/hooks/async/drop.ts @@ -52,7 +52,6 @@ import invariant from "tiny-invariant"; * @returns a response object that includes an array of NFTs that are unclaimed * @twfeature ERC721LazyMintable * @see {@link https://portal.thirdweb.com/react/react.useunclaimednfts?utm_source=sdk | Documentation} - * @beta */ export function useUnclaimedNFTs( contract: RequiredParam, @@ -89,7 +88,6 @@ export function useUnclaimedNFTs( * @returns a response object that includes an array of NFTs that are claimed * @twfeature ERC721LazyMintable * @see {@link https://portal.thirdweb.com/react/react.useclaimednfts?utm_source=sdk | Documentation} - * @beta */ export function useClaimedNFTs( contract: RequiredParam, @@ -226,7 +224,6 @@ export function useBatchesToReveal( * @returns a mutation object that can be used to claim a NFT to the wallet specificed in the params * @twfeature ERC721Claimable | ERC1155Claimable | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useclaimnft?utm_source=sdk | Documentation} - * @beta */ export function useClaimNFT( contract: RequiredParam, @@ -316,7 +313,6 @@ export function useClaimNFT( * @returns a mutation object that can be used to lazy mint a batch of NFTs * @twfeature ERC721LazyMintable | ERC1155LazyMintable * @see {@link https://portal.thirdweb.com/react/react.uselazymint?utm_source=sdk | Documentation} - * @beta */ export function useLazyMint( contract: RequiredParam, @@ -389,7 +385,6 @@ export function useLazyMint( * @returns a mutation object that can be used to lazy mint a batch of NFTs * @twfeature ERC721Revealable | ERC1155Revealable * @see {@link https://portal.thirdweb.com/react/react.usedelayedreveallazymint?utm_source=sdk | Documentation} - * @beta */ export function useDelayedRevealLazyMint( contract: RequiredParam, @@ -470,7 +465,6 @@ export function useDelayedRevealLazyMint( * @returns a mutation object that can be used to reveal a batch of delayed reveal NFTs * @twfeature ERC721Revealable | ERC1155Revealable * @see {@link https://portal.thirdweb.com/react/react.usereveallazymint?utm_source=sdk | Documentation} - * @beta */ export function useRevealLazyMint( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/marketplace.ts b/packages/react-core/src/evm/hooks/async/marketplace.ts index 89ad0cb6929..93eaab2a73f 100644 --- a/packages/react-core/src/evm/hooks/async/marketplace.ts +++ b/packages/react-core/src/evm/hooks/async/marketplace.ts @@ -56,7 +56,6 @@ import invariant from "tiny-invariant"; * @param listingId - the listing id to check * @returns a response object that includes the desired listing * @see {@link https://portal.thirdweb.com/react/react.uselisting?utm_source=sdk | Documentation} - * @beta */ export function useListing( contract: RequiredParam, @@ -163,7 +162,6 @@ export function useEnglishAuction( * @param filter - filter to pass to the query for the sake of pagination & filtering * @returns a response object that includes an array of listings * @see {@link https://portal.thirdweb.com/react/react.uselistings?utm_source=sdk | Documentation} - * @beta */ export function useListings( contract: RequiredParam, @@ -334,7 +332,6 @@ export function useValidEnglishAuctions( * @param contract - an instance of a marketplace contract * @returns a response object that includes the listing count * @see {@link https://portal.thirdweb.com/react/react.uselistingscount?utm_source=sdk | Documentation} - * @beta */ export function useListingsCount(contract: RequiredParam) { const contractAddress = contract?.getAddress(); @@ -422,7 +419,6 @@ export function useEnglishAuctionsCount( * @param filter - filter to pass to the query for the sake of pagination & filtering * @returns a response object that includes an array of listings * @see {@link https://portal.thirdweb.com/react/react.useactivelistings?utm_source=sdk | Documentation} - * @beta */ export function useActiveListings( contract: RequiredParam, @@ -456,7 +452,6 @@ export function useActiveListings( * @param listingId - the listing id to check * @returns a response object that includes the {@link Offer} that is winning the auction * @see {@link https://portal.thirdweb.com/react/react.usewinningbid?utm_source=sdk | Documentation} - * @beta */ export function useWinningBid( contract: RequiredParam, @@ -585,7 +580,6 @@ export function useAuctionWinner( * * @param contract - an instance of a marketplace contract * @param listingId - the listing id to check (only necessary for marketplace v3) - * @returns a response object that includes an array of listings * @twfeature EnglishAuctions * @see {@link https://portal.thirdweb.com/react/react.usebidbuffer?utm_source=sdk | Documentation} @@ -694,7 +688,6 @@ export function useMinimumNextBid( * @param contract - an instance of a Marketplace contract * @param listingId - the id of the listing to fetch offers for * @see {@link https://portal.thirdweb.com/react/react.useoffers?utm_source=sdk | Documentation} - * @beta */ export function useOffers( contract: RequiredParam, @@ -902,7 +895,6 @@ export function useCreateAuctionListing< * @param contract - an instance of a Marketplace contract * @returns a mutation object that can be used to cancel a listing * @see {@link https://portal.thirdweb.com/react/react.usecancellisting?utm_source=sdk | Documentation} - * @beta */ export function useCancelListing( contract: RequiredParam, @@ -1107,7 +1099,6 @@ export function useCancelEnglishAuction( * @param contract - an instance of a Marketplace contract * @returns a mutation object that can be used to make a bid on an auction listing * @see {@link https://portal.thirdweb.com/react/react.usemakebid?utm_source=sdk | Documentation} - * @beta */ export function useMakeBid(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -1166,7 +1157,6 @@ export function useMakeBid(contract: RequiredParam) { * @param contract - an instance of a Marketplace contract * @returns a mutation object that can be used to make a bid on an auction listing * @see {@link https://portal.thirdweb.com/react/react.usemakeoffer?utm_source=sdk | Documentation} - * @beta */ export function useMakeOffer(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -1286,7 +1276,6 @@ export function useAcceptDirectListingOffer( * @param contract - an instance of a Marketplace contract * @returns a mutation object that can be used to accept an offer on a direct listing * @see {@link https://portal.thirdweb.com/react/react.useexecuteauctionsale?utm_source=sdk | Documentation} - * @beta */ export function useExecuteAuctionSale(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -1344,7 +1333,6 @@ export function useExecuteAuctionSale(contract: RequiredParam) { * @param contract - an instance of a Marketplace contract * @returns a mutation object that can be used to buy out an auction listing * @see {@link https://portal.thirdweb.com/react/react.usebuynow?utm_source=sdk | Documentation} - * @beta */ export function useBuyNow(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -1415,7 +1403,6 @@ export function useBuyNow(contract: RequiredParam) { * @param contract - an instance of a MarketplaceV3 contract * @returns a mutation object that can be used to buy out a direct listing * @see {@link https://portal.thirdweb.com/react/react.useBuyDirectListing?utm_source=sdk | Documentation} - * @beta */ export function useBuyDirectListing(contract: RequiredParam) { const activeChainId = useSDKChainId(); diff --git a/packages/react-core/src/evm/hooks/async/nft.ts b/packages/react-core/src/evm/hooks/async/nft.ts index 3ba3d6e266c..e0936f0c4b7 100644 --- a/packages/react-core/src/evm/hooks/async/nft.ts +++ b/packages/react-core/src/evm/hooks/async/nft.ts @@ -46,7 +46,6 @@ import invariant from "tiny-invariant"; * @param contract - an instance of a {@link NFTContract} * @param tokenId - the tokenId to look up * @returns a response object that includes the metadata for the given tokenId - * @beta * @twfeature ERC721 | ERC1155 * @see {@link https://portal.thirdweb.com/react/react.usenft?utm_source=sdk | Documentation} */ @@ -90,7 +89,6 @@ export function useNFT( * @param queryParams - query params to pass to the query for pagination * @returns a response object that includes an array of NFTs * @twfeature ERC721Supply | ERC721Enumerable | ERC1155Enumerable - * @beta * @see {@link https://portal.thirdweb.com/react/react.usenfts?utm_source=sdk | Documentation} */ export function useNFTs( @@ -132,7 +130,6 @@ export function useNFTs( * * @param contract - an instance of a {@link NFTContract} * @returns a response object that includes the total count of NFTs - * @beta * @twfeature ERC721Supply | ERC1155Enumerable * @see {@link https://portal.thirdweb.com/react/react.usetotalcount?utm_source=sdk | Documentation} */ @@ -181,7 +178,6 @@ export function useTotalCount( * @param contract - an instance of a {@link NFTContract} * @param tokenId - required for ERC1155, the tokenId to look up * @returns a response object that includes the total minted supply - * @beta * @twfeature ERC721Supply | ERC1155Enumerable * @see {@link https://portal.thirdweb.com/react/react.usetotalcirculatingsupply?utm_source=sdk | Documentation} */ @@ -235,7 +231,6 @@ export function useTotalCirculatingSupply( * @param ownerWalletAddress - the wallet address to get owned tokens for * @param queryParams - query params to pass to the query for pagination * @returns a response object that includes the list of owned tokens - * @beta * @twfeature ERC721Enumerable | ERC1155Enumerable | ERC721Supply * @see {@link https://portal.thirdweb.com/react/react.useownednfts?utm_source=sdk | Documentation} */ @@ -283,7 +278,6 @@ export function useOwnedNFTs( * @returns a response object that includes the total balance of the owner * @twfeature ERC721 | ERC1155 * @see {@link https://portal.thirdweb.com/react/react.usenftbalance?utm_source=sdk | Documentation} - * @beta */ export function useNFTBalance( contract: RequiredParam, @@ -337,7 +331,6 @@ export function useNFTBalance( * @returns a response object that includes the shared metadata of the contract * @twfeature ERC721SharedMetadata * @see {@link https://portal.thirdweb.com/react/react.usesharedmetadata?utm_source=sdk | Documentation} - * @beta */ export function useSharedMetadata( contract: RequiredParam, @@ -397,7 +390,6 @@ export function useSharedMetadata( * * @param contract - an instance of a {@link NFTContract} * @returns a mutation object that can be used to mint a new NFT token to the connected wallet - * @beta * @twfeature ERC721Mintable | ERC1155Mintable * @see {@link https://portal.thirdweb.com/react/react.usemintnft?utm_source=sdk | Documentation} */ @@ -470,7 +462,6 @@ export function useMintNFT( * * @param contract - an instance of a {@link Erc1155} * @returns a mutation object that can be used to mint a more supply of a token id to the provided wallet - * @beta * @twfeature ERC1155Mintable * @see {@link https://portal.thirdweb.com/react/react.usemintnftsupply?utm_source=sdk | Documentation} */ @@ -537,7 +528,6 @@ export function useMintNFTSupply(contract: Erc1155) { * * @param contract - an instance of a {@link NFTContract} * @returns a mutation object that can be used to transfer NFTs - * @beta * @twfeature ERC721 | ERC1155 * @see {@link https://portal.thirdweb.com/react/react.usetransfernft?utm_source=sdk | Documentation} */ @@ -624,7 +614,6 @@ export function useTransferNFT( * @returns a mutation object that can be used to transfer batch NFTs * @twfeature ERC1155 * @see {@link https://portal.thirdweb.com/react/react.useairdropnft?utm_source=sdk | Documentation} - * @beta */ export function useAirdropNFT(contract: Erc1155) { const activeChainId = useSDKChainId(); @@ -681,7 +670,6 @@ export function useAirdropNFT(contract: Erc1155) { * @returns a mutation object that can be used to burn an NFT token from the connected wallet * @twfeature ERC721Burnable | ERC1155Burnable * @see {@link https://portal.thirdweb.com/react/react.useburnnft?utm_source=sdk | Documentation} - * @beta */ export function useBurnNFT( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/roles.ts b/packages/react-core/src/evm/hooks/async/roles.ts index ff98554b471..dba771d9574 100644 --- a/packages/react-core/src/evm/hooks/async/roles.ts +++ b/packages/react-core/src/evm/hooks/async/roles.ts @@ -57,7 +57,6 @@ type GetAllReturnType = Promise< * @returns a list of addresses for all supported roles on the contract. * @twfeature PermissionsEnumerable * @see {@link https://portal.thirdweb.com/react/react.useallrolemembers?utm_source=sdk | Documentation} - * @beta */ export function useAllRoleMembers( contract: RequiredParam, @@ -90,7 +89,6 @@ export function useAllRoleMembers( * @returns a list of addresses that are members of the role * @twfeature Permissions * @see {@link https://portal.thirdweb.com/react/react.userolemembers?utm_source=sdk | Documentation} - * @beta */ export function useRoleMembers( contract: RequiredParam, @@ -124,7 +122,6 @@ export function useRoleMembers( * @returns true if the address is a member of the role, or false if not * @twfeature PermissionsEnumerable * @see {@link https://portal.thirdweb.com/react/react.useisaddressrole?utm_source=sdk | Documentation} - * @beta */ export function useIsAddressRole( contract: RequiredParam, @@ -187,7 +184,6 @@ export function useIsAddressRole( * @param contract - an instance of a {@link SmartContract} * @returns a mutation object that can be used to overwrite all roles on the contract * @twfeature Permissions - * @beta */ export function useSetAllRoleMembers( contract: RequiredParam, @@ -247,7 +243,6 @@ export function useSetAllRoleMembers( * @returns a mutation object that can be used to grant a member of a role on the contract * @twfeature Permissions | PermissionsEnumerable * @see {@link https://portal.thirdweb.com/react/react.usegrantrole?utm_source=sdk | Documentation} - * @beta */ export function useGrantRole( contract: RequiredParam, @@ -308,7 +303,6 @@ export function useGrantRole( * @returns a mutation object that can be used to revoke a role from a member on the contract * @twfeature Permissions | PermissionsEnumerable * @see {@link https://portal.thirdweb.com/react/react.userevokerole?utm_source=sdk | Documentation} - * @beta */ export function useRevokeRole( contract: RequiredParam, diff --git a/packages/react-core/src/evm/hooks/async/token.ts b/packages/react-core/src/evm/hooks/async/token.ts index b7e44b4aa2e..b37352952d6 100644 --- a/packages/react-core/src/evm/hooks/async/token.ts +++ b/packages/react-core/src/evm/hooks/async/token.ts @@ -40,7 +40,6 @@ import invariant from "tiny-invariant"; * @returns a response object that includes the total minted supply * @twfeature ERC20 * @see {@link https://portal.thirdweb.com/react/react.usetokensupply?utm_source=sdk | Documentation} - * @beta */ export function useTokenSupply(contract: RequiredParam) { const contractAddress = contract?.getAddress(); @@ -72,7 +71,6 @@ export function useTokenSupply(contract: RequiredParam) { * @returns a response object that includes the balance of the address * @twfeature ERC20 * @see {@link https://portal.thirdweb.com/react/react.usetokenbalance?utm_source=sdk | Documentation} - * @beta */ export function useTokenBalance( contract: RequiredParam, @@ -109,7 +107,6 @@ export function useTokenBalance( * @returns a response object that includes the decimals of the ERC20 token * @twfeature ERC20 * @see {@link https://portal.thirdweb.com/react/react.usetokendecimals?utm_source=sdk | Documentation} - * @beta */ export function useTokenDecimals(contract: RequiredParam) { const contractAddress = contract?.getAddress(); @@ -166,7 +163,6 @@ export function useTokenDecimals(contract: RequiredParam) { * @returns a mutation object that can be used to mint new tokens to the connected wallet * @twfeature ERC20Mintable * @see {@link https://portal.thirdweb.com/react/react.useminttoken?utm_source=sdk | Documentation} - * @beta */ export function useMintToken( contract: RequiredParam, @@ -239,7 +235,6 @@ export function useMintToken( * @returns a mutation object that can be used to tokens to the wallet specified in the params * @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 * @see {@link https://portal.thirdweb.com/react/react.useclaimtoken?utm_source=sdk | Documentation} - * @beta */ export function useClaimToken(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -301,7 +296,6 @@ export function useClaimToken(contract: RequiredParam) { * @returns a mutation object that can be used to transfer tokens * @twfeature ERC20 * @see {@link https://portal.thirdweb.com/react/react.usetransfertoken?utm_source=sdk | Documentation} - * @beta */ export function useTransferToken(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -361,7 +355,6 @@ export function useTransferToken(contract: RequiredParam) { * @returns a mutation object that can be used to transfer batch tokens * @twfeature ERC20 * @see {@link https://portal.thirdweb.com/react/react.usetransferbatchtoken?utm_source=sdk | Documentation} - * @beta */ export function useTransferBatchToken(contract: RequiredParam) { const activeChainId = useSDKChainId(); @@ -428,7 +421,6 @@ export function useTransferBatchToken(contract: RequiredParam) { * @returns a mutation object that can be used to burn tokens from the connected wallet * @twfeature ERC20Burnable * @see {@link https://portal.thirdweb.com/react/react.useburntoken?utm_source=sdk | Documentation} - * @beta */ export function useBurnToken(contract: RequiredParam) { const activeChainId = useSDKChainId(); diff --git a/packages/react-core/src/evm/hooks/auth/index.ts b/packages/react-core/src/evm/hooks/auth/useAuth.ts similarity index 71% rename from packages/react-core/src/evm/hooks/auth/index.ts rename to packages/react-core/src/evm/hooks/auth/useAuth.ts index d12109c2101..565e58b9532 100644 --- a/packages/react-core/src/evm/hooks/auth/index.ts +++ b/packages/react-core/src/evm/hooks/auth/useAuth.ts @@ -3,12 +3,6 @@ import { useWallet } from "../../../core/hooks/wallet-hooks"; import { useThirdwebAuthContext } from "../../contexts/thirdweb-auth"; import { useMemo } from "react"; -export { useLogin } from "./useLogin"; -export { useLogout } from "./useLogout"; -export type { UserWithData } from "./useUser"; -export { useUser } from "./useUser"; -export { useSwitchAccount } from "./useSwitchAccount"; - export function useAuth() { const wallet = useWallet(); const authConfig = useThirdwebAuthContext(); diff --git a/packages/react-core/src/evm/hooks/auth/useLogin.ts b/packages/react-core/src/evm/hooks/auth/useLogin.ts index 493666cbc64..bc2283cf076 100644 --- a/packages/react-core/src/evm/hooks/auth/useLogin.ts +++ b/packages/react-core/src/evm/hooks/auth/useLogin.ts @@ -12,9 +12,33 @@ import { AUTH_TOKEN_STORAGE_KEY } from "../../../core/constants/auth"; * * @returns - A function to invoke to login with the connected wallet, and an isLoading state. * - * @see {@link https://portal.thirdweb.com/react/react.uselogin?utm_source=sdk | Documentation} + * @example + * ```tsx + * function App() { + * const { isLoading, login } = useLogin(); * - * @beta + * return ( + * + * ); + * } + * ``` + * + * ```tsx + * // options + * login({ + * domain: "https://your-domain.com", // Your dapp domain + * statement: "My statement", // Text that the user will sign + * uri: "https://your-domain.com/login", // RFC 3986 URI referring to the resource that is the subject of the signing + * version: "1.0", // The current version of the message, which MUST be 1 for this specification. + * chainId: "mainnet", // Chain ID to which the session is bound + * nonce: "my-nonce", // randomized token typically used to prevent replay attacks + * expirationTime: new Date(2021, 1, 1), // When this message expires + * invalidBefore: new Date(2020, 12, 1), // When this message becomes valid + * resources: ["balance", "history", "info"], // A list of information or references to information the user wishes to have resolved + * }) + * ``` */ export function useLogin() { const queryClient = useQueryClient(); diff --git a/packages/react-core/src/evm/hooks/auth/useLogout.ts b/packages/react-core/src/evm/hooks/auth/useLogout.ts index 37c15416dbf..ab4dfaec707 100644 --- a/packages/react-core/src/evm/hooks/auth/useLogout.ts +++ b/packages/react-core/src/evm/hooks/auth/useLogout.ts @@ -10,9 +10,18 @@ import invariant from "tiny-invariant"; * * @returns - A function to invoke to logout. * - * @see {@link https://portal.thirdweb.com/react/react.uselogout?utm_source=sdk | Documentation} + * @example + * ```tsx + * function App() { + * const { logout, isLoading } = useLogout(); * - * @beta + * return ( + * + * ); + *} + * ``` */ export function useLogout() { const queryClient = useQueryClient(); diff --git a/packages/react-core/src/evm/hooks/auth/useSwitchAccount.ts b/packages/react-core/src/evm/hooks/auth/useSwitchAccount.ts index 289533ef3d5..bfc770a167d 100644 --- a/packages/react-core/src/evm/hooks/auth/useSwitchAccount.ts +++ b/packages/react-core/src/evm/hooks/auth/useSwitchAccount.ts @@ -10,7 +10,6 @@ import invariant from "tiny-invariant"; * * @see {@link https://portal.thirdweb.com/react/react.useswitchaccount?utm_source=sdk | Documentation} * - * @beta */ export function useSwitchAccount() { const queryClient = useQueryClient(); diff --git a/packages/react-core/src/evm/hooks/auth/useUser.ts b/packages/react-core/src/evm/hooks/auth/useUser.ts index 0f85b7c9cd8..35e36ac90fd 100644 --- a/packages/react-core/src/evm/hooks/auth/useUser.ts +++ b/packages/react-core/src/evm/hooks/auth/useUser.ts @@ -16,10 +16,23 @@ export interface UserWithData< * Hook to get the currently logged in user. * * @returns - The currently logged in user or null if not logged in, as well as a loading state. + * ```tsx + * { + * user: { + * address: string; + * session?: Json; + * } | undefined; + * isLoggedIn: boolean; + * isLoading: boolean; + *} + * ``` * - * @see {@link https://portal.thirdweb.com/react/react.useuser?utm_source=sdk | Documentation} - * - * @beta + * @example + * ```tsx + * function App() { + * const { user, isLoggedIn, isLoading } = useUser(); + * } + * ``` */ export function useUser< TData extends Json = Json, diff --git a/packages/react-core/src/evm/hooks/contracts/index.ts b/packages/react-core/src/evm/hooks/contracts/index.ts deleted file mode 100644 index 9d7edbf67bf..00000000000 --- a/packages/react-core/src/evm/hooks/contracts/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export { useEditionDrop } from "./useEditionDrop"; -export { useEdition } from "./useEdition"; -export { useNFTDrop } from "./useNFTDrop"; -export { useMarketplace } from "./useMarketplace"; -export { useNFTCollection } from "./useNFTCollection"; -export { usePack } from "./usePack"; -export { useToken } from "./useToken"; -export { useTokenDrop } from "./useTokenDrop"; -export { useVote } from "./useVote"; -export { useSplit } from "./useSplit"; -export { useMultiwrap } from "./useMultiwrap"; -export { useSignatureDrop } from "./useSignatureDrop"; diff --git a/packages/react-core/src/evm/hooks/storage/index.ts b/packages/react-core/src/evm/hooks/storage/index.ts deleted file mode 100644 index 53f273727f1..00000000000 --- a/packages/react-core/src/evm/hooks/storage/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { useSDK } from "../useSDK"; - -export { useStorageUpload } from "./useStorageUpload"; - -/** - * Get the configured `ThirdwebStorage` instance - * @returns The `storageInterface` configured on the `ThirdwebProvider` - * @see {@link https://portal.thirdweb.com/react/react.usestorage?utm_source=sdk | Documentation} - */ -export function useStorage() { - const sdk = useSDK(); - return sdk?.storage; -} diff --git a/packages/react-core/src/evm/hooks/storage/useStorage.ts b/packages/react-core/src/evm/hooks/storage/useStorage.ts new file mode 100644 index 00000000000..313d2dffa53 --- /dev/null +++ b/packages/react-core/src/evm/hooks/storage/useStorage.ts @@ -0,0 +1,29 @@ +import { useSDK } from "../useSDK"; + +/** + * Get the configured `ThirdwebStorage` instance in the `ThirdwebProvider`. + * + * @returns The `storageInterface` configured on the `ThirdwebProvider` + * + * @example + * ```tsx + * const storage = useStorage(); + * + * cost resp = storage?.download("ipfs-url"); // Download a file from IPFS + * if (resp.ok) { + * const value = await resp?.json(); + * } + * + * const fileIpfsHash = await storage?.upload({ + * name: 'file1', + * type: 'file-mime-type', + * uri: 'file-uri-on-device', + * }); // Upload a file to IPFS + * const objIpfsHash = await storage?.upload({key: 'value'}); // Upload an object to IPFS + * const strIpfsHash = await storage?.upload('string-to-upload'); // Upload a string to IPFS + * ``` + */ +export function useStorage() { + const sdk = useSDK(); + return sdk?.storage; +} diff --git a/packages/react-core/src/evm/hooks/useENS.ts b/packages/react-core/src/evm/hooks/useENS.ts index 71d89afad73..c28017a3c03 100644 --- a/packages/react-core/src/evm/hooks/useENS.ts +++ b/packages/react-core/src/evm/hooks/useENS.ts @@ -5,6 +5,10 @@ import { useAddress } from "./wallet"; import { useSupportedChains } from "./useSupportedChains"; import { useWalletContext } from "../../core/providers/thirdweb-wallet-provider"; +/** + * + * @internal + */ export function useENS() { const address = useAddress(); const supportedChains = useSupportedChains(); diff --git a/packages/react-core/src/evm/hooks/useNetworkMismatch.ts b/packages/react-core/src/evm/hooks/useNetworkMismatch.ts index 0a15f7c2303..ad1307e1452 100644 --- a/packages/react-core/src/evm/hooks/useNetworkMismatch.ts +++ b/packages/react-core/src/evm/hooks/useNetworkMismatch.ts @@ -8,7 +8,7 @@ import { useChainId } from "./wallet"; * import { useNetworkMismatch } from "@thirdweb-dev/react" * ``` * - * @returns `true` if the chainId of the connected wallet is different from the chainId of the network passed into + * @returns `true` if the chainId of the connected wallet is different from the chainId of the network passed into `` * * @see {@link https://portal.thirdweb.com/react/react.usenetworkmismatch?utm_source=sdk | Documentation} * diff --git a/packages/react-core/src/evm/hooks/wallet.ts b/packages/react-core/src/evm/hooks/wallet.ts index 6208630b4bd..30769e41ad8 100644 --- a/packages/react-core/src/evm/hooks/wallet.ts +++ b/packages/react-core/src/evm/hooks/wallet.ts @@ -17,7 +17,6 @@ import { useWalletContext } from "../../core/providers/thirdweb-wallet-provider" * * @param tokenAddress - the address of the token contract, if empty will use the chain's native token * @returns the balance of the connected wallet (native or ERC20) - * @beta */ export function useBalance(tokenAddress?: ContractAddress) { const walletAddress = useAddress(); diff --git a/packages/react-core/src/evm/index.ts b/packages/react-core/src/evm/index.ts index 5ed1b018cab..1c3ef5a67e6 100644 --- a/packages/react-core/src/evm/index.ts +++ b/packages/react-core/src/evm/index.ts @@ -219,32 +219,30 @@ export { // thirdweb hooks (work as long as at least `` is used) // auth hooks -export { - useLogin, - useLogout, - useUser, - useAuth, - useSwitchAccount, -} from "./hooks/auth"; -export type { UserWithData } from "./hooks/auth"; +export { useAuth } from "./hooks/auth/useAuth"; +export { useLogin } from "./hooks/auth/useLogin"; +export { useLogout } from "./hooks/auth/useLogout"; +export { useUser } from "./hooks/auth/useUser"; +export { useSwitchAccount } from "./hooks/auth/useSwitchAccount"; + +export type { UserWithData } from "./hooks/auth/useUser"; // contract hooks -export { - useEditionDrop, - useEdition, - useNFTDrop, - useMarketplace, - useNFTCollection, - usePack, - useToken, - useTokenDrop, - useVote, - useSplit, - useMultiwrap, - useSignatureDrop, -} from "./hooks/contracts"; +export { useEditionDrop } from "./hooks/contracts/useEditionDrop"; +export { useEdition } from "./hooks/contracts/useEdition"; +export { useNFTDrop } from "./hooks/contracts/useNFTDrop"; +export { useMarketplace } from "./hooks/contracts/useMarketplace"; +export { useNFTCollection } from "./hooks/contracts/useNFTCollection"; +export { usePack } from "./hooks/contracts/usePack"; +export { useToken } from "./hooks/contracts/useToken"; +export { useTokenDrop } from "./hooks/contracts/useTokenDrop"; +export { useVote } from "./hooks/contracts/useVote"; +export { useSplit } from "./hooks/contracts/useSplit"; +export { useMultiwrap } from "./hooks/contracts/useMultiwrap"; +export { useSignatureDrop } from "./hooks/contracts/useSignatureDrop"; -export { useStorageUpload, useStorage } from "./hooks/storage"; +export { useStorage } from "./hooks/storage/useStorage"; +export { useStorageUpload } from "./hooks/storage/useStorageUpload"; export { useNetworkMismatch } from "./hooks/useNetworkMismatch"; export { useReadonlySDK } from "./hooks/useReadonlySDK"; export { useSigner } from "./hooks/useSigner"; diff --git a/packages/react-core/src/evm/providers/thirdweb-sdk-provider.tsx b/packages/react-core/src/evm/providers/thirdweb-sdk-provider.tsx index 914e17ab60d..616290ac66b 100644 --- a/packages/react-core/src/evm/providers/thirdweb-sdk-provider.tsx +++ b/packages/react-core/src/evm/providers/thirdweb-sdk-provider.tsx @@ -152,23 +152,47 @@ const WrappedThirdwebSDKProvider = ({ }; /** - * A basic wrapper around the Thirdweb SDK. + * The `ThirdwebSDKProvider` is used when you want to provide your own wallet connection logic and just use the thirdweb SDK to interact with smart contracts and the blockchain. + * This means you can use everything in the SDK except for wallet connection-related components and hooks. if you need those please use the `ThirdwebProvider` instead. * - * You can use this in order to be able to pass a provider & signer directly to the SDK. + * `ThirdwebSDKProvider` allows you to set a provider & signer to the Thirdweb SDK. * - * @remarks Utilizing this provider will mean hooks for wallet management are not available, if you need those please use the {@link ThirdwebProvider} instead. + * @example + * Wrap your app in the ThirdwebSDKProvider to access the SDK’s functionality from anywhere in your app. + * + * ```tsx + * import { ThirdwebSDKProvider } from "@thirdweb-dev/react"; + * import { ethers } from "ethers"; + * + * // Example shows how to get the signer from the injected provider ( wallet extension ) + * function Example() { + * return ( + * + * + * + * ) + * } + * ``` * * @public */ -export const ThirdwebSDKProvider = ({ - signer, - children, - queryClient, - supportedChains: _supportedChains, - activeChain, - clientId, - ...restProps -}: React.PropsWithChildren>) => { +export const ThirdwebSDKProvider = ( + props: React.PropsWithChildren>, +) => { + const { + signer, + children, + queryClient, + supportedChains: _supportedChains, + activeChain, + clientId, + ...restProps + } = props; + if (!clientId) { checkClientIdOrSecretKey( "No API key. Please provide a clientId. It is required to access thirdweb's services. You can create a key at https://thirdweb.com/create-api-key", diff --git a/packages/react-core/src/evm/providers/types.ts b/packages/react-core/src/evm/providers/types.ts index 851b30eab45..24ba698bd88 100644 --- a/packages/react-core/src/evm/providers/types.ts +++ b/packages/react-core/src/evm/providers/types.ts @@ -8,29 +8,97 @@ import type { Signer } from "ethers"; export interface ThirdwebSDKProviderProps extends QueryClientProviderProps { /** - * Chains to support. If not provided, will default to the chains supported by the SDK. + * An array of chains supported by your app. + * There are 1000+ chains available in the `@thirdweb-dev/chains` package. You can import the chain you want and pass it to the `supportedChains` prop in an array. + * + * If not provided, it will default to the default supported chains supported by the thirdweb SDK. + * + * @example + * ```tsx + * import { Ethereum, Polygon } from "@thirdweb-dev/chains"; + * + * function Example() { + * return ( + * + * + * + * ) + * } + * ``` */ supportedChains?: TChains; - // a possible signer - optional, defaults to undefined + + /** + * A signer is an abstraction of an Ethereum Account, which can be used to sign messages and initiate transactions. + * + * Since the ThirdwebSDKProvider is used when you want to provide your own wallet connection logic, you will need to provide a signer prop to inform the SDK of the wallet you want to use to sign transactions. + * + * Libraries such as ethers.js, web3.js, wagmi, etc. all provide ways to get a signer. + * + * To use this signer with the SDK, pass it to the `signer` prop. If the signer is connected, the SDK will use this wallet to sign transactions for all write operations on the blockchain. + */ signer?: Signer; /** - * The {@link SDKOptions | Thirdweb SDK Options} to pass to the thirdweb SDK - * comes with sensible defaults + * The thirdweb SDK Options to pass to the thirdweb SDK which includes Gas settings, gasless transactions, RPC configuration, and more. + * + * This Overrides any of the default values for the SDK. If not provided, it uses sensible defaults. */ sdkOptions?: Omit; + /** - * The storage interface to use with the sdk. + * Override the default [Storage](https://portal.thirdweb.com/storage) interface used by the SDK. + * + * It allows you to create an instance of `ThirdwebStorage` with your own customized config, and pass it to the SDK. + * + * *This requires the `@thirdweb-dev/storage` package to be installed.* + * + * @example + * ```tsx + * import { ThirdwebSDKProvider } from "@thirdweb-dev/react"; + * import { + * ThirdwebStorage, + * StorageDownloader, + * IpfsUploader, + * } from "@thirdweb-dev/storage"; + * + * // Configure a custom ThirdwebStorage instance + * const gatewayUrls = { + * "ipfs://": [ + * "https://gateway.ipfscdn.io/ipfs/", + * "https://cloudflare-ipfs.com/ipfs/", + * "https://ipfs.io/ipfs/", + * ], + * }; + * const downloader = new StorageDownloader(); + * const uploader = new IpfsUploader(); + * const storage = new ThirdwebStorage({ uploader, downloader, gatewayUrls }); + * + * // Provide the custom storage instance to the SDK + * function MyApp() { + * return ( + * + * + * + * ); + * } + * ``` */ storageInterface?: IThirdwebStorage; + /** - * The configuration used for thirdweb auth usage. Enables users to login - * to backends with their wallet. + * The configuration object for setting up [Auth](https://portal.thirdweb.com/auth); allowing users to sign in with their wallet. */ authConfig?: ThirdwebAuthConfig; /** - * The network to use for the SDK. + * The activeChain prop determines which chain you want your app to be operating on. + * + * There are 1000+ chains available in the `@thirdweb-dev/chains` package. Import the chain you want and pass it to the `activeChain` prop. + * + * You can override the imported object or pass a custom chain object with required properties. */ activeChain?: | TChains[number]["chainId"] @@ -43,9 +111,16 @@ export interface ThirdwebSDKProviderProps | (string & {}) | Chain; - // client Id for thirdweb services + /** + * The clientId prop is required to use the thirdweb infrastructure services with the SDK. + * + * You can get a client ID by creating an API key on [thirdweb dashboard](https://thirdweb.com/dashboard/settings/api-keys) + */ clientId?: string; - // pass in a secret key when doing server side rendering + /** + * secretKey for thirdweb services + * This is only required if server side rendering is being used. + */ secretKey?: string; } diff --git a/packages/react-core/src/evm/types.ts b/packages/react-core/src/evm/types.ts index a3e56eda499..04d964bfb7c 100644 --- a/packages/react-core/src/evm/types.ts +++ b/packages/react-core/src/evm/types.ts @@ -3,9 +3,7 @@ import type { AirdropInput, Amount, Erc721, - Erc721Mintable, Erc1155, - Erc1155Mintable, ListingType, NFTMetadataInput, Price, @@ -54,20 +52,17 @@ export type Chain = { /** * A wallet address. - * @beta */ export type WalletAddress = AddressOrEns; /** * A contract address. - * @beta */ export type ContractAddress = AddressOrEns; /** * The parameters to pass to the mint and transfer functions. * - * @beta */ export type TokenParams = { to: WalletAddress; @@ -77,7 +72,6 @@ export type TokenParams = { /** * The parameters to pass to the burn function. * - * @beta */ export type TokenBurnParams = { amount: Amount; @@ -91,7 +85,6 @@ export type TokenBurnParams = { * ```javascript * const { contract } = useContract("{{contract_address}}"); * ``` - * @beta */ export type NFTContract = | NFTCollection @@ -106,19 +99,16 @@ export type NFTContract = * ```javascript * const { contract } = useContract("{{contract_address}}"); * ``` - * @beta */ export type TokenContract = TokenDrop | Token | SmartContract | null; /** * Possible NFT contract types. - * @beta */ export type Erc721OrErc1155 = Erc721 | Erc1155; /** * The params to pass to `useTransferNFT`. - * @beta */ export type TransferNFTParams = { to: WalletAddress; @@ -128,7 +118,6 @@ export type TransferNFTParams = { /** * The params to pass to `useTransferBatchNFT`. - * @beta */ export type AirdropNFTParams = { tokenId: BigNumberish; @@ -137,7 +126,6 @@ export type AirdropNFTParams = { /** * The params to pass to `useMintNFTSupply`. - * @beta */ export type MintNFTSupplyParams = { tokenId: BigNumberish; @@ -148,7 +136,6 @@ export type MintNFTSupplyParams = { /** * The params for the {@link useMintNFT} hook mutation. * - * @beta */ export type MintNFTParams = { metadata: NFTMetadataOrUri; @@ -159,18 +146,16 @@ export type MintNFTParams = { /** * The return type of the {@link useMintNFT} hook. * - * @beta */ export type MintNFTReturnType = TContract extends Erc721 - ? Awaited> + ? Awaited> : TContract extends Erc1155 - ? Awaited> + ? Awaited> : never; /** * The params for the {@link useBurnNFT} hook mutation. * - * @beta */ export type BurnNFTParams = { tokenId: BigNumberish; amount?: Amount }; @@ -178,7 +163,6 @@ export type BurnNFTParams = { tokenId: BigNumberish; amount?: Amount }; /** * The possible DROP contract types. - * @beta */ export type DropContract = | NFTDrop @@ -190,14 +174,12 @@ export type DropContract = /** * The possible revealable contract types. - * @beta */ export type RevealableContract = NFTDrop | SignatureDrop | SmartContract | null; /** * The params for the {@link useDelayedRevealLazyMint} hook mutation. * - * @beta */ export type DelayedRevealLazyMintInput = { placeholder: NFTMetadataInput; @@ -208,7 +190,6 @@ export type DelayedRevealLazyMintInput = { /** * The params for the {@link useRevealLazyMint} hook mutation. * - * @beta */ export type RevealLazyMintInput = { batchId: BigNumberish; @@ -218,7 +199,6 @@ export type RevealLazyMintInput = { /** * The params for the {@link useClaimNFT} hook mutation. * - * @beta */ export type ClaimNFTParams = { to?: WalletAddress; @@ -233,7 +213,6 @@ export type ClaimNFTParams = { /** * The return type of the {@link useClaimNFT} hook. * - * @beta */ export type ClaimNFTReturnType = | Awaited> @@ -284,6 +263,9 @@ export type ClaimTokenParams = { // Helpers +/** + * @internal + */ export function getErcs(contract: RequiredParam) { return { erc1155: getErc1155(contract), @@ -292,6 +274,9 @@ export function getErcs(contract: RequiredParam) { }; } +/** + * @internal + */ export function getErc1155( contract: RequiredParam, ): Erc1155 | undefined { @@ -308,6 +293,9 @@ export function getErc1155( return undefined; } +/** + * @internal + */ export function getErc721( contract: RequiredParam, ): Erc721 | undefined { @@ -324,6 +312,9 @@ export function getErc721( return undefined; } +/** + * @internal + */ export function getErc20( contract: RequiredParam, ): Erc20 | undefined { diff --git a/packages/react-core/src/evm/utils/addresses.ts b/packages/react-core/src/evm/utils/addresses.ts index 5fcc9694de5..32d937b68b8 100644 --- a/packages/react-core/src/evm/utils/addresses.ts +++ b/packages/react-core/src/evm/utils/addresses.ts @@ -1,5 +1,8 @@ import { utils } from "ethers"; +/** + * @internal + */ export function shortenString(str: string, extraShort: boolean = true) { return `${str.substring(0, extraShort ? 4 : 6)}...${str.substring( str.length - (extraShort ? 3 : 4), @@ -36,6 +39,9 @@ export function shortenAddress( } } +/** + * @internal + */ export function shortenIfAddress( address?: string | null | false, extraShort: boolean = true, @@ -46,10 +52,16 @@ export function shortenIfAddress( return address || ""; } +/** + * @internal + */ export function isEnsName(name: string): boolean { return name?.endsWith(".eth"); } +/** + * @internal + */ export function isPossibleEVMAddress(address?: string, ignoreEns?: boolean) { if (!address) { return false; diff --git a/packages/react-native-compat/CHANGELOG.md b/packages/react-native-compat/CHANGELOG.md index 8d214a3ee73..ce48ee78fdd 100644 --- a/packages/react-native-compat/CHANGELOG.md +++ b/packages/react-native-compat/CHANGELOG.md @@ -1,5 +1,15 @@ # @thirdweb-dev/react-native-compat +## 0.5.0 + +## 0.4.14 + +## 0.4.13 + +## 0.4.12 + +## 0.4.11 + ## 0.4.10 ## 0.4.9 diff --git a/packages/react-native-compat/package.json b/packages/react-native-compat/package.json index 28b562adc20..884a8132506 100644 --- a/packages/react-native-compat/package.json +++ b/packages/react-native-compat/package.json @@ -1,7 +1,7 @@ { "name": "@thirdweb-dev/react-native-compat", "description": "Shims for Thirdweb in React Native Projects", - "version": "0.4.10", + "version": "0.5.0", "author": "thirdweb eng ", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat", "license": "Apache-2.0", diff --git a/packages/react-native/CHANGELOG.md b/packages/react-native/CHANGELOG.md index 2ae4e2792cd..6fc4216594e 100644 --- a/packages/react-native/CHANGELOG.md +++ b/packages/react-native/CHANGELOG.md @@ -1,5 +1,77 @@ # @thirdweb-dev/react-native +## 0.5.0 + +### Minor Changes + +- [#2018](https://github.com/thirdweb-dev/js/pull/2018) [`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba) Thanks [@iketw](https://github.com/iketw)! - Enforces passing an encryption key for custom jwt auth + + ```typescript + const embedded = useEmbeddedWallet(); + + embedded.connect({ + jwt: "", + encryptionKey: "", + strategy: "jwt", + }); + ``` + +### Patch Changes + +- [#2072](https://github.com/thirdweb-dev/js/pull/2072) [`2346396b`](https://github.com/thirdweb-dev/js/commit/2346396bdffeed169cdfc15839bfb42d87f24303) Thanks [@iketw](https://github.com/iketw)! - Adds analytics nonce to embedded wallet + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + - @thirdweb-dev/react-core@4.1.15 + +## 0.4.14 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + - @thirdweb-dev/react-core@4.1.14 + - @thirdweb-dev/wallets@2.2.1 + +## 0.4.13 + +### Patch Changes + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf), [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + - @thirdweb-dev/wallets@2.2.0 + - @thirdweb-dev/react-core@4.1.13 + +## 0.4.12 + +### Patch Changes + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +- [#2042](https://github.com/thirdweb-dev/js/pull/2042) [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and Type exports + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`34546c24`](https://github.com/thirdweb-dev/js/commit/34546c24c74f4e9e1f5e94567ebe1017ad63aea5), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e), [`cd87be4a`](https://github.com/thirdweb-dev/js/commit/cd87be4a24a9a3a552fbc4f33da6fcb08b7da88b), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + - @thirdweb-dev/react-core@4.1.12 + - @thirdweb-dev/storage@2.0.7 + - @thirdweb-dev/wallets@2.1.11 + +## 0.4.11 + +### Patch Changes + +- [#2025](https://github.com/thirdweb-dev/js/pull/2025) [`97ba1fbd`](https://github.com/thirdweb-dev/js/commit/97ba1fbd42d40d4a2ed5c3680115a147a1fa12f0) Thanks [@iketw](https://github.com/iketw)! - Adds version header to ews calls + +- [#2016](https://github.com/thirdweb-dev/js/pull/2016) [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8) Thanks [@iketw](https://github.com/iketw)! - Share WalletConnectHandler between React and RN to support wallets as receivers + +- Updated dependencies [[`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4), [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819), [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c), [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314)]: + - @thirdweb-dev/react-core@4.1.11 + - @thirdweb-dev/wallets@2.1.10 + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + - @thirdweb-dev/storage@2.0.6 + ## 0.4.10 ### Patch Changes diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 9b0e1118cb7..75c0d7201ba 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/react-native", - "version": "0.4.10", + "version": "0.5.0", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native", "author": "thirdweb eng ", "license": "Apache-2.0", @@ -17,7 +17,7 @@ "clean": "rm -rf dist/", "build": "tsc", "push": "yalc push", - "typedoc": "rimraf typedoc && node ./scripts/typedoc.js" + "typedoc": "node scripts/typedoc.mjs" }, "keywords": [ "react-native", @@ -83,7 +83,7 @@ "react-native-safe-area-context": "4.7.4", "react-native-webview": "12.1.0", "rimraf": "^3.0.2", - "typedoc": "^0.25.2", + "typedoc-gen": "workspace:*", "typescript": "^5.1.6" }, "optionalDependencies": { diff --git a/packages/react-native/scripts/typedoc.js b/packages/react-native/scripts/typedoc.js deleted file mode 100644 index 378bf065054..00000000000 --- a/packages/react-native/scripts/typedoc.js +++ /dev/null @@ -1,38 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const TypeDoc = require("typedoc"); - -async function main() { - // Application.bootstrap also exists, which will not load plugins - // Also accepts an array of option readers if you want to disable - // TypeDoc's tsconfig.json/package.json/typedoc.json option readers - const app = await TypeDoc.Application.bootstrapWithPlugins({ - entryPoints: ["src/index.ts"], - excludeInternal: true, - externalPattern: [ - "**/node_modules/**", - "**/packages/sdk/**", - "**/packages/wallets/**", - "**/packages/chains/**", - ], - exclude: [ - "**/node_modules/**", - "**/packages/sdk/**", - "**/packages/wallets/**", - "**/packages/chains/**", - ], - }); - - const project = await app.convert(); - - if (project) { - // Project may not have converted correctly - const outputDir = "typedoc/"; - - // Rendered docs - await app.generateDocs(project, outputDir); - // Alternatively generate JSON output - await app.generateJson(project, outputDir + "/documentation.json"); - } -} - -main(); diff --git a/packages/react-native/scripts/typedoc.mjs b/packages/react-native/scripts/typedoc.mjs new file mode 100644 index 00000000000..890df41aa34 --- /dev/null +++ b/packages/react-native/scripts/typedoc.mjs @@ -0,0 +1,13 @@ +// @ts-check +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: [ + "**/packages/sdk/**", + "**/packages/wallets/**", + "**/packages/react-core/**", + "**/packages/chains/**", + ], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/react-native/src/core/AsyncStorage.ts b/packages/react-native/src/core/AsyncStorage.ts index e350ed1aa74..e253b816bac 100644 --- a/packages/react-native/src/core/AsyncStorage.ts +++ b/packages/react-native/src/core/AsyncStorage.ts @@ -33,7 +33,9 @@ export class AsyncLocalStorage implements IAsyncStorage { ); } } - +/** + * @internal + */ export class LocalStorage implements SyncStorage { name: string; asyncStorage: MMKV; @@ -71,6 +73,8 @@ export class noopStorage implements IAsyncStorage { } /** + * @internal + * * Returns a new instance of AsyncLocalStorage * * @param name - Name to namespace the storage with @@ -81,6 +85,8 @@ export function createAsyncLocalStorage(name: string) { } /** + * @internal + * * Returns a new instance of LocalStorage * * @param name - Name to namespace the storage with diff --git a/packages/react-native/src/core/SecureStorage.ts b/packages/react-native/src/core/SecureStorage.ts index 31487fa432e..13e552bbcb3 100644 --- a/packages/react-native/src/core/SecureStorage.ts +++ b/packages/react-native/src/core/SecureStorage.ts @@ -29,6 +29,7 @@ export class SecureStorage implements ISecureStorage { } /** + * @internal * Returns a new instance of SecureStorage implemented by Expo SecureStore * * @param name - Name to namespace the storage with diff --git a/packages/react-native/src/core/storage/uploader.ts b/packages/react-native/src/core/storage/uploader.ts index c69bbf4a926..8c932d3dddd 100644 --- a/packages/react-native/src/core/storage/uploader.ts +++ b/packages/react-native/src/core/storage/uploader.ts @@ -5,10 +5,10 @@ import { TW_UPLOAD_SERVER_URL, } from "@thirdweb-dev/storage"; import { IpfsUploaderOptions, UploadDataValue } from "./types"; -import * as Application from "expo-application"; import { Platform } from "react-native"; +import { appBundleId, packageVersion } from "../../evm/utils/version"; +import { BUNDLE_ID_HEADER } from "../../evm/constants/headers"; -const APP_BUNDLE_ID = Application.applicationId; const METADATA_NAME = "Storage React Native SDK"; export class IpfsUploader implements IStorageUploader { @@ -39,9 +39,7 @@ export class IpfsUploader implements IStorageUploader { keyvalues: { ...options?.metadata }, }; - // this is on purpose because we can't import package.json as a module as it is outside rootDir - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { version, name: packageName } = require("../../../package.json"); + const { version, name: packageName } = packageVersion; const platform = `react-native-${Platform.OS}`; if ("uri" in data[0] && "type" in data[0] && "name" in data[0]) { @@ -143,7 +141,7 @@ export class IpfsUploader implements IStorageUploader { }); xhr.open("POST", `${TW_UPLOAD_SERVER_URL}/ipfs/upload`); - xhr.setRequestHeader("x-bundle-id", APP_BUNDLE_ID || ""); // only empty on web + xhr.setRequestHeader(BUNDLE_ID_HEADER, appBundleId || ""); // only empty on web if (this.clientId) { xhr.setRequestHeader("x-client-id", this.clientId); } @@ -168,7 +166,7 @@ export class IpfsUploader implements IStorageUploader { { method: "POST", headers: { - "x-bundle-id": APP_BUNDLE_ID || "", // only empty on web + [BUNDLE_ID_HEADER]: appBundleId || "", // only empty on web ...(this.clientId ? { "x-client-id": this.clientId } : {}), "Content-Type": "application/json", "x-sdk-version": version, diff --git a/packages/react-native/src/evm/components/ConnectWallet.tsx b/packages/react-native/src/evm/components/ConnectWallet.tsx index 51cef418abe..c6191af0fba 100644 --- a/packages/react-native/src/evm/components/ConnectWallet.tsx +++ b/packages/react-native/src/evm/components/ConnectWallet.tsx @@ -36,7 +36,7 @@ export type ConnectWalletProps = { /** * Hide option to request testnet funds for testnets in dropdown * - * @defaultValue false + * The default is `false` */ hideTestnetFaucet?: boolean; @@ -47,7 +47,7 @@ export type ConnectWalletProps = { * Please, note that if you support multiple networks in your app this prop should * be set to `false` to allow users to switch between networks. * - * @defaultValue false + * The default is `false` */ switchToActiveChain?: boolean; @@ -73,7 +73,7 @@ export type ConnectWalletProps = { /** * Hide the "switch to Personal wallet" option in the wallet modal which is shown when wallet is connected to a Smart Wallet * - * @defaultValue false + * The default is `false` */ hideSwitchToPersonalWallet?: boolean; } & ConnectWalletButtonProps; diff --git a/packages/react-native/src/evm/components/ConnectWalletDetails/WalletDetailsButton.tsx b/packages/react-native/src/evm/components/ConnectWalletDetails/WalletDetailsButton.tsx index 842bc5b86f1..846359bbeb3 100644 --- a/packages/react-native/src/evm/components/ConnectWalletDetails/WalletDetailsButton.tsx +++ b/packages/react-native/src/evm/components/ConnectWalletDetails/WalletDetailsButton.tsx @@ -39,7 +39,7 @@ export type ConnectWalletDetailsProps = { /** * Hide the "switch to Personal wallet" option in the dropdown which is shown when wallet is connected to a Smart Wallet * - * @defaultValue false + * The default is `false` */ hideSwitchToPersonalWallet?: boolean; }; diff --git a/packages/react-native/src/evm/components/ConnectWalletFlow/ConnectWalletButton.tsx b/packages/react-native/src/evm/components/ConnectWalletFlow/ConnectWalletButton.tsx index f59d26c1256..926702885de 100644 --- a/packages/react-native/src/evm/components/ConnectWalletFlow/ConnectWalletButton.tsx +++ b/packages/react-native/src/evm/components/ConnectWalletFlow/ConnectWalletButton.tsx @@ -13,12 +13,14 @@ export type ConnectWalletButtonProps = { theme?: ThemeProviderProps["theme"]; /** * Set a custom title for the button - * @defaultValue "Connect Wallet" + * + * The default is `"Connect Wallet"` */ buttonTitle?: string; /** * Set a custom title for the Connect Wallet modal - * @defaultValue "Choose your wallet" + * + * The default is `"Choose your wallet"` */ modalTitle?: string; /** diff --git a/packages/react-native/src/evm/components/Web3Button.tsx b/packages/react-native/src/evm/components/Web3Button.tsx index ddcb293aacd..84b6a91644c 100644 --- a/packages/react-native/src/evm/components/Web3Button.tsx +++ b/packages/react-native/src/evm/components/Web3Button.tsx @@ -20,7 +20,7 @@ import { ActivityIndicator, StyleSheet } from "react-native"; import invariant from "tiny-invariant"; import { useGlobalTheme, useUIContext } from "../providers/ui-context-provider"; -type ActionFn = (contract: SmartContract) => Promise; +export type ActionFn = (contract: SmartContract) => Promise; interface Web3ButtonProps { contractAddress: `0x${string}` | `${string}.eth` | string; diff --git a/packages/react-native/src/evm/components/base/ActiveDot.tsx b/packages/react-native/src/evm/components/base/ActiveDot.tsx index bd2754e4b31..f11342e039d 100644 --- a/packages/react-native/src/evm/components/base/ActiveDot.tsx +++ b/packages/react-native/src/evm/components/base/ActiveDot.tsx @@ -1,5 +1,8 @@ import { StyleSheet, View } from "react-native"; +/** + * @internal + */ export const ActiveDot = ({ width = 28, height = 28, diff --git a/packages/react-native/src/evm/components/base/BaseButton.tsx b/packages/react-native/src/evm/components/base/BaseButton.tsx index dee864f5bc6..f3f8a627eaa 100644 --- a/packages/react-native/src/evm/components/base/BaseButton.tsx +++ b/packages/react-native/src/evm/components/base/BaseButton.tsx @@ -2,6 +2,9 @@ import { Theme } from "../../styles/theme"; import { createBox } from "@shopify/restyle"; import { TouchableOpacity, TouchableOpacityProps } from "react-native"; +/** + * @internal + */ const BaseButton = createBox(TouchableOpacity); export default BaseButton; diff --git a/packages/react-native/src/evm/components/base/Box.tsx b/packages/react-native/src/evm/components/base/Box.tsx index 69a550ae5e4..4bf4ba621bb 100644 --- a/packages/react-native/src/evm/components/base/Box.tsx +++ b/packages/react-native/src/evm/components/base/Box.tsx @@ -1,6 +1,9 @@ import { Theme } from "../../styles/theme"; import { createBox } from "@shopify/restyle"; +/** + * @internal + */ const Box = createBox(); export default Box; diff --git a/packages/react-native/src/evm/components/base/ChainIcon.tsx b/packages/react-native/src/evm/components/base/ChainIcon.tsx index 0fb1a8bdf4d..a92f290bd05 100644 --- a/packages/react-native/src/evm/components/base/ChainIcon.tsx +++ b/packages/react-native/src/evm/components/base/ChainIcon.tsx @@ -9,6 +9,9 @@ export type ChainIconProps = { size: number; }; +/** + * @internal + */ export const ChainIcon = ({ chainIconUrl, size }: ChainIconProps) => { const src = chainIconUrl || defaultChainIcon; diff --git a/packages/react-native/src/evm/components/base/IconTextButton.tsx b/packages/react-native/src/evm/components/base/IconTextButton.tsx index 76ae900d4ac..cbcdf8ef3d1 100644 --- a/packages/react-native/src/evm/components/base/IconTextButton.tsx +++ b/packages/react-native/src/evm/components/base/IconTextButton.tsx @@ -11,6 +11,9 @@ type IconTextProps = { onPress: () => void; } & React.ComponentProps; +/** + * @internal + */ export const IconTextButton = ({ icon, onPress, diff --git a/packages/react-native/src/evm/components/base/ImageSvgUri.tsx b/packages/react-native/src/evm/components/base/ImageSvgUri.tsx index 7d0e336d95c..52572bca518 100644 --- a/packages/react-native/src/evm/components/base/ImageSvgUri.tsx +++ b/packages/react-native/src/evm/components/base/ImageSvgUri.tsx @@ -2,9 +2,12 @@ import { useStorage } from "@thirdweb-dev/react-core"; import { useState } from "react"; import { Image } from "react-native"; import { SvgUri, SvgXml } from "react-native-svg"; -import { isAppBundleIdPresentInGlobal } from "../../utils/global"; import Box from "./Box"; +import { appBundleId } from "../../utils/version"; +/** + * @internal + */ const ImageSvgUri = ({ imageUrl = "", width, @@ -24,10 +27,7 @@ const ImageSvgUri = ({ } const resolvedImageUrl = storage - ? storage.resolveScheme(imageUrl) + - (isAppBundleIdPresentInGlobal() - ? `?bundleId=${(globalThis as any).APP_BUNDLE_ID as string}` - : "") + ? storage.resolveScheme(imageUrl) + `?bundleId=${appBundleId}` : imageUrl.replace("ipfs://", "https://ipfs.io/ipfs/"); if (!resolvedImageUrl || resolvedImageUrl === "") { diff --git a/packages/react-native/src/evm/components/base/Label.tsx b/packages/react-native/src/evm/components/base/Label.tsx index 3a29d84056d..f9b8c2ec9ab 100644 --- a/packages/react-native/src/evm/components/base/Label.tsx +++ b/packages/react-native/src/evm/components/base/Label.tsx @@ -6,6 +6,9 @@ type LabelProps = { text: string; } & React.ComponentProps; +/** + * @internal + */ export const Label = ({ text, ...props }: LabelProps) => { return ( void; } & React.ComponentProps; +/** + * @internal + */ export const Link = ({ text, variant = "link", diff --git a/packages/react-native/src/evm/components/base/NetworkButton.tsx b/packages/react-native/src/evm/components/base/NetworkButton.tsx index f1787ab1f66..7ea90847a50 100644 --- a/packages/react-native/src/evm/components/base/NetworkButton.tsx +++ b/packages/react-native/src/evm/components/base/NetworkButton.tsx @@ -26,6 +26,9 @@ type NetworkButtonProps = { onChainSwitched?: () => void; } & React.ComponentProps; +/** + * @internal + */ export const NetworkButton = ({ onPress, chain, diff --git a/packages/react-native/src/evm/components/base/Text.tsx b/packages/react-native/src/evm/components/base/Text.tsx index d1d17b909cb..4baac4a4041 100644 --- a/packages/react-native/src/evm/components/base/Text.tsx +++ b/packages/react-native/src/evm/components/base/Text.tsx @@ -1,6 +1,9 @@ import { Theme } from "../../styles/theme"; import { createText } from "@shopify/restyle"; +/** + * @internal + */ const Text = createText(); export default Text; diff --git a/packages/react-native/src/evm/components/base/TextInput.tsx b/packages/react-native/src/evm/components/base/TextInput.tsx index af6d392e47f..95b66b9d275 100644 --- a/packages/react-native/src/evm/components/base/TextInput.tsx +++ b/packages/react-native/src/evm/components/base/TextInput.tsx @@ -11,6 +11,9 @@ type TextInputProps = { leftElement?: ReactNode; }; +/** + * @internal + */ export const TextInput = ({ containerProps, textInputProps, diff --git a/packages/react-native/src/evm/components/base/Toast.tsx b/packages/react-native/src/evm/components/base/Toast.tsx index 82dff9b5521..38a4fbc53b6 100644 --- a/packages/react-native/src/evm/components/base/Toast.tsx +++ b/packages/react-native/src/evm/components/base/Toast.tsx @@ -13,6 +13,9 @@ export type ToastProps = { translateY?: number; }; +/** + * @internal + */ export function Toast({ text, icon, diff --git a/packages/react-native/src/evm/components/base/WalletButton.tsx b/packages/react-native/src/evm/components/base/WalletButton.tsx index 2a6c1904f4f..eaa6afa95ec 100644 --- a/packages/react-native/src/evm/components/base/WalletButton.tsx +++ b/packages/react-native/src/evm/components/base/WalletButton.tsx @@ -18,6 +18,9 @@ type WalletButtonProps = { iconHeight?: number; } & React.ComponentProps; +/** + * @internal + */ export const WalletButton = ({ iconWidth = 48, iconHeight = 48, diff --git a/packages/react-native/src/evm/components/base/WalletIcon.tsx b/packages/react-native/src/evm/components/base/WalletIcon.tsx index c99ff2d961b..64ab2ea5758 100644 --- a/packages/react-native/src/evm/components/base/WalletIcon.tsx +++ b/packages/react-native/src/evm/components/base/WalletIcon.tsx @@ -1,6 +1,9 @@ import Box from "./Box"; import ImageSvgUri from "./ImageSvgUri"; +/** + * @internal + */ export const WalletIcon = ({ iconUri, size, diff --git a/packages/react-native/src/evm/components/base/modal/ModalFooter.tsx b/packages/react-native/src/evm/components/base/modal/ModalFooter.tsx index d3490133b93..e6752192e06 100644 --- a/packages/react-native/src/evm/components/base/modal/ModalFooter.tsx +++ b/packages/react-native/src/evm/components/base/modal/ModalFooter.tsx @@ -2,6 +2,9 @@ import { useGlobalTheme } from "../../../providers/ui-context-provider"; import Text from "../Text"; import { TouchableOpacity, StyleSheet, ActivityIndicator } from "react-native"; +/** + * @internal + */ export const ModalFooter = ({ footer, isLoading, diff --git a/packages/react-native/src/evm/components/base/modal/ModalHeaderTextClose.tsx b/packages/react-native/src/evm/components/base/modal/ModalHeaderTextClose.tsx index 851c6a28f23..69848393720 100644 --- a/packages/react-native/src/evm/components/base/modal/ModalHeaderTextClose.tsx +++ b/packages/react-native/src/evm/components/base/modal/ModalHeaderTextClose.tsx @@ -12,6 +12,9 @@ interface ModalHeaderTextCloseProps { onBackPress?: () => void; } +/** + * @internal + */ export const ModalHeaderTextClose = ({ headerText, subHeaderText, diff --git a/packages/react-native/src/evm/components/base/modal/TWModal.tsx b/packages/react-native/src/evm/components/base/modal/TWModal.tsx index 83afeadfcc9..a42b8e7654c 100644 --- a/packages/react-native/src/evm/components/base/modal/TWModal.tsx +++ b/packages/react-native/src/evm/components/base/modal/TWModal.tsx @@ -3,6 +3,9 @@ import Modal, { ModalProps } from "react-native-modal"; const MAX_WIDTH = 500; // Populate with the data... +/** + * @internal + */ export function TWModal(props: Partial) { return ( { if (typeof locale === "string") { switch (locale) { diff --git a/packages/react-native/src/evm/index.ts b/packages/react-native/src/evm/index.ts index b39897d7060..c7ee9afcb5b 100644 --- a/packages/react-native/src/evm/index.ts +++ b/packages/react-native/src/evm/index.ts @@ -38,7 +38,7 @@ export { ConnectWallet, type ConnectWalletProps, } from "./components/ConnectWallet"; -export { Web3Button } from "./components/Web3Button"; +export { Web3Button, type ActionFn } from "./components/Web3Button"; // utilities export * from "./utils/uri"; @@ -52,6 +52,9 @@ export * from "./i18n/types"; // ui components export * from "./components/base"; +/** + * @internal + */ export { ConnectWalletHeader } from "./components/ConnectWalletFlow/ConnectingWallet/ConnectingWalletHeader"; // assets / icons diff --git a/packages/react-native/src/evm/providers/thirdweb-provider.tsx b/packages/react-native/src/evm/providers/thirdweb-provider.tsx index b6a808e47b0..42c097e7e88 100644 --- a/packages/react-native/src/evm/providers/thirdweb-provider.tsx +++ b/packages/react-native/src/evm/providers/thirdweb-provider.tsx @@ -12,22 +12,29 @@ import { DEFAULT_WALLETS } from "../constants/wallets"; import { DappContextProvider } from "./context-provider"; import { UIContextProvider } from "./ui-context-provider"; import { MainModal } from "../components/MainModal"; -import { ThemeProvider } from "../styles/ThemeProvider"; +import { ThemeProvider, ThemeType } from "../styles/ThemeProvider"; import { SafeAreaProvider } from "react-native-safe-area-context"; import { walletIds } from "@thirdweb-dev/wallets"; import { ThirdwebStorage } from "../../core/storage/storage"; -import { useColorScheme } from "react-native"; import type { Locale } from "../i18n/types"; interface ThirdwebProviderProps extends Omit< ThirdwebProviderCoreProps, - "supportedWallets" | "secretKey" | "signer" + "supportedWallets" | "secretKey" | "signer" | "theme" > { /** * Wallets that will be supported by the dApp - * @defaultValue [MetaMaskWallet, CoinbaseWallet] * + * If no wallets are set, default wallets are used which is equivalent to the following: + * + * ```ts + * [ + * metamaskWallet(), + * rainbowWallet(), + * trustWallet() + * ] + *``` * @example * ```jsx * import { MetaMaskWallet, CoinbaseWallet } from "@thirdweb-dev/react-native"; @@ -39,9 +46,31 @@ interface ThirdwebProviderProps */ supportedWallets?: WalletConfig[]; + /** + * Set the theme for all thirdweb components + * + * By default it is set to "dark". + * + * theme can be set to either "dark" or "light" or a custom theme object. + * + * You can also import `lightTheme` or `darkTheme` functions from `@thirdweb-dev/react-native` to use the default themes as base and overrides parts of it. + * + * @example + * ```ts + * import { darkTheme } from "@thirdweb-dev/react-native"; + * const customTheme = darkTheme({ + * colors: { + * accentButtonColor: 'black', + * }, + * }) + * ``` + */ + theme?: ThemeType; + /** * Locale that the app will be displayed in - * @defaultValue en() + * + * By default it is set to `en()` * * @example * ```jsx @@ -78,10 +107,15 @@ interface ThirdwebProviderProps locale?: Locale; } +/** + * Array of default supported chains by the thirdweb SDK + */ +export type DefaultChains = typeof defaultChains; + /** * * The `` component lets you control what networks you want users to connect to, - * what types of wallets can connect to your app, and the settings for the [Thirdweb SDK](https://docs.thirdweb.com/typescript). + * what types of wallets can connect to your app, and the settings for the Thirdweb SDK. * * @example * You can wrap your application with the provider as follows: @@ -98,21 +132,21 @@ interface ThirdwebProviderProps * }; * ``` */ -export const ThirdwebProvider = < - TChains extends Chain[] = typeof defaultChains, ->({ - children, - createWalletStorage = createAsyncLocalStorage, - supportedWallets = DEFAULT_WALLETS, - authConfig, - theme, - storageInterface, - clientId, - sdkOptions, - locale = "en", - ...restProps -}: PropsWithChildren>) => { - const colorScheme = useColorScheme(); +export const ThirdwebProvider = ( + props: PropsWithChildren>, +) => { + const { + children, + createWalletStorage = createAsyncLocalStorage, + supportedWallets = DEFAULT_WALLETS, + authConfig, + theme, + storageInterface, + clientId, + sdkOptions, + locale = "en", + ...restProps + } = props; const coinbaseWalletObj = supportedWallets.find( (w) => w.id === walletIds.coinbase, @@ -152,9 +186,7 @@ export const ThirdwebProvider = < {...sdkOptions} {...restProps} > - + {hasMagicConfig ? ( diff --git a/packages/react-native/src/evm/styles/ThemeProvider.tsx b/packages/react-native/src/evm/styles/ThemeProvider.tsx index 6cac2dfc722..f27551109a6 100644 --- a/packages/react-native/src/evm/styles/ThemeProvider.tsx +++ b/packages/react-native/src/evm/styles/ThemeProvider.tsx @@ -5,8 +5,10 @@ import { PropsWithChildren, useContext } from "react"; import { useColorScheme } from "react-native"; import { useUIContext } from "../providers/ui-context-provider"; +export type ThemeType = "dark" | "light" | Theme; + export type ThemeProviderProps = { - theme?: Theme | "light" | "dark"; + theme?: ThemeType; }; export function ThemeProvider({ diff --git a/packages/react-native/src/evm/utils/uri.ts b/packages/react-native/src/evm/utils/uri.ts index 312335d785d..ecf31cacece 100644 --- a/packages/react-native/src/evm/utils/uri.ts +++ b/packages/react-native/src/evm/utils/uri.ts @@ -2,6 +2,8 @@ import { Chain, getValidChainRPCs } from "@thirdweb-dev/chains"; import { WCMeta } from "../wallets/types/wc"; /** + * @internal + * * Build a WalletConnect display URI from a wc:// uri + a wallet specific link * * @param uri - The wc:// uri @@ -22,6 +24,9 @@ export function formatWalletConnectDisplayUri( : `${uri}`; } +/** + * @internal + */ export function getValidPublicRPCUrl(chain: Chain) { return getValidChainRPCs(chain).map((rpc) => { try { diff --git a/packages/react-native/src/evm/utils/version.ts b/packages/react-native/src/evm/utils/version.ts new file mode 100644 index 00000000000..e4145e95993 --- /dev/null +++ b/packages/react-native/src/evm/utils/version.ts @@ -0,0 +1,12 @@ +import * as Application from "expo-application"; + +export const packageVersion: { + version: string; + name: string; + // this is on purpose because we can't import package.json as a module as it is outside rootDir + // eslint-disable-next-line @typescript-eslint/no-var-requires +} = require("../../../package.json"); + +export const reactNativePackageVersion = `react-native:${packageVersion.version}`; + +export const appBundleId = Application.applicationId || ""; diff --git a/packages/react-native/src/evm/wallets/connectors/coinbase-wallet/index.ts b/packages/react-native/src/evm/wallets/connectors/coinbase-wallet/index.ts index 26e4b746cff..b30eb62e2a2 100644 --- a/packages/react-native/src/evm/wallets/connectors/coinbase-wallet/index.ts +++ b/packages/react-native/src/evm/wallets/connectors/coinbase-wallet/index.ts @@ -23,12 +23,14 @@ export type CoinbaseWalletConnectorOptions = WalletMobileSDKProviderOptions & ConfigurationParams & { /** * Fallback Ethereum JSON RPC URL - * @defaultValue "" + * + * By default it is set to `""` */ jsonRpcUrl?: string; /** * Fallback Ethereum Chain ID - * @defaultValue 1 + * + * By default it is set to `1` */ chainId?: number; }; diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded-connector.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded-connector.ts index 394dc4c8113..b01b3a0497a 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded-connector.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded-connector.ts @@ -1,4 +1,5 @@ import { + AuthEndpointOptions, AuthOptions, AuthParams, AuthResult, @@ -11,6 +12,7 @@ import type { Chain } from "@thirdweb-dev/chains"; import { providers, Signer } from "ethers"; import { utils } from "ethers"; import { + authEndpoint, customJwt, sendVerificationEmail, socialLogin, @@ -101,7 +103,13 @@ export class EmbeddedWalletConnector extends Connector { + try { + const { verifiedToken, email } = await authEndpoint( + authOptions, + this.options.clientId, + ); + this.email = email; + return { + user: { + status: UserWalletStatus.LOGGED_IN_WALLET_INITIALIZED, + recoveryShareManagement: + verifiedToken.authDetails.recoveryShareManagement, + }, + isNewUser: verifiedToken.isNewUser, + needsRecoveryCode: + verifiedToken.authDetails.recoveryShareManagement === + RecoveryShareManagement.USER_MANAGED, + }; + } catch (error) { + console.error(`Error while verifying auth_endpoint auth: ${error}`); + this.disconnect(); + throw error; + } + } + async disconnect(): Promise { clearConnectedEmail(); clearConnectedAuthStrategy(); diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/auth.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/auth.ts index 8ad67b5a23c..38aded57990 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/auth.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/auth.ts @@ -26,12 +26,26 @@ import { isDeviceSharePresentForUser } from "./helpers/storage/local"; import { Auth } from "aws-amplify"; import { DOMAIN_URL_2023, + EWS_VERSION_HEADER, + ROUTE_AUTH_ENDPOINT_CALLBACK, ROUTE_AUTH_JWT_CALLBACK, ROUTE_HEADLESS_OAUTH_LOGIN, + THIRDWEB_SESSION_NONCE_HEADER, } from "./helpers/constants"; -import { AuthOptions, OauthOption, VerifiedTokenResponse } from "../types"; +import { + AuthEndpointOptions, + AuthOptions, + OauthOption, + VerifiedTokenResponse, +} from "../types"; import { InAppBrowser } from "react-native-inappbrowser-reborn"; import { createErrorMessage } from "./helpers/errors"; +import { + appBundleId, + reactNativePackageVersion, +} from "../../../../utils/version"; +import { BUNDLE_ID_HEADER } from "../../../../constants/headers"; +import { ANALYTICS } from "./helpers/analytics"; export async function sendVerificationEmail(options: { email: string; @@ -179,7 +193,13 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) { DOMAIN_URL_2023, )}&platform=${encodeURIComponent("mobile")}`; - const resp = await fetch(headlessLoginLinkWithParams); + const resp = await fetch(headlessLoginLinkWithParams, { + headers: { + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [BUNDLE_ID_HEADER]: appBundleId, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, + }, + }); if (!resp.ok) { const error = await resp.json(); @@ -256,7 +276,12 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) { const resp = await fetch(ROUTE_AUTH_JWT_CALLBACK, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { + "Content-Type": "application/json", + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [BUNDLE_ID_HEADER]: appBundleId, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, + }, body: JSON.stringify({ jwt: jwt, developerClientId: clientId, @@ -288,7 +313,62 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) { return { verifiedToken, email: verifiedToken.authDetails.email }; } catch (e) { throw new Error( - createErrorMessage("Malformed response from post authentication", e), + createErrorMessage("Malformed response from post jwt authentication", e), + ); + } +} + +export async function authEndpoint( + authOptions: AuthEndpointOptions, + clientId: string, +) { + const { payload, encryptionKey } = authOptions; + + const resp = await fetch(ROUTE_AUTH_ENDPOINT_CALLBACK, { + method: "POST", + headers: { + "Content-Type": "application/json", + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [BUNDLE_ID_HEADER]: appBundleId, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, + }, + body: JSON.stringify({ + payload: payload, + developerClientId: clientId, + }), + }); + if (!resp.ok) { + const error = await resp.json(); + throw new Error( + `Custom auth endpoint authentication error: ${error.message}`, + ); + } + + try { + const { verifiedToken, verifiedTokenJwtString } = await resp.json(); + + const toStoreToken: AuthStoredTokenWithCookieReturnType["storedToken"] = { + jwtToken: verifiedToken.jwtToken, + authProvider: verifiedToken.authProvider, + authDetails: { + ...verifiedToken.authDetails, + email: verifiedToken.authDetails.email, + }, + developerClientId: verifiedToken.developerClientId, + cookieString: verifiedTokenJwtString, + shouldStoreCookieString: true, + isNewUser: verifiedToken.isNewUser, + }; + + await postPaperAuthUserManaged(toStoreToken, clientId, encryptionKey); + + return { verifiedToken, email: verifiedToken.authDetails.email }; + } catch (e) { + throw new Error( + createErrorMessage( + "Malformed response from post auth_endpoint authentication", + e, + ), ); } } diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/analytics.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/analytics.ts new file mode 100644 index 00000000000..6d95f02d7b8 --- /dev/null +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/analytics.ts @@ -0,0 +1,5 @@ +import { getRandomString } from "./getRandomValues"; + +export const ANALYTICS = { + nonce: getRandomString(16), +}; diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/api/fetchers.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/api/fetchers.ts index 3a2ebf7f94c..45e994378fd 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/api/fetchers.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/api/fetchers.ts @@ -7,9 +7,10 @@ import { ROUTE_USER_MANAGED_OTP, ROUTE_VALIDATE_USER_MANAGED_OTP, ROUTE_IS_VALID_USER_MANAGED_OTP, + EWS_VERSION_HEADER, + THIRDWEB_SESSION_NONCE_HEADER, } from "../constants"; import { getAuthTokenClient } from "../storage/local"; -import * as Application from "expo-application"; import { RecoveryShareManagement, UserWalletStatus, @@ -19,18 +20,27 @@ import { VerifiedTokenResponse, } from "../../../types"; import { createErrorMessage } from "../errors"; +import { + appBundleId, + reactNativePackageVersion, +} from "../../../../../../utils/version"; +import { BUNDLE_ID_HEADER } from "../../../../../../constants/headers"; +import { ANALYTICS } from "../analytics"; const EMBEDDED_WALLET_TOKEN_HEADER = "embedded-wallet-token"; const PAPER_CLIENT_ID_HEADER = "x-thirdweb-client-id"; -const BUNDLE_ID_HEADER = "x-bundle-id"; -const APP_BUNDLE_ID = Application.applicationId || ""; +const HEADERS = { + "Content-Type": "application/json", + [BUNDLE_ID_HEADER]: appBundleId, + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, +}; export const verifyClientId = async (clientId: string) => { const resp = await fetch(ROUTE_VERIFY_THIRDWEB_CLIENT_ID, { method: "POST", headers: { - "Content-Type": "application/json", - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + ...HEADERS, }, body: JSON.stringify({ clientId, parentDomain: "" }), }); @@ -58,15 +68,19 @@ export const authFetchEmbeddedWalletUser = async ( Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${ authTokenClient || "" }`, - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + [BUNDLE_ID_HEADER]: appBundleId, [PAPER_CLIENT_ID_HEADER]: clientId, + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, } : { Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${ authTokenClient || "" }`, - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + [BUNDLE_ID_HEADER]: appBundleId, [PAPER_CLIENT_ID_HEADER]: clientId, + [EWS_VERSION_HEADER]: reactNativePackageVersion, + [THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce, }; return fetch(url, params); }; @@ -118,8 +132,7 @@ export async function generateAuthTokenFromCognitoEmailOtp( const resp = await fetch(ROUTE_VERIFY_COGNITO_OTP, { method: "POST", headers: { - "Content-Type": "application/json", - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + ...HEADERS, }, body: JSON.stringify({ access_token: session.getAccessToken().getJwtToken(), @@ -143,8 +156,7 @@ export async function sendUserManagedEmailOtp(email: string, clientId: string) { const resp = await fetch(ROUTE_USER_MANAGED_OTP, { method: "POST", headers: { - "Content-Type": "application/json", - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + ...HEADERS, }, body: JSON.stringify({ email, @@ -169,8 +181,7 @@ export async function validateUserManagedEmailOtp(options: { const resp = await fetch(ROUTE_VALIDATE_USER_MANAGED_OTP, { method: "POST", headers: { - "Content-Type": "application/json", - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + ...HEADERS, }, body: JSON.stringify({ email: options.email, @@ -195,8 +206,7 @@ export async function isValidUserManagedEmailOtp(options: { const resp = await fetch(ROUTE_IS_VALID_USER_MANAGED_OTP, { method: "POST", headers: { - "Content-Type": "application/json", - [BUNDLE_ID_HEADER]: APP_BUNDLE_ID, + ...HEADERS, }, body: JSON.stringify({ email: options.email, diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/cognitoAuth.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/cognitoAuth.ts index 0f78002ed60..5c180ab40d8 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/cognitoAuth.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/cognitoAuth.ts @@ -4,7 +4,7 @@ import { COGNITO_APP_CLIENT_ID, COGNITO_USER_POOL_ID, } from "../constants"; -import { getRandomValues } from "../getRandomValues"; +import { getRandomString } from "../getRandomValues"; Amplify.configure({ Auth: { @@ -25,13 +25,6 @@ export async function cognitoEmailSignUp(email: string, clientId: string) { await Auth.signOut(); } -function getRandomString(bytes: number) { - const randomValues = getRandomValues(new Uint8Array(bytes)); - return Array.from(randomValues) - .map((nr) => nr.toString(16).padStart(2, "0")) - .join(""); -} - export async function cognitoEmailSignIn(email: string, clientId: string) { const cognitoUser = await Auth.signIn(`${email}:email:${clientId}`); return cognitoUser; diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/middleware.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/middleware.ts index 9ff76a9de66..eceee8c2ce0 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/middleware.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/auth/middleware.ts @@ -127,15 +127,16 @@ async function getRecoveryCode( storedToken.authDetails.recoveryShareManagement === RecoveryShareManagement.CLOUD_MANAGED ) { - if (storedToken.authProvider === AuthProvider.CUSTOM_JWT) { - // derive sub here - const code = extractSubFromJwt(storedToken.jwtToken); - if (!code) { + if ( + storedToken.authProvider === AuthProvider.CUSTOM_JWT || + storedToken.authProvider === AuthProvider.CUSTOM_AUTH_ENDPOINT + ) { + if (!recoveryCode) { throw new Error( `GetRecoveryCode error: ${ErrorMessages.missingRecoveryCode}`, ); } - return code; + return recoveryCode; } else { try { const code = await getCognitoRecoveryPassword(clientId); @@ -156,25 +157,3 @@ async function getRecoveryCode( throw new Error("Invalid recovery share management option"); } } - -function extractSubFromJwt(jwtToken: string): string | undefined { - const parts = jwtToken.split("."); - if (parts.length !== 3) { - throw new Error("Invalid JWT format."); - } - - const encodedPayload = parts[1]; - if (!encodedPayload) { - throw new Error("Invalid JWT format."); - } - const decodedPayload = Buffer.from(encodedPayload, "base64").toString("utf8"); - - try { - const payloadObject = JSON.parse(decodedPayload); - if (payloadObject && payloadObject.sub) { - return payloadObject.sub; - } - } catch (error) { - throw new Error("Error parsing JWT payload as JSON."); - } -} diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/constants.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/constants.ts index 555ee12e225..a0840730b13 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/constants.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/constants.ts @@ -12,6 +12,9 @@ export const RECOVERY_SHARE_INDEX = RECOVERY_SHARE_ID - 1; export const AWS_REGION = "us-west-2"; +export const EWS_VERSION_HEADER = "x-embedded-wallet-version"; +export const THIRDWEB_SESSION_NONCE_HEADER = "x-session-nonce"; + export const COGNITO_USER_POOL_ID = "us-west-2_UFwLcZIpq"; export const COGNITO_APP_CLIENT_ID = "2e02ha2ce6du13ldk8pai4h3d0"; export const COGNITO_IDENTITY_POOL_ID = @@ -31,6 +34,7 @@ export const ROUTE_STORE_USER_SHARES = `${ROUTE_2023_10_20_API_BASE_PATH}/embedd export const ROUTE_GET_USER_SHARES = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/embedded-wallet-shares`; export const ROUTE_VERIFY_THIRDWEB_CLIENT_ID = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/verify-thirdweb-client-id`; export const ROUTE_AUTH_JWT_CALLBACK = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-custom-jwt`; +export const ROUTE_AUTH_ENDPOINT_CALLBACK = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-custom-auth-endpoint`; export const ROUTE_USER_MANAGED_OTP = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/send-user-managed-email-otp`; export const ROUTE_VALIDATE_USER_MANAGED_OTP = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-thirdweb-email-otp`; diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/getRandomValues.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/getRandomValues.ts index 2f30e5f00c4..e849a9c8bdc 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/getRandomValues.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/embedded/helpers/getRandomValues.ts @@ -11,3 +11,10 @@ export function getRandomValues(array: T): T { // @ts-ignore getRandomValues is polyfilled return crypto.getRandomValues(array); } + +export function getRandomString(bytes: number) { + const randomValues = getRandomValues(new Uint8Array(bytes)); + return Array.from(randomValues) + .map((nr) => nr.toString(16).padStart(2, "0")) + .join(""); +} diff --git a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/types.ts b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/types.ts index 7ab3d4bc634..27f0ca012e1 100644 --- a/packages/react-native/src/evm/wallets/connectors/embedded-wallet/types.ts +++ b/packages/react-native/src/evm/wallets/connectors/embedded-wallet/types.ts @@ -44,6 +44,11 @@ export interface AuthOptions { password: string; } +export interface AuthEndpointOptions { + payload: string; + encryptionKey: string; +} + export type SendEmailOtpReturnType = { isNewUser: boolean; isNewDevice: boolean; @@ -70,14 +75,21 @@ type SocialAuthParams = { type JwtAuthParams = { strategy: "jwt"; jwt: string; - encryptionKey?: string; + encryptionKey: string; +}; + +type AuthEndpointParams = { + strategy: "auth_endpoint"; + payload: string; + encryptionKey: string; }; // this is the input to 'authenticate' export type AuthParams = | EmailVerificationAuthParams | SocialAuthParams - | JwtAuthParams; + | JwtAuthParams + | AuthEndpointParams; // TODO typed based off AuthParams["strategy"] export type AuthResult = { diff --git a/packages/react-native/src/evm/wallets/wallets/coinbase-wallet.ts b/packages/react-native/src/evm/wallets/wallets/coinbase-wallet.ts index b038adbcd68..01cdee9cf56 100644 --- a/packages/react-native/src/evm/wallets/wallets/coinbase-wallet.ts +++ b/packages/react-native/src/evm/wallets/wallets/coinbase-wallet.ts @@ -66,6 +66,26 @@ export class CoinbaseWallet extends AbstractClientWallet + * + * + * ``` + */ export const coinbaseWallet = (config?: { callbackURL?: URL; recommended?: boolean; diff --git a/packages/react-native/src/evm/wallets/wallets/embedded/EmbeddedWallet.ts b/packages/react-native/src/evm/wallets/wallets/embedded/EmbeddedWallet.ts index 42edae5851c..8e730cc7b09 100644 --- a/packages/react-native/src/evm/wallets/wallets/embedded/EmbeddedWallet.ts +++ b/packages/react-native/src/evm/wallets/wallets/embedded/EmbeddedWallet.ts @@ -13,6 +13,8 @@ import { import { EMAIL_WALLET_ICON } from "../../../assets/svgs"; import { WalletMeta } from "@thirdweb-dev/wallets/dist/declarations/src/evm/wallets/base"; import { AUTH_OPTIONS_ICONS } from "../../types/embedded-wallet"; +import { getRandomString } from "../../connectors/embedded-wallet/embedded/helpers/getRandomValues"; +import { ANALYTICS } from "../../connectors/embedded-wallet/embedded/helpers/analytics"; export type EmbeddedWalletOptions = WalletOptions< EmbeddedWalletAdditionalOptions & WalletConnectReceiverConfig @@ -103,6 +105,7 @@ export class EmbeddedWallet extends AbstractClientWallet< onDisconnect = () => { this.removeListeners(); + ANALYTICS.nonce = getRandomString(16); }; onChange = async (payload: any) => { diff --git a/packages/react-native/src/evm/wallets/wallets/local-wallet.tsx b/packages/react-native/src/evm/wallets/wallets/local-wallet.tsx index 59f0122ec02..7618f0993ea 100644 --- a/packages/react-native/src/evm/wallets/wallets/local-wallet.tsx +++ b/packages/react-native/src/evm/wallets/wallets/local-wallet.tsx @@ -3,6 +3,24 @@ import { WalletOptions, walletIds } from "@thirdweb-dev/wallets"; import { createSecureStorage } from "../../../core/SecureStorage"; import { createAsyncLocalStorage } from "../../../core/AsyncStorage"; +/** + * Wallet config for a Local Wallet + * + * @param config - The config for the Local Wallet + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, localWallet } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const localWallet = () => { const secureStorage = createSecureStorage(walletIds.localWallet); const asyncStorage = createAsyncLocalStorage(walletIds.localWallet); diff --git a/packages/react-native/src/evm/wallets/wallets/metamask-wallet.ts b/packages/react-native/src/evm/wallets/wallets/metamask-wallet.ts index 169d5ca836c..fee95972341 100644 --- a/packages/react-native/src/evm/wallets/wallets/metamask-wallet.ts +++ b/packages/react-native/src/evm/wallets/wallets/metamask-wallet.ts @@ -21,6 +21,22 @@ export class MetaMaskWallet extends WalletConnectBase { } } +/** + * Wallet config for MetaMask Wallet. + * + * @param config - The config for MetamaskWallet + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, metamaskWallet } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const metamaskWallet = (config?: WalletConnectConfig) => { return { id: MetaMaskWallet.id, diff --git a/packages/react-native/src/evm/wallets/wallets/rainbow-wallet.ts b/packages/react-native/src/evm/wallets/wallets/rainbow-wallet.ts index 5999a0334c5..3c076f359d4 100644 --- a/packages/react-native/src/evm/wallets/wallets/rainbow-wallet.ts +++ b/packages/react-native/src/evm/wallets/wallets/rainbow-wallet.ts @@ -22,6 +22,22 @@ export class RainbowWallet extends WalletConnectBase { } } +/** + * Wallet config for Rainbow Wallet. + * + * @param config - The config for RainbowWallet + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, rainbowWallet } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const rainbowWallet = (config?: WalletConnectConfig) => { return { id: RainbowWallet.id, diff --git a/packages/react-native/src/evm/wallets/wallets/smart-wallet.tsx b/packages/react-native/src/evm/wallets/wallets/smart-wallet.tsx index 0af75da26e0..682c5b81eb7 100644 --- a/packages/react-native/src/evm/wallets/wallets/smart-wallet.tsx +++ b/packages/react-native/src/evm/wallets/wallets/smart-wallet.tsx @@ -3,6 +3,28 @@ import { SmartWallet, createAsyncLocalStorage } from "@thirdweb-dev/wallets"; import { SmartWalletConfig } from "../types/smart-wallet"; import { SmartWalletFlow } from "../../components/ConnectWalletFlow/SmartWallet/SmartWalletFlow"; +/** + * Wallet config for Smart Wallet. + * + * @param wallet - The EOA wallet config to be connected to the SmartWallet + * @param config - The config for SmartWallet + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, smartWallet, metamaskWallet } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const smartWallet = ( wallet: WalletConfig, config: SmartWalletConfig, diff --git a/packages/react-native/src/evm/wallets/wallets/trust-wallet.ts b/packages/react-native/src/evm/wallets/wallets/trust-wallet.ts index 117c187857f..d9c65040d94 100644 --- a/packages/react-native/src/evm/wallets/wallets/trust-wallet.ts +++ b/packages/react-native/src/evm/wallets/wallets/trust-wallet.ts @@ -20,6 +20,22 @@ export class TrustWallet extends WalletConnectBase { } } +/** + * Wallet config for Trust Wallet. + * + * @param config - The config for TrustWallet + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, trustWallet } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const trustWallet = (config?: WalletConnectConfig) => { return { id: TrustWallet.id, diff --git a/packages/react-native/src/evm/wallets/wallets/wallet-connect/wallet-connect.tsx b/packages/react-native/src/evm/wallets/wallets/wallet-connect/wallet-connect.tsx index 8f6e001ddba..2c30c39dd6c 100644 --- a/packages/react-native/src/evm/wallets/wallets/wallet-connect/wallet-connect.tsx +++ b/packages/react-native/src/evm/wallets/wallets/wallet-connect/wallet-connect.tsx @@ -9,6 +9,22 @@ export type WalletConnectConfig = { recommended?: boolean; }; +/** + * Wallet config for WalletConnect. + * + * @param config - The config for WalletConnect + * @returns The wallet config to be used by the ThirdwebProvider + * + * @example + * ```jsx + * import { ThirdwebProvider, walletConnect } from "@thirdweb-dev/react-native"; + * + * + * + * + * ``` + */ export const walletConnect = ( config?: WalletConnectConfig, ): WalletConfig => { diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts index 8c6f1c99cb5..c7a96257bc2 100644 --- a/packages/react-native/src/index.ts +++ b/packages/react-native/src/index.ts @@ -1,8 +1,8 @@ -import * as Application from "expo-application"; import { isGlobalThisPresent } from "./evm/utils/global"; +import { appBundleId } from "./evm/utils/version"; export * from "./evm"; if (isGlobalThisPresent()) { - (globalThis as any).APP_BUNDLE_ID = Application.applicationId; + (globalThis as any).APP_BUNDLE_ID = appBundleId; } diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index b24bfe27620..17bd9947d0a 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,129 @@ # @thirdweb-dev/react +## 4.1.15 + +### Patch Changes + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + - @thirdweb-dev/react-core@4.1.15 + +## 4.1.14 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + - @thirdweb-dev/react-core@4.1.14 + - @thirdweb-dev/wallets@2.2.1 + +## 4.1.13 + +### Patch Changes + +- [#2029](https://github.com/thirdweb-dev/js/pull/2029) [`b50e4a41`](https://github.com/thirdweb-dev/js/commit/b50e4a41b560eb647fec1224d6b6782be7132034) Thanks [@MananTank](https://github.com/MananTank)! - Connect to MetaMask on mobile device using WalletConnect instead of opening the web app in MetaMask browser by default + + This behavior can be changed by setting `connectionMethod` option to `metamaskWallet` + + ```tsx + + + + ``` + + this is same as not setting `connectionMethod` option: + + ```tsx + + + + ``` + + If you want to revert to old behavior of opening the web app in Metamask browser, set `connectionMethod` to `metamaskBrowser` + + ```tsx + + + + ``` + +- [#2063](https://github.com/thirdweb-dev/js/pull/2063) [`c8ba5cf8`](https://github.com/thirdweb-dev/js/commit/c8ba5cf863b7b2a92e0cb2c50776511782d4e2b6) Thanks [@MananTank](https://github.com/MananTank)! - - Add option to only show the Official WalletConnect Modal for `walletConnect` in ConnectWallet Modal + + ```ts + walletConnect({ + qrModal: "walletConnect", // hide the ConnectWallet Modal and only show the WalletConnect Modal + }); + ``` + + If no, `qrModal` is set, it defaults to `"custom"` as shown below: + + ```ts + walletConnect({ + qrModal: "custom", // render QR code in ConnectWallet Modal + }); + ``` + + - Stop Focus trapping the ConnectWallet Modal when it is rendered but hidden + +- [#2058](https://github.com/thirdweb-dev/js/pull/2058) [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d) Thanks [@MananTank](https://github.com/MananTank)! - Add option to open the official wallet connect modal in ConnectWallet + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf), [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + - @thirdweb-dev/wallets@2.2.0 + - @thirdweb-dev/react-core@4.1.13 + +## 4.1.12 + +### Patch Changes + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +- [#2045](https://github.com/thirdweb-dev/js/pull/2045) [`a135857c`](https://github.com/thirdweb-dev/js/commit/a135857c7ad73e1a508298858eb0f5fd744ec176) Thanks [@MananTank](https://github.com/MananTank)! - Fix type EmbeddedWalletConfigOptions + +- [#1938](https://github.com/thirdweb-dev/js/pull/1938) [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add OneKey wallet + +- [#2042](https://github.com/thirdweb-dev/js/pull/2042) [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and Type exports + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`34546c24`](https://github.com/thirdweb-dev/js/commit/34546c24c74f4e9e1f5e94567ebe1017ad63aea5), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e), [`cd87be4a`](https://github.com/thirdweb-dev/js/commit/cd87be4a24a9a3a552fbc4f33da6fcb08b7da88b), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + - @thirdweb-dev/react-core@4.1.12 + - @thirdweb-dev/wallets@2.1.11 + +## 4.1.11 + +### Patch Changes + +- [#1926](https://github.com/thirdweb-dev/js/pull/1926) [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Rabby browser extension + +- [#2031](https://github.com/thirdweb-dev/js/pull/2031) [`fdf19b0a`](https://github.com/thirdweb-dev/js/commit/fdf19b0a26be0404ddf5424f26d96719de849627) Thanks [@MananTank](https://github.com/MananTank)! - Do not swallow errors in useEmbeddedWallet().connect + +- [#1997](https://github.com/thirdweb-dev/js/pull/1997) [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819) Thanks [@MananTank](https://github.com/MananTank)! - - Fixes issue #1708 + + - Fixes smart wallet icon shown even after clicking on "Switch to Personal wallet" in ConnectWallet dropdown + +- [#1987](https://github.com/thirdweb-dev/js/pull/1987) [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and type exports + +- [#1928](https://github.com/thirdweb-dev/js/pull/1928) [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Crypto.com Defi wallet + +- Updated dependencies [[`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4), [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819), [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c), [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314)]: + - @thirdweb-dev/react-core@4.1.11 + - @thirdweb-dev/wallets@2.1.10 + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + ## 4.1.10 ### Patch Changes diff --git a/packages/react/package.json b/packages/react/package.json index 3df77730dfe..22470d0026a 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/react", - "version": "4.1.10", + "version": "4.1.15", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react", "author": "thirdweb eng ", "license": "Apache-2.0", @@ -68,7 +68,7 @@ "generate-snippets": "node ./scripts/generate-snippets-evm.mjs && node ./scripts/generate-feature-snippets-evm.mjs", "build": "tsc && preconstruct build", "push": "yalc push", - "typedoc": "rimraf typedoc && node typedoc.js" + "typedoc": "node scripts/typedoc.mjs" }, "sideEffects:": false, "devDependencies": { @@ -103,9 +103,8 @@ "prettier": "^3.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "rimraf": "^3.0.2", "stream": "npm:stream-browserify@^3.0.0", - "typedoc": "^0.25.2", + "typedoc-gen": "workspace:*", "typescript": "^5.1.6" }, "dependencies": { @@ -113,8 +112,9 @@ "@emotion/styled": "^11.11.0", "@google/model-viewer": "^2.1.1", "@radix-ui/colors": "^0.1.9", - "@radix-ui/react-dialog": "^1.0.4", + "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-focus-scope": "^1.0.4", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-popover": "^1.0.6", "@radix-ui/react-tabs": "^1.0.4", diff --git a/packages/react/scripts/typedoc.mjs b/packages/react/scripts/typedoc.mjs new file mode 100644 index 00000000000..858debbc0bb --- /dev/null +++ b/packages/react/scripts/typedoc.mjs @@ -0,0 +1,15 @@ +/* eslint-disable better-tree-shaking/no-top-level-side-effects */ + +// @ts-check +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: [ + "**/packages/sdk/**", + "**/packages/wallets/**", + "**/packages/react-core/**", + "**/packages/chains/**", + ], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/react/src/components/Modal.tsx b/packages/react/src/components/Modal.tsx index a00a49b3eb6..379b7a711a4 100644 --- a/packages/react/src/components/Modal.tsx +++ b/packages/react/src/components/Modal.tsx @@ -16,6 +16,7 @@ import { DynamicHeight } from "./DynamicHeight"; import { useEffect, useRef, useState } from "react"; import { useCustomTheme } from "../design-system/CustomThemeProvider"; import { StyledDiv } from "../design-system/elements"; +import { FocusScope } from "@radix-ui/react-focus-scope"; export const Modal: React.FC<{ trigger?: React.ReactNode; @@ -74,48 +75,50 @@ export const Modal: React.FC<{ )} - - - {props.size === "compact" ? ( - - {props.children}{" "} - - ) : ( - props.children - )} + + + + {props.size === "compact" ? ( + + {props.children}{" "} + + ) : ( + props.children + )} - {/* Close Icon */} - {!props.hideCloseIcon && ( - - - - - - - - )} - - + {/* Close Icon */} + {!props.hideCloseIcon && ( + + + + + + + + )} + + + ); diff --git a/packages/react/src/core/query-utils/required-param.ts b/packages/react/src/core/query-utils/required-param.ts index 4d5a0e5d222..dd87efe99a1 100644 --- a/packages/react/src/core/query-utils/required-param.ts +++ b/packages/react/src/core/query-utils/required-param.ts @@ -3,7 +3,7 @@ import invariant from "tiny-invariant"; /** * Makes a parameter required to be passed, but still allows it to be null or undefined. * - * @beta + * @internal */ export type RequiredParam = T | null | undefined; diff --git a/packages/react/src/design-system/index.ts b/packages/react/src/design-system/index.ts index 911b6ef400f..fa31ca98d1e 100644 --- a/packages/react/src/design-system/index.ts +++ b/packages/react/src/design-system/index.ts @@ -1,6 +1,21 @@ import { green, mauve, mauveDark, tomato } from "@radix-ui/colors"; -const darkColors = { +type ThemeColors = { + base1: string; + base2: string; + base3: string; + base4: string; + primaryText: string; + secondaryText: string; + danger: string; + success: string; + overlay: string; + accentText: string; + accentBg: string; + textOnAccent: string; +}; + +const darkColors: ThemeColors = { base1: "hsl(230deg 11.63% 8.43%)", base2: "hsl(230deg 11.63% 12%)", base3: "hsl(230deg 11.63% 15%)", @@ -15,7 +30,7 @@ const darkColors = { textOnAccent: mauveDark.mauve12, }; -const lightColors: typeof darkColors = { +const lightColors: ThemeColors = { base1: mauve.mauve1, base2: mauve.mauve3, base3: mauve.mauve5, @@ -30,7 +45,57 @@ const lightColors: typeof darkColors = { textOnAccent: mauve.mauve1, }; -function createThemeObj(colors: typeof darkColors) { +export type Theme = { + type: "light" | "dark"; + colors: { + primaryText: string; + secondaryText: string; + accentText: string; + + danger: string; + success: string; + + modalOverlayBg: string; + + accentButtonBg: string; + accentButtonText: string; + + primaryButtonBg: string; + primaryButtonText: string; + + secondaryButtonBg: string; + secondaryButtonText: string; + secondaryButtonHoverBg: string; + + modalBg: string; + dropdownBg: string; + + tooltipBg: string; + tooltipText: string; + + inputAutofillBg: string; + scrollbarBg: string; + walletSelectorButtonHoverBg: string; + + separatorLine: string; + + secondaryIconColor: string; + secondaryIconHoverBg: string; + secondaryIconHoverColor: string; + + borderColor: string; + skeletonBg: string; + + selectedTextColor: string; + selectedTextBg: string; + + connectedButtonBg: string; + connectedButtonBgHover: string; + }; + fontFamily: string; +}; + +function createThemeObj(colors: ThemeColors): Theme { return { type: "dark" as "light" | "dark", colors: { @@ -85,8 +150,6 @@ function createThemeObj(colors: typeof darkColors) { export const darkThemeObj = /* @__PURE__ */ createThemeObj(darkColors); export const lightThemeObj = /* @__PURE__ */ createThemeObj(lightColors); -export type Theme = typeof darkThemeObj; - export type ThemeObjectOrType = "light" | "dark" | Theme; export type ThemeOverrides = { @@ -142,6 +205,18 @@ export const shadow = { xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)", }; +/** + * Create a custom light theme object by using the default dark theme as a base and applying overrides. + * + * @example + * ```ts + * const customTheme = lightTheme({ + * colors: { + * modalBg: "red", + * } + * }) + * ``` + */ export function lightTheme(overrides?: ThemeOverrides): Theme { if (!overrides) { return lightThemeObj; @@ -149,6 +224,18 @@ export function lightTheme(overrides?: ThemeOverrides): Theme { return applyThemeOverrides(lightThemeObj, overrides); } +/** + * Create a custom dark theme object by using the default dark theme as a base and applying overrides. + * + * @example + * ```ts + * const customTheme = darkTheme({ + * colors: { + * modalBg: "red", + * } + * }) + * ``` + */ export function darkTheme(overrides?: ThemeOverrides): Theme { if (!overrides) { return darkThemeObj; diff --git a/packages/react/src/evm/components/MediaRenderer.tsx b/packages/react/src/evm/components/MediaRenderer.tsx index b690550086c..9c6d6e30042 100644 --- a/packages/react/src/evm/components/MediaRenderer.tsx +++ b/packages/react/src/evm/components/MediaRenderer.tsx @@ -357,13 +357,14 @@ const LinkPlayer = /* @__PURE__ */ (() => /** * This component can be used to render any media type, including image, audio, video, and html files. * Its convenient for rendering NFT media files, as these can be a variety of different types. + * * The component falls back to a external link if the media type is not supported. - * The default size is 300px by 300px, but this can be changed using the `width` and `height` props. * - * Props: {@link MediaRendererProps} + * The default size is 300px by 300px, but this can be changed using the `width` and `height` props. * * @example * We can take a video file hosted on IPFS and render it using this component as follows + * * ```jsx * const Component = () => { * return any; +export type ActionFn = (contract: SmartContract) => any; const TW_WEB3BUTTON = "tw-web3button"; -interface Web3ButtonProps { +export interface Web3ButtonProps { + /** + * the class to apply to the button for adding custom styles + * + * @example + * ```tsx + * + * Claim NFT + * + * ``` + */ className?: string; + /** + * the address of the contract + * + * If you have not imported your contract to [thirdweb dashboard](https://thirdweb.com/dashboard), you must additionally specify the contractAbi prop. + */ contractAddress: `0x${string}` | `${string}.eth` | string; + /** + * The [Application Binary Interface](https://docs.soliditylang.org/en/v0.8.17/abi-spec.html) (ABI) of the contract. + * + * This is only required if you have not imported your contract to the [thirdweb dashboard](https://thirdweb.com/dashboard). + */ contractAbi?: ContractInterface; - - // called with the result + /** + * Callback function to be run when the contract method call is successful. + * @param result - value returned from given `action` function when it is called + */ onSuccess?: (result: Awaited>) => void; - // called with any error that might happen + /** + * Callback function to be run when the contract method call fails. + * @param error - error thrown when running given `action` function + */ onError?: (error: Error) => void; - // called before the `action` function is called + /** + * Callback function to be run after the user has confirmed the transaction. + * It is called just before the `action` function is called + */ onSubmit?: () => void; - // disabled state + + /** + * Whether the button should be disabled or not + * + * The button is disabled and shows a spinner when the transaction is executing. + */ isDisabled?: boolean; - // the fn to execute + + /** + * The logic to execute when the button is clicked. + * + * The contract instance is available as the first argument of the function for you to interact with. + * + * If the action you are performing is async, make sure to return a Promise from the action function so that the SDK knows when the action is complete + * + * @example + * ```tsx + * contract.erc721.claim(1)} + * > + * Claim NFT + * + * ``` + */ action: TActionFn; + + /** + * button element's `type` attribute + */ type?: "button" | "submit" | "reset"; + + /** + * The theme to use for the button + */ theme?: "dark" | "light" | Theme; + + /** + * The style to apply to the button element + */ style?: React.CSSProperties; - connectWallet?: Omit< - ConnectWalletProps, - | "detailsBtn" - | "hideTestnetFaucet" - | "switchToActiveChain" - | "theme" - | "hideSwitchToPersonalWallet" - >; + + /** + * Web3Button renders a `ConnectWallet` if no wallet is connected. You can pass props for that component by passing a `connectWallet` prop to Web3Button + * + * @example + * ```tsx + * contract.erc721.claim(1)} + * > + * Claim NFT + * + * ``` + */ + connectWallet?: { + /** + * The class to apply to the ConnectWallet component for adding custom styles + */ + className?: string; + + /** + * text to render in ConnectWallet button + * + * The default is `"Connect Wallet"`. + */ + btnTitle?: string; + + /** + * title of the `ConnectWallet` Modal. + * + * The default is `"Connect"`. + */ + modalTitle?: string; + + /** + * Replace the thirdweb icon next to modalTitle and set your own iconUrl + * + * Set to empty string to hide the icon + */ + modalTitleIconUrl?: string; + + auth?: { + loginOptional?: boolean; + onLogin?: (token: string) => void; + onLogout?: () => void; + }; + + /** + * apply custom styles to ConnectWallet button element + */ + style?: React.CSSProperties; + + /** + * Set the size of the modal - `compact` or `wide` on desktop + * + * Modal size is always `compact` on mobile. + * + * By default it is set to `"wide"` for desktop + */ + modalSize?: "compact" | "wide"; + + /** + * If provided, ConnectWallet Modal will show a Terms of Service message at the bottom with below link + */ + termsOfServiceUrl?: string; + + /** + * If provided, ConnectWallet Modal will show a Privacy Policy message at the bottom with below link + */ + privacyPolicyUrl?: string; + + /** + * Customize the welcome screen of the ConnectWallet Modal + * + * Either provide a component to replace the default screen entirely or an object with title, subtitle and imgSrc to change the content of the default screen + */ + welcomeScreen?: WelcomeScreen; + }; } /** - * A component that allows the user to call an on-chain function on a contract. + * Button that executes a function on a smart contract from the connected wallet when clicked. + * + * It ensures the following criteria before attempting to call the contract function: + * + * 1. There is a connected wallet (if there is not, it renders a `ConnectWallet` component instead. * - * The button has to be wrapped in a `ThirdwebProvider` in order to function. + * 2. The connected wallet is on the correct network as specified in the `ThirdwebProvider`'s `activeChain` prop. if it is not, it renders a "switch network" button instead. + * + * If the action you are performing is async, make sure to return a `Promise` from the action function so that the SDK knows when the action is complete. This can be done by either using async/await or by returning a `Promise`. * * @example * ```javascript @@ -70,14 +206,17 @@ interface Web3ButtonProps { * const App = () => { * return ( *
- * contract.erc721.transfer("0x...", 1)} /> + * contract.erc721.transfer("0x...", 1)} + * > + * Claim NFT + * *
- * ) + * ) * } * ``` * - * - * @beta */ export const Web3Button = ( props: PropsWithChildren>, diff --git a/packages/react/src/evm/components/types.ts b/packages/react/src/evm/components/types.ts index d0a6e3da088..55cf0fe5103 100644 --- a/packages/react/src/evm/components/types.ts +++ b/packages/react/src/evm/components/types.ts @@ -1,29 +1,43 @@ import type { ReactNode } from "react"; export interface SharedMediaProps { + /** + * The className to apply on the rendered element to add custom styling. + */ className?: string; + /** + * The style to apply on the rendered element to add custom styling. + */ style?: React.CSSProperties; + /** + * The CSS width property to apply on the rendered element. + */ width?: HTMLIFrameElement["width"]; + /** + * The CSS height property to apply on the rendered element. + */ height?: HTMLIFrameElement["height"]; /** - * Require user interaction to play the media. (default false) + * Require user interaction to play the media. + * + * By default it is set to `false` */ requireInteraction?: boolean; /** - * Show the media controls (where applicable) (default false) + * Show the media controls (where applicable) + * + * By default it is set to `false` */ controls?: HTMLVideoElement["controls"]; children?: ReactNode; + /** + * Provide the [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the media if it is known + */ mimeType?: string; } -/** - * - * The props for the {@link MediaRenderer} component. - * @public - */ export interface MediaRendererProps extends SharedMediaProps { /** * The media source uri. @@ -41,6 +55,12 @@ export interface MediaRendererProps extends SharedMediaProps { * The IPFS gateway URL to use */ gatewayUrl?: string; + /** + * The CSS width property to apply on the rendered element. + */ width?: string; + /** + * The CSS height property to apply on the rendered element. + */ height?: string; } diff --git a/packages/react/src/evm/hooks/wallets/useBloctoWallet.ts b/packages/react/src/evm/hooks/wallets/useBloctoWallet.ts index 9b43a14dfc0..9014a88b6dc 100644 --- a/packages/react/src/evm/hooks/wallets/useBloctoWallet.ts +++ b/packages/react/src/evm/hooks/wallets/useBloctoWallet.ts @@ -1,11 +1,11 @@ import { useConnect } from "@thirdweb-dev/react-core"; import { useCallback } from "react"; -import { BloctoAdditionalOptions } from "../../../wallet/wallets/blocto/bloctoWallet"; +import { BloctoWalletConfigOptions } from "../../../wallet/wallets/blocto/bloctoWallet"; export function useBloctoWallet() { const connect = useConnect(); return useCallback( - async (options?: { chainId?: number } & BloctoAdditionalOptions) => { + async (options?: { chainId?: number } & BloctoWalletConfigOptions) => { const { bloctoWallet } = await import( "../../../wallet/wallets/blocto/bloctoWallet" ); diff --git a/packages/react/src/evm/hooks/wallets/useEmbeddedWallet.ts b/packages/react/src/evm/hooks/wallets/useEmbeddedWallet.ts index a30c2c7f945..07767437ef1 100644 --- a/packages/react/src/evm/hooks/wallets/useEmbeddedWallet.ts +++ b/packages/react/src/evm/hooks/wallets/useEmbeddedWallet.ts @@ -51,6 +51,7 @@ export function useEmbeddedWallet() { } catch (e) { console.error("Error connecting to embedded wallet", e); setStatus("disconnected"); + throw e; } return wallet; }, diff --git a/packages/react/src/evm/hooks/wallets/usePaper.ts b/packages/react/src/evm/hooks/wallets/usePaper.ts index 2e3f4204b7a..5638a5b5bd9 100644 --- a/packages/react/src/evm/hooks/wallets/usePaper.ts +++ b/packages/react/src/evm/hooks/wallets/usePaper.ts @@ -13,6 +13,9 @@ import { useCallback, useEffect } from "react"; type PaperConfig = Omit; +/** + * @deprecated We have deprecated `PaperWallet` in favor of our `EmbeddedWallet` which adds support for more sign in methods. use the `useEmbeddedWallet` hook instead + */ export function usePaperWallet() { const connect = useConnect(); return useCallback( @@ -29,6 +32,9 @@ export function usePaperWallet() { ); } +/** + * @deprecated We have deprecated `PaperWallet` in favor of our `EmbeddedWallet` which adds support for more sign in methods. use the `useEmbeddedWallet` hook instead + */ export function usePaperWalletUserEmail(): UseQueryResult< string | undefined, string diff --git a/packages/react/src/evm/hooks/wallets/useWalletConnect.ts b/packages/react/src/evm/hooks/wallets/useWalletConnect.ts index 2c25d102a71..f97a587517e 100644 --- a/packages/react/src/evm/hooks/wallets/useWalletConnect.ts +++ b/packages/react/src/evm/hooks/wallets/useWalletConnect.ts @@ -2,6 +2,9 @@ import { useConnect } from "@thirdweb-dev/react-core"; import { WC2_QRModalOptions } from "@thirdweb-dev/wallets"; import { useCallback } from "react"; +/** + * @deprecated use the `useWalletConnect` hook instead + */ export function useWalletConnectV1() { const connect = useConnect(); return useCallback( diff --git a/packages/react/src/evm/index.ts b/packages/react/src/evm/index.ts index 8532a96f159..8b62373f9fa 100644 --- a/packages/react/src/evm/index.ts +++ b/packages/react/src/evm/index.ts @@ -10,18 +10,32 @@ export { ConnectWallet, type ConnectWalletProps, } from "../wallet/ConnectWallet/ConnectWallet"; +export type { WelcomeScreen } from "../wallet/ConnectWallet/screens/types"; export { ConnectModalInline } from "../wallet/ConnectWallet/Modal/ConnectModalInline"; -export { NetworkSelector } from "../wallet/ConnectWallet/NetworkSelector"; -export type { NetworkSelectorProps } from "../wallet/ConnectWallet/NetworkSelector"; +export { + NetworkSelector, + type NetworkSelectorProps, + type NetworkSelectorChainProps, +} from "../wallet/ConnectWallet/NetworkSelector"; + +export type { DropDownPosition } from "../wallet/ConnectWallet/Details"; // UI components export * from "./components/MediaRenderer"; export * from "./components/NftMedia"; -export * from "./components/Web3Button"; -export { ThirdwebProvider } from "./providers/thirdweb-provider"; +export { + Web3Button, + type Web3ButtonProps, + type ActionFn, +} from "./components/Web3Button"; +export { + ThirdwebProvider, + type DefaultChains, + type ThirdwebProviderProps, +} from "./providers/thirdweb-provider"; -export type { MediaRendererProps } from "./components/types"; +export type { MediaRendererProps, SharedMediaProps } from "./components/types"; // wallet/hooks export { useInstalledWallets } from "../wallet/hooks/useInstalledWallets"; @@ -49,8 +63,19 @@ export { useWalletConnectV1, } from "./hooks/wallets/useWalletConnect"; +export { + defaultTokens, + type SupportedTokens, +} from "../wallet/ConnectWallet/defaultTokens"; + +export { + oneKeyWallet, + type OneKeyWalletConfigOptions, +} from "../wallet/wallets/oneKey/oneKeyWallet"; + // react-core export * from "@thirdweb-dev/react-core"; + // wallets export { LocalWallet, @@ -73,6 +98,7 @@ export { InjectedWallet, setWalletAnalyticsEnabled, CoreWallet, + OneKeyWallet, CryptoDefiWallet, RabbyWallet, Coin98Wallet, diff --git a/packages/react/src/evm/locales/en.ts b/packages/react/src/evm/locales/en.ts index f732376e619..121892b25d3 100644 --- a/packages/react/src/evm/locales/en.ts +++ b/packages/react/src/evm/locales/en.ts @@ -1,3 +1,4 @@ +import { ThirdwebLocale } from "./types"; import { DeepPartial, immutableOverride } from "../utils/applyOverrides"; // wallets that connect via extension and QR scan @@ -168,6 +169,7 @@ export function enDefault() { trustWallet: extensionAndQRScanScreens("Trust"), zerionWallet: extensionAndQRScanScreens("Zerion"), coreWallet: extensionAndQRScanScreens("Core"), + oneKeyWallet: extensionAndQRScanScreens("OneKey"), cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"), rabbyWallet: extensionAndQRScanScreens("Rabby"), coin98Wallet: extensionAndQRScanScreens("Coin98"), @@ -317,8 +319,33 @@ export function enDefault() { }; } -export type ThirdwebLocale = ReturnType; - +/** + * Calling this function will return the default English locale object to be set on `ThirdwebProvider` to localize the thirdweb components. + * + * You can also overrides parts of the default locale object by passing an object with the same structure as the default locale object and only those parts will be overridden. + * + * @example + * + * ### Use default English Locale + * ```tsx + * const english = en(); // default English locale object + * + * + * ``` + * + * ### Override English Locale + * ```tsx + * const english = en({ + * connectWallet: { + * signIn: "Sign in!" + * } + * }) + * + * + * + * + * ``` + */ export function en(overrides?: DeepPartial) { const defaultObj = enDefault(); if (!overrides) { diff --git a/packages/react/src/evm/locales/es.ts b/packages/react/src/evm/locales/es.ts index a302e44b91b..68c1a74fc58 100644 --- a/packages/react/src/evm/locales/es.ts +++ b/packages/react/src/evm/locales/es.ts @@ -1,5 +1,5 @@ import { DeepPartial, immutableOverride } from "../utils/applyOverrides"; -import { ThirdwebLocale } from "./en"; +import { ThirdwebLocale } from "./types"; // ... @@ -173,6 +173,7 @@ export function esDefault(): ThirdwebLocale { rainbowWallet: extensionAndQRScanScreens("Rainbow"), trustWallet: extensionAndQRScanScreens("Trust"), zerionWallet: extensionAndQRScanScreens("Zerion"), + oneKeyWallet: extensionAndQRScanScreens("OneKey"), cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"), rabbyWallet: extensionAndQRScanScreens("Rabby"), paperWallet: { @@ -326,6 +327,33 @@ export function esDefault(): ThirdwebLocale { }; } +/** + * Calling this function will return the default Spanish locale object to be set on `ThirdwebProvider` to localize the thirdweb components. + * + * You can also overrides parts of the default locale object by passing an object with the same structure as the default locale object and only those parts will be overridden. + * + * @example + * + * ### Use default Spanish Locale + * ```tsx + * const spanish = es(); // default English locale object + * + * + * ``` + * + * ### Override Spanish Locale + * ```tsx + * const spanish = es({ + * connectWallet: { + * signIn: "Iniciar sesión" + * } + * }) + * + * + * + * + * ``` + */ export function es(overrides?: DeepPartial) { const defaultObj = esDefault(); if (!overrides) { diff --git a/packages/react/src/evm/locales/ja.ts b/packages/react/src/evm/locales/ja.ts index 29023854deb..507ce37762e 100644 --- a/packages/react/src/evm/locales/ja.ts +++ b/packages/react/src/evm/locales/ja.ts @@ -1,5 +1,5 @@ import { DeepPartial, immutableOverride } from "../utils/applyOverrides"; -import { ThirdwebLocale } from "./en"; +import { ThirdwebLocale } from "./types"; // wallets that connect via extension and QR scan function extensionAndQRScanScreens(walletName: string) { @@ -173,6 +173,7 @@ export function jaDefault(): ThirdwebLocale { rainbowWallet: extensionAndQRScanScreens("Rainbow"), trustWallet: extensionAndQRScanScreens("Trust"), zerionWallet: extensionAndQRScanScreens("Zerion"), + oneKeyWallet: extensionAndQRScanScreens("OneKey"), cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"), rabbyWallet: extensionAndQRScanScreens("Rabby"), paperWallet: { @@ -320,6 +321,33 @@ export function jaDefault(): ThirdwebLocale { }; } +/** + * Calling this function will return the default Japanese locale object to be set on `ThirdwebProvider` to localize the thirdweb components. + * + * You can also overrides parts of the default locale object by passing an object with the same structure as the default locale object and only those parts will be overridden. + * + * @example + * + * ### Use default Japanese Locale + * ```tsx + * const japanese = ja(); // default English locale object + * + * + * + * + * ``` + * + * ### Override Japanese Locale + * ```tsx + * const japanese = ja({ + * connectWallet: { + * signIn: "サインイン" + * } + * }) + * + * + * ``` + */ export function ja(overrides?: DeepPartial) { const defaultObj = jaDefault(); if (!overrides) { diff --git a/packages/react/src/evm/locales/types.ts b/packages/react/src/evm/locales/types.ts new file mode 100644 index 00000000000..bc2a81afe53 --- /dev/null +++ b/packages/react/src/evm/locales/types.ts @@ -0,0 +1,298 @@ +export type ExtensionAndQRScreensLocale = { + connectionScreen: { + failed: string; + inProgress: string; + instruction: string; + retry: string; + }; + getStartedLink: string; + getStartedScreen: { instruction: string }; + scanScreen: { instruction: string }; +}; + +export type ThirdwebLocale = { + connectWallet: { + agreement: { + and: string; + prefix: string; + privacyPolicy: string; + termsOfService: string; + }; + backupWallet: string; + confirmInWallet: string; + connectAWallet: string; + connectedToSmartWallet: string; + connecting: string; + continueAsGuest: string; + copyAddress: string; + currentNetwork: string; + defaultButtonTitle: string; + defaultModalTitle: string; + disconnectWallet: string; + download: { android: string; chrome: string; iOS: string }; + getStarted: string; + guest: string; + guestWalletWarning: string; + installed: string; + networkSelector: { + addCustomNetwork: string; + allNetworks: string; + categoryLabel: { + others: string; + popular: string; + recentlyUsed: string; + }; + failedToSwitch: string; + inputPlaceholder: string; + loading: string; + mainnets: string; + testnets: string; + title: string; + }; + newToWallets: string; + or: string; + personalWallet: string; + receive: string; + receiveFundsScreen: { instruction: string; title: string }; + recommended: string; + requestTestnetFunds: string; + send: string; + sendFundsScreen: { + amount: string; + insufficientFunds: string; + invalidAddress: string; + noTokensFound: string; + searchToken: string; + selectTokenTitle: string; + sendTo: string; + sending: string; + submitButton: string; + successMessage: string; + title: string; + token: string; + transactionFailed: string; + transactionRejected: string; + }; + signIn: string; + signatureScreen: { + instructionScreen: { + instruction: string; + signInButton: string; + title: string; + }; + signingScreen: { + approveTransactionInSafe: string; + failedToSignIn: string; + inProgress: string; + prompt: string; + promptForSafe: string; + title: string; + tryAgain: string; + }; + }; + smartWallet: string; + switchAccount: string; + switchNetwork: string; + switchTo: string; + switchingNetwork: string; + transactionHistory: string; + welcomeScreen: { defaultSubtitle: string; defaultTitle: string }; + }; + wallets: { + coin98Wallet: { + connectionScreen: { + failed: string; + inProgress: string; + instruction: string; + retry: string; + }; + getStartedLink: string; + getStartedScreen: { instruction: string }; + scanScreen: { instruction: string }; + }; + coinbaseWallet: ExtensionAndQRScreensLocale; + coreWallet: ExtensionAndQRScreensLocale; + cryptoDefiWallet: ExtensionAndQRScreensLocale; + embeddedWallet: { + createPassword: { + confirmation: string; + failedToSetPassword: string; + inputPlaceholder: string; + instruction: string; + saveInstruction: string; + submitButton: string; + title: string; + }; + emailLoginScreen: { + enterCodeSendTo: string; + enterRecoveryCode: string; + failedToSendCode: string; + invalidCode: string; + invalidCodeOrRecoveryCode: string; + newDeviceDetected: string; + resendCode: string; + sendingCode: string; + title: string; + verify: string; + }; + emailPlaceholder: string; + emailRequired: string; + enterPassword: { + inputPlaceholder: string; + instruction: string; + submitButton: string; + title: string; + wrongPassword: string; + }; + invalidEmail: string; + signIn: string; + signInWithApple: string; + signInWithFacebook: string; + signInWithGoogle: string; + socialLoginScreen: { + failed: string; + instruction: string; + retry: string; + title: string; + }; + submitEmail: string; + }; + frameWallet: { + connectionFailedScreen: { + description: string; + downloadFrame: string; + supportLink: string; + title: string; + }; + connectionScreen: { + failed: string; + inProgress: string; + instruction: string; + retry: string; + }; + getStartedLink: string; + getStartedScreen: { instruction: string }; + scanScreen: { instruction: string }; + }; + localWallet: { + confirmPasswordLabel: string; + createScreen: { + connecting: string; + createNewWallet: string; + importWallet: string; + instruction: string; + }; + enterYourPassword: string; + exportScreen: { + description1: string; + description2: string; + download: string; + title: string; + walletAddress: string; + }; + importScreen: { + description1: string; + description2: string; + import: string; + title: string; + uploadJSON: string; + uploadedSuccessfully: string; + }; + passwordLabel: string; + reconnectScreen: { + continue: string; + createNewWallet: string; + savedWallet: string; + title: string; + }; + warningScreen: { + backupWallet: string; + title: string; + warning: string; + }; + }; + magicLink: { + countryCodeMissing: string; + emailOrPhoneRequired: string; + emailPlaceholder: string; + emailRequired: string; + invalidEmail: string; + invalidEmailOrPhone: string; + invalidPhone: string; + loginWith: string; + loginWithEmailOrPhone: string; + loginWithPhone: string; + phoneRequired: string; + signIn: string; + submitEmail: string; + }; + metamaskWallet: ExtensionAndQRScreensLocale; + okxWallet: ExtensionAndQRScreensLocale; + oneKeyWallet: ExtensionAndQRScreensLocale; + paperWallet: { + emailLoginScreen: { + enterCodeSendTo: string; + enterRecoveryCode: string; + failedToSendCode: string; + invalidCode: string; + invalidCodeOrRecoveryCode: string; + newDeviceDetected: string; + resendCode: string; + sendingCode: string; + title: string; + verify: string; + }; + emailPlaceholder: string; + emailRequired: string; + googleLoginScreen: { + failed: string; + instruction: string; + retry: string; + title: string; + }; + invalidEmail: string; + signIn: string; + signInWithGoogle: string; + submitEmail: string; + }; + phantomWallet: ExtensionAndQRScreensLocale; + rabbyWallet: ExtensionAndQRScreensLocale; + rainbowWallet: ExtensionAndQRScreensLocale; + safeWallet: { + accountDetailsScreen: { + connectToSafe: string; + connecting: string; + dashboardLink: string; + failedToConnect: string; + failedToSwitch: string; + findSafeAddressIn: string; + invalidChainConfig: string; + mainnets: string; + network: string; + safeAddress: string; + selectNetworkPlaceholder: string; + switchNetwork: string; + switchingNetwork: string; + testnets: string; + title: string; + }; + connectWalletScreen: { + learnMoreLink: string; + subtitle: string; + title: string; + }; + }; + smartWallet: { + connecting: string; + failedToConnect: string; + wrongNetworkScreen: { + failedToSwitch: string; + subtitle: string; + title: string; + }; + }; + trustWallet: ExtensionAndQRScreensLocale; + walletConnect: { scanInstruction: string }; + zerionWallet: ExtensionAndQRScreensLocale; + }; +}; diff --git a/packages/react/src/evm/providers/locale-provider.tsx b/packages/react/src/evm/providers/locale-provider.tsx index 75078f3725f..ec7ff5393ff 100644 --- a/packages/react/src/evm/providers/locale-provider.tsx +++ b/packages/react/src/evm/providers/locale-provider.tsx @@ -1,5 +1,6 @@ import { createContext, useContext } from "react"; -import { ThirdwebLocale, enDefault } from "../locales/en"; +import { enDefault } from "../locales/en"; +import { ThirdwebLocale } from "../locales/types"; export const ThirdwebLocaleContext = /* @__PURE__ */ (() => createContext(enDefault()))(); diff --git a/packages/react/src/evm/providers/thirdweb-provider.tsx b/packages/react/src/evm/providers/thirdweb-provider.tsx index 09beee634f8..197793462c7 100644 --- a/packages/react/src/evm/providers/thirdweb-provider.tsx +++ b/packages/react/src/evm/providers/thirdweb-provider.tsx @@ -12,41 +12,157 @@ import { defaultWallets } from "../../wallet/wallets/defaultWallets"; import { CustomThemeProvider } from "../../design-system/CustomThemeProvider"; import { signerWallet } from "../../wallet/wallets/signerWallet"; import { Signer } from "ethers"; -import { ThirdwebLocale, en } from "../locales/en"; +import { en } from "../locales/en"; import { ThirdwebLocaleContext } from "./locale-provider"; import { walletIds } from "@thirdweb-dev/wallets"; +import { ThirdwebLocale } from "../locales/types"; -interface ThirdwebProviderProps +export interface ThirdwebProviderProps extends Omit< ThirdwebProviderCoreProps, - "createWalletStorage" | "supportedWallets" | "theme" + "createWalletStorage" | "supportedWallets" | "theme" | "signerWallet" > { /** * Wallets supported by the dApp - * @defaultValue `[ metamaskWallet(), coinbaseWallet(), walletConnect() ]` + * + * If no wallets are provided, the default wallets will be used which is equivalent to the following: + * + * ```tsx + * [ + * metamaskWallet(), + * coinbaseWallet(), + * walletConnect(), + * trustWallet(), + * rainbowWallet(), + * zerionWallet(), + * phantomWallet(), + * ] + * ``` * * @example * ```jsx * import { metamaskWallet, coinbaseWallet, walletConnect } from "@thirdweb-dev/react"; * * * ``` */ supportedWallets?: WalletConfig[]; /** - * theme to use for all thirdweb components - * @defaultValue "dark" + * Set the theme for all thirdweb components + * + * By default it is set to "dark". + * + * theme can be set to either "dark" or "light" or a custom theme object. + * + * You can also import `lightTheme` or `darkTheme` functions from `@thirdweb-dev/react` to use the default themes as base and overrides parts of it. + * + * @example + * ```ts + * import { lightTheme } from "@thirdweb-dev/react"; + * const customTheme = lightTheme({ + * colors: { + * modalBg: 'red' + * } + * }) + * ``` */ theme?: ThemeObjectOrType; + /** + * Use a signer instead of `supportedWallets` if you want to provide your own wallet connection logic. + */ signer?: Signer; + /** + * locale object contains text used for all thirdweb components + * + * it allows you to change the language used in UI components or override the texts used in the UI + * + * React SDK comes out of the box with Spanish and Japanese locale functions, but you can add support for any language you want just by passing an object with the required strings + * + * @example + * + * ## Using Built-in Locales + * + * ### Using the Spanish locale + * ```tsx + * import { ThirdwebProvider, es } from "@thirdweb-dev/react"; + * + * const spanish = es(); + * + * + * ``` + * + * ### Using the Japanese locale + * ```tsx + * import { ThirdwebProvider, jp } from "@thirdweb-dev/react"; + * + * const japanese = jp(); + * + * + * ``` + * + * ### Using English locale ( default ) + * ```tsx + * import { ThirdwebProvider, en } from "@thirdweb-dev/react"; + * + * const english = en(); + * + * + * ``` + * + * ## Overriding the locale + * + * ```tsx + * import { ThirdwebProvider, en } from "@thirdweb-dev/react"; + * + * // override some texts + * const english = en({ + * connectWallet: { + * confirmInWallet: "Confirm in your wallet", + * }, + * wallets: { + * metamaskWallet: { + * connectionScreen: { + * inProgress: "Awaiting Confirmation", + * instruction: "Accept connection request in your MetaMask wallet", + * }, + * }, + * }, + * }); + * + * + * + * ; + * + * ``` + * + * ### Custom locale object + * + * ```tsx + * import { ThirdwebProvider } from "@thirdweb-dev/react"; + * + * + * + * ; + *``` + * + */ locale?: ThirdwebLocale; } +/** + * Array of default supported chains by the thirdweb SDK + */ +export type DefaultChains = typeof defaultChains; + /** * * The `` component lets you control what networks you want users to connect to, @@ -68,15 +184,17 @@ interface ThirdwebProviderProps * ``` * */ -export const ThirdwebProvider = < - TChains extends Chain[] = typeof defaultChains, ->({ - supportedWallets, - children, - signer, - theme: _theme, - ...restProps -}: PropsWithChildren>) => { +export const ThirdwebProvider = ( + props: PropsWithChildren>, +) => { + const { + supportedWallets, + children, + signer, + theme: _theme, + ...restProps + } = props; + const wallets: WalletConfig[] = supportedWallets || defaultWallets; const theme = _theme || "dark"; diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index a649ca5620e..99c3f961e8c 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -1,35 +1,115 @@ -export { defaultTokens } from "./wallet/ConnectWallet/defaultTokens"; +export { + defaultTokens, + type TokenInfo, +} from "./wallet/ConnectWallet/defaultTokens"; + export { defaultWallets } from "./wallet/wallets/defaultWallets"; export { useSmartWallet } from "./evm/hooks/wallets/useSmartWallet"; -export { bloctoWallet } from "./wallet/wallets/blocto/bloctoWallet"; -export { coinbaseWallet } from "./wallet/wallets/coinbase/coinbaseWallet"; + +export { + bloctoWallet, + type BloctoWalletConfigOptions, +} from "./wallet/wallets/blocto/bloctoWallet"; +export { + coinbaseWallet, + type CoinbaseWalletConfigOptions, +} from "./wallet/wallets/coinbase/coinbaseWallet"; export { embeddedWallet } from "./wallet/wallets/embeddedWallet/embeddedWallet"; -export { frameWallet } from "./wallet/wallets/frame/frameWallet"; +export type { EmbeddedWalletConfigOptions } from "./wallet/wallets/embeddedWallet/types"; + +export { + frameWallet, + type FrameWalletConfigOptions, +} from "./wallet/wallets/frame/frameWallet"; + export { localWallet } from "./wallet/wallets/localWallet/localWallet"; -export { magicLink } from "./wallet/wallets/magic/magicLink"; -export { metamaskWallet } from "./wallet/wallets/metamask/metamaskWallet"; +export type { LocalWalletConfigOptions } from "./wallet/wallets/localWallet/types"; + +export { + magicLink, + type MagicWalletConfigOptions, +} from "./wallet/wallets/magic/magicLink"; +export { + metamaskWallet, + type MetamaskWalletConfigOptions, +} from "./wallet/wallets/metamask/metamaskWallet"; + export { paperWallet } from "./wallet/wallets/paper/paperWallet"; -export { phantomWallet } from "./wallet/wallets/phantom/phantomWallet"; -export { rainbowWallet } from "./wallet/wallets/rainbow/RainbowWallet"; -export { safeWallet } from "./wallet/wallets/safe/safeWallet"; +export type { PaperWalletConfigOptions } from "./wallet/wallets/paper/types"; + +export { + phantomWallet, + type PhantomWalletConfigOptions, +} from "./wallet/wallets/phantom/phantomWallet"; + +export { + rainbowWallet, + type RainbowWalletConfigOptions, +} from "./wallet/wallets/rainbow/RainbowWallet"; + +export { + safeWallet, + type SafeWalletConfigOptions, +} from "./wallet/wallets/safe/safeWallet"; + export { smartWallet } from "./wallet/wallets/smartWallet/smartWallet"; -export { trustWallet } from "./wallet/wallets/trustWallet/TrustWallet"; -export { walletConnect } from "./wallet/wallets/walletConnect/walletConnect"; +export type { SmartWalletConfigOptions } from "./wallet/wallets/smartWallet/types"; + +export { + trustWallet, + type TrustWalletConfigOptions, +} from "./wallet/wallets/trustWallet/TrustWallet"; + +export { + walletConnect, + type walletConnectConfigOptions, +} from "./wallet/wallets/walletConnect/walletConnect"; + export { walletConnectV1 } from "./wallet/wallets/walletConnectV1"; -export { zerionWallet } from "./wallet/wallets/zerion/zerionWallet"; -export { okxWallet } from "./wallet/wallets/okx/okxWallet"; -export { coreWallet } from "./wallet/wallets/coreWallet/coreWallet"; -export { cryptoDefiWallet } from "./wallet/wallets/defiWallet/cryptoDefiWallet"; -export { rabbyWallet } from "./wallet/wallets/rabby/rabbyWallet"; -export { coin98Wallet } from "./wallet/wallets/coin98/coin98Wallet"; +export { + zerionWallet, + type ZerionkWalletConfigOptions, +} from "./wallet/wallets/zerion/zerionWallet"; + +export { + okxWallet, + type OKXWalletConfigOptions, +} from "./wallet/wallets/okx/okxWallet"; + +export { + coreWallet, + type CoreWalletConfigOptions, +} from "./wallet/wallets/coreWallet/coreWallet"; + +export { + cryptoDefiWallet, + type CryptoDefiWalletConfigOptions, +} from "./wallet/wallets/defiWallet/cryptoDefiWallet"; + +export { + rabbyWallet, + type RabbyWalletConfigOptions, +} from "./wallet/wallets/rabby/rabbyWallet"; + +export { + coin98Wallet, + type Coin98WalletConfigOptions, +} from "./wallet/wallets/coin98/coin98Wallet"; + +// theming export { darkTheme, lightTheme } from "./design-system/index"; export type { Theme, ThemeOverrides } from "./design-system/index"; -// at the moment we'll re-export everything from the evm package -export * from "./evm"; - // locales export { en } from "./evm/locales/en"; export { ja } from "./evm/locales/ja"; export { es } from "./evm/locales/es"; + +export type { + ThirdwebLocale, + ExtensionAndQRScreensLocale, +} from "./evm/locales/types"; + +// at the moment we'll re-export everything from the evm package +export * from "./evm"; diff --git a/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx b/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx index 0b5e3dbbb9e..7ed6c76d58b 100644 --- a/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx +++ b/packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx @@ -38,13 +38,53 @@ import { Modal } from "../../components/Modal"; import { useTWLocale } from "../../evm/providers/locale-provider"; export type ConnectWalletProps = { + /** + * CSS class to apply to the button element + * + * For some CSS properties, you may need to use the !important to override the default styles + * + * ```tsx + * + * ``` + */ className?: string; + + /** + * Set the theme for the button and modal. + * + * By default it is set to "dark" if `theme` is not set on `ThirdWebProvider` + * If a `theme` is set on `ThirdWebProvider` then that theme will be used by default which can be overridden by setting `theme` prop on `ConnectWallet` component + * + * theme can be set to either "dark" or "light" or a custom theme object. You can also import `lightTheme` or `darkTheme` functions from `@thirdweb-dev/react` to use the default themes as base and overrides parts of it. + * + * @example + * ```ts + * import { lightTheme } from "@thirdweb-dev/react"; + * const customTheme = lightTheme({ + * colors: { + * modalBg: 'red' + * } + * }) + * ``` + */ theme?: "dark" | "light" | Theme; + /** + * set custom label for the button. + * + * The default is `"Connect"` + * + * @example + * ```tsx + * + * ``` + */ btnTitle?: string; + /** - * Set a custom title for the modal - * @defaultValue "Connect" + * Change the title of ConnectWallet Modal + * + * The default is `"Connect"` */ modalTitle?: string; @@ -56,27 +96,84 @@ export type ConnectWalletProps = { modalTitleIconUrl?: string; /** - * render a custom button to display the connected wallet details instead of the default button + * Render a custom button to display connected wallet details instead of the default one + * + * ```tsx + * const address = useAddress(); + * + * { + * return ( + * + * ) + * }} + * /> + * ``` */ detailsBtn?: () => JSX.Element; + + /** + * When user connects the wallet using ConnectWallet Modal, a "Details Button" is rendered. Clicking on this button opens a dropdown which opens in a certain direction relative to the Details button. + * + * `dropdownPosition` prop allows you to customize the direction the dropdown should open relative to the Details button. + * + * ```tsx + * + * ``` + */ dropdownPosition?: DropDownPosition; + + /** + * Enforce that users must sign in with their wallet using [auth](https://portal.thirdweb.com/auth) after connecting their wallet. + * + * This requires the `authConfig` prop to be set on the `ThirdWebProvider` component. + */ auth?: { + /** + * specify whether signing in is optional or not. + * + * By default it is `true` if `authConfig` is set on `ThirdWebProvider` + */ loginOptional?: boolean; + /** + * Callback to be called after user signs in with their wallet + */ onLogin?: (token: string) => void; + /** + * Callback to be called after user signs out + */ onLogout?: () => void; }; + /** + * CSS styles to apply to the button element + */ style?: React.CSSProperties; + /** + * customize the Network selector shown + */ networkSelector?: Omit< NetworkSelectorProps, "theme" | "onClose" | "chains" | "open" >; /** - * Hide option to request testnet funds for testnets in dropdown + * Hide the "Request Testnet funds" link in ConnectWallet dropdown which is shown when user is connected to a testnet. * - * @defaultValue false + * By default it is `false` + * + * @example + * ```tsx + * + * ``` */ hideTestnetFaucet?: boolean; @@ -87,7 +184,7 @@ export type ConnectWalletProps = { * Please, note that if you support multiple networks in your app this prop should * be set to `false` to allow users to switch between networks. * - * @defaultValue false + * By default it is `false` */ switchToActiveChain?: boolean; @@ -96,52 +193,119 @@ export type ConnectWalletProps = { * * Modal size is always `compact` on mobile * - * @defaultValue "wide" + * By default it is `"wide"` for desktop. */ modalSize?: "compact" | "wide"; /** * If provided, Modal will show a Terms of Service message at the bottom with below link + * + * @example + * ```tsx + * + * ``` */ termsOfServiceUrl?: string; /** * If provided, Modal will show a Privacy Policy message at the bottom with below link + * + * @example + * ```tsx + * + * ``` */ privacyPolicyUrl?: string; /** - * Customize the welcome screen + * Customize the welcome screen. This prop is only applicable when modalSize prop is set to "wide". On "wide" Modal size, a welcome screen is shown on the right side of the modal. * - * Either provide a component to replace the default screen entirely + * This screen can be customized in two ways + * + * ### 1. Customize Metadata and Image + * + * ```tsx + * + * ``` * - * or an object with title, subtitle and imgSrc to change the content of the default screen + * ### 2. Render Custom Component + * + * ```tsx + * { + * return + * }} + * /> + * ``` */ welcomeScreen?: WelcomeScreen; /** - * Override the default supported tokens for each network + * Customize the tokens shown in the "Send Funds" screen for various networks. + * + * By default, The "Send Funds" screen shows a few popular tokens for default chains and the native token. For other chains it only shows the native token. + * + * @example + * + * supportedTokens prop allows you to customize this list as shown below which shows "Dai Stablecoin" when users wallet is connected to the "Base" mainnet. * - * These tokens will be displayed in "Send Funds" Modal + * ```tsx + * import { ConnectWallet } from '@thirdweb-dev/react'; + * import { Base } from '@thirdweb-dev/chains'; + * + * function Example() { + * return ( + * + * ); + * } + * ``` */ supportedTokens?: SupportedTokens; /** - * Show balance of ERC20 token instead of the native token in the "Connected" button when connected to certain network + * Display the balance of a token instead of the native token in ConnectWallet details button. * * @example * ```tsx + * import { Base } from "@thirdweb-dev/chains"; + * * + * 1: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" // show USDC balance when connected to Ethereum mainnet + * [Base.chainId]: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", // show Dai stablecoin token balance when connected to Base mainnet + * }} + * /> * ``` */ displayBalanceToken?: Record; /** - * Hide the "switch to Personal wallet" option in the dropdown which is shown when wallet is connected to either Smart Wallet or Safe + * Hide the "Switch to Personal wallet" option in the wallet modal which is shown when wallet is connected to either Smart Wallet or Safe. + * + * By default it is `false` * - * @defaultValue false + * @example + * ```tsx + * + * ``` */ hideSwitchToPersonalWallet?: boolean; }; @@ -151,9 +315,11 @@ const TW_CONNECT_WALLET = "tw-connect-wallet"; /** * A component that allows the user to connect their wallet. * - * The button must be descendant of `ThirdwebProvider` in order to function. + * it renders a button which when clicked opens a modal to allow users to connect to wallets specified in the `ThirdwebProvider`'s supportedWallets prop. + * + * This component must be descendant of `ThirdwebProvider` */ -export const ConnectWallet: React.FC = (props) => { +export function ConnectWallet(props: ConnectWalletProps) { const activeWallet = useWallet(); const contextTheme = useCustomTheme(); const theme = props.theme || contextTheme || "dark"; @@ -354,7 +520,7 @@ export const ConnectWallet: React.FC = (props) => { })()} ); -}; +} function SwitchNetworkButton(props: { style?: React.CSSProperties; diff --git a/packages/react/src/wallet/ConnectWallet/Modal/ConnectModal.tsx b/packages/react/src/wallet/ConnectWallet/Modal/ConnectModal.tsx index 82a9b16a632..f8c24b47f9c 100644 --- a/packages/react/src/wallet/ConnectWallet/Modal/ConnectModal.tsx +++ b/packages/react/src/wallet/ConnectWallet/Modal/ConnectModal.tsx @@ -71,7 +71,9 @@ export const ConnectModalContent = (props: { ? false : !!authConfig?.authUrl && !user?.address; - setHideModal(false); + onModalUnmount(() => { + setHideModal(false); + }); // show sign in screen if required if (requiresSignIn) { @@ -242,7 +244,9 @@ export const ConnectModal = () => { useEffect(() => { if (!isWalletModalOpen) { - setHideModal(false); + onModalUnmount(() => { + setHideModal(false); + }); } }, [isWalletModalOpen, setIsWalletModalOpen, screen]); @@ -268,6 +272,10 @@ export const ConnectModal = () => { size={modalSize} open={isWalletModalOpen} setOpen={(value) => { + if (hideModal) { + return; + } + setIsWalletModalOpen(value); if (!value) { const requiresSignIn = auth?.loginOptional diff --git a/packages/react/src/wallet/ConnectWallet/Modal/ConnectModalInline.tsx b/packages/react/src/wallet/ConnectWallet/Modal/ConnectModalInline.tsx index a18588bf5f5..e6591ea8b50 100644 --- a/packages/react/src/wallet/ConnectWallet/Modal/ConnectModalInline.tsx +++ b/packages/react/src/wallet/ConnectWallet/Modal/ConnectModalInline.tsx @@ -25,6 +25,9 @@ import { ConnectWalletProps } from "../ConnectWallet"; import { useTWLocale } from "../../../evm/providers/locale-provider"; import { StyledDiv } from "../../../design-system/elements"; +/** + * @internal + */ export const ConnectModalInline = ( props: Omit< ConnectWalletProps, diff --git a/packages/react/src/wallet/ConnectWallet/NetworkSelector.tsx b/packages/react/src/wallet/ConnectWallet/NetworkSelector.tsx index 691abc8f1be..898d814d306 100644 --- a/packages/react/src/wallet/ConnectWallet/NetworkSelector.tsx +++ b/packages/react/src/wallet/ConnectWallet/NetworkSelector.tsx @@ -34,23 +34,87 @@ import { import { useTWLocale } from "../../evm/providers/locale-provider"; import { StyledButton, StyledP, StyledUl } from "../../design-system/elements"; -type RenderChain = React.FC<{ +export type NetworkSelectorChainProps = { + /** + * `Chain` object for the chain to be displayed + */ chain: Chain; + /** + * function to be called for switching to the given chain + */ switchChain: () => void; + /** + * flag indicating whether the SDK is currently switching to the given chain + */ switching: boolean; + /** + * flag indicating whether the SDK failed to switch to the given chain + */ switchFailed: boolean; + /** + * function to close the modal + */ close?: () => void; -}>; +}; export type NetworkSelectorProps = { - theme: "dark" | "light" | Theme; + /** + * Theme to use in Modal + * + * Either specify string "dark" or "light" to use the default themes, or provide a custom theme object. + * + * You can also use `darkTheme` or `lightTheme` functions to use the default themes as base and override it. + * + * @example + * ```tsx + * import { darkTheme } from "@thirdweb-dev/react"; + * + * + * ``` + */ + theme?: "dark" | "light" | Theme; + /** + * Callback to be called when modal is closed by the user + */ onClose?: () => void; + /** + * Specify whether the Modal should be open or closed + */ open: boolean; + /** + * Array of chains to be displayed in the modal + */ chains?: Chain[]; + /** + * Array of chains to be displayed under "Popular" section + */ popularChains?: Chain[]; + /** + * Array of chains to be displayed under "Recent" section + */ recentChains?: Chain[]; - renderChain?: RenderChain; + /** + * Override how the chain button is rendered in the Modal + */ + renderChain?: React.FC; + + /** + * Callback to be called when a chain is successfully switched + * @param chain - the new chain that is switched to + */ onSwitch?: (chain: Chain) => void; + /** + * Callback to be called when the "Add Custom Network" button is clicked + * + * The "Add Custom Network" button is displayed at the bottom of the modal - only if this prop is provided + */ onCustomClick?: () => void; }; @@ -68,7 +132,25 @@ const fuseConfig = { ], }; -export const NetworkSelector: React.FC = (props) => { +/** + * Renders a Network Switcher Modal that allows users to switch their wallet to a different network. + * + * @example + * ```tsx + * import { NetworkSelector } from "@thirdweb-dev/react"; + * + * function Example() { + * const [open, setOpen] = useState(false); + * return ( + *
+ * + * setOpen(false)} /> + *
+ * ) + * } + * ``` + */ +export function NetworkSelector(props: NetworkSelectorProps) { const [searchTerm, setSearchTerm] = useState(""); const deferredSearchTerm = useDeferredValue(searchTerm); const themeFromContext = useCustomTheme(); @@ -310,7 +392,7 @@ export const NetworkSelector: React.FC = (props) => {
); -}; +} const filterChainByType = ( chains: Chain[], @@ -333,7 +415,7 @@ const NetworkTab = (props: { popularChains?: Chain[]; type: "testnet" | "mainnet" | "all"; onSwitch: (chain: Chain) => void; - renderChain?: RenderChain; + renderChain?: React.FC; close?: () => void; }) => { const allChains = useMemo( @@ -408,7 +490,7 @@ const NetworkTab = (props: { const NetworkList = /* @__PURE__ */ memo(function NetworkList(props: { chains: Chain[]; onSwitch: (chain: Chain) => void; - renderChain?: RenderChain; + renderChain?: React.FC; close?: () => void; }) { const switchChain = useSwitchChain(); diff --git a/packages/react/src/wallet/ConnectWallet/defaultTokens.ts b/packages/react/src/wallet/ConnectWallet/defaultTokens.ts index b79387bd555..8a0c0a77601 100644 --- a/packages/react/src/wallet/ConnectWallet/defaultTokens.ts +++ b/packages/react/src/wallet/ConnectWallet/defaultTokens.ts @@ -31,6 +31,31 @@ const fantomIcon = export type SupportedTokens = Record; +/** + * Default tokens shown in `ConnectWallet`'s SendFunds screen for each network. + * + * You can use the default tokens as a starting point for your own list of tokens and override tokens for specific networks. + * + * @example + * Below example shows adding a custom token for the Ethereum mainnet at start of the list of default tokens for the Ethereum mainnet. Here the `1` represents the chainId of Ethereum mainnet. + * + * ```tsx + * const ethereumChainId = 1; + * + * + * ``` + */ export const defaultTokens: SupportedTokens = { "1": [ { diff --git a/packages/react/src/wallet/ConnectWallet/screens/types.ts b/packages/react/src/wallet/ConnectWallet/screens/types.ts index 04de32cb489..f1183c75c49 100644 --- a/packages/react/src/wallet/ConnectWallet/screens/types.ts +++ b/packages/react/src/wallet/ConnectWallet/screens/types.ts @@ -1,10 +1,59 @@ +/** + * Render custom Welcome Screen in "wide" ConnectWallet Modal either by passing a custom React component or by passing an object with custom title, subtitle and image + * + * @example + * + * ### Custom React component + * ```tsx + *
+ * ... + *
} + * /> + * ``` + * + * ### Custom title, subtitle and image + * ```tsx + * + * ``` + */ export type WelcomeScreen = | { + /** + * Custom title + */ title?: string; + /** + * Custom subtitle + */ subtitle?: string; + /** + * Custom image + */ img?: { + /** + * Image source + */ src: string; + /** + * Image width + */ width?: number; + /** + * Image height + */ height?: number; }; } diff --git a/packages/react/src/wallet/hooks/useInstalledWallets.ts b/packages/react/src/wallet/hooks/useInstalledWallets.ts index be1ce037e53..cf61aa4655a 100644 --- a/packages/react/src/wallet/hooks/useInstalledWallets.ts +++ b/packages/react/src/wallet/hooks/useInstalledWallets.ts @@ -4,6 +4,9 @@ import { getInjectedMetamaskProvider, } from "@thirdweb-dev/wallets"; +/** + * @internal + */ export function useInstalledWallets() { let isMetamaskInstalled = false; let isCoinbaseWalletInstalled = false; diff --git a/packages/react/src/wallet/wallets/blocto/bloctoWallet.tsx b/packages/react/src/wallet/wallets/blocto/bloctoWallet.tsx index ef9749cce88..521aefd4018 100644 --- a/packages/react/src/wallet/wallets/blocto/bloctoWallet.tsx +++ b/packages/react/src/wallet/wallets/blocto/bloctoWallet.tsx @@ -1,23 +1,58 @@ import type { WalletConfig, WalletOptions } from "@thirdweb-dev/react-core"; import { BloctoWallet } from "@thirdweb-dev/wallets"; -export type BloctoAdditionalOptions = { +export type BloctoWalletConfigOptions = { /** - * Your app’s unique identifier that can be obtained at https://developers.blocto.app, - * To get advanced features and support with Blocto. - * - * https://docs.blocto.app/blocto-sdk/register-app-id + * To get advanced features and support from Blocto, you can create an appId from [blocto dashboard](https://docs.blocto.app/blocto-sdk/register-app-id) */ appId?: string; /** - * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal + * If true, the wallet will be tagged as "reccomended" in `ConnectWallet` Modal */ recommended?: boolean; }; +/** + * A wallet configurator for [Blocto Wallet](https://blocto.io/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const bloctoWalletConfig = bloctoWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(bloctoWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const bloctoWallet = ( - options?: BloctoAdditionalOptions, + options?: BloctoWalletConfigOptions, ): WalletConfig => ({ id: BloctoWallet.id, recommended: options?.recommended, diff --git a/packages/react/src/wallet/wallets/coin98/coin98Wallet.tsx b/packages/react/src/wallet/wallets/coin98/coin98Wallet.tsx index 28c42db738f..5eca54608bb 100644 --- a/packages/react/src/wallet/wallets/coin98/coin98Wallet.tsx +++ b/packages/react/src/wallet/wallets/coin98/coin98Wallet.tsx @@ -2,7 +2,7 @@ import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core"; import { Coin98Wallet, getInjectedCoin98Provider } from "@thirdweb-dev/wallets"; import { Coin98ConnectUI } from "./Coin98ConnectUI"; -type Coin98WalletOptions = { +export type Coin98WalletConfigOptions = { /** * When connecting Coin98 using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -17,8 +17,46 @@ type Coin98WalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Coin98 Wallet](https://coin98.com/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const coin98Config = coin98Wallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(coin98Config, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const coin98Wallet = ( - options?: Coin98WalletOptions, + options?: Coin98WalletConfigOptions, ): WalletConfig => { return { id: Coin98Wallet.id, diff --git a/packages/react/src/wallet/wallets/coinbase/coinbaseWallet.tsx b/packages/react/src/wallet/wallets/coinbase/coinbaseWallet.tsx index 54ddf47a17f..d7740354a57 100644 --- a/packages/react/src/wallet/wallets/coinbase/coinbaseWallet.tsx +++ b/packages/react/src/wallet/wallets/coinbase/coinbaseWallet.tsx @@ -12,10 +12,11 @@ import { } from "@thirdweb-dev/react-core"; import { useEffect, useRef } from "react"; -type CoinbaseWalletOptions = { +export type CoinbaseWalletConfigOptions = { /** * Whether to use the Coinbase's default QR Code modal or show the custom UI in ConnectWallet Modal - * @defaultValue "custom" + * + * The default is `"custom"` */ qrmodal?: "coinbase" | "custom"; @@ -25,8 +26,46 @@ type CoinbaseWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Coinbase Wallet](https://www.coinbase.com/wallet) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const coinbaseWalletConfig = coinbaseWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(coinbaseWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const coinbaseWallet = ( - options?: CoinbaseWalletOptions, + options?: CoinbaseWalletConfigOptions, ): WalletConfig => { const qrmodal = options?.qrmodal || "custom"; diff --git a/packages/react/src/wallet/wallets/coreWallet/coreWallet.tsx b/packages/react/src/wallet/wallets/coreWallet/coreWallet.tsx index 0ec6c409d1b..514eeb914aa 100644 --- a/packages/react/src/wallet/wallets/coreWallet/coreWallet.tsx +++ b/packages/react/src/wallet/wallets/coreWallet/coreWallet.tsx @@ -5,7 +5,7 @@ import { } from "@thirdweb-dev/wallets"; import { CoreWalletConnectUI } from "./CoreWalletConnectUI"; -type CoreWalletOptions = { +export type CoreWalletConfigOptions = { /** * When connecting Core using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -20,8 +20,46 @@ type CoreWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Core Wallet](https://core.app/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const coreWalletConfig = coreWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(coreWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const coreWallet = ( - options?: CoreWalletOptions, + options?: CoreWalletConfigOptions, ): WalletConfig => { return { id: CoreWallet.id, diff --git a/packages/react/src/wallet/wallets/defaultWallets.ts b/packages/react/src/wallet/wallets/defaultWallets.ts index e8befd1bb6c..dbaaa76be1e 100644 --- a/packages/react/src/wallet/wallets/defaultWallets.ts +++ b/packages/react/src/wallet/wallets/defaultWallets.ts @@ -7,6 +7,18 @@ import { zerionWallet } from "./zerion/zerionWallet"; import { rainbowWallet } from "./rainbow/RainbowWallet"; import { phantomWallet } from "./phantom/phantomWallet"; +/** + * The default wallets that are used by the `ThirdwebProvider` if no `supportedWallets` prop is provided. + * + * The defaults wallets are: + * - Metamask + * - Coinbase + * - WalletConnect + * - TrustWallet + * - RainbowWallet + * - ZerionWallet + * - PhantomWallet + */ export const defaultWallets: WalletConfig[] = /* @__PURE__ */ (() => [ metamaskWallet(), coinbaseWallet(), diff --git a/packages/react/src/wallet/wallets/defiWallet/cryptoDefiWallet.tsx b/packages/react/src/wallet/wallets/defiWallet/cryptoDefiWallet.tsx index ccf324e1e78..7da2b5e7a55 100644 --- a/packages/react/src/wallet/wallets/defiWallet/cryptoDefiWallet.tsx +++ b/packages/react/src/wallet/wallets/defiWallet/cryptoDefiWallet.tsx @@ -5,7 +5,7 @@ import { } from "@thirdweb-dev/wallets"; import { CryptoDefiWalletConnectUI } from "./CryptoDefiWalletConnectUI"; -type CryptoDefiWalletOptions = { +export type CryptoDefiWalletConfigOptions = { /** * When connecting Defi wallet using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -20,8 +20,46 @@ type CryptoDefiWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Crypto.com Defi Wallet](https://crypto.com/defi-wallet) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const cryptoDefiWalletConfig = cryptoDefiWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(cryptoDefiWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const cryptoDefiWallet = ( - options?: CryptoDefiWalletOptions, + options?: CryptoDefiWalletConfigOptions, ): WalletConfig => { return { id: CryptoDefiWallet.id, diff --git a/packages/react/src/wallet/wallets/embeddedWallet/embeddedWallet.tsx b/packages/react/src/wallet/wallets/embeddedWallet/embeddedWallet.tsx index 1d2f59bc997..9c209934bce 100644 --- a/packages/react/src/wallet/wallets/embeddedWallet/embeddedWallet.tsx +++ b/packages/react/src/wallet/wallets/embeddedWallet/embeddedWallet.tsx @@ -18,7 +18,7 @@ import { EmbeddedWalletSocialLogin } from "./EmbeddedWalletSocialLogin"; import { EmbeddedWalletOTPLoginUI } from "./EmbeddedWalletOTPLoginUI"; import { AuthOption, - EmbeddedWalletConfig, + EmbeddedWalletConfigOptions, EmbeddedWalletLoginType, } from "./types"; @@ -29,36 +29,139 @@ const DEFAULT_AUTH_OPTIONS: AuthOption[] = [ "facebook", ]; +/** + * A wallet configurator for [Embedded Wallet](https://portal.thirdweb.com/wallet/embedded-wallet) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useEmbeddedWallet + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The hook will return all the necessary functions you'll need to authenticate and connect to the embedded wallet. + * + * ### Connect with Google/Facebook/Apple sign in + * + * ```tsx + * import { useEmbeddedWallet } from "@thirdweb-dev/react"; + * + * function App() { + * const { connect } = useEmbeddedWallet(); + * + * async function handleConnect() { + * const wallet = await connect({ + * strategy: "google", // or "facebook" or "apple" + * }); + * + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + * + * ### Connect with Email verification + * + * ```tsx + * function App() { + * const { connect, sendVerificationEmail } = useEmbeddedWallet(); + * + * const preLogin = async (email: string) => { + * // send email verification code + * await sendVerificationEmail({ email }); + * }; + * + * const handleLogin = async (email: string, verificationCode: string) => { + * // verify email and connect + * await connect({ + * strategy: "email_verification", + * email, + * verificationCode, + * }); + * }; + * + * return
...
; + * } + * ``` + * + * ### Connecting with Iframe + * + * ```tsx + * function App() { + * const { connect } = useEmbeddedWallet(); + * + * const handleConnect = async () => { + * await connect({ + * strategy: "iframe", + * }); + * }; + * + * return
...
; + * } + * ``` + * + * ### Connect with your own auth with JWT + * + * ```tsx + * function App() { + * const { connect } = useEmbeddedWallet(); + * + * async function handleConnect() { + * const wallet = await connect({ + * strategy: "jwt", + * jwt: "your_jwt_token", + * }); + * + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + + */ export const embeddedWallet = ( - _config?: EmbeddedWalletConfig, + options?: EmbeddedWalletConfigOptions, ): WalletConfig => { - const defaultConfig: EmbeddedWalletConfig = { + const defaultConfig: EmbeddedWalletConfigOptions = { auth: { options: DEFAULT_AUTH_OPTIONS, }, }; - const config: EmbeddedWalletConfig = _config - ? { ...defaultConfig, ..._config } + const finalOptions: EmbeddedWalletConfigOptions = options + ? { ...defaultConfig, ...options } : defaultConfig; - const { auth } = config; + const { auth } = finalOptions; return { category: "socialLogin", isHeadless: true, id: EmbeddedWallet.id, - recommended: config?.recommended, + recommended: finalOptions?.recommended, meta: { ...EmbeddedWallet.meta, name: "Email", iconURL: emailIcon, }, - create(options: WalletOptions) { + create(walletOptions: WalletOptions) { return new EmbeddedWallet({ - ...options, - ...config, - clientId: options?.clientId ?? "", + ...walletOptions, + ...finalOptions, + clientId: walletOptions?.clientId ?? "", }); }, selectUI(props) { diff --git a/packages/react/src/wallet/wallets/embeddedWallet/types.ts b/packages/react/src/wallet/wallets/embeddedWallet/types.ts index 15b54249347..5693a301b3d 100644 --- a/packages/react/src/wallet/wallets/embeddedWallet/types.ts +++ b/packages/react/src/wallet/wallets/embeddedWallet/types.ts @@ -5,7 +5,7 @@ import type { export type AuthOption = EmbeddedWalletOauthStrategy | "email"; -export type EmbeddedWalletConfig = Omit< +export type EmbeddedWalletConfigOptions = Omit< EmbeddedWalletAdditionalOptions, "chain" | "clientId" > & { @@ -16,7 +16,14 @@ export type EmbeddedWalletConfig = Omit< /** * Choose which auth providers to show in the wallet connection UI - * @defaultValue `auth: { options: ["email", "google", "apple", "facebook"] }` + * + * By default, all auth methods are enabled, which is equivalent to setting the following: + * + * ```ts + * { + * options: ["email", "google", "apple", "facebook"] + * } + * ``` */ auth?: { options: AuthOption[]; diff --git a/packages/react/src/wallet/wallets/frame/frameWallet.tsx b/packages/react/src/wallet/wallets/frame/frameWallet.tsx index ec468bb5dc5..02c40634a53 100644 --- a/packages/react/src/wallet/wallets/frame/frameWallet.tsx +++ b/packages/react/src/wallet/wallets/frame/frameWallet.tsx @@ -2,15 +2,53 @@ import type { WalletConfig, WalletOptions } from "@thirdweb-dev/react-core"; import { FrameWallet, assertWindowEthereum } from "@thirdweb-dev/wallets"; import { FrameConnectUI } from "./FrameConnectUI"; -type FrameConfig = { +export type FrameWalletConfigOptions = { /** * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal */ recommended?: boolean; }; +/** + * A wallet configurator for [Frame Wallet](https://frame.sh/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const frameWalletConfig = frameWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(frameWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const frameWallet = ( - config?: FrameConfig, + config?: FrameWalletConfigOptions, ): WalletConfig => ({ id: FrameWallet.id, recommended: config?.recommended, diff --git a/packages/react/src/wallet/wallets/headlessConnectUI.tsx b/packages/react/src/wallet/wallets/headlessConnectUI.tsx index e3a4979f13e..33450464aac 100644 --- a/packages/react/src/wallet/wallets/headlessConnectUI.tsx +++ b/packages/react/src/wallet/wallets/headlessConnectUI.tsx @@ -29,10 +29,11 @@ export const HeadlessConnectUI = ({ } catch (e) { if (!singleWallet) { goBack(); - show(); } console.error(e); } + + show(); })(); }, [walletConfig, connect, singleWallet, connected, hide, show, goBack]); diff --git a/packages/react/src/wallet/wallets/localWallet/localWallet.tsx b/packages/react/src/wallet/wallets/localWallet/localWallet.tsx index 1cf06f478c0..998f38496f4 100644 --- a/packages/react/src/wallet/wallets/localWallet/localWallet.tsx +++ b/packages/react/src/wallet/wallets/localWallet/localWallet.tsx @@ -8,6 +8,44 @@ const desktopIcon = const phoneIcon = `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiByeD0iMTIiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl80NF8yKSIvPgo8cGF0aCBkPSJNNDguNjE1NCAxNkgzMS4zODQ2QzI4LjQxMjMgMTYgMjYgMTguMzkyNyAyNiAyMS4zNDA5VjU3LjY1OTFDMjYgNjAuNjA3MyAyOC40MTIzIDYzIDMxLjM4NDYgNjNINDguNjE1NEM1MS41ODc3IDYzIDU0IDYwLjYwNzMgNTQgNTcuNjU5MVYyMS4zNDA5QzU0IDE4LjM5MjcgNTEuNTg3NyAxNiA0OC42MTU0IDE2Wk00MCA2MC44NjM2QzM4LjIxMjMgNjAuODYzNiAzNi43NjkyIDU5LjQzMjMgMzYuNzY5MiA1Ny42NTkxQzM2Ljc2OTIgNTUuODg1OSAzOC4yMTIzIDU0LjQ1NDUgNDAgNTQuNDU0NUM0MS43ODc3IDU0LjQ1NDUgNDMuMjMwOCA1NS44ODU5IDQzLjIzMDggNTcuNjU5MUM0My4yMzA4IDU5LjQzMjMgNDEuNzg3NyA2MC44NjM2IDQwIDYwLjg2MzZaTTQ5LjY5MjMgNTIuMzE4MkgzMC4zMDc3VjIyLjQwOTFINDkuNjkyM1Y1Mi4zMTgyWiIgZmlsbD0id2hpdGUiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl80NF8yIiB4MT0iNDAiIHkxPSIwIiB4Mj0iNDAiIHkyPSI4MCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjQ0UxMUFCIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzkwMEJCNSIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=`; +/** + * A wallet configurator for Local wallet which allows integrating a "Guest Login" experience to app. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const localeWalletConfig = localeWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(localeWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const localWallet = ( config?: LocalWalletConfigOptions, ): LocalWalletConfig => { diff --git a/packages/react/src/wallet/wallets/localWallet/types.ts b/packages/react/src/wallet/wallets/localWallet/types.ts index 16b31c20a7a..12b6487b8f1 100644 --- a/packages/react/src/wallet/wallets/localWallet/types.ts +++ b/packages/react/src/wallet/wallets/localWallet/types.ts @@ -9,7 +9,7 @@ export type LocalWalletConfigOptions = { * If `false`, wallet will not be stored, and no password will be required to connect. * the wallet will be lost when the user leaves or reloads the page. * - * @defaultValue true + * By default, it is set to `true`. */ persist?: boolean; }; diff --git a/packages/react/src/wallet/wallets/magic/magicLink.tsx b/packages/react/src/wallet/wallets/magic/magicLink.tsx index 7480ce81bed..bbb2f6955de 100644 --- a/packages/react/src/wallet/wallets/magic/magicLink.tsx +++ b/packages/react/src/wallet/wallets/magic/magicLink.tsx @@ -43,13 +43,57 @@ import { } from "../../ConnectWallet/icons/socialLogins"; import { useCustomTheme } from "../../../design-system/CustomThemeProvider"; +export type MagicWalletConfigOptions = MagicLinkAdditionalOptions & { + /** + * If true, the wallet will be tagged as "recommended" in ConnectWallet Modal + */ + recommended?: boolean; +}; + +/** + * A wallet configurator for [Magic Link](https://magic.link/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const magicLinkConfig = magicLink({ + * apiKey: "MAGIC_API_KEY, + * }); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(magicLinkConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export function magicLink( - config: MagicLinkAdditionalOptions & { - /** - * If true, the wallet will be tagged as "recommended" in ConnectWallet Modal - */ - recommended?: boolean; - }, + config: MagicWalletConfigOptions, ): ConfiguredMagicLinkWallet { const emailLoginEnabled = config.emailLogin !== false; const smsLoginEnabled = config.smsLogin !== false; diff --git a/packages/react/src/wallet/wallets/metamask/MetamaskConnectUI.tsx b/packages/react/src/wallet/wallets/metamask/MetamaskConnectUI.tsx index 703985941ca..8134a3fca25 100644 --- a/packages/react/src/wallet/wallets/metamask/MetamaskConnectUI.tsx +++ b/packages/react/src/wallet/wallets/metamask/MetamaskConnectUI.tsx @@ -7,16 +7,30 @@ import { GetStartedScreen } from "../../ConnectWallet/screens/GetStartedScreen"; import { MetaMaskWallet } from "@thirdweb-dev/wallets"; import { wait } from "../../../utils/wait"; import { useTWLocale } from "../../../evm/providers/locale-provider"; +import { metamaskUris } from "./metamaskUris"; +import { WCOpenURI } from "../../ConnectWallet/screens/WCOpenUri"; -export const MetamaskConnectUI = (props: ConnectUIProps) => { +export const MetamaskConnectUI = ( + props: ConnectUIProps & { + connectionMethod: "walletConnect" | "metamaskBrowser"; + }, +) => { const [screen, setScreen] = useState< - "connecting" | "scanning" | "get-started" + "connecting" | "scanning" | "get-started" | "open-wc-uri" >("connecting"); const locale = useTWLocale().wallets.metamaskWallet; const { walletConfig, connected } = props; const connect = useConnect(); const [errorConnecting, setErrorConnecting] = useState(false); + const connectingLocale = { + getStartedLink: locale.getStartedLink, + instruction: locale.connectionScreen.instruction, + tryAgain: locale.connectionScreen.retry, + inProgress: locale.connectionScreen.inProgress, + failed: locale.connectionScreen.failed, + }; + const hideBackButton = props.supportedWallets.length === 1; const connectToExtension = useCallback(async () => { @@ -53,27 +67,25 @@ export const MetamaskConnectUI = (props: ConnectUIProps) => { else { // on mobile, open metamask app link if (isMobile()) { - window.open( - `https://metamask.app.link/dapp/${window.location.toString()}`, - ); + if (props.connectionMethod === "walletConnect") { + setScreen("open-wc-uri"); + } else { + window.open( + `https://metamask.app.link/dapp/${window.location.toString()}`, + ); + } } else { // on desktop, show the metamask scan qr code setScreen("scanning"); } } })(); - }, [connectToExtension, walletConfig]); + }, [connectToExtension, props.connectionMethod, walletConfig]); if (screen === "connecting") { return ( { setScreen("get-started"); @@ -103,6 +115,26 @@ export const MetamaskConnectUI = (props: ConnectUIProps) => { ); } + if (screen === "open-wc-uri") { + return ( + { + // NOOP - TODO make onRetry optional + }} + errorConnecting={errorConnecting} + onGetStarted={() => { + setScreen("get-started"); + }} + hideBackButton={hideBackButton} + onBack={props.goBack} + onConnected={connected} + walletConfig={walletConfig} + appUriPrefix={metamaskUris} + /> + ); + } + if (screen === "scanning") { return ( + * + *
+ * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const metamaskWalletConfig = metamaskWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(metamaskWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const metamaskWallet = ( - options?: MetamaskWalletOptions, + options?: MetamaskWalletConfigOptions, ): WalletConfig => { + const connectionMethod = options?.connectionMethod || "walletConnect"; + return { id: MetaMaskWallet.id, recommended: options?.recommended, @@ -38,9 +90,17 @@ export const metamaskWallet = ( qrcode: false, }); + if (connectionMethod === "walletConnect") { + handelWCSessionRequest(wallet, metamaskUris); + } + return wallet; }, - connectUI: MetamaskConnectUI, + connectUI(props) { + return ( + + ); + }, isInstalled() { return !!getInjectedMetamaskProvider(); }, diff --git a/packages/react/src/wallet/wallets/okx/okxWallet.tsx b/packages/react/src/wallet/wallets/okx/okxWallet.tsx index 6e9ddd3ddf2..0fabb293146 100644 --- a/packages/react/src/wallet/wallets/okx/okxWallet.tsx +++ b/packages/react/src/wallet/wallets/okx/okxWallet.tsx @@ -2,7 +2,7 @@ import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core"; import { OKXWallet, getInjectedOKXProvider } from "@thirdweb-dev/wallets"; import { OKXConnectUI } from "./OKXConnectUI"; -type OKXWalletOptions = { +export type OKXWalletConfigOptions = { /** * When connecting OKX using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -17,8 +17,46 @@ type OKXWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [OKX Wallet](https://www.okx.com/web3) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const okxWalletConfig = okxWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(okxWalletConfig); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const okxWallet = ( - options?: OKXWalletOptions, + options?: OKXWalletConfigOptions, ): WalletConfig => { return { id: OKXWallet.id, diff --git a/packages/react/src/wallet/wallets/oneKey/OneKeyConnectUI.tsx b/packages/react/src/wallet/wallets/oneKey/OneKeyConnectUI.tsx new file mode 100644 index 00000000000..4bfa639bf8f --- /dev/null +++ b/packages/react/src/wallet/wallets/oneKey/OneKeyConnectUI.tsx @@ -0,0 +1,148 @@ +import { ConnectUIProps, useConnect } from "@thirdweb-dev/react-core"; +import { ConnectingScreen } from "../../ConnectWallet/screens/ConnectingScreen"; +import { isMobile } from "../../../evm/utils/isMobile"; +import { useCallback, useEffect, useRef, useState } from "react"; +import { OneKeyScan } from "./OneKeyScan"; +import { GetStartedScreen } from "../../ConnectWallet/screens/GetStartedScreen"; +import type { OneKeyWallet } from "@thirdweb-dev/wallets"; +import { wait } from "../../../utils/wait"; +import { useTWLocale } from "../../../evm/providers/locale-provider"; +import { WCOpenURI } from "../../ConnectWallet/screens/WCOpenUri"; +import { oneKeyWalletUris } from "./oneKeyWalletUris"; + +export const OneKeyConnectUI = (props: ConnectUIProps) => { + const [screen, setScreen] = useState< + "connecting" | "scanning" | "get-started" | "open-wc-uri" + >("connecting"); + const locale = useTWLocale().wallets.oneKeyWallet; + const connectingLocale = { + getStartedLink: locale.getStartedLink, + instruction: locale.connectionScreen.instruction, + tryAgain: locale.connectionScreen.retry, + inProgress: locale.connectionScreen.inProgress, + failed: locale.connectionScreen.failed, + }; + const { walletConfig, connected } = props; + const connect = useConnect(); + const [errorConnecting, setErrorConnecting] = useState(false); + + const hideBackButton = props.supportedWallets.length === 1; + + const connectToExtension = useCallback(async () => { + try { + connectPrompted.current = true; + setErrorConnecting(false); + setScreen("connecting"); + await wait(1000); + await connect(walletConfig); + connected(); + } catch (e) { + setErrorConnecting(true); + console.error(e); + } + }, [connected, connect, walletConfig]); + + const connectPrompted = useRef(false); + useEffect(() => { + if (connectPrompted.current) { + return; + } + + const isInstalled = walletConfig.isInstalled + ? walletConfig.isInstalled() + : false; + + // if loading + (async () => { + if (isInstalled) { + connectToExtension(); + } + + // if wallet is not injected + else { + // on mobile, open the OneKey Mobile via wallet connect + if (isMobile()) { + setScreen("open-wc-uri"); + } else { + // on desktop, show the OneKey app scan qr code + setScreen("scanning"); + } + } + })(); + }, [connectToExtension, walletConfig]); + + if (screen === "connecting") { + return ( + { + setScreen("get-started"); + }} + onRetry={connectToExtension} + hideBackButton={hideBackButton} + onBack={props.goBack} + walletName={walletConfig.meta.name} + walletIconURL={walletConfig.meta.iconURL} + /> + ); + } + + if (screen === "open-wc-uri") { + return ( + { + // NOOP - TODO make onRetry optional + }} + errorConnecting={errorConnecting} + onGetStarted={() => { + setScreen("get-started"); + }} + hideBackButton={hideBackButton} + onBack={props.goBack} + onConnected={connected} + walletConfig={walletConfig} + appUriPrefix={oneKeyWalletUris} + /> + ); + } + + if (screen === "get-started") { + return ( + + ); + } + + if (screen === "scanning") { + return ( + { + setScreen("get-started"); + }} + hideBackButton={hideBackButton} + walletConfig={walletConfig} + /> + ); + } + + return null; +}; diff --git a/packages/react/src/wallet/wallets/oneKey/OneKeyScan.tsx b/packages/react/src/wallet/wallets/oneKey/OneKeyScan.tsx new file mode 100644 index 00000000000..38211df8bbd --- /dev/null +++ b/packages/react/src/wallet/wallets/oneKey/OneKeyScan.tsx @@ -0,0 +1,65 @@ +import { ScanScreen } from "../../ConnectWallet/screens/ScanScreen"; +import { + useCreateWalletInstance, + useWalletContext, +} from "@thirdweb-dev/react-core"; +import { useEffect, useRef, useState } from "react"; +import type { OneKeyWallet } from "@thirdweb-dev/wallets"; +import type { WalletConfig } from "@thirdweb-dev/react-core"; +import { useTWLocale } from "../../../evm/providers/locale-provider"; + +export const OneKeyScan: React.FC<{ + onBack: () => void; + onGetStarted: () => void; + onConnected: () => void; + walletConfig: WalletConfig; + hideBackButton: boolean; +}> = ({ onBack, onConnected, onGetStarted, walletConfig, hideBackButton }) => { + const locale = useTWLocale().wallets.oneKeyWallet; + const createInstance = useCreateWalletInstance(); + const [qrCodeUri, setQrCodeUri] = useState(); + const { setConnectedWallet, chainToConnect, setConnectionStatus } = + useWalletContext(); + + const scanStarted = useRef(false); + useEffect(() => { + if (scanStarted.current) { + return; + } + scanStarted.current = true; + + const wallet = createInstance(walletConfig); + + setConnectionStatus("connecting"); + wallet.connectWithQrCode({ + chainId: chainToConnect?.chainId, + onQrCodeUri(uri) { + setQrCodeUri(uri); + }, + onConnected() { + setConnectedWallet(wallet); + onConnected(); + }, + }); + }, [ + createInstance, + setConnectedWallet, + chainToConnect, + onConnected, + walletConfig, + setConnectionStatus, + ]); + + return ( + + ); +}; diff --git a/packages/react/src/wallet/wallets/oneKey/oneKeyWallet.tsx b/packages/react/src/wallet/wallets/oneKey/oneKeyWallet.tsx new file mode 100644 index 00000000000..05b8625d9a7 --- /dev/null +++ b/packages/react/src/wallet/wallets/oneKey/oneKeyWallet.tsx @@ -0,0 +1,90 @@ +import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core"; +import { OneKeyWallet, getInjectedOneKeyProvider } from "@thirdweb-dev/wallets"; +import { OneKeyConnectUI } from "./OneKeyConnectUI"; + +export type OneKeyWalletConfigOptions = { + /** + * When connecting OneKey wallet using the QR Code - Wallet Connect connector is used which requires a project id. + * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. + * + * https://docs.walletconnect.com/2.0/web3modal/options#projectid-required + */ + projectId?: string; + + /** + * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal + */ + recommended?: boolean; +}; + +/** + * A wallet configurator for [Onekey Wallet](https://onekey.so/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const oneKeyWalletConfig = oneKeyWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(oneKeyWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ +export const oneKeyWallet = ( + options?: OneKeyWalletConfigOptions, +): WalletConfig => { + return { + id: OneKeyWallet.id, + recommended: options?.recommended, + meta: { + name: "OneKey Wallet", + urls: { + chrome: + "https://chrome.google.com/webstore/detail/onekey/jnmbobjmhlngoefaiojfljckilhhlhcj", + android: + "https://play.google.com/store/apps/details?id=so.onekey.app.wallet", + ios: "https://apps.apple.com/us/app/onekey-blockchain-defi-wallet/id1609559473", + }, + iconURL: + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAAAXNSR0IArs4c6QAACZ9JREFUeF7tnU9M1EcUx98gNhiFlFhMAYurbcAFrCZNq0lNigKJR7XnKl7btGerB/FQ61nTXiXtucrdRTFpk1LbQ1tg1VglVqSBGMyuRlIWpnk/+NFlWdyZnfn92Tfvl+DBzG9m3vd99r33m/n9EVDmcSS9L5GD3Em5KBNCiIQEmRAgEmV2x6eFpIAEOYFDCRATUsqJqqqqW/h/qeTocDlTEDonrUAjZR/DoqNc/NsiREKIgVRy9LzObJUA8sEBCf06nXPbylNAF6SSAPWkO7tAws3Kk4JnbKKAKkivBKgn3XmOo46JGyr7XBWI1gWoZ7wTo05XZUvAs7ehgJRyYKhj7FSxvooCxPDYkJ1WH+tBtAYgTlu0HG/VGgH9hVdpqwDigtmq3OQ6w5qoSlSdv578c8A3bhVA3eMdD3l9h5zfrRqEEA21j+1cAxCnLqs6k+4svx5aiUA9452StNVsnDUF8qOQBxBHH2vautPRckHtAcS1jzt+t2WpH4WWIhCnL1u6utWPgEOiN72nT0p5xS3L2VorCgjoF91jHVeEEH1WOuROXFNgWPC2hWs+t2rvsOAC2qqgTnXm7dZzAe2Uz60aywBZldPNzjgCuel3a1YzQNakdLMjBshNv1uzmgGyJqWbHTFAbvrdmtUMkDUp3eyIAXLT79asZoCsSelmRwyQm363ZrUzAM0MZSB7Z86acPXvb4b6DzZb669SO3IGoJ9678HLyX+t+WnXZ9sA/1w/nADo+Z05+Pn4fau+ZoCW5HQCoHsXp+DRd08ZIKsKOASQ7fSF0nEEcgSgINIXA/R/KCOfwv7+/inc/XrKevDmCORIBBr5+D5k0/Yu330SGSAHAJqbnIcfe+9ajz6cwhxJYUGlLwbIEYCCSl8MkCMAYQpTPX7tewA67bkGcqAGUoUH22GtxADpKMYArVKLAdKHx5mtDBVpGCAVlda2Ib+QqCoLA6Sq1Op2DNCyHgwQA1SeAgyQkW4cgRggBshIAQbISD6OQAwQA2SkAANkJB9HIAaIATJSgAEyko8jEAPEABkpwAAZyccRiAFigIwUYICM5OMIxAAxQEYKMEBG8nEEYoAYICMFGCAj+TgCMUAMkJECyyfjM2TzmQXlrvgFU0tScQRSRoYbFlOAAWIujBRggIzk45MZoCIM5LKLkMssrLxTsbp2A2za/hpU11YxMQUKOA8QwpJNv4SZG1nI3nkJ+EKq9YrpjXUbYMvuGqjdvQkaDtfyW1pdLqIRlCeDz2BqcFbr6iv/B7ip+TUPol2fboOa5o1ORifnIhA+/z529jHM/vLCqsObjtU7CZJTAD34Zhp013t0KXPtrR1OAIRR5/fPH3k1ThgHprb3BnY6kdbIA4S1DsJj8y31KhAiRO9eaoHaZI1K84ptQxoghOe3vodlF8mmXsXLf4xElCEiCxCmLXzFnc7+likwxc5HiA5cfYdsOiMJEMKDkSfstLUegJjO9l99GxAmagdJgMbPTsKTa7Ox8hWuF2E6o3aQA2hq8BmMnXlclp9wpbmhuw5q22q8FWeMHHhgJMN6avb2C++v3LTYcWE7NB59vay5xfUkUgDhtsTI8fvaqQvBeeuTrdBy4o2S+104xkwqAw++ndYeB1PYwVQrqVRGCiBcKMQ/nQMjQtuXTSXBKewT6ywc68mgXqqkttBICiDdzzrZcKYutNSiEBmAdGsfG/D4UUkXor2Xd0BDd61OoIxtWzIA4WW76gZpEFdEUY8fFWEkAMplF2B4f1pZw4PX26wv7Ol8GYhSGiMBEEYejAAqR9PRemi/0KzSVLvN+JlJ5aIa14QofDacBEA6n3UK0nE6ILeeboSWE1u1IY3bCSQAUv3lY+roGkkG6oNbB9JKC41BRsJADSzonARAqgVsEMVzobP++OIRTKcyJX0YxlxKTsJCAxIAqX5YDlMGpo4gD9Vv1OM2yYfXW4OcSih9kwBI9TsXNtd+1vOO6poQAxQK32qDqAIUpwiEjwbhLR6VfpCIQKo1UBiFK9dAFfiTUL0KCyNtqO7H4W0jey+3VKDaq6dMIgKpFq5oehCr0L6kOqvRYdRjYdBJAqCZoYz35IXKEaTjdO6E3HtpBzT0VP6GKgmAdPbCgtqH0r0PO8hIqPJDstWGBEAohmohjW3xzsPW02/a0tDrRyf6UFlERLvJAKS6/uJTY/P+ZJ29OBy/46vt0HiMxr3RZADCNIZXQKo3vNt66E9nA9WHl0r6IhWB0BidqzHfmSa74rqRB8cMYy3Kam4u0RmZCIR2lvs0Kq7JtJ1uVL7JDKMOPpWhegdkvg8oRR9yEQgN0q2F8p2LxS1GiC1tNWueZ0c4Z25kYHooUxY4OE6QSwhhRp38sUhFIDQMa6GR439pP7NVzAH+W8cQHtMjjFVw0zmWcz45gFCEqN/KUegIfHBx/w80X7BAEiB04NS1Z96r7OJwmBTqcZj/q+ZAFiDTesiW4yjWPaRroELHmxTVphBRjjy+NqQjkG8kbrbeu/iPlcJaBSqsefD1dhQe2yllrxMA+WtEQbzet1BghAa3Klx5b7QzAPmOxuK6nFezlPol4mU6vnCcyh5XKXudSmHFxLAFEkacbYfroPFYvfYrYlSdFOd2zkWgQmf4nzyYvf0csuk5JV/hW1cbDtcBf3SO0O0cSp5XaIT7W7iajavP89mlLxjWNC19B6MuuQlqmvmrPU5dxisww00MFHA+hRlox6dSuiORvRmNAhyBotGdzKgMEBlXRmMIAxSN7mRGZYDIuDIaQxigaHQnMyoDRMaV0RjCAEWjO5lRGSAyrozGENE93vFQgEhEMzyPWskKSJATGIFuAkBXJRvCc49MgWEGKDLtK39gKeWA6E3v6ZNSXql8c9iCsBUQQpwSR9L7EjmZU/vQRNgz5PFirUC1qN4pcIZcB8XaT7GdXKp9VHgAcRqLrY/iOzEB/ank6HkPIE5j8fVTXGeG0Qfn5v3DUSiuborpvJajzyqAMArNy/mbvKgYU6fFaFp+9FkFEEehGHkozlMRcCiVHB32p7iSwvz/6El3ngMJ/XG2gecWkQJ5qWtdgLzLeoYoIg/FetjhVPvoocIZrolAK1dlkDvJkSjWDg1zckXhWVMDFc6II1GYPorpWEXSVv5Mi0ag/AY96c4u3Cvjq7OYOjigaXm3aghxKr9gLjZUSYA4pQXkoZh2uwzOAK4yq0xRCSC/I2/Feqk2wvuH+B4iFYUrpI0uOK+8ClOxGWFagIWuxcXFj4QQCQkywWlORblo2yAoS8WvmJBSTogqMaEabYrN/D+ZQA7oQV+JEwAAAABJRU5ErkJggg==", + }, + create: (walletOptions: WalletOptions) => { + const wallet = new OneKeyWallet({ + ...walletOptions, + projectId: options?.projectId, + qrcode: false, + }); + + return wallet; + }, + connectUI: OneKeyConnectUI, + isInstalled() { + return !!getInjectedOneKeyProvider(); + }, + }; +}; diff --git a/packages/react/src/wallet/wallets/oneKey/oneKeyWalletUris.ts b/packages/react/src/wallet/wallets/oneKey/oneKeyWalletUris.ts new file mode 100644 index 00000000000..441e1bfebfe --- /dev/null +++ b/packages/react/src/wallet/wallets/oneKey/oneKeyWalletUris.ts @@ -0,0 +1,5 @@ +export const oneKeyWalletUris = { + ios: "onekey-wallet://", + android: "onekey-wallet://", + other: "onekey-wallet://", +}; diff --git a/packages/react/src/wallet/wallets/paper/paperWallet.tsx b/packages/react/src/wallet/wallets/paper/paperWallet.tsx index 5bf5af3594b..38f6ab85e7c 100644 --- a/packages/react/src/wallet/wallets/paper/paperWallet.tsx +++ b/packages/react/src/wallet/wallets/paper/paperWallet.tsx @@ -10,7 +10,7 @@ import { PaperFormUI, PaperFormUIScreen } from "./PaperFormUI"; import { PaperOTPLoginUI } from "./PaperOTPLoginUI"; import { OAuthProvider, - PaperConfig, + PaperWalletConfigOptions, PaperLoginType, RecoveryShareManagement, } from "./types"; @@ -21,48 +21,45 @@ import { PaperGoogleLogin } from "./PaperGoogleLogin"; import { emailIcon } from "../../ConnectWallet/icons/dataUris"; /** - * Paper Wallet - * - * @param _config - Options available to create a paper wallet - * @returns The WalletConfig object + * A wallet configurator for [Paper Wallet](https://withpaper.com/) which allows integrating the wallet with React. * * @deprecated We have deprecated PaperWallet in favor of our {@link EmbeddedWallet} which adds support for more sign in methods. * Learn more here: https://portal.thirdweb.com/embedded-wallet */ export const paperWallet = ( - _config?: PaperConfig, + options?: PaperWalletConfigOptions, ): WalletConfig => { const defaultRecovery = "AWS_MANAGED"; - const defaultConfig: PaperConfig = { + const defaultConfig: PaperWalletConfigOptions = { oauthOptions: { providers: ["google"], }, }; - const config: PaperConfig = _config - ? { ...defaultConfig, ..._config } + const finalOptions: PaperWalletConfigOptions = options + ? { ...defaultConfig, ...options } : defaultConfig; - const { oauthOptions } = config; + const { oauthOptions } = finalOptions; return { category: "socialLogin", isHeadless: true, id: PaperWallet.id, - recommended: config?.recommended, + recommended: finalOptions?.recommended, meta: { ...PaperWallet.meta, name: "Email", iconURL: emailIcon, }, - create(options: WalletOptions) { + create(walletOptions: WalletOptions) { return new PaperWallet({ - ...options, - ...config, + ...walletOptions, + ...finalOptions, advancedOptions: { recoveryShareManagement: "AWS_MANAGED", - ...config?.advancedOptions, + ...finalOptions?.advancedOptions, }, }); }, @@ -71,7 +68,8 @@ export const paperWallet = ( @@ -82,7 +80,8 @@ export const paperWallet = ( diff --git a/packages/react/src/wallet/wallets/paper/types.ts b/packages/react/src/wallet/wallets/paper/types.ts index e7cab2ed47b..8a63e34f825 100644 --- a/packages/react/src/wallet/wallets/paper/types.ts +++ b/packages/react/src/wallet/wallets/paper/types.ts @@ -2,7 +2,7 @@ import { PaperWalletAdditionalOptions } from "@thirdweb-dev/wallets"; export type OAuthProvider = "google"; -export type PaperConfig = Omit< +export type PaperWalletConfigOptions = Omit< PaperWalletAdditionalOptions, "chain" | "clientId" > & { @@ -13,7 +13,14 @@ export type PaperConfig = Omit< /** * Enable or Disable OAuth logins and specify which providers to use for OAuth - * @defaultValue `{ providers: ["google"] }` + * + * By default, google is enabled which is equivalent to setting the following: + * + * ```ts + * { + * providers: ["google"] + * } + * ``` */ oauthOptions?: | { diff --git a/packages/react/src/wallet/wallets/phantom/phantomWallet.tsx b/packages/react/src/wallet/wallets/phantom/phantomWallet.tsx index 63054976120..9457e852f6b 100644 --- a/packages/react/src/wallet/wallets/phantom/phantomWallet.tsx +++ b/packages/react/src/wallet/wallets/phantom/phantomWallet.tsx @@ -5,15 +5,53 @@ import { } from "@thirdweb-dev/wallets"; import { PhantomConnectUI } from "./PhantomConnectUI"; -type PhantomWalletOptions = { +export type PhantomWalletConfigOptions = { /** * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal */ recommended?: boolean; }; +/** + * A wallet configurator for [Phantom Wallet](https://phantom.app/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const phantomWalletConfig = phantomWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(phantomWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const phantomWallet = ( - options?: PhantomWalletOptions, + options?: PhantomWalletConfigOptions, ): WalletConfig => { return { recommended: options?.recommended, diff --git a/packages/react/src/wallet/wallets/rabby/rabbyWallet.tsx b/packages/react/src/wallet/wallets/rabby/rabbyWallet.tsx index a7092403c86..ce4aa7e1075 100644 --- a/packages/react/src/wallet/wallets/rabby/rabbyWallet.tsx +++ b/packages/react/src/wallet/wallets/rabby/rabbyWallet.tsx @@ -2,7 +2,7 @@ import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core"; import { RabbyWallet, getInjectedRabbyProvider } from "@thirdweb-dev/wallets"; import { RabbyConnectUI } from "./RabbyConnectUI"; -type RabbyWalletOptions = { +export type RabbyWalletConfigOptions = { /** * When connecting Rabby using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -17,8 +17,46 @@ type RabbyWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Rabby Wallet](https://rabby.io/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const rabbyWalletConfig = rabbyWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(rabbyWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const rabbyWallet = ( - options?: RabbyWalletOptions, + options?: RabbyWalletConfigOptions, ): WalletConfig => { return { id: RabbyWallet.id, diff --git a/packages/react/src/wallet/wallets/rainbow/RainbowWallet.tsx b/packages/react/src/wallet/wallets/rainbow/RainbowWallet.tsx index b1435310458..a5c45aa427d 100644 --- a/packages/react/src/wallet/wallets/rainbow/RainbowWallet.tsx +++ b/packages/react/src/wallet/wallets/rainbow/RainbowWallet.tsx @@ -7,7 +7,7 @@ import { RainbowConnectUI } from "./RainbowConnectUI"; import { handelWCSessionRequest } from "../handleWCSessionRequest"; import { rainbowWalletUris } from "./rainbowWalletUris"; -type RainbowWalletOptions = { +export type RainbowWalletConfigOptions = { /** * When connecting Rainbow using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -22,8 +22,46 @@ type RainbowWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Rainbow Wallet](https://rainbow.me/en/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const rainbowWalletConfig = rainbowWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(rainbowWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const rainbowWallet = ( - options?: RainbowWalletOptions, + options?: RainbowWalletConfigOptions, ): WalletConfig => { return { id: RainbowWallet.id, diff --git a/packages/react/src/wallet/wallets/safe/safeWallet.tsx b/packages/react/src/wallet/wallets/safe/safeWallet.tsx index 870386180ee..379f9526ad8 100644 --- a/packages/react/src/wallet/wallets/safe/safeWallet.tsx +++ b/packages/react/src/wallet/wallets/safe/safeWallet.tsx @@ -9,17 +9,62 @@ import { import { defaultWallets } from "../defaultWallets"; import { useState } from "react"; import { SelectpersonalWallet } from "./SelectPersonalWallet"; -import type { SafeWalletConfigOptions, SafeWalletConfig } from "./types"; +import type { SafeWalletConfig } from "./types"; import { SelectAccount } from "./SelectAccount"; import { HeadlessConnectUI } from "../headlessConnectUI"; +export type SafeWalletConfigOptions = { + /** + * An array of personalWallets to show in ConnectWallet Modal to use with SafeWallet + */ + personalWallets?: WalletConfig[]; + + /** + * If true, the wallet will be tagged as "recommended" in ConnectWallet Modal + */ + recommended?: boolean; +}; + +/** + * A wallet configurator for [Safe](https://safe.global/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const safeWalletConfig = safeWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(safeWalletConfig, options); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const safeWallet = ( - config?: SafeWalletConfigOptions & { - /** - * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal - */ - recommended?: boolean; - }, + config?: SafeWalletConfigOptions, ): SafeWalletConfig => { const personalWallets = config?.personalWallets || defaultWallets; return { diff --git a/packages/react/src/wallet/wallets/safe/types.ts b/packages/react/src/wallet/wallets/safe/types.ts index 40a8e84a987..f60509f02b3 100644 --- a/packages/react/src/wallet/wallets/safe/types.ts +++ b/packages/react/src/wallet/wallets/safe/types.ts @@ -1,8 +1,4 @@ import { WalletConfig } from "@thirdweb-dev/react-core"; import { SafeWallet } from "@thirdweb-dev/wallets"; -export type SafeWalletConfigOptions = { - personalWallets?: WalletConfig[]; -}; - export type SafeWalletConfig = WalletConfig; diff --git a/packages/react/src/wallet/wallets/signerWallet.tsx b/packages/react/src/wallet/wallets/signerWallet.tsx index 04d51d0d008..6ca66ee87cf 100644 --- a/packages/react/src/wallet/wallets/signerWallet.tsx +++ b/packages/react/src/wallet/wallets/signerWallet.tsx @@ -2,6 +2,9 @@ import { SignerWallet, WalletOptions } from "@thirdweb-dev/wallets"; import { Signer } from "ethers"; import { WalletConfig } from "@thirdweb-dev/react-core"; +/** + * @internal + */ export const signerWallet = (signer: Signer): WalletConfig => { return { id: "signerWallet", diff --git a/packages/react/src/wallet/wallets/smartWallet/SmartWalletConnecting.tsx b/packages/react/src/wallet/wallets/smartWallet/SmartWalletConnecting.tsx index 5d8bb7efcdc..1d9c464c0c4 100644 --- a/packages/react/src/wallet/wallets/smartWallet/SmartWalletConnecting.tsx +++ b/packages/react/src/wallet/wallets/smartWallet/SmartWalletConnecting.tsx @@ -15,15 +15,15 @@ import { } from "@thirdweb-dev/react-core"; import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { Container, ModalHeader } from "../../../components/basic"; -import { SmartWalletConfig } from "./types"; import { Text } from "../../../components/text"; import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider"; +import type { SmartWallet } from "@thirdweb-dev/wallets"; export const SmartWalletConnecting: React.FC<{ onBack: () => void; onConnect: () => void; - smartWallet: SmartWalletConfig; + smartWallet: WalletConfig; personalWallet: WalletConfig; }> = (props) => { const locale = useTWLocale().wallets.smartWallet; diff --git a/packages/react/src/wallet/wallets/smartWallet/smartWallet.tsx b/packages/react/src/wallet/wallets/smartWallet/smartWallet.tsx index 989ef59ce02..b4f0e28538e 100644 --- a/packages/react/src/wallet/wallets/smartWallet/smartWallet.tsx +++ b/packages/react/src/wallet/wallets/smartWallet/smartWallet.tsx @@ -1,18 +1,95 @@ import { - WalletConfig, - ConnectUIProps, - WalletOptions, + type WalletConfig, + type ConnectUIProps, + type WalletOptions, useWallet, } from "@thirdweb-dev/react-core"; import { SmartWallet } from "@thirdweb-dev/wallets"; -import { SmartWalletConfig, SmartWalletConfigOptions } from "./types"; +import { SmartWalletConfigOptions } from "./types"; import { SmartWalletConnecting } from "./SmartWalletConnecting"; import { HeadlessConnectUI } from "../headlessConnectUI"; +/** + * A wallet configurator for [Smart Wallet](https://portal.thirdweb.com/wallet/smart-wallet) which allows integrating the wallet with React + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * import { + * smartWallet, + * metamaskWallet, + * coinbaseWallet, + * walletConnect, + * } from "@thirdweb-dev/react"; + * + * const config = { + * factoryAddress: "0x...", + * gasless: true, + * } + * + * + * + * ; + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * You need to connect to a personal wallet first, You can use the useConnect hook to connect to a personal wallet first and then connect to the Smart Wallet. Make sure personal wallet is on the same network as the Smart Wallet. + * + * ```tsx + * import { useConnect, smartWallet, metamaskWallet } from "@thirdweb-dev/react"; + * import { Goerli } from "@thirdweb-dev/chains"; + * + * const personalWalletConfig = metamaskWallet(); // or use any other wallet + * + * const smartWalletConfig = smartWallet(personalWalletConfig, { + * factoryAddress: "0x...", + * gasless: true, + * }); + * + * function App() { + * const connect = useConnect(); + * + * const handleConnect = async () => { + * // 1. connect the personal wallet first on the network that the smart wallet is deployed to + * const personalWallet = await connect(personalWalletConfig, { + * chainId: Goerli.chainId, + * }); + * + * // 2. connect to smart wallet + * const smartWallet = await connect(smartWalletConfig, { + * chainId: Goerli.chainId, + * personalWallet: personalWallet, + * }); + * + * console.log("connected to", smartWallet); + * }; + * + * return
...
; + * } + * ``` + */ export const smartWallet = ( wallet: WalletConfig, config: SmartWalletConfigOptions, -): SmartWalletConfig => { +): WalletConfig => { const WalletSelectUI = wallet.selectUI; return { diff --git a/packages/react/src/wallet/wallets/smartWallet/types.ts b/packages/react/src/wallet/wallets/smartWallet/types.ts index b6fd110c5bc..7e8a49fe5bf 100644 --- a/packages/react/src/wallet/wallets/smartWallet/types.ts +++ b/packages/react/src/wallet/wallets/smartWallet/types.ts @@ -1,12 +1,6 @@ -import { WalletConfig } from "@thirdweb-dev/react-core"; -import { - SmartWallet, - SmartWalletConfig as SmartWalletConfig_, -} from "@thirdweb-dev/wallets"; +import { SmartWalletConfig } from "@thirdweb-dev/wallets"; export type SmartWalletConfigOptions = Omit< - SmartWalletConfig_, + SmartWalletConfig, "chain" | "clientId" | "secretKey" >; - -export type SmartWalletConfig = WalletConfig; diff --git a/packages/react/src/wallet/wallets/trustWallet/TrustWallet.tsx b/packages/react/src/wallet/wallets/trustWallet/TrustWallet.tsx index ca8900cda1b..89b85b93449 100644 --- a/packages/react/src/wallet/wallets/trustWallet/TrustWallet.tsx +++ b/packages/react/src/wallet/wallets/trustWallet/TrustWallet.tsx @@ -4,7 +4,7 @@ import { TrustConnectUI } from "./TrustConnectUI"; import { trustWalletUris } from "./trustWalletUris"; import { handelWCSessionRequest } from "../handleWCSessionRequest"; -type TrustWalletOptions = { +export type TrustWalletConfigOptions = { /** * When connecting Trust using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -19,8 +19,46 @@ type TrustWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Trust Wallet](https://trustwallet.com/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const trustWalletConfig = trustWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(trustWalletConfig); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const trustWallet = ( - options?: TrustWalletOptions, + options?: TrustWalletConfigOptions, ): WalletConfig => { return { id: TrustWallet.id, diff --git a/packages/react/src/wallet/wallets/walletConnect/WalletConnectScan.tsx b/packages/react/src/wallet/wallets/walletConnect/WalletConnectScan.tsx index d0a54ca4fa7..0a39605e353 100644 --- a/packages/react/src/wallet/wallets/walletConnect/WalletConnectScan.tsx +++ b/packages/react/src/wallet/wallets/walletConnect/WalletConnectScan.tsx @@ -4,14 +4,17 @@ import { } from "@thirdweb-dev/react-core"; import { useEffect, useRef, useState } from "react"; import type { WalletConnect } from "@thirdweb-dev/wallets"; -import type { WalletConfig } from "@thirdweb-dev/react-core"; +import type { ConnectUIProps, WalletConfig } from "@thirdweb-dev/react-core"; import { QRCode } from "../../../components/QRCode"; import { Img } from "../../../components/Img"; import { Spacer } from "../../../components/Spacer"; -import { ModalHeader, Container } from "../../../components/basic"; +import { ModalHeader, Container, Line } from "../../../components/basic"; import { iconSize } from "../../../design-system"; import { Text } from "../../../components/text"; import { useTWLocale } from "../../../evm/providers/locale-provider"; +import { Button } from "../../../components/buttons"; +import { Spinner } from "../../../components/Spinner"; +import { wait } from "../../../utils/wait"; export const WalletConnectScan: React.FC<{ onBack: () => void; @@ -19,41 +22,40 @@ export const WalletConnectScan: React.FC<{ walletConfig: WalletConfig; hideBackButton: boolean; modalSize: "wide" | "compact"; -}> = ({ onBack, onConnected, walletConfig }) => { + hide: ConnectUIProps["hide"]; + show: ConnectUIProps["show"]; +}> = ({ onBack, onConnected, walletConfig, hide, show }) => { const locale = useTWLocale().wallets.walletConnect; const createInstance = useCreateWalletInstance(); const [qrCodeUri, setQrCodeUri] = useState(); const { setConnectedWallet, chainToConnect, setConnectionStatus } = useWalletContext(); + const [isWCModalOpen, setIsWCModalOpen] = useState(false); - const scanStarted = useRef(false); - useEffect(() => { - if (scanStarted.current) { - return; - } - scanStarted.current = true; - + const handleWCModalConnect = async () => { const walletInstance = createInstance(walletConfig); setConnectionStatus("connecting"); - walletInstance.connectWithQrCode({ - chainId: chainToConnect?.chainId, - onQrCodeUri(uri) { - setQrCodeUri(uri); - }, - onConnected() { - setConnectedWallet(walletInstance); - onConnected(); - }, - }); - }, [ - createInstance, - setConnectedWallet, - chainToConnect, - onConnected, - walletConfig, - setConnectionStatus, - ]); + + try { + setQrCodeUri(undefined); + setIsWCModalOpen(true); + wait(1000).then(() => { + hide(); + }); + + await walletInstance.connectWithModal({ + chainId: chainToConnect?.chainId, + }); + + setConnectedWallet(walletInstance); + onConnected(); + show(); + } catch { + show(); + setIsWCModalOpen(false); + } + }; return ( @@ -64,20 +66,30 @@ export const WalletConnectScan: React.FC<{ - - } - /> + {isWCModalOpen ? ( + + + + ) : ( + + )} - - {/* */} {/* @@ -95,10 +107,84 @@ export const WalletConnectScan: React.FC<{ {locale.scanInstruction} + + + + + ); }; +function WalletConnectQRScanConnect(props: { + qrCodeUri: string | undefined; + setQrCodeUri: (uri: string) => void; + walletConfig: WalletConfig; + onConnected: () => void; + setConnectedWallet: (wallet: WalletConnect) => void; + createInstance: (walletConfig: WalletConfig) => WalletConnect; + setConnectionStatus: ( + status: "disconnected" | "connecting" | "connected", + ) => void; + chainIdToConnect?: number; +}) { + const { + qrCodeUri, + walletConfig, + onConnected, + setConnectedWallet, + createInstance, + setQrCodeUri, + chainIdToConnect, + setConnectionStatus, + } = props; + + const scanStarted = useRef(false); + useEffect(() => { + if (scanStarted.current) { + return; + } + scanStarted.current = true; + + const walletInstance = createInstance(walletConfig); + + setConnectionStatus("connecting"); + walletInstance.connectWithQrCode({ + chainId: chainIdToConnect, + onQrCodeUri(uri) { + setQrCodeUri(uri); + }, + onConnected() { + setConnectedWallet(walletInstance); + onConnected(); + }, + }); + }, [ + createInstance, + setConnectedWallet, + chainIdToConnect, + onConnected, + walletConfig, + setConnectionStatus, + setQrCodeUri, + ]); + + return ( + + } + /> + ); +} + // export const CopyButton: React.FC<{ // text: string; // tip: string; diff --git a/packages/react/src/wallet/wallets/walletConnect/walletConnect.tsx b/packages/react/src/wallet/wallets/walletConnect/walletConnect.tsx index 03bfb28208a..c82d03993e9 100644 --- a/packages/react/src/wallet/wallets/walletConnect/walletConnect.tsx +++ b/packages/react/src/wallet/wallets/walletConnect/walletConnect.tsx @@ -6,7 +6,7 @@ import { WalletConnectScan } from "./WalletConnectScan"; import { HeadlessConnectUI } from "../headlessConnectUI"; import { isMobile } from "../../../evm/utils/isMobile"; -type walletConnectConfig = { +export type walletConnectConfigOptions = { /** * Your project’s unique identifier that can be obtained at https://cloud.walletconnect.com/ * @@ -27,12 +27,68 @@ type walletConnectConfig = { * If true, the wallet will be tagged as "reccomended" in ConnectWallet Modal */ recommended?: boolean; + + /** + * Specify wheher a custom QR Modal or the Official WalletConnect Modal should be used on desktop. The custom screen has an option to open the official WalletConnect Modal too. + * + * Note that the official WalletConnect Modal is always used on mobile devices. + * + * The default is `"custom"` ( for desktop ) + */ + qrModal?: "custom" | "walletConnect"; }; +/** + * A wallet configurator for [WalletConnect](https://walletconnect.com/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const walletConnectConfig = walletConnect(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(walletConnectConfig); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const walletConnect = ( - config?: walletConnectConfig, + config?: walletConnectConfigOptions, ): WalletConfig => { const projectId = config?.projectId || TW_WC_PROJECT_ID; + + // on mobile - always use the official WalletConnect Modal + // on desktop - use the official WalletConnect Modal if qrModal is set to "walletconnect" + const showOfficialModal = isMobile() + ? true + : config?.qrModal === "walletConnect" + ? true + : false; + return { recommended: config?.recommended, id: WalletConnect.id, @@ -44,13 +100,14 @@ export const walletConnect = ( create(options: WalletOptions) { return new WalletConnect({ ...options, - qrcode: isMobile() ? true : false, + + qrcode: showOfficialModal, projectId, qrModalOptions: config?.qrModalOptions, }); }, connectUI(props) { - if (isMobile()) { + if (showOfficialModal) { return ; } @@ -61,6 +118,8 @@ export const walletConnect = ( walletConfig={props.walletConfig} hideBackButton={props.supportedWallets.length > 1} modalSize={props.modalSize} + hide={props.hide} + show={props.show} /> ); }, diff --git a/packages/react/src/wallet/wallets/zerion/zerionWallet.tsx b/packages/react/src/wallet/wallets/zerion/zerionWallet.tsx index 8d544e27610..9a95ce4df70 100644 --- a/packages/react/src/wallet/wallets/zerion/zerionWallet.tsx +++ b/packages/react/src/wallet/wallets/zerion/zerionWallet.tsx @@ -4,7 +4,7 @@ import { ZerionConnectUI } from "./ZerionConnectUI"; import { handelWCSessionRequest } from "../handleWCSessionRequest"; import { zerionWalletUris } from "./zerionWalletUris"; -type ZerionkWalletOptions = { +export type ZerionkWalletConfigOptions = { /** * When connecting MetaMask using the QR Code - Wallet Connect connector is used which requires a project id. * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. @@ -19,8 +19,46 @@ type ZerionkWalletOptions = { recommended?: boolean; }; +/** + * A wallet configurator for [Zerion Wallet](https://zerion.io/) which allows integrating the wallet with React. + * + * It returns a `WalletConfig` object which can be used to connect the wallet to app via `ConnectWallet` component or `useConnect` hook. + * + * @example + * + * ### Usage with ConnectWallet + * + * To allow users to connect to this wallet using the `ConnectWallet` component, you can add it to `ThirdwebProvider`'s supportedWallets prop. + * + * ```tsx + * + * + * + * ``` + * + * ### Usage with useConnect + * + * you can use the `useConnect` hook to programmatically connect to the wallet without using the `ConnectWallet` component. + * + * The wallet also needs to be added in `ThirdwebProvider`'s supportedWallets if you want the wallet to auto-connect on next page load. + * + * ```tsx + * const zerionWalletConfig = zerionWallet(); + * + * function App() { + * const connect = useConnect(); + * + * async function handleConnect() { + * const wallet = await connect(zerionWalletConfig); + * console.log('connected to', wallet); + * } + * + * return ; + * } + * ``` + */ export const zerionWallet = ( - options?: ZerionkWalletOptions, + options?: ZerionkWalletConfigOptions, ): WalletConfig => { return { id: ZerionWallet.id, diff --git a/packages/react/typedoc.js b/packages/react/typedoc.js deleted file mode 100644 index 21fd9a7f1f4..00000000000 --- a/packages/react/typedoc.js +++ /dev/null @@ -1,39 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires, better-tree-shaking/no-top-level-side-effects -const TypeDoc = require("typedoc"); - -async function main() { - // Application.bootstrap also exists, which will not load plugins - // Also accepts an array of option readers if you want to disable - // TypeDoc's tsconfig.json/package.json/typedoc.json option readers - const app = await TypeDoc.Application.bootstrapWithPlugins({ - entryPoints: ["src/index.ts"], - excludeInternal: true, - externalPattern: [ - "**/node_modules/**", - "**/packages/sdk/**", - "**/packages/wallets/**", - "**/packages/chains/**", - ], - exclude: [ - "**/node_modules/**", - "**/packages/sdk/**", - "**/packages/wallets/**", - "**/packages/chains/**", - ], - }); - - const project = await app.convert(); - - if (project) { - // Project may not have converted correctly - const outputDir = "typedoc/"; - - // Rendered docs - await app.generateDocs(project, outputDir); - // Alternatively generate JSON output - await app.generateJson(project, outputDir + "/documentation.json"); - } -} - -// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects -main(); diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 410dc34b229..b1fad8d6c23 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,63 @@ # @thirdweb-dev/sdk +## 4.0.21 + +### Patch Changes + +- [#2067](https://github.com/thirdweb-dev/js/pull/2067) [`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173) Thanks [@kumaryash90](https://github.com/kumaryash90)! - fix deployments + +## 4.0.20 + +### Patch Changes + +- [#2062](https://github.com/thirdweb-dev/js/pull/2062) [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Expose baseFee in getDynamicFeeData() + +- [#2053](https://github.com/thirdweb-dev/js/pull/2053) [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Fix error message + +- [#2059](https://github.com/thirdweb-dev/js/pull/2059) [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf) Thanks [@jnsdls](https://github.com/jnsdls)! - contract.roles.setAll now allows passing a actingAddress explictly to "prepare()" to correctly prepare the txn when there are multiple roles being removed + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3)]: + - @thirdweb-dev/chains@0.1.61 + +## 4.0.19 + +### Patch Changes + +- [#2050](https://github.com/thirdweb-dev/js/pull/2050) [`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875) Thanks [@kumaryash90](https://github.com/kumaryash90)! - update implementations + +- [#2049](https://github.com/thirdweb-dev/js/pull/2049) [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4) Thanks [@jnsdls](https://github.com/jnsdls)! - contract roles: ensure that the connected wallet address always ends up being removed _last_ in the multi-call to remove/revoke roles + +- [#2048](https://github.com/thirdweb-dev/js/pull/2048) [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7) Thanks [@kumaryash90](https://github.com/kumaryash90)! - metadata role + +- [#2051](https://github.com/thirdweb-dev/js/pull/2051) [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add migration role + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +- [#2044](https://github.com/thirdweb-dev/js/pull/2044) [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b) Thanks [@kumaryash90](https://github.com/kumaryash90)! - update contract publisher + +- Updated dependencies [[`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56)]: + - @thirdweb-dev/storage@2.0.7 + +## 4.0.18 + +### Patch Changes + +- [#2012](https://github.com/thirdweb-dev/js/pull/2012) [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Propagate isPartialAbi + +- [#2003](https://github.com/thirdweb-dev/js/pull/2003) [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix undefined error for unknown chains + +- [#2005](https://github.com/thirdweb-dev/js/pull/2005) [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Enable deployments for older AccountFactories + +- [#2009](https://github.com/thirdweb-dev/js/pull/2009) [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add missing roles from new contracts + +- [#2011](https://github.com/thirdweb-dev/js/pull/2011) [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Don't fetch metadata from CDN for local nodes + +- [#2010](https://github.com/thirdweb-dev/js/pull/2010) [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Fix code comment + +- Updated dependencies [[`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa)]: + - @thirdweb-dev/chains@0.1.60 + - @thirdweb-dev/storage@2.0.6 + ## 4.0.17 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5bac971af4f..25eedd75e9c 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "4.0.17", + "version": "4.0.21", "description": "The main thirdweb SDK.", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk", "license": "Apache-2.0", @@ -72,7 +72,7 @@ "test": "make test-evm", "test:single": "SWC_NODE_PROJECT=./tsconfig.test.json mocha --config './test/evm/.mocharc.json' --timeout 90000", "push": "yalc push", - "typedoc": "rimraf typedoc && node typedoc.js" + "typedoc": "node scripts/typedoc.mjs" }, "devDependencies": { "@aws-sdk/client-secrets-manager": "^3.378.0", @@ -112,9 +112,9 @@ "nyc": "^15.1.0", "prettier": "^3.0.0", "rimraf": "^3.0.2", - "typedoc": "^0.25.2", "typescript": "^5.1.6", - "zksync-web3": "^0.14.3" + "zksync-web3": "^0.14.3", + "typedoc-gen": "workspace:*" }, "peerDependencies": { "@aws-sdk/client-secrets-manager": "^3.215.0", diff --git a/packages/sdk/scripts/typedoc.mjs b/packages/sdk/scripts/typedoc.mjs new file mode 100644 index 00000000000..bbf546317f9 --- /dev/null +++ b/packages/sdk/scripts/typedoc.mjs @@ -0,0 +1,10 @@ +// @ts-check +/* eslint-disable better-tree-shaking/no-top-level-side-effects */ + +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: ["**/packages/storage/**", "**/packages/chains/**"], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/sdk/src/core/constants/urls.ts b/packages/sdk/src/core/constants/urls.ts index 375da2cdca1..6195fa1497d 100644 --- a/packages/sdk/src/core/constants/urls.ts +++ b/packages/sdk/src/core/constants/urls.ts @@ -1,3 +1,6 @@ +/** + * @internal + */ export function getRpcUrl(network: string, clientId?: string) { return `https://${network}.rpc.thirdweb.com/${clientId || ""}`; } diff --git a/packages/sdk/src/core/utils/apiKey.ts b/packages/sdk/src/core/utils/apiKey.ts index 6cb0a6f748b..7bc8084ba3e 100644 --- a/packages/sdk/src/core/utils/apiKey.ts +++ b/packages/sdk/src/core/utils/apiKey.ts @@ -1,13 +1,21 @@ let alreadyChecked = false; -export function checkClientIdOrSecretKey(message: string, clientId?: string, secretKey?: string) { - if (alreadyChecked) { - return; - } - alreadyChecked = true; - if (clientId || secretKey) { - return; - } +/** + * @internal + */ +export function checkClientIdOrSecretKey( + message: string, + clientId?: string, + secretKey?: string, +) { + if (alreadyChecked) { + return; + } + alreadyChecked = true; - console.warn(message); -} \ No newline at end of file + if (clientId || secretKey) { + return; + } + + console.warn(message); +} diff --git a/packages/sdk/src/evm/common/abi.ts b/packages/sdk/src/evm/common/abi.ts index 4b4e1797f77..92adba9b7e4 100644 --- a/packages/sdk/src/evm/common/abi.ts +++ b/packages/sdk/src/evm/common/abi.ts @@ -1,6 +1,9 @@ import { GENERATED_ABI } from "@thirdweb-dev/generated-abis"; import { ContractInterface } from "ethers/lib/ethers"; +/** + * @internal + */ export function getCachedAbiForContract( address: string, ): ContractInterface | undefined { diff --git a/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentAddress.ts b/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentAddress.ts index ae81c2592bd..e9e062e119e 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentAddress.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentAddress.ts @@ -4,7 +4,7 @@ import { getSaltHash } from "./getSaltHash"; /** * Pre-compute a contract's deployment address for a CREATE2 deployment. * - * @public + * @internal * @param bytecode - Creation bytecode of the contract to deploy * @param encodedArgs - Abi-encoded constructor params * @param create2FactoryAddress - The create2 factory address to use diff --git a/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentInfo.ts b/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentInfo.ts index 7c43ef828fd..ba3a44317c8 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentInfo.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/computeDeploymentInfo.ts @@ -23,6 +23,9 @@ import { extractConstructorParamsFromAbi } from "../feature-detection/extractCon import { caches } from "./caches"; import { getRoyaltyEngineV1ByChainId } from "../../constants/royaltyEngine"; +/** + * @internal + */ export async function computeDeploymentInfo( contractType: DeployedContractType, provider: providers.Provider, diff --git a/packages/sdk/src/evm/common/any-evm-utils/constants.ts b/packages/sdk/src/evm/common/any-evm-utils/constants.ts index 2cef92e4dcb..2dfda9749cb 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/constants.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/constants.ts @@ -1,5 +1,11 @@ +/** + * @internal + */ export const CREATE2_FACTORY_BYTECODE = "0x604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"; +/** + * @internal + */ export const SIGNATURE = { v: 27, r: "0x2222222222222222222222222222222222222222222222222222222222222222", @@ -7,9 +13,18 @@ export const SIGNATURE = { }; export const COMMON_FACTORY = "0x4e59b44847b379578588920cA78FbF26c0B4956C"; // for pre-eip-155 supporting chains +/** + * @internal + */ export const GAS_LIMIT_FOR_DEPLOYER = 5000000; +/** + * @internal + */ export const DEPLOYER_BYTECODE = "0x60806040526040516107f33803806107f383398101604081905261002291610359565b805160005b818110156100c157828181518110610041576100416104c9565b6020026020010151600001516001600160a01b03163b600014156100af576100ad838281518110610074576100746104c9565b602002602001015160200151848381518110610092576100926104c9565b6020026020010151604001516100c960201b6100091760201c565b505b806100b9816104df565b915050610027565b505050610557565b606061011183836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061011860201b60201c565b9392505050565b6060610127848460008561012f565b949350505050565b6060824710156101955760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101ec5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161018c565b600080866001600160a01b031685876040516102089190610508565b60006040518083038185875af1925050503d8060008114610245576040519150601f19603f3d011682016040523d82523d6000602084013e61024a565b606091505b50909250905061025b828286610266565b979650505050505050565b60608315610275575081610111565b8251156102855782518084602001fd5b8160405162461bcd60e51b815260040161018c9190610524565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156102d7576102d761029f565b60405290565b604051601f8201601f191681016001600160401b03811182821017156103055761030561029f565b604052919050565b80516001600160a01b038116811461032457600080fd5b919050565b60005b8381101561034457818101518382015260200161032c565b83811115610353576000848401525b50505050565b6000602080838503121561036c57600080fd5b82516001600160401b038082111561038357600080fd5b818501915085601f83011261039757600080fd5b8151818111156103a9576103a961029f565b8060051b6103b88582016102dd565b91825283810185019185810190898411156103d257600080fd5b86860192505b838310156104bc578251858111156103f05760008081fd5b86016060601f19828d0381018213156104095760008081fd5b6104116102b5565b61041c8b850161030d565b8152604061042b81860161030d565b828d01529284015192898411156104425760008081fd5b83850194508e603f86011261045957600093508384fd5b8b85015193508984111561046f5761046f61029f565b61047f8c84601f870116016102dd565b92508383528e818587010111156104965760008081fd5b6104a5848d8501838801610329565b8101919091528452505091860191908601906103d8565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561050157634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825161051a818460208701610329565b9190910192915050565b6020815260008251806020840152610543816040850160208701610329565b601f01601f19169190910160400192915050565b61028d806105666000396000f3fe6080604052600080fd5b606061004b83836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610052565b9392505050565b60606100618484600085610069565b949350505050565b6060824710156100cf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101265760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016100c6565b600080866001600160a01b031685876040516101429190610208565b60006040518083038185875af1925050503d806000811461017f576040519150601f19603f3d011682016040523d82523d6000602084013e610184565b606091505b509150915061019482828661019f565b979650505050505050565b606083156101ae57508161004b565b8251156101be5782518084602001fd5b8160405162461bcd60e51b81526004016100c69190610224565b60005b838110156101f35781810151838201526020016101db565b83811115610202576000848401525b50505050565b6000825161021a8184602087016101d8565b9190910192915050565b60208152600082518060208401526102438160408501602087016101d8565b601f01601f1916919091016040019291505056fea26469706673582212200b524eb8ceaafe6c603273ee859fddbc2d6f1b7860c3d853dcf6f129f9d9371364736f6c634300080c0033"; +/** + * @internal + */ export const DEPLOYER_ABI = [ { inputs: [ diff --git a/packages/sdk/src/evm/common/any-evm-utils/convertParamValues.ts b/packages/sdk/src/evm/common/any-evm-utils/convertParamValues.ts index 47d460d10a0..1a5a1e100d1 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/convertParamValues.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/convertParamValues.ts @@ -1,6 +1,9 @@ import { BigNumber, utils } from "ethers"; import invariant from "tiny-invariant"; +/** + * @internal + */ export function convertParamValues( constructorParamTypes: string[], constructorParamValues: any[], diff --git a/packages/sdk/src/evm/common/any-evm-utils/createTransactionBatches.ts b/packages/sdk/src/evm/common/any-evm-utils/createTransactionBatches.ts index 2e356e7ffef..9099cfbaaca 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/createTransactionBatches.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/createTransactionBatches.ts @@ -2,6 +2,9 @@ import { PrecomputedDeploymentTransaction } from "../../types/any-evm/deploy-dat import { GAS_LIMIT_FOR_DEPLOYER } from "./constants"; import { estimateGasForDeploy } from "./estimateGasForDeploy"; +/** + * @internal + */ export function createTransactionBatches( transactions: PrecomputedDeploymentTransaction[], upperGasLimit: number = GAS_LIMIT_FOR_DEPLOYER, diff --git a/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministic.ts b/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministic.ts index 5b86e8e7b3b..1312dcfc9d4 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministic.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministic.ts @@ -8,7 +8,7 @@ import { isContractDeployed } from "./isContractDeployed"; * Deploy a contract at a deterministic address, using Create2 method * Address depends on the Create2 factory address. * - * @public + * @internal * * @param signer - The signer to use * @param bytecode - The bytecode to deploy diff --git a/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministicRaw.ts b/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministicRaw.ts index 1a9a072c917..fe1b11bb377 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministicRaw.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/deployContractDeterministicRaw.ts @@ -13,7 +13,7 @@ import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt"; * Deploy a contract at a deterministic address, using Create2 method * Address depends on the Create2 factory address. * - * @public + * @internal * * @param signer - The signer to use * @param bytecode - The bytecode to deploy diff --git a/packages/sdk/src/evm/common/any-evm-utils/deployWithThrowawayDeployer.ts b/packages/sdk/src/evm/common/any-evm-utils/deployWithThrowawayDeployer.ts index 7deac75762b..e1c0d1bbc7b 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/deployWithThrowawayDeployer.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/deployWithThrowawayDeployer.ts @@ -4,6 +4,9 @@ import type { DeployOptions } from "../../types/deploy/deploy-options"; import { DEPLOYER_ABI, DEPLOYER_BYTECODE } from "./constants"; import { createTransactionBatches } from "./createTransactionBatches"; +/** + * @internal + */ export async function deployWithThrowawayDeployer( signer: Signer, transactions: PrecomputedDeploymentTransaction[], diff --git a/packages/sdk/src/evm/common/any-evm-utils/estimateGasForDeploy.ts b/packages/sdk/src/evm/common/any-evm-utils/estimateGasForDeploy.ts index c10b1c39f02..ba68b7a12f3 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/estimateGasForDeploy.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/estimateGasForDeploy.ts @@ -1,5 +1,8 @@ import { utils } from "ethers"; +/** + * @internal + */ export function estimateGasForDeploy(initCode: string) { let gasLimit = utils diff --git a/packages/sdk/src/evm/common/any-evm-utils/fetchAndCacheDeployMetadata.ts b/packages/sdk/src/evm/common/any-evm-utils/fetchAndCacheDeployMetadata.ts index 968b3317a3a..f3ef67a51fa 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/fetchAndCacheDeployMetadata.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/fetchAndCacheDeployMetadata.ts @@ -5,6 +5,9 @@ import type { DeployMetadata } from "../../types/deploy/deploy-options"; const deployMetadataCache: Record = {}; +/** + * @internal + */ export async function fetchAndCacheDeployMetadata( publishMetadataUri: string, storage: ThirdwebStorage, diff --git a/packages/sdk/src/evm/common/any-evm-utils/fetchPublishedContractFromPolygon.ts b/packages/sdk/src/evm/common/any-evm-utils/fetchPublishedContractFromPolygon.ts index 6dda59ecd3e..2a386bb741c 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/fetchPublishedContractFromPolygon.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/fetchPublishedContractFromPolygon.ts @@ -13,6 +13,9 @@ import { PublishedContractSchema } from "../../schema/contracts/custom"; export const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024"; +/** + * @internal + */ export async function fetchPublishedContractFromPolygon( publisherAddress: AddressOrEns, contractName: string, diff --git a/packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryDeploymentInfo.ts b/packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryDeploymentInfo.ts index 041e544e6e1..41e0b42fcb8 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryDeploymentInfo.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/getCreate2FactoryDeploymentInfo.ts @@ -5,7 +5,7 @@ import { getKeylessTxn } from "./getKeylessTxn"; /** * - * @public + * @internal * @param transaction - Unsigned transaction object * @param signature - Signature bytes */ diff --git a/packages/sdk/src/evm/common/any-evm-utils/isContractDeployed.ts b/packages/sdk/src/evm/common/any-evm-utils/isContractDeployed.ts index 89410cf27b1..efcc070a9d4 100644 --- a/packages/sdk/src/evm/common/any-evm-utils/isContractDeployed.ts +++ b/packages/sdk/src/evm/common/any-evm-utils/isContractDeployed.ts @@ -3,7 +3,7 @@ import { providers } from "ethers"; /** * Check if a contract exists at the given address * - * @internal + * @public * @param address - The address to check * @param provider - The provider to use */ diff --git a/packages/sdk/src/evm/common/claim-conditions/calculateClaimCost.ts b/packages/sdk/src/evm/common/claim-conditions/calculateClaimCost.ts index 0b0893e134e..6ec147894e0 100644 --- a/packages/sdk/src/evm/common/claim-conditions/calculateClaimCost.ts +++ b/packages/sdk/src/evm/common/claim-conditions/calculateClaimCost.ts @@ -1,5 +1,5 @@ import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { Address } from "../../schema/shared/Address"; import type { Price } from "../../types/currency"; import { BigNumberish, CallOverrides } from "ethers"; diff --git a/packages/sdk/src/evm/common/claim-conditions/fetchSnapshotEntryForAddress.ts b/packages/sdk/src/evm/common/claim-conditions/fetchSnapshotEntryForAddress.ts index 622e38812e5..aeee0f2fced 100644 --- a/packages/sdk/src/evm/common/claim-conditions/fetchSnapshotEntryForAddress.ts +++ b/packages/sdk/src/evm/common/claim-conditions/fetchSnapshotEntryForAddress.ts @@ -9,6 +9,9 @@ import { import { ThirdwebStorage } from "@thirdweb-dev/storage"; import type { providers } from "ethers"; +/** + * @internal + */ export async function fetchSnapshotEntryForAddress( address: string, merkleRoot: string, diff --git a/packages/sdk/src/evm/common/claim-conditions/prepareClaim.ts b/packages/sdk/src/evm/common/claim-conditions/prepareClaim.ts index 0fb7614d9fd..44f3af85bf7 100644 --- a/packages/sdk/src/evm/common/claim-conditions/prepareClaim.ts +++ b/packages/sdk/src/evm/common/claim-conditions/prepareClaim.ts @@ -1,4 +1,4 @@ -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import type { ClaimCondition, ClaimVerification, diff --git a/packages/sdk/src/evm/common/currency/approveErc20Allowance.ts b/packages/sdk/src/evm/common/currency/approveErc20Allowance.ts index d4ea5efbdf8..e58b5025d45 100644 --- a/packages/sdk/src/evm/common/currency/approveErc20Allowance.ts +++ b/packages/sdk/src/evm/common/currency/approveErc20Allowance.ts @@ -1,7 +1,10 @@ import type { IERC20 } from "@thirdweb-dev/contracts-js"; import { BigNumber, utils, type BigNumberish } from "ethers"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +/** + * @internal + */ export async function approveErc20Allowance( contractToApprove: ContractWrapper, currencyAddress: string, diff --git a/packages/sdk/src/evm/common/currency/cleanCurrencyAddress.ts b/packages/sdk/src/evm/common/currency/cleanCurrencyAddress.ts index dd1b7303548..5c1d1fdc4d4 100644 --- a/packages/sdk/src/evm/common/currency/cleanCurrencyAddress.ts +++ b/packages/sdk/src/evm/common/currency/cleanCurrencyAddress.ts @@ -1,6 +1,9 @@ import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency"; import { isNativeToken } from "./isNativeToken"; +/** + * @internal + */ export function cleanCurrencyAddress(currencyAddress: string): string { if (isNativeToken(currencyAddress)) { return NATIVE_TOKEN_ADDRESS; diff --git a/packages/sdk/src/evm/common/currency/hasERC20Allowance.ts b/packages/sdk/src/evm/common/currency/hasERC20Allowance.ts index 76dfb4beb58..0ea5295e0aa 100644 --- a/packages/sdk/src/evm/common/currency/hasERC20Allowance.ts +++ b/packages/sdk/src/evm/common/currency/hasERC20Allowance.ts @@ -1,7 +1,10 @@ import type { IERC20 } from "@thirdweb-dev/contracts-js"; import { BigNumber } from "ethers"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +/** + * @internal + */ export async function hasERC20Allowance( contractToApprove: ContractWrapper, currencyAddress: string, diff --git a/packages/sdk/src/evm/common/currency/normalizeAmount.ts b/packages/sdk/src/evm/common/currency/normalizeAmount.ts index 8a2eb0bb203..bc7c84aa046 100644 --- a/packages/sdk/src/evm/common/currency/normalizeAmount.ts +++ b/packages/sdk/src/evm/common/currency/normalizeAmount.ts @@ -1,9 +1,12 @@ import { BigNumber, utils } from "ethers"; import { AmountSchema } from "../../../core/schema/shared"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { Amount } from "../../types/currency"; import { BaseERC20 } from "../../types/eips"; +/** + * @internal + */ export async function normalizeAmount( contractWrapper: ContractWrapper, amount: Amount, diff --git a/packages/sdk/src/evm/common/currency/setErc20Allowance.ts b/packages/sdk/src/evm/common/currency/setErc20Allowance.ts index cbfa127e932..b9cd740e707 100644 --- a/packages/sdk/src/evm/common/currency/setErc20Allowance.ts +++ b/packages/sdk/src/evm/common/currency/setErc20Allowance.ts @@ -1,8 +1,11 @@ import type { IERC20 } from "@thirdweb-dev/contracts-js"; import { BigNumber } from "ethers"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { isNativeToken } from "./isNativeToken"; +/** + * @internal + */ export async function setErc20Allowance( contractToApprove: ContractWrapper, value: BigNumber, diff --git a/packages/sdk/src/evm/common/ens/resolveEns.ts b/packages/sdk/src/evm/common/ens/resolveEns.ts index b44b86ff7e0..999a2d93bcc 100644 --- a/packages/sdk/src/evm/common/ens/resolveEns.ts +++ b/packages/sdk/src/evm/common/ens/resolveEns.ts @@ -11,6 +11,9 @@ let provider: providers.Provider | undefined; const ENS_CACHE = new Map>(); +/** + * @internal + */ export async function resolveEns( ens: string, depth = 0, diff --git a/packages/sdk/src/evm/common/feature-detection/detectContractFeature.ts b/packages/sdk/src/evm/common/feature-detection/detectContractFeature.ts index 624ff96803f..90c31562d4f 100644 --- a/packages/sdk/src/evm/common/feature-detection/detectContractFeature.ts +++ b/packages/sdk/src/evm/common/feature-detection/detectContractFeature.ts @@ -1,5 +1,5 @@ import { FeatureName } from "../../constants/contract-features"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { AbiSchema } from "../../schema/contracts/custom"; import { BaseContract } from "ethers"; import { isExtensionEnabled } from "./isFeatureEnabled"; diff --git a/packages/sdk/src/evm/common/feature-detection/detectFeatures.ts b/packages/sdk/src/evm/common/feature-detection/detectFeatures.ts index d9a20d152c8..1f7af8526cc 100644 --- a/packages/sdk/src/evm/common/feature-detection/detectFeatures.ts +++ b/packages/sdk/src/evm/common/feature-detection/detectFeatures.ts @@ -31,6 +31,9 @@ export function detectFeatures( return results; } +/** + * @internal + */ export function detectFeaturesFromBytecode( bytecode: string, features: Record = SUPPORTED_FEATURES, diff --git a/packages/sdk/src/evm/common/feature-detection/getAllDetectedFeatures.ts b/packages/sdk/src/evm/common/feature-detection/getAllDetectedFeatures.ts index dbbbe5263dc..61b5d9bdd0b 100644 --- a/packages/sdk/src/evm/common/feature-detection/getAllDetectedFeatures.ts +++ b/packages/sdk/src/evm/common/feature-detection/getAllDetectedFeatures.ts @@ -20,6 +20,9 @@ export function getAllDetectedFeatures(abi: AbiInput): FeatureWithEnabled[] { return features; } +/** + * @internal + */ export function getAllDetectedExtensionsFromBytecode( bytecode: string, ): FeatureWithEnabled[] { @@ -28,6 +31,9 @@ export function getAllDetectedExtensionsFromBytecode( return features; } +/** + * @internal + */ export function constructAbiFromBytecode(bytecode: string): AbiInput { let extensions = getAllDetectedExtensionsFromBytecode(bytecode); // special deduping for ERC721 and ERC20 diff --git a/packages/sdk/src/evm/common/feature-detection/hasFunction.ts b/packages/sdk/src/evm/common/feature-detection/hasFunction.ts index 0b3f17f4ce4..177edaf9ee4 100644 --- a/packages/sdk/src/evm/common/feature-detection/hasFunction.ts +++ b/packages/sdk/src/evm/common/feature-detection/hasFunction.ts @@ -1,4 +1,4 @@ -import type { ContractWrapper } from "../../core/classes/contract-wrapper"; +import type { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import type { BaseContract } from "ethers"; /** diff --git a/packages/sdk/src/evm/common/feature-detection/hasMatchingAbi.ts b/packages/sdk/src/evm/common/feature-detection/hasMatchingAbi.ts index 5e9eccbfb4f..5d8e02201f2 100644 --- a/packages/sdk/src/evm/common/feature-detection/hasMatchingAbi.ts +++ b/packages/sdk/src/evm/common/feature-detection/hasMatchingAbi.ts @@ -40,6 +40,9 @@ export function hasMatchingAbi( return intersection.length === interfaceFn.length; } +/** + * @internal + */ export function matchesAbiFromBytecode( contractBytecode: string, featureAbis: readonly AbiInput[], diff --git a/packages/sdk/src/evm/common/feature-detection/isFeatureEnabled.ts b/packages/sdk/src/evm/common/feature-detection/isFeatureEnabled.ts index 1c9383d0e1d..6cccbe6c751 100644 --- a/packages/sdk/src/evm/common/feature-detection/isFeatureEnabled.ts +++ b/packages/sdk/src/evm/common/feature-detection/isFeatureEnabled.ts @@ -10,6 +10,7 @@ import { detectFeatures } from "./detectFeatures"; * @deprecated use isExtensionEnabled instead * @param abi - The abi to check * @param featureName - The feature name to check + * @internal */ export function isFeatureEnabled( abi: AbiInput, diff --git a/packages/sdk/src/evm/common/feature-detection/matchesPrebuiltAbi.ts b/packages/sdk/src/evm/common/feature-detection/matchesPrebuiltAbi.ts index 1c0dddd4516..8605fa4f717 100644 --- a/packages/sdk/src/evm/common/feature-detection/matchesPrebuiltAbi.ts +++ b/packages/sdk/src/evm/common/feature-detection/matchesPrebuiltAbi.ts @@ -1,4 +1,4 @@ -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { AbiInput, AbiSchema } from "../../schema/contracts/custom"; import { BaseContract } from "ethers"; import { hasMatchingAbi } from "./hasMatchingAbi"; diff --git a/packages/sdk/src/evm/common/feature-detection/resolveContractUriFromAddress.ts b/packages/sdk/src/evm/common/feature-detection/resolveContractUriFromAddress.ts index ac170d65742..cbd1d30def8 100644 --- a/packages/sdk/src/evm/common/feature-detection/resolveContractUriFromAddress.ts +++ b/packages/sdk/src/evm/common/feature-detection/resolveContractUriFromAddress.ts @@ -15,6 +15,9 @@ export async function resolveContractUriFromAddress( return extractIPFSHashFromBytecode(bytecode); } +/** + * @internal + */ export async function resolveContractUriAndBytecode( address: string, provider: providers.Provider, diff --git a/packages/sdk/src/evm/common/fetchContractMetadata.ts b/packages/sdk/src/evm/common/fetchContractMetadata.ts index 26a015ed572..8ce51c0ac2f 100644 --- a/packages/sdk/src/evm/common/fetchContractMetadata.ts +++ b/packages/sdk/src/evm/common/fetchContractMetadata.ts @@ -28,6 +28,9 @@ export async function fetchContractMetadata( return formatCompilerMetadata(metadata); } +/** + * @internal + */ export function formatCompilerMetadata(metadata: any): PublishedMetadata { const abi = AbiSchema.parse(metadata.output.abi); const compilationTarget = metadata.settings.compilationTarget; diff --git a/packages/sdk/src/evm/common/gas-price.ts b/packages/sdk/src/evm/common/gas-price.ts index c5b881b7f54..7dbe4b47c20 100644 --- a/packages/sdk/src/evm/common/gas-price.ts +++ b/packages/sdk/src/evm/common/gas-price.ts @@ -6,6 +6,7 @@ import { isBrowser } from "./utils"; type FeeData = { maxFeePerGas: null | BigNumber; maxPriorityFeePerGas: null | BigNumber; + baseFee: null | BigNumber; }; export async function getDefaultGasOverrides(provider: providers.Provider) { @@ -63,16 +64,17 @@ export async function getDynamicFeeData( maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; if (!maxPriorityFeePerGas) { // chain does not support eip-1559, return null for both - return { maxFeePerGas: null, maxPriorityFeePerGas: null }; + return { maxFeePerGas: null, maxPriorityFeePerGas: null, baseFee: null }; } } - // eip-1559 formula, with an extra 10% tip to account for gas volatility - maxFeePerGas = baseBlockFee - .mul(2) - .add(getPreferredPriorityFee(maxPriorityFeePerGas)); + // add 10% tip to maxPriorityFeePerGas for faster processing + maxPriorityFeePerGas = getPreferredPriorityFee(maxPriorityFeePerGas); + // eip-1559 formula, doubling the base fee ensures that the tx can be included in the next 6 blocks no matter how busy the network is + // good article on the subject: https://www.blocknative.com/blog/eip-1559-fees + maxFeePerGas = baseBlockFee.mul(2).add(maxPriorityFeePerGas); - return { maxFeePerGas, maxPriorityFeePerGas }; + return { maxFeePerGas, maxPriorityFeePerGas, baseFee: baseBlockFee }; } function getPreferredPriorityFee( @@ -80,8 +82,8 @@ function getPreferredPriorityFee( percentMultiplier: number = 10, ): BigNumber { const extraTip = defaultPriorityFeePerGas.div(100).mul(percentMultiplier); // + 10% - const txGasPrice = defaultPriorityFeePerGas.add(extraTip); - return txGasPrice; + const totalPriorityFee = defaultPriorityFeePerGas.add(extraTip); + return totalPriorityFee; } export async function getGasPrice( diff --git a/packages/sdk/src/evm/common/marketplace.ts b/packages/sdk/src/evm/common/marketplace.ts index 9691e76a1ce..23ba64a9d51 100644 --- a/packages/sdk/src/evm/common/marketplace.ts +++ b/packages/sdk/src/evm/common/marketplace.ts @@ -13,7 +13,7 @@ import { InterfaceId_IERC1155, InterfaceId_IERC721, } from "../constants/contract"; -import { ContractWrapper } from "../core/classes/contract-wrapper"; +import { ContractWrapper } from "../core/classes/internal/contract-wrapper"; import { fetchCurrencyValue } from "./currency/fetchCurrencyValue"; import { NewDirectListing } from "../types/marketplace/NewDirectListing"; import { NewAuctionListing } from "../types/marketplace/NewAuctionListing"; diff --git a/packages/sdk/src/evm/common/metadata-resolver.ts b/packages/sdk/src/evm/common/metadata-resolver.ts index 7c81fa29228..313fde44151 100644 --- a/packages/sdk/src/evm/common/metadata-resolver.ts +++ b/packages/sdk/src/evm/common/metadata-resolver.ts @@ -32,6 +32,9 @@ function putInCache( metadataCache[getCacheKey(address, chainId)] = metadata; } +/** + * @internal + */ export function getContractMetadataFromCache( address: string, chainId: number, @@ -96,6 +99,9 @@ export async function fetchContractMetadataFromAddress( return metadata; } +/** + * @internal + */ export async function fetchContractMetadataFromBytecode( address: Address, chainId: number, diff --git a/packages/sdk/src/evm/common/plugin/getCompositePluginABI.ts b/packages/sdk/src/evm/common/plugin/getCompositePluginABI.ts index 2e1de4693f0..9638258b2f9 100644 --- a/packages/sdk/src/evm/common/plugin/getCompositePluginABI.ts +++ b/packages/sdk/src/evm/common/plugin/getCompositePluginABI.ts @@ -2,7 +2,7 @@ import { getAllExtensionsAbi, getAllPluginsAbi, } from "../../constants/thirdweb-features"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { Abi, AbiSchema } from "../../schema/contracts/custom"; import { SDKOptions } from "../../schema/sdk-options"; import { isExtensionEnabled } from "../feature-detection/isFeatureEnabled"; diff --git a/packages/sdk/src/evm/common/role.ts b/packages/sdk/src/evm/common/role.ts index fe5c8b4d47c..0fa59e7f26b 100644 --- a/packages/sdk/src/evm/common/role.ts +++ b/packages/sdk/src/evm/common/role.ts @@ -16,6 +16,7 @@ const roleMap = { signer: "SIGNER_ROLE", metadata: "METADATA_ROLE", revoke: "REVOKE_ROLE", + migration: "MIGRATION_ROLE", } as const; /** diff --git a/packages/sdk/src/evm/common/version-checker.ts b/packages/sdk/src/evm/common/version-checker.ts index 6a03ad188ba..f37efaad5c1 100644 --- a/packages/sdk/src/evm/common/version-checker.ts +++ b/packages/sdk/src/evm/common/version-checker.ts @@ -58,6 +58,9 @@ export function isIncrementalVersion(current: string, next: string) { return eqMajor && eqMinor && nextSemver.patch > currentSemver.patch; } +/** + * @internal + */ export function isDowngradeVersion(current: string, next: string) { const currentSemver = toSemver(current); const nextSemver = toSemver(next); diff --git a/packages/sdk/src/evm/constants/addresses/getContractPublisherAddress.ts b/packages/sdk/src/evm/constants/addresses/getContractPublisherAddress.ts index dde2d7534bc..1b45ca081bd 100644 --- a/packages/sdk/src/evm/constants/addresses/getContractPublisherAddress.ts +++ b/packages/sdk/src/evm/constants/addresses/getContractPublisherAddress.ts @@ -1,6 +1,6 @@ import { getProcessEnv } from "../../../core/utils/process"; -const ContractPublisher_address = "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; // Polygon only +const ContractPublisher_address = "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; // Polygon only /** * @internal diff --git a/packages/sdk/src/evm/constants/urls.ts b/packages/sdk/src/evm/constants/urls.ts index 8f467171a92..1a845d87f8d 100644 --- a/packages/sdk/src/evm/constants/urls.ts +++ b/packages/sdk/src/evm/constants/urls.ts @@ -79,6 +79,9 @@ export function getChainProvider( return getProviderFromRpcUrl(rpcUrl, sdkOptions, chainId); } +/** + * @internal + */ export function getChainIdFromNetwork( network: ChainOrRpcUrl, options: SDKOptionsOutput, @@ -109,6 +112,9 @@ export function getChainIdFromNetwork( ); } +/** + * @internal + */ export async function getChainIdOrName( network: NetworkInput, ): Promise { @@ -134,6 +140,7 @@ export async function getChainIdOrName( /** * Check whether a NetworkInput value is a Chain config (naively, without parsing) + * @internal */ export function isChainConfig( network: NetworkInput, diff --git a/packages/sdk/src/evm/contracts/contractRoles.ts b/packages/sdk/src/evm/contracts/contractRoles.ts index 0685f82b133..23e03abe74a 100644 --- a/packages/sdk/src/evm/contracts/contractRoles.ts +++ b/packages/sdk/src/evm/contracts/contractRoles.ts @@ -1,6 +1,11 @@ export const ADMIN_ROLE = ["admin"] as const; -export const NFT_BASE_CONTRACT_ROLES = ["admin", "minter", "transfer"] as const; +export const NFT_BASE_CONTRACT_ROLES = [ + "admin", + "minter", + "transfer", + "metadata", +] as const; export const MARKETPLACE_CONTRACT_ROLES = ["admin", "lister", "asset"] as const; diff --git a/packages/sdk/src/evm/contracts/index.ts b/packages/sdk/src/evm/contracts/index.ts index 847eeb496fb..22bc31ce970 100644 --- a/packages/sdk/src/evm/contracts/index.ts +++ b/packages/sdk/src/evm/contracts/index.ts @@ -60,6 +60,9 @@ type InitalizeParams = [ options?: SDKOptions, ]; +/** + * @internal + */ export const EditionDropInitializer = { name: "DropERC1155" as const, contractType: prebuiltContractTypes["edition-drop"], @@ -106,6 +109,9 @@ export const EditionDropInitializer = { }, }; +/** + * @internal + */ export const EditionInitializer = { name: "TokenERC1155" as const, contractType: prebuiltContractTypes["edition"], @@ -146,6 +152,9 @@ export const EditionInitializer = { }, }; +/** + * @internal + */ export const MarketplaceInitializer = { name: "Marketplace" as const, contractType: prebuiltContractTypes.marketplace, @@ -187,6 +196,9 @@ export const MarketplaceInitializer = { }, }; +/** + * @internal + */ export const MarketplaceV3Initializer = { name: "MarketplaceV3" as const, contractType: prebuiltContractTypes["marketplace-v3"], @@ -256,6 +268,9 @@ export const MarketplaceV3Initializer = { }, }; +/** + * @internal + */ export const MultiwrapInitializer = { name: "Multiwrap" as const, contractType: prebuiltContractTypes.multiwrap, @@ -295,6 +310,9 @@ export const MultiwrapInitializer = { }, }; +/** + * @internal + */ export const NFTCollectionInitializer = { name: "TokenERC721" as const, contractType: prebuiltContractTypes["nft-collection"], @@ -336,6 +354,9 @@ export const NFTCollectionInitializer = { }, }; +/** + * @internal + */ export const NFTDropInitializer = { name: "DropERC721" as const, contractType: prebuiltContractTypes["nft-drop"], @@ -382,6 +403,9 @@ export const NFTDropInitializer = { }, }; +/** + * @internal + */ export const PackInitializer = { name: "Pack" as const, contractType: prebuiltContractTypes["pack"], @@ -424,6 +448,9 @@ export const PackInitializer = { }, }; +/** + * @internal + */ export const SignatureDropInitializer = { name: "SignatureDrop" as const, contractType: prebuiltContractTypes["signature-drop"], @@ -474,6 +501,9 @@ export const SignatureDropInitializer = { }, }; +/** + * @internal + */ export const SplitInitializer = { name: "Split" as const, contractType: prebuiltContractTypes["split"], @@ -514,6 +544,9 @@ export const SplitInitializer = { }, }; +/** + * @internal + */ export const TokenDropInitializer = { name: "DropERC20" as const, contractType: prebuiltContractTypes["token-drop"], @@ -558,6 +591,9 @@ export const TokenDropInitializer = { }, }; +/** + * @internal + */ export const TokenInitializer = { name: "TokenERC20" as const, contractType: prebuiltContractTypes.token, @@ -598,6 +634,9 @@ export const TokenInitializer = { }, }; +/** + * @internal + */ export const VoteInitializer = { name: "VoteERC20" as const, contractType: prebuiltContractTypes.vote, @@ -666,6 +705,9 @@ export const PREBUILT_CONTRACTS_MAP = /* @__PURE__ */ { [prebuiltContractTypes.vote]: VoteInitializer, } as const; +/** + * @internal + */ export const PREBUILT_CONTRACTS_APPURI_MAP = /* @__PURE__ */ { [prebuiltContractTypes["edition-drop"]]: "ipfs://QmNm3wRzpKYWo1SRtJfgfxtvudp5p2nXD6EttcsQJHwTmk", @@ -695,6 +737,9 @@ const SmartContract = { roles: ALL_ROLES, }; +/** + * @internal + */ export const CONTRACTS_MAP = /* @__PURE__ */ { ...PREBUILT_CONTRACTS_MAP, [SmartContract.contractType]: SmartContract, @@ -710,6 +755,9 @@ export function getContractTypeForRemoteName(name: string): ContractType { ); } +/** + * @internal + */ export function getContractName( type: PrebuiltContractType, ): string | undefined { @@ -718,28 +766,47 @@ export function getContractName( )?.name; } +/** + * @internal + */ export type PrebuiltContractsMap = typeof PREBUILT_CONTRACTS_MAP; +/** + * @internal + */ export type PrebuiltContractsInstances = { [K in keyof PrebuiltContractsMap]: Awaited< ReturnType<(typeof PREBUILT_CONTRACTS_MAP)[K]["initialize"]> >; }; - +/** + * @internal + */ export type ContractsMap = typeof CONTRACTS_MAP; - +/** + * @internal + */ export type ValidContractInstance = | Awaited> | SmartContractType; - +/** + * @internal + */ export type SchemaForPrebuiltContractType< TContractType extends PrebuiltContractType, > = PrebuiltContractsMap[TContractType]["schema"]; - +/** + * @internal + */ export type ContractForPrebuiltContractType< TContractType extends PrebuiltContractType, > = PrebuiltContractsInstances[TContractType]; - +/** + * @internal + */ export type ContractType = keyof ContractsMap; +/** + * @internal + */ export type DeploySchemaForPrebuiltContractType< TContractType extends PrebuiltContractType, > = SchemaForPrebuiltContractType["deploy"]; diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/edition-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/edition-drop.ts index aa7b36cfe6c..5e1f7bad3b1 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/edition-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/edition-drop.ts @@ -14,10 +14,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { DropErc1155ClaimConditions } from "../../core/classes/drop-erc1155-claim-conditions"; -import { DropErc1155History } from "../../core/classes/drop-erc1155-history"; -import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; +import { DropErc1155History } from "../../core/classes/internal/erc1155/drop-erc1155-history"; +import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput, TransactionResultWithId } from "../../core/types"; @@ -42,14 +42,15 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "edition-drop"); * ``` * - * @public + * @internal + * @deprecated use contract.erc1155 instead */ export class EditionDrop extends StandardErc1155 { private static contractRoles = NFT_BASE_CONTRACT_ROLES; public abi: Abi; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public encoder: ContractEncoder; public estimator: GasCostEstimator; public events: ContractEvents; @@ -117,7 +118,7 @@ export class EditionDrop extends StandardErc1155 { public history: DropErc1155History; public interceptor: ContractInterceptor; - public owner: ContractOwner; + public owner: ContractOwner; constructor( network: NetworkInput, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/edition.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/edition.ts index d02c7a8656a..d7785b5d9f4 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/edition.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/edition.ts @@ -15,9 +15,9 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { Erc1155SignatureMintable } from "../../core/classes/erc-1155-signature-mintable"; -import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; +import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput, TransactionResultWithId } from "../../core/types"; @@ -41,7 +41,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "edition"); * ``` * - * @public + * @internal + * @deprecated use contract.erc1155 instead */ export class Edition extends StandardErc1155 { static contractRoles = NFT_BASE_CONTRACT_ROLES; @@ -57,7 +58,7 @@ export class Edition extends StandardErc1155 { (typeof Edition.contractRoles)[number] >; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public encoder: ContractEncoder; public estimator: GasCostEstimator; public events: ContractEvents; @@ -98,7 +99,7 @@ export class Edition extends StandardErc1155 { */ public signature: Erc1155SignatureMintable; public interceptor: ContractInterceptor; - public owner: ContractOwner; + public owner: ContractOwner; constructor( network: NetworkInput, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplace.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplace.ts index a1612a2633b..5c3ed894f48 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplace.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplace.ts @@ -18,10 +18,10 @@ import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; -import { MarketplaceAuction } from "../../core/classes/marketplace-auction"; -import { MarketplaceDirect } from "../../core/classes/marketplace-direct"; +import { MarketplaceAuction } from "../../core/classes/internal/marketplace/marketplace-auction"; +import { MarketplaceDirect } from "../../core/classes/internal/marketplace/marketplace-direct"; import { Transaction } from "../../core/classes/transactions"; import { UpdateableNetwork } from "../../core/interfaces/contract"; import { NetworkInput } from "../../core/types"; @@ -50,7 +50,8 @@ import { Offer } from "../../types/marketplace/Offer"; * const contract = await sdk.getContract("{{contract_address}}", "marketplace"); * ``` * - * @public + * @internal + * @deprecated use contract.directListings / contract.auctions / contract.offers instead */ export class Marketplace implements UpdateableNetwork { static contractRoles = MARKETPLACE_CONTRACT_ROLES; @@ -62,7 +63,7 @@ export class Marketplace implements UpdateableNetwork { public encoder: ContractEncoder; public events: ContractEvents; public estimator: GasCostEstimator; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public metadata: ContractMetadata< MarketplaceContract, typeof MarketplaceContractSchema diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplacev3.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplacev3.ts index 717dd45618b..0cbc3389735 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplacev3.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/marketplacev3.ts @@ -20,7 +20,7 @@ import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { MarketplaceV3DirectListings } from "../../core/classes/marketplacev3-direct-listings"; import { MarketplaceV3EnglishAuctions } from "../../core/classes/marketplacev3-english-auction"; @@ -46,7 +46,8 @@ import { MARKETPLACE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "marketplace"); * ``` * - * @public + * @internal + * @deprecated use contract.directListings / contract.auctions / contract.offers instead */ export class MarketplaceV3 implements UpdateableNetwork { static contractRoles = MARKETPLACE_CONTRACT_ROLES; @@ -58,7 +59,7 @@ export class MarketplaceV3 implements UpdateableNetwork { public encoder: ContractEncoder; public events: ContractEvents; public estimator: GasCostEstimator; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public metadata: ContractMetadata< MarketplaceV3Contract, typeof MarketplaceContractSchema diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/multiwrap.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/multiwrap.ts index 5a3188332dd..cc27c52e562 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/multiwrap.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/multiwrap.ts @@ -20,8 +20,8 @@ import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractOwner } from "../../core/classes/contract-owner"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; -import { StandardErc721 } from "../../core/classes/erc-721-standard"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput, TransactionResultWithId } from "../../core/types"; @@ -52,6 +52,7 @@ import { MULTIWRAP_CONTRACT_ROLES } from "../contractRoles"; * * @beta */ +// TODO create extension wrappers for this export class Multiwrap extends StandardErc721 { static contractRoles = MULTIWRAP_CONTRACT_ROLES; @@ -90,7 +91,7 @@ export class Multiwrap extends StandardErc721 { MultiwrapContract, typeof MultiwrapContractSchema >; - public owner: ContractOwner; + public owner: ContractOwner; constructor( network: NetworkInput, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-collection.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-collection.ts index a215cf9a07c..a833dee3b13 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-collection.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-collection.ts @@ -14,8 +14,8 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; -import { StandardErc721 } from "../../core/classes/erc-721-standard"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard"; import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; @@ -39,7 +39,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "nft-collection"); * ``` * - * @public + * @internal + * @deprecated use contract.erc721 instead */ export class NFTCollection extends StandardErc721 { static contractRoles = NFT_BASE_CONTRACT_ROLES; @@ -59,7 +60,7 @@ export class NFTCollection extends StandardErc721 { public estimator: GasCostEstimator; public events: ContractEvents; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; /** * Configure royalties * @remarks Set your own royalties for the entire contract or per token @@ -81,7 +82,7 @@ export class NFTCollection extends StandardErc721 { TokenERC721, typeof TokenErc721ContractSchema >; - public owner: ContractOwner; + public owner: ContractOwner; /** * Signature Minting diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts index 1d142614304..7b7b80b401c 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts @@ -18,10 +18,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { DelayedReveal } from "../../core/classes/delayed-reveal"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; -import { StandardErc721 } from "../../core/classes/erc-721-standard"; +import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput, TransactionResultWithId } from "../../core/types"; @@ -47,7 +47,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "nft-drop"); * ``` * - * @public + * @internal + * @deprecated use contract.erc721 instead */ export class NFTDrop extends StandardErc721 { static contractRoles = NFT_BASE_CONTRACT_ROLES; @@ -61,7 +62,7 @@ export class NFTDrop extends StandardErc721 { >; public app: ContractAppURI; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public events: ContractEvents; public roles: ContractRoles< PrebuiltNFTDrop, @@ -154,7 +155,7 @@ export class NFTDrop extends StandardErc721 { */ public checkout: PaperCheckout; - public owner: ContractOwner; + public owner: ContractOwner; constructor( network: NetworkInput, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/pack.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/pack.ts index 5c291b18a6d..257c67b6176 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/pack.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/pack.ts @@ -37,8 +37,8 @@ import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractOwner } from "../../core/classes/contract-owner"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; -import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { PackVRF } from "../../core/classes/pack-vrf"; import { Transaction } from "../../core/classes/transactions"; @@ -71,6 +71,7 @@ import { PACK_CONTRACT_ROLES } from "../contractRoles"; * * @public */ +// TODO create extension wrappers export class Pack extends StandardErc1155 { static contractRoles = PACK_CONTRACT_ROLES; @@ -107,7 +108,7 @@ export class Pack extends StandardErc1155 { */ public interceptor: ContractInterceptor; - public owner: ContractOwner; + public owner: ContractOwner; private _vrf?: PackVRF; diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts index dfee283f1a3..5968ef510ce 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts @@ -19,10 +19,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { DelayedReveal } from "../../core/classes/delayed-reveal"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; -import { StandardErc721 } from "../../core/classes/erc-721-standard"; +import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard"; import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; @@ -51,13 +51,14 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "signature-drop"); * ``` * - * @public + * @internal + * @deprecated use contract.erc721 instead */ export class SignatureDrop extends StandardErc721 { static contractRoles = NFT_BASE_CONTRACT_ROLES; public abi: Abi; - public owner: ContractOwner; + public owner: ContractOwner; public encoder: ContractEncoder; public estimator: GasCostEstimator; public metadata: ContractMetadata< @@ -66,7 +67,7 @@ export class SignatureDrop extends StandardErc721 { >; public app: ContractAppURI; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public events: ContractEvents; public roles: ContractRoles< SignatureDropContract, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/split.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/split.ts index c8c26f30977..4a972277428 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/split.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/split.ts @@ -13,7 +13,7 @@ import { ContractEvents } from "../../core/classes/contract-events"; import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractRoles } from "../../core/classes/contract-roles"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { UpdateableNetwork } from "../../core/interfaces/contract"; @@ -41,6 +41,7 @@ import { ADMIN_ROLE } from "../contractRoles"; * * @public */ +// TODO create extension wrappers for this export class Split implements UpdateableNetwork { static contractRoles = ADMIN_ROLE; diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/token-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/token-drop.ts index 97fa3f33477..36b31f13518 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/token-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/token-drop.ts @@ -11,9 +11,9 @@ import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; -import { StandardErc20 } from "../../core/classes/erc-20-standard"; +import { StandardErc20 } from "../../core/classes/internal/erc20/erc-20-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput } from "../../core/types"; @@ -37,7 +37,8 @@ import { TOKEN_DROP_CONTRACT_ROLES } from "../contractRoles"; * const sdk = new ThirdwebSDK("{{chainName}}"); * const contract = await sdk.getContract("{{contract_address}}", "token-drop"); * ``` - * + * @internal + * @deprecated use contract.erc20 instead */ export class TokenDrop extends StandardErc20 { static contractRoles = TOKEN_DROP_CONTRACT_ROLES; @@ -55,7 +56,7 @@ export class TokenDrop extends StandardErc20 { public encoder: ContractEncoder; public estimator: GasCostEstimator; public sales: ContractPrimarySale; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public events: ContractEvents; /** * Configure claim conditions diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/token.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/token.ts index ac697c8d1a7..e78047e2c38 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/token.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/token.ts @@ -12,10 +12,10 @@ import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractPrimarySale } from "../../core/classes/contract-sales"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; -import { TokenERC20History } from "../../core/classes/erc-20-history"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; +import { TokenERC20History } from "../../core/classes/internal/erc20/erc-20-history"; import { Erc20SignatureMintable } from "../../core/classes/erc-20-signature-mintable"; -import { StandardErc20 } from "../../core/classes/erc-20-standard"; +import { StandardErc20 } from "../../core/classes/internal/erc20/erc-20-standard"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { NetworkInput } from "../../core/types"; @@ -40,7 +40,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles"; * const contract = await sdk.getContract("{{contract_address}}", "token"); * ``` * - * @public + * @internal + * @deprecated use contract.erc20 instead */ export class Token extends StandardErc20 { static contractRoles = NFT_BASE_CONTRACT_ROLES; @@ -57,7 +58,7 @@ export class Token extends StandardErc20 { public estimator: GasCostEstimator; public history: TokenERC20History; public events: ContractEvents; - public platformFees: ContractPlatformFee; + public platformFees: ContractPlatformFee; public sales: ContractPrimarySale; /** * Signature Minting diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/vote.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/vote.ts index 8814afe930d..c22a221d70a 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/vote.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/vote.ts @@ -17,7 +17,7 @@ import { ContractEncoder } from "../../core/classes/contract-encoder"; import { ContractEvents } from "../../core/classes/contract-events"; import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractMetadata } from "../../core/classes/contract-metadata"; -import { ContractWrapper } from "../../core/classes/contract-wrapper"; +import { ContractWrapper } from "../../core/classes/internal/contract-wrapper"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { Transaction } from "../../core/classes/transactions"; import { UpdateableNetwork } from "../../core/interfaces/contract"; @@ -50,6 +50,7 @@ import { VoteType } from "../../enums/vote/Vote"; * * @public */ +// TODO create extension wrappers for this export class Vote implements UpdateableNetwork { private contractWrapper: ContractWrapper; private storage: ThirdwebStorage; diff --git a/packages/sdk/src/evm/contracts/smart-contract.ts b/packages/sdk/src/evm/contracts/smart-contract.ts index 6dea2815895..2a6fa3aaf6d 100644 --- a/packages/sdk/src/evm/contracts/smart-contract.ts +++ b/packages/sdk/src/evm/contracts/smart-contract.ts @@ -57,7 +57,7 @@ import { ContractPublishedMetadata } from "../core/classes/contract-published-me import { ContractRoles } from "../core/classes/contract-roles"; import { ContractRoyalty } from "../core/classes/contract-royalty"; import { ContractPrimarySale } from "../core/classes/contract-sales"; -import { ContractWrapper } from "../core/classes/contract-wrapper"; +import { ContractWrapper } from "../core/classes/internal/contract-wrapper"; import { Erc1155 } from "../core/classes/erc-1155"; import { Erc20 } from "../core/classes/erc-20"; import { Erc721 } from "../core/classes/erc-721"; @@ -94,17 +94,17 @@ import { ExtensionManager } from "../core/classes/extension-manager"; * // call any function in your contract * await contract.call("myCustomFunction", [param1, param2]); * - * // if your contract follows the ERC721 standard, contract.nft will be present - * const allNFTs = await contract.erc721.query.all() + * // if your contract follows an ERC standard, contract.ercXYZ will be present + * const allNFTs = await contract.erc721.getAll() * - * // if your contract extends IMintableERC721, contract.nft.mint() will be available + * // if your contract extends a particular contract extension, the corresponding function will be available * const tx = await contract.erc721.mint({ * name: "Cool NFT", * image: readFileSync("some_image.png"), * }); * ``` * - * @beta + * @public */ export class SmartContract< TContract extends BaseContractInterface = BaseContract, @@ -118,7 +118,7 @@ export class SmartContract< public interceptor: ContractInterceptor; public encoder: ContractEncoder; public estimator: GasCostEstimator; - public publishedMetadata: ContractPublishedMetadata; + public publishedMetadata: ContractPublishedMetadata; public metadata: ContractMetadata; get abi(): Abi { @@ -149,14 +149,14 @@ export class SmartContract< /** * Handle platform fees */ - get platformFees(): ContractPlatformFee { + get platformFees(): ContractPlatformFee { return assertEnabled(this.detectPlatformFees(), FEATURE_PLATFORM_FEE); } /** * Set and get the owner of the contract */ - get owner(): ContractOwner { + get owner(): ContractOwner { return assertEnabled(this.detectOwnable(), FEATURE_OWNER); } @@ -352,12 +352,12 @@ export class SmartContract< * const isAccountDeployed = await contract.accountFactory.isAccountDeployed(admin, extraData); * ``` */ - get accountFactory(): AccountFactory { + get accountFactory(): AccountFactory { return assertEnabled(this.detectAccountFactory(), FEATURE_ACCOUNT_FACTORY); } // TODO documentation - get account(): Account { + get account(): Account { return assertEnabled(this.detectAccount(), FEATURE_ACCOUNT); } diff --git a/packages/sdk/src/evm/core/classes/account-factory.ts b/packages/sdk/src/evm/core/classes/account-factory.ts index e2d926c08d4..12a445bf653 100644 --- a/packages/sdk/src/evm/core/classes/account-factory.ts +++ b/packages/sdk/src/evm/core/classes/account-factory.ts @@ -8,13 +8,20 @@ import { isContractDeployed } from "../../common/any-evm-utils/isContractDeploye import { buildTransactionFunction } from "../../common/transactions"; import { TransactionResultWithAddress } from "../types"; import { ContractEvents } from "./contract-events"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 -export class AccountFactory - implements DetectableFeature -{ +/** + * Interact with ERC-4337 account factory contracts + * @remarks Exposes useful functions available on the account factory contract. + * @example + * ```javascript + * const contract = await sdk.getContract("{{contract_address}}"); + * await contract.accountFactory.predictAccountAddress(walletAddress); + * ``` + * @public + */ +export class AccountFactory implements DetectableFeature { featureName = FEATURE_ACCOUNT_FACTORY.name; private contractWrapper: ContractWrapper; diff --git a/packages/sdk/src/evm/core/classes/account.ts b/packages/sdk/src/evm/core/classes/account.ts index c8f6aa14655..0964f4d919b 100644 --- a/packages/sdk/src/evm/core/classes/account.ts +++ b/packages/sdk/src/evm/core/classes/account.ts @@ -3,7 +3,7 @@ import { FEATURE_ACCOUNT_PERMISSIONS, } from "../../constants/thirdweb-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import type { IAccountCore } from "@thirdweb-dev/contracts-js"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; @@ -13,14 +13,21 @@ import { SignerWithPermissions, } from "../../types/account"; import { buildTransactionFunction } from "../../common/transactions"; -import { AccountPermissions } from "./account-permissions"; +import { AccountPermissions } from "./internal/erc4337/account-permissions"; import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; import { assertEnabled } from "../../common/feature-detection/assertEnabled"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 -export class Account - implements DetectableFeature -{ +/** + * Interact with ERC-4337 accounts + * @remarks Exposes useful functions available on account contracts. + * @example + * ```javascript + * const contract = await sdk.getContract("{{contract_address}}"); + * await contract.account.getAllAdminsAndSigners(); + * ``` + * @public + */ +export class Account implements DetectableFeature { featureName = FEATURE_ACCOUNT.name; private contractWrapper: ContractWrapper; private accountPermissions: AccountPermissions | undefined; diff --git a/packages/sdk/src/evm/core/classes/airdrop-erc1155.ts b/packages/sdk/src/evm/core/classes/airdrop-erc1155.ts index 994a43d53a1..2914dd84194 100644 --- a/packages/sdk/src/evm/core/classes/airdrop-erc1155.ts +++ b/packages/sdk/src/evm/core/classes/airdrop-erc1155.ts @@ -11,7 +11,7 @@ import { Airdrop1155Output, } from "../../types/airdrop/airdrop"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/airdrop-erc20.ts b/packages/sdk/src/evm/core/classes/airdrop-erc20.ts index 05514cd9f5e..e3a73054615 100644 --- a/packages/sdk/src/evm/core/classes/airdrop-erc20.ts +++ b/packages/sdk/src/evm/core/classes/airdrop-erc20.ts @@ -4,7 +4,7 @@ import { buildTransactionFunction } from "../../common/transactions"; import { FEATURE_AIRDROP_ERC20 } from "../../constants/thirdweb-features"; import { Address } from "../../schema/shared/Address"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; import { Airdrop20Content, Airdrop20Output } from "../../types/airdrop/airdrop"; diff --git a/packages/sdk/src/evm/core/classes/airdrop-erc721.ts b/packages/sdk/src/evm/core/classes/airdrop-erc721.ts index b4806fc8177..c9e0250003d 100644 --- a/packages/sdk/src/evm/core/classes/airdrop-erc721.ts +++ b/packages/sdk/src/evm/core/classes/airdrop-erc721.ts @@ -8,7 +8,7 @@ import { Airdrop721Output, } from "../../types/airdrop/airdrop"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-appuri.ts b/packages/sdk/src/evm/core/classes/contract-appuri.ts index efdfc300853..1548ad13fb9 100644 --- a/packages/sdk/src/evm/core/classes/contract-appuri.ts +++ b/packages/sdk/src/evm/core/classes/contract-appuri.ts @@ -10,7 +10,7 @@ import { FEATURE_APPURI } from "../../constants/thirdweb-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { TransactionResult } from "../types"; import { ContractMetadata } from "./contract-metadata"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-encoder.ts b/packages/sdk/src/evm/core/classes/contract-encoder.ts index 625c5ff581a..a61ad78ff96 100644 --- a/packages/sdk/src/evm/core/classes/contract-encoder.ts +++ b/packages/sdk/src/evm/core/classes/contract-encoder.ts @@ -1,4 +1,4 @@ -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { BaseContract, utils } from "ethers"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-events.ts b/packages/sdk/src/evm/core/classes/contract-events.ts index 46f4c1da0a0..dbd6c6e4916 100644 --- a/packages/sdk/src/evm/core/classes/contract-events.ts +++ b/packages/sdk/src/evm/core/classes/contract-events.ts @@ -2,7 +2,7 @@ import type { BaseContract, Event, providers, utils } from "ethers"; import type EventEmitter from "eventemitter3"; import { EventType } from "../../constants/events"; import type { ContractEvent, EventQueryOptions } from "../../types/events"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; /** * Listen to Contract events in real time diff --git a/packages/sdk/src/evm/core/classes/contract-interceptor.ts b/packages/sdk/src/evm/core/classes/contract-interceptor.ts index a351b76749b..6278e3a2612 100644 --- a/packages/sdk/src/evm/core/classes/contract-interceptor.ts +++ b/packages/sdk/src/evm/core/classes/contract-interceptor.ts @@ -1,9 +1,9 @@ -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { BaseContract, CallOverrides } from "ethers"; /** * Allows overriding transaction behavior for this contract - * @public + * @internal */ export class ContractInterceptor { private contractWrapper; diff --git a/packages/sdk/src/evm/core/classes/contract-metadata.ts b/packages/sdk/src/evm/core/classes/contract-metadata.ts index 1f69448cfe2..cd5495dedbb 100644 --- a/packages/sdk/src/evm/core/classes/contract-metadata.ts +++ b/packages/sdk/src/evm/core/classes/contract-metadata.ts @@ -13,7 +13,7 @@ import { buildTransactionFunction } from "../../common/transactions"; import { FEATURE_METADATA } from "../../constants/thirdweb-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { TransactionResult } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-owner.ts b/packages/sdk/src/evm/core/classes/contract-owner.ts index 75599651c1f..39033c73498 100644 --- a/packages/sdk/src/evm/core/classes/contract-owner.ts +++ b/packages/sdk/src/evm/core/classes/contract-owner.ts @@ -4,17 +4,14 @@ import { buildTransactionFunction } from "../../common/transactions"; import { FEATURE_OWNER } from "../../constants/thirdweb-features"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** * Encodes and decodes Contract functions * @public */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 -export class ContractOwner - implements DetectableFeature -{ +export class ContractOwner implements DetectableFeature { featureName = FEATURE_OWNER.name; private contractWrapper; diff --git a/packages/sdk/src/evm/core/classes/contract-platform-fee.ts b/packages/sdk/src/evm/core/classes/contract-platform-fee.ts index f45222a2e04..d5c9e8cde7a 100644 --- a/packages/sdk/src/evm/core/classes/contract-platform-fee.ts +++ b/packages/sdk/src/evm/core/classes/contract-platform-fee.ts @@ -4,7 +4,7 @@ import { buildTransactionFunction } from "../../common/transactions"; import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; import { CommonPlatformFeeSchema } from "../../schema/contracts/common"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** @@ -21,10 +21,7 @@ import { Transaction } from "./transactions"; * ``` * @public */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 -export class ContractPlatformFee - implements DetectableFeature -{ +export class ContractPlatformFee implements DetectableFeature { featureName = FEATURE_PLATFORM_FEE.name; private contractWrapper; diff --git a/packages/sdk/src/evm/core/classes/contract-published-metadata.ts b/packages/sdk/src/evm/core/classes/contract-published-metadata.ts index 21fe96d9495..5ff45851933 100644 --- a/packages/sdk/src/evm/core/classes/contract-published-metadata.ts +++ b/packages/sdk/src/evm/core/classes/contract-published-metadata.ts @@ -10,15 +10,14 @@ import { ContractSource, PublishedMetadata, } from "../../schema/contracts/custom"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { fetchSourceFilesFromMetadata } from "../../common/fetchSourceFilesFromMetadata"; /** * Handles publish metadata for a contract * @internal */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 -export class ContractPublishedMetadata { +export class ContractPublishedMetadata { private contractWrapper; private storage: ThirdwebStorage; diff --git a/packages/sdk/src/evm/core/classes/contract-publisher.ts b/packages/sdk/src/evm/core/classes/contract-publisher.ts index d153e1d69d3..d5a6dc6b2d4 100644 --- a/packages/sdk/src/evm/core/classes/contract-publisher.ts +++ b/packages/sdk/src/evm/core/classes/contract-publisher.ts @@ -42,8 +42,8 @@ import { import { SDKOptions } from "../../schema/sdk-options"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; import { NetworkInput, TransactionResult } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { RPCConnectionHandler } from "./rpc-connection-handler"; +import { ContractWrapper } from "./internal/contract-wrapper"; +import { RPCConnectionHandler } from "./internal/rpc-connection-handler"; import { Transaction } from "./transactions"; import { fetchAndCacheDeployMetadata } from "../../common/any-evm-utils/fetchAndCacheDeployMetadata"; import { fetchPublishedContractFromPolygon } from "../../common/any-evm-utils/fetchPublishedContractFromPolygon"; diff --git a/packages/sdk/src/evm/core/classes/contract-roles.ts b/packages/sdk/src/evm/core/classes/contract-roles.ts index 9a9880001de..2f10298e730 100644 --- a/packages/sdk/src/evm/core/classes/contract-roles.ts +++ b/packages/sdk/src/evm/core/classes/contract-roles.ts @@ -14,7 +14,7 @@ import { Address } from "../../schema/shared/Address"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { ContractEncoder } from "./contract-encoder"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** @@ -135,9 +135,17 @@ export class ContractRoles * * */ setAll = /* @__PURE__ */ buildTransactionFunction( - async (rolesWithAddresses: { - [key in TRole]?: AddressOrEns[]; - }): Promise => { + async ( + rolesWithAddresses: { + [key in TRole]?: AddressOrEns[]; + }, + actingAddress?: string, + ): Promise => { + // if we are removing multiple roles, we need to allways remove the connected wallet address *last* + // this is so we don't renounce (i.e.) admin role first and then try to revoke someone else's (i.e.) admin role after (which will revert the entire txn because we are no longer an admin) + // if it is explicitly passed in (i.e. for estimation) we use that value, otherwise we get it from the connected signer + const connectedWalletAddress = + actingAddress || (await this.contractWrapper.getSignerAddress()); const contractEncoder = new ContractEncoder(this.contractWrapper); const roles = Object.keys(rolesWithAddresses) as TRole[]; @@ -170,6 +178,16 @@ export class ContractRoles const toRemove = currentAddresses.filter( (address) => !addresses.includes(address), ); + + // if we're removing more than one address we have to make sure we always remove the *connected* (acting) wallet address first + // otherwise we'll revoke the connected wallet address and then try to revoke someone else's address which will revert the entire txn + if (toRemove.length > 1) { + const index = toRemove.indexOf(connectedWalletAddress); + if (index > -1) { + toRemove.splice(index, 1); + toRemove.push(connectedWalletAddress); + } + } if (toAdd.length) { toAdd.forEach((address) => { encoded.push( diff --git a/packages/sdk/src/evm/core/classes/contract-royalty.ts b/packages/sdk/src/evm/core/classes/contract-royalty.ts index aa96780b08a..deab1f746b0 100644 --- a/packages/sdk/src/evm/core/classes/contract-royalty.ts +++ b/packages/sdk/src/evm/core/classes/contract-royalty.ts @@ -13,7 +13,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { TransactionResult } from "../types"; import { ContractEncoder } from "./contract-encoder"; import { ContractMetadata, IGenericSchemaType } from "./contract-metadata"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-sales.ts b/packages/sdk/src/evm/core/classes/contract-sales.ts index b62544af61e..d4baa0206fb 100644 --- a/packages/sdk/src/evm/core/classes/contract-sales.ts +++ b/packages/sdk/src/evm/core/classes/contract-sales.ts @@ -3,7 +3,7 @@ import { buildTransactionFunction } from "../../common/transactions"; import { FEATURE_PRIMARY_SALE } from "../../constants/thirdweb-features"; import { Address } from "../../schema/shared/Address"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-verifier.ts b/packages/sdk/src/evm/core/classes/contract-verifier.ts index 3f5c59069b7..4d4b395266f 100644 --- a/packages/sdk/src/evm/core/classes/contract-verifier.ts +++ b/packages/sdk/src/evm/core/classes/contract-verifier.ts @@ -7,7 +7,7 @@ import { verify } from "../../common/verification"; import { SDKOptions } from "../../schema/sdk-options"; import { ConstructorParamMap } from "../../types/any-evm/deploy-data"; import { NetworkInput } from "../types"; -import { RPCConnectionHandler } from "./rpc-connection-handler"; +import { RPCConnectionHandler } from "./internal/rpc-connection-handler"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import invariant from "tiny-invariant"; diff --git a/packages/sdk/src/evm/core/classes/delayed-reveal.ts b/packages/sdk/src/evm/core/classes/delayed-reveal.ts index 8dfbe511506..af97af72f87 100644 --- a/packages/sdk/src/evm/core/classes/delayed-reveal.ts +++ b/packages/sdk/src/evm/core/classes/delayed-reveal.ts @@ -25,7 +25,7 @@ import { } from "../../types/eips"; import type { UploadProgressEvent } from "../../types/events"; import type { TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/drop-claim-conditions.ts b/packages/sdk/src/evm/core/classes/drop-claim-conditions.ts index 2dcad8a1be6..61017314909 100644 --- a/packages/sdk/src/evm/core/classes/drop-claim-conditions.ts +++ b/packages/sdk/src/evm/core/classes/drop-claim-conditions.ts @@ -53,7 +53,7 @@ import { } from "../../types/eips"; import { ContractEncoder } from "./contract-encoder"; import { ContractMetadata } from "./contract-metadata"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; import { ClaimEligibility } from "../../enums/ClaimEligibility"; @@ -931,7 +931,7 @@ export class DropClaimConditions< }); } - isNewSinglePhaseDrop( + private isNewSinglePhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return ( @@ -946,7 +946,7 @@ export class DropClaimConditions< ); } - isNewMultiphaseDrop( + private isNewMultiphaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return ( @@ -955,7 +955,7 @@ export class DropClaimConditions< ); } - isLegacySinglePhaseDrop( + private isLegacySinglePhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return ( @@ -970,7 +970,7 @@ export class DropClaimConditions< ); } - isLegacyMultiPhaseDrop( + private isLegacyMultiPhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return ( diff --git a/packages/sdk/src/evm/core/classes/drop-erc1155-claim-conditions.ts b/packages/sdk/src/evm/core/classes/drop-erc1155-claim-conditions.ts index bb261b72543..dba290f53f9 100644 --- a/packages/sdk/src/evm/core/classes/drop-erc1155-claim-conditions.ts +++ b/packages/sdk/src/evm/core/classes/drop-erc1155-claim-conditions.ts @@ -47,7 +47,7 @@ import { } from "../../types/eips"; import { ContractEncoder } from "./contract-encoder"; import { ContractMetadata } from "./contract-metadata"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; import { ClaimEligibility } from "../../enums/ClaimEligibility"; @@ -972,7 +972,7 @@ export class DropErc1155ClaimConditions< }); } - isNewSinglePhaseDrop( + private isNewSinglePhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return detectContractFeature( @@ -981,7 +981,7 @@ export class DropErc1155ClaimConditions< ); } - isNewMultiphaseDrop( + private isNewMultiphaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return detectContractFeature( @@ -990,7 +990,7 @@ export class DropErc1155ClaimConditions< ); } - isLegacySinglePhaseDrop( + private isLegacySinglePhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return detectContractFeature( @@ -999,7 +999,7 @@ export class DropErc1155ClaimConditions< ); } - isLegacyMultiPhaseDrop( + private isLegacyMultiPhaseDrop( contractWrapper: ContractWrapper, ): contractWrapper is ContractWrapper { return detectContractFeature( diff --git a/packages/sdk/src/evm/core/classes/erc-1155-signature-mintable.ts b/packages/sdk/src/evm/core/classes/erc-1155-signature-mintable.ts index f3e7c1d5395..d62d0a70b47 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-signature-mintable.ts +++ b/packages/sdk/src/evm/core/classes/erc-1155-signature-mintable.ts @@ -30,7 +30,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { TransactionResultWithId } from "../types"; import { ContractEncoder } from "./contract-encoder"; import { ContractRoles } from "./contract-roles"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-1155.ts b/packages/sdk/src/evm/core/classes/erc-1155.ts index d9069443d08..4fac3339030 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155.ts +++ b/packages/sdk/src/evm/core/classes/erc-1155.ts @@ -54,17 +54,17 @@ import type { UploadProgressEvent } from "../../types/events"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { UpdateableNetwork } from "../interfaces/contract"; import { NetworkInput, TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { ERC1155Claimable } from "./erc-1155-claimable"; -import { Erc1155ClaimableWithConditions } from "./erc-1155-claimable-with-conditions"; +import { ContractWrapper } from "./internal/contract-wrapper"; +import { ERC1155Claimable } from "./internal/erc1155/erc-1155-claimable"; +import { Erc1155ClaimableWithConditions } from "./internal/erc1155/erc-1155-claimable-with-conditions"; import { Erc1155SignatureMintable } from "./erc-1155-signature-mintable"; import { Transaction } from "./transactions"; import { ContractEncoder } from "./contract-encoder"; -import { Erc1155Burnable } from "./erc-1155-burnable"; -import { Erc1155Enumerable } from "./erc-1155-enumerable"; -import { Erc1155LazyMintable } from "./erc-1155-lazy-mintable"; -import { Erc1155Mintable } from "./erc-1155-mintable"; +import { Erc1155Burnable } from "./internal/erc1155/erc-1155-burnable"; +import { Erc1155Enumerable } from "./internal/erc1155/erc-1155-enumerable"; +import { Erc1155LazyMintable } from "./internal/erc1155/erc-1155-lazy-mintable"; +import { Erc1155Mintable } from "./internal/erc1155/erc-1155-mintable"; /** * Standard ERC1155 NFT functions diff --git a/packages/sdk/src/evm/core/classes/erc-20-signature-mintable.ts b/packages/sdk/src/evm/core/classes/erc-20-signature-mintable.ts index 58ee84a381f..848b9ef0a38 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-signature-mintable.ts +++ b/packages/sdk/src/evm/core/classes/erc-20-signature-mintable.ts @@ -18,7 +18,7 @@ import { import type { DetectableFeature } from "../interfaces/DetectableFeature"; import { ContractEncoder } from "./contract-encoder"; import { ContractRoles } from "./contract-roles"; -import type { ContractWrapper } from "./contract-wrapper"; +import type { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** @@ -213,7 +213,7 @@ export class Erc20SignatureMintable implements DetectableFeature { FilledSignaturePayload20[], ] = await Promise.all([ this.contractWrapper.getChainID(), - this.contractWrapper.read("name", []), // ERC20Permit (EIP-712) spec differs from signature mint 721, 1155. + this.contractWrapper.read("name", []), // ERC20Permit (EIP-712) spec differs from signature mint 721, 1155. Promise.all( payloadsToSign.map((m) => Signature20PayloadInput.parseAsync(m)), ), diff --git a/packages/sdk/src/evm/core/classes/erc-20.ts b/packages/sdk/src/evm/core/classes/erc-20.ts index e26d1cce8b3..ac72a0b9593 100644 --- a/packages/sdk/src/evm/core/classes/erc-20.ts +++ b/packages/sdk/src/evm/core/classes/erc-20.ts @@ -33,14 +33,14 @@ import type { import type { DetectableFeature } from "../interfaces/DetectableFeature"; import { UpdateableNetwork } from "../interfaces/contract"; import type { NetworkInput } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; +import type { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; import { normalizeAmount } from "../../common/currency/normalizeAmount"; import { ContractEncoder } from "./contract-encoder"; -import { Erc20Burnable } from "./erc-20-burnable"; -import { Erc20Droppable } from "./erc-20-droppable"; -import { Erc20Mintable } from "./erc-20-mintable"; +import { Erc20Burnable } from "./internal/erc20/erc-20-burnable"; +import { Erc20Droppable } from "./internal/erc20/erc-20-droppable"; +import { Erc20Mintable } from "./internal/erc20/erc-20-mintable"; import { Erc20SignatureMintable } from "./erc-20-signature-mintable"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-721-with-quantity-signature-mintable.ts b/packages/sdk/src/evm/core/classes/erc-721-with-quantity-signature-mintable.ts index b9158d6b3ca..159e181ea4e 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-with-quantity-signature-mintable.ts +++ b/packages/sdk/src/evm/core/classes/erc-721-with-quantity-signature-mintable.ts @@ -28,7 +28,7 @@ import { import { DetectableFeature } from "../interfaces/DetectableFeature"; import { TransactionResultWithId } from "../types"; import { ContractEncoder } from "./contract-encoder"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-721.ts b/packages/sdk/src/evm/core/classes/erc-721.ts index 11b9c2723ac..5dda556587c 100644 --- a/packages/sdk/src/evm/core/classes/erc-721.ts +++ b/packages/sdk/src/evm/core/classes/erc-721.ts @@ -64,18 +64,18 @@ import type { UploadProgressEvent } from "../../types/events"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { UpdateableNetwork } from "../interfaces/contract"; import type { NetworkInput, TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Erc721Burnable } from "./erc-721-burnable"; -import { Erc721ClaimableWithConditions } from "./erc-721-claim-conditions"; -import { Erc721ClaimableZora } from "./erc-721-claim-zora"; -import { Erc721Claimable } from "./erc-721-claimable"; -import { Erc721LazyMintable } from "./erc-721-lazy-mintable"; -import { Erc721LoyaltyCard } from "./erc-721-loyalty-card"; -import { Erc721UpdatableMetadata } from "./erc-721-metadata"; -import { Erc721Mintable } from "./erc-721-mintable"; -import { Erc721SharedMetadata } from "./erc-721-shared-metadata"; -import { Erc721Supply } from "./erc-721-supply"; -import { Erc721TieredDrop } from "./erc-721-tiered-drop"; +import type { ContractWrapper } from "./internal/contract-wrapper"; +import { Erc721Burnable } from "./internal/erc721/erc-721-burnable"; +import { Erc721ClaimableWithConditions } from "./internal/erc721/erc-721-claim-conditions"; +import { Erc721ClaimableZora } from "./internal/erc721/erc-721-claim-zora"; +import { Erc721Claimable } from "./internal/erc721/erc-721-claimable"; +import { Erc721LazyMintable } from "./internal/erc721/erc-721-lazy-mintable"; +import { Erc721LoyaltyCard } from "./internal/erc721/erc-721-loyalty-card"; +import { Erc721UpdatableMetadata } from "./internal/erc721/erc-721-metadata"; +import { Erc721Mintable } from "./internal/erc721/erc-721-mintable"; +import { Erc721SharedMetadata } from "./internal/erc721/erc-721-shared-metadata"; +import { Erc721Supply } from "./internal/erc721/erc-721-supply"; +import { Erc721TieredDrop } from "./internal/erc721/erc-721-tiered-drop"; import { Erc721WithQuantitySignatureMintable } from "./erc-721-with-quantity-signature-mintable"; import { Transaction } from "./transactions"; diff --git a/packages/sdk/src/evm/core/classes/extension-manager.ts b/packages/sdk/src/evm/core/classes/extension-manager.ts index 8832b2dd2e6..f89272b3430 100644 --- a/packages/sdk/src/evm/core/classes/extension-manager.ts +++ b/packages/sdk/src/evm/core/classes/extension-manager.ts @@ -1,6 +1,6 @@ import type { BaseRouter } from "@thirdweb-dev/contracts-js"; import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { buildTransactionFunction } from "../../common/transactions"; import { Transaction } from "./transactions"; import { diff --git a/packages/sdk/src/evm/core/classes/gas-cost-estimator.ts b/packages/sdk/src/evm/core/classes/gas-cost-estimator.ts index 7ae4f2be710..0d78f6af79c 100644 --- a/packages/sdk/src/evm/core/classes/gas-cost-estimator.ts +++ b/packages/sdk/src/evm/core/classes/gas-cost-estimator.ts @@ -1,4 +1,4 @@ -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { BaseContract, BigNumber, utils } from "ethers"; /** diff --git a/packages/sdk/src/evm/core/classes/contract-wrapper.ts b/packages/sdk/src/evm/core/classes/internal/contract-wrapper.ts similarity index 95% rename from packages/sdk/src/evm/core/classes/contract-wrapper.ts rename to packages/sdk/src/evm/core/classes/internal/contract-wrapper.ts index 6c72e672189..b981167f5a1 100644 --- a/packages/sdk/src/evm/core/classes/contract-wrapper.ts +++ b/packages/sdk/src/evm/core/classes/internal/contract-wrapper.ts @@ -14,34 +14,34 @@ import { type providers, } from "ethers"; import invariant from "tiny-invariant"; -import { computeEOAForwarderAddress } from "../../common/any-evm-utils/computeEOAForwarderAddress"; -import { computeForwarderAddress } from "../../common/any-evm-utils/computeForwarderAddress"; -import { TransactionError, parseRevertReason } from "../../common/error"; -import { extractFunctionsFromAbi } from "../../common/feature-detection/extractFunctionsFromAbi"; -import { fetchSourceFilesFromMetadata } from "../../common/fetchSourceFilesFromMetadata"; +import { computeEOAForwarderAddress } from "../../../common/any-evm-utils/computeEOAForwarderAddress"; +import { computeForwarderAddress } from "../../../common/any-evm-utils/computeForwarderAddress"; +import { TransactionError, parseRevertReason } from "../../../common/error"; +import { extractFunctionsFromAbi } from "../../../common/feature-detection/extractFunctionsFromAbi"; +import { fetchSourceFilesFromMetadata } from "../../../common/fetchSourceFilesFromMetadata"; import { BiconomyForwarderAbi, ChainAwareForwardRequest, ForwardRequest, getAndIncrementNonce, -} from "../../common/forwarder"; -import { getDefaultGasOverrides } from "../../common/gas-price"; -import { fetchContractMetadataFromAddress } from "../../common/metadata-resolver"; -import { signEIP2612Permit } from "../../common/permit"; -import { signTypedDataInternal } from "../../common/sign"; -import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES"; -import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId"; -import { EventType } from "../../constants/events"; -import { AbiSchema, ContractSource } from "../../schema/contracts/custom"; -import { SDKOptions } from "../../schema/sdk-options"; -import { Address } from "../../schema/shared/Address"; -import { CallOverrideSchema } from "../../schema/shared/CallOverrideSchema"; +} from "../../../common/forwarder"; +import { getDefaultGasOverrides } from "../../../common/gas-price"; +import { fetchContractMetadataFromAddress } from "../../../common/metadata-resolver"; +import { signEIP2612Permit } from "../../../common/permit"; +import { signTypedDataInternal } from "../../../common/sign"; +import { CONTRACT_ADDRESSES } from "../../../constants/addresses/CONTRACT_ADDRESSES"; +import { getContractAddressByChainId } from "../../../constants/addresses/getContractAddressByChainId"; +import { EventType } from "../../../constants/events"; +import { AbiSchema, ContractSource } from "../../../schema/contracts/custom"; +import { SDKOptions } from "../../../schema/sdk-options"; +import { Address } from "../../../schema/shared/Address"; +import { CallOverrideSchema } from "../../../schema/shared/CallOverrideSchema"; import { ForwardRequestMessage, GaslessTransaction, NetworkInput, PermitRequestMessage, -} from "../types"; +} from "../../types"; import { RPCConnectionHandler } from "./rpc-connection-handler"; /** diff --git a/packages/sdk/src/evm/core/classes/drop-erc1155-history.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/drop-erc1155-history.ts similarity index 90% rename from packages/sdk/src/evm/core/classes/drop-erc1155-history.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/drop-erc1155-history.ts index fb6f6007cd2..38415a0c0b4 100644 --- a/packages/sdk/src/evm/core/classes/drop-erc1155-history.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/drop-erc1155-history.ts @@ -1,5 +1,5 @@ -import { PrebuiltEditionDrop } from "../../types/eips"; -import { ContractEvents } from "./contract-events"; +import { PrebuiltEditionDrop } from "../../../../types/eips"; +import { ContractEvents } from "../../contract-events"; import { BigNumber, BigNumberish } from "ethers"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-1155-batch-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-batch-mintable.ts similarity index 82% rename from packages/sdk/src/evm/core/classes/erc-1155-batch-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-batch-mintable.ts index 43d96c6d154..afc3f9346dc 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-batch-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-batch-mintable.ts @@ -2,19 +2,19 @@ import type { IMintableERC1155, IMulticall } from "@thirdweb-dev/contracts-js"; import { TokensMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/TokenERC1155"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { constants } from "ethers"; -import { NFT } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { uploadOrExtractURIs } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_EDITION_BATCH_MINTABLE } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { EditionMetadataOrUri } from "../../schema/tokens/edition"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { TransactionResultWithId } from "../types"; -import { ContractEncoder } from "./contract-encoder"; -import { ContractWrapper } from "./contract-wrapper"; -import type { Erc1155 } from "./erc-1155"; -import { Transaction } from "./transactions"; +import { NFT } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { uploadOrExtractURIs } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_EDITION_BATCH_MINTABLE } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { EditionMetadataOrUri } from "../../../../schema/tokens/edition"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { TransactionResultWithId } from "../../../types"; +import { ContractEncoder } from "../../contract-encoder"; +import { ContractWrapper } from "../contract-wrapper"; +import type { Erc1155 } from "../../erc-1155"; +import { Transaction } from "../../transactions"; /** * Mint Many ERC1155 NFTs at once diff --git a/packages/sdk/src/evm/core/classes/erc-1155-burnable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-burnable.ts similarity index 88% rename from packages/sdk/src/evm/core/classes/erc-1155-burnable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-burnable.ts index 1c1b1ea94da..37ae2fc6df6 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-burnable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-burnable.ts @@ -1,10 +1,10 @@ -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_EDITION_BURNABLE } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_EDITION_BURNABLE } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IBurnableERC1155 } from "@thirdweb-dev/contracts-js"; import { BigNumberish } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-1155-claimable-with-conditions.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable-with-conditions.ts similarity index 75% rename from packages/sdk/src/evm/core/classes/erc-1155-claimable-with-conditions.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable-with-conditions.ts index b26b544ff6e..445df7b415f 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-claimable-with-conditions.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable-with-conditions.ts @@ -1,13 +1,13 @@ -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_EDITION_CLAIM_CONDITIONS_V2 } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { CustomContractSchema } from "../../schema/contracts/custom"; -import { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import { BaseClaimConditionERC1155 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractMetadata } from "./contract-metadata"; -import { ContractWrapper } from "./contract-wrapper"; -import { DropErc1155ClaimConditions } from "./drop-erc1155-claim-conditions"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_EDITION_CLAIM_CONDITIONS_V2 } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { CustomContractSchema } from "../../../../schema/contracts/custom"; +import { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import { BaseClaimConditionERC1155 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractMetadata } from "../../contract-metadata"; +import { ContractWrapper } from "../contract-wrapper"; +import { DropErc1155ClaimConditions } from "../../drop-erc1155-claim-conditions"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumberish } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-1155-claimable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable.ts similarity index 82% rename from packages/sdk/src/evm/core/classes/erc-1155-claimable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable.ts index b7214aa6c26..bad827aac60 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-claimable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-claimable.ts @@ -1,12 +1,12 @@ -import { calculateClaimCost } from "../../common/claim-conditions/calculateClaimCost"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_EDITION_CLAIM_CUSTOM } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { calculateClaimCost } from "../../../../common/claim-conditions/calculateClaimCost"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_EDITION_CLAIM_CUSTOM } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IClaimableERC1155 } from "@thirdweb-dev/contracts-js"; import { BigNumberish, CallOverrides } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-1155-enumerable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-enumerable.ts similarity index 87% rename from packages/sdk/src/evm/core/classes/erc-1155-enumerable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-enumerable.ts index 8a060fa1493..9297680ea8d 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-enumerable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-enumerable.ts @@ -3,15 +3,15 @@ import { BigNumber, BigNumberish } from "ethers"; import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams, -} from "../../../core/schema/QueryParams"; -import { NFT } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { FEATURE_EDITION_ENUMERABLE } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { BaseERC1155 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import type { Erc1155 } from "./erc-1155"; +} from "../../../../../core/schema/QueryParams"; +import { NFT } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { FEATURE_EDITION_ENUMERABLE } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { BaseERC1155 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import type { Erc1155 } from "../../erc-1155"; /** * List ERC1155 NFTs diff --git a/packages/sdk/src/evm/core/classes/erc-1155-lazy-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-lazy-mintable.ts similarity index 87% rename from packages/sdk/src/evm/core/classes/erc-1155-lazy-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-lazy-mintable.ts index c5e2c998e03..fa2c27428cb 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-lazy-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-lazy-mintable.ts @@ -2,23 +2,26 @@ import type { DropERC1155_V2 } from "@thirdweb-dev/contracts-js"; import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/LazyMint"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { utils, type providers } from "ethers"; -import { NFTMetadata, NFTMetadataOrUri } from "../../../core/schema/nft"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { getPrebuiltInfo } from "../../common/legacy"; -import { uploadOrExtractURIs } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; +import { NFTMetadata, NFTMetadataOrUri } from "../../../../../core/schema/nft"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { getPrebuiltInfo } from "../../../../common/legacy"; +import { uploadOrExtractURIs } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; import { FEATURE_EDITION_LAZY_MINTABLE_V2, FEATURE_EDITION_REVEALABLE, -} from "../../constants/erc1155-features"; -import { BaseDelayedRevealERC1155, BaseDropERC1155 } from "../../types/eips"; -import type { UploadProgressEvent } from "../../types/events"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { DelayedReveal } from "./delayed-reveal"; -import type { Erc1155 } from "./erc-1155"; -import { Transaction } from "./transactions"; +} from "../../../../constants/erc1155-features"; +import { + BaseDelayedRevealERC1155, + BaseDropERC1155, +} from "../../../../types/eips"; +import type { UploadProgressEvent } from "../../../../types/events"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { TransactionResultWithId } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { DelayedReveal } from "../../delayed-reveal"; +import type { Erc1155 } from "../../erc-1155"; +import { Transaction } from "../../transactions"; export class Erc1155LazyMintable implements DetectableFeature { featureName = FEATURE_EDITION_LAZY_MINTABLE_V2.name; diff --git a/packages/sdk/src/evm/core/classes/erc-1155-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-mintable.ts similarity index 85% rename from packages/sdk/src/evm/core/classes/erc-1155-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-mintable.ts index a99b1fb86ea..2a18a1b25ba 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-mintable.ts @@ -1,21 +1,21 @@ -import { NFT } from "../../../core/schema/nft"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { uploadOrExtractURI } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { EditionMetadataOrUri } from "../../schema/tokens/edition"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { NFT } from "../../../../../core/schema/nft"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { uploadOrExtractURI } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_EDITION_MINTABLE } from "../../../../constants/erc1155-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { EditionMetadataOrUri } from "../../../../schema/tokens/edition"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { TransactionResultWithId } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IMintableERC1155 } from "@thirdweb-dev/contracts-js"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumber, type BigNumberish, constants } from "ethers"; import type { IMulticall } from "@thirdweb-dev/contracts-js"; import { TransferSingleEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/ITokenERC1155"; -import type { Erc1155 } from "./erc-1155"; +import type { Erc1155 } from "../../erc-1155"; import { Erc1155BatchMintable } from "./erc-1155-batch-mintable"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-1155-standard.ts b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-standard.ts similarity index 89% rename from packages/sdk/src/evm/core/classes/erc-1155-standard.ts rename to packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-standard.ts index f49b99185d9..e26c129f467 100644 --- a/packages/sdk/src/evm/core/classes/erc-1155-standard.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc1155/erc-1155-standard.ts @@ -1,16 +1,16 @@ import type { DropERC1155, TokenERC1155 } from "@thirdweb-dev/contracts-js"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumber, BigNumberish, BytesLike } from "ethers"; -import { NFT } from "../../../core/schema/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { Address } from "../../schema/shared/Address"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { AirdropInput } from "../../types/airdrop/airdrop"; -import { BaseERC1155, BaseSignatureMintERC1155 } from "../../types/eips"; -import { UpdateableNetwork } from "../interfaces/contract"; -import { NetworkInput } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Erc1155 } from "./erc-1155"; +import { NFT } from "../../../../../core/schema/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { Address } from "../../../../schema/shared/Address"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { AirdropInput } from "../../../../types/airdrop/airdrop"; +import { BaseERC1155, BaseSignatureMintERC1155 } from "../../../../types/eips"; +import { UpdateableNetwork } from "../../../interfaces/contract"; +import { NetworkInput } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Erc1155 } from "../../erc-1155"; /** * Standard ERC1155 NFT functions diff --git a/packages/sdk/src/evm/core/classes/erc-20-batch-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-batch-mintable.ts similarity index 76% rename from packages/sdk/src/evm/core/classes/erc-20-batch-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-batch-mintable.ts index e8860874ec0..972448a242c 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-batch-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-batch-mintable.ts @@ -1,13 +1,13 @@ import type { IMintableERC20, IMulticall } from "@thirdweb-dev/contracts-js"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../constants/erc20-features"; -import type { TokenMintInput } from "../../schema/tokens/token"; -import type { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractEncoder } from "./contract-encoder"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc20 } from "./erc-20"; -import { Transaction } from "./transactions"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../../../constants/erc20-features"; +import type { TokenMintInput } from "../../../../schema/tokens/token"; +import type { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractEncoder } from "../../contract-encoder"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc20 } from "../../erc-20"; +import { Transaction } from "../../transactions"; /** * Mint Many ERC20 Tokens at once @@ -17,9 +17,8 @@ import { Transaction } from "./transactions"; * const contract = await sdk.getContract("{{contract_address}}"); * await contract.token.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); * ``` - * @public + * @internal */ - export class Erc20BatchMintable implements DetectableFeature { featureName = FEATURE_TOKEN_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; diff --git a/packages/sdk/src/evm/core/classes/erc-20-burnable.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-burnable.ts similarity index 73% rename from packages/sdk/src/evm/core/classes/erc-20-burnable.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-burnable.ts index d673573c628..d7706219ff6 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-burnable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-burnable.ts @@ -1,14 +1,17 @@ -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_TOKEN_BURNABLE } from "../../constants/erc20-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { Amount } from "../../types/currency"; -import type { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_TOKEN_BURNABLE } from "../../../../constants/erc20-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { Amount } from "../../../../types/currency"; +import type { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IBurnableERC20 } from "@thirdweb-dev/contracts-js"; -import type { Erc20 } from "./erc-20"; +import type { Erc20 } from "../../erc-20"; +/** + * @internal + */ export class Erc20Burnable implements DetectableFeature { featureName = FEATURE_TOKEN_BURNABLE.name; diff --git a/packages/sdk/src/evm/core/classes/erc-20-claim-conditions.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-claim-conditions.ts similarity index 79% rename from packages/sdk/src/evm/core/classes/erc-20-claim-conditions.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-claim-conditions.ts index fb8d64ae1ff..64d09bbea84 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-claim-conditions.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-claim-conditions.ts @@ -1,16 +1,16 @@ -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_TOKEN_CLAIM_CONDITIONS_V2 } from "../../constants/erc20-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import type { Amount } from "../../types/currency"; -import type { BaseDropERC20 } from "../../types/eips"; -import type { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_TOKEN_CLAIM_CONDITIONS_V2 } from "../../../../constants/erc20-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import type { Amount } from "../../../../types/currency"; +import type { BaseDropERC20 } from "../../../../types/eips"; +import type { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; -import { CustomContractSchema } from "../../schema/contracts/custom"; -import { ContractMetadata } from "./contract-metadata"; -import { DropClaimConditions } from "./drop-claim-conditions"; -import type { Erc20 } from "./erc-20"; +import { CustomContractSchema } from "../../../../schema/contracts/custom"; +import { ContractMetadata } from "../../contract-metadata"; +import { DropClaimConditions } from "../../drop-claim-conditions"; +import type { Erc20 } from "../../erc-20"; /** * Configure and claim ERC20 tokens diff --git a/packages/sdk/src/evm/core/classes/erc-20-droppable.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-droppable.ts similarity index 91% rename from packages/sdk/src/evm/core/classes/erc-20-droppable.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-droppable.ts index 81d0e63d4a9..e5d140a60ca 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-droppable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-droppable.ts @@ -1,7 +1,7 @@ -import type { BaseDropERC20 } from "../../types/eips"; -import type { ContractWrapper } from "./contract-wrapper"; +import type { BaseDropERC20 } from "../../../../types/eips"; +import type { ContractWrapper } from "../contract-wrapper"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; -import type { Erc20 } from "./erc-20"; +import type { Erc20 } from "../../erc-20"; import { Erc20ClaimableWithConditions } from "./erc-20-claim-conditions"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-20-history.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-history.ts similarity index 87% rename from packages/sdk/src/evm/core/classes/erc-20-history.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-history.ts index 659e64ad454..64590bf6a2c 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-history.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-history.ts @@ -1,9 +1,9 @@ import type { TokenERC20 } from "@thirdweb-dev/contracts-js"; import { BigNumber, constants } from "ethers"; -import { fetchCurrencyValue } from "../../common/currency/fetchCurrencyValue"; -import type { TokenHolderBalance } from "../../types/currency"; -import { ContractEvents } from "./contract-events"; -import { ContractWrapper } from "./contract-wrapper"; +import { fetchCurrencyValue } from "../../../../common/currency/fetchCurrencyValue"; +import type { TokenHolderBalance } from "../../../../types/currency"; +import { ContractEvents } from "../../contract-events"; +import { ContractWrapper } from "../contract-wrapper"; /** * Manages history for Token contracts diff --git a/packages/sdk/src/evm/core/classes/erc-20-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-mintable.ts similarity index 75% rename from packages/sdk/src/evm/core/classes/erc-20-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-mintable.ts index c636cf4a725..6528be8900f 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-mintable.ts @@ -1,14 +1,14 @@ -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_TOKEN_MINTABLE } from "../../constants/erc20-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { Amount } from "../../types/currency"; -import type { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_TOKEN_MINTABLE } from "../../../../constants/erc20-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { Amount } from "../../../../types/currency"; +import type { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IMintableERC20, IMulticall } from "@thirdweb-dev/contracts-js"; -import type { Erc20 } from "./erc-20"; +import type { Erc20 } from "../../erc-20"; import { Erc20BatchMintable } from "./erc-20-batch-mintable"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-20-standard.ts b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-standard.ts similarity index 90% rename from packages/sdk/src/evm/core/classes/erc-20-standard.ts rename to packages/sdk/src/evm/core/classes/internal/erc20/erc-20-standard.ts index b6e3270f34b..72b6a973899 100644 --- a/packages/sdk/src/evm/core/classes/erc-20-standard.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc20/erc-20-standard.ts @@ -1,16 +1,16 @@ import type { DropERC20, TokenERC20 } from "@thirdweb-dev/contracts-js"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; -import { buildTransactionFunction } from "../../common/transactions"; -import { Address } from "../../schema/shared/Address"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { TokenMintInput } from "../../schema/tokens/token"; -import { Amount, Currency, CurrencyValue } from "../../types/currency"; -import { BaseERC20, BaseSignatureMintERC20 } from "../../types/eips"; -import { UpdateableNetwork } from "../interfaces/contract"; -import { NetworkInput } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Erc20 } from "./erc-20"; -import { Transaction } from "./transactions"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { Address } from "../../../../schema/shared/Address"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { TokenMintInput } from "../../../../schema/tokens/token"; +import { Amount, Currency, CurrencyValue } from "../../../../types/currency"; +import { BaseERC20, BaseSignatureMintERC20 } from "../../../../types/eips"; +import { UpdateableNetwork } from "../../../interfaces/contract"; +import { NetworkInput } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Erc20 } from "../../erc-20"; +import { Transaction } from "../../transactions"; /** * Standard ERC20 Token functions diff --git a/packages/sdk/src/evm/core/classes/account-permissions.ts b/packages/sdk/src/evm/core/classes/internal/erc4337/account-permissions.ts similarity index 96% rename from packages/sdk/src/evm/core/classes/account-permissions.ts rename to packages/sdk/src/evm/core/classes/internal/erc4337/account-permissions.ts index 92fbe7167c1..39ec80cb27f 100644 --- a/packages/sdk/src/evm/core/classes/account-permissions.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc4337/account-permissions.ts @@ -1,8 +1,8 @@ import { BigNumber, utils } from "ethers"; -import { FEATURE_ACCOUNT_PERMISSIONS } from "../../constants/thirdweb-features"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { FEATURE_ACCOUNT_PERMISSIONS } from "../../../../constants/thirdweb-features"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IAccountCore, @@ -10,11 +10,11 @@ import type { IAccountPermissions_V1, } from "@thirdweb-dev/contracts-js"; import invariant from "tiny-invariant"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { resolveOrGenerateId } from "../../common/signature-minting"; -import { buildTransactionFunction } from "../../common/transactions"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { resolveOrGenerateId } from "../../../../common/signature-minting"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; import { AdminFlag, DEFAULT_PERMISSIONS, @@ -30,8 +30,8 @@ import { SignerPermissionsOutput, SignerPermissionsSchema, SignerWithPermissions, -} from "../../types/account"; -import { AddressZero } from "../../constants/addresses/AddressZero"; +} from "../../../../types/account"; +import { AddressZero } from "../../../../constants/addresses/AddressZero"; export class AccountPermissions implements DetectableFeature { featureName = FEATURE_ACCOUNT_PERMISSIONS.name; diff --git a/packages/sdk/src/evm/core/classes/erc-721-batch-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-batch-mintable.ts similarity index 80% rename from packages/sdk/src/evm/core/classes/erc-721-batch-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-batch-mintable.ts index fc1fb4671a0..0b607811690 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-batch-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-batch-mintable.ts @@ -1,18 +1,18 @@ import type { IMintableERC721, IMulticall } from "@thirdweb-dev/contracts-js"; import type { TokensMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/IMintableERC721"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; -import type { NFT, NFTMetadataOrUri } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { uploadOrExtractURIs } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_BATCH_MINTABLE } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import { ContractEncoder } from "./contract-encoder"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; -import { Transaction } from "./transactions"; +import type { NFT, NFTMetadataOrUri } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { uploadOrExtractURIs } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_BATCH_MINTABLE } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import { ContractEncoder } from "../../contract-encoder"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; +import { Transaction } from "../../transactions"; /** * Mint Many ERC721 NFTs at once diff --git a/packages/sdk/src/evm/core/classes/erc-721-burnable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-burnable.ts similarity index 72% rename from packages/sdk/src/evm/core/classes/erc-721-burnable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-burnable.ts index d970548c10c..6c46b5de11e 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-burnable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-burnable.ts @@ -1,8 +1,8 @@ -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_BURNABLE } from "../../constants/erc721-features"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_BURNABLE } from "../../../../constants/erc721-features"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IBurnableERC721 } from "@thirdweb-dev/contracts-js"; import { BigNumberish } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-721-claim-conditions.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-conditions.ts similarity index 81% rename from packages/sdk/src/evm/core/classes/erc-721-claim-conditions.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-conditions.ts index 614f4b8b4d8..f41e9534ee3 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-claim-conditions.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-conditions.ts @@ -1,20 +1,20 @@ -import type { NFT } from "../../../core/schema/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_CLAIM_CONDITIONS_V2 } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import type { BaseClaimConditionERC721 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import type { NFT } from "../../../../../core/schema/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_CLAIM_CONDITIONS_V2 } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import type { BaseClaimConditionERC721 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumber, BigNumberish } from "ethers"; import { TokensClaimedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/TieredDrop"; -import { CustomContractSchema } from "../../schema/contracts/custom"; -import { ContractMetadata } from "./contract-metadata"; -import { DropClaimConditions } from "./drop-claim-conditions"; -import type { Erc721 } from "./erc-721"; +import { CustomContractSchema } from "../../../../schema/contracts/custom"; +import { ContractMetadata } from "../../contract-metadata"; +import { DropClaimConditions } from "../../drop-claim-conditions"; +import type { Erc721 } from "../../erc-721"; /** * Configure and claim ERC721 NFTs diff --git a/packages/sdk/src/evm/core/classes/erc-721-claim-zora.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-zora.ts similarity index 83% rename from packages/sdk/src/evm/core/classes/erc-721-claim-zora.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-zora.ts index 490502d889c..fd85a274bcb 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-claim-zora.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claim-zora.ts @@ -4,17 +4,17 @@ import { SaleEvent, } from "@thirdweb-dev/contracts-js/dist/declarations/src/Zora_IERC721Drop"; import { BigNumber, BigNumberish } from "ethers"; -import { NFT } from "../../../core/schema/nft"; -import { toWei } from "../../common/currency/toWei"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_CLAIM_ZORA } from "../../constants/erc721-features"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; -import { Transaction } from "./transactions"; +import { NFT } from "../../../../../core/schema/nft"; +import { toWei } from "../../../../common/currency/toWei"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_CLAIM_ZORA } from "../../../../constants/erc721-features"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { TransactionResultWithId } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; +import { Transaction } from "../../transactions"; /** * Claim ERC721 NFTs from a Zora Drop diff --git a/packages/sdk/src/evm/core/classes/erc-721-claimable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claimable.ts similarity index 83% rename from packages/sdk/src/evm/core/classes/erc-721-claimable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claimable.ts index e2ae8b05959..8dafc5a59ad 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-claimable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-claimable.ts @@ -1,17 +1,17 @@ -import type { NFT } from "../../../core/schema/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_CLAIM_CUSTOM } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { ClaimOptions } from "../../types/claim-conditions/claim-conditions"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import type { NFT } from "../../../../../core/schema/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_CLAIM_CUSTOM } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { ClaimOptions } from "../../../../types/claim-conditions/claim-conditions"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IClaimableERC721 } from "@thirdweb-dev/contracts-js"; import { BigNumber, BigNumberish, CallOverrides } from "ethers"; import { TokensClaimedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/TieredDrop"; -import { calculateClaimCost } from "../../common/claim-conditions/calculateClaimCost"; -import type { Erc721 } from "./erc-721"; +import { calculateClaimCost } from "../../../../common/claim-conditions/calculateClaimCost"; +import type { Erc721 } from "../../erc-721"; /** * Configure and claim ERC721 NFTs diff --git a/packages/sdk/src/evm/core/classes/erc-721-enumerable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-enumerable.ts similarity index 81% rename from packages/sdk/src/evm/core/classes/erc-721-enumerable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-enumerable.ts index 89c79e5997a..d36fb6a1d53 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-enumerable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-enumerable.ts @@ -1,17 +1,17 @@ import type { IERC721Enumerable } from "@thirdweb-dev/contracts-js"; import { BigNumber } from "ethers"; -import type { NFT } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { FEATURE_NFT_ENUMERABLE } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { BaseERC721 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; +import type { NFT } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { FEATURE_NFT_ENUMERABLE } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { BaseERC721 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams, -} from "../../../core/schema/QueryParams"; +} from "../../../../../core/schema/QueryParams"; /** * List owned ERC721 NFTs diff --git a/packages/sdk/src/evm/core/classes/erc-721-lazy-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-lazy-mintable.ts similarity index 84% rename from packages/sdk/src/evm/core/classes/erc-721-lazy-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-lazy-mintable.ts index 033e03c547d..543ce85faab 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-lazy-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-lazy-mintable.ts @@ -1,23 +1,29 @@ -import type { NFTMetadata, NFTMetadataOrUri } from "../../../core/schema/nft"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { buildTransactionFunction } from "../../common/transactions"; +import type { + NFTMetadata, + NFTMetadataOrUri, +} from "../../../../../core/schema/nft"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { buildTransactionFunction } from "../../../../common/transactions"; import { FEATURE_NFT_LAZY_MINTABLE, FEATURE_NFT_REVEALABLE, -} from "../../constants/erc721-features"; -import type { UploadProgressEvent } from "../../types/events"; -import type { BaseDropERC721 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +} from "../../../../constants/erc721-features"; +import type { UploadProgressEvent } from "../../../../types/events"; +import type { BaseDropERC721 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; import { utils } from "ethers"; -import { getBaseUriFromBatch, uploadOrExtractURIs } from "../../common/nft"; -import type { BaseDelayedRevealERC721 } from "../../types/eips"; -import { DelayedReveal } from "./delayed-reveal"; +import { + getBaseUriFromBatch, + uploadOrExtractURIs, +} from "../../../../common/nft"; +import type { BaseDelayedRevealERC721 } from "../../../../types/eips"; +import { DelayedReveal } from "../../delayed-reveal"; import type { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/LazyMint"; -import type { Erc721 } from "./erc-721"; +import type { Erc721 } from "../../erc-721"; /** * Lazily mint and claim ERC721 NFTs diff --git a/packages/sdk/src/evm/core/classes/erc-721-loyalty-card.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-loyalty-card.ts similarity index 81% rename from packages/sdk/src/evm/core/classes/erc-721-loyalty-card.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-loyalty-card.ts index fd0651add46..a62ae94dd18 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-loyalty-card.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-loyalty-card.ts @@ -1,8 +1,8 @@ -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_LOYALTY_CARD } from "../../constants/erc721-features"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_LOYALTY_CARD } from "../../../../constants/erc721-features"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { ILoyaltyCard } from "@thirdweb-dev/contracts-js"; import { BigNumberish } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-721-metadata.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-metadata.ts similarity index 73% rename from packages/sdk/src/evm/core/classes/erc-721-metadata.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-metadata.ts index e6f0e2e090c..3c094ee9b5a 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-metadata.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-metadata.ts @@ -1,10 +1,10 @@ -import { NFTMetadataOrUri } from "../../../core/schema/nft"; -import { uploadOrExtractURI } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_UPDATABLE_METADATA } from "../../constants/erc721-features"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { NFTMetadataOrUri } from "../../../../../core/schema/nft"; +import { uploadOrExtractURI } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_UPDATABLE_METADATA } from "../../../../constants/erc721-features"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { INFTMetadata } from "@thirdweb-dev/contracts-js"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumberish } from "ethers"; diff --git a/packages/sdk/src/evm/core/classes/erc-721-mintable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-mintable.ts similarity index 81% rename from packages/sdk/src/evm/core/classes/erc-721-mintable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-mintable.ts index ba9dba936bd..4e5c90cc9e2 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-mintable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-mintable.ts @@ -1,19 +1,19 @@ -import type { NFT, NFTMetadataOrUri } from "../../../core/schema/nft"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_MINTABLE } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import type { NFT, NFTMetadataOrUri } from "../../../../../core/schema/nft"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_MINTABLE } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import type { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; import type { IMintableERC721 } from "@thirdweb-dev/contracts-js"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; -import { uploadOrExtractURI } from "../../common/nft"; +import { uploadOrExtractURI } from "../../../../common/nft"; import type { IMulticall } from "@thirdweb-dev/contracts-js"; import { TransferEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/ITokenERC721"; -import type { Erc721 } from "./erc-721"; +import type { Erc721 } from "../../erc-721"; import { Erc721BatchMintable } from "./erc-721-batch-mintable"; /** diff --git a/packages/sdk/src/evm/core/classes/erc-721-shared-metadata.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-shared-metadata.ts similarity index 89% rename from packages/sdk/src/evm/core/classes/erc-721-shared-metadata.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-shared-metadata.ts index bcbcc0e8784..82e2c3c25fd 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-shared-metadata.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-shared-metadata.ts @@ -1,12 +1,12 @@ import type { SharedMetadata } from "@thirdweb-dev/contracts-js"; import { isFileOrBuffer, type ThirdwebStorage } from "@thirdweb-dev/storage"; -import { BasicNFTInput } from "../../../core/schema/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_SHARED_METADATA } from "../../constants/erc721-features"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import { TransactionResult } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { BasicNFTInput } from "../../../../../core/schema/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_SHARED_METADATA } from "../../../../constants/erc721-features"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import { TransactionResult } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; /** * Set shared metadata for ERC721 NFTs (Open Edition) diff --git a/packages/sdk/src/evm/core/classes/erc-721-standard.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-standard.ts similarity index 89% rename from packages/sdk/src/evm/core/classes/erc-721-standard.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-standard.ts index 3cf4735e9bd..b11c6d64748 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-standard.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-standard.ts @@ -5,18 +5,18 @@ import type { } from "@thirdweb-dev/contracts-js"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumber, BigNumberish } from "ethers"; -import { QueryAllParams } from "../../../core/schema/QueryParams"; -import { NFT } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { Address } from "../../schema/shared/Address"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { BaseERC721 } from "../../types/eips"; -import { UpdateableNetwork } from "../interfaces/contract"; -import { NetworkInput } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Erc721 } from "./erc-721"; -import { Transaction } from "./transactions"; +import { QueryAllParams } from "../../../../../core/schema/QueryParams"; +import { NFT } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { Address } from "../../../../schema/shared/Address"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { BaseERC721 } from "../../../../types/eips"; +import { UpdateableNetwork } from "../../../interfaces/contract"; +import { NetworkInput } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Erc721 } from "../../erc-721"; +import { Transaction } from "../../transactions"; /** * Standard ERC721 NFT functions diff --git a/packages/sdk/src/evm/core/classes/erc-721-supply.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-supply.ts similarity index 86% rename from packages/sdk/src/evm/core/classes/erc-721-supply.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-supply.ts index aed10a9dff4..ac2fd649a1e 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-supply.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-supply.ts @@ -5,16 +5,16 @@ import type { OpenEditionERC721, } from "@thirdweb-dev/contracts-js"; import { BigNumber, constants } from "ethers"; -import type { QueryAllParams } from "../../../core/schema/QueryParams"; -import { DEFAULT_QUERY_ALL_COUNT } from "../../../core/schema/QueryParams"; -import type { NFT } from "../../../core/schema/nft"; -import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; -import { hasFunction } from "../../common/feature-detection/hasFunction"; -import { FEATURE_NFT_SUPPLY } from "../../constants/erc721-features"; -import type { BaseERC721 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; +import type { QueryAllParams } from "../../../../../core/schema/QueryParams"; +import { DEFAULT_QUERY_ALL_COUNT } from "../../../../../core/schema/QueryParams"; +import type { NFT } from "../../../../../core/schema/nft"; +import { detectContractFeature } from "../../../../common/feature-detection/detectContractFeature"; +import { hasFunction } from "../../../../common/feature-detection/hasFunction"; +import { FEATURE_NFT_SUPPLY } from "../../../../constants/erc721-features"; +import type { BaseERC721 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; import { Erc721Enumerable } from "./erc-721-enumerable"; import { Erc721AQueryable } from "./erc-721a-queryable"; diff --git a/packages/sdk/src/evm/core/classes/erc-721-tiered-drop.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-tiered-drop.ts similarity index 92% rename from packages/sdk/src/evm/core/classes/erc-721-tiered-drop.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721-tiered-drop.ts index 62822e22869..7d0a31395b5 100644 --- a/packages/sdk/src/evm/core/classes/erc-721-tiered-drop.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721-tiered-drop.ts @@ -8,26 +8,32 @@ import type { NFT, NFTMetadata, NFTMetadataOrUri, -} from "../../../core/schema/nft"; -import { CommonNFTInput, NFTMetadataInput } from "../../../core/schema/nft"; -import { normalizePriceValue } from "../../common/currency/normalizePriceValue"; -import { setErc20Allowance } from "../../common/currency/setErc20Allowance"; -import { getBaseUriFromBatch, uploadOrExtractURIs } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { FEATURE_NFT_TIERED_DROP } from "../../constants/erc721-features"; +} from "../../../../../core/schema/nft"; +import { + CommonNFTInput, + NFTMetadataInput, +} from "../../../../../core/schema/nft"; +import { normalizePriceValue } from "../../../../common/currency/normalizePriceValue"; +import { setErc20Allowance } from "../../../../common/currency/setErc20Allowance"; +import { + getBaseUriFromBatch, + uploadOrExtractURIs, +} from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { FEATURE_NFT_TIERED_DROP } from "../../../../constants/erc721-features"; import { GenericRequest, TieredDropPayloadInput, TieredDropPayloadOutput, TieredDropPayloadSchema, TieredDropPayloadWithSignature, -} from "../../schema/contracts/tiered-drop"; -import type { UploadProgressEvent } from "../../types/events"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { TransactionResultWithId } from "../types"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; -import { Transaction } from "./transactions"; +} from "../../../../schema/contracts/tiered-drop"; +import type { UploadProgressEvent } from "../../../../types/events"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { TransactionResultWithId } from "../../../types"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; +import { Transaction } from "../../transactions"; export class Erc721TieredDrop implements DetectableFeature { featureName = FEATURE_NFT_TIERED_DROP.name; diff --git a/packages/sdk/src/evm/core/classes/erc-721a-queryable.ts b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721a-queryable.ts similarity index 80% rename from packages/sdk/src/evm/core/classes/erc-721a-queryable.ts rename to packages/sdk/src/evm/core/classes/internal/erc721/erc-721a-queryable.ts index 80cb997e386..62f075aba98 100644 --- a/packages/sdk/src/evm/core/classes/erc-721a-queryable.ts +++ b/packages/sdk/src/evm/core/classes/internal/erc721/erc-721a-queryable.ts @@ -1,17 +1,17 @@ import type { IERC721AQueryableUpgradeable } from "@thirdweb-dev/contracts-js"; import { BigNumber } from "ethers"; -import type { NFT } from "../../../core/schema/nft"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { FEATURE_NFT_QUERYABLE } from "../../constants/erc721-features"; -import type { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { BaseERC721 } from "../../types/eips"; -import { DetectableFeature } from "../interfaces/DetectableFeature"; -import type { ContractWrapper } from "./contract-wrapper"; -import type { Erc721 } from "./erc-721"; +import type { NFT } from "../../../../../core/schema/nft"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; +import { FEATURE_NFT_QUERYABLE } from "../../../../constants/erc721-features"; +import type { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import type { BaseERC721 } from "../../../../types/eips"; +import { DetectableFeature } from "../../../interfaces/DetectableFeature"; +import type { ContractWrapper } from "../contract-wrapper"; +import type { Erc721 } from "../../erc-721"; import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams, -} from "../../../core/schema/QueryParams"; +} from "../../../../../core/schema/QueryParams"; /** * List owned ERC721 NFTs diff --git a/packages/sdk/src/evm/core/classes/factory.ts b/packages/sdk/src/evm/core/classes/internal/factory.ts similarity index 94% rename from packages/sdk/src/evm/core/classes/factory.ts rename to packages/sdk/src/evm/core/classes/internal/factory.ts index d0a84c355dd..ab06a371426 100644 --- a/packages/sdk/src/evm/core/classes/factory.ts +++ b/packages/sdk/src/evm/core/classes/internal/factory.ts @@ -12,10 +12,10 @@ import { import EventEmitter from "eventemitter3"; import invariant from "tiny-invariant"; import { z } from "zod"; -import { getDeployArguments } from "../../common/deploy"; -import { buildTransactionFunction } from "../../common/transactions"; -import { getApprovedImplementation } from "../../constants/addresses/getApprovedImplementation"; -import { getDefaultTrustedForwarders } from "../../constants/addresses/getDefaultTrustedForwarders"; +import { getDeployArguments } from "../../../common/deploy"; +import { buildTransactionFunction } from "../../../common/transactions"; +import { getApprovedImplementation } from "../../../constants/addresses/getApprovedImplementation"; +import { getDefaultTrustedForwarders } from "../../../constants/addresses/getDefaultTrustedForwarders"; import { DeploySchemaForPrebuiltContractType, EditionDropInitializer, @@ -34,15 +34,15 @@ import { TokenInitializer, VoteInitializer, getContractName, -} from "../../contracts"; -import { SDKOptions } from "../../schema/sdk-options"; -import { Address } from "../../schema/shared/Address"; -import type { DeployOptions } from "../../types/deploy/deploy-options"; -import type { DeployEvents } from "../../types/deploy/deploy-events"; -import { NetworkInput } from "../types"; +} from "../../../contracts"; +import { SDKOptions } from "../../../schema/sdk-options"; +import { Address } from "../../../schema/shared/Address"; +import type { DeployOptions } from "../../../types/deploy/deploy-options"; +import type { DeployEvents } from "../../../types/deploy/deploy-events"; +import { NetworkInput } from "../../types"; import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; -import { overrideFeeRecipient } from "../../common/override-fee-recipient"; +import { Transaction } from "../transactions"; +import { overrideFeeRecipient } from "../../../common/override-fee-recipient"; /** * @internal diff --git a/packages/sdk/src/evm/core/classes/marketplace-auction.ts b/packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-auction.ts similarity index 93% rename from packages/sdk/src/evm/core/classes/marketplace-auction.ts rename to packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-auction.ts index 30c1b8a3e69..9fca37f13cf 100644 --- a/packages/sdk/src/evm/core/classes/marketplace-auction.ts +++ b/packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-auction.ts @@ -6,36 +6,36 @@ import { import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { BigNumber, BigNumberish, constants, utils } from "ethers"; import invariant from "tiny-invariant"; -import { cleanCurrencyAddress } from "../../common/currency/cleanCurrencyAddress"; -import { fetchCurrencyMetadata } from "../../common/currency/fetchCurrencyMetadata"; -import { fetchCurrencyValue } from "../../common/currency/fetchCurrencyValue"; -import { normalizePriceValue } from "../../common/currency/normalizePriceValue"; -import { setErc20Allowance } from "../../common/currency/setErc20Allowance"; -import { resolveAddress } from "../../common/ens/resolveAddress"; +import { cleanCurrencyAddress } from "../../../../common/currency/cleanCurrencyAddress"; +import { fetchCurrencyMetadata } from "../../../../common/currency/fetchCurrencyMetadata"; +import { fetchCurrencyValue } from "../../../../common/currency/fetchCurrencyValue"; +import { normalizePriceValue } from "../../../../common/currency/normalizePriceValue"; +import { setErc20Allowance } from "../../../../common/currency/setErc20Allowance"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; import { AuctionAlreadyStartedError, AuctionHasNotEndedError, ListingNotFoundError, WrongListingTypeError, -} from "../../common/error"; +} from "../../../../common/error"; import { handleTokenApproval, isWinningBid, mapOffer, validateNewListingParam, -} from "../../common/marketplace"; -import { fetchTokenMetadataForContract } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; -import { CurrencyValue, Price } from "../../types/currency"; -import { TransactionResultWithId } from "../types"; -import { ContractEncoder } from "./contract-encoder"; -import { ContractEvents } from "./contract-events"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; -import { ListingType } from "../../enums/marketplace/ListingType"; -import { AuctionListing } from "../../types/marketplace/AuctionListing"; -import { Offer } from "../../types/marketplace/Offer"; -import { NewAuctionListing } from "../../types/marketplace/NewAuctionListing"; +} from "../../../../common/marketplace"; +import { fetchTokenMetadataForContract } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; +import { CurrencyValue, Price } from "../../../../types/currency"; +import { TransactionResultWithId } from "../../../types"; +import { ContractEncoder } from "../../contract-encoder"; +import { ContractEvents } from "../../contract-events"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; +import { ListingType } from "../../../../enums/marketplace/ListingType"; +import { AuctionListing } from "../../../../types/marketplace/AuctionListing"; +import { Offer } from "../../../../types/marketplace/Offer"; +import { NewAuctionListing } from "../../../../types/marketplace/NewAuctionListing"; /** * Handles auction listings diff --git a/packages/sdk/src/evm/core/classes/marketplace-direct.ts b/packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-direct.ts similarity index 93% rename from packages/sdk/src/evm/core/classes/marketplace-direct.ts rename to packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-direct.ts index 677e3a6d0d8..82e6c537513 100644 --- a/packages/sdk/src/evm/core/classes/marketplace-direct.ts +++ b/packages/sdk/src/evm/core/classes/internal/marketplace/marketplace-direct.ts @@ -15,37 +15,37 @@ import { type BigNumberish, } from "ethers"; import invariant from "tiny-invariant"; -import { cleanCurrencyAddress } from "../../common/currency/cleanCurrencyAddress"; -import { fetchCurrencyValue } from "../../common/currency/fetchCurrencyValue"; -import { isNativeToken } from "../../common/currency/isNativeToken"; -import { normalizePriceValue } from "../../common/currency/normalizePriceValue"; -import { setErc20Allowance } from "../../common/currency/setErc20Allowance"; -import { resolveAddress } from "../../common/ens/resolveAddress"; +import { cleanCurrencyAddress } from "../../../../common/currency/cleanCurrencyAddress"; +import { fetchCurrencyValue } from "../../../../common/currency/fetchCurrencyValue"; +import { isNativeToken } from "../../../../common/currency/isNativeToken"; +import { normalizePriceValue } from "../../../../common/currency/normalizePriceValue"; +import { setErc20Allowance } from "../../../../common/currency/setErc20Allowance"; +import { resolveAddress } from "../../../../common/ens/resolveAddress"; import { ListingNotFoundError, WrongListingTypeError, -} from "../../common/error"; +} from "../../../../common/error"; import { handleTokenApproval, isTokenApprovedForTransfer, mapOffer, validateNewListingParam, -} from "../../common/marketplace"; -import { fetchTokenMetadataForContract } from "../../common/nft"; -import { buildTransactionFunction } from "../../common/transactions"; +} from "../../../../common/marketplace"; +import { fetchTokenMetadataForContract } from "../../../../common/nft"; +import { buildTransactionFunction } from "../../../../common/transactions"; import { InterfaceId_IERC1155, InterfaceId_IERC721, -} from "../../constants/contract"; -import { ListingType } from "../../enums/marketplace/ListingType"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import { Price } from "../../types/currency"; -import { TransactionResultWithId } from "../types"; -import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; -import { DirectListing } from "../../types/marketplace/DirectListing"; -import { Offer } from "../../types/marketplace/Offer"; -import { NewDirectListing } from "../../types/marketplace/NewDirectListing"; +} from "../../../../constants/contract"; +import { ListingType } from "../../../../enums/marketplace/ListingType"; +import { AddressOrEns } from "../../../../schema/shared/AddressOrEnsSchema"; +import { Price } from "../../../../types/currency"; +import { TransactionResultWithId } from "../../../types"; +import { ContractWrapper } from "../contract-wrapper"; +import { Transaction } from "../../transactions"; +import { DirectListing } from "../../../../types/marketplace/DirectListing"; +import { Offer } from "../../../../types/marketplace/Offer"; +import { NewDirectListing } from "../../../../types/marketplace/NewDirectListing"; /** * Handles direct listings diff --git a/packages/sdk/src/evm/core/classes/registry.ts b/packages/sdk/src/evm/core/classes/internal/registry.ts similarity index 86% rename from packages/sdk/src/evm/core/classes/registry.ts rename to packages/sdk/src/evm/core/classes/internal/registry.ts index e3c809034f1..67d8e4889a5 100644 --- a/packages/sdk/src/evm/core/classes/registry.ts +++ b/packages/sdk/src/evm/core/classes/internal/registry.ts @@ -1,14 +1,14 @@ import type { TWRegistry } from "@thirdweb-dev/contracts-js"; import type { ThirdwebStorage } from "@thirdweb-dev/storage"; import { ContractInterface, constants, utils } from "ethers"; -import { resolveAddress } from "../../common/ens/resolveAddress"; -import { buildTransactionFunction } from "../../common/transactions"; -import { SDKOptions } from "../../schema/sdk-options"; -import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; -import type { NetworkInput, TransactionResult } from "../types"; -import { ContractEncoder } from "./contract-encoder"; +import { resolveAddress } from "../../../common/ens/resolveAddress"; +import { buildTransactionFunction } from "../../../common/transactions"; +import { SDKOptions } from "../../../schema/sdk-options"; +import { AddressOrEns } from "../../../schema/shared/AddressOrEnsSchema"; +import type { NetworkInput, TransactionResult } from "../../types"; +import { ContractEncoder } from "../contract-encoder"; import { ContractWrapper } from "./contract-wrapper"; -import { Transaction } from "./transactions"; +import { Transaction } from "../transactions"; /** * @internal diff --git a/packages/sdk/src/evm/core/classes/rpc-connection-handler.ts b/packages/sdk/src/evm/core/classes/internal/rpc-connection-handler.ts similarity index 90% rename from packages/sdk/src/evm/core/classes/rpc-connection-handler.ts rename to packages/sdk/src/evm/core/classes/internal/rpc-connection-handler.ts index d265908db77..dba3bfb3d3f 100644 --- a/packages/sdk/src/evm/core/classes/rpc-connection-handler.ts +++ b/packages/sdk/src/evm/core/classes/internal/rpc-connection-handler.ts @@ -1,11 +1,11 @@ -import { isSigner } from "../../functions/getSignerAndProvider"; -import { getSignerAndProvider } from "../../constants/urls"; +import { isSigner } from "../../../functions/getSignerAndProvider"; +import { getSignerAndProvider } from "../../../constants/urls"; import { SDKOptions, SDKOptionsOutput, SDKOptionsSchema, -} from "../../schema/sdk-options"; -import { NetworkInput } from "../types"; +} from "../../../schema/sdk-options"; +import { NetworkInput } from "../../types"; import type { Signer, providers } from "ethers"; import EventEmitter from "eventemitter3"; diff --git a/packages/sdk/src/evm/core/classes/marketplacev3-direct-listings.ts b/packages/sdk/src/evm/core/classes/marketplacev3-direct-listings.ts index 0a14ce77184..442ae13a022 100644 --- a/packages/sdk/src/evm/core/classes/marketplacev3-direct-listings.ts +++ b/packages/sdk/src/evm/core/classes/marketplacev3-direct-listings.ts @@ -42,7 +42,7 @@ import { TransactionResultWithId } from "../types"; import { ContractEncoder } from "./contract-encoder"; import { ContractEvents } from "./contract-events"; import { ContractInterceptor } from "./contract-interceptor"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { GasCostEstimator } from "./gas-cost-estimator"; import { Transaction } from "./transactions"; import { Status } from "../../enums/marketplace/Status"; diff --git a/packages/sdk/src/evm/core/classes/marketplacev3-english-auction.ts b/packages/sdk/src/evm/core/classes/marketplacev3-english-auction.ts index 9457749670d..1bc43c49b64 100644 --- a/packages/sdk/src/evm/core/classes/marketplacev3-english-auction.ts +++ b/packages/sdk/src/evm/core/classes/marketplacev3-english-auction.ts @@ -35,7 +35,7 @@ import { TransactionResultWithId } from "../types"; import { ContractEncoder } from "./contract-encoder"; import { ContractEvents } from "./contract-events"; import { ContractInterceptor } from "./contract-interceptor"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { GasCostEstimator } from "./gas-cost-estimator"; import { Transaction } from "./transactions"; diff --git a/packages/sdk/src/evm/core/classes/marketplacev3-offers.ts b/packages/sdk/src/evm/core/classes/marketplacev3-offers.ts index f81139b40bc..37bbc8097c1 100644 --- a/packages/sdk/src/evm/core/classes/marketplacev3-offers.ts +++ b/packages/sdk/src/evm/core/classes/marketplacev3-offers.ts @@ -25,7 +25,7 @@ import { TransactionResultWithId } from "../types"; import { ContractEncoder } from "./contract-encoder"; import { ContractEvents } from "./contract-events"; import { ContractInterceptor } from "./contract-interceptor"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { GasCostEstimator } from "./gas-cost-estimator"; import { Transaction } from "./transactions"; diff --git a/packages/sdk/src/evm/core/classes/multichain-registry.ts b/packages/sdk/src/evm/core/classes/multichain-registry.ts index 152252cb4f8..eabc2520e77 100644 --- a/packages/sdk/src/evm/core/classes/multichain-registry.ts +++ b/packages/sdk/src/evm/core/classes/multichain-registry.ts @@ -19,7 +19,7 @@ import type { } from "../../types/registry"; import type { NetworkInput, TransactionResult } from "../types"; import { ContractEncoder } from "./contract-encoder"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Transaction } from "./transactions"; /** @@ -105,7 +105,18 @@ export class MultichainRegistry { async ( contract: AddContractInput, ): Promise> => { - return await this.addContracts.prepare([contract]); + const deployerAddress = await this.registryRouter.getSignerAddress(); + + return Transaction.fromContractWrapper({ + contractWrapper: this.registryLogic, + method: "add", + args: [ + deployerAddress, + contract.address, + contract.chainId, + contract.metadataURI || "", + ], + }); }, ); @@ -139,7 +150,17 @@ export class MultichainRegistry { async ( contract: ContractInput, ): Promise> => { - return await this.removeContracts.prepare([contract]); + const deployerAddress = await this.registryRouter.getSignerAddress(); + + return Transaction.fromContractWrapper({ + contractWrapper: this.registryLogic, + method: "remove", + args: [ + deployerAddress, + await resolveAddress(contract.address), + contract.chainId, + ], + }); }, ); diff --git a/packages/sdk/src/evm/core/classes/pack-vrf.ts b/packages/sdk/src/evm/core/classes/pack-vrf.ts index faa27f3d7d9..6eb5ca7b57d 100644 --- a/packages/sdk/src/evm/core/classes/pack-vrf.ts +++ b/packages/sdk/src/evm/core/classes/pack-vrf.ts @@ -22,7 +22,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { UpdateableNetwork } from "../interfaces/contract"; import type { NetworkInput, TransactionResultWithId } from "../types"; import { ContractEvents } from "./contract-events"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; import { Erc20 } from "./erc-20"; import { Transaction } from "./transactions"; diff --git a/packages/sdk/src/evm/core/classes/transactions.ts b/packages/sdk/src/evm/core/classes/transactions.ts index 69e8a64d0e5..d6fed0e0c69 100644 --- a/packages/sdk/src/evm/core/classes/transactions.ts +++ b/packages/sdk/src/evm/core/classes/transactions.ts @@ -48,7 +48,7 @@ import { BytesLike } from "ethers"; import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES"; import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId"; import { getCompositeABI } from "../../common/plugin/getCompositePluginABI"; -import { ContractWrapper } from "./contract-wrapper"; +import { ContractWrapper } from "./internal/contract-wrapper"; abstract class TransactionContext { protected args: any[]; @@ -875,7 +875,7 @@ export class DeployTransaction extends TransactionContext { } } -export async function defaultGaslessSendFunction( +async function defaultGaslessSendFunction( transaction: GaslessTransaction, signer: Signer, provider: providers.Provider, @@ -903,6 +903,9 @@ export async function defaultGaslessSendFunction( ); } +/** + * @internal + */ export async function engineSendFunction( transaction: GaslessTransaction, signer: Signer, @@ -955,7 +958,7 @@ export async function engineSendFunction( } } -export async function biconomySendFunction( +async function biconomySendFunction( transaction: GaslessTransaction, signer: Signer, provider: providers.Provider, @@ -984,7 +987,7 @@ export async function biconomySendFunction( ); } -export async function defenderSendFunction( +async function defenderSendFunction( transaction: GaslessTransaction, signer: Signer, provider: providers.Provider, diff --git a/packages/sdk/src/evm/core/sdk.ts b/packages/sdk/src/evm/core/sdk.ts index e23910b99ef..1a87c130b3e 100644 --- a/packages/sdk/src/evm/core/sdk.ts +++ b/packages/sdk/src/evm/core/sdk.ts @@ -16,7 +16,7 @@ import { AddressOrEns } from "../schema/shared/AddressOrEnsSchema"; import { SDKOptions } from "../schema/sdk-options"; import { ContractPublisher } from "./classes/contract-publisher"; import { MultichainRegistry } from "./classes/multichain-registry"; -import { RPCConnectionHandler } from "./classes/rpc-connection-handler"; +import { RPCConnectionHandler } from "./classes/internal/rpc-connection-handler"; import type { ContractForPrebuiltContractType, ContractType, @@ -78,8 +78,8 @@ import { Address } from "../schema/shared/Address"; import type { CurrencyValue } from "../types/currency"; import type { ContractWithMetadata } from "../types/registry"; import { DeploySchemaForPrebuiltContractType } from "../contracts"; -import { ContractFactory } from "./classes/factory"; -import { ContractRegistry } from "./classes/registry"; +import { ContractFactory } from "./classes/internal/factory"; +import { ContractRegistry } from "./classes/internal/registry"; import { DeployTransaction, Transaction } from "./classes/transactions"; import { type BytesLike, @@ -1054,6 +1054,7 @@ export class ContractDeployer extends RPCConnectionHandler { THIRDWEB_DEPLOYER, "LoyaltyCard", deployArgs, + "latest", options, ); }, @@ -1111,6 +1112,7 @@ export class ContractDeployer extends RPCConnectionHandler { THIRDWEB_DEPLOYER, "OpenEditionERC721", deployArgs, + "latest", options, ); }, @@ -1472,6 +1474,7 @@ export class ContractDeployer extends RPCConnectionHandler { THIRDWEB_DEPLOYER, "AirdropERC20", deployArgs, + "latest", options, ); }, @@ -1503,6 +1506,7 @@ export class ContractDeployer extends RPCConnectionHandler { THIRDWEB_DEPLOYER, "AirdropERC721", deployArgs, + "latest", options, ); }, @@ -1534,15 +1538,16 @@ export class ContractDeployer extends RPCConnectionHandler { THIRDWEB_DEPLOYER, "AirdropERC1155", deployArgs, + "latest", options, ); }, ); /** - * Deploys a new contract + * Deploys a new prebuilt contract * - * @internal + * @public * @param contractType - the type of contract to deploy * @param contractMetadata - the metadata to deploy the contract with * @param version - the version of the contract to deploy @@ -1647,13 +1652,14 @@ export class ContractDeployer extends RPCConnectionHandler { * @param constructorParams - the constructor params to pass to the contract * * @deprecated use deployPublishedContract instead + * @internal */ deployReleasedContract = /* @__PURE__ */ buildDeployTransactionFunction( async ( publisherAddress: AddressOrEns, contractName: string, constructorParams: any[], - version = "latest", + version: string = "latest", options?: DeployOptions, ): Promise => { const publishedContract = await this.fetchPublishedContractFromPolygon( @@ -1824,6 +1830,7 @@ export class ContractDeployer extends RPCConnectionHandler { * @param deployMetadata - the deploy metadata * @param signer - the signer to use * @param options - the deploy options + * @internal */ deployViaAutoFactory = /* @__PURE__ */ buildDeployTransactionFunction( async ( @@ -1887,6 +1894,7 @@ export class ContractDeployer extends RPCConnectionHandler { `Error deploying contract at ${tx.predictedAddress}`, (e as any)?.message, ); + throw e; } } @@ -1923,6 +1931,7 @@ export class ContractDeployer extends RPCConnectionHandler { * @param deployMetadata - the deploy metadata * @param signer - the signer to use * @param chainId - the chain id to deploy to + * @internal */ deployViaCustomFactory = /* @__PURE__ */ buildDeployTransactionFunction( async ( @@ -2054,6 +2063,9 @@ export class ContractDeployer extends RPCConnectionHandler { })); } + /** + * @internal + */ public override updateSignerOrProvider(network: NetworkInput) { super.updateSignerOrProvider(network); this.updateContractSignerOrProvider(); @@ -2228,7 +2240,7 @@ export class ContractDeployer extends RPCConnectionHandler { ); /** - * @internal + * @public * @param abi - the abi of the contract * @param bytecode - the bytecode of the contract * @param constructorParams - the constructor params to pass to the contract diff --git a/packages/sdk/src/evm/core/wallet/user-wallet.ts b/packages/sdk/src/evm/core/wallet/user-wallet.ts index e06489dbd44..bc10efea90a 100644 --- a/packages/sdk/src/evm/core/wallet/user-wallet.ts +++ b/packages/sdk/src/evm/core/wallet/user-wallet.ts @@ -26,8 +26,8 @@ import { SDKOptions } from "../../schema/sdk-options"; import { Address } from "../../schema/shared/Address"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; import type { Amount, CurrencyValue } from "../../types/currency"; -import { ContractWrapper } from "../classes/contract-wrapper"; -import { RPCConnectionHandler } from "../classes/rpc-connection-handler"; +import { ContractWrapper } from "../classes/internal/contract-wrapper"; +import { RPCConnectionHandler } from "../classes/internal/rpc-connection-handler"; import { NetworkInput, TransactionResult } from "../types"; import { getDefaultGasOverrides } from "../../common/gas-price"; /** diff --git a/packages/sdk/src/evm/index.ts b/packages/sdk/src/evm/index.ts index 2f4b6b2372f..37ad2a42a07 100644 --- a/packages/sdk/src/evm/index.ts +++ b/packages/sdk/src/evm/index.ts @@ -42,41 +42,11 @@ export * from "./core/classes/contract-sales"; export * from "./core/classes/delayed-reveal"; export * from "./core/classes/drop-claim-conditions"; export * from "./core/classes/drop-erc1155-claim-conditions"; -export * from "./core/classes/drop-erc1155-history"; -export * from "./core/classes/erc-20-batch-mintable"; -export * from "./core/classes/erc-20-burnable"; -export * from "./core/classes/erc-20-claim-conditions"; -export * from "./core/classes/erc-20-droppable"; -export * from "./core/classes/erc-20-mintable"; -export * from "./core/classes/erc-20-signature-mintable"; export * from "./core/classes/erc-20"; -export * from "./core/classes/erc-20-history"; -export * from "./core/classes/erc-20-standard"; -export * from "./core/classes/erc-721-batch-mintable"; -export * from "./core/classes/erc-721-claim-conditions"; -export * from "./core/classes/erc-721-claimable"; -export * from "./core/classes/erc-721-lazy-mintable"; -export * from "./core/classes/erc-721-mintable"; -export * from "./core/classes/erc-721-supply"; -export * from "./core/classes/erc-721-enumerable"; -export * from "./core/classes/erc-721-tiered-drop"; export * from "./core/classes/erc-721"; -export * from "./core/classes/erc-721-with-quantity-signature-mintable"; -export * from "./core/classes/erc-721-burnable"; -export * from "./core/classes/erc-721-standard"; -export * from "./core/classes/erc-1155-batch-mintable"; -export * from "./core/classes/erc-1155-burnable"; -export * from "./core/classes/erc-1155-enumerable"; -export * from "./core/classes/erc-1155-lazy-mintable"; -export * from "./core/classes/erc-1155-mintable"; export * from "./core/classes/erc-1155"; -export * from "./core/classes/erc-1155-signature-mintable"; -export * from "./core/classes/erc-1155-standard"; -export * from "./core/classes/marketplace-direct"; -export * from "./core/classes/marketplace-auction"; -export * from "./core/classes/marketplacev3-direct-listings"; -export * from "./core/classes/marketplacev3-english-auction"; -export * from "./core/classes/marketplacev3-offers"; +export * from "./core/classes/account"; +export * from "./core/classes/account-factory"; export * from "./core/classes/gas-cost-estimator"; export * from "./core/classes/delayed-reveal"; export * from "./core/classes/contract-events"; @@ -86,8 +56,14 @@ export * from "./core/classes/contract-published-metadata"; export * from "./core/classes/contract-owner"; export * from "./core/classes/transactions"; export * from "./core/classes/contract-appuri"; -export * from "./core/classes/account"; -export * from "./core/classes/account-factory"; +export * from "./core/classes/marketplacev3-direct-listings"; +export * from "./core/classes/marketplacev3-english-auction"; +export * from "./core/classes/marketplacev3-offers"; +export * from "./core/classes/extension-manager"; +export * from "./core/classes/airdrop-erc20"; +export * from "./core/classes/airdrop-erc721"; +export * from "./core/classes/airdrop-erc1155"; +export * from "./core/classes/contract-verifier"; export * from "./core/wallet/user-wallet"; export * from "./core/sdk"; //#endregion @r/packages/sdk/src/evm/core diff --git a/packages/sdk/src/evm/integrations/thirdweb-checkout.ts b/packages/sdk/src/evm/integrations/thirdweb-checkout.ts index 5dce29b3390..1fef74a1935 100644 --- a/packages/sdk/src/evm/integrations/thirdweb-checkout.ts +++ b/packages/sdk/src/evm/integrations/thirdweb-checkout.ts @@ -1,6 +1,6 @@ import { SignatureDrop } from "@thirdweb-dev/contracts-js/dist/declarations/src/SignatureDrop"; import { ChainId } from "../constants/chains/ChainId"; -import { ContractWrapper } from "../core/classes/contract-wrapper"; +import { ContractWrapper } from "../core/classes/internal/contract-wrapper"; import { SignedPayload721WithQuantitySignature } from "../schema/contracts/common/signature"; import { PrebuiltEditionDrop, PrebuiltNFTDrop } from "../types/eips"; import invariant from "tiny-invariant"; diff --git a/packages/sdk/src/evm/lib/static-batch-rpc.ts b/packages/sdk/src/evm/lib/static-batch-rpc.ts index 2afecd6d111..17ba4b2b914 100644 --- a/packages/sdk/src/evm/lib/static-batch-rpc.ts +++ b/packages/sdk/src/evm/lib/static-batch-rpc.ts @@ -10,7 +10,10 @@ const DEFAULT_BATCH_OPTIONS = { export type BatchOptions = Partial; -// mostly copied from ethers.js directly but make it a StaticJsonRpcProvider +/** + * mostly copied from ethers.js directly but make it a StaticJsonRpcProvider + * @internal + */ export class StaticJsonRpcBatchProvider extends providers.StaticJsonRpcProvider { private _timeLimitMs: number; private _sizeLimit: number; diff --git a/packages/sdk/src/evm/types/transactions.ts b/packages/sdk/src/evm/types/transactions.ts index 6e7ef927ee0..89b6a698d91 100644 --- a/packages/sdk/src/evm/types/transactions.ts +++ b/packages/sdk/src/evm/types/transactions.ts @@ -1,4 +1,4 @@ -import { ContractWrapper } from "../core/classes/contract-wrapper"; +import { ContractWrapper } from "../core/classes/internal/contract-wrapper"; import { TransactionResult } from "../core/types"; import { SDKOptionsOutput } from "../schema/sdk-options"; import { ThirdwebStorage } from "@thirdweb-dev/storage"; diff --git a/packages/sdk/src/evm/zksync/constants/addresses.ts b/packages/sdk/src/evm/zksync/constants/addresses.ts index 360f109a654..16f647d7326 100644 --- a/packages/sdk/src/evm/zksync/constants/addresses.ts +++ b/packages/sdk/src/evm/zksync/constants/addresses.ts @@ -14,12 +14,12 @@ export const CONTRACT_ADDRESSES: Record< } > = { [280]: { - openzeppelinForwarder: "0x12A305cc7168fa3b7B172fE53c57b9a22716F667", + openzeppelinForwarder: AddressZero, openzeppelinForwarderEOA: AddressZero, biconomyForwarder: AddressZero, }, [324]: { - openzeppelinForwarder: "0x4e0C3577335961Ff800FFDA24981EB2F38D94483", + openzeppelinForwarder: AddressZero, openzeppelinForwarderEOA: AddressZero, biconomyForwarder: AddressZero, }, @@ -92,18 +92,10 @@ export function getImplementation( * @returns the array of trusted forwarders for the given chain id * @internal */ +/* eslint-disable @typescript-eslint/no-unused-vars */ export function zkGetDefaultTrustedForwarders( chainId: number, contractName?: string, ): string[] { - const biconomyForwarder = - CONTRACT_ADDRESSES[chainId]?.biconomyForwarder || AddressZero; - const openzeppelinForwarder = - CONTRACT_ADDRESSES[chainId]?.openzeppelinForwarder || AddressZero; - - return contractName && contractName === "Pack" - ? [] - : [openzeppelinForwarder, biconomyForwarder].filter( - (a) => a !== AddressZero, - ); + return []; } diff --git a/packages/sdk/src/evm/zksync/zksync-deploy-utils.ts b/packages/sdk/src/evm/zksync/zksync-deploy-utils.ts index 0556b49ce0d..f55283d475d 100644 --- a/packages/sdk/src/evm/zksync/zksync-deploy-utils.ts +++ b/packages/sdk/src/evm/zksync/zksync-deploy-utils.ts @@ -160,7 +160,7 @@ async function registerContractOnMultiChainRegistry( openzeppelin: { relayerUrl: "https://api.defender.openzeppelin.com/autotasks/dad61716-3624-46c9-874f-0e73f15f04d5/runs/webhook/7d6a1834-dd33-4b7b-8af4-b6b4719a0b97/FdHMqyF3p6MGHw6K2nkLsv", - relayerForwarderAddress: "0xEbc1977d1aC2fe1F6DAaF584E2957F7c436fcdEF", + relayerForwarderAddress: "0x409d530a6961297ece29121dbee2c917c3398659", }, experimentalChainlessSupport: true, }, diff --git a/packages/sdk/test/evm/airdrop-erc1155.test.ts b/packages/sdk/test/evm/airdrop-erc1155.test.ts index bd7558ea912..fa406b72777 100644 --- a/packages/sdk/test/evm/airdrop-erc1155.test.ts +++ b/packages/sdk/test/evm/airdrop-erc1155.test.ts @@ -46,7 +46,7 @@ describe("Airdrop ERC1155", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; await mockPublishAirdrop(); airdropContract = await sdk.getContract( await sdk.deployer.deployAirdropERC1155({ diff --git a/packages/sdk/test/evm/airdrop-erc20.test.ts b/packages/sdk/test/evm/airdrop-erc20.test.ts index 96588c9ee6a..b518585973c 100644 --- a/packages/sdk/test/evm/airdrop-erc20.test.ts +++ b/packages/sdk/test/evm/airdrop-erc20.test.ts @@ -48,7 +48,7 @@ describe("Airdrop ERC20", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; await mockPublishAirdrop(); airdropContract = await sdk.getContract( await sdk.deployer.deployAirdropERC20({ diff --git a/packages/sdk/test/evm/airdrop-erc721.test.ts b/packages/sdk/test/evm/airdrop-erc721.test.ts index 7e4a33c4f6b..fedb37af72b 100644 --- a/packages/sdk/test/evm/airdrop-erc721.test.ts +++ b/packages/sdk/test/evm/airdrop-erc721.test.ts @@ -46,7 +46,7 @@ describe("Airdrop ERC721", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; await mockPublishAirdrop(); airdropContract = await sdk.getContract( await sdk.deployer.deployAirdropERC721({ diff --git a/packages/sdk/test/evm/any-evm-keyless.test.ts b/packages/sdk/test/evm/any-evm-keyless.test.ts index ff06199b2d8..7a54111a068 100644 --- a/packages/sdk/test/evm/any-evm-keyless.test.ts +++ b/packages/sdk/test/evm/any-evm-keyless.test.ts @@ -39,7 +39,7 @@ describe("Any EVM Keyless Deploy", async () => { async function deployTieredDrop() { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const walletAddress = await sdk.wallet.getAddress(); // This needs to match the published contract for the currently used ABI @@ -94,11 +94,11 @@ describe("Any EVM Keyless Deploy", async () => { async function deployMarketplaceV3() { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const walletAddress = await sdk.wallet.getAddress(); // IPFS URIs here and below This needs to match the published contract URIs for the contract and extensions - // the URI can be found by querying the ContractPublisher for those contracts: https://thirdweb.com/polygon/0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7/explorer + // the URI can be found by querying the ContractPublisher for those contracts: https://thirdweb.com/polygon/0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808/explorer const publishUri = await mockUploadMetadataWithBytecode( "MarketplaceV3", marketplaceV3CompilerMetadata.output.abi, diff --git a/packages/sdk/test/evm/erc721-queryable.test.skip.ts b/packages/sdk/test/evm/erc721-queryable.test.skip.ts index efbc45dc3f5..eb13734baaf 100644 --- a/packages/sdk/test/evm/erc721-queryable.test.skip.ts +++ b/packages/sdk/test/evm/erc721-queryable.test.skip.ts @@ -147,7 +147,7 @@ describe("ERC721A Queryable NFT Contract", async () => { // const mockPublisher = process.env.contractPublisherAddress; // process.env.contractPublisherAddress = - // "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + // "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; contract = await deployOpenEdition(); // process.env.contractPublisherAddress = mockPublisher; }); diff --git a/packages/sdk/test/evm/new-publish-deploy.test.ts b/packages/sdk/test/evm/new-publish-deploy.test.ts index c639af6a5cd..b1d3fc29bbc 100644 --- a/packages/sdk/test/evm/new-publish-deploy.test.ts +++ b/packages/sdk/test/evm/new-publish-deploy.test.ts @@ -183,7 +183,7 @@ describe("New Publish Flow", async () => { it("should deploy with auto factory", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const adminAddress = await adminWallet.getAddress(); // mock publish as a autoFactory-deploy contract @@ -262,7 +262,7 @@ describe("New Publish Flow", async () => { it("should deploy via old factory", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const adminAddress = await adminWallet.getAddress(); // mock publish as old-style factory deployable -- omit deployType, networksForDeployment etc diff --git a/packages/sdk/test/evm/publisher.test.ts b/packages/sdk/test/evm/publisher.test.ts index 0a44cf0c54f..c2bc81bd10d 100644 --- a/packages/sdk/test/evm/publisher.test.ts +++ b/packages/sdk/test/evm/publisher.test.ts @@ -362,7 +362,7 @@ describe("Publishing", async () => { // ("ipfs://Qmbu57WNPmmGuNZEiEAVi9yeXxGK2GkJRBbRMaPxs9KS5b"); const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const addr = await sdk.deployer.deployContractFromUri(ipfsUri, [ adminWallet.address, "NFT", @@ -415,7 +415,7 @@ describe("Publishing", async () => { // ("ipfs://QmXQ2f6qA7FD8uks1hKK1soTn6sbEGBSfDpzN9buYXkGxZ"); const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const addr = await sdk.deployer.deployContractFromUri(ipfsUri, [ adminWallet.address, "NFT", @@ -476,7 +476,7 @@ describe("Publishing", async () => { ("ipfs://QmZsZcLS3fAtPw2EyZGbHxkdeofTxNtqMoXNWLc79sRXWa"); const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const addr = await sdk.deployer.deployContractFromUri(ipfsUri, [ adminWallet.address, "NFT", @@ -537,7 +537,7 @@ describe("Publishing", async () => { // ("ipfs://QmNuKYGZoiHyumKjT7gPk3vwy3WKt7gTf1hKGZ2eyGZGRd"); const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const addr = await sdk.deployer.deployContractFromUri(ipfsUri, [ adminWallet.address, "NFT", diff --git a/packages/sdk/test/evm/transactions.test.ts b/packages/sdk/test/evm/transactions.test.ts index f9a25997e50..9ef1f18e7f2 100644 --- a/packages/sdk/test/evm/transactions.test.ts +++ b/packages/sdk/test/evm/transactions.test.ts @@ -41,7 +41,7 @@ describe("Transactions", async () => { it("Should succesfully prepare and execute a transaction", async () => { const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const address = await sdk.deployer.deployContractFromUri(mockPublishUri, [ adminWallet.address, "NFT", @@ -87,7 +87,7 @@ describe("Transactions", async () => { }); const mockPublisher = process.env.contractPublisherAddress; process.env.contractPublisherAddress = - "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; + "0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808"; const address = await sdk.deployer.deployContractFromUri(mockPublishUri, [ adminWallet.address, "NFT", diff --git a/packages/sdk/typedoc.js b/packages/sdk/typedoc.js deleted file mode 100644 index 8e9600f1ab8..00000000000 --- a/packages/sdk/typedoc.js +++ /dev/null @@ -1,30 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires, better-tree-shaking/no-top-level-side-effects -const TypeDoc = require("typedoc"); - -async function main() { - // Application.bootstrap also exists, which will not load plugins - // Also accepts an array of option readers if you want to disable - // TypeDoc's tsconfig.json/package.json/typedoc.json option readers - const app = await TypeDoc.Application.bootstrapWithPlugins({ - entryPoints: ["src/index.ts"], - excludeInternal: true, - externalPattern: ["**/node_modules/**"], - exclude: ["**/node_modules/**"], - pretty: false, - }); - - const project = await app.convert(); - - if (project) { - // Project may not have converted correctly - const outputDir = "typedoc/"; - - // Rendered docs - await app.generateDocs(project, outputDir); - // Alternatively generate JSON output - await app.generateJson(project, outputDir + "/documentation.json"); - } -} - -// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects -main(); diff --git a/packages/storage/CHANGELOG.md b/packages/storage/CHANGELOG.md index b758ce72aaf..6d37279c0d2 100644 --- a/packages/storage/CHANGELOG.md +++ b/packages/storage/CHANGELOG.md @@ -1,5 +1,17 @@ # @thirdweb-dev/storage +## 2.0.7 + +### Patch Changes + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +## 2.0.6 + +### Patch Changes + +- [#2021](https://github.com/thirdweb-dev/js/pull/2021) [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Catch issue when converting invalid IPFS CID to v1 + ## 2.0.5 ### Patch Changes diff --git a/packages/storage/package.json b/packages/storage/package.json index 4a04f763c49..751c3b288c4 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/storage", - "version": "2.0.5", + "version": "2.0.7", "main": "dist/thirdweb-dev-storage.cjs.js", "module": "dist/thirdweb-dev-storage.esm.js", "exports": { @@ -25,7 +25,7 @@ "test": "pnpm test:all", "test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000", "push": "yalc push", - "typedoc": "rimraf typedoc && node typedoc.js" + "typedoc": "node scripts/typedoc.mjs" }, "files": [ "dist/" @@ -54,8 +54,8 @@ "esm": "^3.2.25", "mocha": "^10.2.0", "rimraf": "^3.0.2", - "typedoc": "^0.25.2", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "typedoc-gen": "workspace:*" }, "dependencies": { "cid-tool": "^3.0.0", diff --git a/packages/storage/scripts/typedoc.mjs b/packages/storage/scripts/typedoc.mjs new file mode 100644 index 00000000000..e96c9913808 --- /dev/null +++ b/packages/storage/scripts/typedoc.mjs @@ -0,0 +1,8 @@ +// @ts-check +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: [], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/storage/src/common/utils.ts b/packages/storage/src/common/utils.ts index cd8fd1b0df1..7332d9abf49 100644 --- a/packages/storage/src/common/utils.ts +++ b/packages/storage/src/common/utils.ts @@ -162,7 +162,17 @@ export function replaceSchemeWithGatewayUrl( } const path = uri.replace(scheme, ""); - return getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId); + try { + const gatewayUrl = getGatewayUrlForCid( + schemeGatewayUrls[index], + path, + clientId, + ); + return gatewayUrl; + } catch (err) { + console.warn(`The IPFS uri: ${path} is not valid.`); + return undefined; + } } /** diff --git a/packages/storage/typedoc.js b/packages/storage/typedoc.js deleted file mode 100644 index c190a165be1..00000000000 --- a/packages/storage/typedoc.js +++ /dev/null @@ -1,28 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const TypeDoc = require("typedoc"); - -async function main() { - // Application.bootstrap also exists, which will not load plugins - // Also accepts an array of option readers if you want to disable - // TypeDoc's tsconfig.json/package.json/typedoc.json option readers - const app = await TypeDoc.Application.bootstrapWithPlugins({ - entryPoints: ["src/index.ts"], - excludeInternal: true, - externalPattern: ["**/node_modules/**"], - exclude: ["**/node_modules/**"], - }); - - const project = await app.convert(); - - if (project) { - // Project may not have converted correctly - const outputDir = "typedoc/"; - - // Rendered docs - await app.generateDocs(project, outputDir); - // Alternatively generate JSON output - await app.generateJson(project, outputDir + "/documentation.json"); - } -} - -main(); diff --git a/packages/typedoc-gen/CHANGELOG.md b/packages/typedoc-gen/CHANGELOG.md new file mode 100644 index 00000000000..05de74af08e --- /dev/null +++ b/packages/typedoc-gen/CHANGELOG.md @@ -0,0 +1,7 @@ +# typedoc-gen + +## 1.0.1 + +### Patch Changes + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - Update typedoc setup diff --git a/packages/typedoc-gen/package.json b/packages/typedoc-gen/package.json new file mode 100644 index 00000000000..3243b198523 --- /dev/null +++ b/packages/typedoc-gen/package.json @@ -0,0 +1,22 @@ +{ + "private": true, + "name": "typedoc-gen", + "version": "1.0.1", + "description": "", + "main": "dist/index.mjs", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsup src/index.ts --format esm --dts", + "watch": "tsup src/index.ts --format esm --dts --watch" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "typedoc": "^0.25.2" + }, + "devDependencies": { + "prettier": "^3.0.0", + "tsup": "^6.7.0" + } +} diff --git a/packages/typedoc-gen/src/index.ts b/packages/typedoc-gen/src/index.ts new file mode 100644 index 00000000000..23293abc624 --- /dev/null +++ b/packages/typedoc-gen/src/index.ts @@ -0,0 +1,43 @@ +import TypeDoc from "typedoc"; +import fs from "fs/promises"; +import { existsSync } from "fs"; +import path from "path"; + +/** + * + * Generate a documentation JSON file for a project + */ +export async function typedoc(options: { + entryPoints: string[]; + exclude: string[]; + output: "json" | "html" | "both"; +}) { + const outFile = "typedoc/documentation.json"; + + const app = await TypeDoc.Application.bootstrapWithPlugins({ + entryPoints: options.entryPoints, + excludeInternal: true, + exclude: options.exclude, + }); + + const project = await app.convert(); + if (!project) { + throw new Error("Failed to create project"); + } + + if (options.output === "html" || options.output === "both") { + const docsFolder = path.resolve(process.cwd(), "typedoc/docs"); + + if (existsSync(docsFolder)) { + await fs.rm(docsFolder, { + recursive: true, + }); + } + + await app.generateDocs(project, "typedoc/docs"); + } + + if (options.output === "json" || options.output === "both") { + await app.generateJson(project, outFile); + } +} diff --git a/packages/typedoc-gen/tsconfig.json b/packages/typedoc-gen/tsconfig.json new file mode 100644 index 00000000000..e0cf3b000bd --- /dev/null +++ b/packages/typedoc-gen/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "module": "commonjs" /* Specify what module code is generated. */, + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + "strict": true /* Enable all strict type-checking options. */, + "skipLibCheck": true /* Skip type checking all .d.ts files. */, + "noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */, + "noEmit": false /* Do not emit outputs. */ + } +} diff --git a/packages/unity-js-bridge/CHANGELOG.md b/packages/unity-js-bridge/CHANGELOG.md index 9f0bd42c00a..5cc0af2008e 100644 --- a/packages/unity-js-bridge/CHANGELOG.md +++ b/packages/unity-js-bridge/CHANGELOG.md @@ -1,5 +1,77 @@ # @thirdweb-dev/unity-js-bridge +## 0.3.0 + +### Minor Changes + +- [#2018](https://github.com/thirdweb-dev/js/pull/2018) [`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba) Thanks [@iketw](https://github.com/iketw)! - Enforces passing an encryption key for custom jwt auth + + ```typescript + const embedded = useEmbeddedWallet(); + + embedded.connect({ + jwt: "", + encryptionKey: "", + strategy: "jwt", + }); + ``` + +### Patch Changes + +- [#2073](https://github.com/thirdweb-dev/js/pull/2073) [`0c730e57`](https://github.com/thirdweb-dev/js/commit/0c730e57e0ebfce5683d3404d69f2895826573c4) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Add JWT/AuthEndpoint login options + +- [#2078](https://github.com/thirdweb-dev/js/pull/2078) [`065f85bf`](https://github.com/thirdweb-dev/js/commit/065f85bf7190899984bcf86ebef8e0d530e5de98) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Support revokeSessionKey/getAllActiveSigners + +- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]: + - @thirdweb-dev/wallets@2.3.0 + - @thirdweb-dev/auth@4.1.17 + +## 0.2.110 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + - @thirdweb-dev/wallets@2.2.1 + - @thirdweb-dev/auth@4.1.16 + +## 0.2.109 + +### Patch Changes + +- [#2061](https://github.com/thirdweb-dev/js/pull/2061) [`0fb2f1fc`](https://github.com/thirdweb-dev/js/commit/0fb2f1fc5e2241f8b0fff2ad9219eeed40a8d1d0) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Support for sdk.wallet.GetEmail + +- [#2056](https://github.com/thirdweb-dev/js/pull/2056) [`5a0283d0`](https://github.com/thirdweb-dev/js/commit/5a0283d083b47a8f26ce61ce59c914e27d60401c) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Reload local wallet in case of reconnection (sw) + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf), [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac), [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + - @thirdweb-dev/wallets@2.2.0 + - @thirdweb-dev/auth@4.1.15 + +## 0.2.108 + +### Patch Changes + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82), [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5), [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + - @thirdweb-dev/storage@2.0.7 + - @thirdweb-dev/wallets@2.1.11 + - @thirdweb-dev/auth@4.1.14 + +## 0.2.107 + +### Patch Changes + +- [#2026](https://github.com/thirdweb-dev/js/pull/2026) [`9798a31a`](https://github.com/thirdweb-dev/js/commit/9798a31a9a103e3a51cfc0e8233d093478bf994d) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Pass down authOptions when connecting smart wallets. + +- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]: + - @thirdweb-dev/wallets@2.1.10 + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + - @thirdweb-dev/storage@2.0.6 + - @thirdweb-dev/auth@4.1.13 + ## 0.2.106 ### Patch Changes diff --git a/packages/unity-js-bridge/package.json b/packages/unity-js-bridge/package.json index ebbbb1874d9..56e453c737e 100644 --- a/packages/unity-js-bridge/package.json +++ b/packages/unity-js-bridge/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/unity-js-bridge", - "version": "0.2.106", + "version": "0.3.0", "main": "dist/thirdweb-unity-bridge.js", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge", "license": "Apache-2.0", diff --git a/packages/unity-js-bridge/src/thirdweb-bridge.ts b/packages/unity-js-bridge/src/thirdweb-bridge.ts index 54f7909795d..ba3dc87edbc 100644 --- a/packages/unity-js-bridge/src/thirdweb-bridge.ts +++ b/packages/unity-js-bridge/src/thirdweb-bridge.ts @@ -92,10 +92,13 @@ interface TWBridge { smartWalletAddAdmin: (admin: string) => Promise; smartWalletRemoveAdmin: (admin: string) => Promise; smartWalletCreateSessionKey: (options: string) => Promise; + smartWalletRevokeSessionKey: (signer: string) => Promise; + smartWalletGetAllActiveSigners: () => Promise; waitForTransactionResult: (txHash: string) => Promise; getLatestBlockNumber: () => Promise; getBlock: (blockNumber: string) => Promise; getBlockWithTransactions: (blockNumber: string) => Promise; + getEmail: () => Promise; } const w = window; @@ -325,10 +328,22 @@ class ThirdwebBridge implements TWBridge { authResult, }); } else if (authOptionsParsed.authProvider === 4) { - // CustomAuth + // JWT const authResult = await embeddedWallet.authenticate({ strategy: "jwt", - jwt: authOptionsParsed.authToken, + jwt: authOptionsParsed.jwtOrPayload, + encryptionKey: authOptionsParsed.encryptionKey, + }); + await embeddedWallet.connect({ + chainId: chainIdNumber, + authResult, + }); + } else if (authOptionsParsed.authProvider === 5) { + // AuthEndpoint + const authResult = await embeddedWallet.authenticate({ + strategy: "auth_endpoint", + payload: authOptionsParsed.jwtOrPayload, + encryptionKey: authOptionsParsed.encryptionKey, }); await embeddedWallet.connect({ chainId: chainIdNumber, @@ -349,10 +364,15 @@ class ThirdwebBridge implements TWBridge { password, email, personalWallet, + authOptions, ); if (this.activeWallet) { // Pass EOA and reconnect to initialize smart wallet - await this.initializeSmartWallet(smartWallet, this.activeWallet, smartWalletAccountOverride); + await this.initializeSmartWallet( + smartWallet, + this.activeWallet, + smartWalletAccountOverride, + ); } else { // If EOA wallet is not connected, throw error throw new Error( @@ -631,8 +651,11 @@ class ThirdwebBridge implements TWBridge { personalWallet: AbstractClientWallet, accountAddress?: string, ) { - if(accountAddress) { - console.debug("Initializing smart wallet with account address override:", accountAddress); + if (accountAddress) { + console.debug( + "Initializing smart wallet with account address override:", + accountAddress, + ); } const personalWalletAddress = await personalWallet.getAddress(); console.debug("Personal wallet address:", personalWalletAddress); @@ -651,10 +674,16 @@ class ThirdwebBridge implements TWBridge { const localWallet = this.walletMap.get( walletIds.localWallet, ) as LocalWallet; - await localWallet.loadOrCreate({ - strategy: "encryptedJson", - password, - }); + try { + await localWallet.loadOrCreate({ + strategy: "encryptedJson", + password, + }); + } catch (e) { + console.warn(e); + return localWallet; + } + return localWallet; } @@ -687,16 +716,40 @@ class ThirdwebBridge implements TWBridge { optionsParsed.nativeTokenLimitPerTransactionInWei, ); const startDate = BigNumber.from(optionsParsed.startDate).toNumber(); - const expirationDate = BigNumber.from(optionsParsed.expirationDate).toNumber(); - const result = await smartWallet.createSessionKey(optionsParsed.signerAddress, { - approvedCallTargets: approvedCallTargets, - nativeTokenLimitPerTransaction: nativeTokenLimitPerTransaction, - startDate: startDate, - expirationDate: expirationDate, - }); + const expirationDate = BigNumber.from( + optionsParsed.expirationDate, + ).toNumber(); + const result = await smartWallet.createSessionKey( + optionsParsed.signerAddress, + { + approvedCallTargets: approvedCallTargets, + nativeTokenLimitPerTransaction: nativeTokenLimitPerTransaction, + startDate: startDate, + expirationDate: expirationDate, + }, + ); return JSON.stringify({ result: result }, bigNumberReplacer); } + public async smartWalletRevokeSessionKey(signer: string) { + if (!this.activeWallet) { + throw new Error("No wallet connected"); + } + const smartWallet = this.activeWallet as SmartWallet; + const result = await smartWallet.revokeSessionKey(signer); + return JSON.stringify({ result: result }, bigNumberReplacer); + } + + + public async smartWalletGetAllActiveSigners(){ + if (!this.activeWallet) { + throw new Error("No wallet connected"); + } + const smartWallet = this.activeWallet as SmartWallet; + const res = await smartWallet.getAllActiveSigners(); + return JSON.stringify({ result: res }, bigNumberReplacer); + } + public async waitForTransactionResult(txHash: string) { if (!this.activeSDK) { throw new Error("SDK not initialized"); @@ -705,7 +758,7 @@ class ThirdwebBridge implements TWBridge { return JSON.stringify({ result: res }, bigNumberReplacer); } - public async getLatestBlockNumber(){ + public async getLatestBlockNumber() { if (!this.activeSDK) { throw new Error("SDK not initialized"); } @@ -713,22 +766,34 @@ class ThirdwebBridge implements TWBridge { return JSON.stringify({ result: res }, bigNumberReplacer); } - public async getBlock(blockNumber: string){ + public async getBlock(blockNumber: string) { if (!this.activeSDK) { throw new Error("SDK not initialized"); } - const res = await this.activeSDK.getProvider().getBlock(Number(blockNumber)); + const res = await this.activeSDK + .getProvider() + .getBlock(Number(blockNumber)); return JSON.stringify({ result: res }, bigNumberReplacer); } - public async getBlockWithTransactions(blockNumber: string){ + public async getBlockWithTransactions(blockNumber: string) { if (!this.activeSDK) { throw new Error("SDK not initialized"); } - const res = await this.activeSDK.getProvider().getBlockWithTransactions(Number(blockNumber)); + const res = await this.activeSDK + .getProvider() + .getBlockWithTransactions(Number(blockNumber)); return JSON.stringify({ result: res }, bigNumberReplacer); } + public async getEmail() { + const embeddedWallet = this.walletMap.get( + walletIds.embeddedWallet, + ) as EmbeddedWallet; + const email = await embeddedWallet.getEmail(); + return JSON.stringify({ result: email }); + } + public openPopupWindow() { const win = window.open("", undefined, "width=350, height=500"); if (win) { diff --git a/packages/wallets/CHANGELOG.md b/packages/wallets/CHANGELOG.md index 9d3abb590fc..0df4a4d1fdb 100644 --- a/packages/wallets/CHANGELOG.md +++ b/packages/wallets/CHANGELOG.md @@ -1,5 +1,87 @@ # @thirdweb-dev/wallets +## 2.3.0 + +### Minor Changes + +- [#2018](https://github.com/thirdweb-dev/js/pull/2018) [`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba) Thanks [@iketw](https://github.com/iketw)! - Enforces passing an encryption key for custom jwt auth + + ```typescript + const embedded = useEmbeddedWallet(); + + embedded.connect({ + jwt: "", + encryptionKey: "", + strategy: "jwt", + }); + ``` + +### Patch Changes + +- [#2070](https://github.com/thirdweb-dev/js/pull/2070) [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe) Thanks [@MananTank](https://github.com/MananTank)! - Fix assertWindowEthereum - actually check if `window.ethereum` is truthy or not instead of just checking `"ethereum" in window` + +- [#2080](https://github.com/thirdweb-dev/js/pull/2080) [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da) Thanks [@adam-maj](https://github.com/adam-maj)! - Add support for signTransaction to smart wallets + +- [#2077](https://github.com/thirdweb-dev/js/pull/2077) [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Respect `value` in smart wallet gas estimations + add `getUserOpReceipt` utility function + +## 2.2.1 + +### Patch Changes + +- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]: + - @thirdweb-dev/sdk@4.0.21 + +## 2.2.0 + +### Minor Changes + +- [#2052](https://github.com/thirdweb-dev/js/pull/2052) [`94966069`](https://github.com/thirdweb-dev/js/commit/9496606964d65268f8ee6bf9f78b2786e99d33ac) Thanks [@ElasticBottle](https://github.com/ElasticBottle)! - feat: add custom auth endpoint authentication strategy support for embeddedWallet + + Configure the endpoint for where the payload is to be sent too over at thirdweb.com/dashboard. + + ```typsecript + await embeddedWallet.authenticate({ + strategy: "auth_endpoint", + payload: "SOME_STRING", + encryptionKey: "" + }); + ``` + +### Patch Changes + +- [#2058](https://github.com/thirdweb-dev/js/pull/2058) [`15ae5e7f`](https://github.com/thirdweb-dev/js/commit/15ae5e7f95a482a9736923c0e10916a0a6115c3d) Thanks [@MananTank](https://github.com/MananTank)! - Add option to open the official wallet connect modal in ConnectWallet + +- Updated dependencies [[`d2001ca4`](https://github.com/thirdweb-dev/js/commit/d2001ca464aa699ac821c97eb37de7409ba865f3), [`85842c15`](https://github.com/thirdweb-dev/js/commit/85842c1596c901e228be1894b6702a8871d9e794), [`e595d4d9`](https://github.com/thirdweb-dev/js/commit/e595d4d92f03e36cbe61e1f00a366e37ede5d814), [`497677f3`](https://github.com/thirdweb-dev/js/commit/497677f3596977fa90ebc0fa76cb5842d46d8dcf)]: + - @thirdweb-dev/chains@0.1.61 + - @thirdweb-dev/sdk@4.0.20 + +## 2.1.11 + +### Patch Changes + +- [#1842](https://github.com/thirdweb-dev/js/pull/1842) [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56) Thanks [@MananTank](https://github.com/MananTank)! - JSDoc improvements + +- [#1938](https://github.com/thirdweb-dev/js/pull/1938) [`4ae1cd63`](https://github.com/thirdweb-dev/js/commit/4ae1cd63bb7b471cae48a27bf6554c4953c1dc82) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add OneKey wallet + +- [#2042](https://github.com/thirdweb-dev/js/pull/2042) [`61c62b3f`](https://github.com/thirdweb-dev/js/commit/61c62b3f07a082ffd7620c949e3bcc6b75c104b5) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and Type exports + +- [#2040](https://github.com/thirdweb-dev/js/pull/2040) [`7bb054e4`](https://github.com/thirdweb-dev/js/commit/7bb054e45c75450c8f465809d23eb66371f6ef8e) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Remove barrel files + +- Updated dependencies [[`cfe81b44`](https://github.com/thirdweb-dev/js/commit/cfe81b443205d84e58128b8d7d5f2dc940b12875), [`72c0bb10`](https://github.com/thirdweb-dev/js/commit/72c0bb10d6d765d1679b2b22ac63d85db101b5c4), [`ca618ea0`](https://github.com/thirdweb-dev/js/commit/ca618ea0c9ac5dc4f65cbfbfd39360e4150c72c7), [`aefc4cda`](https://github.com/thirdweb-dev/js/commit/aefc4cda4c4fad81411d3a9485931e28100b5718), [`a36c7e83`](https://github.com/thirdweb-dev/js/commit/a36c7e8331744879a169f84e97b66abf0ab44f56), [`d20e7898`](https://github.com/thirdweb-dev/js/commit/d20e7898562a3914841522f2e09f88ca37dfdd4b)]: + - @thirdweb-dev/sdk@4.0.19 + +## 2.1.10 + +### Patch Changes + +- [#1926](https://github.com/thirdweb-dev/js/pull/1926) [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Rabby browser extension + +- [#1928](https://github.com/thirdweb-dev/js/pull/1928) [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Crypto.com Defi wallet + +- Updated dependencies [[`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa)]: + - @thirdweb-dev/sdk@4.0.18 + - @thirdweb-dev/chains@0.1.60 + ## 2.1.9 ### Patch Changes diff --git a/packages/wallets/evm/connectors/onekey/package.json b/packages/wallets/evm/connectors/onekey/package.json new file mode 100644 index 00000000000..a1c7e4f91ea --- /dev/null +++ b/packages/wallets/evm/connectors/onekey/package.json @@ -0,0 +1,7 @@ +{ + "main": "dist/thirdweb-dev-wallets-evm-connectors-onekey.cjs.js", + "module": "dist/thirdweb-dev-wallets-evm-connectors-onekey.esm.js", + "browser": { + "./dist/thirdweb-dev-wallets-evm-connectors-onekey.esm.js": "./dist/thirdweb-dev-wallets-evm-connectors-onekey.browser.esm.js" + } +} diff --git a/packages/wallets/evm/wallets/onekey/package.json b/packages/wallets/evm/wallets/onekey/package.json new file mode 100644 index 00000000000..78ce8845d5c --- /dev/null +++ b/packages/wallets/evm/wallets/onekey/package.json @@ -0,0 +1,7 @@ +{ + "main": "dist/thirdweb-dev-wallets-evm-wallets-onekey.cjs.js", + "module": "dist/thirdweb-dev-wallets-evm-wallets-onekey.esm.js", + "browser": { + "./dist/thirdweb-dev-wallets-evm-wallets-onekey.esm.js": "./dist/thirdweb-dev-wallets-evm-wallets-onekey.browser.esm.js" + } +} diff --git a/packages/wallets/package.json b/packages/wallets/package.json index caf29c4c41a..294b1646189 100644 --- a/packages/wallets/package.json +++ b/packages/wallets/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/wallets", - "version": "2.1.9", + "version": "2.3.0", "main": "dist/thirdweb-dev-wallets.cjs.js", "module": "dist/thirdweb-dev-wallets.esm.js", "browser": { @@ -105,6 +105,13 @@ }, "default": "./evm/wallets/ethers/dist/thirdweb-dev-wallets-evm-wallets-ethers.cjs.js" }, + "./evm/wallets/onekey": { + "module": { + "browser": "./evm/wallets/onekey/dist/thirdweb-dev-wallets-evm-wallets-onekey.browser.esm.js", + "default": "./evm/wallets/onekey/dist/thirdweb-dev-wallets-evm-wallets-onekey.esm.js" + }, + "default": "./evm/wallets/onekey/dist/thirdweb-dev-wallets-evm-wallets-onekey.cjs.js" + }, "./evm/wallets/signer": { "module": { "browser": "./evm/wallets/signer/dist/thirdweb-dev-wallets-evm-wallets-signer.browser.esm.js", @@ -273,6 +280,13 @@ }, "default": "./evm/connectors/coin98/dist/thirdweb-dev-wallets-evm-connectors-coin98.cjs.js" }, + "./evm/connectors/onekey": { + "module": { + "browser": "./evm/connectors/onekey/dist/thirdweb-dev-wallets-evm-connectors-onekey.browser.esm.js", + "default": "./evm/connectors/onekey/dist/thirdweb-dev-wallets-evm-connectors-onekey.esm.js" + }, + "default": "./evm/connectors/onekey/dist/thirdweb-dev-wallets-evm-connectors-onekey.cjs.js" + }, "./evm/connectors/signer": { "module": { "browser": "./evm/connectors/signer/dist/thirdweb-dev-wallets-evm-connectors-signer.browser.esm.js", @@ -548,8 +562,8 @@ "ethers-aws-kms-signer": "^1.3.2", "rimraf": "^3.0.2", "tweetnacl": "^1.0.3", - "typedoc": "^0.25.2", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "typedoc-gen": "workspace:*" }, "scripts": { "format": "prettier --write 'src/**/*'", @@ -559,7 +573,7 @@ "build": "tsc && cross-env THIRDWEB_EWS_SDK_VERSION=$npm_package_version preconstruct build", "preconstruct:fix": "preconstruct fix", "push": "yalc push", - "typedoc": "rimraf typedoc && node typedoc.js" + "typedoc": "node scripts/typedoc.mjs" }, "engines": { "node": ">=18" diff --git a/packages/wallets/scripts/typedoc.mjs b/packages/wallets/scripts/typedoc.mjs new file mode 100644 index 00000000000..bd51cf55f5d --- /dev/null +++ b/packages/wallets/scripts/typedoc.mjs @@ -0,0 +1,10 @@ +// @ts-check +/* eslint-disable better-tree-shaking/no-top-level-side-effects */ + +import { typedoc } from "typedoc-gen"; + +typedoc({ + entryPoints: ["src/index.ts"], + exclude: [], + output: "both", // TODO: change this to 'json' when old portal is fully migrated to new portal +}); diff --git a/packages/wallets/src/core/AsyncStorage.ts b/packages/wallets/src/core/AsyncStorage.ts index 8aeea6634d6..7dc3815af9b 100644 --- a/packages/wallets/src/core/AsyncStorage.ts +++ b/packages/wallets/src/core/AsyncStorage.ts @@ -39,7 +39,9 @@ export class AsyncLocalStorage implements AsyncStorage { }); } } - +/** + * @internal + */ export function createAsyncLocalStorage(name: string) { return new AsyncLocalStorage(name); } diff --git a/packages/wallets/src/core/CredentialsStorage.ts b/packages/wallets/src/core/CredentialsStorage.ts index 3d5a33aebef..265496cb5c3 100644 --- a/packages/wallets/src/core/CredentialsStorage.ts +++ b/packages/wallets/src/core/CredentialsStorage.ts @@ -1,5 +1,10 @@ import { AsyncStorage } from "./AsyncStorage"; +// TODO: remove this file - this is not being used + +/** + * @internal + */ export class CredentialsStorage implements AsyncStorage { async getItem(): Promise { const credential = await navigator.credentials.get({ diff --git a/packages/wallets/src/core/SyncStorage.ts b/packages/wallets/src/core/SyncStorage.ts index 5c3761ac27e..3aa26064f06 100644 --- a/packages/wallets/src/core/SyncStorage.ts +++ b/packages/wallets/src/core/SyncStorage.ts @@ -26,6 +26,9 @@ export class LocalStorage implements SyncStorage { } } +/** + * @internal + */ export function createLocalStorage(name: string) { return new LocalStorage(name); } diff --git a/packages/wallets/src/core/index.ts b/packages/wallets/src/core/index.ts index c5d3cb9947a..21c8e64daee 100644 --- a/packages/wallets/src/core/index.ts +++ b/packages/wallets/src/core/index.ts @@ -3,7 +3,5 @@ export * from "./SyncStorage"; export * from "./interfaces/auth"; export type { DAppMetaData } from "./types/dAppMeta"; -export { CredentialsStorage } from "./CredentialsStorage"; - export * from "./types/walletConnect"; export { WalletConnectV2Handler } from "./WalletConnect/WalletConnectV2Handler"; diff --git a/packages/wallets/src/core/interfaces/auth.ts b/packages/wallets/src/core/interfaces/auth.ts index 4a1f0852d80..e31e9762dc5 100644 --- a/packages/wallets/src/core/interfaces/auth.ts +++ b/packages/wallets/src/core/interfaces/auth.ts @@ -1,3 +1,6 @@ +/** + * @internal + */ export type Ecosystem = "evm"; export interface GenericAuthWallet { type: Ecosystem; diff --git a/packages/wallets/src/evm/connectors/blocto/index.ts b/packages/wallets/src/evm/connectors/blocto/index.ts index 7833861645c..a2890349013 100644 --- a/packages/wallets/src/evm/connectors/blocto/index.ts +++ b/packages/wallets/src/evm/connectors/blocto/index.ts @@ -1,13 +1,12 @@ import { WagmiConnector, WagmiConnectorData, -} from "../../../lib/wagmi-connectors"; +} from "../../../lib/wagmi-connectors/WagmiConnector"; import { UserRejectedRequestError, SwitchChainError, - normalizeChainId, ConnectorNotFoundError, -} from "../../../lib/wagmi-core"; +} from "../../../lib/wagmi-core/errors"; import type { EthereumProviderConfig, EthereumProviderInterface as BloctoProvider, @@ -17,6 +16,7 @@ import { providers, utils } from "ethers"; import { walletIds } from "../../constants/walletIds"; import type { Chain } from "@thirdweb-dev/chains"; import { getValidPublicRPCUrl } from "../../utils/url"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; type BloctoSigner = providers.JsonRpcSigner; type BloctoOptions = Partial; diff --git a/packages/wallets/src/evm/connectors/coin98/getInjectedCoin98Provider.ts b/packages/wallets/src/evm/connectors/coin98/getInjectedCoin98Provider.ts index 822ec4190c3..4a9fe6c7788 100644 --- a/packages/wallets/src/evm/connectors/coin98/getInjectedCoin98Provider.ts +++ b/packages/wallets/src/evm/connectors/coin98/getInjectedCoin98Provider.ts @@ -7,6 +7,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedCoin98Provider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/coinbase-wallet/getInjectedCoinbaseProvider.ts b/packages/wallets/src/evm/connectors/coinbase-wallet/getInjectedCoinbaseProvider.ts index b3814a19dc5..4e51fe5bc87 100644 --- a/packages/wallets/src/evm/connectors/coinbase-wallet/getInjectedCoinbaseProvider.ts +++ b/packages/wallets/src/evm/connectors/coinbase-wallet/getInjectedCoinbaseProvider.ts @@ -1,6 +1,9 @@ import { Ethereum } from "../injected/types"; import { assertWindowEthereum } from "../../utils/assertWindowEthereum"; +/** + * @internal + */ export function getInjectedCoinbaseProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/coinbase-wallet/index.ts b/packages/wallets/src/evm/connectors/coinbase-wallet/index.ts index dc488379bc0..8138e1b18f6 100644 --- a/packages/wallets/src/evm/connectors/coinbase-wallet/index.ts +++ b/packages/wallets/src/evm/connectors/coinbase-wallet/index.ts @@ -1,12 +1,11 @@ -import { WagmiConnector } from "../../../lib/wagmi-connectors"; +import { WagmiConnector } from "../../../lib/wagmi-connectors/WagmiConnector"; import { UserRejectedRequestError, ChainNotConfiguredError, AddChainError, SwitchChainError, - normalizeChainId, ProviderRpcError, -} from "../../../lib/wagmi-core"; +} from "../../../lib/wagmi-core/errors"; import type { CoinbaseWalletProvider, CoinbaseWalletSDK, @@ -16,16 +15,19 @@ import type { Chain } from "@thirdweb-dev/chains"; import { providers, utils } from "ethers"; import { walletIds } from "../../constants/walletIds"; import { getValidPublicRPCUrl } from "../../utils/url"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; type Options = CoinbaseWalletSDKOptions & { /** * Fallback Ethereum JSON RPC URL - * @defaultValue "" + * + * By default it is set to `""` */ jsonRpcUrl?: string; /** * Fallback Ethereum Chain ID - * @defaultValue 1 + * + * By default it is set to `1` */ chainId?: number; }; diff --git a/packages/wallets/src/evm/connectors/core-wallet/getInjectedCoreWalletProvider.ts b/packages/wallets/src/evm/connectors/core-wallet/getInjectedCoreWalletProvider.ts index 11cc9b3b201..b50f7148350 100644 --- a/packages/wallets/src/evm/connectors/core-wallet/getInjectedCoreWalletProvider.ts +++ b/packages/wallets/src/evm/connectors/core-wallet/getInjectedCoreWalletProvider.ts @@ -7,6 +7,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedCoreWalletProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider.ts b/packages/wallets/src/evm/connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider.ts index 31484c8a7a9..b2024737800 100644 --- a/packages/wallets/src/evm/connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider.ts +++ b/packages/wallets/src/evm/connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider.ts @@ -7,6 +7,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedCryptoDefiWalletProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/constants/settings.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/constants/settings.ts index 6bf5f6ece25..8433d180cdf 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/constants/settings.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/constants/settings.ts @@ -1,26 +1,60 @@ import { getPaperOriginUrl } from "@paperxyz/sdk-common-utilities"; - +/** + * @internal + */ export const EMBEDDED_WALLET_PATH = "/sdk/2022-08-12/embedded-wallet"; -export const HEADLESS_GOOGLE_OAUTH_ROUTE = `/auth/headless-google-login-managed`; +/** + * @internal + */ +export const HEADLESS_GOOGLE_OAUTH_ROUTE = `/auth/headless-google-login-managed`; +/** + * @internal + */ export const GET_IFRAME_BASE_URL = () => `${getPaperOriginUrl().replace( "withpaper.com", "embedded-wallet.thirdweb.com", )}`; - +/** + * @internal + */ export const WALLET_USER_DETAILS_LOCAL_STORAGE_NAME = (clientId: string) => `thirdwebEwsWalletUserDetails-${clientId}`; + +/** + * @internal + */ export const WALLET_USER_ID_LOCAL_STORAGE_NAME = (clientId: string) => `thirdwebEwsWalletUserId-${clientId}`; + +/** + * @internal + */ const AUTH_TOKEN_LOCAL_STORAGE_PREFIX = "walletToken"; + +/** + * @internal + */ export const AUTH_TOKEN_LOCAL_STORAGE_NAME = (clientId: string) => { return `${AUTH_TOKEN_LOCAL_STORAGE_PREFIX}-${clientId}`; }; + +/** + * @internal + */ const DEVICE_SHARE_LOCAL_STORAGE_PREFIX = "a"; + +/** + * @internal + */ export const DEVICE_SHARE_LOCAL_STORAGE_NAME = ( clientId: string, userId: string, ) => `${DEVICE_SHARE_LOCAL_STORAGE_PREFIX}-${clientId}-${userId}`; + +/** + * @internal + */ export const DEVICE_SHARE_LOCAL_STORAGE_NAME_DEPRECATED = (clientId: string) => `${DEVICE_SHARE_LOCAL_STORAGE_PREFIX}-${clientId}`; diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/auth.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/auth.ts index 42890b881ae..58979aedd6c 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/auth.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/auth.ts @@ -14,10 +14,14 @@ export enum AuthProvider { GOOGLE = "Google", EMAIL_OTP = "EmailOtp", CUSTOM_JWT = "CustomJWT", + CUSTOM_AUTH_ENDPOINT = "CustomAuthEndpoint", FACEBOOK = "Facebook", APPLE = "Apple", } +/** + * @internal + */ export type GetHeadlessLoginLinkReturnType = { loginLink: string; }; diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/embedded-wallets.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/embedded-wallets.ts index 2b2f4362eb0..2833154fa80 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/embedded-wallets.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/embedded-wallets.ts @@ -89,6 +89,10 @@ export type SendEmailOtpReturnType = { recoveryShareManagement: RecoveryShareManagement; }; export type LogoutReturnType = { success: boolean }; + +/** + * @internal + */ export type GetAuthDetailsReturnType = { authDetails?: AuthDetails }; // ! Types seem repetitive, but the name should identify which goes where diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/signer.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/signer.ts index e467e25007d..eb5314eee4e 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/signer.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/interfaces/embedded-wallets/signer.ts @@ -1,3 +1,6 @@ +/** + * @internal + */ export type GetAddressReturnType = { address: string }; export type SignMessageReturnType = { signedMessage: string }; export type SignTransactionReturnType = { diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/abstract-login.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/abstract-login.ts index c23e2a89c32..69eb5b70480 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/abstract-login.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/abstract-login.ts @@ -10,6 +10,7 @@ import type { import type { EmbeddedWalletIframeCommunicator } from "../../utils/iFrameCommunication/EmbeddedWalletIframeCommunicator"; export type LoginQuerierTypes = { + loginWithCustomAuthEndpoint: { payload: string; encryptionKey: string }; loginWithCustomJwt: { jwt: string; encryptionKey?: string }; loginWithThirdwebModal: undefined | { email: string }; sendThirdwebEmailLoginOtp: { email: string }; @@ -68,6 +69,10 @@ export abstract class AbstractLogin< jwt: string; encryptionKey: string; }): Promise; + abstract loginWithCustomAuthEndpoint(args: { + payload: string; + encryptionKey: string; + }): Promise; abstract loginWithModal(args?: MODAL): Promise; abstract loginWithEmailOtp(args: EMAIL_MODAL): Promise; abstract loginWithOauth( diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/base-login.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/base-login.ts index 4891684864c..faaabc7a171 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/base-login.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/base-login.ts @@ -184,6 +184,7 @@ export class BaseLogin extends AbstractLogin< encryptionKey, jwt, }: LoginQuerierTypes["loginWithCustomJwt"]): Promise { + await this.preLogin(); const result = await this.LoginQuerier.call({ procedureName: "loginWithCustomJwt", params: { encryptionKey, jwt }, @@ -191,6 +192,18 @@ export class BaseLogin extends AbstractLogin< return this.postLogin(result); } + override async loginWithCustomAuthEndpoint({ + encryptionKey, + payload, + }: LoginQuerierTypes["loginWithCustomAuthEndpoint"]): Promise { + await this.preLogin(); + const result = await this.LoginQuerier.call({ + procedureName: "loginWithCustomAuthEndpoint", + params: { encryptionKey, payload }, + }); + return this.postLogin(result); + } + override async verifyEmailLoginOtp({ email, otp, diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/index.ts b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/index.ts index 5189c8894bb..2b7c59095b0 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/index.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/implementations/lib/auth/index.ts @@ -96,8 +96,6 @@ export class Auth { * @returns `{{user: InitializedUser}}` An InitializedUser object. See {@link EmbeddedWalletSdk.getUser} for more */ async loginWithModal(): Promise { - await this.preLogin(); - return this.BaseLogin.loginWithModal(); } @@ -133,6 +131,12 @@ export class Auth { return this.BaseLogin.loginWithCustomJwt(args); } + async loginWithCustomAuthEndpoint( + args: Parameters[0], + ): Promise { + return this.BaseLogin.loginWithCustomAuthEndpoint(args); + } + async loginWithOauth( args: Parameters[0], ): Promise { diff --git a/packages/wallets/src/evm/connectors/embedded-wallet/index.ts b/packages/wallets/src/evm/connectors/embedded-wallet/index.ts index 031b939c702..f04feea8902 100644 --- a/packages/wallets/src/evm/connectors/embedded-wallet/index.ts +++ b/packages/wallets/src/evm/connectors/embedded-wallet/index.ts @@ -1,7 +1,7 @@ import { Chain } from "@thirdweb-dev/chains"; import type { Signer, providers } from "ethers"; import { utils } from "ethers"; -import { normalizeChainId } from "../../../lib/wagmi-core"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; import { walletIds } from "../../constants/walletIds"; import { Connector } from "../../interfaces/connector"; @@ -250,13 +250,18 @@ export class EmbeddedWalletConnector extends Connector typeof window !== 'undefined' ? window.ethereum : undefined` + * By default it is set to the following: + * + * ```ts + * () => typeof window !== 'undefined' ? window.ethereum : undefined + * ``` */ getProvider?: () => Ethereum | undefined; /** * MetaMask and other injected providers do not support programmatic disconnect. + * * This flag simulates the disconnect behavior by keeping track of connection status in storage. See [GitHub issue](https://github.com/MetaMask/metamask-extension/issues/10353) for more info. - * @defaultValue true + * + * By default, it is set to `true`. */ shimDisconnect?: boolean; }; diff --git a/packages/wallets/src/evm/connectors/injected/types.ts b/packages/wallets/src/evm/connectors/injected/types.ts index 85445ae5753..c48b83bf0f6 100644 --- a/packages/wallets/src/evm/connectors/injected/types.ts +++ b/packages/wallets/src/evm/connectors/injected/types.ts @@ -52,6 +52,7 @@ type InjectedProviderFlags = { isZerion?: true; isOkxWallet?: true; isCoreWallet?: true; + isOneKey?: true; isDefiWallet?: true; isRabbyWallet?: true; isCoin98Wallet?: true; diff --git a/packages/wallets/src/evm/connectors/local-wallet/index.ts b/packages/wallets/src/evm/connectors/local-wallet/index.ts index b90640e1fa5..e00fde07ea9 100644 --- a/packages/wallets/src/evm/connectors/local-wallet/index.ts +++ b/packages/wallets/src/evm/connectors/local-wallet/index.ts @@ -1,4 +1,4 @@ -import { normalizeChainId } from "../../../lib/wagmi-core"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; import { ConnectParams, Connector } from "../../interfaces/connector"; import type { LocalWalletConnectionArgs } from "../../wallets/local-wallet"; import type { Chain } from "@thirdweb-dev/chains"; diff --git a/packages/wallets/src/evm/connectors/magic/index.ts b/packages/wallets/src/evm/connectors/magic/index.ts index fb7bdc6f458..236f7ceecf3 100644 --- a/packages/wallets/src/evm/connectors/magic/index.ts +++ b/packages/wallets/src/evm/connectors/magic/index.ts @@ -1,4 +1,4 @@ -import { WagmiConnector, normalizeChainId } from "../../../lib/wagmi-core"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; import { MagicAuthOptions, MagicConnectorBaseOptions, @@ -17,6 +17,7 @@ import { Address } from "@thirdweb-dev/sdk"; import { Magic } from "magic-sdk"; import type { AbstractProvider } from "web3-core"; import { RPCProviderModule } from "@magic-sdk/provider/dist/types/modules/rpc-provider"; +import { WagmiConnector } from "../../../lib/wagmi-connectors/WagmiConnector"; export type MagicAuthConnectOptions = { chainId?: number; diff --git a/packages/wallets/src/evm/connectors/magic/types.ts b/packages/wallets/src/evm/connectors/magic/types.ts index 669d147452c..28e4649a012 100644 --- a/packages/wallets/src/evm/connectors/magic/types.ts +++ b/packages/wallets/src/evm/connectors/magic/types.ts @@ -22,17 +22,20 @@ export interface MagicOptions { export interface MagicAuthOptions extends MagicOptions { /** * enable email login for the Magic Auth. - * @defaultValue true + * + * By default it is set to `true` */ emailLogin?: boolean; /** * enable sms login for the Magic Auth. - * @defaultValue true + * + * By default it is set to `true` */ smsLogin?: boolean; /** * Specify whether to use the Magic Auth or Magic Connect. - * @defaultValue "auth" + * + * By default it is set to `"auth"` */ type?: "auth" | "connect"; @@ -52,7 +55,8 @@ export interface MagicConnectorBaseOptions { magicSdkConfiguration?: MagicSDKAdditionalConfiguration; /** * Specify whether to use the Magic Auth or Magic Connect. - * @defaultValue "auth" + * + * By default it is set to `"auth"` */ type?: "auth" | "connect"; } diff --git a/packages/wallets/src/evm/connectors/metamask/getInjectedMetamaskProvider.ts b/packages/wallets/src/evm/connectors/metamask/getInjectedMetamaskProvider.ts index ef790bf7d67..15db4364af9 100644 --- a/packages/wallets/src/evm/connectors/metamask/getInjectedMetamaskProvider.ts +++ b/packages/wallets/src/evm/connectors/metamask/getInjectedMetamaskProvider.ts @@ -1,6 +1,9 @@ import { Ethereum } from "../injected/types"; import { assertWindowEthereum } from "../../utils/assertWindowEthereum"; +/** + * @internal + */ export function getInjectedMetamaskProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/okx/getInjectedOKXProvider.ts b/packages/wallets/src/evm/connectors/okx/getInjectedOKXProvider.ts index 44dbccbeaaf..b3466e80add 100644 --- a/packages/wallets/src/evm/connectors/okx/getInjectedOKXProvider.ts +++ b/packages/wallets/src/evm/connectors/okx/getInjectedOKXProvider.ts @@ -7,6 +7,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedOKXProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/onekey/getInjectedOneKeyProvider.ts b/packages/wallets/src/evm/connectors/onekey/getInjectedOneKeyProvider.ts new file mode 100644 index 00000000000..237446c0cf7 --- /dev/null +++ b/packages/wallets/src/evm/connectors/onekey/getInjectedOneKeyProvider.ts @@ -0,0 +1,22 @@ +import { Ethereum } from "../injected/types"; +import { assertWindowEthereum } from "../../utils/assertWindowEthereum"; + +declare global { + interface Window { + $onekey?: { + ethereum: Ethereum; + }; + } +} + +export function getInjectedOneKeyProvider(): Ethereum | undefined { + if (typeof window === "undefined") { + return; + } + + if (assertWindowEthereum(globalThis.window)) { + if (globalThis.window.$onekey && globalThis.window.$onekey.ethereum) { + return globalThis.window.$onekey.ethereum; + } + } +} diff --git a/packages/wallets/src/evm/connectors/onekey/index.ts b/packages/wallets/src/evm/connectors/onekey/index.ts new file mode 100644 index 00000000000..310875d5767 --- /dev/null +++ b/packages/wallets/src/evm/connectors/onekey/index.ts @@ -0,0 +1,135 @@ +import { AsyncStorage } from "../../../core/AsyncStorage"; +import { + ConnectorNotFoundError, + ResourceUnavailableError, + RpcError, + UserRejectedRequestError, +} from "../../../lib/wagmi-core/errors"; +import { walletIds } from "../../constants/walletIds"; +import { InjectedConnector, InjectedConnectorOptions } from "../injected"; +import type { Chain } from "@thirdweb-dev/chains"; +import { utils } from "ethers"; +import { getInjectedOneKeyProvider } from "./getInjectedOneKeyProvider"; + +export type OneKeyConnectorOptions = InjectedConnectorOptions; + +type OneKeyWalletConnectorConstructorArg = { + chains?: Chain[]; + connectorStorage: AsyncStorage; + options?: OneKeyConnectorOptions; +}; + +export class OneKeyConnector extends InjectedConnector { + readonly id = walletIds.oneKey; + + constructor(arg: OneKeyWalletConnectorConstructorArg) { + const defaultOptions = { + name: "OneKey Wallet", + shimDisconnect: true, + shimChainChangedDisconnect: true, + getProvider: getInjectedOneKeyProvider, + }; + + const options = { + ...defaultOptions, + ...arg.options, + }; + + super({ + chains: arg.chains, + options, + connectorStorage: arg.connectorStorage, + }); + } + + /** + * Connect to injected OneKeyWallet provider + */ + async connect(options: { chainId?: number } = {}) { + try { + const provider = await this.getProvider(); + if (!provider) { + throw new ConnectorNotFoundError(); + } + + this.setupListeners(); + + // emit "connecting" event + this.emit("message", { type: "connecting" }); + + // Attempt to show wallet select prompt with `wallet_requestPermissions` when + // `shimDisconnect` is active and account is in disconnected state (flag in storage) + let account: string | null = null; + if ( + this.options?.shimDisconnect && + !Boolean(this.connectorStorage.getItem(this.shimDisconnectKey)) + ) { + account = await this.getAccount().catch(() => null); + const isConnected = !!account; + if (isConnected) { + // Attempt to show another prompt for selecting wallet if already connected + try { + await provider.request({ + method: "wallet_requestPermissions", + params: [{ eth_accounts: {} }], + }); + } catch (error) { + // Not all injected providers support `wallet_requestPermissions` (e.g. iOS). + // Only bubble up error if user rejects request + if (this.isUserRejectedRequestError(error)) { + throw new UserRejectedRequestError(error); + } + } + } + } + + // if account is not already set, request accounts and use the first account + if (!account) { + const accounts = await provider.request({ + method: "eth_requestAccounts", + }); + account = utils.getAddress(accounts[0] as string); + } + + // get currently connected chainId + let connectedChainId = await this.getChainId(); + // check if connected chain is unsupported + let isUnsupported = this.isChainUnsupported(connectedChainId); + + // if chainId is given, but does not match the currently connected chainId, switch to the given chainId + if (options.chainId && connectedChainId !== options.chainId) { + try { + await this.switchChain(options.chainId); + // recalculate the chainId and isUnsupported + connectedChainId = options.chainId; + isUnsupported = this.isChainUnsupported(options.chainId); + } catch (e) { + console.error(`Could not switch to chain id : ${options.chainId}`, e); + } + } + + // if shimDisconnect is enabled + if (this.options?.shimDisconnect) { + // add shimDisconnectKey in storage - this signals that connector is "connected" + await this.connectorStorage.setItem(this.shimDisconnectKey, "true"); + } + + const connectionInfo = { + chain: { id: connectedChainId, unsupported: isUnsupported }, + provider: provider, + account, + }; + + this.emit("connect", connectionInfo); + return connectionInfo; + } catch (error) { + if (this.isUserRejectedRequestError(error)) { + throw new UserRejectedRequestError(error); + } + if ((error as RpcError).code === -32002) { + throw new ResourceUnavailableError(error); + } + throw error; + } + } +} diff --git a/packages/wallets/src/evm/connectors/paper/index.ts b/packages/wallets/src/evm/connectors/paper/index.ts index d2ebcbdcf1a..c3c06974b01 100644 --- a/packages/wallets/src/evm/connectors/paper/index.ts +++ b/packages/wallets/src/evm/connectors/paper/index.ts @@ -10,7 +10,7 @@ import { import type { Chain } from "@thirdweb-dev/chains"; import type { Signer, providers } from "ethers"; import { utils } from "ethers"; -import { normalizeChainId } from "../../../lib/wagmi-core"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; import { walletIds } from "../../constants/walletIds"; import { Connector } from "../../interfaces/connector"; import { diff --git a/packages/wallets/src/evm/connectors/phantom/getInjectedPhantomProvider.ts b/packages/wallets/src/evm/connectors/phantom/getInjectedPhantomProvider.ts index 97ecccdd693..ea5f3dddfa1 100644 --- a/packages/wallets/src/evm/connectors/phantom/getInjectedPhantomProvider.ts +++ b/packages/wallets/src/evm/connectors/phantom/getInjectedPhantomProvider.ts @@ -8,6 +8,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedPhantomProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/rabby/getInjectedRabbyProvider.ts b/packages/wallets/src/evm/connectors/rabby/getInjectedRabbyProvider.ts index 6364667ed69..95bd04bb98c 100644 --- a/packages/wallets/src/evm/connectors/rabby/getInjectedRabbyProvider.ts +++ b/packages/wallets/src/evm/connectors/rabby/getInjectedRabbyProvider.ts @@ -7,6 +7,9 @@ declare global { } } +/** + * @internal + */ export function getInjectedRabbyProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/rainbow/getInjectedRainbowProvider.ts b/packages/wallets/src/evm/connectors/rainbow/getInjectedRainbowProvider.ts index 114dc5c3988..d8e2cb2d9a4 100644 --- a/packages/wallets/src/evm/connectors/rainbow/getInjectedRainbowProvider.ts +++ b/packages/wallets/src/evm/connectors/rainbow/getInjectedRainbowProvider.ts @@ -1,6 +1,9 @@ import { Ethereum } from "../injected/types"; import { assertWindowEthereum } from "../../utils/assertWindowEthereum"; +/** + * @internal + */ export function getInjectedRainbowProvider(): Ethereum | undefined { if (typeof window === "undefined") { return; diff --git a/packages/wallets/src/evm/connectors/safe/constants.ts b/packages/wallets/src/evm/connectors/safe/constants.ts index 4494979ea90..2ca403d4e4c 100644 --- a/packages/wallets/src/evm/connectors/safe/constants.ts +++ b/packages/wallets/src/evm/connectors/safe/constants.ts @@ -24,5 +24,8 @@ export const CHAIN_ID_TO_GNOSIS_SERVER_URL = { 1313161554: "https://safe-transaction-aurora.safe.global", } as const; +/** + * @internal + */ export const SafeSupportedChainsSet = /* @__PURE__ */ (() => new Set(Object.keys(CHAIN_ID_TO_GNOSIS_SERVER_URL).map(Number)))(); diff --git a/packages/wallets/src/evm/connectors/signer/index.ts b/packages/wallets/src/evm/connectors/signer/index.ts index cd279c1d99b..ce4da9cb085 100644 --- a/packages/wallets/src/evm/connectors/signer/index.ts +++ b/packages/wallets/src/evm/connectors/signer/index.ts @@ -1,4 +1,4 @@ -import { normalizeChainId } from "../../../lib/wagmi-core"; +import { normalizeChainId } from "../../../lib/wagmi-core/normalizeChainId"; import { ConnectParams, Connector } from "../../interfaces/connector"; import type { LocalWalletConnectionArgs } from "../../wallets/local-wallet"; import type { Chain } from "@thirdweb-dev/chains"; diff --git a/packages/wallets/src/evm/connectors/smart-wallet/index.ts b/packages/wallets/src/evm/connectors/smart-wallet/index.ts index b45662866fe..93227461f3e 100644 --- a/packages/wallets/src/evm/connectors/smart-wallet/index.ts +++ b/packages/wallets/src/evm/connectors/smart-wallet/index.ts @@ -359,6 +359,7 @@ export class SmartWalletConnector extends Connector { { targets: [], data: [], + values: [], }, // batched tx flag to avoid hitting the Router fallback method ); const receipt = await tx.wait(); @@ -590,6 +591,7 @@ export class SmartWalletConnector extends Connector { batchData: { targets, data, + values, }, }; } @@ -606,6 +608,7 @@ export class SmartWalletConnector extends Connector { batchData: { targets, data, + values, }, }; } diff --git a/packages/wallets/src/evm/connectors/smart-wallet/lib/base-api.ts b/packages/wallets/src/evm/connectors/smart-wallet/lib/base-api.ts index 67b10a45761..9a9e3a5dec4 100644 --- a/packages/wallets/src/evm/connectors/smart-wallet/lib/base-api.ts +++ b/packages/wallets/src/evm/connectors/smart-wallet/lib/base-api.ts @@ -31,6 +31,7 @@ import { Transaction, getDynamicFeeData } from "@thirdweb-dev/sdk"; export type BatchData = { targets: (string | undefined)[]; data: BytesLike[]; + values: BigNumberish[]; }; export interface BaseApiParams { @@ -201,6 +202,7 @@ export abstract class BaseAccountAPI { from: this.getAccountAddress(), to: batchData.targets[i], data: batchData.data[i], + value: batchData.values[i], }), ), ); @@ -210,6 +212,7 @@ export abstract class BaseAccountAPI { from: this.getAccountAddress(), to: detailsForUserOp.target, data: detailsForUserOp.data, + value: detailsForUserOp.value, }); } @@ -226,6 +229,7 @@ export abstract class BaseAccountAPI { from: this.entryPointAddress, to: this.getAccountAddress(), data: callData, + value: detailsForUserOp.value, })); } @@ -301,6 +305,7 @@ export abstract class BaseAccountAPI { } if (!maxFeePerGas) { maxFeePerGas = feeData.maxFeePerGas ?? undefined; + maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? undefined; const network = await this.provider.getNetwork(); const chainId = network.chainId; @@ -384,7 +389,7 @@ export abstract class BaseAccountAPI { */ async signUserOp(userOp: UserOperationStruct): Promise { const userOpHash = await this.getUserOpHash(userOp); - const signature = this.signUserOpHash(userOpHash); + const signature = await this.signUserOpHash(userOpHash); return { ...userOp, signature, @@ -414,7 +419,7 @@ export abstract class BaseAccountAPI { async getUserOpReceipt( userOpHash: string, timeout = 30000, - interval = 5000, + interval = 2000, ): Promise { const endtime = Date.now() + timeout; while (Date.now() < endtime) { diff --git a/packages/wallets/src/evm/connectors/smart-wallet/lib/erc4337-signer.ts b/packages/wallets/src/evm/connectors/smart-wallet/lib/erc4337-signer.ts index 09b0493e317..ee0f4118f38 100644 --- a/packages/wallets/src/evm/connectors/smart-wallet/lib/erc4337-signer.ts +++ b/packages/wallets/src/evm/connectors/smart-wallet/lib/erc4337-signer.ts @@ -6,6 +6,7 @@ import { BaseAccountAPI, BatchData } from "./base-api"; import type { ERC4337EthersProvider } from "./erc4337-provider"; import { HttpRpcClient } from "./http-rpc-client"; import { randomNonce } from "./utils"; +import { deepHexlify } from "@account-abstraction/utils"; export class ERC4337EthersSigner extends Signer { config: ClientConfig; @@ -150,9 +151,27 @@ Code: ${errorCode}`; } async signTransaction( - // eslint-disable-next-line @typescript-eslint/no-unused-vars transaction: utils.Deferrable, + batchData?: BatchData, ): Promise { - throw new Error("not implemented"); + const tx = await ethers.utils.resolveProperties(transaction); + await this.verifyAllNecessaryFields(tx); + + const multidimensionalNonce = randomNonce(); + const userOperation = await this.smartAccountAPI.createSignedUserOp( + { + target: tx.to || "", + data: tx.data?.toString() || "0x", + value: tx.value, + gasLimit: tx.gasLimit, + nonce: multidimensionalNonce, + }, + batchData, + ); + + const userOpString = JSON.stringify( + deepHexlify(await utils.resolveProperties(userOperation)), + ); + return userOpString; } } diff --git a/packages/wallets/src/evm/connectors/smart-wallet/utils.ts b/packages/wallets/src/evm/connectors/smart-wallet/utils.ts index 85ab001c922..52e4b247b4d 100644 --- a/packages/wallets/src/evm/connectors/smart-wallet/utils.ts +++ b/packages/wallets/src/evm/connectors/smart-wallet/utils.ts @@ -4,6 +4,8 @@ import { ThirdwebSDK, } from "@thirdweb-dev/sdk"; import { BytesLike } from "ethers"; +import { ENTRYPOINT_ADDRESS } from "./lib/constants"; +import { EntryPoint__factory } from "@account-abstraction/contracts"; export type AccessibleSmartWallets = { owned: string; @@ -118,3 +120,45 @@ export async function getSmartWalletAddress( ]); return accountAddress; } + +export async function getUserOpReceipt( + chain: ChainOrRpcUrl, + userOpHash: string, + timeout = 30000, + interval = 2000, + entryPointAddress?: string, +): Promise { + const readOnlySDK = getSDK(chain); + const entrypoint = await readOnlySDK.getContract( + entryPointAddress || ENTRYPOINT_ADDRESS, + EntryPoint__factory.abi, + ); + + // do a first check for the last 5000 blocks + const pastEvents = await entrypoint.events.getEvents("UserOperationEvent", { + fromBlock: -9000, // look at the last 9000 blocks + filters: { + userOpHash, + }, + }); + + if (pastEvents[0]) { + return pastEvents[0].transaction.transactionHash; + } + + // if not found, query the last 100 blocks every 2 seconds for the next 30 seconds + const endtime = Date.now() + timeout; + while (Date.now() < endtime) { + const events = await entrypoint.events.getEvents("UserOperationEvent", { + fromBlock: -100, + filters: { + userOpHash, + }, + }); + if (events[0]) { + return events[0].transaction.transactionHash; + } + await new Promise((resolve) => setTimeout(resolve, interval)); + } + return null; +} diff --git a/packages/wallets/src/evm/connectors/wallet-connect/index.ts b/packages/wallets/src/evm/connectors/wallet-connect/index.ts index c21054feef4..79e996243ba 100644 --- a/packages/wallets/src/evm/connectors/wallet-connect/index.ts +++ b/packages/wallets/src/evm/connectors/wallet-connect/index.ts @@ -4,14 +4,14 @@ import { ProviderRpcError, SwitchChainError, UserRejectedRequestError, - WagmiConnector, -} from "../../../lib/wagmi-core"; +} from "../../../lib/wagmi-core/errors"; import { type Chain } from "@thirdweb-dev/chains"; import type WalletConnectProvider from "@walletconnect/ethereum-provider"; import { providers, utils } from "ethers"; import { walletIds } from "../../constants/walletIds"; import { QRModalOptions } from "./qrModalOptions"; import { getValidPublicRPCUrl } from "../../utils/url"; +import { WagmiConnector } from "../../../lib/wagmi-connectors/WagmiConnector"; const chainsToRequest = new Set([1, 137, 10, 42161, 56]); @@ -82,6 +82,7 @@ export class WalletConnectConnector extends WagmiConnector< #initProviderPromise?: Promise; #storage: AsyncStorage; filteredChains: Chain[]; + showWalletConnectModal: boolean; constructor(config: { chains?: Chain[]; options: WalletConnectOptions }) { super({ @@ -97,6 +98,8 @@ export class WalletConnectConnector extends WagmiConnector< return chainsToRequest.has(c.chainId); }) : this.chains; + + this.showWalletConnectModal = this.options.qrcode !== false; } async connect({ chainId: chainIdP, pairingTopic }: ConnectConfig = {}) { @@ -323,12 +326,12 @@ export class WalletConnectConnector extends WagmiConnector< async #createProvider() { if (!this.#initProviderPromise && typeof window !== "undefined") { - this.#initProviderPromise = this.#initProvider(); + this.#initProviderPromise = this.initProvider(); } return this.#initProviderPromise; } - async #initProvider() { + async initProvider() { const { default: EthereumProvider, OPTIONAL_EVENTS, @@ -341,7 +344,7 @@ export class WalletConnectConnector extends WagmiConnector< if (defaultChain) { // EthereumProvider populates & deduplicates required methods and events internally this.#provider = await EthereumProvider.init({ - showQrModal: this.options.qrcode !== false, + showQrModal: this.showWalletConnectModal, projectId: this.options.projectId, optionalMethods: OPTIONAL_METHODS, optionalEvents: OPTIONAL_EVENTS, diff --git a/packages/wallets/src/evm/constants/dappMeta.ts b/packages/wallets/src/evm/constants/dappMeta.ts index 4b0a605caf2..bd267f1c47e 100644 --- a/packages/wallets/src/evm/constants/dappMeta.ts +++ b/packages/wallets/src/evm/constants/dappMeta.ts @@ -1,5 +1,8 @@ import { DAppMetaData } from "../../core/types/dAppMeta"; +/** + * @internal + */ export const DEFAULT_DAPP_META: DAppMetaData = { name: "thirdweb powered dApp", url: "https://thirdweb.com", diff --git a/packages/wallets/src/evm/constants/walletIds.ts b/packages/wallets/src/evm/constants/walletIds.ts index 4c0ff518a4d..dfe1fd6bc8e 100644 --- a/packages/wallets/src/evm/constants/walletIds.ts +++ b/packages/wallets/src/evm/constants/walletIds.ts @@ -19,6 +19,7 @@ export const walletIds = { walletConnect: "walletConnect", phantom: "phantom", okx: "okx", + oneKey: "oneKey", rabby: "rabby", // add new ids sorted alphabetically } as const; diff --git a/packages/wallets/src/evm/constants/wc.ts b/packages/wallets/src/evm/constants/wc.ts index 4cf501155e4..2f5c3e61b39 100644 --- a/packages/wallets/src/evm/constants/wc.ts +++ b/packages/wallets/src/evm/constants/wc.ts @@ -2,6 +2,7 @@ export const TW_WC_PROJECT_ID = "145769e410f16970a79ff77b2d89a1e0"; export const WC_RELAY_URL = "wss://relay.walletconnect.com"; /** + * @internal * Methods */ export const EIP155_SIGNING_METHODS = { diff --git a/packages/wallets/src/evm/index.ts b/packages/wallets/src/evm/index.ts index 871a159a46b..9839f8283ff 100644 --- a/packages/wallets/src/evm/index.ts +++ b/packages/wallets/src/evm/index.ts @@ -2,15 +2,16 @@ export { EIP155_SIGNING_METHODS } from "./constants/wc"; export { walletIds } from "./constants/walletIds"; -export { WagmiConnector } from "../lib/wagmi-connectors"; +export { WagmiConnector } from "../lib/wagmi-connectors/WagmiConnector"; export { AddChainError, ChainNotConfiguredError, ProviderRpcError, SwitchChainError, UserRejectedRequestError, - normalizeChainId, -} from "../lib/wagmi-core"; +} from "../lib/wagmi-core/errors"; +export { normalizeChainId } from "../lib/wagmi-core/normalizeChainId"; + export { DEFAULT_DAPP_META } from "./constants/dappMeta"; export type { EVMWallet } from "./interfaces"; export { Connector, WagmiAdapter } from "./interfaces/connector"; @@ -50,19 +51,30 @@ export * from "./wallets/engine"; export { OKXWallet, type OKXWalletOptions } from "./wallets/okx"; export { getInjectedOKXProvider } from "./connectors/okx/getInjectedOKXProvider"; -export { CoreWallet, type CoreWalletOptions } from "./wallets/core-wallet"; +export { + CoreWallet, + type CoreWalletOptions, + type CoreWalletAdditionalOptions, +} from "./wallets/core-wallet"; export { getInjectedCoreWalletProvider } from "./connectors/core-wallet/getInjectedCoreWalletProvider"; +export { OneKeyWallet, type OneKeyOptions } from "./wallets/onekey"; +export { getInjectedOneKeyProvider } from "./connectors/onekey/getInjectedOneKeyProvider"; export { CryptoDefiWallet, type CryptoDefiWalletOptions, + type CryptoDefiWalletAdditionalOptions, } from "./wallets/crypto-defi-wallet"; export { getInjectedCryptoDefiWalletProvider } from "./connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider"; export { RabbyWallet, type RabbyOptions } from "./wallets/rabby"; export { getInjectedRabbyProvider } from "./connectors/rabby/getInjectedRabbyProvider"; -export { Coin98Wallet, type Coin98Options } from "./wallets/coin98"; +export { + Coin98Wallet, + type Coin98Options, + type Coin98AdditionalOptions, +} from "./wallets/coin98"; export { getInjectedCoin98Provider } from "./connectors/coin98/getInjectedCoin98Provider"; export type { Chain } from "@thirdweb-dev/chains"; diff --git a/packages/wallets/src/evm/interfaces/connector.ts b/packages/wallets/src/evm/interfaces/connector.ts index 7c323ab8ff5..d3e94a4435c 100644 --- a/packages/wallets/src/evm/interfaces/connector.ts +++ b/packages/wallets/src/evm/interfaces/connector.ts @@ -1,7 +1,7 @@ import type { Chain } from "@thirdweb-dev/chains"; import type { Signer, providers } from "ethers"; import EventEmitter from "eventemitter3"; -import { WagmiConnector } from "../../lib/wagmi-core"; +import { WagmiConnector } from "../../lib/wagmi-connectors/WagmiConnector"; export abstract class Connector< // eslint-disable-next-line @typescript-eslint/ban-types diff --git a/packages/wallets/src/evm/utils/assertWindowEthereum.ts b/packages/wallets/src/evm/utils/assertWindowEthereum.ts index 7bde29c8b4c..f7e9846093f 100644 --- a/packages/wallets/src/evm/utils/assertWindowEthereum.ts +++ b/packages/wallets/src/evm/utils/assertWindowEthereum.ts @@ -4,6 +4,9 @@ interface WindowWithEthereum extends Window { ethereum: Ethereum; } +/** + * @internal + */ export function assertWindowEthereum(w: Window): w is WindowWithEthereum { - return typeof w !== "undefined" && !!w && "ethereum" in w; + return typeof w !== "undefined" && !!w && "ethereum" in w && !!w.ethereum; } diff --git a/packages/wallets/src/evm/wallets/coin98.ts b/packages/wallets/src/evm/wallets/coin98.ts index c2d971214ca..be6b8da72a1 100644 --- a/packages/wallets/src/evm/wallets/coin98.ts +++ b/packages/wallets/src/evm/wallets/coin98.ts @@ -7,7 +7,7 @@ import { walletIds } from "../constants/walletIds"; import { TW_WC_PROJECT_ID } from "../constants/wc"; import { getInjectedCoin98Provider } from "../connectors/coin98/getInjectedCoin98Provider"; -type Coin98AdditionalOptions = { +export type Coin98AdditionalOptions = { /** * Whether to open the default Wallet Connect QR code Modal for connecting to Coin98 app on mobile if Coin98 wallet is not injected when calling connect(). */ diff --git a/packages/wallets/src/evm/wallets/core-wallet.ts b/packages/wallets/src/evm/wallets/core-wallet.ts index 33ec9420ad3..8159aa5ecd1 100644 --- a/packages/wallets/src/evm/wallets/core-wallet.ts +++ b/packages/wallets/src/evm/wallets/core-wallet.ts @@ -7,7 +7,7 @@ import { walletIds } from "../constants/walletIds"; import { TW_WC_PROJECT_ID } from "../constants/wc"; import { getInjectedCoreWalletProvider } from "../connectors/core-wallet/getInjectedCoreWalletProvider"; -type CoreWalletAdditionalOptions = { +export type CoreWalletAdditionalOptions = { /** * Whether to open the default Wallet Connect QR code Modal for connecting to Core app on mobile if Core wallet is not injected when calling connect(). */ diff --git a/packages/wallets/src/evm/wallets/crypto-defi-wallet.ts b/packages/wallets/src/evm/wallets/crypto-defi-wallet.ts index 36ef9c10134..76e2d03414b 100644 --- a/packages/wallets/src/evm/wallets/crypto-defi-wallet.ts +++ b/packages/wallets/src/evm/wallets/crypto-defi-wallet.ts @@ -7,7 +7,7 @@ import { walletIds } from "../constants/walletIds"; import { TW_WC_PROJECT_ID } from "../constants/wc"; import { getInjectedCryptoDefiWalletProvider } from "../connectors/crypto-defi-wallet/getInjectedCryptoDefiWalletProvider"; -type CryptoDefiWalletAdditionalOptions = { +export type CryptoDefiWalletAdditionalOptions = { /** * Whether to open the default Wallet Connect QR code Modal for connecting to Defi app on mobile if Defi wallet is not injected when calling connect(). */ diff --git a/packages/wallets/src/evm/wallets/local-wallet.ts b/packages/wallets/src/evm/wallets/local-wallet.ts index bc36616e730..0ba339f2f83 100644 --- a/packages/wallets/src/evm/wallets/local-wallet.ts +++ b/packages/wallets/src/evm/wallets/local-wallet.ts @@ -510,6 +510,9 @@ function getEncryptor(encryption: EncryptOptions | undefined) { : noop; } +/** + * @internal + */ export function isValidPrivateKey(value: string) { return !!value.match(/^(0x)?[0-9a-f]{64}$/i); } diff --git a/packages/wallets/src/evm/wallets/onekey.ts b/packages/wallets/src/evm/wallets/onekey.ts new file mode 100644 index 00000000000..85be5de49ec --- /dev/null +++ b/packages/wallets/src/evm/wallets/onekey.ts @@ -0,0 +1,139 @@ +import type { WalletConnectConnector as WalletConnectConnectorType } from "../connectors/wallet-connect"; +import type { QRModalOptions } from "../connectors/wallet-connect/qrModalOptions"; +import { Connector, WagmiAdapter } from "../interfaces/connector"; +import { AbstractClientWallet, WalletOptions } from "./base"; +import type { OneKeyConnector as OneKeyConnectorType } from "../connectors/onekey"; +import { walletIds } from "../constants/walletIds"; +import { TW_WC_PROJECT_ID } from "../constants/wc"; +import { getInjectedOneKeyProvider } from "../connectors/onekey/getInjectedOneKeyProvider"; + +type OneKeyAdditionalOptions = { + /** + * Whether to open the default Wallet Connect QR code Modal for connecting to OneKey app on mobile if OneKey wallet is not injected when calling connect(). + */ + qrcode?: boolean; + + /** + * When connecting OneKey wallet using the QR Code - Wallet Connect connector is used which requires a project id. + * This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com. + * + * https://docs.walletconnect.com/2.0/web3modal/options#projectid-required + */ + projectId?: string; + + /** + * options to customize the Wallet Connect QR Code Modal ( only relevant when qrcode is true ) + * + * https://docs.walletconnect.com/2.0/web3modal/options + */ + qrModalOptions?: QRModalOptions; +}; + +export type OneKeyOptions = WalletOptions; + +type ConnectWithQrCodeArgs = { + chainId?: number; + onQrCodeUri: (uri: string) => void; + onConnected: (accountAddress: string) => void; +}; + +export class OneKeyWallet extends AbstractClientWallet { + connector?: Connector; + walletConnectConnector?: WalletConnectConnectorType; + OneKeyConnector?: OneKeyConnectorType; + isInjected: boolean; + + static id = walletIds.coreWallet as string; + + public get walletName() { + return "Core wallet" as const; + } + + constructor(options: OneKeyOptions) { + super(OneKeyWallet.id, options); + this.isInjected = !!getInjectedOneKeyProvider(); + } + + protected async getConnector(): Promise { + if (!this.connector) { + // if OneKey wallet is injected, use the injected connector + // otherwise, use the wallet connect connector for using the OneKey app on mobile via QR code scan + + if (this.isInjected) { + // import the connector dynamically + const { OneKeyConnector } = await import("../connectors/onekey"); + this.OneKeyConnector = new OneKeyConnector({ + chains: this.chains, + connectorStorage: this.walletStorage, + options: { + shimDisconnect: true, + }, + }); + + this.connector = new WagmiAdapter(this.OneKeyConnector); + } else { + const { WalletConnectConnector } = await import( + "../connectors/wallet-connect" + ); + + const walletConnectConnector = new WalletConnectConnector({ + chains: this.chains, + options: { + projectId: this.options?.projectId || TW_WC_PROJECT_ID, // TODO, + storage: this.walletStorage, + qrcode: this.options?.qrcode, + dappMetadata: this.dappMetadata, + qrModalOptions: this.options?.qrModalOptions, + }, + }); + + walletConnectConnector.getProvider().then((provider) => { + provider.signer.client.on("session_request_sent", () => { + this.emit("wc_session_request_sent"); + }); + }); + + // need to save this for getting the QR code URI + this.walletConnectConnector = walletConnectConnector; + this.connector = new WagmiAdapter(walletConnectConnector); + } + } + + return this.connector; + } + + /** + * connect to wallet with QR code + * + * @example + * ```typescript + * wallet.connectWithQrCode({ + * chainId: 1, + * onQrCodeUri(qrCodeUri) { + * // render the QR code with `qrCodeUri` + * }, + * onConnected(accountAddress) { + * // update UI to show connected state + * }, + * }) + * ``` + */ + async connectWithQrCode(options: ConnectWithQrCodeArgs) { + await this.getConnector(); + const wcConnector = this.walletConnectConnector; + + if (!wcConnector) { + throw new Error("WalletConnect connector not found"); + } + + const wcProvider = await wcConnector.getProvider(); + + // set a listener for display_uri event + wcProvider.on("display_uri", (uri) => { + options.onQrCodeUri(uri); + }); + + // trigger connect flow + this.connect({ chainId: options.chainId }).then(options.onConnected); + } +} diff --git a/packages/wallets/src/evm/wallets/smart-wallet.ts b/packages/wallets/src/evm/wallets/smart-wallet.ts index 1c8dbeb4e57..e2a104f15dd 100644 --- a/packages/wallets/src/evm/wallets/smart-wallet.ts +++ b/packages/wallets/src/evm/wallets/smart-wallet.ts @@ -26,6 +26,7 @@ export { getAllSmartWallets, getSmartWalletAddress, isSmartWalletDeployed, + getUserOpReceipt, } from "../connectors/smart-wallet/utils"; export type { PaymasterAPI } from "@account-abstraction/sdk"; diff --git a/packages/wallets/src/evm/wallets/wallet-connect-v1.ts b/packages/wallets/src/evm/wallets/wallet-connect-v1.ts index a22b9a667fa..b15888be53a 100644 --- a/packages/wallets/src/evm/wallets/wallet-connect-v1.ts +++ b/packages/wallets/src/evm/wallets/wallet-connect-v1.ts @@ -1,6 +1,7 @@ import { WalletConnect } from "./wallet-connect"; /** + * @internal * @deprecated Use `WalletConnect` instead * * The WalletConnect v1.0 protocol has been shut down and no longer works. diff --git a/packages/wallets/src/evm/wallets/wallet-connect.ts b/packages/wallets/src/evm/wallets/wallet-connect.ts index eccf4c4a8d2..ab0d47d6fa7 100644 --- a/packages/wallets/src/evm/wallets/wallet-connect.ts +++ b/packages/wallets/src/evm/wallets/wallet-connect.ts @@ -1,4 +1,4 @@ -import type { WagmiConnectorData } from "../../lib/wagmi-core"; +import type { WagmiConnectorData } from "../../lib/wagmi-connectors/WagmiConnector"; import type { WalletConnectConnector } from "../connectors/wallet-connect"; import { QRModalOptions } from "../connectors/wallet-connect/qrModalOptions"; import { Connector, WagmiAdapter } from "../interfaces/connector"; @@ -166,6 +166,8 @@ export class WalletConnect extends AbstractClientWallet { throw new Error("WalletConnect connector not found"); } + wcConnector.showWalletConnectModal = false; + const wcProvider = await wcConnector.getProvider(); wcProvider.on("display_uri", (uri) => { @@ -175,4 +177,19 @@ export class WalletConnect extends AbstractClientWallet { // trigger connect flow this.connect({ chainId: options.chainId }).then(options.onConnected); } + + async connectWithModal(options?: { chainId?: number }) { + await this.getConnector(); + const wcConnector = this.#walletConnectConnector; + + if (!wcConnector) { + throw new Error("WalletConnect connector not found"); + } + + wcConnector.showWalletConnectModal = true; + + await wcConnector.initProvider(); + + await this.connect({ chainId: options?.chainId }); + } } diff --git a/packages/wallets/src/lib/wagmi-connectors/index.ts b/packages/wallets/src/lib/wagmi-connectors/index.ts deleted file mode 100644 index c508e8c6585..00000000000 --- a/packages/wallets/src/lib/wagmi-connectors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { WagmiConnector, type WagmiConnectorData } from "./WagmiConnector"; diff --git a/packages/wallets/src/lib/wagmi-core/errors.ts b/packages/wallets/src/lib/wagmi-core/errors.ts index 983245d57c2..c1cf1159729 100644 --- a/packages/wallets/src/lib/wagmi-core/errors.ts +++ b/packages/wallets/src/lib/wagmi-core/errors.ts @@ -1,4 +1,4 @@ -import type { WagmiConnector } from "../wagmi-connectors"; +import type { WagmiConnector } from "../wagmi-connectors/WagmiConnector"; import type { utils } from "ethers"; /** @@ -37,6 +37,7 @@ export class RpcError extends Error { } /** + * @internal * Error subclass implementing Ethereum Provider errors per EIP-1193. * @see https://eips.ethereum.org/EIPS/eip-1193 */ @@ -70,11 +71,17 @@ export class ProviderRpcError extends RpcError { } } +/** + * @internal + */ export class AddChainError extends Error { name = "AddChainError"; message = "Error adding chain"; } +/** + * @internal + */ export class ChainNotConfiguredError extends Error { name = "ChainNotConfigured"; @@ -101,7 +108,9 @@ export class ResourceUnavailableError extends RpcError { super("Resource unavailable", { cause, code: -32002 }); } } - +/** + * @internal + */ export class SwitchChainError extends ProviderRpcError { name = "SwitchChainError"; @@ -109,7 +118,9 @@ export class SwitchChainError extends ProviderRpcError { super("Error switching chain", { cause, code: 4902 }); } } - +/** + * @internal + */ export class SwitchChainNotSupportedError extends Error { name = "SwitchChainNotSupportedError"; @@ -117,7 +128,9 @@ export class SwitchChainNotSupportedError extends Error { super(`"${connector.name}" does not support programmatic chain switching.`); } } - +/** + * @internal + */ export class UserRejectedRequestError extends ProviderRpcError { name = "UserRejectedRequestError"; @@ -126,6 +139,9 @@ export class UserRejectedRequestError extends ProviderRpcError { } } +/** + * @internal + */ // Ethers does not have an error type so we can use this for casting // https://github.com/ethers-io/ethers.js/blob/main/packages/logger/src.ts/index.ts#L268 export type EthersError = Error & { diff --git a/packages/wallets/src/lib/wagmi-core/index.ts b/packages/wallets/src/lib/wagmi-core/index.ts deleted file mode 100644 index f7a76364559..00000000000 --- a/packages/wallets/src/lib/wagmi-core/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export { normalizeChainId } from "./normalizeChainId"; - -export { - RpcError, - ProviderRpcError, - AddChainError, - ChainNotConfiguredError, - ConnectorNotFoundError, - ResourceUnavailableError, - SwitchChainError, - SwitchChainNotSupportedError, - UserRejectedRequestError, -} from "./errors"; -export type { EthersError } from "./errors"; - -export { WagmiConnector, type WagmiConnectorData } from "../wagmi-connectors"; diff --git a/packages/wallets/src/lib/wagmi-core/normalizeChainId.ts b/packages/wallets/src/lib/wagmi-core/normalizeChainId.ts index 09f0b52ce73..479fbb89808 100644 --- a/packages/wallets/src/lib/wagmi-core/normalizeChainId.ts +++ b/packages/wallets/src/lib/wagmi-core/normalizeChainId.ts @@ -1,3 +1,6 @@ +/** + * @internal + */ export function normalizeChainId(chainId: string | number | bigint) { if (typeof chainId === "string") { return Number.parseInt( diff --git a/packages/wallets/typedoc.js b/packages/wallets/typedoc.js deleted file mode 100644 index 376c4aedcc2..00000000000 --- a/packages/wallets/typedoc.js +++ /dev/null @@ -1,29 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires, better-tree-shaking/no-top-level-side-effects -const TypeDoc = require("typedoc"); - -async function main() { - // Application.bootstrap also exists, which will not load plugins - // Also accepts an array of option readers if you want to disable - // TypeDoc's tsconfig.json/package.json/typedoc.json option readers - const app = await TypeDoc.Application.bootstrapWithPlugins({ - entryPoints: ["src/index.ts"], - excludeInternal: true, - externalPattern: ["**/node_modules/**"], - exclude: ["**/node_modules/**"], - }); - - const project = await app.convert(); - - if (project) { - // Project may not have converted correctly - const outputDir = "typedoc/"; - - // Rendered docs - await app.generateDocs(project, outputDir); - // Alternatively generate JSON output - await app.generateJson(project, outputDir + "/documentation.json"); - } -} - -// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects -main(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ef6518453f..0ec53ad151e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -513,9 +513,30 @@ importers: benchmark: specifier: ^2.1.4 version: 2.1.4 + circomlibjs: + specifier: ^0.1.7 + version: 0.1.7 + crypto: + specifier: 0.0.3 + version: 0.0.3 eslint-config-thirdweb: specifier: workspace:* version: link:../eslint-config-thirdweb + ethereum-cryptography: + specifier: ^1.0.3 + version: 1.2.0 + ethereumjs-util: + specifier: ^7.0.9 + version: 7.1.5 + keccak256: + specifier: ^1.0.6 + version: 1.0.6 + sha1: + specifier: ^1.1.1 + version: 1.1.1 + tape: + specifier: ^4.9.2 + version: 4.17.0 typescript: specifier: ^5.1.6 version: 5.1.6 @@ -554,11 +575,14 @@ importers: specifier: ^0.1.9 version: 0.1.9 '@radix-ui/react-dialog': - specifier: ^1.0.4 - version: 1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + specifier: ^1.0.5 + version: 1.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-dropdown-menu': specifier: ^2.0.5 version: 2.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-focus-scope': + specifier: ^1.0.4 + version: 1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-icons': specifier: ^1.3.0 version: 1.3.0(react@18.2.0) @@ -698,15 +722,12 @@ importers: react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) - rimraf: - specifier: ^3.0.2 - version: 3.0.2 stream: specifier: npm:stream-browserify@^3.0.0 version: /stream-browserify@3.0.0 - typedoc: - specifier: ^0.25.2 - version: 0.25.2(typescript@5.1.6) + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 @@ -819,6 +840,9 @@ importers: react: specifier: ^18.2.0 version: 18.2.0 + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 @@ -1010,9 +1034,9 @@ importers: rimraf: specifier: ^3.0.2 version: 3.0.2 - typedoc: - specifier: ^0.25.2 - version: 0.25.2(typescript@5.1.6) + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 @@ -1231,9 +1255,9 @@ importers: rimraf: specifier: ^3.0.2 version: 3.0.2 - typedoc: - specifier: ^0.25.2 - version: 0.25.2(typescript@5.1.6) + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 @@ -1371,15 +1395,28 @@ importers: rimraf: specifier: ^3.0.2 version: 3.0.2 - typedoc: - specifier: ^0.25.2 - version: 0.25.2(typescript@5.1.6) + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 packages/tw-tsconfig: {} + packages/typedoc-gen: + dependencies: + typedoc: + specifier: ^0.25.2 + version: 0.25.2(typescript@5.1.6) + devDependencies: + prettier: + specifier: ^3.0.0 + version: 3.0.0 + tsup: + specifier: ^6.7.0 + version: 6.7.0(typescript@5.1.6) + packages/unity-js-bridge: dependencies: '@thirdweb-dev/auth': @@ -1588,9 +1625,9 @@ importers: tweetnacl: specifier: ^1.0.3 version: 1.0.3 - typedoc: - specifier: ^0.25.2 - version: 0.25.2(typescript@5.1.6) + typedoc-gen: + specifier: workspace:* + version: link:../typedoc-gen typescript: specifier: ^5.1.6 version: 5.1.6 @@ -8824,6 +8861,20 @@ packages: '@lit-labs/ssr-dom-shim': 1.0.0 dev: false + /@ljharb/resumer@0.0.1: + resolution: {integrity: sha512-skQiAOrCfO7vRTq53cxznMpks7wS1va95UCidALlOVWqvBAzwPVErwizDwoMqNVMEn1mDq0utxZd02eIrvF1lw==} + engines: {node: '>= 0.4'} + dependencies: + '@ljharb/through': 2.3.11 + dev: true + + /@ljharb/through@2.3.11: + resolution: {integrity: sha512-ccfcIDlogiXNq5KcbAwbaO7lMh3Tm1i3khMPYpxlK8hH/W53zN81KM9coerRLOnTGu3nfXIniAmQbRI9OxbC0w==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + dev: true + /@magic-ext/connect@6.7.2: resolution: {integrity: sha512-b56mYYzgeXmRzZ8DgsUV6hFKFidaoRJvibUgcRwSuGElDdQxuhkz6FUyTLLS0zGbGdg4lfa7F1J/II1NrxA+lQ==} deprecated: Connect extension has been merged to magic-sdk, please download the latest magic-sdk to unlock more features @@ -10137,8 +10188,8 @@ packages: react: 18.2.0 dev: false - /@radix-ui/react-dialog@1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-hJtRy/jPULGQZceSAP2Re6/4NpKo8im6V8P2hUqZsdFiSL8l35kYsw3qbRI6Ay5mQd2+wlLqje770eq+RJ3yZg==} + /@radix-ui/react-dialog@1.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-GjWJX/AUpB703eEBanuBnIWdIXg6NvJFCXcNlSZk4xdszCdhrJgBoUd1cGk67vFO+WdA2pfI/plOpqz/5GUP6Q==} peerDependencies: '@types/react': '*' '@types/react-dom': '*' @@ -10154,11 +10205,11 @@ packages: '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.17)(react@18.2.0) '@radix-ui/react-context': 1.0.1(@types/react@18.2.17)(react@18.2.0) - '@radix-ui/react-dismissable-layer': 1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-dismissable-layer': 1.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-focus-guards': 1.0.1(@types/react@18.2.17)(react@18.2.0) - '@radix-ui/react-focus-scope': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-focus-scope': 1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-id': 1.0.1(@types/react@18.2.17)(react@18.2.0) - '@radix-ui/react-portal': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-portal': 1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-presence': 1.0.1(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-slot': 1.0.2(@types/react@18.2.17)(react@18.2.0) @@ -10210,6 +10261,31 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /@radix-ui/react-dismissable-layer@1.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-aJeDjQhywg9LBu2t/At58hCvr7pEm0o2Ke1x33B+MhjNmmZ17sy4KImo0KPLgsnc/zN7GPdce8Cnn0SWvwZO7g==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@babel/runtime': 7.22.6 + '@radix-ui/primitive': 1.0.1 + '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.17)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.17)(react@18.2.0) + '@radix-ui/react-use-escape-keydown': 1.0.3(@types/react@18.2.17)(react@18.2.0) + '@types/react': 18.2.17 + '@types/react-dom': 18.2.7 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-dropdown-menu@2.0.5(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-xdOrZzOTocqqkCkYo8yRPCib5OkTkqN7lqNCdxwPOdE466DOaNl4N8PkUIlsXthQvW5Wwkd+aEmWpfWlBoDPEw==} peerDependencies: @@ -10274,6 +10350,29 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /@radix-ui/react-focus-scope@1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-sL04Mgvf+FmyvZeYfNu1EPAaaxD+aw7cYeIB9L9Fvq8+urhltTRaEo5ysKOpHuKPclsZcSUMKlN05x4u+CINpA==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@babel/runtime': 7.22.6 + '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.17)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.17)(react@18.2.0) + '@types/react': 18.2.17 + '@types/react-dom': 18.2.7 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-icons@1.3.0(react@18.2.0): resolution: {integrity: sha512-jQxj/0LKgp+j9BiTXz3O3sgs26RNet2iLWmsPyRz2SIcR4q/4SbazXfnYwbAr+vLYKSfc7qxzyGQA1HLlYiuNw==} peerDependencies: @@ -10421,6 +10520,27 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /@radix-ui/react-portal@1.0.4(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-Qki+C/EuGUVCQTOTD5vzJzJuMUlewbzuKyUy+/iHM2uwGiru9gZeBJtHAPKAEkB5KWGi9mP/CHKcY0wt1aW45Q==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@babel/runtime': 7.22.6 + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0) + '@types/react': 18.2.17 + '@types/react-dom': 18.2.7 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-presence@1.0.1(@types/react-dom@18.2.7)(@types/react@18.2.17)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-UXLW4UAbIY5ZjcvzjfRFo5gxva8QirC9hF7wRE4U5gz+TP0DbRk+//qyuAQ1McDxBt1xNMBTaciFGvEmJvAZCg==} peerDependencies: @@ -11168,7 +11288,7 @@ packages: dependencies: '@noble/hashes': 1.2.0 '@noble/secp256k1': 1.7.1 - '@scure/base': 1.1.1 + '@scure/base': 1.1.3 dev: true /@scure/bip32@1.3.2: @@ -11183,7 +11303,7 @@ packages: resolution: {integrity: sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg==} dependencies: '@noble/hashes': 1.2.0 - '@scure/base': 1.1.1 + '@scure/base': 1.1.3 dev: true /@scure/bip39@1.2.1: @@ -14123,7 +14243,7 @@ packages: /ansi-sequence-parser@1.1.1: resolution: {integrity: sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==} - dev: true + dev: false /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} @@ -14230,7 +14350,7 @@ packages: /array-buffer-byte-length@1.0.0: resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 is-array-buffer: 3.0.2 /array-each@1.0.1: @@ -14306,6 +14426,19 @@ packages: es-shim-unscopables: 1.0.0 get-intrinsic: 1.2.0 + /arraybuffer.prototype.slice@1.0.2: + resolution: {integrity: sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==} + engines: {node: '>= 0.4'} + dependencies: + array-buffer-byte-length: 1.0.0 + call-bind: 1.0.5 + define-properties: 1.2.0 + es-abstract: 1.22.3 + get-intrinsic: 1.2.2 + is-array-buffer: 3.0.2 + is-shared-array-buffer: 1.0.2 + dev: true + /arrify@1.0.1: resolution: {integrity: sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==} engines: {node: '>=0.10.0'} @@ -14505,6 +14638,10 @@ packages: dependencies: deep-equal: 2.2.0 + /b4a@1.6.4: + resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==} + dev: true + /babel-core@7.0.0-bridge.0(@babel/core@7.22.9): resolution: {integrity: sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==} peerDependencies: @@ -14980,6 +15117,30 @@ packages: readable-stream: 3.6.2 dev: true + /blake-hash@2.0.0: + resolution: {integrity: sha512-Igj8YowDu1PRkRsxZA7NVkdFNxH5rKv5cpLxQ0CVXSIA77pVYwCPRQJ2sMew/oneUpfuYRyjG6r8SmmmnbZb1w==} + engines: {node: '>= 10'} + requiresBuild: true + dependencies: + node-addon-api: 3.2.1 + node-gyp-build: 4.6.0 + readable-stream: 3.6.2 + dev: true + + /blake2b-wasm@2.4.0: + resolution: {integrity: sha512-S1kwmW2ZhZFFFOghcx73+ZajEfKBqhP82JMssxtLVMxlaPea1p9uoLiUZ5WYyHn0KddwbLc+0vh4wR0KBNoT5w==} + dependencies: + b4a: 1.6.4 + nanoassert: 2.0.0 + dev: true + + /blake2b@2.1.4: + resolution: {integrity: sha512-AyBuuJNI64gIvwx13qiICz6H6hpmjvYS5DGkG6jbXMOT8Z3WUJ3V1X0FlhIoT1b/5JtHE3ki+xjtMvu1nn+t9A==} + dependencies: + blake2b-wasm: 2.4.0 + nanoassert: 2.0.0 + dev: true + /blakejs@1.2.1: resolution: {integrity: sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==} @@ -15474,6 +15635,13 @@ packages: function-bind: 1.1.1 get-intrinsic: 1.2.0 + /call-bind@1.0.5: + resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==} + dependencies: + function-bind: 1.1.2 + get-intrinsic: 1.2.2 + set-function-length: 1.1.1 + /caller-callsite@2.0.0: resolution: {integrity: sha512-JuG3qI4QOftFsZyOn1qq87fq5grLIyk1JYd5lJmdA+fG7aQ9pA/i3JIJGcO3q0MrRcHlOt1U+ZeHW8Dq9axALQ==} engines: {node: '>=4'} @@ -15716,6 +15884,18 @@ packages: inherits: 2.0.4 safe-buffer: 5.2.1 + /circomlibjs@0.1.7: + resolution: {integrity: sha512-GRAUoAlKAsiiTa+PA725G9RmEmJJRc8tRFxw/zKktUxlQISGznT4hH4ESvW8FNTsrGg/nNd06sGP/Wlx0LUHVg==} + dependencies: + blake-hash: 2.0.0 + blake2b: 2.1.4 + ethers: 5.7.2 + ffjavascript: 0.2.62 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: true + /cjs-module-lexer@1.2.2: resolution: {integrity: sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==} @@ -16002,7 +16182,7 @@ packages: - supports-color /concat-map@0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} /config-chain@1.1.13: resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==} @@ -16283,6 +16463,11 @@ packages: type-fest: 1.4.0 dev: false + /crypto@0.0.3: + resolution: {integrity: sha512-Q6Ka98WcvWXXg+9cnqd3jHpTSIOaH6/q0m/bESMfQo/0uFxy6e/7EqVS4JdaWx9qLdqV56tDufy2b12dj7BHJg==} + deprecated: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in. + dev: true + /css-blank-pseudo@3.0.3(postcss@8.4.21): resolution: {integrity: sha512-VS90XWtsHGqoM0t4KpH053c4ehxZ2E6HtGI7x68YFV0pTo/QmkV/YFA+NnlvK8guxZVNWGQhVNJGC39Q8XF4OQ==} engines: {node: ^12 || ^14 || >=16} @@ -16671,6 +16856,18 @@ packages: sort-any: 2.0.0 dev: true + /deep-equal@1.1.2: + resolution: {integrity: sha512-5tdhKF6DbU7iIzrIOa1AOUt39ZRm13cmL1cGEh//aqR8x9+tNfbywRf0n5FD/18OKMdo7DNEtrX2t22ZAkI+eg==} + engines: {node: '>= 0.4'} + dependencies: + is-arguments: 1.1.1 + is-date-object: 1.0.5 + is-regex: 1.1.4 + object-is: 1.1.5 + object-keys: 1.1.1 + regexp.prototype.flags: 1.5.1 + dev: true + /deep-equal@2.2.0: resolution: {integrity: sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==} dependencies: @@ -16737,6 +16934,14 @@ packages: resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} engines: {node: '>=10'} + /define-data-property@1.1.1: + resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.0 + /define-lazy-prop@2.0.0: resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} engines: {node: '>=8'} @@ -16769,7 +16974,6 @@ packages: /defined@1.0.1: resolution: {integrity: sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==} - dev: false /del@6.1.1: resolution: {integrity: sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg==} @@ -17075,6 +17279,13 @@ packages: engines: {node: '>=10'} dev: false + /dotignore@0.1.2: + resolution: {integrity: sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw==} + hasBin: true + dependencies: + minimatch: 3.1.2 + dev: true + /duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: false @@ -17285,6 +17496,51 @@ packages: unbox-primitive: 1.0.2 which-typed-array: 1.1.9 + /es-abstract@1.22.3: + resolution: {integrity: sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA==} + engines: {node: '>= 0.4'} + dependencies: + array-buffer-byte-length: 1.0.0 + arraybuffer.prototype.slice: 1.0.2 + available-typed-arrays: 1.0.5 + call-bind: 1.0.5 + es-set-tostringtag: 2.0.1 + es-to-primitive: 1.2.1 + function.prototype.name: 1.1.6 + get-intrinsic: 1.2.2 + get-symbol-description: 1.0.0 + globalthis: 1.0.3 + gopd: 1.0.1 + has-property-descriptors: 1.0.0 + has-proto: 1.0.1 + has-symbols: 1.0.3 + hasown: 2.0.0 + internal-slot: 1.0.5 + is-array-buffer: 3.0.2 + is-callable: 1.2.7 + is-negative-zero: 2.0.2 + is-regex: 1.1.4 + is-shared-array-buffer: 1.0.2 + is-string: 1.0.7 + is-typed-array: 1.1.12 + is-weakref: 1.0.2 + object-inspect: 1.13.1 + object-keys: 1.1.1 + object.assign: 4.1.4 + regexp.prototype.flags: 1.5.1 + safe-array-concat: 1.0.1 + safe-regex-test: 1.0.0 + string.prototype.trim: 1.2.8 + string.prototype.trimend: 1.0.7 + string.prototype.trimstart: 1.0.7 + typed-array-buffer: 1.0.0 + typed-array-byte-length: 1.0.0 + typed-array-byte-offset: 1.0.0 + typed-array-length: 1.0.4 + unbox-primitive: 1.0.2 + which-typed-array: 1.1.13 + dev: true + /es-array-method-boxes-properly@1.0.0: resolution: {integrity: sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==} dev: false @@ -17314,7 +17570,7 @@ packages: resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} engines: {node: '>= 0.4'} dependencies: - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.2 has: 1.0.3 has-tostringtag: 1.0.0 @@ -17909,7 +18165,7 @@ packages: minimatch: 3.1.2 object.values: 1.1.6 resolve: 1.22.1 - semver: 7.5.4 + semver: 7.5.3 tsconfig-paths: 3.14.2 transitivePeerDependencies: - eslint-import-resolver-typescript @@ -18420,7 +18676,6 @@ packages: create-hash: 1.2.0 ethereum-cryptography: 0.1.3 rlp: 2.2.7 - dev: false /ethers-aws-kms-signer@1.3.2: resolution: {integrity: sha512-A/xsjCtUGXybpo7imThn4wWcOazHKQi9wnfs9ArPrgp4TmD7dH0bw0FsX71rr9QWsP6RCj0FAGsAxCKNWgEP/g==} @@ -19080,6 +19335,14 @@ packages: /fetch-retry@4.1.1: resolution: {integrity: sha512-e6eB7zN6UBSwGVwrbWVH+gdLnkW9WwHhmq2YDK1Sh30pzx1onRVGBvogTlUeWxwTa+L86NYdo4hFkh7O8ZjSnA==} + /ffjavascript@0.2.62: + resolution: {integrity: sha512-uJ7MTrdzhX/3f+hxn0XhdXbJCqYZJSBB6y2/ui4t21vKYVjyTMlU80pPXu40ir6qpqbrdzUeKdlOdJ0aFG9UNA==} + dependencies: + wasmbuilder: 0.0.16 + wasmcurves: 0.2.2 + web-worker: 1.2.0 + dev: true + /fflate@0.7.3: resolution: {integrity: sha512-0Zz1jOzJWERhyhsimS54VTqOteCNwRtIlh8isdL0AXLo0g7xNTfTL7oWrkmCnPhZGocKIkWHBistBrrpoNH3aw==} dev: false @@ -19545,6 +19808,9 @@ packages: /function-bind@1.1.1: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + /function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + /function.prototype.name@1.1.5: resolution: {integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==} engines: {node: '>= 0.4'} @@ -19554,6 +19820,16 @@ packages: es-abstract: 1.21.2 functions-have-names: 1.2.3 + /function.prototype.name@1.1.6: + resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.5 + define-properties: 1.2.0 + es-abstract: 1.22.3 + functions-have-names: 1.2.3 + dev: true + /functional-red-black-tree@1.0.1: resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==} dev: true @@ -19608,6 +19884,14 @@ packages: has: 1.0.3 has-symbols: 1.0.3 + /get-intrinsic@1.2.2: + resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==} + dependencies: + function-bind: 1.1.2 + has-proto: 1.0.1 + has-symbols: 1.0.3 + hasown: 2.0.0 + /get-nonce@1.0.1: resolution: {integrity: sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==} engines: {node: '>=6'} @@ -19655,8 +19939,8 @@ packages: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.0 + call-bind: 1.0.5 + get-intrinsic: 1.2.2 /get-tsconfig@4.4.0: resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==} @@ -20166,6 +20450,12 @@ packages: type-fest: 0.8.1 dev: true + /hasown@2.0.0: + resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} + engines: {node: '>= 0.4'} + dependencies: + function-bind: 1.1.2 + /he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true @@ -20649,9 +20939,9 @@ packages: /is-array-buffer@3.0.2: resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==} dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.0 - is-typed-array: 1.1.10 + call-bind: 1.0.5 + get-intrinsic: 1.2.2 + is-typed-array: 1.1.12 /is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} @@ -20671,7 +20961,7 @@ packages: resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} engines: {node: '>= 0.4'} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 has-tostringtag: 1.0.0 /is-buffer@1.1.6: @@ -20705,6 +20995,12 @@ packages: dependencies: has: 1.0.3 + /is-core-module@2.13.1: + resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} + dependencies: + hasown: 2.0.0 + dev: true + /is-data-descriptor@0.1.4: resolution: {integrity: sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==} engines: {node: '>=0.10.0'} @@ -20957,7 +21253,7 @@ packages: /is-shared-array-buffer@1.0.2: resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 /is-stream-ended@0.1.4: resolution: {integrity: sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==} @@ -21005,6 +21301,12 @@ packages: gopd: 1.0.1 has-tostringtag: 1.0.0 + /is-typed-array@1.1.12: + resolution: {integrity: sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==} + engines: {node: '>= 0.4'} + dependencies: + which-typed-array: 1.1.13 + /is-typedarray@1.0.0: resolution: {integrity: sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==} @@ -21036,7 +21338,7 @@ packages: /is-weakref@1.0.2: resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 /is-weakset@2.0.2: resolution: {integrity: sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==} @@ -22496,7 +22798,7 @@ packages: /jsonc-parser@3.2.0: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} - dev: true + dev: false /jsonfile@2.4.0: resolution: {integrity: sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==} @@ -22564,6 +22866,14 @@ packages: safe-buffer: 5.2.1 dev: false + /keccak256@1.0.6: + resolution: {integrity: sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw==} + dependencies: + bn.js: 5.2.1 + buffer: 6.0.3 + keccak: 3.0.3 + dev: true + /keccak@3.0.3: resolution: {integrity: sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ==} engines: {node: '>=10.0.0'} @@ -23006,7 +23316,7 @@ packages: /lunr@2.3.9: resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} - dev: true + dev: false /magic-sdk@13.6.2: resolution: {integrity: sha512-ZjIZM2gqaxxOR+ZAyKVw50akjfdyo0q5hZzrCMiqyCqh4BXulU7yqHgUa/5/nJ+0/4xBgUejoOcDEm+UdmzLjA==} @@ -23117,6 +23427,7 @@ packages: resolution: {integrity: sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==} engines: {node: '>= 12'} hasBin: true + dev: false /mcl-wasm@0.7.9: resolution: {integrity: sha512-iJIUcQWA88IJB/5L15GnJVnSQJmf/YaxxV6zRavv83HILHaJQb6y0iFyDMdDO0gN8X37tdxmAOrH/P8B6RB8sQ==} @@ -23724,7 +24035,7 @@ packages: engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 - dev: true + dev: false /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} @@ -23839,6 +24150,18 @@ packages: yargs-parser: 20.2.4 yargs-unparser: 2.0.0 + /mock-property@1.0.3: + resolution: {integrity: sha512-2emPTb1reeLLYwHxyVx993iYyCHEiRRO+y8NFXFPL5kl5q14sgTK76cXyEKkeKCHeRw35SfdkUJ10Q1KfHuiIQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + functions-have-names: 1.2.3 + gopd: 1.0.1 + has-property-descriptors: 1.0.0 + hasown: 2.0.0 + isarray: 2.0.5 + dev: true + /module-error@1.0.2: resolution: {integrity: sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==} engines: {node: '>=10'} @@ -23921,6 +24244,10 @@ packages: object-assign: 4.1.1 thenify-all: 1.6.0 + /nanoassert@2.0.0: + resolution: {integrity: sha512-7vO7n28+aYO4J+8w96AzhmU8G+Y/xpPDJz/se19ICsqj/momRbb9mh9ZUtkoJ5X3nTnPdhEJyc0qnM6yAsHBaA==} + dev: true + /nanoid@3.3.3: resolution: {integrity: sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -24108,6 +24435,10 @@ packages: /node-addon-api@2.0.2: resolution: {integrity: sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==} + /node-addon-api@3.2.1: + resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} + dev: true + /node-dir@0.1.17: resolution: {integrity: sha512-tmPX422rYgofd4epzrNoOXiE8XFZYOcCq1vD7MAXCDO+O+zndlA2ztdKKMa+EeuBG5tHETpr4ml4RGgpqDCCAg==} engines: {node: '>= 0.10.5'} @@ -24373,6 +24704,10 @@ packages: /object-inspect@1.12.3: resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} + /object-inspect@1.13.1: + resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} + dev: true + /object-is@1.1.5: resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} engines: {node: '>= 0.4'} @@ -25446,7 +25781,6 @@ packages: lilconfig: 2.1.0 postcss: 8.4.21 yaml: 1.10.2 - dev: false /postcss-load-config@3.1.4(ts-node@10.9.1): resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} @@ -27028,6 +27362,15 @@ packages: define-properties: 1.2.0 functions-have-names: 1.2.3 + /regexp.prototype.flags@1.5.1: + resolution: {integrity: sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + set-function-name: 2.0.1 + dev: true + /regexpu-core@5.3.2: resolution: {integrity: sha512-RAM5FlZz+Lhmo7db9L298p2vHP5ZywrVXmVXpmAD9GuL5MPH6t9ROw1iA/wfHkQ76Qe7AaPF0nGuim96/IrQMQ==} engines: {node: '>=4'} @@ -27239,6 +27582,15 @@ packages: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 + /resolve@1.22.8: + resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} + hasBin: true + dependencies: + is-core-module: 2.13.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + /resolve@1.7.1: resolution: {integrity: sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==} dependencies: @@ -27428,6 +27780,16 @@ packages: dependencies: tslib: 2.5.0 + /safe-array-concat@1.0.1: + resolution: {integrity: sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==} + engines: {node: '>=0.4'} + dependencies: + call-bind: 1.0.5 + get-intrinsic: 1.2.2 + has-symbols: 1.0.3 + isarray: 2.0.5 + dev: true + /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -27446,8 +27808,8 @@ packages: /safe-regex-test@1.0.0: resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} dependencies: - call-bind: 1.0.2 - get-intrinsic: 1.2.0 + call-bind: 1.0.5 + get-intrinsic: 1.2.2 is-regex: 1.1.4 /safe-regex2@2.0.0: @@ -27756,6 +28118,24 @@ packages: /set-cookie-parser@2.6.0: resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} + /set-function-length@1.1.1: + resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.0 + + /set-function-name@2.0.1: + resolution: {integrity: sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.0 + dev: true + /set-value@2.0.1: resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==} engines: {node: '>=0.10.0'} @@ -27782,6 +28162,13 @@ packages: inherits: 2.0.4 safe-buffer: 5.2.1 + /sha1@1.1.1: + resolution: {integrity: sha512-dZBS6OrMjtgVkopB1Gmo4RQCDKiZsqcpAQpkV/aaj+FCrCg8r4I4qMkDPQjBgLIxlmu9k4nUbWq6ohXahOneYA==} + dependencies: + charenc: 0.0.2 + crypt: 0.0.2 + dev: true + /shallow-clone@3.0.1: resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} engines: {node: '>=8'} @@ -27818,7 +28205,7 @@ packages: jsonc-parser: 3.2.0 vscode-oniguruma: 1.7.0 vscode-textmate: 8.0.0 - dev: true + dev: false /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} @@ -28320,6 +28707,15 @@ packages: define-properties: 1.2.0 es-abstract: 1.21.2 + /string.prototype.trim@1.2.8: + resolution: {integrity: sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.22.3 + dev: true + /string.prototype.trimend@1.0.6: resolution: {integrity: sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==} dependencies: @@ -28327,6 +28723,14 @@ packages: define-properties: 1.2.0 es-abstract: 1.21.2 + /string.prototype.trimend@1.0.7: + resolution: {integrity: sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==} + dependencies: + call-bind: 1.0.5 + define-properties: 1.2.0 + es-abstract: 1.22.3 + dev: true + /string.prototype.trimstart@1.0.6: resolution: {integrity: sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==} dependencies: @@ -28334,6 +28738,14 @@ packages: define-properties: 1.2.0 es-abstract: 1.21.2 + /string.prototype.trimstart@1.0.7: + resolution: {integrity: sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==} + dependencies: + call-bind: 1.0.5 + define-properties: 1.2.0 + es-abstract: 1.22.3 + dev: true + /string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} dependencies: @@ -28659,6 +29071,28 @@ packages: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} + /tape@4.17.0: + resolution: {integrity: sha512-KCuXjYxCZ3ru40dmND+oCLsXyuA8hoseu2SS404Px5ouyS0A99v8X/mdiLqsR5MTAyamMBN7PRwt2Dv3+xGIxw==} + hasBin: true + dependencies: + '@ljharb/resumer': 0.0.1 + '@ljharb/through': 2.3.11 + call-bind: 1.0.2 + deep-equal: 1.1.2 + defined: 1.0.1 + dotignore: 0.1.2 + for-each: 0.3.3 + glob: 7.2.3 + has: 1.0.3 + inherits: 2.0.4 + is-regex: 1.1.4 + minimist: 1.2.8 + mock-property: 1.0.3 + object-inspect: 1.12.3 + resolve: 1.22.8 + string.prototype.trim: 1.2.8 + dev: true + /tar@6.1.15: resolution: {integrity: sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==} engines: {node: '>=10'} @@ -29160,6 +29594,42 @@ packages: - ts-node dev: true + /tsup@6.7.0(typescript@5.1.6): + resolution: {integrity: sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==} + engines: {node: '>=14.18'} + hasBin: true + peerDependencies: + '@swc/core': ^1 + postcss: ^8.4.12 + typescript: '>=4.1.0' + peerDependenciesMeta: + '@swc/core': + optional: true + postcss: + optional: true + typescript: + optional: true + dependencies: + bundle-require: 4.0.1(esbuild@0.17.11) + cac: 6.7.14 + chokidar: 3.5.3 + debug: 4.3.4(supports-color@8.1.1) + esbuild: 0.17.11 + execa: 5.1.1 + globby: 11.1.0 + joycon: 3.1.1 + postcss-load-config: 3.1.4(postcss@8.4.21) + resolve-from: 5.0.0 + rollup: 3.19.1 + source-map: 0.8.0-beta.0 + sucrase: 3.29.0 + tree-kill: 1.2.2 + typescript: 5.1.6 + transitivePeerDependencies: + - supports-color + - ts-node + dev: true + /tsutils@3.21.0(typescript@5.1.6): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} @@ -29354,12 +29824,42 @@ packages: - supports-color dev: true + /typed-array-buffer@1.0.0: + resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.5 + get-intrinsic: 1.2.2 + is-typed-array: 1.1.12 + dev: true + + /typed-array-byte-length@1.0.0: + resolution: {integrity: sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.5 + for-each: 0.3.3 + has-proto: 1.0.1 + is-typed-array: 1.1.12 + dev: true + + /typed-array-byte-offset@1.0.0: + resolution: {integrity: sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.5 + for-each: 0.3.3 + has-proto: 1.0.1 + is-typed-array: 1.1.12 + dev: true + /typed-array-length@1.0.4: resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 for-each: 0.3.3 - is-typed-array: 1.1.10 + is-typed-array: 1.1.12 /typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} @@ -29378,7 +29878,7 @@ packages: minimatch: 9.0.3 shiki: 0.14.5 typescript: 5.1.6 - dev: true + dev: false /typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} @@ -29443,7 +29943,7 @@ packages: /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} dependencies: - call-bind: 1.0.2 + call-bind: 1.0.5 has-bigints: 1.0.2 has-symbols: 1.0.3 which-boxed-primitive: 1.0.2 @@ -29935,11 +30435,11 @@ packages: /vscode-oniguruma@1.7.0: resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} - dev: true + dev: false /vscode-textmate@8.0.0: resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} - dev: true + dev: false /w3c-hr-time@1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} @@ -29960,6 +30460,16 @@ packages: dependencies: makeerror: 1.0.12 + /wasmbuilder@0.0.16: + resolution: {integrity: sha512-Qx3lEFqaVvp1cEYW7Bfi+ebRJrOiwz2Ieu7ZG2l7YyeSJIok/reEQCQCuicj/Y32ITIJuGIM9xZQppGx5LrQdA==} + dev: true + + /wasmcurves@0.2.2: + resolution: {integrity: sha512-JRY908NkmKjFl4ytnTu5ED6AwPD+8VJ9oc94kdq7h5bIwbj0L4TDJ69mG+2aLs2SoCmGfqIesMWTEJjtYsoQXQ==} + dependencies: + wasmbuilder: 0.0.16 + dev: true + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} @@ -29978,6 +30488,10 @@ packages: dependencies: defaults: 1.0.4 + /web-worker@1.2.0: + resolution: {integrity: sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==} + dev: true + /web3-core-helpers@1.5.2: resolution: {integrity: sha512-U7LJoeUdQ3aY9t5gU7t/1XpcApsWm+4AcW5qKl/44ZxD44w0Dmsq1c5zJm3GuLr/a9MwQfXK4lpmvxVQWHHQRg==} engines: {node: '>=8.0.0'} @@ -30546,6 +31060,16 @@ packages: path-exists: 4.0.0 dev: false + /which-typed-array@1.1.13: + resolution: {integrity: sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.5 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + /which-typed-array@1.1.9: resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} engines: {node: '>= 0.4'} diff --git a/turbo.json b/turbo.json index 5edb6b25ecb..d5b65dc9367 100644 --- a/turbo.json +++ b/turbo.json @@ -5,6 +5,10 @@ "outputs": ["dist/**"], "dependsOn": ["^build"] }, + "typedoc": { + "outputs": ["typedoc/**"], + "dependsOn": ["^build"] + }, "@thirdweb-dev/chains#build": { "outputs": ["dist/**", "chains/**"], "dependsOn": ["^build"],