Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddfdfc5a02 | ||
|
|
dbdafa2b01 | ||
|
|
77c2a8ae0c | ||
|
|
5c1f4db356 | ||
|
|
5b83353237 | ||
|
|
56c139c5a2 | ||
|
|
03d8d6c15b | ||
|
|
f12f9bbdcf | ||
|
|
82ee42d667 | ||
|
|
81c297faeb |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.69
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
|
||||
## 4.1.68
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.68",
|
||||
"version": "4.1.69",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/chains
|
||||
|
||||
## 0.1.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2852](https://github.com/thirdweb-dev/js/pull/2852) [`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
|
||||
|
||||
## 0.1.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -6,10 +6,22 @@ export default {
|
||||
{
|
||||
"name": "BOASCAN",
|
||||
"url": "https://boascan.io",
|
||||
"standard": "EIP3091"
|
||||
"standard": "EIP3091",
|
||||
"icon": {
|
||||
"url": "ipfs://QmW3CT4SHmso5dRJdsjR8GL1qmt79HkdAebCn2uNaWXFYh",
|
||||
"width": 256,
|
||||
"height": 257,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmW3CT4SHmso5dRJdsjR8GL1qmt79HkdAebCn2uNaWXFYh",
|
||||
"width": 256,
|
||||
"height": 257,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://docs.bosagora.org",
|
||||
"name": "BOSagora Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 46109,
|
||||
"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": "qr0224t1tp Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "qr0224t1tp Testnet Token",
|
||||
"symbol": "CRH",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 46109,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://46109.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/qr0224t1tp/testnet/rpc"
|
||||
],
|
||||
"shortName": "qr0224t1tp Testnet",
|
||||
"slug": "qr0224t1tp-testnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -6,10 +6,22 @@ export default {
|
||||
{
|
||||
"name": "MEVerse Chain Testnet Explorer",
|
||||
"url": "https://testnet.meversescan.io",
|
||||
"standard": "none"
|
||||
"standard": "none",
|
||||
"icon": {
|
||||
"url": "ipfs://QmPuQ6gaCfUtNdRuaEDbdhot2m2KCy2ZHCJUvZXJAtdeyJ",
|
||||
"width": 800,
|
||||
"height": 800,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmPuQ6gaCfUtNdRuaEDbdhot2m2KCy2ZHCJUvZXJAtdeyJ",
|
||||
"width": 800,
|
||||
"height": 800,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://www.meverse.sg",
|
||||
"name": "MEVerse Chain Testnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -10,6 +10,12 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmYbskrGpidbMwsJekTeLrr8Z6GA9q4Uxh7piS1F9BdWWv",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://compverse.io",
|
||||
"name": "Compverse Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -6,10 +6,22 @@ export default {
|
||||
{
|
||||
"name": "MEVerse Chain Explorer",
|
||||
"url": "https://www.meversescan.io",
|
||||
"standard": "none"
|
||||
"standard": "none",
|
||||
"icon": {
|
||||
"url": "ipfs://QmPuQ6gaCfUtNdRuaEDbdhot2m2KCy2ZHCJUvZXJAtdeyJ",
|
||||
"width": 800,
|
||||
"height": 800,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmPuQ6gaCfUtNdRuaEDbdhot2m2KCy2ZHCJUvZXJAtdeyJ",
|
||||
"width": 800,
|
||||
"height": 800,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://www.meverse.sg",
|
||||
"name": "MEVerse Chain Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -16,6 +16,12 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmVhezQHkqSZ5Tvtsw18giA1yBjV1URSsBQ7HenUh6p6oC",
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://octa.space",
|
||||
"name": "OctaSpace",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -6,10 +6,22 @@ export default {
|
||||
{
|
||||
"name": "Pepe Explorer",
|
||||
"url": "https://explorer.pepenetwork.io",
|
||||
"standard": "none"
|
||||
"standard": "none",
|
||||
"icon": {
|
||||
"url": "ipfs://QmPX3uipdwd195z1MJff7uj8hpZdSuVvM5z47eiz2o7Gz5",
|
||||
"width": 960,
|
||||
"height": 944,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmPX3uipdwd195z1MJff7uj8hpZdSuVvM5z47eiz2o7Gz5",
|
||||
"width": 960,
|
||||
"height": 944,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://pepenetwork.io",
|
||||
"name": "PepeNetwork Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -10,6 +10,12 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmZTWoZ3LvivSinaJ4aSwqU8pCXw8oSZNnUCh4wwXxtAoQ",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://larissa.network",
|
||||
"name": "Larissa Chain",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/chains",
|
||||
"version": "0.1.100",
|
||||
"version": "0.1.101",
|
||||
"main": "dist/thirdweb-dev-chains.cjs.js",
|
||||
"module": "dist/thirdweb-dev-chains.esm.js",
|
||||
"exports": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,15 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
- @thirdweb-dev/auth@4.1.69
|
||||
|
||||
## 0.13.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/cli",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.76",
|
||||
"version": "0.13.77",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.6.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
- @thirdweb-dev/auth@4.1.69
|
||||
|
||||
## 4.6.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.6.9",
|
||||
"version": "4.6.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.7.42
|
||||
|
||||
## 0.7.41
|
||||
|
||||
## 0.7.40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.7.41",
|
||||
"version": "0.7.42",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.7.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
- @thirdweb-dev/react-core@4.6.10
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
|
||||
## 0.7.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.7.41",
|
||||
"version": "0.7.42",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.6.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
- @thirdweb-dev/react-core@4.6.10
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
|
||||
## 4.6.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.6.9",
|
||||
"version": "4.6.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`03d8d6c`](https://github.com/thirdweb-dev/js/commit/03d8d6c15b02fb6889680484daf40f6189ad6359), [`5b83353`](https://github.com/thirdweb-dev/js/commit/5b833532372dd6e96dd0aeda7a4b190e9f280d4f), [`77c2a8a`](https://github.com/thirdweb-dev/js/commit/77c2a8ae0cdb49091bd961b60ef5c316ccd6e119), [`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668), [`56c139c`](https://github.com/thirdweb-dev/js/commit/56c139c5a2c1e702e038a8948fefd647b3695823)]:
|
||||
- thirdweb@5.13.0
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
|
||||
## 4.0.70
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.70",
|
||||
"version": "4.0.71",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,19 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.6.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2858](https://github.com/thirdweb-dev/js/pull/2858) [`82ee42d`](https://github.com/thirdweb-dev/js/commit/82ee42d667219b5a2aa323278af1e9981076b339) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - Unity 4.12.4
|
||||
|
||||
- [#2854](https://github.com/thirdweb-dev/js/pull/2854) [`81c297f`](https://github.com/thirdweb-dev/js/commit/81c297faeb698503cf5e2716d604c9f0c18ad668) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - Unity 4.12.3
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
- @thirdweb-dev/wallets@2.5.11
|
||||
- @thirdweb-dev/auth@4.1.69
|
||||
|
||||
## 0.6.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.6.19",
|
||||
"version": "0.6.20",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -171,7 +171,7 @@ class ThirdwebBridge implements TWBridge {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_PLATFORM = "unity";
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_VERSION = "4.12.2";
|
||||
(globalThis as any).X_SDK_VERSION = "4.12.4";
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.5.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dbdafa2`](https://github.com/thirdweb-dev/js/commit/dbdafa2b01148b13d05fd75803926d9d37396668)]:
|
||||
- @thirdweb-dev/chains@0.1.101
|
||||
- @thirdweb-dev/sdk@4.0.71
|
||||
|
||||
## 2.5.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.5.10",
|
||||
"version": "2.5.11",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
Binary file not shown.
@@ -39,7 +39,7 @@ export const SERVICE_DEFINITIONS = {
|
||||
},
|
||||
embeddedWallets: {
|
||||
name: "embeddedWallets",
|
||||
title: "Embedded Wallets",
|
||||
title: "In-App Wallets",
|
||||
description: "E-mail and social login wallets for easy web3 onboarding",
|
||||
// all actions allowed
|
||||
actions: [],
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.13.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#2853](https://github.com/thirdweb-dev/js/pull/2853) [`56c139c`](https://github.com/thirdweb-dev/js/commit/56c139c5a2c1e702e038a8948fefd647b3695823) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add account abstraction options to `useConnect` and handle smart wallet autoconnection outside of UI components
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2859](https://github.com/thirdweb-dev/js/pull/2859) [`03d8d6c`](https://github.com/thirdweb-dev/js/commit/03d8d6c15b02fb6889680484daf40f6189ad6359) Thanks [@jnsdls](https://github.com/jnsdls)! - add `gasless` prop to `<TransactionButton />`
|
||||
|
||||
- [#2861](https://github.com/thirdweb-dev/js/pull/2861) [`5b83353`](https://github.com/thirdweb-dev/js/commit/5b833532372dd6e96dd0aeda7a4b190e9f280d4f) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Export airdrop extensions
|
||||
|
||||
- [#2857](https://github.com/thirdweb-dev/js/pull/2857) [`77c2a8a`](https://github.com/thirdweb-dev/js/commit/77c2a8ae0cdb49091bd961b60ef5c316ccd6e119) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Docs: update incorrect code snippets, fix typos
|
||||
|
||||
## 5.12.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"version": "5.12.0",
|
||||
"version": "5.13.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
||||
|
||||
@@ -31,7 +31,7 @@ export const viemAdapter = {
|
||||
* ```ts
|
||||
* import { viemAdapter } from "thirdweb/adapters";
|
||||
*
|
||||
* const contract = viemmAdapter.contract.fromViem({
|
||||
* const contract = viemAdapter.contract.fromViem({
|
||||
* viemContract: viemContract,
|
||||
* chain: ethereum,
|
||||
* client,
|
||||
@@ -246,7 +246,7 @@ function fromViemWalletClient(options: {
|
||||
const viemAccount = options.walletClient.account;
|
||||
if (!viemAccount) {
|
||||
throw new Error(
|
||||
"Account not found in walletClient, please pass it explicitely.",
|
||||
"Account not found in walletClient, please pass it explicitly.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineChain } from "../utils.js";
|
||||
export const anvil = /* @__PURE__ */ defineChain({
|
||||
id: 31337,
|
||||
name: "Anvil",
|
||||
rpc: "http://localhost:8545",
|
||||
rpc: "http://127.0.0.1:8545",
|
||||
testnet: true,
|
||||
nativeCurrency: {
|
||||
name: "Anvil Ether",
|
||||
|
||||
@@ -27,7 +27,7 @@ export type WatchContractEventsOptions<
|
||||
* ### Listen to all events for a contract
|
||||
* ```ts
|
||||
* import { watchContractEvents } from "thirdweb";
|
||||
* const unwatch = watchEvents({
|
||||
* const unwatch = watchContractEvents({
|
||||
* contract: myContract,
|
||||
* onEvents: (events) => {
|
||||
* // do something with the events
|
||||
@@ -41,7 +41,7 @@ export type WatchContractEventsOptions<
|
||||
* const myEvent = prepareEvent({
|
||||
* event: "event MyEvent(uint256 myArg)",
|
||||
* });
|
||||
* const events = await watchEvents({
|
||||
* const events = await watchContractEvents({
|
||||
* contract: myContract,
|
||||
* events: [myEvent],
|
||||
* onEvents: (events) => {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* READ
|
||||
*/
|
||||
export {
|
||||
isClaimed,
|
||||
type IsClaimedParams,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/read/isClaimed.js";
|
||||
export {
|
||||
tokenConditionId,
|
||||
type TokenConditionIdParams,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/read/tokenConditionId.js";
|
||||
export {
|
||||
tokenMerkleRoot,
|
||||
type TokenMerkleRootParams,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/read/tokenMerkleRoot.js";
|
||||
|
||||
/**
|
||||
* Write
|
||||
*/
|
||||
export {
|
||||
airdropERC20,
|
||||
type AirdropERC20Params,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/write/airdropERC20.js";
|
||||
export {
|
||||
airdropERC721,
|
||||
type AirdropERC721Params,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/write/airdropERC721.js";
|
||||
export {
|
||||
airdropERC1155,
|
||||
type AirdropERC1155Params,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/write/airdropERC1155.js";
|
||||
export {
|
||||
airdropNativeToken,
|
||||
type AirdropNativeTokenParams,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/write/airdropNativeToken.js";
|
||||
export {
|
||||
setMerkleRoot,
|
||||
type SetMerkleRootParams,
|
||||
} from "../../extensions/airdrop/__generated__/Airdrop/write/setMerkleRoot.js";
|
||||
export {
|
||||
airdropERC20WithSignature,
|
||||
generateAirdropSignatureERC20,
|
||||
type GenerateAirdropERC20SignatureOptions,
|
||||
} from "../../extensions/airdrop/write/airdropERC20WithSignature.js";
|
||||
export {
|
||||
airdropERC721WithSignature,
|
||||
generateAirdropSignatureERC721,
|
||||
type GenerateAirdropERC721SignatureOptions,
|
||||
} from "../../extensions/airdrop/write/airdropERC721WithSignature.js";
|
||||
export {
|
||||
airdropERC1155WithSignature,
|
||||
generateAirdropSignatureERC1155,
|
||||
type GenerateAirdropERC1155SignatureOptions,
|
||||
} from "../../extensions/airdrop/write/airdropERC1155WithSignature.js";
|
||||
export {
|
||||
claimERC20,
|
||||
type ClaimERC20Params,
|
||||
} from "../../extensions/airdrop/write/claimERC20.js";
|
||||
export {
|
||||
claimERC721,
|
||||
type ClaimERC721Params,
|
||||
} from "../../extensions/airdrop/write/claimERC721.js";
|
||||
export {
|
||||
claimERC1155,
|
||||
type ClaimERC1155Params,
|
||||
} from "../../extensions/airdrop/write/claimERC1155.js";
|
||||
export {
|
||||
generateMerkleTreeInfoERC20,
|
||||
type GenerateMerkleTreeInfoERC20Params,
|
||||
} from "../../extensions/airdrop/write/merkleInfoERC20.js";
|
||||
export {
|
||||
generateMerkleTreeInfoERC721,
|
||||
type GenerateMerkleTreeInfoERC721Params,
|
||||
} from "../../extensions/airdrop/write/merkleInfoERC721.js";
|
||||
export {
|
||||
generateMerkleTreeInfoERC1155,
|
||||
type GenerateMerkleTreeInfoERC1155Params,
|
||||
} from "../../extensions/airdrop/write/merkleInfoERC1155.js";
|
||||
export {
|
||||
saveSnapshot,
|
||||
type SaveSnapshotParams,
|
||||
} from "../../extensions/airdrop/write/saveSnapshot.js";
|
||||
@@ -61,7 +61,7 @@ export {
|
||||
} from "../../extensions/uniswap/__generated__/IUniswapV3Factory/write/setOwner.js";
|
||||
|
||||
export {
|
||||
getUniswapV3Pools as getUniswapV3Pool,
|
||||
type GetUniswapV3PoolsParams as GetUniswapV3PoolParams,
|
||||
type GetUniswapV3PoolsResult as GetUniswapV3PoolResult,
|
||||
getUniswapV3Pool,
|
||||
type GetUniswapV3PoolParams,
|
||||
type GetUniswapV3PoolResult,
|
||||
} from "../../extensions/uniswap/read/getUniswapV3Pools.js";
|
||||
|
||||
@@ -54,6 +54,8 @@ export {
|
||||
useIsAutoConnecting,
|
||||
} from "../react/core/hooks/wallets/wallet-hooks.js";
|
||||
|
||||
export type { ConnectManagerOptions } from "../wallets/manager/index.js";
|
||||
|
||||
// contract related
|
||||
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
||||
export {
|
||||
|
||||
@@ -39,7 +39,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
contractId: "Airdrop",
|
||||
contractParams: [TEST_ACCOUNT_A.address],
|
||||
contractParams: [TEST_ACCOUNT_A.address, ""],
|
||||
}),
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
|
||||
@@ -27,7 +27,7 @@ import { airdropERC1155WithSignature as generatedAirdropERC1155WithSignature } f
|
||||
*/
|
||||
export const airdropERC1155WithSignature = generatedAirdropERC1155WithSignature;
|
||||
|
||||
export type GenerateAirdropSignatureOptions = {
|
||||
export type GenerateAirdropERC1155SignatureOptions = {
|
||||
account: Account;
|
||||
contract: ThirdwebContract;
|
||||
airdropRequest: GenerateReqInput;
|
||||
@@ -67,7 +67,7 @@ export type GenerateAirdropSignatureOptions = {
|
||||
* @returns A promise that resolves to the req and signature.
|
||||
*/
|
||||
export async function generateAirdropSignatureERC1155(
|
||||
options: GenerateAirdropSignatureOptions,
|
||||
options: GenerateAirdropERC1155SignatureOptions,
|
||||
) {
|
||||
const { airdropRequest, account, contract } = options;
|
||||
const tokenAddress = airdropRequest.tokenAddress;
|
||||
|
||||
@@ -37,7 +37,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
contractId: "Airdrop",
|
||||
contractParams: [TEST_ACCOUNT_A.address],
|
||||
contractParams: [TEST_ACCOUNT_A.address, ""],
|
||||
}),
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
|
||||
@@ -27,7 +27,7 @@ import { airdropERC20WithSignature as generatedAirdropERC20WithSignature } from
|
||||
*/
|
||||
export const airdropERC20WithSignature = generatedAirdropERC20WithSignature;
|
||||
|
||||
export type GenerateAirdropSignatureOptions = {
|
||||
export type GenerateAirdropERC20SignatureOptions = {
|
||||
account: Account;
|
||||
contract: ThirdwebContract;
|
||||
airdropRequest: GenerateReqInput;
|
||||
@@ -67,7 +67,7 @@ export type GenerateAirdropSignatureOptions = {
|
||||
* @returns A promise that resolves to the req and signature.
|
||||
*/
|
||||
export async function generateAirdropSignatureERC20(
|
||||
options: GenerateAirdropSignatureOptions,
|
||||
options: GenerateAirdropERC20SignatureOptions,
|
||||
) {
|
||||
const { airdropRequest, account, contract } = options;
|
||||
const tokenAddress = airdropRequest.tokenAddress;
|
||||
|
||||
@@ -39,7 +39,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
contractId: "Airdrop",
|
||||
contractParams: [TEST_ACCOUNT_A.address],
|
||||
contractParams: [TEST_ACCOUNT_A.address, ""],
|
||||
}),
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
|
||||
@@ -27,7 +27,7 @@ import { airdropERC721WithSignature as generatedAirdropERC721WithSignature } fro
|
||||
*/
|
||||
export const airdropERC721WithSignature = generatedAirdropERC721WithSignature;
|
||||
|
||||
export type GenerateAirdropSignatureOptions = {
|
||||
export type GenerateAirdropERC721SignatureOptions = {
|
||||
account: Account;
|
||||
contract: ThirdwebContract;
|
||||
airdropRequest: GenerateReqInput;
|
||||
@@ -67,7 +67,7 @@ export type GenerateAirdropSignatureOptions = {
|
||||
* @returns A promise that resolves to the req and signature.
|
||||
*/
|
||||
export async function generateAirdropSignatureERC721(
|
||||
options: GenerateAirdropSignatureOptions,
|
||||
options: GenerateAirdropERC721SignatureOptions,
|
||||
) {
|
||||
const { airdropRequest, account, contract } = options;
|
||||
const tokenAddress = airdropRequest.tokenAddress;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
||||
import { processSnapshotERC1155 } from "../../../utils/extensions/airdrop/process-snapshot-erc1155.js";
|
||||
import type { SnapshotEntryERC1155 } from "../../../utils/extensions/airdrop/types.js";
|
||||
|
||||
export type GenerateMerkleTreeInfoParams = {
|
||||
export type GenerateMerkleTreeInfoERC1155Params = {
|
||||
snapshot: SnapshotEntryERC1155[];
|
||||
tokenAddress: string;
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export type GenerateMerkleTreeInfoParams = {
|
||||
* @returns A promise that resolves to the merkle-root and snapshot-uri.
|
||||
*/
|
||||
export async function generateMerkleTreeInfoERC1155(
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoParams>,
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoERC1155Params>,
|
||||
) {
|
||||
const { snapshot, contract } = options;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
||||
import { processSnapshotERC20 } from "../../../utils/extensions/airdrop/process-snapshot-erc20.js";
|
||||
import type { SnapshotEntryERC20 } from "../../../utils/extensions/airdrop/types.js";
|
||||
|
||||
export type GenerateMerkleTreeInfoParams = {
|
||||
export type GenerateMerkleTreeInfoERC20Params = {
|
||||
snapshot: SnapshotEntryERC20[];
|
||||
tokenAddress: string;
|
||||
};
|
||||
@@ -42,7 +42,7 @@ export type GenerateMerkleTreeInfoParams = {
|
||||
* @returns A promise that resolves to the merkle-root and snapshot-uri.
|
||||
*/
|
||||
export async function generateMerkleTreeInfoERC20(
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoParams>,
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoERC20Params>,
|
||||
) {
|
||||
const { snapshot, contract } = options;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
||||
import { processSnapshotERC721 } from "../../../utils/extensions/airdrop/process-snapshot-erc721.js";
|
||||
import type { SnapshotEntryERC721 } from "../../../utils/extensions/airdrop/types.js";
|
||||
|
||||
export type GenerateMerkleTreeInfoParams = {
|
||||
export type GenerateMerkleTreeInfoERC721Params = {
|
||||
snapshot: SnapshotEntryERC721[];
|
||||
tokenAddress: string;
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export type GenerateMerkleTreeInfoParams = {
|
||||
* @returns A promise that resolves to the merkle-root and snapshot-uri.
|
||||
*/
|
||||
export async function generateMerkleTreeInfoERC721(
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoParams>,
|
||||
options: BaseTransactionOptions<GenerateMerkleTreeInfoERC721Params>,
|
||||
) {
|
||||
const { snapshot, contract } = options;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export type ResolveNameOptions = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves the primary name for a specificed address.
|
||||
* Resolves the primary name for a specified address.
|
||||
* @param options - The options for resolving an ENS address.
|
||||
* @example
|
||||
* ```ts
|
||||
|
||||
@@ -30,9 +30,9 @@ export type GetBalanceResult = {
|
||||
* @extension ERC20
|
||||
* @example
|
||||
* ```ts
|
||||
* import { balanceOf } from "thirdweb/extensions/erc20";
|
||||
* import { getBalance } from "thirdweb/extensions/erc20";
|
||||
*
|
||||
* const balance = await balanceOf({ contract, address: "0x..." });
|
||||
* const balance = await getBalance({ contract, address: "0x..." });
|
||||
* ```
|
||||
*/
|
||||
export async function getBalance(
|
||||
|
||||
@@ -29,7 +29,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
||||
chain: ANVIL_CHAIN,
|
||||
account: TEST_ACCOUNT_A,
|
||||
contractId: "Airdrop",
|
||||
contractParams: [TEST_ACCOUNT_A.address],
|
||||
contractParams: [TEST_ACCOUNT_A.address, ""],
|
||||
});
|
||||
expect(address).toBeDefined();
|
||||
expect(address.length).toBe(42);
|
||||
|
||||
@@ -6,11 +6,11 @@ import {
|
||||
UNISWAPV3_FACTORY_CONTRACT,
|
||||
WETH_CONTRACT_ADDRESS,
|
||||
} from "~test/test-contracts.js";
|
||||
import { getUniswapV3Pools } from "./getUniswapV3Pools.js";
|
||||
import { getUniswapV3Pool } from "./getUniswapV3Pools.js";
|
||||
|
||||
describe.runIf(process.env.TW_SECRET_KEY)("uniswap.getUniswapV3Pool", () => {
|
||||
it("should return the WETH/OHM pool address and fee", async () => {
|
||||
const pools = await getUniswapV3Pools({
|
||||
const pools = await getUniswapV3Pool({
|
||||
contract: UNISWAPV3_FACTORY_CONTRACT,
|
||||
tokenA: WETH_CONTRACT_ADDRESS,
|
||||
tokenB: OHM_CONTRACT_ADDRESS,
|
||||
@@ -30,7 +30,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("uniswap.getUniswapV3Pool", () => {
|
||||
});
|
||||
|
||||
it("should return an empty array when no pool exists for the pair", async () => {
|
||||
const pools = await getUniswapV3Pools({
|
||||
const pools = await getUniswapV3Pool({
|
||||
contract: UNISWAPV3_FACTORY_CONTRACT,
|
||||
tokenA: MOG_CONTRACT_ADDRESS,
|
||||
tokenB: OHM_CONTRACT_ADDRESS,
|
||||
|
||||
@@ -6,12 +6,12 @@ import { UniswapFee } from "../types.js";
|
||||
/**
|
||||
* Represents the parameters for the `findUniswapV3Pool` function.
|
||||
*/
|
||||
export type GetUniswapV3PoolsParams = {
|
||||
export type GetUniswapV3PoolParams = {
|
||||
tokenA: Address;
|
||||
tokenB: Address;
|
||||
};
|
||||
|
||||
export type GetUniswapV3PoolsResult = {
|
||||
export type GetUniswapV3PoolResult = {
|
||||
poolFee: UniswapFee;
|
||||
poolAddress: Address;
|
||||
};
|
||||
@@ -24,16 +24,16 @@ export type GetUniswapV3PoolsResult = {
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getUniswapV3Pool } from "thirdweb/extensions/uniswap";
|
||||
* const { poolFee, poolAddress } = await getUniswapV3Pool({
|
||||
* const pools = await getUniswapV3Pool({
|
||||
* tokenA: "0x...",
|
||||
* tokenB: "0x...",
|
||||
* factoryContract: contract
|
||||
* contract: factoryContract
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export async function getUniswapV3Pools(
|
||||
options: BaseTransactionOptions<GetUniswapV3PoolsParams>,
|
||||
): Promise<GetUniswapV3PoolsResult[]> {
|
||||
export async function getUniswapV3Pool(
|
||||
options: BaseTransactionOptions<GetUniswapV3PoolParams>,
|
||||
): Promise<GetUniswapV3PoolResult[]> {
|
||||
const { getPool } = await import(
|
||||
"../__generated__/IUniswapV3Factory/read/getPool.js"
|
||||
);
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { useEffect } from "react";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import { createWallet } from "../../../../wallets/create-wallet.js";
|
||||
// import {
|
||||
// getSavedConnectParamsFromStorage,
|
||||
// type WithPersonalWalletConnectionOptions,
|
||||
// } from "../../../../wallets/storage/walletStorage.js";
|
||||
import type {
|
||||
Wallet,
|
||||
// WalletWithPersonalAccount,
|
||||
} from "../../../../wallets/interfaces/wallet.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import {
|
||||
getLastConnectedChain,
|
||||
getStoredActiveWalletId,
|
||||
@@ -16,11 +8,9 @@ import {
|
||||
} from "../../../../wallets/manager/index.js";
|
||||
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
|
||||
import { asyncLocalStorage } from "../../../../wallets/storage/asyncLocalStorage.js";
|
||||
import { getSavedConnectParamsFromStorage } from "../../../../wallets/storage/walletStorage.js";
|
||||
import type { AppMetadata } from "../../../../wallets/types.js";
|
||||
import { connectionManager } from "../../connectionManager.js";
|
||||
import { timeoutPromise } from "../../utils/timeoutPromise.js";
|
||||
// import type { WalletConfig } from "../../types/wallets.js";
|
||||
import {
|
||||
useConnect,
|
||||
useSetActiveWalletConnectionStatus,
|
||||
@@ -154,9 +144,12 @@ export type AutoConnectProps = {
|
||||
*/
|
||||
export function AutoConnect(props: AutoConnectProps) {
|
||||
const setConnectionStatus = useSetActiveWalletConnectionStatus();
|
||||
const { connect } = useConnect();
|
||||
const { connect } = useConnect({
|
||||
client: props.client,
|
||||
accountAbstraction: props.accountAbstraction,
|
||||
});
|
||||
const { isAutoConnecting } = connectionManager;
|
||||
const { wallets, accountAbstraction } = props;
|
||||
const { wallets } = props;
|
||||
const timeout = props.timeout ?? 15000;
|
||||
// get the supported wallets from thirdweb provider
|
||||
// check the storage for last connected wallets and connect them all
|
||||
@@ -182,74 +175,31 @@ export function AutoConnect(props: AutoConnectProps) {
|
||||
const lastConnectedChain = await getLastConnectedChain(asyncLocalStorage);
|
||||
|
||||
async function handleWalletConnection(wallet: Wallet) {
|
||||
setConnectionStatus("connecting");
|
||||
return wallet.autoConnect({
|
||||
client: props.client,
|
||||
chain: lastConnectedChain ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
if (lastActiveWalletId === "smart") {
|
||||
if (!accountAbstraction) {
|
||||
return;
|
||||
}
|
||||
const activeWallet =
|
||||
lastActiveWalletId && wallets.find((w) => w.id === lastActiveWalletId);
|
||||
|
||||
const savedParams = await getSavedConnectParamsFromStorage(
|
||||
asyncLocalStorage,
|
||||
"accountAbstraction",
|
||||
);
|
||||
if (activeWallet) {
|
||||
try {
|
||||
setConnectionStatus("connecting"); // only set connecting status if we are connecting the last active EOA
|
||||
await timeoutPromise(handleWalletConnection(activeWallet), {
|
||||
ms: timeout,
|
||||
message: `AutoConnect timeout : ${timeout}ms limit exceeded.`,
|
||||
});
|
||||
|
||||
const personalWalletId =
|
||||
savedParams && "personalWalletId" in savedParams
|
||||
? savedParams.personalWalletId
|
||||
: null;
|
||||
|
||||
if (personalWalletId) {
|
||||
const personalWallet = wallets.find((w) => w.id === personalWalletId);
|
||||
|
||||
if (personalWallet) {
|
||||
try {
|
||||
const account = await timeoutPromise(
|
||||
handleWalletConnection(personalWallet),
|
||||
{
|
||||
ms: timeout,
|
||||
message: `AutoConnect timeout : ${timeout}ms limit exceeded.`,
|
||||
},
|
||||
);
|
||||
|
||||
const smartWallet = createWallet("smart", accountAbstraction);
|
||||
await smartWallet.connect({
|
||||
personalAccount: account,
|
||||
client: props.client,
|
||||
});
|
||||
|
||||
connect(smartWallet);
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect personal wallet");
|
||||
console.error(e);
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const activeWallet = wallets.find((w) => w.id === lastActiveWalletId);
|
||||
|
||||
if (activeWallet) {
|
||||
try {
|
||||
await timeoutPromise(handleWalletConnection(activeWallet), {
|
||||
ms: timeout,
|
||||
message: `AutoConnect timeout : ${timeout}ms limit exceeded.`,
|
||||
});
|
||||
|
||||
connect(activeWallet);
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect last active wallet");
|
||||
console.error(e);
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
} else {
|
||||
connect(activeWallet);
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect last active wallet");
|
||||
console.error(e);
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
} else {
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
|
||||
// then connect wallets that were last connected but were not set as active
|
||||
@@ -265,7 +215,6 @@ export function AutoConnect(props: AutoConnectProps) {
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect a non-active connected wallet");
|
||||
console.error(e);
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useState, useSyncExternalStore } from "react";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import type { ConnectManagerOptions } from "../../../../wallets/manager/index.js";
|
||||
import { connectionManager } from "../../connectionManager.js";
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,7 @@ export function useConnectedWallets() {
|
||||
* const setActiveAccount = useSetActiveWallet();
|
||||
*
|
||||
* // later in your code
|
||||
* setActiveAccount(account);
|
||||
* await setActiveAccount(account);
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
@@ -133,26 +134,23 @@ export function useSetActiveWallet() {
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useConnect() {
|
||||
const { setActiveWallet } = connectionManager;
|
||||
export function useConnect(options?: ConnectManagerOptions) {
|
||||
const { connect } = connectionManager;
|
||||
const [isConnecting, setIsConnecting] = useState(false);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
const connect = useCallback(
|
||||
async (options: Wallet | (() => Promise<Wallet>)) => {
|
||||
const handleConnection = useCallback(
|
||||
async (walletOrFn: Wallet | (() => Promise<Wallet>)) => {
|
||||
// reset error state
|
||||
setError(null);
|
||||
if (typeof options !== "function") {
|
||||
setActiveWallet(options);
|
||||
return options;
|
||||
if (typeof walletOrFn !== "function") {
|
||||
return connect(walletOrFn, options);
|
||||
}
|
||||
|
||||
setIsConnecting(true);
|
||||
try {
|
||||
const wallet = await options();
|
||||
// add the uuid for this wallet
|
||||
setActiveWallet(wallet);
|
||||
return wallet;
|
||||
const w = await walletOrFn();
|
||||
return connect(w, options);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(e as Error);
|
||||
@@ -161,10 +159,10 @@ export function useConnect() {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
[setActiveWallet],
|
||||
[connect, options],
|
||||
);
|
||||
|
||||
return { connect, isConnecting, error } as const;
|
||||
return { connect: handleConnection, isConnecting, error } as const;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Suspense, lazy, useCallback } from "react";
|
||||
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
|
||||
import { useSiweAuth } from "../../../../core/hooks/auth/useSiweAuth.js";
|
||||
import { useConnectUI } from "../../../../core/hooks/others/useWalletConnectionCtx.js";
|
||||
import { useConnect } from "../../../../core/hooks/wallets/wallet-hooks.js";
|
||||
import { useSetActiveWallet } from "../../../../core/hooks/wallets/wallet-hooks.js";
|
||||
import { useSetSelectionData } from "../../../providers/wallet-ui-states-provider.js";
|
||||
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
|
||||
import { WalletSelector } from "../WalletSelector.js";
|
||||
@@ -39,7 +39,7 @@ export const ConnectModalContent = (props: {
|
||||
connectLocale,
|
||||
client,
|
||||
} = useConnectUI();
|
||||
const { connect } = useConnect();
|
||||
const setActiveWallet = useSetActiveWallet();
|
||||
const setSelectionData = useSetSelectionData();
|
||||
|
||||
const siweAuth = useSiweAuth(auth);
|
||||
@@ -47,7 +47,7 @@ export const ConnectModalContent = (props: {
|
||||
|
||||
const handleConnected = useCallback(
|
||||
(wallet: Wallet) => {
|
||||
connect(wallet);
|
||||
setActiveWallet(wallet);
|
||||
|
||||
if (onConnect) {
|
||||
onConnect(wallet);
|
||||
@@ -69,7 +69,7 @@ export const ConnectModalContent = (props: {
|
||||
setModalVisibility,
|
||||
onClose,
|
||||
onConnect,
|
||||
connect,
|
||||
setActiveWallet,
|
||||
showSignatureScreen,
|
||||
setScreen,
|
||||
setSelectionData,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { createWallet } from "../../../../../wallets/create-wallet.js";
|
||||
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
|
||||
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
|
||||
import { asyncLocalStorage } from "../../../../../wallets/storage/asyncLocalStorage.js";
|
||||
import { saveConnectParamsToStorage } from "../../../../../wallets/storage/walletStorage.js";
|
||||
import type { WalletInfo } from "../../../../../wallets/wallet-info.js";
|
||||
import { connectionManager } from "../../../../core/connectionManager.js";
|
||||
import { useConnectUI } from "../../../../core/hooks/others/useWalletConnectionCtx.js";
|
||||
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
|
||||
import { getSmartWalletLocale } from "../../../wallets/smartWallet/locale/getSmartWalletLocale.js";
|
||||
@@ -107,31 +105,24 @@ function SmartWalletConnecting(props: {
|
||||
if (!personalWallet) {
|
||||
throw new Error("No personal wallet");
|
||||
}
|
||||
const personalAccount = personalWallet.getAccount();
|
||||
if (!personalAccount) {
|
||||
throw new Error("No personal account");
|
||||
}
|
||||
|
||||
setSmartWalletConnectionStatus("connecting");
|
||||
|
||||
try {
|
||||
const smartWallet = createWallet("smart", props.accountAbstraction);
|
||||
await smartWallet.connect({
|
||||
personalAccount,
|
||||
client,
|
||||
});
|
||||
|
||||
saveConnectParamsToStorage(asyncLocalStorage, "accountAbstraction", {
|
||||
personalWalletId: personalWallet.id,
|
||||
});
|
||||
|
||||
done(smartWallet);
|
||||
const connected = await connectionManager.handleConnection(
|
||||
personalWallet,
|
||||
{
|
||||
accountAbstraction: props.accountAbstraction,
|
||||
client,
|
||||
},
|
||||
);
|
||||
done(connected);
|
||||
setSmartWalletConnectionStatus("idle");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setSmartWalletConnectionStatus("connect-error");
|
||||
}
|
||||
}, [client, done, personalWallet, props.accountAbstraction]);
|
||||
}, [done, personalWallet, client, props.accountAbstraction]);
|
||||
|
||||
const connectStarted = useRef(false);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
|
||||
import {
|
||||
type WaitForReceiptOptions,
|
||||
waitForReceipt as doWaitForReceipt,
|
||||
@@ -58,6 +59,12 @@ export type TransactionButtonProps = {
|
||||
* The `React.ReactNode` to be rendered inside the button
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
|
||||
/**
|
||||
* Configuration for gasless transactions.
|
||||
* Refer to [`GaslessOptions`](https://portal.thirdweb.com/references/typescript/v5/GaslessOptions) for more details.
|
||||
*/
|
||||
gasless?: GaslessOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -85,13 +92,14 @@ export function TransactionButton(props: TransactionButtonProps) {
|
||||
onTransactionConfirmed,
|
||||
onError,
|
||||
onClick,
|
||||
gasless,
|
||||
...buttonProps
|
||||
} = props;
|
||||
const account = useActiveAccount();
|
||||
const wallet = useActiveWallet();
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
|
||||
const sendTransaction = useSendTransactionCore();
|
||||
const sendTransaction = useSendTransactionCore(undefined, gasless);
|
||||
|
||||
if (!isPending) {
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import type { Chain } from "../../chains/types.js";
|
||||
import type { ThirdwebClient } from "../../client/client.js";
|
||||
import { computedStore } from "../../reactive/computedStore.js";
|
||||
import { effect } from "../../reactive/effect.js";
|
||||
import { createStore } from "../../reactive/store.js";
|
||||
import { smartWallet } from "../create-wallet.js";
|
||||
import type { Account, Wallet } from "../interfaces/wallet.js";
|
||||
import type { SmartWalletOptions } from "../smart/types.js";
|
||||
import type { AsyncStorage } from "../storage/AsyncStorage.js";
|
||||
import { deleteConnectParamsFromStorage } from "../storage/walletStorage.js";
|
||||
|
||||
@@ -10,10 +13,14 @@ type WalletIdToConnectedWalletMap = Map<string, Wallet>;
|
||||
export type ConnectionStatus = "connected" | "disconnected" | "connecting";
|
||||
|
||||
const CONNECTED_WALLET_IDS = "thirdweb:connected-wallet-ids";
|
||||
const ACTIVE_WALLET_ID = "thirdweb:active-wallet-id";
|
||||
const LAST_ACTIVE_EOA_ID = "thirdweb:active-wallet-id";
|
||||
const LAST_ACTIVE_CHAIN = "thirdweb:active-chain";
|
||||
|
||||
export type ConnectionManager = ReturnType<typeof createConnectionManager>;
|
||||
export type ConnectManagerOptions = {
|
||||
client: ThirdwebClient;
|
||||
accountAbstraction?: SmartWalletOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a connection manager for Wallet connections
|
||||
@@ -48,6 +55,9 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
// actions
|
||||
const addConnectedWallet = (wallet: Wallet) => {
|
||||
const oldValue = walletIdToConnectedWalletMap.getValue();
|
||||
if (oldValue.has(wallet.id)) {
|
||||
return;
|
||||
}
|
||||
const newValue = new Map(oldValue);
|
||||
newValue.set(wallet.id, wallet);
|
||||
walletIdToConnectedWalletMap.setValue(newValue);
|
||||
@@ -71,7 +81,7 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
|
||||
// if disconnecting the active wallet
|
||||
if (activeWalletStore.getValue() === wallet) {
|
||||
activeWalletStore.setValue(undefined);
|
||||
storage.removeItem(LAST_ACTIVE_EOA_ID);
|
||||
activeAccountStore.setValue(undefined);
|
||||
activeWalletChainStore.setValue(undefined);
|
||||
activeWalletConnectionStatusStore.setValue("disconnected");
|
||||
@@ -83,22 +93,58 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
wallet.disconnect();
|
||||
};
|
||||
|
||||
const setActiveWallet = (wallet: Wallet) => {
|
||||
// handle the connection logic, but don't set the wallet as active
|
||||
const handleConnection = async (
|
||||
wallet: Wallet,
|
||||
options?: ConnectManagerOptions,
|
||||
) => {
|
||||
const account = wallet.getAccount();
|
||||
if (!account) {
|
||||
throw new Error("Can not a wallet without an account as active");
|
||||
throw new Error("Can not set a wallet without an account as active");
|
||||
}
|
||||
|
||||
const personalWallet = wallet;
|
||||
let activeWallet = personalWallet;
|
||||
if (options?.accountAbstraction) {
|
||||
activeWallet = smartWallet(options.accountAbstraction);
|
||||
await activeWallet.connect({
|
||||
personalAccount: wallet.getAccount(),
|
||||
client: options.client,
|
||||
});
|
||||
}
|
||||
|
||||
handleSetActiveWallet(activeWallet);
|
||||
|
||||
// add personal wallet to connected wallets list
|
||||
addConnectedWallet(personalWallet);
|
||||
|
||||
if (personalWallet.id !== "smart") {
|
||||
storage.setItem(LAST_ACTIVE_EOA_ID, personalWallet.id);
|
||||
}
|
||||
|
||||
return activeWallet;
|
||||
};
|
||||
|
||||
const connect = async (wallet: Wallet, options?: ConnectManagerOptions) => {
|
||||
// connectedWallet can be either wallet or smartWallet based on
|
||||
const connectedWallet = await handleConnection(wallet, options);
|
||||
handleSetActiveWallet(connectedWallet);
|
||||
return connectedWallet;
|
||||
};
|
||||
|
||||
const handleSetActiveWallet = (activeWallet: Wallet) => {
|
||||
const account = activeWallet.getAccount();
|
||||
if (!account) {
|
||||
throw new Error("Can not set a wallet without an account as active");
|
||||
}
|
||||
|
||||
// also add it to connected wallets if it's not already there
|
||||
const _connectedWalletsMap = walletIdToConnectedWalletMap.getValue();
|
||||
if (!_connectedWalletsMap.has(wallet.id)) {
|
||||
addConnectedWallet(wallet);
|
||||
}
|
||||
addConnectedWallet(activeWallet);
|
||||
|
||||
// update active states
|
||||
activeWalletStore.setValue(wallet);
|
||||
activeWalletStore.setValue(activeWallet);
|
||||
activeAccountStore.setValue(account);
|
||||
activeWalletChainStore.setValue(wallet.getChain());
|
||||
activeWalletChainStore.setValue(activeWallet.getChain());
|
||||
activeWalletConnectionStatusStore.setValue("connected");
|
||||
|
||||
// setup listeners
|
||||
@@ -107,24 +153,34 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
activeAccountStore.setValue(newAccount);
|
||||
};
|
||||
|
||||
const unsubAccounts = wallet.subscribe("accountChanged", onAccountsChanged);
|
||||
const unsubAccounts = activeWallet.subscribe(
|
||||
"accountChanged",
|
||||
onAccountsChanged,
|
||||
);
|
||||
|
||||
const unsubChainChanged = wallet.subscribe("chainChanged", (chain) =>
|
||||
const unsubChainChanged = activeWallet.subscribe("chainChanged", (chain) =>
|
||||
activeWalletChainStore.setValue(chain),
|
||||
);
|
||||
const unsubDisconnect = wallet.subscribe("disconnect", () => {
|
||||
const unsubDisconnect = activeWallet.subscribe("disconnect", () => {
|
||||
handleDisconnect();
|
||||
});
|
||||
|
||||
const handleDisconnect = () => {
|
||||
onWalletDisconnect(wallet);
|
||||
|
||||
onWalletDisconnect(activeWallet);
|
||||
unsubAccounts();
|
||||
unsubChainChanged();
|
||||
unsubDisconnect();
|
||||
};
|
||||
};
|
||||
|
||||
const setActiveWallet = async (activeWallet: Wallet) => {
|
||||
handleSetActiveWallet(activeWallet);
|
||||
// do not set smart wallet as last active EOA
|
||||
if (activeWallet.id !== "smart") {
|
||||
storage.setItem(LAST_ACTIVE_EOA_ID, activeWallet.id);
|
||||
}
|
||||
};
|
||||
|
||||
// side effects
|
||||
|
||||
effect(
|
||||
@@ -152,20 +208,6 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
false,
|
||||
);
|
||||
|
||||
// save active wallet id to storage
|
||||
effect(
|
||||
() => {
|
||||
const value = activeWalletStore.getValue()?.id;
|
||||
if (value) {
|
||||
storage.setItem(ACTIVE_WALLET_ID, value);
|
||||
} else {
|
||||
storage.removeItem(ACTIVE_WALLET_ID);
|
||||
}
|
||||
},
|
||||
[activeWalletStore],
|
||||
false,
|
||||
);
|
||||
|
||||
const switchActiveWalletChain = async (chain: Chain) => {
|
||||
const wallet = activeWalletStore.getValue();
|
||||
if (!wallet) {
|
||||
@@ -189,6 +231,8 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
addConnectedWallet,
|
||||
disconnectWallet,
|
||||
setActiveWallet,
|
||||
connect,
|
||||
handleConnection,
|
||||
activeWalletChainStore: activeWalletChainStore,
|
||||
switchActiveWalletChain,
|
||||
activeWalletConnectionStatusStore: activeWalletConnectionStatusStore,
|
||||
@@ -222,7 +266,7 @@ export async function getStoredActiveWalletId(
|
||||
storage: AsyncStorage,
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
const value = await storage.getItem(ACTIVE_WALLET_ID);
|
||||
const value = await storage.getItem(LAST_ACTIVE_EOA_ID);
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
Binary file not shown.
Generated
+1
-1
@@ -19526,7 +19526,7 @@ packages:
|
||||
engines: {node: '>=10.0.0'}
|
||||
dependencies:
|
||||
'@metamask/safe-event-emitter': 2.0.0
|
||||
eth-rpc-errors: 4.0.2
|
||||
eth-rpc-errors: 4.0.3
|
||||
dev: false
|
||||
|
||||
/[email protected]:
|
||||
|
||||
Reference in New Issue
Block a user