Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9deda6f4b | ||
|
|
b91d3e9901 | ||
|
|
d248aa2c5a | ||
|
|
8f3b685ad2 | ||
|
|
26349f311d | ||
|
|
2897576513 | ||
|
|
07fb1b5ffa | ||
|
|
300a3c6f04 | ||
|
|
26367c04f3 | ||
|
|
39e2af6f2f | ||
|
|
a5ba9e4fbf | ||
|
|
c9b0131acd | ||
|
|
34b315993c | ||
|
|
14d9a71c92 | ||
|
|
7f5311222b | ||
|
|
b4847dd134 | ||
|
|
cf82c3b58c | ||
|
|
a17326634e | ||
|
|
70c4a119d6 | ||
|
|
f0443bd989 | ||
|
|
73462ef108 | ||
|
|
27c225a512 | ||
|
|
cb1c9937fa | ||
|
|
588b210601 | ||
|
|
7e483ec97f | ||
|
|
c902901cff | ||
|
|
205018f6e1 | ||
|
|
269e68c0a1 | ||
|
|
2888efc065 | ||
|
|
c753641570 | ||
|
|
4b0e63dcc0 | ||
|
|
6979810de5 | ||
|
|
4c37af49aa |
@@ -0,0 +1,13 @@
|
|||||||
|
## Problem solved
|
||||||
|
|
||||||
|
Short description of the bug fixed or feature added
|
||||||
|
|
||||||
|
## Changes made
|
||||||
|
|
||||||
|
- [ ] Public API changes: list the public API changes made if any
|
||||||
|
- [ ] Internal API changes: explain the internal logic changes
|
||||||
|
|
||||||
|
## How to test
|
||||||
|
|
||||||
|
- [ ] Automated tests: link to unit test file
|
||||||
|
- [ ] Manual tests: step by step instructions on how to test
|
||||||
@@ -17,6 +17,7 @@ concurrency:
|
|||||||
env:
|
env:
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||||
|
TW_SECRET_KEY: ${{ secrets.TW_SECRET_KEY }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
"hotlink-revert": "node ./scripts/hotlink/hotlink-revert.mjs",
|
"hotlink-revert": "node ./scripts/hotlink/hotlink-revert.mjs",
|
||||||
"explain:major": "node ./scripts/changeset-explain-major.mjs"
|
"explain:major": "node ./scripts/changeset-explain-major.mjs"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@8.1.0",
|
"packageManager": "pnpm@8.6.12",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@changesets/changelog-github": "^0.4.8",
|
"@changesets/changelog-github": "^0.4.8",
|
||||||
"@changesets/cli": "^2.26.2",
|
"@changesets/cli": "^2.26.2",
|
||||||
|
|||||||
@@ -1,5 +1,40 @@
|
|||||||
# @thirdweb-dev/auth
|
# @thirdweb-dev/auth
|
||||||
|
|
||||||
|
## 3.2.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.15
|
||||||
|
|
||||||
|
## 3.2.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.14
|
||||||
|
|
||||||
|
## 3.2.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.13
|
||||||
|
|
||||||
|
## 3.2.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.12
|
||||||
|
|
||||||
|
## 3.2.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`4b0e63dc`](https://github.com/thirdweb-dev/js/commit/4b0e63dcc0ca871ce9cef76f8a41ff290316741c)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.11
|
||||||
|
|
||||||
## 3.2.27
|
## 3.2.27
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/auth",
|
"name": "@thirdweb-dev/auth",
|
||||||
"version": "3.2.27",
|
"version": "3.2.32",
|
||||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||||
"browser": {
|
"browser": {
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
# @thirdweb-dev/chains
|
# @thirdweb-dev/chains
|
||||||
|
|
||||||
|
## 0.1.44
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1499](https://github.com/thirdweb-dev/js/pull/1499) [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf) Thanks [@Marfuen](https://github.com/Marfuen)! - Update deploy command from CLI to use show a public gateway url temporarily. Updated chains too.
|
||||||
|
|
||||||
|
## 0.1.43
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1469](https://github.com/thirdweb-dev/js/pull/1469) [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308) Thanks [@jnsdls](https://github.com/jnsdls)! - update chains
|
||||||
|
|
||||||
|
- [#1474](https://github.com/thirdweb-dev/js/pull/1474) [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9) Thanks [@adam-maj](https://github.com/adam-maj)! - Add back scroll-alpha-testnet
|
||||||
|
|
||||||
|
- [#1458](https://github.com/thirdweb-dev/js/pull/1458) [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Update chains
|
||||||
|
|
||||||
|
- [#1461](https://github.com/thirdweb-dev/js/pull/1461) [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - add xai-goerli chain and support BigInteger from Unity
|
||||||
|
|
||||||
## 0.1.42
|
## 0.1.42
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Japan Open Chain Testnet",
|
||||||
|
"chain": "JOCT",
|
||||||
|
"rpc": [
|
||||||
|
"https://japan-open-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc-1.testnet.japanopenchain.org:8545",
|
||||||
|
"https://rpc-2.testnet.japanopenchain.org:8545"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Japan Open Chain Testnet Token",
|
||||||
|
"symbol": "JOCT",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://www.japanopenchain.org/",
|
||||||
|
"shortName": "joct",
|
||||||
|
"chainId": 10081,
|
||||||
|
"networkId": 10081,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Testnet Block Explorer",
|
||||||
|
"url": "https://explorer.testnet.japanopenchain.org",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "japan-open-chain-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "MaxxChain Mainnet",
|
||||||
|
"chain": "MaxxChain",
|
||||||
|
"rpc": [
|
||||||
|
"https://maxxchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.maxxchain.org",
|
||||||
|
"https://rpc1.maxxchain.org",
|
||||||
|
"https://rpc2.maxxchain.org"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.maxxchain.org"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Power",
|
||||||
|
"symbol": "PWR",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmRhQG9TZrXDdbQeTzBmjg3pqgwaD5TKVZj8k4kaz8AoZx",
|
||||||
|
"width": 1021,
|
||||||
|
"height": 1021,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"infoURL": "https://www.maxxchain.org/",
|
||||||
|
"shortName": "PWR",
|
||||||
|
"chainId": 10201,
|
||||||
|
"networkId": 10201,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "MaxxChain Block Explorer",
|
||||||
|
"url": "https://explorer.maxxchain.org",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "maxxchain"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -3,7 +3,7 @@ export default {
|
|||||||
"name": "Ultron Testnet",
|
"name": "Ultron Testnet",
|
||||||
"chain": "Ultron",
|
"chain": "Ultron",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmS4W4kY7XYBA4f52vuuytXh3YaTcNBXF14V9tEY6SNqhz",
|
"url": "ipfs://QmPC6odFVyAQrXJQaZJVFpEQfRNbzZ5BjDZ7KBKmXPaYDw",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
@@ -27,7 +27,7 @@ export default {
|
|||||||
"name": "Ultron Testnet Explorer",
|
"name": "Ultron Testnet Explorer",
|
||||||
"url": "https://explorer.ultron-dev.io",
|
"url": "https://explorer.ultron-dev.io",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmS4W4kY7XYBA4f52vuuytXh3YaTcNBXF14V9tEY6SNqhz",
|
"url": "ipfs://QmPC6odFVyAQrXJQaZJVFpEQfRNbzZ5BjDZ7KBKmXPaYDw",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export default {
|
|||||||
"name": "Ultron Mainnet",
|
"name": "Ultron Mainnet",
|
||||||
"chain": "Ultron",
|
"chain": "Ultron",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmS4W4kY7XYBA4f52vuuytXh3YaTcNBXF14V9tEY6SNqhz",
|
"url": "ipfs://QmPC6odFVyAQrXJQaZJVFpEQfRNbzZ5BjDZ7KBKmXPaYDw",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
@@ -27,7 +27,7 @@ export default {
|
|||||||
"name": "Ultron Explorer",
|
"name": "Ultron Explorer",
|
||||||
"url": "https://ulxscan.com",
|
"url": "https://ulxscan.com",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmS4W4kY7XYBA4f52vuuytXh3YaTcNBXF14V9tEY6SNqhz",
|
"url": "ipfs://QmPC6odFVyAQrXJQaZJVFpEQfRNbzZ5BjDZ7KBKmXPaYDw",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Swisstronik Testnet",
|
||||||
|
"chain": "SWTR",
|
||||||
|
"rpc": [
|
||||||
|
"https://swisstronik-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://json-rpc.testnet.swisstronik.com"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.testnet.swisstronik.com"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Swisstronik",
|
||||||
|
"symbol": "SWTR",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"name": "EIP155"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EIP1559"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"infoURL": "https://www.swisstronik.com",
|
||||||
|
"shortName": "swtr",
|
||||||
|
"chainId": 1291,
|
||||||
|
"networkId": 1291,
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://bafybeihuintkoipxalwans23vhxajbwjnozpy34ww7ia7ds7nay3rpylzi",
|
||||||
|
"width": 256,
|
||||||
|
"height": 256,
|
||||||
|
"format": "svg"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Swisstronik Scout",
|
||||||
|
"url": "https://explorer-evm.testnet.swisstronik.com",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "swisstronik-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { Chain } from "../src/types";
|
import type { Chain } from "../src/types";
|
||||||
export default {
|
export default {
|
||||||
"name": "Credit Smartchain Mainnet",
|
"name": "Credit Smart Chain",
|
||||||
"chain": "CREDIT",
|
"chain": "CREDIT",
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://credit-smartchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://credit-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://mainnet-rpc.cscscan.io"
|
"https://rpc.creditsmartchain.com"
|
||||||
],
|
],
|
||||||
"faucets": [],
|
"faucets": [],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
@@ -23,7 +23,7 @@ export default {
|
|||||||
"infoURL": "https://creditsmartchain.com",
|
"infoURL": "https://creditsmartchain.com",
|
||||||
"shortName": "Credit",
|
"shortName": "Credit",
|
||||||
"chainId": 13308,
|
"chainId": 13308,
|
||||||
"networkId": 1,
|
"networkId": 13308,
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
@@ -32,8 +32,8 @@ export default {
|
|||||||
},
|
},
|
||||||
"explorers": [
|
"explorers": [
|
||||||
{
|
{
|
||||||
"name": "CSC Scan",
|
"name": "Creditscan",
|
||||||
"url": "https://explorer.cscscan.io",
|
"url": "https://scan.creditsmartchain.com",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
@@ -44,5 +44,5 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
"slug": "credit-smartchain"
|
"slug": "credit-smart-chain"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Beam Testnet",
|
||||||
|
"chain": "BEAM",
|
||||||
|
"rpc": [
|
||||||
|
"https://beam-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://subnets.avax.network/beam/testnet/rpc"
|
||||||
|
],
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"name": "EIP1559"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Merit Circle",
|
||||||
|
"symbol": "MC",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://gaming.meritcircle.io",
|
||||||
|
"shortName": "BEAM",
|
||||||
|
"chainId": 13337,
|
||||||
|
"networkId": 13337,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Beam Explorer",
|
||||||
|
"url": "https://subnets-test.avax.network/beam",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "beam-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Humanode Testnet 5 Israfel",
|
||||||
|
"chain": "Humanode Testnet 5",
|
||||||
|
"rpc": [
|
||||||
|
"https://humanode-testnet-5-israfel.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://explorer-rpc-http.testnet5.stages.humanode.io"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://t.me/HumanodeTestnet5FaucetBot"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "HMND",
|
||||||
|
"symbol": "HMND",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://humanode.io",
|
||||||
|
"shortName": "hmnd-t5",
|
||||||
|
"chainId": 14853,
|
||||||
|
"networkId": 14853,
|
||||||
|
"explorers": [],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "humanode-testnet-5-israfel"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Holesky",
|
||||||
|
"chain": "ETH",
|
||||||
|
"rpc": [
|
||||||
|
"https://holesky.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.holesky.ethpandaops.io"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.holesky.ethpandaops.io",
|
||||||
|
"https://holesky-faucet.pk910.de"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Testnet ETH",
|
||||||
|
"symbol": "ETH",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://holesky.ethpandaops.io",
|
||||||
|
"shortName": "holesky",
|
||||||
|
"chainId": 17000,
|
||||||
|
"networkId": 17000,
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1628,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"status": "incubating",
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Holesky Explorer",
|
||||||
|
"url": "https://holesky.beaconcha.in",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1628,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "holesky"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -3,9 +3,9 @@ export default {
|
|||||||
"name": "Lightlink Phoenix Mainnet",
|
"name": "Lightlink Phoenix Mainnet",
|
||||||
"chain": "Lightlink Phoenix Mainnet",
|
"chain": "Lightlink Phoenix Mainnet",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmNRUoMgx16hurD3au3ou5A9rmTLYmre8WiGmQEPFmP2Vo",
|
"url": "ipfs://QmXMDj6iAFn2ducQcUU1M87PMMdT2jfyL3Tp3Lz5uUD5Lv",
|
||||||
"width": 600,
|
"width": 200,
|
||||||
"height": 600,
|
"height": 200,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"rpc": [
|
"rpc": [
|
||||||
@@ -33,9 +33,9 @@ export default {
|
|||||||
"name": "phoenix",
|
"name": "phoenix",
|
||||||
"url": "https://phoenix.lightlink.io",
|
"url": "https://phoenix.lightlink.io",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmNRUoMgx16hurD3au3ou5A9rmTLYmre8WiGmQEPFmP2Vo",
|
"url": "ipfs://QmXMDj6iAFn2ducQcUU1M87PMMdT2jfyL3Tp3Lz5uUD5Lv",
|
||||||
"width": 600,
|
"width": 200,
|
||||||
"height": 600,
|
"height": 200,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ export default {
|
|||||||
"name": "Lightlink Pegasus Testnet",
|
"name": "Lightlink Pegasus Testnet",
|
||||||
"chain": "Lightlink Pegasus Testnet",
|
"chain": "Lightlink Pegasus Testnet",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmNRUoMgx16hurD3au3ou5A9rmTLYmre8WiGmQEPFmP2Vo",
|
"url": "ipfs://QmXMDj6iAFn2ducQcUU1M87PMMdT2jfyL3Tp3Lz5uUD5Lv",
|
||||||
"width": 600,
|
"width": 200,
|
||||||
"height": 600,
|
"height": 200,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"rpc": [
|
"rpc": [
|
||||||
@@ -35,9 +35,9 @@ export default {
|
|||||||
"name": "pegasus",
|
"name": "pegasus",
|
||||||
"url": "https://pegasus.lightlink.io",
|
"url": "https://pegasus.lightlink.io",
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://QmNRUoMgx16hurD3au3ou5A9rmTLYmre8WiGmQEPFmP2Vo",
|
"url": "ipfs://QmXMDj6iAFn2ducQcUU1M87PMMdT2jfyL3Tp3Lz5uUD5Lv",
|
||||||
"width": 600,
|
"width": 200,
|
||||||
"height": 600,
|
"height": 200,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export default {
|
|||||||
"chain": "REAP",
|
"chain": "REAP",
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://reapchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://reapchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://test-rpc.reapchain.org"
|
"https://test-eth.reapchain.org"
|
||||||
],
|
],
|
||||||
"faucets": [
|
"faucets": [
|
||||||
"http://faucet.reapchain.com"
|
"http://faucet.reapchain.com"
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Unicorn Ultra Nebulas Testnet",
|
||||||
|
"chain": "u2u",
|
||||||
|
"rpc": [
|
||||||
|
"https://unicorn-ultra-nebulas-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc-nebulas-testnet.uniultra.xyz"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.uniultra.xyz"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Unicorn Ultra Nebulas Testnet",
|
||||||
|
"symbol": "U2U",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://uniultra.xyz",
|
||||||
|
"shortName": "u2u_nebulas",
|
||||||
|
"chainId": 2484,
|
||||||
|
"networkId": 2484,
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmcW64RgqQVHnNbVFyfaMNKt7dJvFqEbfEHZmeyeK8dpEa",
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmcW64RgqQVHnNbVFyfaMNKt7dJvFqEbfEHZmeyeK8dpEa",
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"name": "U2U Explorer",
|
||||||
|
"url": "https://testnet.u2uscan.xyz",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "unicorn-ultra-nebulas-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Orderly Sepolia Testnet",
|
||||||
|
"chain": "ETH",
|
||||||
|
"rpc": [
|
||||||
|
"https://orderly-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://l2-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Sepolia Ether",
|
||||||
|
"symbol": "ETH",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"shortName": "orderlyl2",
|
||||||
|
"chainId": 4460,
|
||||||
|
"networkId": 4460,
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmSpwp3RAVhZsErAQrCQxEmjnGqJQMigarzZbfqr9Ktakb",
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "basescout",
|
||||||
|
"url": "https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM",
|
||||||
|
"width": 551,
|
||||||
|
"height": 540,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "orderly-sepolia-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Xai Goerli Orbit",
|
||||||
|
"chain": "Xai Goerli Orbit Testnet",
|
||||||
|
"shortName": "xai-goerli",
|
||||||
|
"chainId": 47279324479,
|
||||||
|
"testnet": true,
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Xai Goerli Ether",
|
||||||
|
"symbol": "ETH",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://xai-goerli-orbit.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://testnet.xai-chain.net/rpc"
|
||||||
|
],
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Xai Goerli Testnet Explorer",
|
||||||
|
"url": "https://testnet-explorer.xai-chain.net",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"infoURL": "https://xai.games/",
|
||||||
|
"slug": "xai-goerli-orbit"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -2,8 +2,11 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "Scroll Sepolia Testnet",
|
"name": "Scroll Sepolia Testnet",
|
||||||
"chain": "ETH",
|
"chain": "ETH",
|
||||||
"status": "incubating",
|
"status": "active",
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
|
"https://scroll-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://sepolia-rpc.scroll.io/"
|
||||||
|
],
|
||||||
"faucets": [],
|
"faucets": [],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
"name": "Ether",
|
"name": "Ether",
|
||||||
@@ -14,11 +17,21 @@ export default {
|
|||||||
"shortName": "scr-sepolia",
|
"shortName": "scr-sepolia",
|
||||||
"chainId": 534351,
|
"chainId": 534351,
|
||||||
"networkId": 534351,
|
"networkId": 534351,
|
||||||
"explorers": [],
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Scroll Sepolia Testnet Block Explorer",
|
||||||
|
"url": "https://sepolia-blockscout.scroll.io",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
"parent": {
|
"parent": {
|
||||||
"type": "L2",
|
"type": "L2",
|
||||||
"chain": "eip155-11155111",
|
"chain": "eip155-11155111",
|
||||||
"bridges": []
|
"bridges": [
|
||||||
|
{
|
||||||
|
"url": "https://scroll.io/bridge"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"testnet": true,
|
"testnet": true,
|
||||||
"slug": "scroll-sepolia-testnet"
|
"slug": "scroll-sepolia-testnet"
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ export default {
|
|||||||
"name": "Scroll",
|
"name": "Scroll",
|
||||||
"chain": "ETH",
|
"chain": "ETH",
|
||||||
"status": "incubating",
|
"status": "incubating",
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
|
"https://scroll.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.scroll.io"
|
||||||
|
],
|
||||||
"faucets": [],
|
"faucets": [],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
"name": "Ether",
|
"name": "Ether",
|
||||||
@@ -14,11 +17,21 @@ export default {
|
|||||||
"shortName": "scr",
|
"shortName": "scr",
|
||||||
"chainId": 534352,
|
"chainId": 534352,
|
||||||
"networkId": 534352,
|
"networkId": 534352,
|
||||||
"explorers": [],
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Scroll Mainnet Block Explorer",
|
||||||
|
"url": "https://blockscout.scroll.io",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
"parent": {
|
"parent": {
|
||||||
"type": "L2",
|
"type": "L2",
|
||||||
"chain": "eip155-1",
|
"chain": "eip155-1",
|
||||||
"bridges": []
|
"bridges": [
|
||||||
|
{
|
||||||
|
"url": "https://scroll.io/bridge"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
"slug": "scroll"
|
"slug": "scroll"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "Scroll Alpha Testnet",
|
"name": "Scroll Alpha Testnet",
|
||||||
"chain": "ETH",
|
"chain": "ETH",
|
||||||
"status": "active",
|
"status": "deprecated",
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://scroll-alpha-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://scroll-alpha-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://alpha-rpc.scroll.io/l2"
|
"https://alpha-rpc.scroll.io/l2"
|
||||||
@@ -20,12 +20,7 @@ export default {
|
|||||||
"explorers": [
|
"explorers": [
|
||||||
{
|
{
|
||||||
"name": "Scroll Alpha Testnet Block Explorer",
|
"name": "Scroll Alpha Testnet Block Explorer",
|
||||||
"url": "https://blockscout.scroll.io",
|
"url": "https://alpha-blockscout.scroll.io",
|
||||||
"standard": "EIP3091"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Scroll Alpha Testnet Block Explorer",
|
|
||||||
"url": "https://scrollscan.co",
|
|
||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "PAWCHAIN Testnet",
|
||||||
|
"chain": "PAW",
|
||||||
|
"rpc": [
|
||||||
|
"https://pawchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://pawchainx.com/"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "PAW",
|
||||||
|
"symbol": "PAW",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://pawchainx.com/",
|
||||||
|
"shortName": "PAW",
|
||||||
|
"chainId": 542,
|
||||||
|
"networkId": 542,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "PAWCHAIN Testnet",
|
||||||
|
"url": "https://pawscan.io",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "pawchain-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Miexs Smartchain",
|
||||||
|
"chain": "MiexsSmartchain",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://bafkreic6tcc6swh5kzljwqnswj6rlemcm7n6ra7xkgttwv5v3fv7ozj5zu",
|
||||||
|
"width": 1500,
|
||||||
|
"height": 1500,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://miexs-smartchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://mainnet-rpc.miexs.com"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Miexs Coin",
|
||||||
|
"symbol": "MIX",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://miexs.com",
|
||||||
|
"shortName": "Miexs",
|
||||||
|
"chainId": 761412,
|
||||||
|
"networkId": 761412,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Miexs Smartchain Explorer",
|
||||||
|
"url": "https://miexs.com",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "miexs-smartchain"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -9,7 +9,11 @@ export default {
|
|||||||
"https://evm-dataseed3.meerscan.io",
|
"https://evm-dataseed3.meerscan.io",
|
||||||
"https://evm-dataseed.meerscan.com",
|
"https://evm-dataseed.meerscan.com",
|
||||||
"https://evm-dataseed1.meerscan.com",
|
"https://evm-dataseed1.meerscan.com",
|
||||||
"https://evm-dataseed2.meerscan.com"
|
"https://evm-dataseed2.meerscan.com",
|
||||||
|
"https://qng.rpc.qitmeer.io",
|
||||||
|
"https://mainnet.meerlabs.com",
|
||||||
|
"https://rpc.dimai.ai",
|
||||||
|
"https://rpc.woowow.io"
|
||||||
],
|
],
|
||||||
"faucets": [],
|
"faucets": [],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
@@ -37,7 +41,7 @@ export default {
|
|||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"url": "https://evm.meerscan.com",
|
"url": "https://qng.meerscan.io",
|
||||||
"standard": "none"
|
"standard": "none"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,8 +2,15 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "Qitmeer Network Testnet",
|
"name": "Qitmeer Network Testnet",
|
||||||
"chain": "MEER",
|
"chain": "MEER",
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
"faucets": [],
|
"https://qitmeer-network-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://testnet-qng.rpc.qitmeer.io",
|
||||||
|
"https://testnet.meerlabs.com",
|
||||||
|
"https://meer.testnet.meerfans.club"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.qitmeer.io"
|
||||||
|
],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
"name": "Qitmeer Testnet",
|
"name": "Qitmeer Testnet",
|
||||||
"symbol": "MEER-T",
|
"symbol": "MEER-T",
|
||||||
@@ -28,7 +35,7 @@ export default {
|
|||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
},
|
},
|
||||||
"url": "https://testnet.qng.meerscan.io",
|
"url": "https://qng-testnet.meerscan.io",
|
||||||
"standard": "none"
|
"standard": "none"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "IMPERIUM TESTNET",
|
"name": "IMPERIUM TESTNET",
|
||||||
"chain": "tIMP",
|
"chain": "tIMP",
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
|
"https://imperium-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://data-aws-testnet.imperiumchain.com",
|
||||||
|
"https://data-aws2-testnet.imperiumchain.com"
|
||||||
|
],
|
||||||
"faucets": [
|
"faucets": [
|
||||||
"https://faucet.imperiumchain.com/"
|
"https://faucet.imperiumchain.com/"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "IMPERIUM MAINNET",
|
"name": "IMPERIUM MAINNET",
|
||||||
"chain": "IMP",
|
"chain": "IMP",
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
|
"https://imperium.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://data-aws-mainnet.imperiumchain.com",
|
||||||
|
"https://data-aws2-mainnet.imperiumchain.com"
|
||||||
|
],
|
||||||
"faucets": [
|
"faucets": [
|
||||||
"https://faucet.imperiumchain.com/"
|
"https://faucet.imperiumchain.com/"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Omit<Chain, "slug">} */
|
||||||
|
export default {
|
||||||
|
name: "Xai Goerli Orbit",
|
||||||
|
chain: "Xai Goerli Orbit Testnet",
|
||||||
|
shortName: "xai-goerli",
|
||||||
|
chainId: 47279324479,
|
||||||
|
testnet: true,
|
||||||
|
nativeCurrency: {
|
||||||
|
name: "Xai Goerli Ether",
|
||||||
|
symbol: "ETH",
|
||||||
|
decimals: 18,
|
||||||
|
},
|
||||||
|
rpc: ["https://testnet.xai-chain.net/rpc"],
|
||||||
|
explorers: [
|
||||||
|
{
|
||||||
|
name: "Xai Goerli Testnet Explorer",
|
||||||
|
url: "https://testnet-explorer.xai-chain.net",
|
||||||
|
standard: "EIP3091",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
faucets: [],
|
||||||
|
infoURL: "https://xai.games/",
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/chains",
|
"name": "@thirdweb-dev/chains",
|
||||||
"version": "0.1.42",
|
"version": "0.1.44",
|
||||||
"main": "dist/thirdweb-dev-chains.cjs.js",
|
"main": "dist/thirdweb-dev-chains.cjs.js",
|
||||||
"module": "dist/thirdweb-dev-chains.esm.js",
|
"module": "dist/thirdweb-dev-chains.esm.js",
|
||||||
"browser": {
|
"browser": {
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ for (const file of additionalChainsFiles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chains = chains
|
chains = chains
|
||||||
.filter((c) => c.status !== "deprecated")
|
// Keep scroll-alpha-testnet for now even though its deprecated
|
||||||
|
.filter((c) => c.status !== "deprecated" || c.chainId === 534353)
|
||||||
.map((chain) => {
|
.map((chain) => {
|
||||||
if (overrides[chain.chainId]) {
|
if (overrides[chain.chainId]) {
|
||||||
chain = merge(chain, overrides[chain.chainId], {
|
chain = merge(chain, overrides[chain.chainId], {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,47 @@
|
|||||||
# thirdweb
|
# thirdweb
|
||||||
|
|
||||||
|
## 0.11.15
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1499](https://github.com/thirdweb-dev/js/pull/1499) [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf) Thanks [@Marfuen](https://github.com/Marfuen)! - Update deploy command from CLI to use show a public gateway url temporarily. Updated chains too.
|
||||||
|
|
||||||
|
- Updated dependencies [[`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf), [`28975765`](https://github.com/thirdweb-dev/js/commit/2897576513eb6f497a9f92e3e473182b4fc9681b), [`b91d3e99`](https://github.com/thirdweb-dev/js/commit/b91d3e990198b77dc1358e738c11dc4acaa67491)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.51
|
||||||
|
- @thirdweb-dev/storage@1.2.6
|
||||||
|
- @thirdweb-dev/chains@0.1.44
|
||||||
|
|
||||||
|
## 0.11.14
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a5ba9e4f`](https://github.com/thirdweb-dev/js/commit/a5ba9e4fbfee228e5b9ac27cd0157187e3a50117), [`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.50
|
||||||
|
|
||||||
|
## 0.11.13
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.49
|
||||||
|
|
||||||
|
## 0.11.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`27c225a5`](https://github.com/thirdweb-dev/js/commit/27c225a51221417592b5940887abd1ccb8b67e47), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed), [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9), [`f0443bd9`](https://github.com/thirdweb-dev/js/commit/f0443bd989dbba50d0836d1cf274bfb2f44a53fd), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76), [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.5
|
||||||
|
- @thirdweb-dev/sdk@3.10.48
|
||||||
|
- @thirdweb-dev/chains@0.1.43
|
||||||
|
|
||||||
|
## 0.11.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`4c37af49`](https://github.com/thirdweb-dev/js/commit/4c37af49aa4fa66beb8ffe8ef556068a29f3c5d4)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.4
|
||||||
|
- @thirdweb-dev/sdk@3.10.47
|
||||||
|
|
||||||
## 0.11.10
|
## 0.11.10
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "thirdweb",
|
"name": "thirdweb",
|
||||||
"main": "dist/cli/index.js",
|
"main": "dist/cli/index.js",
|
||||||
"version": "0.11.10",
|
"version": "0.11.15",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ export async function deployApp(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const uri = await upload(storage, distPath);
|
const uri = await upload(storage, distPath);
|
||||||
return storage.resolveScheme(uri);
|
return `${uri.replace(
|
||||||
|
"ipfs://",
|
||||||
|
"https://cf-ipfs.com/ipfs/",
|
||||||
|
)}`;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Can't upload project", err);
|
console.error("Can't upload project", err);
|
||||||
return Promise.reject("Can't upload project");
|
return Promise.reject("Can't upload project");
|
||||||
|
|||||||
@@ -199,13 +199,15 @@ export async function generate(options: GenerateOptions, apiSecretKey: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
||||||
if (packageJson.scripts?.postinstall?.includes("thirdweb generate") || packageJson.scripts?.postinstall?.includes("thirdweb@latest generate")) {
|
if (
|
||||||
|
packageJson.scripts?.postinstall?.includes("thirdweb generate") ||
|
||||||
|
packageJson.scripts?.postinstall?.includes("thirdweb@latest generate")
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const postinstall = packageJson.scripts?.postinstall
|
const postinstall = packageJson.scripts?.postinstall
|
||||||
? packageJson.scripts.postinstall +
|
? packageJson.scripts.postinstall + `npx --yes thirdweb@latest generate`
|
||||||
`npx --yes thirdweb@latest generate`
|
|
||||||
: `npx --yes thirdweb@latest generate`;
|
: `npx --yes thirdweb@latest generate`;
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
|||||||
@@ -1,5 +1,61 @@
|
|||||||
# @thirdweb-dev/react-core
|
# @thirdweb-dev/react-core
|
||||||
|
|
||||||
|
## 3.14.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1489](https://github.com/thirdweb-dev/js/pull/1489) [`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9) Thanks [@iketw](https://github.com/iketw)! - Cleanup and minor bug fix in ReactCore
|
||||||
|
|
||||||
|
- [#1486](https://github.com/thirdweb-dev/js/pull/1486) [`300a3c6f`](https://github.com/thirdweb-dev/js/commit/300a3c6f04d0ea7e25dfdb0a4c28b3a5796fcadf) Thanks [@iketw](https://github.com/iketw)! - Add better error messages when using hooks outside the <ThirdwebProvider />
|
||||||
|
|
||||||
|
- Updated dependencies [[`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf), [`28975765`](https://github.com/thirdweb-dev/js/commit/2897576513eb6f497a9f92e3e473182b4fc9681b), [`b91d3e99`](https://github.com/thirdweb-dev/js/commit/b91d3e990198b77dc1358e738c11dc4acaa67491)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.15
|
||||||
|
- @thirdweb-dev/sdk@3.10.51
|
||||||
|
- @thirdweb-dev/storage@1.2.6
|
||||||
|
- @thirdweb-dev/chains@0.1.44
|
||||||
|
- @thirdweb-dev/auth@3.2.32
|
||||||
|
|
||||||
|
## 3.14.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74), [`a5ba9e4f`](https://github.com/thirdweb-dev/js/commit/a5ba9e4fbfee228e5b9ac27cd0157187e3a50117), [`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.14
|
||||||
|
- @thirdweb-dev/sdk@3.10.50
|
||||||
|
- @thirdweb-dev/auth@3.2.31
|
||||||
|
|
||||||
|
## 3.14.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.13
|
||||||
|
- @thirdweb-dev/sdk@3.10.49
|
||||||
|
- @thirdweb-dev/auth@3.2.30
|
||||||
|
|
||||||
|
## 3.14.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`27c225a5`](https://github.com/thirdweb-dev/js/commit/27c225a51221417592b5940887abd1ccb8b67e47), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed), [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9), [`f0443bd9`](https://github.com/thirdweb-dev/js/commit/f0443bd989dbba50d0836d1cf274bfb2f44a53fd), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76), [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.5
|
||||||
|
- @thirdweb-dev/wallets@1.1.12
|
||||||
|
- @thirdweb-dev/sdk@3.10.48
|
||||||
|
- @thirdweb-dev/chains@0.1.43
|
||||||
|
- @thirdweb-dev/auth@3.2.29
|
||||||
|
|
||||||
|
## 3.14.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1460](https://github.com/thirdweb-dev/js/pull/1460) [`4b0e63dc`](https://github.com/thirdweb-dev/js/commit/4b0e63dcc0ca871ce9cef76f8a41ff290316741c) Thanks [@MananTank](https://github.com/MananTank)! - Save `oAuthRedirectResult` when autoconnecting Magic Link via social login
|
||||||
|
|
||||||
|
- Updated dependencies [[`4c37af49`](https://github.com/thirdweb-dev/js/commit/4c37af49aa4fa66beb8ffe8ef556068a29f3c5d4), [`4b0e63dc`](https://github.com/thirdweb-dev/js/commit/4b0e63dcc0ca871ce9cef76f8a41ff290316741c)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.4
|
||||||
|
- @thirdweb-dev/wallets@1.1.11
|
||||||
|
- @thirdweb-dev/sdk@3.10.47
|
||||||
|
- @thirdweb-dev/auth@3.2.28
|
||||||
|
|
||||||
## 3.14.27
|
## 3.14.27
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-core",
|
"name": "@thirdweb-dev/react-core",
|
||||||
"version": "3.14.27",
|
"version": "3.14.32",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -229,7 +229,11 @@ export function ThirdwebWalletProvider(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const parsedWallet = JSON.parse(lastConnectedWallet as string);
|
const parsedWallet = JSON.parse(lastConnectedWallet as string);
|
||||||
parsedWallet.connectParams.chainId = chainId;
|
if (parsedWallet.connectParams) {
|
||||||
|
parsedWallet.connectParams.chainId = chainId;
|
||||||
|
} else {
|
||||||
|
parsedWallet.connectParams = { chainId };
|
||||||
|
}
|
||||||
await lastConnectedWalletStorage.setItem(
|
await lastConnectedWalletStorage.setItem(
|
||||||
LAST_CONNECTED_WALLET_STORAGE_KEY,
|
LAST_CONNECTED_WALLET_STORAGE_KEY,
|
||||||
JSON.stringify(parsedWallet),
|
JSON.stringify(parsedWallet),
|
||||||
@@ -317,7 +321,7 @@ export function ThirdwebWalletProvider(
|
|||||||
),
|
),
|
||||||
{
|
{
|
||||||
ms: autoConnectTimeout,
|
ms: autoConnectTimeout,
|
||||||
message: "Failed to Auto connect. Auto connect timed out.",
|
message: autoConnectTimeoutErrorMessage,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -346,7 +350,7 @@ export function ThirdwebWalletProvider(
|
|||||||
setConnectionStatus("connecting");
|
setConnectionStatus("connecting");
|
||||||
await timeoutPromise(wallet.autoConnect(walletInfo.connectParams), {
|
await timeoutPromise(wallet.autoConnect(walletInfo.connectParams), {
|
||||||
ms: autoConnectTimeout,
|
ms: autoConnectTimeout,
|
||||||
message: "Failed to Auto connect. Auto connect timed out.",
|
message: autoConnectTimeoutErrorMessage,
|
||||||
});
|
});
|
||||||
setConnectedWallet(wallet, walletInfo.connectParams, true);
|
setConnectedWallet(wallet, walletInfo.connectParams, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -552,3 +556,5 @@ function timeoutPromise<T>(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const autoConnectTimeoutErrorMessage = `Failed to Auto connect. Auto connect timed out. You can increase the timeout duration using the autoConnectTimeout prop on <ThirdwebProvider />`;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { Chain, defaultChains } from "@thirdweb-dev/chains";
|
import { Chain } from "@thirdweb-dev/chains";
|
||||||
import React, { createContext, PropsWithChildren, useContext } from "react";
|
import React, { createContext, PropsWithChildren, useContext } from "react";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
interface ThirdwebConfigContext {
|
interface ThirdwebConfigContext {
|
||||||
chains: Chain[];
|
chains: Chain[];
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThirdwebConfigContext =
|
export const ThirdwebConfigContext = /* @__PURE__ */ createContext<
|
||||||
/* @__PURE__ */ createContext<ThirdwebConfigContext>({
|
ThirdwebConfigContext | undefined
|
||||||
chains: defaultChains,
|
>(undefined);
|
||||||
});
|
|
||||||
|
|
||||||
export const ThirdwebConfigProvider: React.FC<
|
export const ThirdwebConfigProvider: React.FC<
|
||||||
PropsWithChildren<{
|
PropsWithChildren<{
|
||||||
@@ -22,5 +22,10 @@ export const ThirdwebConfigProvider: React.FC<
|
|||||||
);
|
);
|
||||||
|
|
||||||
export function useThirdwebConfigContext() {
|
export function useThirdwebConfigContext() {
|
||||||
return useContext(ThirdwebConfigContext);
|
const context = useContext(ThirdwebConfigContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useThirdwebConfigContext() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useSDK } from "../hooks/useSDK";
|
import { useSDK } from "../hooks/useSDK";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
interface ThirdwebConnectedWalletContext {
|
interface ThirdwebConnectedWalletContext {
|
||||||
wallet: UserWallet | undefined;
|
wallet: UserWallet | undefined;
|
||||||
@@ -26,10 +27,9 @@ const INITIAL_CONTEXT_VALUE: ThirdwebConnectedWalletContext = {
|
|||||||
signer: undefined,
|
signer: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThirdwebConnectedWalletContext =
|
export const ThirdwebConnectedWalletContext = /* @__PURE__ */ createContext<
|
||||||
/* @__PURE__ */ createContext<ThirdwebConnectedWalletContext>(
|
ThirdwebConnectedWalletContext | undefined
|
||||||
INITIAL_CONTEXT_VALUE,
|
>(undefined);
|
||||||
);
|
|
||||||
|
|
||||||
export const ThirdwebConnectedWalletProvider: React.FC<
|
export const ThirdwebConnectedWalletProvider: React.FC<
|
||||||
PropsWithChildren<{ signer?: Signer }>
|
PropsWithChildren<{ signer?: Signer }>
|
||||||
@@ -115,5 +115,10 @@ export const ThirdwebConnectedWalletProvider: React.FC<
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function useThirdwebConnectedWalletContext() {
|
export function useThirdwebConnectedWalletContext() {
|
||||||
return useContext(ThirdwebConnectedWalletContext);
|
const context = useContext(ThirdwebConnectedWalletContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useThirdwebConnectedWalletContext() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ export function useAuth() {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ThirdwebAuth(wallet, authConfig.domain)
|
return new ThirdwebAuth(wallet, authConfig.domain);
|
||||||
}, [wallet, authConfig, authConfig?.domain])
|
}, [wallet, authConfig?.domain]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import { useThirdwebConnectedWalletContext } from "../contexts/thirdweb-wallet";
|
import { useContext } from "react";
|
||||||
|
import { ThirdwebConnectedWalletContext } from "../contexts/thirdweb-wallet";
|
||||||
import type { Signer } from "ethers";
|
import type { Signer } from "ethers";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export function useSigner(): Signer | undefined {
|
export function useSigner(): Signer | undefined {
|
||||||
return useThirdwebConnectedWalletContext().signer;
|
const context = useContext(ThirdwebConnectedWalletContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useSigner() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context.signer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import { useThirdwebConfigContext } from "../contexts/thirdweb-config";
|
import { useContext } from "react";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
import { ThirdwebConfigContext } from "../contexts/thirdweb-config";
|
||||||
|
|
||||||
export function useSupportedChains() {
|
export function useSupportedChains() {
|
||||||
return useThirdwebConfigContext().chains;
|
const context = useContext(ThirdwebConfigContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useSupportedChains() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context.chains;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { useThirdwebConnectedWalletContext } from "../contexts/thirdweb-wallet";
|
import invariant from "tiny-invariant";
|
||||||
|
import {
|
||||||
|
ThirdwebConnectedWalletContext,
|
||||||
|
useThirdwebConnectedWalletContext,
|
||||||
|
} from "../contexts/thirdweb-wallet";
|
||||||
import { ContractAddress } from "../types";
|
import { ContractAddress } from "../types";
|
||||||
import { cacheKeys } from "../utils/cache-keys";
|
import { cacheKeys } from "../utils/cache-keys";
|
||||||
import { useSupportedChains } from "./useSupportedChains";
|
import { useSupportedChains } from "./useSupportedChains";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { Chain, defaultChains } from "@thirdweb-dev/chains";
|
import { Chain, defaultChains } from "@thirdweb-dev/chains";
|
||||||
import { useMemo } from "react";
|
import { useContext, useMemo } from "react";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A hook to get the native or (optional) ERC20 token balance of the connected wallet.
|
* A hook to get the native or (optional) ERC20 token balance of the connected wallet.
|
||||||
@@ -40,7 +44,12 @@ export function useBalance(tokenAddress?: ContractAddress) {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export function useConnectedWallet() {
|
export function useConnectedWallet() {
|
||||||
return useThirdwebConnectedWalletContext().wallet;
|
const context = useContext(ThirdwebConnectedWalletContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useConnectedWallet() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context.signer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +80,12 @@ export function useConnectedWallet() {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function useAddress(): string | undefined {
|
export function useAddress(): string | undefined {
|
||||||
return useThirdwebConnectedWalletContext().address;
|
const context = useContext(ThirdwebConnectedWalletContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useAddress() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context.address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +110,12 @@ export function useAddress(): string | undefined {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function useChainId(): number | undefined {
|
export function useChainId(): number | undefined {
|
||||||
return useThirdwebConnectedWalletContext().chainId;
|
const context = useContext(ThirdwebConnectedWalletContext);
|
||||||
|
invariant(
|
||||||
|
context,
|
||||||
|
"useChainId() hook must be used within a <ThirdwebProvider/>",
|
||||||
|
);
|
||||||
|
return context.chainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @thirdweb-dev/react-native-compat
|
# @thirdweb-dev/react-native-compat
|
||||||
|
|
||||||
|
## 0.2.51
|
||||||
|
|
||||||
|
## 0.2.50
|
||||||
|
|
||||||
|
## 0.2.49
|
||||||
|
|
||||||
|
## 0.2.48
|
||||||
|
|
||||||
|
## 0.2.47
|
||||||
|
|
||||||
## 0.2.46
|
## 0.2.46
|
||||||
|
|
||||||
## 0.2.45
|
## 0.2.45
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-native-compat",
|
"name": "@thirdweb-dev/react-native-compat",
|
||||||
"description": "Shims for Thirdweb in React Native Projects",
|
"description": "Shims for Thirdweb in React Native Projects",
|
||||||
"version": "0.2.46",
|
"version": "0.2.51",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -1,5 +1,97 @@
|
|||||||
# @thirdweb-dev/react-native
|
# @thirdweb-dev/react-native
|
||||||
|
|
||||||
|
## 0.2.51
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1489](https://github.com/thirdweb-dev/js/pull/1489) [`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9) Thanks [@iketw](https://github.com/iketw)! - Adding walletConnect as a supportedWallet in React Native
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import {
|
||||||
|
localWallet,
|
||||||
|
ThirdwebProvider,
|
||||||
|
walletConnect,
|
||||||
|
} from "@thirdweb-dev/react-native";
|
||||||
|
import { Ethereum } from "@thirdweb-dev/chains";
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
const activeChain = Ethereum;
|
||||||
|
return (
|
||||||
|
<ThirdwebProvider
|
||||||
|
activeChain={activeChain}
|
||||||
|
supportedChains={[activeChain]}
|
||||||
|
clientId="your-client-id"
|
||||||
|
supportedWallets={[
|
||||||
|
localWallet(),
|
||||||
|
walletConnect({
|
||||||
|
projectId: "your-wallet-connect-project-id", // optional, but we recommend you get your own for production
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<AppInner />
|
||||||
|
</ThirdwebProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
- [#1496](https://github.com/thirdweb-dev/js/pull/1496) [`26349f31`](https://github.com/thirdweb-dev/js/commit/26349f311d144d692c69a6c2a7ec0f34949851d4) Thanks [@iketw](https://github.com/iketw)! - Improves loading states when disconnecting and fetching balances
|
||||||
|
|
||||||
|
- Updated dependencies [[`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9), [`300a3c6f`](https://github.com/thirdweb-dev/js/commit/300a3c6f04d0ea7e25dfdb0a4c28b3a5796fcadf), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf), [`28975765`](https://github.com/thirdweb-dev/js/commit/2897576513eb6f497a9f92e3e473182b4fc9681b), [`b91d3e99`](https://github.com/thirdweb-dev/js/commit/b91d3e990198b77dc1358e738c11dc4acaa67491)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 0.2.50
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74), [`a5ba9e4f`](https://github.com/thirdweb-dev/js/commit/a5ba9e4fbfee228e5b9ac27cd0157187e3a50117), [`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 0.2.49
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1479](https://github.com/thirdweb-dev/js/pull/1479) [`14d9a71c`](https://github.com/thirdweb-dev/js/commit/14d9a71c928019907618cc8694af0bc631e94b68) Thanks [@iketw](https://github.com/iketw)! - Deprecates magicWallet in favor of magicLink for consistency with our React package
|
||||||
|
|
||||||
|
- [#1477](https://github.com/thirdweb-dev/js/pull/1477) [`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Pass unauth'd RPCs to wallets when adding new chains
|
||||||
|
|
||||||
|
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 0.2.48
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1458](https://github.com/thirdweb-dev/js/pull/1458) [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add `hideTestnetFaucet` to hide the "Request Testnet funds" button in ConnectWallet details dropdown in `@thirdweb-dev/react-native` and `@thirdweb-dev/react`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
<ConnectWallet hideTestnetFaucet={true} />
|
||||||
|
```
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`27c225a5`](https://github.com/thirdweb-dev/js/commit/27c225a51221417592b5940887abd1ccb8b67e47), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed), [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9), [`f0443bd9`](https://github.com/thirdweb-dev/js/commit/f0443bd989dbba50d0836d1cf274bfb2f44a53fd), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76), [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 0.2.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`4c37af49`](https://github.com/thirdweb-dev/js/commit/4c37af49aa4fa66beb8ffe8ef556068a29f3c5d4), [`4b0e63dc`](https://github.com/thirdweb-dev/js/commit/4b0e63dcc0ca871ce9cef76f8a41ff290316741c)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
## 0.2.46
|
## 0.2.46
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-native",
|
"name": "@thirdweb-dev/react-native",
|
||||||
"version": "0.2.46",
|
"version": "0.2.51",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
|
|||||||
) {
|
) {
|
||||||
return reject(
|
return reject(
|
||||||
new Error(
|
new Error(
|
||||||
`This looks like a network error, the endpoint might be blocked by an internet provider or a firewall. ${xhr.responseText}`,
|
`Upload failed due to a network error. ${xhr.responseText}`,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ export type ConnectWalletProps = {
|
|||||||
* render custom rows in the Connect Wallet Details modal
|
* render custom rows in the Connect Wallet Details modal
|
||||||
*/
|
*/
|
||||||
extraRows?: ConnectWalletDetailsProps["extraRows"];
|
extraRows?: ConnectWalletDetailsProps["extraRows"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide option to request testnet funds for testnets in dropdown
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
hideTestnetFaucet?: boolean;
|
||||||
} & ConnectWalletButtonProps;
|
} & ConnectWalletButtonProps;
|
||||||
|
|
||||||
export const ConnectWallet = ({
|
export const ConnectWallet = ({
|
||||||
@@ -27,6 +34,7 @@ export const ConnectWallet = ({
|
|||||||
buttonTitle,
|
buttonTitle,
|
||||||
modalTitle,
|
modalTitle,
|
||||||
extraRows,
|
extraRows,
|
||||||
|
hideTestnetFaucet,
|
||||||
}: ConnectWalletProps) => {
|
}: ConnectWalletProps) => {
|
||||||
const fadeAnim = useRef(new Animated.Value(0)).current;
|
const fadeAnim = useRef(new Animated.Value(0)).current;
|
||||||
const address = useAddress();
|
const address = useAddress();
|
||||||
@@ -47,6 +55,7 @@ export const ConnectWallet = ({
|
|||||||
address={address}
|
address={address}
|
||||||
detailsButton={detailsButton}
|
detailsButton={detailsButton}
|
||||||
extraRows={extraRows}
|
extraRows={extraRows}
|
||||||
|
hideTestnetFaucet={hideTestnetFaucet}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ConnectWalletButton
|
<ConnectWalletButton
|
||||||
|
|||||||
+3
-1
@@ -32,11 +32,13 @@ export const ConnectWalletDetailsModal = ({
|
|||||||
onClosePress,
|
onClosePress,
|
||||||
extraRows,
|
extraRows,
|
||||||
address,
|
address,
|
||||||
|
hideTestnetFaucet,
|
||||||
}: {
|
}: {
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
onClosePress: () => void;
|
onClosePress: () => void;
|
||||||
extraRows?: React.FC;
|
extraRows?: React.FC;
|
||||||
address?: string;
|
address?: string;
|
||||||
|
hideTestnetFaucet?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useAppTheme();
|
const theme = useAppTheme();
|
||||||
const [isExportModalVisible, setIsExportModalVisible] = useState(false);
|
const [isExportModalVisible, setIsExportModalVisible] = useState(false);
|
||||||
@@ -198,7 +200,7 @@ export const ConnectWalletDetailsModal = ({
|
|||||||
<Text variant="bodySmallSecondary">Current Network</Text>
|
<Text variant="bodySmallSecondary">Current Network</Text>
|
||||||
</View>
|
</View>
|
||||||
<NetworkButton chain={chain} enableSwitchModal={true} />
|
<NetworkButton chain={chain} enableSwitchModal={true} />
|
||||||
{chain?.testnet && chain?.faucets?.length ? (
|
{!hideTestnetFaucet && chain?.testnet && chain?.faucets?.length ? (
|
||||||
<IconTextButton
|
<IconTextButton
|
||||||
mt="xs"
|
mt="xs"
|
||||||
text="Request Testnet Funds"
|
text="Request Testnet Funds"
|
||||||
|
|||||||
+6
-8
@@ -3,27 +3,29 @@ import BaseButton from "../base/BaseButton";
|
|||||||
import { ChainIcon } from "../base/ChainIcon";
|
import { ChainIcon } from "../base/ChainIcon";
|
||||||
import Text from "../base/Text";
|
import Text from "../base/Text";
|
||||||
import { WalletIcon } from "../base/WalletIcon";
|
import { WalletIcon } from "../base/WalletIcon";
|
||||||
import { useWallet, useBalance, useChain } from "@thirdweb-dev/react-core";
|
import { useWallet, useChain } from "@thirdweb-dev/react-core";
|
||||||
import { StyleSheet, View } from "react-native";
|
import { StyleSheet, View } from "react-native";
|
||||||
import { LocalWallet } from "@thirdweb-dev/wallets";
|
import { LocalWallet } from "@thirdweb-dev/wallets";
|
||||||
import Box from "../base/Box";
|
import Box from "../base/Box";
|
||||||
import { ConnectWalletDetailsModal } from "./ConnectWalletDetailsModal";
|
import { ConnectWalletDetailsModal } from "./ConnectWalletDetailsModal";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { TextBalance } from "../base/TextBalance";
|
||||||
|
|
||||||
export type ConnectWalletDetailsProps = {
|
export type ConnectWalletDetailsProps = {
|
||||||
address?: string;
|
address?: string;
|
||||||
detailsButton?: React.FC<{ onPress: () => void }>;
|
detailsButton?: React.FC<{ onPress: () => void }>;
|
||||||
extraRows?: React.FC;
|
extraRows?: React.FC;
|
||||||
|
hideTestnetFaucet?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WalletDetailsButton = ({
|
export const WalletDetailsButton = ({
|
||||||
address,
|
address,
|
||||||
detailsButton,
|
detailsButton,
|
||||||
extraRows,
|
extraRows,
|
||||||
|
hideTestnetFaucet,
|
||||||
}: ConnectWalletDetailsProps) => {
|
}: ConnectWalletDetailsProps) => {
|
||||||
const activeWallet = useWallet();
|
const activeWallet = useWallet();
|
||||||
const chain = useChain();
|
const chain = useChain();
|
||||||
const balanceQuery = useBalance();
|
|
||||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||||
|
|
||||||
const onPress = () => {
|
const onPress = () => {
|
||||||
@@ -46,6 +48,7 @@ export const WalletDetailsButton = ({
|
|||||||
onClosePress={onPress}
|
onClosePress={onPress}
|
||||||
extraRows={extraRows}
|
extraRows={extraRows}
|
||||||
address={address}
|
address={address}
|
||||||
|
hideTestnetFaucet={hideTestnetFaucet}
|
||||||
/>
|
/>
|
||||||
{detailsButton ? (
|
{detailsButton ? (
|
||||||
detailsButton({ onPress })
|
detailsButton({ onPress })
|
||||||
@@ -61,12 +64,7 @@ export const WalletDetailsButton = ({
|
|||||||
<ChainIcon size={32} chainIconUrl={chain?.icon?.url} />
|
<ChainIcon size={32} chainIconUrl={chain?.icon?.url} />
|
||||||
</View>
|
</View>
|
||||||
<Box justifyContent="center" alignItems="flex-start">
|
<Box justifyContent="center" alignItems="flex-start">
|
||||||
<Text variant="bodySmall">
|
<TextBalance textVariant="bodySmall" />
|
||||||
{balanceQuery.data
|
|
||||||
? Number(balanceQuery.data.displayValue).toFixed(3)
|
|
||||||
: ""}{" "}
|
|
||||||
{balanceQuery.data?.symbol}
|
|
||||||
</Text>
|
|
||||||
{activeWallet?.walletId === LocalWallet.id ? (
|
{activeWallet?.walletId === LocalWallet.id ? (
|
||||||
<Text variant="error">Guest</Text>
|
<Text variant="error">Guest</Text>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
+6
-10
@@ -2,14 +2,14 @@ import { Icon } from "../../assets/icon";
|
|||||||
import { useAppTheme } from "../../styles/hooks";
|
import { useAppTheme } from "../../styles/hooks";
|
||||||
import { AddressDisplay } from "../base/AddressDisplay";
|
import { AddressDisplay } from "../base/AddressDisplay";
|
||||||
import BaseButton from "../base/BaseButton";
|
import BaseButton from "../base/BaseButton";
|
||||||
import Text from "../base/Text";
|
|
||||||
import { WalletIcon } from "../base/WalletIcon";
|
import { WalletIcon } from "../base/WalletIcon";
|
||||||
import { useWallet, useBalance } from "@thirdweb-dev/react-core";
|
import { useWallet } from "@thirdweb-dev/react-core";
|
||||||
import { ActivityIndicator, StyleSheet, View } from "react-native";
|
import { ActivityIndicator, StyleSheet, View } from "react-native";
|
||||||
import * as Clipboard from "expo-clipboard";
|
import * as Clipboard from "expo-clipboard";
|
||||||
import Box from "../base/Box";
|
import Box from "../base/Box";
|
||||||
import CopyIcon from "../../assets/copy";
|
import CopyIcon from "../../assets/copy";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { TextBalance } from "../base/TextBalance";
|
||||||
|
|
||||||
interface WalletDetailsModalHeaderProps {
|
interface WalletDetailsModalHeaderProps {
|
||||||
address?: string;
|
address?: string;
|
||||||
@@ -24,7 +24,6 @@ export const WalletDetailsModalHeader = ({
|
|||||||
onAddressCopied,
|
onAddressCopied,
|
||||||
}: WalletDetailsModalHeaderProps) => {
|
}: WalletDetailsModalHeaderProps) => {
|
||||||
const theme = useAppTheme();
|
const theme = useAppTheme();
|
||||||
const balanceQuery = useBalance();
|
|
||||||
const activeWallet = useWallet();
|
const activeWallet = useWallet();
|
||||||
const [showLoading, setShowLoading] = useState(false);
|
const [showLoading, setShowLoading] = useState(false);
|
||||||
|
|
||||||
@@ -38,7 +37,9 @@ export const WalletDetailsModalHeader = ({
|
|||||||
|
|
||||||
const onDisconnectPressInternal = () => {
|
const onDisconnectPressInternal = () => {
|
||||||
setShowLoading(true);
|
setShowLoading(true);
|
||||||
onDisconnectPress();
|
setTimeout(() => {
|
||||||
|
onDisconnectPress();
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -65,12 +66,7 @@ export const WalletDetailsModalHeader = ({
|
|||||||
color={theme.colors.textSecondary}
|
color={theme.colors.textSecondary}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Text variant="bodySmallSecondary">
|
<TextBalance textVariant="bodySmallSecondary" />
|
||||||
{balanceQuery.data
|
|
||||||
? Number(balanceQuery.data.displayValue).toFixed(3)
|
|
||||||
: ""}{" "}
|
|
||||||
{balanceQuery.data?.symbol}
|
|
||||||
</Text>
|
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
{showLoading ? (
|
{showLoading ? (
|
||||||
<ActivityIndicator size="small" color={theme.colors.iconHighlight} />
|
<ActivityIndicator size="small" color={theme.colors.iconHighlight} />
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ export const ConnectWalletFlow = () => {
|
|||||||
setIsConnecting(false);
|
setIsConnecting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClose = useCallback(() => {
|
||||||
|
onClose(true);
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
const getComponentForWallet = useCallback(() => {
|
const getComponentForWallet = useCallback(() => {
|
||||||
switch (activeWallet?.id) {
|
switch (activeWallet?.id) {
|
||||||
case SmartWallet.id:
|
case SmartWallet.id:
|
||||||
@@ -100,7 +104,7 @@ export const ConnectWalletFlow = () => {
|
|||||||
<activeWallet.connectUI
|
<activeWallet.connectUI
|
||||||
theme={theme || "dark"}
|
theme={theme || "dark"}
|
||||||
goBack={onBackPress}
|
goBack={onBackPress}
|
||||||
close={() => onClose(true)}
|
close={handleClose}
|
||||||
isOpen={modalVisible}
|
isOpen={modalVisible}
|
||||||
open={onOpenModal}
|
open={onOpenModal}
|
||||||
walletConfig={activeWallet}
|
walletConfig={activeWallet}
|
||||||
@@ -112,6 +116,7 @@ export const ConnectWalletFlow = () => {
|
|||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activeWallet,
|
activeWallet,
|
||||||
|
handleClose,
|
||||||
modalVisible,
|
modalVisible,
|
||||||
onBackPress,
|
onBackPress,
|
||||||
onClose,
|
onClose,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ const styles = StyleSheet.create({
|
|||||||
borderTopLeftRadius: 24,
|
borderTopLeftRadius: 24,
|
||||||
borderTopRightRadius: 24,
|
borderTopRightRadius: 24,
|
||||||
padding: 24,
|
padding: 24,
|
||||||
|
paddingBottom: 40,
|
||||||
},
|
},
|
||||||
contentContainer: {
|
contentContainer: {
|
||||||
maxHeight: MODAL_HEIGHT,
|
maxHeight: MODAL_HEIGHT,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useState } from "react";
|
|||||||
import { Image } from "react-native";
|
import { Image } from "react-native";
|
||||||
import { SvgUri } from "react-native-svg";
|
import { SvgUri } from "react-native-svg";
|
||||||
import { isAppBundleIdPresentInGlobal } from "../../utils/global";
|
import { isAppBundleIdPresentInGlobal } from "../../utils/global";
|
||||||
|
import Box from "./Box";
|
||||||
|
|
||||||
const ImageSvgUri = ({
|
const ImageSvgUri = ({
|
||||||
imageUrl = "",
|
imageUrl = "",
|
||||||
@@ -29,29 +30,29 @@ const ImageSvgUri = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
return (
|
||||||
return (
|
<Box style={{ width: width, height: height }}>
|
||||||
<SvgUri
|
{error ? (
|
||||||
width={width}
|
<SvgUri
|
||||||
height={height}
|
width={width}
|
||||||
uri={resolvedImageUrl}
|
height={height}
|
||||||
onError={(err) => {
|
uri={resolvedImageUrl}
|
||||||
console.warn("Error loading an svg image: ", err);
|
onError={(err) => {
|
||||||
}}
|
console.warn("Error loading an svg image: ", err);
|
||||||
/>
|
}}
|
||||||
);
|
/>
|
||||||
} else {
|
) : (
|
||||||
// always try to render Image first, if error then try to render svg
|
// always try to render Image first, if error then try to render svg
|
||||||
// Image from RN handles onError better than SvgUri
|
// Image from RN handles onError better than SvgUri
|
||||||
return (
|
<Image
|
||||||
<Image
|
alt={imageAlt}
|
||||||
alt={imageAlt}
|
source={{ uri: resolvedImageUrl }}
|
||||||
source={{ uri: resolvedImageUrl }}
|
style={[{ width: width, height: height }]}
|
||||||
style={[{ width: width, height: height }]}
|
onError={() => setError(true)}
|
||||||
onError={() => setError(true)}
|
/>
|
||||||
/>
|
)}
|
||||||
);
|
</Box>
|
||||||
}
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ImageSvgUri;
|
export default ImageSvgUri;
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import React, { useCallback, useEffect, useRef } from "react";
|
||||||
|
import { View, Animated, Easing, StyleSheet } from "react-native";
|
||||||
|
import { baseTheme } from "../../styles/theme";
|
||||||
|
import { useAppTheme } from "../../styles/hooks";
|
||||||
|
|
||||||
|
type LoadingTextAnimationProps = {
|
||||||
|
text: string;
|
||||||
|
textVariant: keyof typeof baseTheme.textVariants;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LoadingTextAnimation = ({
|
||||||
|
text,
|
||||||
|
textVariant,
|
||||||
|
}: LoadingTextAnimationProps) => {
|
||||||
|
const fadeAnim = useRef(new Animated.Value(0)).current;
|
||||||
|
const theme = useAppTheme();
|
||||||
|
|
||||||
|
const fadeInOut = useCallback(() => {
|
||||||
|
Animated.loop(
|
||||||
|
Animated.sequence([
|
||||||
|
Animated.timing(fadeAnim, {
|
||||||
|
toValue: 1,
|
||||||
|
duration: 600,
|
||||||
|
easing: Easing.linear,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}),
|
||||||
|
Animated.timing(fadeAnim, {
|
||||||
|
toValue: 0,
|
||||||
|
duration: 600,
|
||||||
|
easing: Easing.linear,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
{ iterations: -1 },
|
||||||
|
).start();
|
||||||
|
}, [fadeAnim]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fadeInOut();
|
||||||
|
}, [fadeInOut]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.animatedView}>
|
||||||
|
<Animated.Text
|
||||||
|
style={{
|
||||||
|
color: theme.colors.textSecondary,
|
||||||
|
fontWeight: theme.textVariants[textVariant].fontWeight as any,
|
||||||
|
fontSize: theme.textVariants[textVariant].fontSize,
|
||||||
|
lineHeight: theme.textVariants[textVariant].lineHeight,
|
||||||
|
opacity: fadeAnim,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</Animated.Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LoadingTextAnimation;
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
animatedView: {
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { useBalance } from "@thirdweb-dev/react-core";
|
||||||
|
import Text from "./Text";
|
||||||
|
import LoadingTextAnimation from "./LoadingTextAnimation";
|
||||||
|
import { baseTheme } from "../../styles/theme";
|
||||||
|
|
||||||
|
type TextBalance = {
|
||||||
|
textVariant: keyof typeof baseTheme.textVariants;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TextBalance = ({ textVariant }: TextBalance) => {
|
||||||
|
const balanceQuery = useBalance();
|
||||||
|
|
||||||
|
return !balanceQuery.data ? (
|
||||||
|
<LoadingTextAnimation text="Fetching..." textVariant={textVariant} />
|
||||||
|
) : (
|
||||||
|
<Text variant={textVariant}>
|
||||||
|
{Number(balanceQuery.data?.displayValue).toFixed(3)}{" "}
|
||||||
|
{balanceQuery.data.symbol}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -3,7 +3,12 @@ import Modal, { ModalProps } from "react-native-modal";
|
|||||||
// Populate with the data...
|
// Populate with the data...
|
||||||
export function TWModal(props: Partial<ModalProps>) {
|
export function TWModal(props: Partial<ModalProps>) {
|
||||||
return (
|
return (
|
||||||
<Modal {...props} useNativeDriver hideModalContentWhileAnimating={true}>
|
<Modal
|
||||||
|
{...props}
|
||||||
|
avoidKeyboard
|
||||||
|
useNativeDriver
|
||||||
|
hideModalContentWhileAnimating={true}
|
||||||
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
export const TW_WC_PROJECT_ID = "145769e410f16970a79ff77b2d89a1e0";
|
export const TW_WC_PROJECT_ID = "145769e410f16970a79ff77b2d89a1e0";
|
||||||
export const WC_RELAY_URL = "wss://relay.walletconnect.com";
|
export const WC_RELAY_URL = "wss://relay.walletconnect.com";
|
||||||
|
|
||||||
|
export const WC_LINKS = {
|
||||||
|
native: "wc://",
|
||||||
|
universal: "wc://",
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
callback: (args: any) => void;
|
||||||
|
delay?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDebounceCallback({ callback, delay = 250 }: Props) {
|
||||||
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const callbackRef = useRef(callback);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
callbackRef.current = callback;
|
||||||
|
}, [callback]);
|
||||||
|
|
||||||
|
const debouncedCallback = useCallback(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore args can be any in this case
|
||||||
|
(args) => {
|
||||||
|
if (timeoutRef.current) {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
timeoutRef.current = setTimeout(() => {
|
||||||
|
callbackRef.current(args);
|
||||||
|
}, delay);
|
||||||
|
},
|
||||||
|
[delay],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (timeoutRef.current) {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return debouncedCallback;
|
||||||
|
}
|
||||||
@@ -15,9 +15,13 @@ export { TrustWallet, trustWallet } from "./wallets/wallets/trust-wallet";
|
|||||||
export { smartWallet } from "./wallets/wallets/smart-wallet";
|
export { smartWallet } from "./wallets/wallets/smart-wallet";
|
||||||
export { localWallet } from "./wallets/wallets/local-wallet";
|
export { localWallet } from "./wallets/wallets/local-wallet";
|
||||||
export { LocalWallet } from "./wallets/wallets/LocalWallet";
|
export { LocalWallet } from "./wallets/wallets/LocalWallet";
|
||||||
export { magicWallet } from "./wallets/wallets/magic-wallet";
|
export { magicWallet } from "./wallets/wallets/magic-link";
|
||||||
export { MagicWallet } from "./wallets/wallets/MagicWallet";
|
export { MagicWallet } from "./wallets/wallets/MagicLink";
|
||||||
export * from "./wallets/wallets/WalletConnectV2";
|
export { MagicLink } from "./wallets/wallets/MagicLink";
|
||||||
|
export { magicLink } from "./wallets/wallets/magic-link";
|
||||||
|
export * from "./wallets/wallets/wallet-connect/WalletConnectBase";
|
||||||
|
export { WalletConnect } from "./wallets/wallets/wallet-connect/WalletConnect";
|
||||||
|
export { walletConnect } from "./wallets/wallets/wallet-connect/wallet-connect";
|
||||||
export type { WCMeta } from "./wallets/types/wc";
|
export type { WCMeta } from "./wallets/types/wc";
|
||||||
|
|
||||||
export { useCoinbaseWallet } from "./wallets/hooks/useCoinbaseWallet";
|
export { useCoinbaseWallet } from "./wallets/hooks/useCoinbaseWallet";
|
||||||
|
|||||||
@@ -7,47 +7,47 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useWalletConnectListener } from "../wallets/hooks/useWalletConnectListener";
|
import { useWalletConnectListener } from "../wallets/hooks/useWalletConnectListener";
|
||||||
import { MagicWallet } from "../wallets/wallets/MagicWallet";
|
import { MagicLink } from "../wallets/wallets/MagicLink";
|
||||||
import { useWalletContext } from "@thirdweb-dev/react-core";
|
import { useWalletContext } from "@thirdweb-dev/react-core";
|
||||||
|
|
||||||
type DappContextType = {
|
type DappContextType = {
|
||||||
smartWallet?: SmartWallet;
|
smartWallet?: SmartWallet;
|
||||||
setSmartWallet?: (value?: SmartWallet) => void;
|
setSmartWallet?: (value?: SmartWallet) => void;
|
||||||
magicWallet?: MagicWallet;
|
magicLink?: MagicLink;
|
||||||
setMagicWallet?: (value?: MagicWallet) => void;
|
setMagicLink?: (value?: MagicLink) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DappContext = createContext<DappContextType>({});
|
const DappContext = createContext<DappContextType>({});
|
||||||
|
|
||||||
export const DappContextProvider = (props: React.PropsWithChildren) => {
|
export const DappContextProvider = (props: React.PropsWithChildren) => {
|
||||||
const [smartWallet, setSmartWallet] = useState<SmartWallet | undefined>();
|
const [smartWallet, setSmartWallet] = useState<SmartWallet | undefined>();
|
||||||
const [magicWallet, setMagicWallet] = useState<MagicWallet | undefined>();
|
const [magicLink, setMagicLink] = useState<MagicLink | undefined>();
|
||||||
const createdWalletInstance = useWalletContext().createdWalletInstance;
|
const createdWalletInstance = useWalletContext().createdWalletInstance;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (createdWalletInstance?.walletId === walletIds.magicLink) {
|
if (createdWalletInstance?.walletId === walletIds.magicLink) {
|
||||||
setMagicWallet(createdWalletInstance as MagicWallet);
|
setMagicLink(createdWalletInstance as MagicLink);
|
||||||
}
|
}
|
||||||
}, [createdWalletInstance, setMagicWallet]);
|
}, [createdWalletInstance, setMagicLink]);
|
||||||
|
|
||||||
useWalletConnectListener();
|
useWalletConnectListener();
|
||||||
|
|
||||||
const magicSDK = useCallback(() => {
|
const magicSDK = useCallback(() => {
|
||||||
if (magicWallet) {
|
if (magicLink) {
|
||||||
const magic = magicWallet.getMagicSDK();
|
const magic = magicLink.getMagicSDK();
|
||||||
return <magic.Relayer />;
|
return <magic.Relayer />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, [magicWallet]);
|
}, [magicLink]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DappContext.Provider
|
<DappContext.Provider
|
||||||
value={{
|
value={{
|
||||||
smartWallet,
|
smartWallet,
|
||||||
setSmartWallet,
|
setSmartWallet,
|
||||||
magicWallet: magicWallet,
|
magicLink: magicLink,
|
||||||
setMagicWallet: setMagicWallet,
|
setMagicLink: setMagicLink,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
@@ -66,11 +66,11 @@ export const useSmartWallet = () => {
|
|||||||
return [context.smartWallet, context.setSmartWallet] as const;
|
return [context.smartWallet, context.setSmartWallet] as const;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useMagicWallet = () => {
|
export const useMagicLink = () => {
|
||||||
const context = useContext(DappContext);
|
const context = useContext(DappContext);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
magicWallet: context.magicWallet,
|
magicLink: context.magicLink,
|
||||||
setMagicWallet: context.setMagicWallet,
|
setMagicLink: context.setMagicLink,
|
||||||
} as const;
|
} as const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export type WCWallet = {
|
||||||
|
iconURL: string;
|
||||||
|
name: string;
|
||||||
|
links: {
|
||||||
|
native: string;
|
||||||
|
universal: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Chain, getValidChainRPCs } from "@thirdweb-dev/chains";
|
||||||
import { WCMeta } from "../wallets/types/wc";
|
import { WCMeta } from "../wallets/types/wc";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,3 +21,19 @@ export function formatWalletConnectDisplayUri(
|
|||||||
}wc?uri=${encodedUri}`
|
}wc?uri=${encodedUri}`
|
||||||
: `${uri}`;
|
: `${uri}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getValidPublicRPCUrl(chain: Chain) {
|
||||||
|
return getValidChainRPCs(chain).map((rpc) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(rpc);
|
||||||
|
// remove client id from url
|
||||||
|
if (url.hostname.endsWith(".thirdweb.com")) {
|
||||||
|
url.pathname = "";
|
||||||
|
url.search = "";
|
||||||
|
}
|
||||||
|
return url.toString();
|
||||||
|
} catch (e) {
|
||||||
|
return rpc;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type {
|
|||||||
WalletMobileSDKProviderOptions,
|
WalletMobileSDKProviderOptions,
|
||||||
} from "@coinbase/wallet-mobile-sdk/build/WalletMobileSDKEVMProvider";
|
} from "@coinbase/wallet-mobile-sdk/build/WalletMobileSDKEVMProvider";
|
||||||
import type { ConfigurationParams } from "@coinbase/wallet-mobile-sdk/src/CoinbaseWalletSDK.types";
|
import type { ConfigurationParams } from "@coinbase/wallet-mobile-sdk/src/CoinbaseWalletSDK.types";
|
||||||
import { getValidChainRPCs } from "@thirdweb-dev/chains";
|
|
||||||
import {
|
import {
|
||||||
UserRejectedRequestError,
|
UserRejectedRequestError,
|
||||||
ChainNotConfiguredError,
|
ChainNotConfiguredError,
|
||||||
@@ -18,6 +17,7 @@ import {
|
|||||||
} from "@thirdweb-dev/wallets";
|
} from "@thirdweb-dev/wallets";
|
||||||
import type { Address } from "abitype";
|
import type { Address } from "abitype";
|
||||||
import { providers, utils } from "ethers";
|
import { providers, utils } from "ethers";
|
||||||
|
import { getValidPublicRPCUrl } from "evm/utils/uri";
|
||||||
|
|
||||||
export type CoinbaseWalletConnectorOptions = WalletMobileSDKProviderOptions &
|
export type CoinbaseWalletConnectorOptions = WalletMobileSDKProviderOptions &
|
||||||
ConfigurationParams & {
|
ConfigurationParams & {
|
||||||
@@ -227,7 +227,7 @@ export class CoinbaseWalletConnector extends WagmiConnector<
|
|||||||
chainId: id,
|
chainId: id,
|
||||||
chainName: chain.name,
|
chainName: chain.name,
|
||||||
nativeCurrency: chain.nativeCurrency,
|
nativeCurrency: chain.nativeCurrency,
|
||||||
rpcUrls: [getValidChainRPCs(chain)],
|
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
|
||||||
blockExplorerUrls: this.getBlockExplorerUrls(chain),
|
blockExplorerUrls: this.getBlockExplorerUrls(chain),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export type WCMeta = {
|
|||||||
name: string;
|
name: string;
|
||||||
iconURL: string;
|
iconURL: string;
|
||||||
links: {
|
links: {
|
||||||
native?: string;
|
native: string;
|
||||||
universal?: string;
|
universal: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+8
-1
@@ -6,7 +6,7 @@ import {
|
|||||||
import type { MagicConnector as MagicConnectorType } from "../connectors/magic/magic-connector";
|
import type { MagicConnector as MagicConnectorType } from "../connectors/magic/magic-connector";
|
||||||
import { MagicConnector } from "../connectors/magic/magic-connector";
|
import { MagicConnector } from "../connectors/magic/magic-connector";
|
||||||
|
|
||||||
export class MagicWallet extends AbstractClientWallet<
|
export class MagicLink extends AbstractClientWallet<
|
||||||
MagicLinkOptions,
|
MagicLinkOptions,
|
||||||
MagicConnectorOptions
|
MagicConnectorOptions
|
||||||
> {
|
> {
|
||||||
@@ -68,3 +68,10 @@ export class MagicWallet extends AbstractClientWallet<
|
|||||||
return super.disconnect();
|
return super.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use `MagicLink` instead
|
||||||
|
*
|
||||||
|
* Renamed for consistency with our React package
|
||||||
|
*/
|
||||||
|
export class MagicWallet extends MagicLink {}
|
||||||
+24
-16
@@ -10,22 +10,22 @@ import {
|
|||||||
useWalletContext,
|
useWalletContext,
|
||||||
} from "@thirdweb-dev/react-core";
|
} from "@thirdweb-dev/react-core";
|
||||||
import { MagicLinkOptions } from "../connectors/magic/types";
|
import { MagicLinkOptions } from "../connectors/magic/types";
|
||||||
import { MagicWallet } from "./MagicWallet";
|
import { MagicLink } from "./MagicLink";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import Box from "../../components/base/Box";
|
import Box from "../../components/base/Box";
|
||||||
import { TextInput } from "../../components/base/TextInput";
|
import { TextInput } from "../../components/base/TextInput";
|
||||||
import Text from "../../components/base/Text";
|
import Text from "../../components/base/Text";
|
||||||
import { ActivityIndicator } from "react-native";
|
import { ActivityIndicator } from "react-native";
|
||||||
import { useMagicWallet } from "../../providers/context-provider";
|
import { useMagicLink } from "../../providers/context-provider";
|
||||||
|
|
||||||
export const magicWallet = (
|
export const magicLink = (
|
||||||
magicLinkOptions: MagicLinkOptions,
|
magicLinkOptions: MagicLinkOptions,
|
||||||
): WalletConfig<MagicWallet> => {
|
): WalletConfig<MagicLink> => {
|
||||||
return {
|
return {
|
||||||
id: walletIds.magicLink,
|
id: walletIds.magicLink,
|
||||||
meta: MagicWallet.meta,
|
meta: MagicLink.meta,
|
||||||
create: (options: WalletOptions) => {
|
create: (options: WalletOptions) => {
|
||||||
return new MagicWallet({
|
return new MagicLink({
|
||||||
...options,
|
...options,
|
||||||
...magicLinkOptions,
|
...magicLinkOptions,
|
||||||
chainId: options.chain.chainId,
|
chainId: options.chain.chainId,
|
||||||
@@ -42,7 +42,7 @@ export const magicWallet = (
|
|||||||
/**
|
/**
|
||||||
* UI for selecting wallet - this UI is rendered in the wallet selection screen
|
* UI for selecting wallet - this UI is rendered in the wallet selection screen
|
||||||
*/
|
*/
|
||||||
selectUI: (props: SelectUIProps<MagicWallet>) => {
|
selectUI: (props: SelectUIProps<MagicLink>) => {
|
||||||
return (
|
return (
|
||||||
<Box flex={1}>
|
<Box flex={1}>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -71,23 +71,23 @@ export const magicWallet = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const MagicConnectionUI: React.FC<
|
const MagicConnectionUI: React.FC<
|
||||||
ConnectUIProps<MagicWallet> & { magicLinkOptions: MagicLinkOptions }
|
ConnectUIProps<MagicLink> & { magicLinkOptions: MagicLinkOptions }
|
||||||
> = ({ selectionData, walletConfig, close, magicLinkOptions }) => {
|
> = ({ selectionData, walletConfig, close, magicLinkOptions }) => {
|
||||||
const createWalletInstance = useCreateWalletInstance();
|
const createWalletInstance = useCreateWalletInstance();
|
||||||
const setConnectedWallet = useSetConnectedWallet();
|
const setConnectedWallet = useSetConnectedWallet();
|
||||||
const chainToConnect = useWalletContext().chainToConnect;
|
const chainToConnect = useWalletContext().chainToConnect;
|
||||||
const setConnectionStatus = useSetConnectionStatus();
|
const setConnectionStatus = useSetConnectionStatus();
|
||||||
const { magicWallet: ctxMagicWallet, setMagicWallet } = useMagicWallet();
|
const { magicLink: ctxMagicLink, setMagicLink } = useMagicLink();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const inst = createWalletInstance(walletConfig);
|
const inst = createWalletInstance(walletConfig);
|
||||||
setMagicWallet?.(inst);
|
setMagicLink?.(inst);
|
||||||
}, [createWalletInstance, setMagicWallet, walletConfig]);
|
}, [createWalletInstance, setMagicLink, walletConfig]);
|
||||||
|
|
||||||
const connectPrompted = useRef(false);
|
const connectPrompted = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (connectPrompted.current || !ctxMagicWallet) {
|
if (connectPrompted.current || !ctxMagicLink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connectPrompted.current = true;
|
connectPrompted.current = true;
|
||||||
@@ -105,10 +105,10 @@ const MagicConnectionUI: React.FC<
|
|||||||
: { phoneNumber: selectionData }),
|
: { phoneNumber: selectionData }),
|
||||||
};
|
};
|
||||||
close();
|
close();
|
||||||
await ctxMagicWallet.connect(connectParams);
|
await ctxMagicLink.connect(connectParams);
|
||||||
await ctxMagicWallet.getMagicSDK().user.getMetadata();
|
await ctxMagicLink.getMagicSDK().user.getMetadata();
|
||||||
|
|
||||||
setConnectedWallet(ctxMagicWallet, connectParams);
|
setConnectedWallet(ctxMagicLink, connectParams);
|
||||||
setConnectionStatus("connected");
|
setConnectionStatus("connected");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setConnectionStatus("disconnected");
|
setConnectionStatus("disconnected");
|
||||||
@@ -119,7 +119,7 @@ const MagicConnectionUI: React.FC<
|
|||||||
selectionData,
|
selectionData,
|
||||||
walletConfig,
|
walletConfig,
|
||||||
close,
|
close,
|
||||||
ctxMagicWallet,
|
ctxMagicLink,
|
||||||
setConnectedWallet,
|
setConnectedWallet,
|
||||||
setConnectionStatus,
|
setConnectionStatus,
|
||||||
chainToConnect?.chainId,
|
chainToConnect?.chainId,
|
||||||
@@ -129,6 +129,14 @@ const MagicConnectionUI: React.FC<
|
|||||||
return (
|
return (
|
||||||
<Box minHeight={500}>
|
<Box minHeight={500}>
|
||||||
<ActivityIndicator size="small" />
|
<ActivityIndicator size="small" />
|
||||||
|
<TextInput placeholder="Enter the OTP sent to your email / phone number" />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use `magicLink()` instead
|
||||||
|
*
|
||||||
|
* Renamed for consistency with our React package
|
||||||
|
*/
|
||||||
|
export const magicWallet = magicLink;
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { walletIds } from "@thirdweb-dev/wallets";
|
import { walletIds } from "@thirdweb-dev/wallets";
|
||||||
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
||||||
import { WalletConnectV2 } from "./WalletConnectV2";
|
|
||||||
import { WCMeta } from "../types/wc";
|
import { WCMeta } from "../types/wc";
|
||||||
|
import { WalletConnectBase } from "./wallet-connect/WalletConnectBase";
|
||||||
|
|
||||||
export class MetaMaskWallet extends WalletConnectV2 {
|
export class MetaMaskWallet extends WalletConnectBase {
|
||||||
static id = walletIds.metamask;
|
static id = walletIds.metamask;
|
||||||
static meta = {
|
static meta = {
|
||||||
name: "MetaMask",
|
name: "MetaMask",
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import {
|
|||||||
WalletOptions as WalletOptionsRC,
|
WalletOptions as WalletOptionsRC,
|
||||||
WalletConfig,
|
WalletConfig,
|
||||||
} from "@thirdweb-dev/react-core";
|
} from "@thirdweb-dev/react-core";
|
||||||
import { WalletConnectV2 } from "./WalletConnectV2";
|
import { WalletConnectBase } from "./wallet-connect/WalletConnectBase";
|
||||||
|
|
||||||
export class RainbowWallet extends WalletConnectV2 {
|
export class RainbowWallet extends WalletConnectBase {
|
||||||
static id = "rainbow" as const;
|
static id = "rainbow" as const;
|
||||||
static meta = {
|
static meta = {
|
||||||
name: "Rainbow",
|
name: "Rainbow",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
||||||
import { WalletConnectV2 } from "./WalletConnectV2";
|
|
||||||
import { WCMeta } from "../types/wc";
|
import { WCMeta } from "../types/wc";
|
||||||
|
import { WalletConnectBase } from "./wallet-connect/WalletConnectBase";
|
||||||
|
|
||||||
export class TrustWallet extends WalletConnectV2 {
|
export class TrustWallet extends WalletConnectBase {
|
||||||
static id = "trust" as const;
|
static id = "trust" as const;
|
||||||
static meta = {
|
static meta = {
|
||||||
name: "Trust Wallet",
|
name: "Trust Wallet",
|
||||||
@@ -31,5 +31,5 @@ export const trustWallet = (config?: TrustWalletConfig) => {
|
|||||||
walletId: "trust",
|
walletId: "trust",
|
||||||
projectId: config?.projectId,
|
projectId: config?.projectId,
|
||||||
}),
|
}),
|
||||||
} satisfies WalletConfig<WalletConnectV2>;
|
} satisfies WalletConfig<WalletConnectBase>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { MMKV } from "react-native-mmkv";
|
||||||
|
import { WC2Options, WalletConnectBase } from "./WalletConnectBase";
|
||||||
|
|
||||||
|
const PREFIX = "__TW__WALLET__CONNECT__";
|
||||||
|
|
||||||
|
export class WalletConnect extends WalletConnectBase {
|
||||||
|
static id = "WalletConnect" as const;
|
||||||
|
static meta = {
|
||||||
|
name: "WalletConnect",
|
||||||
|
iconURL:
|
||||||
|
"ipfs://QmX58KPRaTC9JYZ7KriuBzeoEaV2P9eZcA3qbFnTHZazKw/wallet-connect.svg",
|
||||||
|
links: {
|
||||||
|
native: "wc:",
|
||||||
|
universal: "wc:",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
storage: MMKV;
|
||||||
|
links: { native: string; universal: string };
|
||||||
|
|
||||||
|
constructor(options: WC2Options) {
|
||||||
|
super(options);
|
||||||
|
|
||||||
|
this.storage = new MMKV();
|
||||||
|
|
||||||
|
const storedLinksStr = this.storage.getString(PREFIX + "links");
|
||||||
|
|
||||||
|
this.links = storedLinksStr
|
||||||
|
? JSON.parse(storedLinksStr)
|
||||||
|
: {
|
||||||
|
native: "wc:",
|
||||||
|
universal: "wc:",
|
||||||
|
};
|
||||||
|
|
||||||
|
this.on("disconnect", () => {
|
||||||
|
this.storage.delete(PREFIX + "links");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getMeta() {
|
||||||
|
return { ...WalletConnect.meta, links: this.links };
|
||||||
|
}
|
||||||
|
|
||||||
|
setWCLinks(links: { native: string; universal: string }) {
|
||||||
|
this.storage.set(PREFIX + "links", JSON.stringify(links));
|
||||||
|
this.links = links;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-5
@@ -1,13 +1,14 @@
|
|||||||
import { TW_WC_PROJECT_ID } from "../../constants/walletConnect";
|
|
||||||
import { formatWalletConnectDisplayUri } from "../../utils/uri";
|
|
||||||
import type {
|
import type {
|
||||||
WalletConnectOptions,
|
WalletConnectOptions,
|
||||||
WalletOptions,
|
WalletOptions,
|
||||||
} from "@thirdweb-dev/wallets";
|
} from "@thirdweb-dev/wallets";
|
||||||
import { WalletConnect as WalletConnectV2Wallets } from "@thirdweb-dev/wallets";
|
import { WalletConnect as WalletConnectV2Wallets } from "@thirdweb-dev/wallets";
|
||||||
import { Linking } from "react-native";
|
import { Linking } from "react-native";
|
||||||
import { WCMeta } from "../types/wc";
|
import { TW_WC_PROJECT_ID } from "../../../constants/walletConnect";
|
||||||
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
|
import { createAsyncLocalStorage } from "../../../../core/AsyncStorage";
|
||||||
|
import { WCMeta } from "../../types/wc";
|
||||||
|
import { formatWalletConnectDisplayUri } from "../../../utils/uri";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
|
||||||
export type WC2Options = {
|
export type WC2Options = {
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +25,7 @@ export type WC2Options = {
|
|||||||
walletId: NonNullable<WalletOptions["walletId"]>;
|
walletId: NonNullable<WalletOptions["walletId"]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export abstract class WalletConnectV2 extends WalletConnectV2Wallets {
|
export abstract class WalletConnectBase extends WalletConnectV2Wallets {
|
||||||
constructor(options: WC2Options) {
|
constructor(options: WC2Options) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@@ -41,9 +42,21 @@ export abstract class WalletConnectV2 extends WalletConnectV2Wallets {
|
|||||||
this.on("disconnect", () => {
|
this.on("disconnect", () => {
|
||||||
this.removeListener("display_uri", this._onWCOpenWallet);
|
this.removeListener("display_uri", this._onWCOpenWallet);
|
||||||
this.removeListener("wc_session_request_sent", this._onWCOpenWallet);
|
this.removeListener("wc_session_request_sent", this._onWCOpenWallet);
|
||||||
|
this.cleanAsyncStorage();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cleanAsyncStorage() {
|
||||||
|
const allKeys = await AsyncStorage.getAllKeys();
|
||||||
|
for (const key of allKeys) {
|
||||||
|
if (key.includes("wc@2")) {
|
||||||
|
await AsyncStorage.removeItem(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await AsyncStorage.removeItem(".sdk-comm");
|
||||||
|
}
|
||||||
|
|
||||||
abstract getMeta(): WCMeta;
|
abstract getMeta(): WCMeta;
|
||||||
|
|
||||||
_onWCOpenWallet(uri?: string) {
|
_onWCOpenWallet(uri?: string) {
|
||||||
@@ -60,3 +73,10 @@ export abstract class WalletConnectV2 extends WalletConnectV2Wallets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated There's no longer the need to define V1/V2 for walletConnect.
|
||||||
|
*
|
||||||
|
* Use WalletConnectBase instead.
|
||||||
|
*/
|
||||||
|
export abstract class WalletConnectV2 extends WalletConnectBase {}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { Image, StyleSheet } from "react-native";
|
||||||
|
import BaseButton from "../../../components/base/BaseButton";
|
||||||
|
import { WCWallet } from "../../../types/wc";
|
||||||
|
import Text from "../../../components/base/Text";
|
||||||
|
import { WCMeta } from "../../types/wc";
|
||||||
|
import { useState } from "react";
|
||||||
|
import WalletLoadingThumbnail from "./WalletLoadingThumbnail";
|
||||||
|
|
||||||
|
export const WALLET_MARGIN = 8;
|
||||||
|
export const WALLET_HEIGHT = 80;
|
||||||
|
|
||||||
|
export const WalletConnectButton = ({
|
||||||
|
item,
|
||||||
|
onPress,
|
||||||
|
}: {
|
||||||
|
item: WCWallet;
|
||||||
|
onPress: (item: WCMeta) => void;
|
||||||
|
}) => {
|
||||||
|
const [isAnimating, setIsAnimating] = useState(false);
|
||||||
|
|
||||||
|
const onWalletPress = () => {
|
||||||
|
setIsAnimating(true);
|
||||||
|
onPress(item);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseButton
|
||||||
|
flexDirection="column"
|
||||||
|
style={styles.buttonContainer}
|
||||||
|
onPress={onWalletPress}
|
||||||
|
>
|
||||||
|
{isAnimating ? (
|
||||||
|
<WalletLoadingThumbnail>
|
||||||
|
<Image
|
||||||
|
alt={item.name}
|
||||||
|
source={{ uri: item.iconURL }}
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
borderWidth: 1,
|
||||||
|
height: 50,
|
||||||
|
width: 50,
|
||||||
|
borderRadius: 30 / 3.5,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</WalletLoadingThumbnail>
|
||||||
|
) : (
|
||||||
|
<Image
|
||||||
|
alt={item.name}
|
||||||
|
source={{ uri: item.iconURL }}
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
borderWidth: 0,
|
||||||
|
height: 50,
|
||||||
|
width: 50,
|
||||||
|
borderRadius: 30 / 3.5,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Text variant="bodySmallSecondary" fontSize={12} numberOfLines={1}>
|
||||||
|
{item.name.split(" ")[0]}
|
||||||
|
</Text>
|
||||||
|
</BaseButton>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
imageWrapper: {
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
overflow: "hidden",
|
||||||
|
position: "relative",
|
||||||
|
},
|
||||||
|
buttonContainer: {
|
||||||
|
flex: 1,
|
||||||
|
height: WALLET_HEIGHT,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginVertical: WALLET_MARGIN,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
Dimensions,
|
||||||
|
FlatList,
|
||||||
|
Platform,
|
||||||
|
StyleSheet,
|
||||||
|
TextInput,
|
||||||
|
View,
|
||||||
|
} from "react-native";
|
||||||
|
import Box from "../../../components/base/Box";
|
||||||
|
import Text from "../../../components/base/Text";
|
||||||
|
import { useDebounceCallback } from "../../../hooks/useDebounceCallback";
|
||||||
|
import { TWModal } from "../../../components/base/modal/TWModal";
|
||||||
|
import {
|
||||||
|
ConnectUIProps,
|
||||||
|
useCreateWalletInstance,
|
||||||
|
useSetConnectedWallet,
|
||||||
|
useSetConnectionStatus,
|
||||||
|
} from "@thirdweb-dev/react-core";
|
||||||
|
import { WalletConnect } from "./WalletConnect";
|
||||||
|
import { useAppTheme } from "../../../styles/hooks";
|
||||||
|
import { ConnectWalletHeader } from "../../../components/ConnectWalletFlow/ConnectingWallet/ConnectingWalletHeader";
|
||||||
|
import { WalletConnectButton } from "./WalletConnectButton";
|
||||||
|
|
||||||
|
type WCWallet = {
|
||||||
|
iconURL: string;
|
||||||
|
name: string;
|
||||||
|
links: {
|
||||||
|
native: string;
|
||||||
|
universal: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEVICE_WIDTH = Dimensions.get("window").width;
|
||||||
|
const MODAL_HEIGHT = Dimensions.get("window").height * 0.5;
|
||||||
|
|
||||||
|
export function WalletConnectUI({
|
||||||
|
close,
|
||||||
|
walletConfig,
|
||||||
|
goBack,
|
||||||
|
projectId,
|
||||||
|
}: ConnectUIProps<WalletConnect> & { projectId: string }) {
|
||||||
|
const theme = useAppTheme();
|
||||||
|
const [wallets, setWallets] = useState<WCWallet[]>([]);
|
||||||
|
const [error, setError] = useState<string | undefined>();
|
||||||
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
const [searchWallets, setSearchWallets] = useState<WCWallet[]>([]);
|
||||||
|
const createWalletInstance = useCreateWalletInstance();
|
||||||
|
const setConnectedWallet = useSetConnectedWallet();
|
||||||
|
const setConnectionStatus = useSetConnectionStatus();
|
||||||
|
|
||||||
|
const onChangeText = useDebounceCallback({ callback: setSearch });
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const abortController = new AbortController();
|
||||||
|
const signal = abortController.signal;
|
||||||
|
|
||||||
|
async function fetchAsync() {
|
||||||
|
const platformOS =
|
||||||
|
Platform.OS.toLowerCase() === "ios" ? "iOS" : "Android";
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
response = await fetch(
|
||||||
|
`https://explorer-api.walletconnect.com/w3m/v1/get${platformOS}Listings?projectId=${projectId}&chains=eip155:1`,
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to fetch wallets", err);
|
||||||
|
setError(`Failed to fetch wallets: ${err}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response?.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
const walletsB = [];
|
||||||
|
const listings: {
|
||||||
|
[key: string]: {
|
||||||
|
name: string;
|
||||||
|
image_id: string;
|
||||||
|
mobile: {
|
||||||
|
native: string;
|
||||||
|
universal: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} = data.listings;
|
||||||
|
for (const listing of Object.values(listings)) {
|
||||||
|
walletsB.push({
|
||||||
|
name: listing.name,
|
||||||
|
iconURL: `https://explorer-api.walletconnect.com/w3m/v1/getWalletImage/${listing.image_id}?projectId=${projectId}`,
|
||||||
|
links: listing.mobile
|
||||||
|
? listing.mobile
|
||||||
|
: {
|
||||||
|
native: "wc://",
|
||||||
|
universal: "wc://",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setWallets(walletsB);
|
||||||
|
setSearchWallets(walletsB);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchAsync();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
abortController.abort();
|
||||||
|
};
|
||||||
|
}, [projectId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (wallets && search) {
|
||||||
|
setSearchWallets(
|
||||||
|
wallets.filter((w) => {
|
||||||
|
return w.name.toLowerCase().includes(search.toLowerCase());
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} else if (search.length === 0) {
|
||||||
|
setSearchWallets(wallets);
|
||||||
|
}
|
||||||
|
}, [search, wallets]);
|
||||||
|
|
||||||
|
const onChooseWalletItem = (walletMeta: WCWallet) => {
|
||||||
|
const wcWallet = createWalletInstance(walletConfig);
|
||||||
|
wcWallet.setWCLinks(walletMeta.links);
|
||||||
|
|
||||||
|
setConnectionStatus("connecting");
|
||||||
|
wcWallet
|
||||||
|
.connect()
|
||||||
|
.then(() => {
|
||||||
|
setConnectedWallet(wcWallet);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
setConnectionStatus("disconnected");
|
||||||
|
console.error(`Error connecting with WalletConnect: ${e}`);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClosePress = () => {
|
||||||
|
setConnectionStatus("disconnected");
|
||||||
|
close();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TWModal
|
||||||
|
isVisible={true}
|
||||||
|
onBackdropPress={onClosePress}
|
||||||
|
backdropOpacity={0.7}
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
style={[styles.modal, { backgroundColor: theme.colors.background }]}
|
||||||
|
>
|
||||||
|
<ConnectWalletHeader
|
||||||
|
subHeaderText={""}
|
||||||
|
onBackPress={goBack}
|
||||||
|
onClose={onClosePress}
|
||||||
|
/>
|
||||||
|
<View style={styles.explorerContainer}>
|
||||||
|
{loading ? (
|
||||||
|
<ActivityIndicator size={"small"} />
|
||||||
|
) : (
|
||||||
|
<FlatList
|
||||||
|
data={searchWallets}
|
||||||
|
contentContainerStyle={styles.listContentContainer}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
numColumns={4}
|
||||||
|
fadingEdgeLength={20}
|
||||||
|
stickyHeaderIndices={[0]}
|
||||||
|
ListHeaderComponent={
|
||||||
|
<Box
|
||||||
|
borderColor="border"
|
||||||
|
borderWidth={0.5}
|
||||||
|
backgroundColor="background"
|
||||||
|
flex={1}
|
||||||
|
flexDirection="row"
|
||||||
|
borderRadius="md"
|
||||||
|
alignItems="center"
|
||||||
|
mb="sm"
|
||||||
|
padding="xs"
|
||||||
|
width={"100%"}
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
onChangeText={onChangeText}
|
||||||
|
placeholder="Search Wallets"
|
||||||
|
placeholderTextColor={theme.colors.textSecondary}
|
||||||
|
style={{
|
||||||
|
...styles.textInput,
|
||||||
|
color: theme.colors.textSecondary,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
ListEmptyComponent={
|
||||||
|
error ? (
|
||||||
|
<Text variant="error">{error}</Text>
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.emptyContainer,
|
||||||
|
{ height: Math.round(MODAL_HEIGHT) },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Text variant="bodySmall">No results found</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
renderItem={({ item }) => (
|
||||||
|
<WalletConnectButton item={item} onPress={onChooseWalletItem} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</TWModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
modal: {
|
||||||
|
position: "absolute",
|
||||||
|
bottom: -20,
|
||||||
|
left: -20,
|
||||||
|
width: DEVICE_WIDTH,
|
||||||
|
borderTopLeftRadius: 24,
|
||||||
|
borderTopRightRadius: 24,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingTop: 24,
|
||||||
|
paddingBottom: 12,
|
||||||
|
},
|
||||||
|
listContentContainer: {
|
||||||
|
paddingBottom: 12,
|
||||||
|
flexGrow: 1,
|
||||||
|
},
|
||||||
|
emptyContainer: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
textInput: {
|
||||||
|
margin: 0,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: "500",
|
||||||
|
padding: 2,
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
explorerContainer: {
|
||||||
|
display: "flex",
|
||||||
|
height: MODAL_HEIGHT,
|
||||||
|
width: "100%",
|
||||||
|
flexDirection: "row",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 25,
|
||||||
|
},
|
||||||
|
});
|
||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
import { Animated, Easing, StyleSheet, View } from "react-native";
|
||||||
|
import Svg, { Rect } from "react-native-svg";
|
||||||
|
import { useAppTheme } from "../../../styles/hooks";
|
||||||
|
|
||||||
|
const AnimatedRect = Animated.createAnimatedComponent(Rect);
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
imageSize?: number;
|
||||||
|
showError?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function WalletLoadingThumbnail({ children, showError }: Props) {
|
||||||
|
const Theme = useAppTheme();
|
||||||
|
const spinValue = useRef(new Animated.Value(0));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const animation = Animated.timing(spinValue.current, {
|
||||||
|
toValue: 1,
|
||||||
|
duration: 1150,
|
||||||
|
useNativeDriver: true,
|
||||||
|
easing: Easing.linear,
|
||||||
|
});
|
||||||
|
|
||||||
|
const loop = Animated.loop(animation);
|
||||||
|
loop.start();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
loop.stop();
|
||||||
|
};
|
||||||
|
}, [spinValue]);
|
||||||
|
|
||||||
|
const spin = spinValue.current.interpolate({
|
||||||
|
inputRange: [0, 1],
|
||||||
|
outputRange: [0, -371],
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Svg width={60} height={60} viewBox="0 0 60 60" style={styles.loader}>
|
||||||
|
<AnimatedRect
|
||||||
|
x="2"
|
||||||
|
y="2"
|
||||||
|
width={56}
|
||||||
|
height={56}
|
||||||
|
rx={15}
|
||||||
|
stroke={showError ? "transparent" : Theme.colors.linkPrimary}
|
||||||
|
strokeWidth={2}
|
||||||
|
fill="transparent"
|
||||||
|
strokeDasharray={"116 255"}
|
||||||
|
strokeDashoffset={spin}
|
||||||
|
/>
|
||||||
|
</Svg>
|
||||||
|
{showError && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.error,
|
||||||
|
{
|
||||||
|
borderColor: Theme.colors.border,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{children}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
loader: {
|
||||||
|
position: "absolute",
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
position: "absolute",
|
||||||
|
borderWidth: 2,
|
||||||
|
height: 56,
|
||||||
|
width: 56,
|
||||||
|
borderRadius: 30 / 3.5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default WalletLoadingThumbnail;
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { WalletConfig, WalletOptions } from "@thirdweb-dev/react-core";
|
||||||
|
import { WalletConnect } from "./WalletConnect";
|
||||||
|
import { WalletConnectUI } from "./WalletConnectUI";
|
||||||
|
import { TW_WC_PROJECT_ID } from "../../../constants/walletConnect";
|
||||||
|
import { walletIds } from "@thirdweb-dev/wallets";
|
||||||
|
|
||||||
|
export type WalletConnectConfig = {
|
||||||
|
projectId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const walletConnect = (
|
||||||
|
config?: WalletConnectConfig,
|
||||||
|
): WalletConfig<WalletConnect> => {
|
||||||
|
const projectId = config?.projectId || TW_WC_PROJECT_ID;
|
||||||
|
return {
|
||||||
|
id: WalletConnect.id,
|
||||||
|
meta: WalletConnect.meta,
|
||||||
|
create: (options: WalletOptions) =>
|
||||||
|
new WalletConnect({
|
||||||
|
...options,
|
||||||
|
walletId: walletIds.walletConnect,
|
||||||
|
projectId,
|
||||||
|
}),
|
||||||
|
connectUI(props) {
|
||||||
|
return <WalletConnectUI {...props} projectId={projectId} />;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,5 +1,58 @@
|
|||||||
# @thirdweb-dev/react
|
# @thirdweb-dev/react
|
||||||
|
|
||||||
|
## 3.14.32
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`07fb1b5f`](https://github.com/thirdweb-dev/js/commit/07fb1b5ffa4c170e252df31070852ddb9a81dec9), [`300a3c6f`](https://github.com/thirdweb-dev/js/commit/300a3c6f04d0ea7e25dfdb0a4c28b3a5796fcadf), [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf), [`28975765`](https://github.com/thirdweb-dev/js/commit/2897576513eb6f497a9f92e3e473182b4fc9681b), [`b91d3e99`](https://github.com/thirdweb-dev/js/commit/b91d3e990198b77dc1358e738c11dc4acaa67491)]:
|
||||||
|
- @thirdweb-dev/react-core@3.14.32
|
||||||
|
- @thirdweb-dev/wallets@1.1.15
|
||||||
|
- @thirdweb-dev/sdk@3.10.51
|
||||||
|
- @thirdweb-dev/chains@0.1.44
|
||||||
|
|
||||||
|
## 3.14.31
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74), [`a5ba9e4f`](https://github.com/thirdweb-dev/js/commit/a5ba9e4fbfee228e5b9ac27cd0157187e3a50117), [`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.14
|
||||||
|
- @thirdweb-dev/sdk@3.10.50
|
||||||
|
- @thirdweb-dev/react-core@3.14.31
|
||||||
|
|
||||||
|
## 3.14.30
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.13
|
||||||
|
- @thirdweb-dev/sdk@3.10.49
|
||||||
|
- @thirdweb-dev/react-core@3.14.30
|
||||||
|
|
||||||
|
## 3.14.29
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1458](https://github.com/thirdweb-dev/js/pull/1458) [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add `hideTestnetFaucet` to hide the "Request Testnet funds" button in ConnectWallet details dropdown in `@thirdweb-dev/react-native` and `@thirdweb-dev/react`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
<ConnectWallet hideTestnetFaucet={true} />
|
||||||
|
```
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed), [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9), [`f0443bd9`](https://github.com/thirdweb-dev/js/commit/f0443bd989dbba50d0836d1cf274bfb2f44a53fd), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76), [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 3.14.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`4b0e63dc`](https://github.com/thirdweb-dev/js/commit/4b0e63dcc0ca871ce9cef76f8a41ff290316741c)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
## 3.14.27
|
## 3.14.27
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react",
|
"name": "@thirdweb-dev/react",
|
||||||
"version": "3.14.27",
|
"version": "3.14.32",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -47,6 +47,13 @@ type ConnectWalletProps = {
|
|||||||
};
|
};
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
networkSelector?: Omit<NetworkSelectorProps, "theme" | "onClose" | "chains">;
|
networkSelector?: Omit<NetworkSelectorProps, "theme" | "onClose" | "chains">;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide option to request testnet funds for testnets in dropdown
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
hideTestnetFaucet?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TW_CONNECT_WALLET = "tw-connect-wallet";
|
const TW_CONNECT_WALLET = "tw-connect-wallet";
|
||||||
@@ -163,6 +170,7 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
|||||||
theme={theme}
|
theme={theme}
|
||||||
style={props.style}
|
style={props.style}
|
||||||
detailsBtn={props.detailsBtn}
|
detailsBtn={props.detailsBtn}
|
||||||
|
hideTestnetFaucet={props.hideTestnetFaucet}
|
||||||
onDisconnect={() => {
|
onDisconnect={() => {
|
||||||
if (authConfig?.authUrl) {
|
if (authConfig?.authUrl) {
|
||||||
logout();
|
logout();
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export const ConnectedWalletDetails: React.FC<{
|
|||||||
networkSelector?: Omit<NetworkSelectorProps, "theme" | "onClose" | "chains">;
|
networkSelector?: Omit<NetworkSelectorProps, "theme" | "onClose" | "chains">;
|
||||||
className?: string;
|
className?: string;
|
||||||
detailsBtn?: () => JSX.Element;
|
detailsBtn?: () => JSX.Element;
|
||||||
|
hideTestnetFaucet?: boolean;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const disconnect = useDisconnect();
|
const disconnect = useDisconnect();
|
||||||
const chains = useSupportedChains();
|
const chains = useSupportedChains();
|
||||||
@@ -322,32 +323,33 @@ export const ConnectedWalletDetails: React.FC<{
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Request Testnet funds */}
|
{/* Request Testnet funds */}
|
||||||
{((chain?.faucets && chain.faucets.length > 0) ||
|
{!props.hideTestnetFaucet &&
|
||||||
chain?.chainId === Localhost.chainId) && (
|
((chain?.faucets && chain.faucets.length > 0) ||
|
||||||
<MenuLink
|
chain?.chainId === Localhost.chainId) && (
|
||||||
href={chain?.faucets ? chain.faucets[0] : "#"}
|
<MenuLink
|
||||||
target="_blank"
|
href={chain?.faucets ? chain.faucets[0] : "#"}
|
||||||
as="a"
|
target="_blank"
|
||||||
onClick={async (e) => {
|
as="a"
|
||||||
if (chain.chainId === Localhost.chainId) {
|
onClick={async (e) => {
|
||||||
e.preventDefault();
|
if (chain.chainId === Localhost.chainId) {
|
||||||
setOpen(false);
|
e.preventDefault();
|
||||||
await sdk?.wallet.requestFunds(10);
|
setOpen(false);
|
||||||
await balanceQuery.refetch();
|
await sdk?.wallet.requestFunds(10);
|
||||||
}
|
await balanceQuery.refetch();
|
||||||
}}
|
}
|
||||||
style={{
|
}}
|
||||||
textDecoration: "none",
|
style={{
|
||||||
color: "inherit",
|
textDecoration: "none",
|
||||||
fontSize: fontSize.sm,
|
color: "inherit",
|
||||||
}}
|
fontSize: fontSize.sm,
|
||||||
>
|
}}
|
||||||
<SecondaryIconContainer>
|
>
|
||||||
<FundsIcon size={iconSize.sm} />
|
<SecondaryIconContainer>
|
||||||
</SecondaryIconContainer>
|
<FundsIcon size={iconSize.sm} />
|
||||||
Request Testnet Funds
|
</SecondaryIconContainer>
|
||||||
</MenuLink>
|
Request Testnet Funds
|
||||||
)}
|
</MenuLink>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Export Wallet */}
|
{/* Export Wallet */}
|
||||||
{activeWallet?.walletId === walletIds.localWallet && (
|
{activeWallet?.walletId === walletIds.localWallet && (
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,56 @@
|
|||||||
# @thirdweb-dev/sdk
|
# @thirdweb-dev/sdk
|
||||||
|
|
||||||
|
## 3.10.51
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1500](https://github.com/thirdweb-dev/js/pull/1500) [`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Pass sdk options to fetch contract metadata where possible
|
||||||
|
|
||||||
|
- [#1495](https://github.com/thirdweb-dev/js/pull/1495) [`28975765`](https://github.com/thirdweb-dev/js/commit/2897576513eb6f497a9f92e3e473182b4fc9681b) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Custom gas price for Create2 factory deployment on Cronos testnet
|
||||||
|
|
||||||
|
- [#1490](https://github.com/thirdweb-dev/js/pull/1490) [`b91d3e99`](https://github.com/thirdweb-dev/js/commit/b91d3e990198b77dc1358e738c11dc4acaa67491) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Small fix for Promise.all()"
|
||||||
|
|
||||||
|
- Updated dependencies [[`d248aa2c`](https://github.com/thirdweb-dev/js/commit/d248aa2c5a89a297dd2623c961793026de1de346), [`8f3b685a`](https://github.com/thirdweb-dev/js/commit/8f3b685ad2bd73cb4d5d8c8aa25c04ffc10fb7cf)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.6
|
||||||
|
- @thirdweb-dev/chains@0.1.44
|
||||||
|
|
||||||
|
## 3.10.50
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1480](https://github.com/thirdweb-dev/js/pull/1480) [`a5ba9e4f`](https://github.com/thirdweb-dev/js/commit/a5ba9e4fbfee228e5b9ac27cd0157187e3a50117) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Separate Account and AccountPermissions extensions
|
||||||
|
|
||||||
|
- [#1484](https://github.com/thirdweb-dev/js/pull/1484) [`39e2af6f`](https://github.com/thirdweb-dev/js/commit/39e2af6f2f4d933dca1b3de4a37de76375bafd74) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Expose getPolygonGasPriorityFee()
|
||||||
|
|
||||||
|
## 3.10.49
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1468](https://github.com/thirdweb-dev/js/pull/1468) [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Enable dynamic contract deployment with any evm
|
||||||
|
|
||||||
|
## 3.10.48
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1473](https://github.com/thirdweb-dev/js/pull/1473) [`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4) Thanks [@jnsdls](https://github.com/jnsdls)! - do not pass empty auth tokens
|
||||||
|
|
||||||
|
- [#1472](https://github.com/thirdweb-dev/js/pull/1472) [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add sdk information to service request headers
|
||||||
|
|
||||||
|
- [#1471](https://github.com/thirdweb-dev/js/pull/1471) [`f0443bd9`](https://github.com/thirdweb-dev/js/commit/f0443bd989dbba50d0836d1cf274bfb2f44a53fd) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Expose erc721.claimConditions.getSupplyClaimedByWallet()
|
||||||
|
|
||||||
|
- [#1469](https://github.com/thirdweb-dev/js/pull/1469) [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308) Thanks [@jnsdls](https://github.com/jnsdls)! - fix secret key auth strategy for RPC
|
||||||
|
|
||||||
|
- Updated dependencies [[`73462ef1`](https://github.com/thirdweb-dev/js/commit/73462ef10800aeeb5976634e2bc6fb5d3e8501e4), [`27c225a5`](https://github.com/thirdweb-dev/js/commit/27c225a51221417592b5940887abd1ccb8b67e47), [`cb1c9937`](https://github.com/thirdweb-dev/js/commit/cb1c9937fadb2d06eb148cf9819f2b3601376308), [`70c4a119`](https://github.com/thirdweb-dev/js/commit/70c4a119d691a37ec999d9f6087902d532cc82ed), [`a1732663`](https://github.com/thirdweb-dev/js/commit/a17326634e758c3bf42f0cc3869b8792f1e18cc9), [`588b2106`](https://github.com/thirdweb-dev/js/commit/588b21060139a7c0bf5805e2c629a16792ed2c76), [`269e68c0`](https://github.com/thirdweb-dev/js/commit/269e68c0a15e8f78cb5b68c9456ca8094b9e1f30)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.5
|
||||||
|
- @thirdweb-dev/chains@0.1.43
|
||||||
|
|
||||||
|
## 3.10.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`4c37af49`](https://github.com/thirdweb-dev/js/commit/4c37af49aa4fa66beb8ffe8ef556068a29f3c5d4)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.4
|
||||||
|
|
||||||
## 3.10.46
|
## 3.10.46
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/sdk",
|
"name": "@thirdweb-dev/sdk",
|
||||||
"version": "3.10.46",
|
"version": "3.10.51",
|
||||||
"description": "The main thirdweb SDK.",
|
"description": "The main thirdweb SDK.",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ export const CUSTOM_GAS_FOR_CHAIN: Record<number, CustomChain> = {
|
|||||||
name: "Canto Testnet",
|
name: "Canto Testnet",
|
||||||
gasPrice: 1000 * 10 ** 9,
|
gasPrice: 1000 * 10 ** 9,
|
||||||
},
|
},
|
||||||
|
[338]: {
|
||||||
|
name: "Cronos Testnet",
|
||||||
|
gasPrice: 2000 * 10 ** 9,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
/* eslint-enable no-useless-computed-key */
|
/* eslint-enable no-useless-computed-key */
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
|||||||
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
||||||
import { caches } from "./caches";
|
import { caches } from "./caches";
|
||||||
import { computeDeploymentInfo } from "./computeDeploymentInfo";
|
import { computeDeploymentInfo } from "./computeDeploymentInfo";
|
||||||
import { generatePluginFunctions } from "../plugin/generatePluginFunctions";
|
import {
|
||||||
|
generateExtensionFunctions,
|
||||||
|
generatePluginFunctions,
|
||||||
|
} from "../plugin/generatePluginFunctions";
|
||||||
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
|
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
|
||||||
|
import { getMetadataForExtensions } from "../plugin/getMetadataForExtensions";
|
||||||
|
import { Extension } from "../../types/extensions";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns txn data for keyless deploys as well as signer deploys.
|
* Returns txn data for keyless deploys as well as signer deploys.
|
||||||
@@ -42,6 +47,10 @@ export async function getDeploymentInfo(
|
|||||||
storage,
|
storage,
|
||||||
);
|
);
|
||||||
const pluginMetadata = await getMetadataForPlugins(metadataUri, storage);
|
const pluginMetadata = await getMetadataForPlugins(metadataUri, storage);
|
||||||
|
const extensionMetadata = await getMetadataForExtensions(
|
||||||
|
metadataUri,
|
||||||
|
storage,
|
||||||
|
);
|
||||||
|
|
||||||
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
|
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
|
||||||
if (pluginMetadata.length > 0) {
|
if (pluginMetadata.length > 0) {
|
||||||
@@ -87,6 +96,42 @@ export async function getDeploymentInfo(
|
|||||||
};
|
};
|
||||||
|
|
||||||
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
|
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
|
||||||
|
} else if (extensionMetadata.length > 0) {
|
||||||
|
// get deployment info for all extensions
|
||||||
|
const extensionDeploymentInfo = await Promise.all(
|
||||||
|
extensionMetadata.map(async (metadata) => {
|
||||||
|
const info = await computeDeploymentInfo(
|
||||||
|
"extension",
|
||||||
|
provider,
|
||||||
|
storage,
|
||||||
|
create2FactoryAddress,
|
||||||
|
{ metadata: metadata },
|
||||||
|
);
|
||||||
|
return info;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
// create constructor param input for BaseRouter
|
||||||
|
const routerInput: Extension[] = [];
|
||||||
|
extensionMetadata.forEach((metadata, index) => {
|
||||||
|
const extensionFunctions = generateExtensionFunctions(metadata.abi);
|
||||||
|
routerInput.push({
|
||||||
|
metadata: {
|
||||||
|
name: metadata.name,
|
||||||
|
metadataURI: "",
|
||||||
|
implementation:
|
||||||
|
extensionDeploymentInfo[index].transaction.predictedAddress,
|
||||||
|
},
|
||||||
|
functions: extensionFunctions,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// routerInput as constructor param for BaseRouter
|
||||||
|
customParams["_extensions"] = {
|
||||||
|
value: routerInput,
|
||||||
|
};
|
||||||
|
|
||||||
|
finalDeploymentInfo.push(...extensionDeploymentInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
const implementationDeployInfo = await computeDeploymentInfo(
|
const implementationDeployInfo = await computeDeploymentInfo(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export * from "./error";
|
|||||||
export * from "./snapshots";
|
export * from "./snapshots";
|
||||||
export * from "./role";
|
export * from "./role";
|
||||||
export * from "./metadata-resolver";
|
export * from "./metadata-resolver";
|
||||||
|
export * from "./gas-price";
|
||||||
|
|
||||||
// feature detection
|
// feature detection
|
||||||
export * from "./feature-detection/matchesPrebuiltAbi";
|
export * from "./feature-detection/matchesPrebuiltAbi";
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import TWRegistryABI from "@thirdweb-dev/contracts-js/dist/abis/TWMultichainRegi
|
|||||||
import { getMultichainRegistryAddress } from "../constants/addresses/getMultichainRegistryAddress";
|
import { getMultichainRegistryAddress } from "../constants/addresses/getMultichainRegistryAddress";
|
||||||
import { getChainProvider } from "../constants/urls";
|
import { getChainProvider } from "../constants/urls";
|
||||||
import type { TWMultichainRegistryLogic } from "@thirdweb-dev/contracts-js";
|
import type { TWMultichainRegistryLogic } from "@thirdweb-dev/contracts-js";
|
||||||
|
import { SDKOptions } from "../schema";
|
||||||
|
|
||||||
// Internal static cache
|
// Internal static cache
|
||||||
const metadataCache: Record<string, PublishedMetadata> = {};
|
const metadataCache: Record<string, PublishedMetadata> = {};
|
||||||
@@ -39,6 +40,7 @@ export async function fetchContractMetadataFromAddress(
|
|||||||
address: Address,
|
address: Address,
|
||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
sdkOptions: SDKOptions = {},
|
||||||
) {
|
) {
|
||||||
const chainId = (await provider.getNetwork()).chainId;
|
const chainId = (await provider.getNetwork()).chainId;
|
||||||
const cached = getFromCache(address, chainId);
|
const cached = getFromCache(address, chainId);
|
||||||
@@ -57,16 +59,17 @@ export async function fetchContractMetadataFromAddress(
|
|||||||
metadata = await fetchContractMetadata(compilerMetadataUri, storage);
|
metadata = await fetchContractMetadata(compilerMetadataUri, storage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug(
|
console.debug(
|
||||||
"Failed to get Contract Metadata from IPFS, defaulting to onchain registry",
|
"Contract Metadata not found on IPFS, defaulting to onchain registry. Original error:",
|
||||||
(e as any)?.message,
|
(e as any)?.message,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
// try from multichain registry
|
// try from multichain registry
|
||||||
if (!multichainRegistry) {
|
if (!multichainRegistry) {
|
||||||
|
// TODO enforce always passing sdk options for clientId/secretKey
|
||||||
multichainRegistry = new Contract(
|
multichainRegistry = new Contract(
|
||||||
getMultichainRegistryAddress(),
|
getMultichainRegistryAddress(),
|
||||||
TWRegistryABI,
|
TWRegistryABI,
|
||||||
getChainProvider("polygon", {}),
|
getChainProvider("polygon", sdkOptions),
|
||||||
) as TWMultichainRegistryLogic;
|
) as TWMultichainRegistryLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import { Abi } from "../../schema/contracts/custom";
|
import { Abi } from "../../schema/contracts/custom";
|
||||||
import { utils } from "ethers";
|
import { utils } from "ethers";
|
||||||
import { Plugin } from "../../types/plugins";
|
import { Plugin } from "../../types/plugins";
|
||||||
|
import { ExtensionFunction } from "../../types/extensions";
|
||||||
|
|
||||||
function getFunctionSignature(fnInputs: any): string {
|
function getFunctionSignature(fnInputs: any): string {
|
||||||
return (
|
return (
|
||||||
"(" +
|
"(" +
|
||||||
fnInputs
|
fnInputs
|
||||||
.map((i: any) => {
|
.map((i: any) => {
|
||||||
return i.type === "tuple" ? getFunctionSignature(i.components) : i.type;
|
return i.type === "tuple"
|
||||||
|
? getFunctionSignature(i.components)
|
||||||
|
: i.type === "tuple[]"
|
||||||
|
? getFunctionSignature(i.components) + `[]`
|
||||||
|
: i.type;
|
||||||
})
|
})
|
||||||
.join(",") +
|
.join(",") +
|
||||||
")"
|
")"
|
||||||
@@ -34,3 +39,25 @@ export function generatePluginFunctions(
|
|||||||
}
|
}
|
||||||
return pluginFunctions;
|
return pluginFunctions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function generateExtensionFunctions(
|
||||||
|
extensionAbi: any,
|
||||||
|
): ExtensionFunction[] {
|
||||||
|
const extensionInterface = new utils.Interface(extensionAbi);
|
||||||
|
const extensionFunctions: ExtensionFunction[] = [];
|
||||||
|
// TODO - filter out common functions like _msgSender(), contractType(), etc.
|
||||||
|
|
||||||
|
for (const fnFragment of Object.values(extensionInterface.functions)) {
|
||||||
|
const fn = extensionInterface.getFunction(
|
||||||
|
extensionInterface.getSighash(fnFragment),
|
||||||
|
);
|
||||||
|
if (fn.name.startsWith("_")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
extensionFunctions.push({
|
||||||
|
functionSelector: extensionInterface.getSighash(fn),
|
||||||
|
functionSignature: fn.name + getFunctionSignature(fn.inputs),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return extensionFunctions;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { getAllExtensionsAbi } from "../../constants/thirdweb-features";
|
||||||
|
import { ContractWrapper } from "../../core/classes/contract-wrapper";
|
||||||
|
import {
|
||||||
|
AbiSchema,
|
||||||
|
PreDeployMetadataFetched,
|
||||||
|
} from "../../schema/contracts/custom";
|
||||||
|
import { isFeatureEnabled } from "../feature-detection/isFeatureEnabled";
|
||||||
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { getChainProvider } from "../../constants/urls";
|
||||||
|
import { fetchAndCachePublishedContractURI } from "../any-evm-utils/fetchAndCachePublishedContractURI";
|
||||||
|
import { fetchAndCacheDeployMetadata } from "../any-evm-utils/fetchAndCacheDeployMetadata";
|
||||||
|
import { Extension } from "../../types/extensions";
|
||||||
|
|
||||||
|
export async function getMetadataForExtensions(
|
||||||
|
publishedMetadataUri: string,
|
||||||
|
storage: ThirdwebStorage,
|
||||||
|
): Promise<PreDeployMetadataFetched[]> {
|
||||||
|
let extensionMetadata: PreDeployMetadataFetched[] = [];
|
||||||
|
|
||||||
|
const { compilerMetadata, extendedMetadata } =
|
||||||
|
await fetchAndCacheDeployMetadata(publishedMetadataUri, storage);
|
||||||
|
// check if contract is extension-pattern
|
||||||
|
const isExtensionRouter: boolean = isFeatureEnabled(
|
||||||
|
AbiSchema.parse(compilerMetadata.abi),
|
||||||
|
"ExtensionRouter",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isExtensionRouter) {
|
||||||
|
if (
|
||||||
|
extendedMetadata &&
|
||||||
|
extendedMetadata.factoryDeploymentData?.implementationAddresses
|
||||||
|
) {
|
||||||
|
const implementationsAddresses = Object.entries(
|
||||||
|
extendedMetadata.factoryDeploymentData.implementationAddresses,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const entry = implementationsAddresses.find(
|
||||||
|
([, implementation]) => implementation !== "",
|
||||||
|
);
|
||||||
|
const [network, implementation] = entry ? entry : [];
|
||||||
|
if (network && implementation) {
|
||||||
|
const provider = getChainProvider(parseInt(network), {});
|
||||||
|
const contract = new ContractWrapper(
|
||||||
|
provider,
|
||||||
|
implementation,
|
||||||
|
getAllExtensionsAbi,
|
||||||
|
{},
|
||||||
|
storage,
|
||||||
|
);
|
||||||
|
|
||||||
|
const extensions = await contract.call("getAllExtensions");
|
||||||
|
|
||||||
|
const extensionNames: string[] = Array.from(
|
||||||
|
new Set(extensions.map((item: Extension) => item.metadata.name)),
|
||||||
|
);
|
||||||
|
|
||||||
|
const extensionUris = await Promise.all(
|
||||||
|
extensionNames.map((name) => {
|
||||||
|
return fetchAndCachePublishedContractURI(name);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
extensionMetadata = (
|
||||||
|
await Promise.all(
|
||||||
|
extensionUris.map(async (uri) => {
|
||||||
|
return fetchAndCacheDeployMetadata(uri, storage);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return extensionMetadata;
|
||||||
|
}
|
||||||
@@ -67,6 +67,7 @@ import {
|
|||||||
FEATURE_EXTENSION_ROUTER,
|
FEATURE_EXTENSION_ROUTER,
|
||||||
FEATURE_ACCOUNT,
|
FEATURE_ACCOUNT,
|
||||||
FEATURE_ACCOUNT_FACTORY,
|
FEATURE_ACCOUNT_FACTORY,
|
||||||
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
} from "./thirdweb-features";
|
} from "./thirdweb-features";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,6 +135,7 @@ export type Feature =
|
|||||||
| typeof FEATURE_ENGLISH_AUCTIONS
|
| typeof FEATURE_ENGLISH_AUCTIONS
|
||||||
| typeof FEATURE_OFFERS
|
| typeof FEATURE_OFFERS
|
||||||
| typeof FEATURE_ACCOUNT
|
| typeof FEATURE_ACCOUNT
|
||||||
|
| typeof FEATURE_ACCOUNT_PERMISSIONS
|
||||||
| typeof FEATURE_ACCOUNT_FACTORY;
|
| typeof FEATURE_ACCOUNT_FACTORY;
|
||||||
|
|
||||||
export type Extension = Feature;
|
export type Extension = Feature;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import IThirdwebPrimarySaleAbi from "@thirdweb-dev/contracts-js/dist/abis/IPrima
|
|||||||
import IThirdwebRoyaltyAbi from "@thirdweb-dev/contracts-js/dist/abis/IRoyalty.json";
|
import IThirdwebRoyaltyAbi from "@thirdweb-dev/contracts-js/dist/abis/IRoyalty.json";
|
||||||
import IOwnableAbi from "@thirdweb-dev/contracts-js/dist/abis/Ownable.json";
|
import IOwnableAbi from "@thirdweb-dev/contracts-js/dist/abis/Ownable.json";
|
||||||
import IAccountFactory from "@thirdweb-dev/contracts-js/dist/abis/IAccountFactory.json";
|
import IAccountFactory from "@thirdweb-dev/contracts-js/dist/abis/IAccountFactory.json";
|
||||||
import IAccountCore from "@thirdweb-dev/contracts-js/dist/abis/IAccountCore.json";
|
import IAccountPermissions from "@thirdweb-dev/contracts-js/dist/abis/IAccountPermissions.json";
|
||||||
|
import IAccount from "@thirdweb-dev/contracts-js/dist/abis/IAccount.json";
|
||||||
|
|
||||||
export const getAllPluginsAbi = [
|
export const getAllPluginsAbi = [
|
||||||
{
|
{
|
||||||
@@ -291,6 +292,18 @@ export const FEATURE_ACCOUNT_FACTORY = {
|
|||||||
features: {},
|
features: {},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_ACCOUNT_PERMISSIONS = {
|
||||||
|
name: "AccountPermissions",
|
||||||
|
namespace: "accountPermissions",
|
||||||
|
docLinks: {
|
||||||
|
// TODO
|
||||||
|
sdk: "sdk.account",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [IAccountPermissions],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const FEATURE_ACCOUNT = {
|
export const FEATURE_ACCOUNT = {
|
||||||
name: "Account",
|
name: "Account",
|
||||||
namespace: "account",
|
namespace: "account",
|
||||||
@@ -299,6 +312,6 @@ export const FEATURE_ACCOUNT = {
|
|||||||
sdk: "sdk.account",
|
sdk: "sdk.account",
|
||||||
contracts: "",
|
contracts: "",
|
||||||
},
|
},
|
||||||
abis: [IAccountCore],
|
abis: [IAccount],
|
||||||
features: {},
|
features: { [FEATURE_ACCOUNT_PERMISSIONS.name]: FEATURE_ACCOUNT_PERMISSIONS },
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { getValidChainRPCs } from "@thirdweb-dev/chains";
|
|||||||
import type { Chain } from "@thirdweb-dev/chains";
|
import type { Chain } from "@thirdweb-dev/chains";
|
||||||
import { providers } from "ethers";
|
import { providers } from "ethers";
|
||||||
import type { Signer } from "ethers";
|
import type { Signer } from "ethers";
|
||||||
|
import pkg from "../../../package.json";
|
||||||
|
import { isBrowser } from "@thirdweb-dev/storage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -159,26 +161,76 @@ export function getProviderFromRpcUrl(
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const headers: HeadersInit = {};
|
const headers: HeadersInit = {};
|
||||||
|
// will be used to make sure we don't cache providers with different auth strategies
|
||||||
|
let authStrategy = "none";
|
||||||
|
|
||||||
if (isTwUrl(rpcUrl)) {
|
if (isTwUrl(rpcUrl)) {
|
||||||
if (sdkOptions?.clientId) {
|
// if we have a secret key passed in the SDK options we want to always use that
|
||||||
headers["x-client-id"] = sdkOptions?.clientId;
|
if (sdkOptions?.secretKey) {
|
||||||
// bundleId may already be injected
|
// compute the clientId from the secret key
|
||||||
if (!rpcUrl.includes("bundleId")) {
|
// should only be used on Node.js in a backend/script context
|
||||||
rpcUrl =
|
if (typeof window !== "undefined") {
|
||||||
rpcUrl +
|
throw new Error("Cannot use secretKey in browser context");
|
||||||
(typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis
|
|
||||||
? `?bundleId=${(globalThis as any).APP_BUNDLE_ID as string}`
|
|
||||||
: "");
|
|
||||||
}
|
}
|
||||||
} else if (sdkOptions?.secretKey) {
|
// this is on purpose because we're using the crypto module only in node
|
||||||
headers["x-secret-key"] = sdkOptions?.secretKey;
|
// try to trick webpack :)
|
||||||
|
const pto = "pto";
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const crypto = require("cry" + pto);
|
||||||
|
const hashedSecretKey = crypto
|
||||||
|
.createHash("sha256")
|
||||||
|
.update(sdkOptions.secretKey)
|
||||||
|
.digest("hex");
|
||||||
|
const derivedClientId = hashedSecretKey.slice(0, 32);
|
||||||
|
const utilizedRpcUrl = new URL(rpcUrl);
|
||||||
|
// always set the clientId on the path to the derived client id
|
||||||
|
utilizedRpcUrl.pathname = derivedClientId;
|
||||||
|
// set the headers
|
||||||
|
headers["x-client-id"] = derivedClientId;
|
||||||
|
headers["x-secret-key"] = sdkOptions.secretKey;
|
||||||
|
// set the final rpc url
|
||||||
|
rpcUrl = utilizedRpcUrl.toString();
|
||||||
|
authStrategy = "secretKey";
|
||||||
}
|
}
|
||||||
// if we have a tw auth token on global context add it to the headers
|
// if we do NOT have a secret key but we have a client id we want to use that
|
||||||
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis) {
|
else if (sdkOptions?.clientId) {
|
||||||
|
const utilizedRpcUrl = new URL(rpcUrl);
|
||||||
|
// always set the clientId on the path to the client id
|
||||||
|
utilizedRpcUrl.pathname = sdkOptions.clientId;
|
||||||
|
// set the headers
|
||||||
|
headers["x-client-id"] = sdkOptions.clientId;
|
||||||
|
// set the final rpc url
|
||||||
|
rpcUrl = utilizedRpcUrl.toString();
|
||||||
|
authStrategy = "clientId";
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we *also* have a tw auth token on global context add it to the headers (in addition to anything else)
|
||||||
|
if (
|
||||||
|
typeof globalThis !== "undefined" &&
|
||||||
|
"TW_AUTH_TOKEN" in globalThis &&
|
||||||
|
typeof (globalThis as any).TW_AUTH_TOKEN === "string"
|
||||||
|
) {
|
||||||
headers["authorization"] = `Bearer ${
|
headers["authorization"] = `Bearer ${
|
||||||
(globalThis as any).TW_AUTH_TOKEN as string
|
(globalThis as any).TW_AUTH_TOKEN as string
|
||||||
}`;
|
}`;
|
||||||
|
authStrategy = "twAuthToken";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bundleId =
|
||||||
|
typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis
|
||||||
|
? ((globalThis as any).APP_BUNDLE_ID as string)
|
||||||
|
: undefined;
|
||||||
|
if (!rpcUrl.includes("bundleId")) {
|
||||||
|
rpcUrl = rpcUrl + (bundleId ? `?bundleId=${bundleId}` : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
headers["x-sdk-version"] = pkg.version;
|
||||||
|
headers["x-sdk-name"] = pkg.name;
|
||||||
|
headers["x-sdk-platform"] = bundleId
|
||||||
|
? "react-native"
|
||||||
|
: isBrowser()
|
||||||
|
? "browser"
|
||||||
|
: "node";
|
||||||
}
|
}
|
||||||
const match = rpcUrl.match(/^(ws|http)s?:/i);
|
const match = rpcUrl.match(/^(ws|http)s?:/i);
|
||||||
// Try the JSON batch provider if available
|
// Try the JSON batch provider if available
|
||||||
@@ -187,7 +239,7 @@ export function getProviderFromRpcUrl(
|
|||||||
case "http":
|
case "http":
|
||||||
case "https":
|
case "https":
|
||||||
// Create a unique cache key for these params
|
// Create a unique cache key for these params
|
||||||
const seralizedOpts = `${rpcUrl}-${chainId || -1}`;
|
const seralizedOpts = `${rpcUrl}-${chainId || -1}-${authStrategy}`;
|
||||||
|
|
||||||
// Check if we have a provider in our cache already
|
// Check if we have a provider in our cache already
|
||||||
const existingProvider = RPC_PROVIDER_MAP.get(seralizedOpts);
|
const existingProvider = RPC_PROVIDER_MAP.get(seralizedOpts);
|
||||||
@@ -217,6 +269,7 @@ export function getProviderFromRpcUrl(
|
|||||||
case "ws":
|
case "ws":
|
||||||
case "wss":
|
case "wss":
|
||||||
// Use the WebSocketProvider for ws:// URLs
|
// Use the WebSocketProvider for ws:// URLs
|
||||||
|
// TODO: handle auth for WS at some point
|
||||||
return new providers.WebSocketProvider(rpcUrl, chainId);
|
return new providers.WebSocketProvider(rpcUrl, chainId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const EditionDropInitializer = {
|
|||||||
) => {
|
) => {
|
||||||
const [, provider] = getSignerAndProvider(network, options);
|
const [, provider] = getSignerAndProvider(network, options);
|
||||||
const [abi, contract, _network] = await Promise.all([
|
const [abi, contract, _network] = await Promise.all([
|
||||||
await EditionDropInitializer.getAbi(address, provider, storage),
|
EditionDropInitializer.getAbi(address, provider, storage),
|
||||||
import("./prebuilt-implementations/edition-drop"),
|
import("./prebuilt-implementations/edition-drop"),
|
||||||
provider.getNetwork(),
|
provider.getNetwork(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -0,0 +1,727 @@
|
|||||||
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import { FEATURE_ACCOUNT_PERMISSIONS } from "../../constants/thirdweb-features";
|
||||||
|
import { utils, BigNumber } from "ethers";
|
||||||
|
import { Transaction } from "./transactions";
|
||||||
|
|
||||||
|
import type {
|
||||||
|
IAccountCore,
|
||||||
|
IAccountPermissions,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import {
|
||||||
|
SignedSignerPermissionsPayload,
|
||||||
|
SignerPermissionsOutput,
|
||||||
|
SignerWithPermissions,
|
||||||
|
SignerPermissions,
|
||||||
|
SignerPermissionsInput,
|
||||||
|
SignerPermissionRequest,
|
||||||
|
SignerPermissionsSchema,
|
||||||
|
PermissionSnapshotInput,
|
||||||
|
PermissionSnapshotSchema,
|
||||||
|
PermissionSnapshotOutput,
|
||||||
|
} from "../../types";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
import { buildTransactionFunction } from "../../common/transactions";
|
||||||
|
import { resolveOrGenerateId } from "../../common/signature-minting";
|
||||||
|
import { AddressOrEns } from "../../schema";
|
||||||
|
import { resolveAddress } from "../../common";
|
||||||
|
|
||||||
|
export class AccountPermissions implements DetectableFeature {
|
||||||
|
featureName = FEATURE_ACCOUNT_PERMISSIONS.name;
|
||||||
|
private contractWrapper: ContractWrapper<IAccountCore>;
|
||||||
|
|
||||||
|
constructor(contractWrapper: ContractWrapper<IAccountCore>) {
|
||||||
|
this.contractWrapper = contractWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAddress(): string {
|
||||||
|
return this.contractWrapper.readContract.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* HELPER FUNCTIONS
|
||||||
|
********************************/
|
||||||
|
|
||||||
|
private hasDuplicateSigners(snapshot: PermissionSnapshotOutput): boolean {
|
||||||
|
const checkedSigner: Record<string, boolean> = {};
|
||||||
|
|
||||||
|
const signers = snapshot.map((item) => item.signer);
|
||||||
|
|
||||||
|
for (const signer of signers) {
|
||||||
|
if (!checkedSigner[signer]) {
|
||||||
|
checkedSigner[signer] = true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the access restrictions for a given role
|
||||||
|
*
|
||||||
|
* @param restrictions - The access restrictions for a given role
|
||||||
|
* @returns formatted role restrictions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private parseSignerPermissionsStruct(
|
||||||
|
permissions: IAccountPermissions.SignerPermissionsStruct,
|
||||||
|
): SignerPermissions {
|
||||||
|
return {
|
||||||
|
startDate: new Date(
|
||||||
|
parseInt(permissions.startTimestamp.toString()) * 1000,
|
||||||
|
),
|
||||||
|
expirationDate: new Date(
|
||||||
|
parseInt(permissions.endTimestamp.toString()) * 1000,
|
||||||
|
),
|
||||||
|
nativeTokenLimitPerTransaction: BigNumber.from(
|
||||||
|
permissions.nativeTokenLimitPerTransaction,
|
||||||
|
),
|
||||||
|
approvedCallTargets: permissions.approvedTargets,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sendSignerPermissionRequest(
|
||||||
|
signerAddress: string,
|
||||||
|
permissions: SignerPermissionsOutput,
|
||||||
|
): Promise<Transaction> {
|
||||||
|
const { payload, signature } = await this.generatePayload(
|
||||||
|
signerAddress,
|
||||||
|
permissions,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { success } =
|
||||||
|
await this.contractWrapper.readContract.verifySignerPermissionRequest(
|
||||||
|
payload,
|
||||||
|
signature,
|
||||||
|
);
|
||||||
|
if (!success) {
|
||||||
|
throw new Error(`Invalid signature.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "setPermissionsForSigner",
|
||||||
|
args: [payload, signature],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async buildSignerPermissionRequest(
|
||||||
|
signerAddress: string,
|
||||||
|
permissions: SignerPermissionsOutput,
|
||||||
|
): Promise<string> {
|
||||||
|
const { payload, signature } = await this.generatePayload(
|
||||||
|
signerAddress,
|
||||||
|
permissions,
|
||||||
|
);
|
||||||
|
|
||||||
|
const isValidSigner =
|
||||||
|
await this.contractWrapper.readContract.verifySignerPermissionRequest(
|
||||||
|
payload,
|
||||||
|
signature,
|
||||||
|
);
|
||||||
|
if (!isValidSigner) {
|
||||||
|
throw new Error(`Invalid signature.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.contractWrapper.writeContract.interface.encodeFunctionData(
|
||||||
|
"setPermissionsForSigner",
|
||||||
|
[payload, signature],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate and sign a payload to grant or revoke a signer's access to the account.
|
||||||
|
*
|
||||||
|
* @param signer - The address of the signer
|
||||||
|
* @param roleAction - The address of the signer
|
||||||
|
* @returns The generated payload and signature produced on signing that payload.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private async generatePayload(
|
||||||
|
signerAddress: string,
|
||||||
|
permissions: SignerPermissionsOutput,
|
||||||
|
): Promise<SignedSignerPermissionsPayload> {
|
||||||
|
// Get payload struct.
|
||||||
|
const payload: IAccountPermissions.SignerPermissionRequestStruct = {
|
||||||
|
signer: signerAddress,
|
||||||
|
approvedTargets: permissions.approvedCallTargets,
|
||||||
|
nativeTokenLimitPerTransaction: utils.parseEther(
|
||||||
|
permissions.nativeTokenLimitPerTransaction,
|
||||||
|
),
|
||||||
|
permissionStartTimestamp: permissions.startDate,
|
||||||
|
permissionEndTimestamp: permissions.expirationDate,
|
||||||
|
reqValidityStartTimestamp: 0,
|
||||||
|
// Req validity ends 10 years from now.
|
||||||
|
reqValidityEndTimestamp: BigNumber.from(
|
||||||
|
Math.floor(
|
||||||
|
new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 10).getTime() /
|
||||||
|
1000,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
uid: resolveOrGenerateId(undefined),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Generate signature
|
||||||
|
const chainId = await this.contractWrapper.getChainID();
|
||||||
|
const connectedSigner = this.contractWrapper.getSigner();
|
||||||
|
invariant(connectedSigner, "No signer available");
|
||||||
|
|
||||||
|
const signature = await this.contractWrapper.signTypedData(
|
||||||
|
connectedSigner,
|
||||||
|
{
|
||||||
|
name: "Account",
|
||||||
|
version: "1",
|
||||||
|
chainId,
|
||||||
|
verifyingContract: this.getAddress(),
|
||||||
|
},
|
||||||
|
{ SignerPermissionRequest },
|
||||||
|
payload,
|
||||||
|
);
|
||||||
|
|
||||||
|
return { payload, signature };
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* READ FUNCTIONS
|
||||||
|
********************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether a signer is an admin on the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const isAdmin = await contract.account.isAdmin(signer);
|
||||||
|
* ```
|
||||||
|
* @param signer - The address of a signer of the account.
|
||||||
|
* @returns whether a signer is an admin on the account.
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
public async isAdmin(signerAddress: AddressOrEns): Promise<boolean> {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
return await this.contractWrapper.readContract.isAdmin(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether a signer has permissions to use the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const isAdmin = await contract.account.isSigner(signer);
|
||||||
|
* ```
|
||||||
|
* @param signer - The address of a signer of the account.
|
||||||
|
* @returns whether a signer has permissions to use the account.
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
public async isSigner(signerAddress: AddressOrEns): Promise<boolean> {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
return await this.contractWrapper.readContract.isActiveSigner(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all admins of the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const allAdmins = await contract.account.getAllAdmins();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @returns all admins of the account.
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
public async getAllAdmins(): Promise<string[]> {
|
||||||
|
return await this.contractWrapper.readContract.getAllAdmins();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all (non-admin) signers with permissions to use the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const allSigners = await contract.account.getAllSigners();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @returns all (non-admin) signers with permissions to use the account.
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
public async getAllSigners(): Promise<SignerWithPermissions[]> {
|
||||||
|
const activeSignersWithPerms: IAccountPermissions.SignerPermissionsStruct[] =
|
||||||
|
await this.contractWrapper.readContract.getAllActiveSigners();
|
||||||
|
|
||||||
|
return await Promise.all(
|
||||||
|
activeSignersWithPerms.map(async (signerWithPermissions) => {
|
||||||
|
const signer = signerWithPermissions.signer;
|
||||||
|
const permissions = this.parseSignerPermissionsStruct(
|
||||||
|
signerWithPermissions,
|
||||||
|
);
|
||||||
|
return { signer, permissions };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all admins and non-admin signers with permissions to use the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const allAdminsAndSigners = await contract.account.getAllAdminsAndSigners();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @returns all admins and non-admin signers with permissions to use the account.
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
public async getAllAdminsAndSigners(): Promise<SignerWithPermissions[]> {
|
||||||
|
const allAdmins = await this.getAllAdmins();
|
||||||
|
const transformedAdmins: SignerWithPermissions[] = allAdmins.map(
|
||||||
|
(admin) => {
|
||||||
|
return {
|
||||||
|
isAdmin: true,
|
||||||
|
signer: admin,
|
||||||
|
permissions: {
|
||||||
|
startDate: new Date(0),
|
||||||
|
expirationDate: new Date(0),
|
||||||
|
nativeTokenLimitPerTransaction: BigNumber.from(0),
|
||||||
|
approvedCallTargets: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const allSigners = await this.getAllSigners();
|
||||||
|
|
||||||
|
return [...transformedAdmins, ...allSigners];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* WRITE FUNCTIONS
|
||||||
|
********************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grant an address admin access to the account.
|
||||||
|
*
|
||||||
|
* @remarks Grants an address admin access to the account. The admin will have complete authority over the account.
|
||||||
|
*
|
||||||
|
* @param signer - The address to be granted admin access to the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.grantAdminAccess(signer);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
grantAdminPermissions = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "setAdmin",
|
||||||
|
args: [resolvedSignerAddress, true],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Revoke an address' admin access to the account.
|
||||||
|
*
|
||||||
|
* @remarks Revokes an address' admin access to the account.
|
||||||
|
*
|
||||||
|
* @param signer - The address of an admin of the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.revokeAdminAccess(signer);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
revokeAdminPermissions = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "setAdmin",
|
||||||
|
args: [resolvedSignerAddress, false],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grant a signer permissions to use the account.
|
||||||
|
*
|
||||||
|
* @remarks Grants a signer permissions to use the account.
|
||||||
|
*
|
||||||
|
* @param signer - The signer to be granted permissions to use the account.
|
||||||
|
* @param permissions - The permissions to be applied to the signer's use of the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.grantPermissions(signer, permissions);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
grantPermissions = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
signerAddress: AddressOrEns,
|
||||||
|
permissions: SignerPermissionsInput,
|
||||||
|
): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
const resolvedPermissions = await SignerPermissionsSchema.parseAsync(
|
||||||
|
permissions,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (await this.isAdmin(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer is already an admin. Cannot grant permissions to an existing admin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await this.isSigner(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer already has permissions. Cannot grant permissions to an existing signer. You can update permissions using `updatePermissions`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.sendSignerPermissionRequest(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
resolvedPermissions,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the permissions of a signer for using the account.
|
||||||
|
*
|
||||||
|
* @remarks Updates the permissions of a signer for using the account.
|
||||||
|
*
|
||||||
|
* @param signer - The signer whose permissions to use the account are to be updated.
|
||||||
|
* @param permissions - The permissions to be applied to the signer's use of the account.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.updateAccess(signer, restrictions);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
updatePermissions = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
signerAddress: AddressOrEns,
|
||||||
|
permissions: SignerPermissionsInput,
|
||||||
|
): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
const resolvedPermissions = await SignerPermissionsSchema.parseAsync(
|
||||||
|
permissions,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (await this.isAdmin(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer is already an admin. Cannot update permissions of an existing admin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(await this.isSigner(resolvedSignerAddress))) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.sendSignerPermissionRequest(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
resolvedPermissions,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Revoke a scoped access address to the account
|
||||||
|
*
|
||||||
|
* @remarks Revokes an address' access to the account.
|
||||||
|
*
|
||||||
|
* @param signer - The address whose access to the account is to be revoked.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.revokeAccess(signer);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
revokeAccess = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
|
||||||
|
if (await this.isAdmin(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer is already an admin. Cannot revoke permissions of an admin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(await this.isSigner(resolvedSignerAddress))) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
||||||
|
startDate: BigNumber.from(0),
|
||||||
|
expirationDate: BigNumber.from(0),
|
||||||
|
approvedCallTargets: [],
|
||||||
|
nativeTokenLimitPerTransaction: "0",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Approve an address as a call target for a given signer on the account
|
||||||
|
*
|
||||||
|
* @remarks Approves an address as a call target for a given signer on the account.
|
||||||
|
*
|
||||||
|
* @param signer - A signer with restricted access to the account.
|
||||||
|
* @param target - The address to approve as a call target for the signer.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.approveTargetForSigner(signer, target);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
approveTargetForSigner = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
signerAddress: AddressOrEns,
|
||||||
|
target: AddressOrEns,
|
||||||
|
): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
const resolvedTarget = await resolveAddress(target);
|
||||||
|
|
||||||
|
if (await this.isAdmin(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer is already an admin. Cannot approve targets for an admin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(await this.isSigner(resolvedSignerAddress))) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const permissions: IAccountPermissions.SignerPermissionsStruct =
|
||||||
|
await this.contractWrapper.readContract.getPermissionsForSigner(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (permissions.approvedTargets.includes(target)) {
|
||||||
|
throw new Error("Target is already approved");
|
||||||
|
}
|
||||||
|
|
||||||
|
const newTargets = [...permissions.approvedTargets, resolvedTarget];
|
||||||
|
|
||||||
|
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
||||||
|
startDate: BigNumber.from(permissions.startTimestamp),
|
||||||
|
expirationDate: BigNumber.from(permissions.endTimestamp),
|
||||||
|
approvedCallTargets: newTargets,
|
||||||
|
nativeTokenLimitPerTransaction:
|
||||||
|
permissions.nativeTokenLimitPerTransaction.toString(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disapprove an address as a call target for a given signer on the account
|
||||||
|
*
|
||||||
|
* @remarks Disapprove an address as a call target for a given signer on the account.
|
||||||
|
*
|
||||||
|
* @param signer - A signer with restricted access to the account.
|
||||||
|
* @param target - The address to disapprove as a call target for the signer.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.disapproveTargetForSigner(signer, target);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
disapproveTargetForSigner = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
signerAddress: AddressOrEns,
|
||||||
|
target: AddressOrEns,
|
||||||
|
): Promise<Transaction> => {
|
||||||
|
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
||||||
|
const resolvedTarget = await resolveAddress(target);
|
||||||
|
|
||||||
|
if (await this.isAdmin(resolvedSignerAddress)) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer is already an admin. Cannot approve targets for an admin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(await this.isSigner(resolvedSignerAddress))) {
|
||||||
|
throw new Error(
|
||||||
|
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const permissions: IAccountPermissions.SignerPermissionsStruct =
|
||||||
|
await this.contractWrapper.readContract.getPermissionsForSigner(
|
||||||
|
resolvedSignerAddress,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!permissions.approvedTargets.includes(resolvedTarget)) {
|
||||||
|
throw new Error("Target is currently not approved");
|
||||||
|
}
|
||||||
|
|
||||||
|
const newTargets = permissions.approvedTargets.filter(
|
||||||
|
(approvedTarget) =>
|
||||||
|
utils.getAddress(approvedTarget) !== utils.getAddress(resolvedTarget),
|
||||||
|
);
|
||||||
|
|
||||||
|
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
||||||
|
startDate: BigNumber.from(permissions.startTimestamp),
|
||||||
|
expirationDate: BigNumber.from(permissions.endTimestamp),
|
||||||
|
approvedCallTargets: newTargets,
|
||||||
|
nativeTokenLimitPerTransaction:
|
||||||
|
permissions.nativeTokenLimitPerTransaction.toString(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the account's entire snapshot of permissions.
|
||||||
|
*
|
||||||
|
* @remarks Sets the account's entire snapshot of permissions.
|
||||||
|
*
|
||||||
|
* @param permissionSnapshot - the snapshot to set as the account's entire permission snapshot.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const tx = await contract.account.setAccess(permissionSnapshot);
|
||||||
|
* const receipt = tx.receipt();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @twfeature AccountPermissions
|
||||||
|
*/
|
||||||
|
resetAllPermissions = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
permissionSnapshot: PermissionSnapshotInput,
|
||||||
|
): Promise<Transaction> => {
|
||||||
|
const resolvedSnapshot = await PermissionSnapshotSchema.parseAsync(
|
||||||
|
permissionSnapshot,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All cases
|
||||||
|
*
|
||||||
|
* - Add new admin :check:
|
||||||
|
* - Remove current admin :check:
|
||||||
|
* - Add new scoped :check:
|
||||||
|
* - Remove current scoped :check:
|
||||||
|
* - Update current scoped :check:
|
||||||
|
* - Current admin -> new scoped :check:
|
||||||
|
* - Current scoped -> new admin :check:
|
||||||
|
**/
|
||||||
|
|
||||||
|
// No duplicate signers in input!
|
||||||
|
if (this.hasDuplicateSigners(resolvedSnapshot)) {
|
||||||
|
throw new Error("Duplicate signers found in input.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const addAdminData: string[] = [];
|
||||||
|
const removeAdminData: string[] = [];
|
||||||
|
const addOrUpdateSignerData: string[] = [];
|
||||||
|
const removeSignerData: string[] = [];
|
||||||
|
|
||||||
|
// Remove all existing admins not included in the passed snapshot.
|
||||||
|
const allAdmins = await this.getAllAdmins();
|
||||||
|
const allToMakeAdmin = resolvedSnapshot
|
||||||
|
.filter((item) => item.makeAdmin)
|
||||||
|
.map((item) => item.signer);
|
||||||
|
allAdmins.forEach((admin) => {
|
||||||
|
if (!allToMakeAdmin.includes(admin)) {
|
||||||
|
removeAdminData.push(
|
||||||
|
this.contractWrapper.writeContract.interface.encodeFunctionData(
|
||||||
|
"setAdmin",
|
||||||
|
[admin, false],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove all existing signers not included in the passed snapshot.
|
||||||
|
const allSigners = await this.getAllSigners();
|
||||||
|
const allToMakeSigners = resolvedSnapshot
|
||||||
|
.filter((item) => {
|
||||||
|
return !item.makeAdmin;
|
||||||
|
})
|
||||||
|
.map((item) => item.signer);
|
||||||
|
await Promise.all(
|
||||||
|
allSigners.map(async (item) => {
|
||||||
|
if (!allToMakeSigners.includes(item.signer)) {
|
||||||
|
const data = await this.buildSignerPermissionRequest(item.signer, {
|
||||||
|
startDate: BigNumber.from(0),
|
||||||
|
expirationDate: BigNumber.from(0),
|
||||||
|
approvedCallTargets: [],
|
||||||
|
nativeTokenLimitPerTransaction: "0",
|
||||||
|
});
|
||||||
|
|
||||||
|
removeSignerData.push(data);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const member of resolvedSnapshot) {
|
||||||
|
// Add new admin
|
||||||
|
if (member.makeAdmin) {
|
||||||
|
addAdminData.push(
|
||||||
|
this.contractWrapper.writeContract.interface.encodeFunctionData(
|
||||||
|
"setAdmin",
|
||||||
|
[member.signer, true],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Add new scoped
|
||||||
|
const data = await this.buildSignerPermissionRequest(
|
||||||
|
member.signer,
|
||||||
|
member.permissions,
|
||||||
|
);
|
||||||
|
addOrUpdateSignerData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const data: string[] = [];
|
||||||
|
removeAdminData.forEach((item) => {
|
||||||
|
data.push(item);
|
||||||
|
});
|
||||||
|
removeSignerData.forEach((item) => {
|
||||||
|
data.push(item);
|
||||||
|
});
|
||||||
|
addOrUpdateSignerData.forEach((item) => {
|
||||||
|
data.push(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "multicall",
|
||||||
|
args: [data],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,190 +1,48 @@
|
|||||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
import { ContractWrapper } from "./contract-wrapper";
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
import { FEATURE_ACCOUNT } from "../../constants/thirdweb-features";
|
|
||||||
import { utils, BigNumber } from "ethers";
|
|
||||||
import { Transaction } from "./transactions";
|
|
||||||
|
|
||||||
import type {
|
|
||||||
IAccountCore,
|
|
||||||
IAccountPermissions,
|
|
||||||
} from "@thirdweb-dev/contracts-js";
|
|
||||||
import {
|
import {
|
||||||
SignedSignerPermissionsPayload,
|
FEATURE_ACCOUNT,
|
||||||
SignerPermissionsOutput,
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
|
} from "../../constants/thirdweb-features";
|
||||||
|
|
||||||
|
import type { IAccountCore } from "@thirdweb-dev/contracts-js";
|
||||||
|
import {
|
||||||
SignerWithPermissions,
|
SignerWithPermissions,
|
||||||
SignerPermissions,
|
|
||||||
SignerPermissionsInput,
|
SignerPermissionsInput,
|
||||||
SignerPermissionRequest,
|
|
||||||
SignerPermissionsSchema,
|
|
||||||
PermissionSnapshotInput,
|
PermissionSnapshotInput,
|
||||||
PermissionSnapshotSchema,
|
|
||||||
PermissionSnapshotOutput,
|
|
||||||
} from "../../types";
|
} from "../../types";
|
||||||
import invariant from "tiny-invariant";
|
|
||||||
import { buildTransactionFunction } from "../../common/transactions";
|
|
||||||
import { resolveOrGenerateId } from "../../common/signature-minting";
|
|
||||||
import { AddressOrEns } from "../../schema";
|
import { AddressOrEns } from "../../schema";
|
||||||
import { resolveAddress } from "../../common";
|
import { assertEnabled, detectContractFeature } from "../../common";
|
||||||
|
import { AccountPermissions } from "./account-permissions";
|
||||||
|
|
||||||
export class Account<TContract extends IAccountCore>
|
export class Account<TContract extends IAccountCore>
|
||||||
implements DetectableFeature
|
implements DetectableFeature
|
||||||
{
|
{
|
||||||
featureName = FEATURE_ACCOUNT.name;
|
featureName = FEATURE_ACCOUNT.name;
|
||||||
private contractWrapper: ContractWrapper<IAccountCore>;
|
private contractWrapper: ContractWrapper<IAccountCore>;
|
||||||
|
private accountPermissions: AccountPermissions | undefined;
|
||||||
|
|
||||||
constructor(contractWrapper: ContractWrapper<TContract>) {
|
constructor(contractWrapper: ContractWrapper<TContract>) {
|
||||||
this.contractWrapper = contractWrapper;
|
this.contractWrapper = contractWrapper;
|
||||||
|
this.accountPermissions = this.detectAccountPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private detectAccountPermissions(): AccountPermissions | undefined {
|
||||||
|
if (
|
||||||
|
detectContractFeature<IAccountCore>(
|
||||||
|
this.contractWrapper,
|
||||||
|
"AccountPermissions",
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return new AccountPermissions(this.contractWrapper);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAddress(): string {
|
getAddress(): string {
|
||||||
return this.contractWrapper.readContract.address;
|
return this.contractWrapper.readContract.address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* HELPER FUNCTIONS
|
|
||||||
********************************/
|
|
||||||
|
|
||||||
private hasDuplicateSigners(snapshot: PermissionSnapshotOutput): boolean {
|
|
||||||
const checkedSigner: Record<string, boolean> = {};
|
|
||||||
|
|
||||||
const signers = snapshot.map((item) => item.signer);
|
|
||||||
|
|
||||||
for (const signer of signers) {
|
|
||||||
if (!checkedSigner[signer]) {
|
|
||||||
checkedSigner[signer] = true;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format the access restrictions for a given role
|
|
||||||
*
|
|
||||||
* @param restrictions - The access restrictions for a given role
|
|
||||||
* @returns formatted role restrictions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private parseSignerPermissionsStruct(
|
|
||||||
permissions: IAccountPermissions.SignerPermissionsStruct,
|
|
||||||
): SignerPermissions {
|
|
||||||
return {
|
|
||||||
startDate: new Date(
|
|
||||||
parseInt(permissions.startTimestamp.toString()) * 1000,
|
|
||||||
),
|
|
||||||
expirationDate: new Date(
|
|
||||||
parseInt(permissions.endTimestamp.toString()) * 1000,
|
|
||||||
),
|
|
||||||
nativeTokenLimitPerTransaction: BigNumber.from(
|
|
||||||
permissions.nativeTokenLimitPerTransaction,
|
|
||||||
),
|
|
||||||
approvedCallTargets: permissions.approvedTargets,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async sendSignerPermissionRequest(
|
|
||||||
signerAddress: string,
|
|
||||||
permissions: SignerPermissionsOutput,
|
|
||||||
): Promise<Transaction> {
|
|
||||||
const { payload, signature } = await this.generatePayload(
|
|
||||||
signerAddress,
|
|
||||||
permissions,
|
|
||||||
);
|
|
||||||
|
|
||||||
const { success } =
|
|
||||||
await this.contractWrapper.readContract.verifySignerPermissionRequest(
|
|
||||||
payload,
|
|
||||||
signature,
|
|
||||||
);
|
|
||||||
if (!success) {
|
|
||||||
throw new Error(`Invalid signature.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Transaction.fromContractWrapper({
|
|
||||||
contractWrapper: this.contractWrapper,
|
|
||||||
method: "setPermissionsForSigner",
|
|
||||||
args: [payload, signature],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async buildSignerPermissionRequest(
|
|
||||||
signerAddress: string,
|
|
||||||
permissions: SignerPermissionsOutput,
|
|
||||||
): Promise<string> {
|
|
||||||
const { payload, signature } = await this.generatePayload(
|
|
||||||
signerAddress,
|
|
||||||
permissions,
|
|
||||||
);
|
|
||||||
|
|
||||||
const isValidSigner =
|
|
||||||
await this.contractWrapper.readContract.verifySignerPermissionRequest(
|
|
||||||
payload,
|
|
||||||
signature,
|
|
||||||
);
|
|
||||||
if (!isValidSigner) {
|
|
||||||
throw new Error(`Invalid signature.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.contractWrapper.writeContract.interface.encodeFunctionData(
|
|
||||||
"setPermissionsForSigner",
|
|
||||||
[payload, signature],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate and sign a payload to grant or revoke a signer's access to the account.
|
|
||||||
*
|
|
||||||
* @param signer - The address of the signer
|
|
||||||
* @param roleAction - The address of the signer
|
|
||||||
* @returns The generated payload and signature produced on signing that payload.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private async generatePayload(
|
|
||||||
signerAddress: string,
|
|
||||||
permissions: SignerPermissionsOutput,
|
|
||||||
): Promise<SignedSignerPermissionsPayload> {
|
|
||||||
// Get payload struct.
|
|
||||||
const payload: IAccountPermissions.SignerPermissionRequestStruct = {
|
|
||||||
signer: signerAddress,
|
|
||||||
approvedTargets: permissions.approvedCallTargets,
|
|
||||||
nativeTokenLimitPerTransaction: utils.parseEther(
|
|
||||||
permissions.nativeTokenLimitPerTransaction,
|
|
||||||
),
|
|
||||||
permissionStartTimestamp: permissions.startDate,
|
|
||||||
permissionEndTimestamp: permissions.expirationDate,
|
|
||||||
reqValidityStartTimestamp: 0,
|
|
||||||
// Req validity ends 10 years from now.
|
|
||||||
reqValidityEndTimestamp: BigNumber.from(
|
|
||||||
Math.floor(
|
|
||||||
new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 10).getTime() /
|
|
||||||
1000,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
uid: resolveOrGenerateId(undefined),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Generate signature
|
|
||||||
const chainId = await this.contractWrapper.getChainID();
|
|
||||||
const connectedSigner = this.contractWrapper.getSigner();
|
|
||||||
invariant(connectedSigner, "No signer available");
|
|
||||||
|
|
||||||
const signature = await this.contractWrapper.signTypedData(
|
|
||||||
connectedSigner,
|
|
||||||
{
|
|
||||||
name: "Account",
|
|
||||||
version: "1",
|
|
||||||
chainId,
|
|
||||||
verifyingContract: this.getAddress(),
|
|
||||||
},
|
|
||||||
{ SignerPermissionRequest },
|
|
||||||
payload,
|
|
||||||
);
|
|
||||||
|
|
||||||
return { payload, signature };
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* READ FUNCTIONS
|
* READ FUNCTIONS
|
||||||
********************************/
|
********************************/
|
||||||
@@ -199,13 +57,13 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* @param signer - The address of a signer of the account.
|
* @param signer - The address of a signer of the account.
|
||||||
* @returns whether a signer is an admin on the account.
|
* @returns whether a signer is an admin on the account.
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
public async isAdmin(signerAddress: AddressOrEns): Promise<boolean> {
|
public async isAdmin(signerAddress: AddressOrEns): Promise<boolean> {
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
return assertEnabled(
|
||||||
return await this.contractWrapper.readContract.isAdmin(
|
this.accountPermissions,
|
||||||
resolvedSignerAddress,
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
);
|
).isAdmin(signerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,13 +76,13 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* @param signer - The address of a signer of the account.
|
* @param signer - The address of a signer of the account.
|
||||||
* @returns whether a signer has permissions to use the account.
|
* @returns whether a signer has permissions to use the account.
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
public async isSigner(signerAddress: AddressOrEns): Promise<boolean> {
|
public async isSigner(signerAddress: AddressOrEns): Promise<boolean> {
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
return assertEnabled(
|
||||||
return await this.contractWrapper.readContract.isActiveSigner(
|
this.accountPermissions,
|
||||||
resolvedSignerAddress,
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
);
|
).isSigner(signerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,10 +95,13 @@ export class Account<TContract extends IAccountCore>
|
|||||||
*
|
*
|
||||||
* @returns all admins of the account.
|
* @returns all admins of the account.
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
public async getAllAdmins(): Promise<string[]> {
|
public async getAllAdmins(): Promise<string[]> {
|
||||||
return await this.contractWrapper.readContract.getAllAdmins();
|
return assertEnabled(
|
||||||
|
this.accountPermissions,
|
||||||
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
|
).getAllAdmins();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,21 +114,13 @@ export class Account<TContract extends IAccountCore>
|
|||||||
*
|
*
|
||||||
* @returns all (non-admin) signers with permissions to use the account.
|
* @returns all (non-admin) signers with permissions to use the account.
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
public async getAllSigners(): Promise<SignerWithPermissions[]> {
|
public async getAllSigners(): Promise<SignerWithPermissions[]> {
|
||||||
const activeSignersWithPerms: IAccountPermissions.SignerPermissionsStruct[] =
|
return assertEnabled(
|
||||||
await this.contractWrapper.readContract.getAllActiveSigners();
|
this.accountPermissions,
|
||||||
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
return await Promise.all(
|
).getAllSigners();
|
||||||
activeSignersWithPerms.map(async (signerWithPermissions) => {
|
|
||||||
const signer = signerWithPermissions.signer;
|
|
||||||
const permissions = this.parseSignerPermissionsStruct(
|
|
||||||
signerWithPermissions,
|
|
||||||
);
|
|
||||||
return { signer, permissions };
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,27 +133,13 @@ export class Account<TContract extends IAccountCore>
|
|||||||
*
|
*
|
||||||
* @returns all admins and non-admin signers with permissions to use the account.
|
* @returns all admins and non-admin signers with permissions to use the account.
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
public async getAllAdminsAndSigners(): Promise<SignerWithPermissions[]> {
|
public async getAllAdminsAndSigners(): Promise<SignerWithPermissions[]> {
|
||||||
const allAdmins = await this.getAllAdmins();
|
return assertEnabled(
|
||||||
const transformedAdmins: SignerWithPermissions[] = allAdmins.map(
|
this.accountPermissions,
|
||||||
(admin) => {
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
return {
|
).getAllAdminsAndSigners();
|
||||||
isAdmin: true,
|
|
||||||
signer: admin,
|
|
||||||
permissions: {
|
|
||||||
startDate: new Date(0),
|
|
||||||
expirationDate: new Date(0),
|
|
||||||
nativeTokenLimitPerTransaction: BigNumber.from(0),
|
|
||||||
approvedCallTargets: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const allSigners = await this.getAllSigners();
|
|
||||||
|
|
||||||
return [...transformedAdmins, ...allSigners];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
@@ -320,18 +159,14 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
grantAdminPermissions = /* @__PURE__ */ buildTransactionFunction(
|
public async grantAdminPermissions(signerAddress: AddressOrEns) {
|
||||||
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
return Transaction.fromContractWrapper({
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
contractWrapper: this.contractWrapper,
|
).grantAdminPermissions(signerAddress);
|
||||||
method: "setAdmin",
|
}
|
||||||
args: [resolvedSignerAddress, true],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revoke an address' admin access to the account.
|
* Revoke an address' admin access to the account.
|
||||||
@@ -346,18 +181,14 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
revokeAdminPermissions = /* @__PURE__ */ buildTransactionFunction(
|
public async revokeAdminPermissions(signerAddress: AddressOrEns) {
|
||||||
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
return Transaction.fromContractWrapper({
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
contractWrapper: this.contractWrapper,
|
).revokeAdminPermissions(signerAddress);
|
||||||
method: "setAdmin",
|
}
|
||||||
args: [resolvedSignerAddress, false],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grant a signer permissions to use the account.
|
* Grant a signer permissions to use the account.
|
||||||
@@ -373,36 +204,17 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
grantPermissions = /* @__PURE__ */ buildTransactionFunction(
|
public async grantPermissions(
|
||||||
async (
|
signerAddress: AddressOrEns,
|
||||||
signerAddress: AddressOrEns,
|
permissions: SignerPermissionsInput,
|
||||||
permissions: SignerPermissionsInput,
|
) {
|
||||||
): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
const resolvedPermissions = await SignerPermissionsSchema.parseAsync(
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
permissions,
|
).grantPermissions(signerAddress, permissions);
|
||||||
);
|
}
|
||||||
|
|
||||||
if (await this.isAdmin(resolvedSignerAddress)) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer is already an admin. Cannot grant permissions to an existing admin.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await this.isSigner(resolvedSignerAddress)) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer already has permissions. Cannot grant permissions to an existing signer. You can update permissions using `updatePermissions`.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.sendSignerPermissionRequest(
|
|
||||||
resolvedSignerAddress,
|
|
||||||
resolvedPermissions,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the permissions of a signer for using the account.
|
* Update the permissions of a signer for using the account.
|
||||||
@@ -418,36 +230,17 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
updatePermissions = /* @__PURE__ */ buildTransactionFunction(
|
public async updatePermissions(
|
||||||
async (
|
signerAddress: AddressOrEns,
|
||||||
signerAddress: AddressOrEns,
|
permissions: SignerPermissionsInput,
|
||||||
permissions: SignerPermissionsInput,
|
) {
|
||||||
): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
const resolvedPermissions = await SignerPermissionsSchema.parseAsync(
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
permissions,
|
).updatePermissions(signerAddress, permissions);
|
||||||
);
|
}
|
||||||
|
|
||||||
if (await this.isAdmin(resolvedSignerAddress)) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer is already an admin. Cannot update permissions of an existing admin.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(await this.isSigner(resolvedSignerAddress))) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.sendSignerPermissionRequest(
|
|
||||||
resolvedSignerAddress,
|
|
||||||
resolvedPermissions,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revoke a scoped access address to the account
|
* Revoke a scoped access address to the account
|
||||||
@@ -462,32 +255,14 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
revokeAccess = /* @__PURE__ */ buildTransactionFunction(
|
public async revokeAccess(signerAddress: AddressOrEns) {
|
||||||
async (signerAddress: AddressOrEns): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
if (await this.isAdmin(resolvedSignerAddress)) {
|
).revokeAccess(signerAddress);
|
||||||
throw new Error(
|
}
|
||||||
"Signer is already an admin. Cannot revoke permissions of an admin.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(await this.isSigner(resolvedSignerAddress))) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
|
||||||
startDate: BigNumber.from(0),
|
|
||||||
expirationDate: BigNumber.from(0),
|
|
||||||
approvedCallTargets: [],
|
|
||||||
nativeTokenLimitPerTransaction: "0",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approve an address as a call target for a given signer on the account
|
* Approve an address as a call target for a given signer on the account
|
||||||
@@ -503,48 +278,17 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
approveTargetForSigner = /* @__PURE__ */ buildTransactionFunction(
|
public async approveTargetForSigner(
|
||||||
async (
|
signerAddress: AddressOrEns,
|
||||||
signerAddress: AddressOrEns,
|
target: AddressOrEns,
|
||||||
target: AddressOrEns,
|
) {
|
||||||
): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
const resolvedTarget = await resolveAddress(target);
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
|
).approveTargetForSigner(signerAddress, target);
|
||||||
if (await this.isAdmin(resolvedSignerAddress)) {
|
}
|
||||||
throw new Error(
|
|
||||||
"Signer is already an admin. Cannot approve targets for an admin.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(await this.isSigner(resolvedSignerAddress))) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const permissions: IAccountPermissions.SignerPermissionsStruct =
|
|
||||||
await this.contractWrapper.readContract.getPermissionsForSigner(
|
|
||||||
resolvedSignerAddress,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (permissions.approvedTargets.includes(target)) {
|
|
||||||
throw new Error("Target is already approved");
|
|
||||||
}
|
|
||||||
|
|
||||||
const newTargets = [...permissions.approvedTargets, resolvedTarget];
|
|
||||||
|
|
||||||
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
|
||||||
startDate: BigNumber.from(permissions.startTimestamp),
|
|
||||||
expirationDate: BigNumber.from(permissions.endTimestamp),
|
|
||||||
approvedCallTargets: newTargets,
|
|
||||||
nativeTokenLimitPerTransaction:
|
|
||||||
permissions.nativeTokenLimitPerTransaction.toString(),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disapprove an address as a call target for a given signer on the account
|
* Disapprove an address as a call target for a given signer on the account
|
||||||
@@ -560,51 +304,17 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
disapproveTargetForSigner = /* @__PURE__ */ buildTransactionFunction(
|
public async disapproveTargetForSigner(
|
||||||
async (
|
signerAddress: AddressOrEns,
|
||||||
signerAddress: AddressOrEns,
|
target: AddressOrEns,
|
||||||
target: AddressOrEns,
|
) {
|
||||||
): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSignerAddress = await resolveAddress(signerAddress);
|
this.accountPermissions,
|
||||||
const resolvedTarget = await resolveAddress(target);
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
|
).disapproveTargetForSigner(signerAddress, target);
|
||||||
if (await this.isAdmin(resolvedSignerAddress)) {
|
}
|
||||||
throw new Error(
|
|
||||||
"Signer is already an admin. Cannot approve targets for an admin.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(await this.isSigner(resolvedSignerAddress))) {
|
|
||||||
throw new Error(
|
|
||||||
"Signer does not already have permissions. You can grant permissions using `grantPermissions`.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const permissions: IAccountPermissions.SignerPermissionsStruct =
|
|
||||||
await this.contractWrapper.readContract.getPermissionsForSigner(
|
|
||||||
resolvedSignerAddress,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!permissions.approvedTargets.includes(resolvedTarget)) {
|
|
||||||
throw new Error("Target is currently not approved");
|
|
||||||
}
|
|
||||||
|
|
||||||
const newTargets = permissions.approvedTargets.filter(
|
|
||||||
(approvedTarget) =>
|
|
||||||
utils.getAddress(approvedTarget) !== utils.getAddress(resolvedTarget),
|
|
||||||
);
|
|
||||||
|
|
||||||
return await this.sendSignerPermissionRequest(resolvedSignerAddress, {
|
|
||||||
startDate: BigNumber.from(permissions.startTimestamp),
|
|
||||||
expirationDate: BigNumber.from(permissions.endTimestamp),
|
|
||||||
approvedCallTargets: newTargets,
|
|
||||||
nativeTokenLimitPerTransaction:
|
|
||||||
permissions.nativeTokenLimitPerTransaction.toString(),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the account's entire snapshot of permissions.
|
* Set the account's entire snapshot of permissions.
|
||||||
@@ -619,111 +329,14 @@ export class Account<TContract extends IAccountCore>
|
|||||||
* const receipt = tx.receipt();
|
* const receipt = tx.receipt();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @twfeature Account
|
* @twfeature AccountPermissions
|
||||||
*/
|
*/
|
||||||
resetAllPermissions = /* @__PURE__ */ buildTransactionFunction(
|
public async resetAllPermissions(
|
||||||
async (
|
permissionSnapshot: PermissionSnapshotInput,
|
||||||
permissionSnapshot: PermissionSnapshotInput,
|
) {
|
||||||
): Promise<Transaction> => {
|
return assertEnabled(
|
||||||
const resolvedSnapshot = await PermissionSnapshotSchema.parseAsync(
|
this.accountPermissions,
|
||||||
permissionSnapshot,
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
);
|
).resetAllPermissions(permissionSnapshot);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* All cases
|
|
||||||
*
|
|
||||||
* - Add new admin :check:
|
|
||||||
* - Remove current admin :check:
|
|
||||||
* - Add new scoped :check:
|
|
||||||
* - Remove current scoped :check:
|
|
||||||
* - Update current scoped :check:
|
|
||||||
* - Current admin -> new scoped :check:
|
|
||||||
* - Current scoped -> new admin :check:
|
|
||||||
**/
|
|
||||||
|
|
||||||
// No duplicate signers in input!
|
|
||||||
if (this.hasDuplicateSigners(resolvedSnapshot)) {
|
|
||||||
throw new Error("Duplicate signers found in input.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const addAdminData: string[] = [];
|
|
||||||
const removeAdminData: string[] = [];
|
|
||||||
const addOrUpdateSignerData: string[] = [];
|
|
||||||
const removeSignerData: string[] = [];
|
|
||||||
|
|
||||||
// Remove all existing admins not included in the passed snapshot.
|
|
||||||
const allAdmins = await this.getAllAdmins();
|
|
||||||
const allToMakeAdmin = resolvedSnapshot
|
|
||||||
.filter((item) => item.makeAdmin)
|
|
||||||
.map((item) => item.signer);
|
|
||||||
allAdmins.forEach((admin) => {
|
|
||||||
if (!allToMakeAdmin.includes(admin)) {
|
|
||||||
removeAdminData.push(
|
|
||||||
this.contractWrapper.writeContract.interface.encodeFunctionData(
|
|
||||||
"setAdmin",
|
|
||||||
[admin, false],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove all existing signers not included in the passed snapshot.
|
|
||||||
const allSigners = await this.getAllSigners();
|
|
||||||
const allToMakeSigners = resolvedSnapshot
|
|
||||||
.filter((item) => {
|
|
||||||
return !item.makeAdmin;
|
|
||||||
})
|
|
||||||
.map((item) => item.signer);
|
|
||||||
await Promise.all(
|
|
||||||
allSigners.map(async (item) => {
|
|
||||||
if (!allToMakeSigners.includes(item.signer)) {
|
|
||||||
const data = await this.buildSignerPermissionRequest(item.signer, {
|
|
||||||
startDate: BigNumber.from(0),
|
|
||||||
expirationDate: BigNumber.from(0),
|
|
||||||
approvedCallTargets: [],
|
|
||||||
nativeTokenLimitPerTransaction: "0",
|
|
||||||
});
|
|
||||||
|
|
||||||
removeSignerData.push(data);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const member of resolvedSnapshot) {
|
|
||||||
// Add new admin
|
|
||||||
if (member.makeAdmin) {
|
|
||||||
addAdminData.push(
|
|
||||||
this.contractWrapper.writeContract.interface.encodeFunctionData(
|
|
||||||
"setAdmin",
|
|
||||||
[member.signer, true],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Add new scoped
|
|
||||||
const data = await this.buildSignerPermissionRequest(
|
|
||||||
member.signer,
|
|
||||||
member.permissions,
|
|
||||||
);
|
|
||||||
addOrUpdateSignerData.push(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const data: string[] = [];
|
|
||||||
removeAdminData.forEach((item) => {
|
|
||||||
data.push(item);
|
|
||||||
});
|
|
||||||
removeSignerData.forEach((item) => {
|
|
||||||
data.push(item);
|
|
||||||
});
|
|
||||||
addOrUpdateSignerData.forEach((item) => {
|
|
||||||
data.push(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Transaction.fromContractWrapper({
|
|
||||||
contractWrapper: this.contractWrapper,
|
|
||||||
method: "multicall",
|
|
||||||
args: [data],
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user