Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f202f597ca | ||
|
|
91f0245be7 | ||
|
|
ae74b8ef62 | ||
|
|
5a373a7509 | ||
|
|
088547f763 | ||
|
|
586e91dbe6 | ||
|
|
f65578d637 | ||
|
|
447d984653 | ||
|
|
34a3bb8ae3 | ||
|
|
bc003c2fef | ||
|
|
c88fa57591 | ||
|
|
c12f0874b4 | ||
|
|
184c325ab2 | ||
|
|
046c9ad604 |
@@ -1,5 +1,19 @@
|
|||||||
# @thirdweb-dev/auth
|
# @thirdweb-dev/auth
|
||||||
|
|
||||||
|
## 3.2.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @thirdweb-dev/wallets@1.1.19
|
||||||
|
|
||||||
|
## 3.2.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @thirdweb-dev/wallets@1.1.18
|
||||||
|
|
||||||
## 3.2.34
|
## 3.2.34
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/auth",
|
"name": "@thirdweb-dev/auth",
|
||||||
"version": "3.2.34",
|
"version": "3.2.36",
|
||||||
"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,19 @@
|
|||||||
# @thirdweb-dev/chains
|
# @thirdweb-dev/chains
|
||||||
|
|
||||||
|
## 0.1.47
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
|
||||||
|
|
||||||
|
## 0.1.46
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1508](https://github.com/thirdweb-dev/js/pull/1508) [`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f) Thanks [@jnsdls](https://github.com/jnsdls)! - update xpla chain icons
|
||||||
|
|
||||||
|
- [#1513](https://github.com/thirdweb-dev/js/pull/1513) [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34) Thanks [@jnsdls](https://github.com/jnsdls)! - add additonal chains
|
||||||
|
|
||||||
## 0.1.45
|
## 0.1.45
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Ancient8 Testnet",
|
||||||
|
"chain": "Ancient8",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmSX8sHToRzyFupT8BvPQjVsegRWFYz2mdnLkVnqBFKohY",
|
||||||
|
"width": 901,
|
||||||
|
"height": 901,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://ancient8-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc-testnet.ancient8.gg"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Ether",
|
||||||
|
"symbol": "ETH",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://ancient8.gg/",
|
||||||
|
"shortName": "a8",
|
||||||
|
"chainId": 2863311531,
|
||||||
|
"networkId": 2863311531,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "a8scan-testnet",
|
||||||
|
"url": "https://testnet.a8scan.io",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "ancient8-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -5,6 +5,12 @@ export default {
|
|||||||
"shortName": "POPTestnet",
|
"shortName": "POPTestnet",
|
||||||
"chainId": 331769,
|
"chainId": 331769,
|
||||||
"testnet": true,
|
"testnet": true,
|
||||||
|
"icon": {
|
||||||
|
"format": "png",
|
||||||
|
"url": "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
|
||||||
|
"height": 400,
|
||||||
|
"width": 400
|
||||||
|
},
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://proofofpepe-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://proofofpepe-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://testnet01.proofofpepe.tech"
|
"https://testnet01.proofofpepe.tech"
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "POP Mainnet",
|
||||||
|
"chain": "POP",
|
||||||
|
"shortName": "POP",
|
||||||
|
"chainId": 331771,
|
||||||
|
"testnet": false,
|
||||||
|
"icon": {
|
||||||
|
"format": "png",
|
||||||
|
"url": "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
|
||||||
|
"height": 400,
|
||||||
|
"width": 400
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://pop.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc00.proofofpepe.tech",
|
||||||
|
"https://rpc01.proofofpepe.tech",
|
||||||
|
"https://rpc02.proofofpepe.tech"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Pepe",
|
||||||
|
"symbol": "PEPE",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Pepescan",
|
||||||
|
"url": "https://pepescan.app",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"slug": "pop"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -15,7 +15,7 @@ export default {
|
|||||||
"shortName": "xpla",
|
"shortName": "xpla",
|
||||||
"chainId": 37,
|
"chainId": 37,
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://Qmf4GoxfpeA5VGqu7KP5eyv1WKaCpNDbvMxq1MjQBwFWxq",
|
"url": "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
@@ -28,5 +28,8 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
|
"redFlags": [
|
||||||
|
"reusedChainId"
|
||||||
|
],
|
||||||
"slug": "xpla"
|
"slug": "xpla"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -18,7 +18,7 @@ export default {
|
|||||||
"shortName": "xpla-test",
|
"shortName": "xpla-test",
|
||||||
"chainId": 47,
|
"chainId": 47,
|
||||||
"icon": {
|
"icon": {
|
||||||
"url": "ipfs://Qmf4GoxfpeA5VGqu7KP5eyv1WKaCpNDbvMxq1MjQBwFWxq",
|
"url": "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"format": "png"
|
"format": "png"
|
||||||
@@ -31,5 +31,8 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testnet": true,
|
"testnet": true,
|
||||||
|
"redFlags": [
|
||||||
|
"reusedChainId"
|
||||||
|
],
|
||||||
"slug": "xpla-testnet"
|
"slug": "xpla-testnet"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Worlds Appchain",
|
||||||
|
"chain": "WRLDS",
|
||||||
|
"shortName": "WRLDS",
|
||||||
|
"chainId": 91003,
|
||||||
|
"testnet": true,
|
||||||
|
"rpc": [
|
||||||
|
"https://worlds-appchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://api.evm.worlds.dev.eclipsenetwork.xyz/"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "WRLDS",
|
||||||
|
"symbol": "WRLDS",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.evm.worlds.dev.eclipsenetwork.xyz/request_neon"
|
||||||
|
],
|
||||||
|
"slug": "worlds-appchain"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -8,6 +8,12 @@ export default {
|
|||||||
shortName: "POPTestnet",
|
shortName: "POPTestnet",
|
||||||
chainId: 331769,
|
chainId: 331769,
|
||||||
testnet: true,
|
testnet: true,
|
||||||
|
icon: {
|
||||||
|
format: "png",
|
||||||
|
url: "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
|
||||||
|
height: 400,
|
||||||
|
width: 400,
|
||||||
|
},
|
||||||
rpc: ["https://testnet01.proofofpepe.tech"],
|
rpc: ["https://testnet01.proofofpepe.tech"],
|
||||||
nativeCurrency: {
|
nativeCurrency: {
|
||||||
name: "POP",
|
name: "POP",
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Omit<Chain, "slug">} */
|
||||||
|
export default {
|
||||||
|
name: "POP Mainnet",
|
||||||
|
chain: "POP",
|
||||||
|
shortName: "POP",
|
||||||
|
chainId: 331771,
|
||||||
|
testnet: false,
|
||||||
|
icon: {
|
||||||
|
format: "png",
|
||||||
|
url: "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
|
||||||
|
height: 400,
|
||||||
|
width: 400,
|
||||||
|
},
|
||||||
|
rpc: [
|
||||||
|
"https://rpc00.proofofpepe.tech",
|
||||||
|
"https://rpc01.proofofpepe.tech",
|
||||||
|
"https://rpc02.proofofpepe.tech",
|
||||||
|
],
|
||||||
|
nativeCurrency: {
|
||||||
|
name: "Pepe",
|
||||||
|
symbol: "PEPE",
|
||||||
|
decimals: 18,
|
||||||
|
},
|
||||||
|
explorers: [
|
||||||
|
{ name: "Pepescan", url: "https://pepescan.app", standard: "none" },
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -15,7 +15,7 @@ export default {
|
|||||||
shortName: "xpla",
|
shortName: "xpla",
|
||||||
chainId: 37,
|
chainId: 37,
|
||||||
icon: {
|
icon: {
|
||||||
url: "ipfs://Qmf4GoxfpeA5VGqu7KP5eyv1WKaCpNDbvMxq1MjQBwFWxq",
|
url: "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
|
||||||
width: 512,
|
width: 512,
|
||||||
height: 512,
|
height: 512,
|
||||||
format: "png",
|
format: "png",
|
||||||
@@ -28,4 +28,5 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
testnet: false,
|
testnet: false,
|
||||||
|
redFlags: ["reusedChainId"],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default {
|
|||||||
shortName: "xpla-test",
|
shortName: "xpla-test",
|
||||||
chainId: 47,
|
chainId: 47,
|
||||||
icon: {
|
icon: {
|
||||||
url: "ipfs://Qmf4GoxfpeA5VGqu7KP5eyv1WKaCpNDbvMxq1MjQBwFWxq",
|
url: "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
|
||||||
width: 512,
|
width: 512,
|
||||||
height: 512,
|
height: 512,
|
||||||
format: "png",
|
format: "png",
|
||||||
@@ -29,4 +29,5 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
testnet: true,
|
testnet: true,
|
||||||
|
redFlags: ["reusedChainId"],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Omit<Chain, "slug">} */
|
||||||
|
export default {
|
||||||
|
name: "Worlds Appchain",
|
||||||
|
chain: "WRLDS",
|
||||||
|
shortName: "WRLDS",
|
||||||
|
chainId: 91003,
|
||||||
|
testnet: true,
|
||||||
|
rpc: ["https://api.evm.worlds.dev.eclipsenetwork.xyz/"],
|
||||||
|
nativeCurrency: {
|
||||||
|
name: "WRLDS",
|
||||||
|
symbol: "WRLDS",
|
||||||
|
decimals: 18,
|
||||||
|
},
|
||||||
|
faucets: ["https://faucet.evm.worlds.dev.eclipsenetwork.xyz/request_neon"],
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/chains",
|
"name": "@thirdweb-dev/chains",
|
||||||
"version": "0.1.45",
|
"version": "0.1.47",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ ${exports.join("\n")}
|
|||||||
export * from "./types";
|
export * from "./types";
|
||||||
export * from "./utils";
|
export * from "./utils";
|
||||||
export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c421613, c10, c420, c56, c97, c250, c4002, c43114, c43113, c1337];
|
export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c421613, c10, c420, c56, c97, c250, c4002, c43114, c43113, c1337];
|
||||||
|
// @ts-expect-error - TODO: fix this later
|
||||||
export const allChains: Chain[] = [${exportNames.join(", ")}];
|
export const allChains: Chain[] = [${exportNames.join(", ")}];
|
||||||
|
|
||||||
type ChainsById = {
|
type ChainsById = {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,23 @@
|
|||||||
# thirdweb
|
# thirdweb
|
||||||
|
|
||||||
|
## 0.11.19
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.55
|
||||||
|
- @thirdweb-dev/chains@0.1.47
|
||||||
|
- @thirdweb-dev/storage@1.2.8
|
||||||
|
|
||||||
|
## 0.11.18
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.46
|
||||||
|
- @thirdweb-dev/storage@1.2.7
|
||||||
|
- @thirdweb-dev/sdk@3.10.54
|
||||||
|
|
||||||
## 0.11.17
|
## 0.11.17
|
||||||
|
|
||||||
### 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.17",
|
"version": "0.11.19",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @thirdweb-dev/contracts-js
|
# @thirdweb-dev/contracts-js
|
||||||
|
|
||||||
|
## 1.3.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
|
||||||
|
|
||||||
## 1.3.11
|
## 1.3.11
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/contracts-js",
|
"name": "@thirdweb-dev/contracts-js",
|
||||||
"version": "1.3.11",
|
"version": "1.3.12",
|
||||||
"main": "dist/thirdweb-dev-contracts-js.cjs.js",
|
"main": "dist/thirdweb-dev-contracts-js.cjs.js",
|
||||||
"module": "dist/thirdweb-dev-contracts-js.esm.js",
|
"module": "dist/thirdweb-dev-contracts-js.esm.js",
|
||||||
"browser": {
|
"browser": {
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thirdweb-dev/contracts": "3.8.3"
|
"@thirdweb-dev/contracts": "3.8.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-env": "^7.22.9",
|
"@babel/preset-env": "^7.22.9",
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
# @thirdweb-dev/react-core
|
# @thirdweb-dev/react-core
|
||||||
|
|
||||||
|
## 3.14.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1522](https://github.com/thirdweb-dev/js/pull/1522) [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0) Thanks [@MananTank](https://github.com/MananTank)! - - New prop `switchToActiveChain` added to `ConnectWallet`` component to show "Switch Network" button if wallet is not connected to the `activeChain`passed to the`ThirdwebProvider`
|
||||||
|
- Add max-height on `ConnectWallet` modal
|
||||||
|
- Local Wallet UI adjustments
|
||||||
|
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.55
|
||||||
|
- @thirdweb-dev/chains@0.1.47
|
||||||
|
- @thirdweb-dev/storage@1.2.8
|
||||||
|
- @thirdweb-dev/wallets@1.1.19
|
||||||
|
- @thirdweb-dev/auth@3.2.36
|
||||||
|
|
||||||
|
## 3.14.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.46
|
||||||
|
- @thirdweb-dev/storage@1.2.7
|
||||||
|
- @thirdweb-dev/sdk@3.10.54
|
||||||
|
- @thirdweb-dev/wallets@1.1.18
|
||||||
|
- @thirdweb-dev/auth@3.2.35
|
||||||
|
|
||||||
## 3.14.34
|
## 3.14.34
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-core",
|
"name": "@thirdweb-dev/react-core",
|
||||||
"version": "3.14.34",
|
"version": "3.14.36",
|
||||||
"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",
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^4.32.0",
|
"@tanstack/react-query": "^4.33.0",
|
||||||
"@thirdweb-dev/chains": "workspace:*",
|
"@thirdweb-dev/chains": "workspace:*",
|
||||||
"@thirdweb-dev/generated-abis": "workspace:^",
|
"@thirdweb-dev/generated-abis": "workspace:^",
|
||||||
"@thirdweb-dev/sdk": "workspace:*",
|
"@thirdweb-dev/sdk": "workspace:*",
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ export const ThirdwebProviderCore = <TChains extends Chain[]>({
|
|||||||
autoSwitch={props.autoSwitch}
|
autoSwitch={props.autoSwitch}
|
||||||
autoConnectTimeout={props.autoConnectTimeout}
|
autoConnectTimeout={props.autoConnectTimeout}
|
||||||
clientId={props.clientId}
|
clientId={props.clientId}
|
||||||
|
activeChainSetExplicitly={!!props.activeChain}
|
||||||
>
|
>
|
||||||
<ThirdwebSDKProviderWrapper
|
<ThirdwebSDKProviderWrapper
|
||||||
queryClient={props.queryClient}
|
queryClient={props.queryClient}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ type ThirdwebWalletContextData = {
|
|||||||
* Get wallet config object from wallet instance
|
* Get wallet config object from wallet instance
|
||||||
*/
|
*/
|
||||||
getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined;
|
getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined;
|
||||||
|
activeChainSetExplicitly: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThirdwebWalletContext = /* @__PURE__ */ createContext<
|
const ThirdwebWalletContext = /* @__PURE__ */ createContext<
|
||||||
@@ -106,6 +107,7 @@ export function ThirdwebWalletProvider(
|
|||||||
autoSwitch?: boolean;
|
autoSwitch?: boolean;
|
||||||
autoConnectTimeout?: number;
|
autoConnectTimeout?: number;
|
||||||
clientId?: string;
|
clientId?: string;
|
||||||
|
activeChainSetExplicitly: boolean;
|
||||||
}>,
|
}>,
|
||||||
) {
|
) {
|
||||||
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
||||||
@@ -480,6 +482,7 @@ export function ThirdwebWalletProvider(
|
|||||||
getWalletConfig: (walletInstance: WalletInstance) => {
|
getWalletConfig: (walletInstance: WalletInstance) => {
|
||||||
return walletInstanceToConfig.get(walletInstance);
|
return walletInstanceToConfig.get(walletInstance);
|
||||||
},
|
},
|
||||||
|
activeChainSetExplicitly: props.activeChainSetExplicitly,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import { getCachedAbiForContract, TransactionResult } from "@thirdweb-dev/sdk";
|
import { getCachedAbiForContract, TransactionResult } from "@thirdweb-dev/sdk";
|
||||||
import type {
|
import type {
|
||||||
Abi,
|
|
||||||
CommonContractSchemaInput,
|
CommonContractSchemaInput,
|
||||||
ContractEvent,
|
ContractEvent,
|
||||||
ContractForPrebuiltContractType,
|
ContractForPrebuiltContractType,
|
||||||
@@ -33,6 +32,7 @@ import type {
|
|||||||
ThirdwebSDK,
|
ThirdwebSDK,
|
||||||
ValidContractInstance,
|
ValidContractInstance,
|
||||||
BaseContractForAddress,
|
BaseContractForAddress,
|
||||||
|
PublishedMetadata,
|
||||||
} from "@thirdweb-dev/sdk";
|
} from "@thirdweb-dev/sdk";
|
||||||
import type { CallOverrides, ContractInterface, providers } from "ethers";
|
import type { CallOverrides, ContractInterface, providers } from "ethers";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
@@ -88,19 +88,11 @@ export const contractType = {
|
|||||||
|
|
||||||
// end contract type
|
// end contract type
|
||||||
|
|
||||||
type FetchCompilerMetadataReturnType = {
|
|
||||||
name: string;
|
|
||||||
metadata: Record<string, any>;
|
|
||||||
abi: Abi;
|
|
||||||
info: Record<string, any>;
|
|
||||||
licenses: string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
// contract compiler metadata
|
// contract compiler metadata
|
||||||
function fetchCompilerMetadata(
|
function fetchCompilerMetadata(
|
||||||
contractAddress: RequiredParam<ContractAddress>,
|
contractAddress: RequiredParam<ContractAddress>,
|
||||||
sdk: RequiredParam<ThirdwebSDK>,
|
sdk: RequiredParam<ThirdwebSDK>,
|
||||||
): Promise<FetchCompilerMetadataReturnType> | null {
|
): Promise<PublishedMetadata> | null {
|
||||||
if (!contractAddress || !sdk) {
|
if (!contractAddress || !sdk) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -114,7 +106,7 @@ function fetchCompilerMetadata(
|
|||||||
|
|
||||||
export function useCompilerMetadata(
|
export function useCompilerMetadata(
|
||||||
contractAddress: RequiredParam<ContractAddress>,
|
contractAddress: RequiredParam<ContractAddress>,
|
||||||
): UseQueryResult<FetchCompilerMetadataReturnType | null> {
|
): UseQueryResult<PublishedMetadata | null> {
|
||||||
const sdk = useSDK();
|
const sdk = useSDK();
|
||||||
|
|
||||||
return useQueryWithNetwork(
|
return useQueryWithNetwork(
|
||||||
|
|||||||
@@ -251,6 +251,9 @@ export { ThirdwebSDKProvider } from "./providers/thirdweb-sdk-provider";
|
|||||||
export { useSDK, useSDKChainId } from "./hooks/useSDK";
|
export { useSDK, useSDKChainId } from "./hooks/useSDK";
|
||||||
export type { ThirdwebSDKProviderProps } from "./providers/types";
|
export type { ThirdwebSDKProviderProps } from "./providers/types";
|
||||||
|
|
||||||
|
// utils
|
||||||
|
export { invalidateContractAndBalances } from "./utils/cache-keys";
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export type {
|
export type {
|
||||||
Chain,
|
Chain,
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# @thirdweb-dev/react-native-compat
|
# @thirdweb-dev/react-native-compat
|
||||||
|
|
||||||
|
## 0.2.55
|
||||||
|
|
||||||
|
## 0.2.54
|
||||||
|
|
||||||
## 0.2.53
|
## 0.2.53
|
||||||
|
|
||||||
## 0.2.52
|
## 0.2.52
|
||||||
|
|||||||
@@ -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.53",
|
"version": "0.2.55",
|
||||||
"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,27 @@
|
|||||||
# @thirdweb-dev/react-native
|
# @thirdweb-dev/react-native
|
||||||
|
|
||||||
|
## 0.2.55
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.55
|
||||||
|
- @thirdweb-dev/chains@0.1.47
|
||||||
|
- @thirdweb-dev/storage@1.2.8
|
||||||
|
- @thirdweb-dev/react-core@3.14.36
|
||||||
|
- @thirdweb-dev/wallets@1.1.19
|
||||||
|
|
||||||
|
## 0.2.54
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.46
|
||||||
|
- @thirdweb-dev/storage@1.2.7
|
||||||
|
- @thirdweb-dev/react-core@3.14.35
|
||||||
|
- @thirdweb-dev/sdk@3.10.54
|
||||||
|
- @thirdweb-dev/wallets@1.1.18
|
||||||
|
|
||||||
## 0.2.53
|
## 0.2.53
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-native",
|
"name": "@thirdweb-dev/react-native",
|
||||||
"version": "0.2.53",
|
"version": "0.2.55",
|
||||||
"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",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"@magic-sdk/provider": "17.2.0",
|
"@magic-sdk/provider": "17.2.0",
|
||||||
"@magic-sdk/react-native-bare": "^18.5.0",
|
"@magic-sdk/react-native-bare": "^18.5.0",
|
||||||
"@shopify/restyle": "^2.4.2",
|
"@shopify/restyle": "^2.4.2",
|
||||||
"@tanstack/react-query": "^4.32.0",
|
"@tanstack/react-query": "^4.33.0",
|
||||||
"@thirdweb-dev/chains": "workspace:*",
|
"@thirdweb-dev/chains": "workspace:*",
|
||||||
"@thirdweb-dev/react-core": "workspace:*",
|
"@thirdweb-dev/react-core": "workspace:*",
|
||||||
"@thirdweb-dev/sdk": "workspace:*",
|
"@thirdweb-dev/sdk": "workspace:*",
|
||||||
|
|||||||
@@ -1,5 +1,28 @@
|
|||||||
# @thirdweb-dev/react
|
# @thirdweb-dev/react
|
||||||
|
|
||||||
|
## 3.14.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1522](https://github.com/thirdweb-dev/js/pull/1522) [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0) Thanks [@MananTank](https://github.com/MananTank)! - - New prop `switchToActiveChain` added to `ConnectWallet`` component to show "Switch Network" button if wallet is not connected to the `activeChain`passed to the`ThirdwebProvider`
|
||||||
|
- Add max-height on `ConnectWallet` modal
|
||||||
|
- Local Wallet UI adjustments
|
||||||
|
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.55
|
||||||
|
- @thirdweb-dev/chains@0.1.47
|
||||||
|
- @thirdweb-dev/react-core@3.14.36
|
||||||
|
- @thirdweb-dev/wallets@1.1.19
|
||||||
|
|
||||||
|
## 3.14.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.46
|
||||||
|
- @thirdweb-dev/react-core@3.14.35
|
||||||
|
- @thirdweb-dev/sdk@3.10.54
|
||||||
|
- @thirdweb-dev/wallets@1.1.18
|
||||||
|
|
||||||
## 3.14.34
|
## 3.14.34
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react",
|
"name": "@thirdweb-dev/react",
|
||||||
"version": "3.14.34",
|
"version": "3.14.36",
|
||||||
"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",
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-tooltip": "^1.0.6",
|
"@radix-ui/react-tooltip": "^1.0.6",
|
||||||
"@react-icons/all-files": "^4.1.0",
|
"@react-icons/all-files": "^4.1.0",
|
||||||
"@tanstack/react-query": "^4.32.0",
|
"@tanstack/react-query": "^4.33.0",
|
||||||
"@thirdweb-dev/chains": "workspace:*",
|
"@thirdweb-dev/chains": "workspace:*",
|
||||||
"@thirdweb-dev/react-core": "workspace:*",
|
"@thirdweb-dev/react-core": "workspace:*",
|
||||||
"@thirdweb-dev/wallets": "workspace:*",
|
"@thirdweb-dev/wallets": "workspace:*",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export const FormFieldWithIconButton: React.FC<{
|
|||||||
error?: string;
|
error?: string;
|
||||||
noSave?: boolean;
|
noSave?: boolean;
|
||||||
dataTest?: string;
|
dataTest?: string;
|
||||||
|
placeholder?: string;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -42,6 +43,7 @@ export const FormFieldWithIconButton: React.FC<{
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
data-test={props.dataTest}
|
data-test={props.dataTest}
|
||||||
|
placeholder={props.placeholder}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<InputButton type="button" onClick={props.right.onClick}>
|
<InputButton type="button" onClick={props.right.onClick}>
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ export const ConnectModal = () => {
|
|||||||
>
|
>
|
||||||
<Modal
|
<Modal
|
||||||
style={{
|
style={{
|
||||||
maxWidth: "480px",
|
maxWidth: "450px",
|
||||||
|
maxHeight: "70vh",
|
||||||
}}
|
}}
|
||||||
open={isWalletModalOpen}
|
open={isWalletModalOpen}
|
||||||
setOpen={(value) => {
|
setOpen={(value) => {
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ import {
|
|||||||
useConnectionStatus,
|
useConnectionStatus,
|
||||||
useLogin,
|
useLogin,
|
||||||
useLogout,
|
useLogout,
|
||||||
|
useNetworkMismatch,
|
||||||
|
useSwitchChain,
|
||||||
useThirdwebAuthContext,
|
useThirdwebAuthContext,
|
||||||
useUser,
|
useUser,
|
||||||
useWallet,
|
useWallet,
|
||||||
|
useWalletContext,
|
||||||
} from "@thirdweb-dev/react-core";
|
} from "@thirdweb-dev/react-core";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -54,6 +57,13 @@ type ConnectWalletProps = {
|
|||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
hideTestnetFaucet?: boolean;
|
hideTestnetFaucet?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to show "Switch Network" button if wallet connected, but it is not connected to the `activeChain` provided in `ThirdwebProvider`
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
switchToActiveChain?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TW_CONNECT_WALLET = "tw-connect-wallet";
|
const TW_CONNECT_WALLET = "tw-connect-wallet";
|
||||||
@@ -83,6 +93,8 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
|||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { login } = useLogin();
|
const { login } = useLogin();
|
||||||
const { logout } = useLogout();
|
const { logout } = useLogout();
|
||||||
|
const isNetworkMismatch = useNetworkMismatch();
|
||||||
|
const { activeChainSetExplicitly } = useWalletContext();
|
||||||
|
|
||||||
const requiresSignIn = props.auth?.loginOptional
|
const requiresSignIn = props.auth?.loginOptional
|
||||||
? false
|
? false
|
||||||
@@ -108,61 +120,87 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Sign In Button */}
|
{(() => {
|
||||||
{requiresSignIn && (
|
// wallet is not connected
|
||||||
<Button
|
if (!activeWallet) {
|
||||||
variant="inverted"
|
// Connect Wallet button
|
||||||
onClick={signIn}
|
return (
|
||||||
data-theme={theme}
|
<AnimatedButton
|
||||||
className={`${TW_CONNECT_WALLET}--sign-in ${props.className || ""}}`}
|
disabled={isLoading}
|
||||||
style={props.style}
|
className={`${props.className || ""} ${TW_CONNECT_WALLET}`}
|
||||||
>
|
data-theme={theme}
|
||||||
<Flex
|
data-is-loading={isLoading}
|
||||||
alignItems="center"
|
variant="inverted"
|
||||||
gap="sm"
|
type="button"
|
||||||
style={{
|
style={{
|
||||||
paddingRight: spacing.xs,
|
minWidth: "140px",
|
||||||
borderRight: "1px solid",
|
...props.style,
|
||||||
marginRight: spacing.xs,
|
}}
|
||||||
}}
|
aria-label={
|
||||||
>
|
connectionStatus === "connecting" ? "Connecting" : btnTitle
|
||||||
<LockIcon size={iconSize.sm} />
|
}
|
||||||
<span> Sign in </span>
|
onClick={() => {
|
||||||
</Flex>
|
setModalConfig({
|
||||||
<span>{shortenAddress(address || "", true)}</span>
|
title: props.modalTitle || "Choose your wallet",
|
||||||
</Button>
|
theme,
|
||||||
)}
|
data: undefined,
|
||||||
|
});
|
||||||
|
setIsWalletModalOpen(true);
|
||||||
|
}}
|
||||||
|
data-test="connect-wallet-button"
|
||||||
|
>
|
||||||
|
{isLoading ? <Spinner size="sm" color="inverted" /> : btnTitle}
|
||||||
|
</AnimatedButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
{!requiresSignIn &&
|
// switch network button
|
||||||
(!activeWallet ? (
|
if (
|
||||||
// connect wallet button
|
props.switchToActiveChain &&
|
||||||
<AnimatedButton
|
isNetworkMismatch &&
|
||||||
disabled={isLoading}
|
activeChainSetExplicitly
|
||||||
className={`${props.className || ""} ${TW_CONNECT_WALLET}`}
|
) {
|
||||||
data-theme={theme}
|
return (
|
||||||
data-is-loading={isLoading}
|
<SwitchNetworkButton
|
||||||
variant="inverted"
|
style={props.style}
|
||||||
type="button"
|
theme={theme}
|
||||||
style={{
|
className={props.className}
|
||||||
minWidth: "140px",
|
/>
|
||||||
...props.style,
|
);
|
||||||
}}
|
}
|
||||||
aria-label={
|
|
||||||
connectionStatus === "connecting" ? "Connecting" : btnTitle
|
// sign in button
|
||||||
}
|
else if (requiresSignIn) {
|
||||||
onClick={() => {
|
return (
|
||||||
setModalConfig({
|
<Button
|
||||||
title: props.modalTitle || "Choose your wallet",
|
variant="inverted"
|
||||||
theme,
|
onClick={signIn}
|
||||||
data: undefined,
|
data-theme={theme}
|
||||||
});
|
className={`${TW_CONNECT_WALLET}--sign-in ${
|
||||||
setIsWalletModalOpen(true);
|
props.className || ""
|
||||||
}}
|
}`}
|
||||||
data-test="connect-wallet-button"
|
style={props.style}
|
||||||
>
|
data-test="sign-in-button"
|
||||||
{isLoading ? <Spinner size="sm" color="inverted" /> : btnTitle}
|
>
|
||||||
</AnimatedButton>
|
<Flex
|
||||||
) : (
|
alignItems="center"
|
||||||
|
gap="sm"
|
||||||
|
style={{
|
||||||
|
paddingRight: spacing.xs,
|
||||||
|
borderRight: "1px solid",
|
||||||
|
marginRight: spacing.xs,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LockIcon size={iconSize.sm} />
|
||||||
|
<span> Sign in </span>
|
||||||
|
</Flex>
|
||||||
|
<span>{shortenAddress(address || "", true)}</span>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// wallet details button
|
||||||
|
return (
|
||||||
<ConnectedWalletDetails
|
<ConnectedWalletDetails
|
||||||
networkSelector={props.networkSelector}
|
networkSelector={props.networkSelector}
|
||||||
dropdownPosition={props.dropdownPosition}
|
dropdownPosition={props.dropdownPosition}
|
||||||
@@ -178,11 +216,52 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
);
|
||||||
|
})()}
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function SwitchNetworkButton(props: {
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
className?: string;
|
||||||
|
theme: "dark" | "light";
|
||||||
|
}) {
|
||||||
|
const { activeChain } = useWalletContext();
|
||||||
|
const switchChain = useSwitchChain();
|
||||||
|
const [switching, setSwitching] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AnimatedButton
|
||||||
|
className={`${TW_CONNECT_WALLET}--switch-network ${
|
||||||
|
props.className || ""
|
||||||
|
}`}
|
||||||
|
variant="inverted"
|
||||||
|
type="button"
|
||||||
|
data-theme={props.theme}
|
||||||
|
data-is-loading={switching}
|
||||||
|
data-test="switch-network-button"
|
||||||
|
disabled={switching}
|
||||||
|
onClick={async () => {
|
||||||
|
setSwitching(true);
|
||||||
|
try {
|
||||||
|
await switchChain(activeChain.chainId);
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
setSwitching(false);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
minWidth: "140px",
|
||||||
|
...props.style,
|
||||||
|
}}
|
||||||
|
aria-label={switching ? "Switching Network" : undefined}
|
||||||
|
>
|
||||||
|
{switching ? <Spinner size="sm" color="inverted" /> : "Switch Network"}
|
||||||
|
</AnimatedButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const AnimatedButton = /* @__PURE__ */ styled(Button)`
|
const AnimatedButton = /* @__PURE__ */ styled(Button)`
|
||||||
animation: ${fadeInAnimation} 300ms ease;
|
animation: ${fadeInAnimation} 300ms ease;
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const WalletSelection: React.FC<{
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WalletList>
|
<WalletListContainer>
|
||||||
{walletConfigs.map((walletConfig) => {
|
{walletConfigs.map((walletConfig) => {
|
||||||
const isInstalled = walletConfig.isInstalled
|
const isInstalled = walletConfig.isInstalled
|
||||||
? walletConfig.isInstalled()
|
? walletConfig.isInstalled()
|
||||||
@@ -150,11 +150,11 @@ export const WalletSelection: React.FC<{
|
|||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</WalletList>
|
</WalletListContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const WalletList = styled.ul`
|
const WalletListContainer = styled.ul`
|
||||||
all: unset;
|
all: unset;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Spacer } from "../../../components/Spacer";
|
import { Spacer } from "../../../components/Spacer";
|
||||||
import { Button } from "../../../components/buttons";
|
import { Button } from "../../../components/buttons";
|
||||||
import { FormFooter, Label } from "../../../components/formElements";
|
import { Label } from "../../../components/formElements";
|
||||||
import {
|
import {
|
||||||
ModalTitle,
|
ModalTitle,
|
||||||
ModalDescription,
|
ModalDescription,
|
||||||
@@ -172,7 +172,7 @@ export const ExportLocalWallet: React.FC<{
|
|||||||
|
|
||||||
<SavedWalletAddress>{shortenAddress(savedAddress)}</SavedWalletAddress>
|
<SavedWalletAddress>{shortenAddress(savedAddress)}</SavedWalletAddress>
|
||||||
|
|
||||||
<Spacer y="lg" />
|
<Spacer y="xl" />
|
||||||
|
|
||||||
{passwordIsRequired && (
|
{passwordIsRequired && (
|
||||||
<>
|
<>
|
||||||
@@ -207,22 +207,21 @@ export const ExportLocalWallet: React.FC<{
|
|||||||
error={isWrongPassword ? "Wrong Password" : ""}
|
error={isWrongPassword ? "Wrong Password" : ""}
|
||||||
dataTest="current-password"
|
dataTest="current-password"
|
||||||
/>
|
/>
|
||||||
<Spacer y="xl" />
|
<Spacer y="md" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<FormFooter>
|
<Button
|
||||||
<Button
|
disabled={exportDisabled}
|
||||||
disabled={exportDisabled}
|
variant="inverted"
|
||||||
variant="inverted"
|
style={{
|
||||||
style={{
|
opacity: exportDisabled ? 0.5 : 1,
|
||||||
opacity: exportDisabled ? 0.5 : 1,
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
Backup
|
Backup
|
||||||
</Button>
|
</Button>
|
||||||
</FormFooter>
|
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";
|
import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";
|
||||||
import { WalletConfig, useWalletContext } from "@thirdweb-dev/react-core";
|
import { WalletConfig, useWalletContext } from "@thirdweb-dev/react-core";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { FormFooter, Label } from "../../../components/formElements";
|
import { Label } from "../../../components/formElements";
|
||||||
import { spacing } from "../../../design-system";
|
import { spacing } from "../../../design-system";
|
||||||
import { Spinner } from "../../../components/Spinner";
|
import { Spinner } from "../../../components/Spinner";
|
||||||
import { shortenAddress } from "../../../evm/utils/addresses";
|
import { shortenAddress } from "../../../evm/utils/addresses";
|
||||||
@@ -131,6 +131,7 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
|
|||||||
meta={meta}
|
meta={meta}
|
||||||
hideBack={!props.renderBackButton}
|
hideBack={!props.renderBackButton}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ModalTitle
|
<ModalTitle
|
||||||
style={{
|
style={{
|
||||||
textAlign: "left",
|
textAlign: "left",
|
||||||
@@ -138,12 +139,13 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
|
|||||||
>
|
>
|
||||||
Guest Wallet
|
Guest Wallet
|
||||||
</ModalTitle>
|
</ModalTitle>
|
||||||
|
|
||||||
<Spacer y="xs" />
|
<Spacer y="xs" />
|
||||||
<ModalDescription>
|
<ModalDescription>
|
||||||
Connect to saved wallet on your device
|
Connect to saved wallet on your device
|
||||||
</ModalDescription>
|
</ModalDescription>
|
||||||
|
|
||||||
<Spacer y="lg" />
|
<Spacer y="xl" />
|
||||||
|
|
||||||
<Label>Saved Wallet</Label>
|
<Label>Saved Wallet</Label>
|
||||||
|
|
||||||
@@ -153,7 +155,7 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
|
|||||||
{savedAddress === "" ? "Loading..." : shortenAddress(savedAddress)}
|
{savedAddress === "" ? "Loading..." : shortenAddress(savedAddress)}
|
||||||
</SecondaryText>
|
</SecondaryText>
|
||||||
|
|
||||||
<Spacer y="lg" />
|
<Spacer y="xl" />
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
@@ -190,27 +192,27 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
|
|||||||
value={password}
|
value={password}
|
||||||
error={isWrongPassword ? "Wrong Password" : ""}
|
error={isWrongPassword ? "Wrong Password" : ""}
|
||||||
dataTest="current-password"
|
dataTest="current-password"
|
||||||
|
placeholder="Enter your password"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacer y="lg" />
|
<Spacer y="md" />
|
||||||
|
|
||||||
{/* Connect Button */}
|
{/* Connect Button */}
|
||||||
<FormFooter>
|
<Button
|
||||||
<Button
|
variant="inverted"
|
||||||
variant="inverted"
|
type="submit"
|
||||||
type="submit"
|
style={{
|
||||||
style={{
|
display: "flex",
|
||||||
display: "flex",
|
gap: spacing.sm,
|
||||||
gap: spacing.sm,
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Connect
|
Connect
|
||||||
{isConnecting && <Spinner size="sm" color="inverted" />}
|
{isConnecting && <Spinner size="sm" color="inverted" />}
|
||||||
</Button>
|
</Button>
|
||||||
</FormFooter>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<Spacer y="xxl" />
|
<Spacer y="xl" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const LocalWalletModalHeader: React.FC<{
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Img src={props.meta.iconURL} width={iconSize.xl} height={iconSize.xl} />
|
<Img src={props.meta.iconURL} width={iconSize.xl} height={iconSize.xl} />
|
||||||
<Spacer y="sm" />
|
<Spacer y="md" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,38 @@
|
|||||||
# @thirdweb-dev/sdk
|
# @thirdweb-dev/sdk
|
||||||
|
|
||||||
|
## 3.10.55
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1488](https://github.com/thirdweb-dev/js/pull/1488) [`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Dynamic contract detection and deployment using updated publish metadata
|
||||||
|
|
||||||
|
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
|
||||||
|
|
||||||
|
- [#1526](https://github.com/thirdweb-dev/js/pull/1526) [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Fix supported chains map in getChainProvider
|
||||||
|
|
||||||
|
- [#1525](https://github.com/thirdweb-dev/js/pull/1525) [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Correct chain / polygon rpc for fetching published contract
|
||||||
|
|
||||||
|
- [#1523](https://github.com/thirdweb-dev/js/pull/1523) [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Separate ERC1155Supply extension
|
||||||
|
|
||||||
|
- [#1516](https://github.com/thirdweb-dev/js/pull/1516) [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Return early for claim checks when possible
|
||||||
|
|
||||||
|
- [#1288](https://github.com/thirdweb-dev/js/pull/1288) [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Airdrops
|
||||||
|
|
||||||
|
- [#1498](https://github.com/thirdweb-dev/js/pull/1498) [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Optimized fetching contract metadata, and fallback to bytecode extension detection for un-imported contracts
|
||||||
|
|
||||||
|
- Updated dependencies [[`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
|
||||||
|
- @thirdweb-dev/contracts-js@1.3.12
|
||||||
|
- @thirdweb-dev/chains@0.1.47
|
||||||
|
- @thirdweb-dev/storage@1.2.8
|
||||||
|
|
||||||
|
## 3.10.54
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.46
|
||||||
|
- @thirdweb-dev/storage@1.2.7
|
||||||
|
|
||||||
## 3.10.53
|
## 3.10.53
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/sdk",
|
"name": "@thirdweb-dev/sdk",
|
||||||
"version": "3.10.53",
|
"version": "3.10.55",
|
||||||
"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",
|
||||||
|
|||||||
@@ -14,13 +14,23 @@ export async function computeCloneFactoryAddress(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory?: string,
|
create2Factory?: string,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!create2Factory) {
|
if (!create2Factory) {
|
||||||
create2Factory = await getCreate2FactoryAddress(provider);
|
create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
await computeDeploymentInfo("infra", provider, storage, create2Factory, {
|
await computeDeploymentInfo(
|
||||||
contractName: "TWCloneFactory",
|
"infra",
|
||||||
})
|
provider,
|
||||||
|
storage,
|
||||||
|
create2Factory,
|
||||||
|
{
|
||||||
|
contractName: "TWCloneFactory",
|
||||||
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
).transaction.predictedAddress;
|
).transaction.predictedAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import {
|
|||||||
ContractOptions,
|
ContractOptions,
|
||||||
DeploymentPreset,
|
DeploymentPreset,
|
||||||
} from "../../types/any-evm/deploy-data";
|
} from "../../types/any-evm/deploy-data";
|
||||||
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI";
|
import {
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
fetchPublishedContractFromPolygon,
|
||||||
|
} from "./fetchPublishedContractFromPolygon";
|
||||||
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
||||||
import { isContractDeployed } from "./isContractDeployed";
|
import { isContractDeployed } from "./isContractDeployed";
|
||||||
import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
|
import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
|
||||||
@@ -26,8 +29,12 @@ export async function computeDeploymentInfo(
|
|||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory: string,
|
create2Factory: string,
|
||||||
contractOptions?: ContractOptions,
|
contractOptions?: ContractOptions,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<DeploymentPreset> {
|
): Promise<DeploymentPreset> {
|
||||||
const contractName = contractOptions && contractOptions.contractName;
|
const contractName = contractOptions && contractOptions.contractName;
|
||||||
|
const version = contractOptions && contractOptions.version;
|
||||||
|
let publisherAddress = contractOptions && contractOptions.publisherAddress;
|
||||||
let metadata = contractOptions && contractOptions.metadata;
|
let metadata = contractOptions && contractOptions.metadata;
|
||||||
invariant(contractName || metadata, "Require contract name or metadata");
|
invariant(contractName || metadata, "Require contract name or metadata");
|
||||||
|
|
||||||
@@ -57,9 +64,20 @@ export async function computeDeploymentInfo(
|
|||||||
|
|
||||||
if (!metadata) {
|
if (!metadata) {
|
||||||
invariant(contractName, "Require contract name");
|
invariant(contractName, "Require contract name");
|
||||||
const uri = await fetchAndCachePublishedContractURI(contractName);
|
if (!publisherAddress) {
|
||||||
metadata = (await fetchAndCacheDeployMetadata(uri, storage))
|
publisherAddress = THIRDWEB_DEPLOYER;
|
||||||
.compilerMetadata;
|
}
|
||||||
|
const publishedContract = await fetchPublishedContractFromPolygon(
|
||||||
|
publisherAddress,
|
||||||
|
contractName,
|
||||||
|
version,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
);
|
||||||
|
metadata = (
|
||||||
|
await fetchAndCacheDeployMetadata(publishedContract.metadataUri, storage)
|
||||||
|
).compilerMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
const encodedArgs = await encodeConstructorParamsForImplementation(
|
const encodedArgs = await encodeConstructorParamsForImplementation(
|
||||||
@@ -68,6 +86,8 @@ export async function computeDeploymentInfo(
|
|||||||
storage,
|
storage,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
contractOptions?.constructorParams,
|
contractOptions?.constructorParams,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
const address = computeDeploymentAddress(
|
const address = computeDeploymentAddress(
|
||||||
metadata.bytecode,
|
metadata.bytecode,
|
||||||
@@ -108,6 +128,8 @@ export async function encodeConstructorParamsForImplementation(
|
|||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory: string,
|
create2Factory: string,
|
||||||
constructorParamMap?: ConstructorParamMap,
|
constructorParamMap?: ConstructorParamMap,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<BytesLike> {
|
): Promise<BytesLike> {
|
||||||
const constructorParams = extractConstructorParamsFromAbi(
|
const constructorParams = extractConstructorParamsFromAbi(
|
||||||
compilerMetadata.abi,
|
compilerMetadata.abi,
|
||||||
@@ -147,6 +169,8 @@ export async function encodeConstructorParamsForImplementation(
|
|||||||
{
|
{
|
||||||
contractName: "WETH9",
|
contractName: "WETH9",
|
||||||
},
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
if (!caches.deploymentPresets["WETH9"]) {
|
if (!caches.deploymentPresets["WETH9"]) {
|
||||||
caches.deploymentPresets["WETH9"] = deploymentInfo;
|
caches.deploymentPresets["WETH9"] = deploymentInfo;
|
||||||
@@ -168,6 +192,8 @@ export async function encodeConstructorParamsForImplementation(
|
|||||||
{
|
{
|
||||||
contractName: "ForwarderEOAOnly",
|
contractName: "ForwarderEOAOnly",
|
||||||
},
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
if (!caches.deploymentPresets["ForwarderEOAOnly"]) {
|
if (!caches.deploymentPresets["ForwarderEOAOnly"]) {
|
||||||
caches.deploymentPresets["ForwarderEOAOnly"] = deploymentInfo;
|
caches.deploymentPresets["ForwarderEOAOnly"] = deploymentInfo;
|
||||||
@@ -183,6 +209,8 @@ export async function encodeConstructorParamsForImplementation(
|
|||||||
{
|
{
|
||||||
contractName: "Forwarder",
|
contractName: "Forwarder",
|
||||||
},
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
if (!caches.deploymentPresets["Forwarder"]) {
|
if (!caches.deploymentPresets["Forwarder"]) {
|
||||||
caches.deploymentPresets["Forwarder"] = deploymentInfo;
|
caches.deploymentPresets["Forwarder"] = deploymentInfo;
|
||||||
|
|||||||
@@ -14,13 +14,23 @@ export async function computeEOAForwarderAddress(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory?: string,
|
create2Factory?: string,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!create2Factory) {
|
if (!create2Factory || create2Factory === "") {
|
||||||
create2Factory = await getCreate2FactoryAddress(provider);
|
create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
await computeDeploymentInfo("infra", provider, storage, create2Factory, {
|
await computeDeploymentInfo(
|
||||||
contractName: "ForwarderEOAOnly",
|
"infra",
|
||||||
})
|
provider,
|
||||||
|
storage,
|
||||||
|
create2Factory,
|
||||||
|
{
|
||||||
|
contractName: "ForwarderEOAOnly",
|
||||||
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
).transaction.predictedAddress;
|
).transaction.predictedAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,23 @@ export async function computeForwarderAddress(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory?: string,
|
create2Factory?: string,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!create2Factory) {
|
if (!create2Factory || create2Factory === "") {
|
||||||
create2Factory = await getCreate2FactoryAddress(provider);
|
create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
await computeDeploymentInfo("infra", provider, storage, create2Factory, {
|
await computeDeploymentInfo(
|
||||||
contractName: "Forwarder",
|
"infra",
|
||||||
})
|
provider,
|
||||||
|
storage,
|
||||||
|
create2Factory,
|
||||||
|
{
|
||||||
|
contractName: "Forwarder",
|
||||||
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
).transaction.predictedAddress;
|
).transaction.predictedAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,23 @@ export async function computeNativeTokenAddress(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
create2Factory?: string,
|
create2Factory?: string,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (!create2Factory) {
|
if (!create2Factory || create2Factory === "") {
|
||||||
create2Factory = await getCreate2FactoryAddress(provider);
|
create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
await computeDeploymentInfo("infra", provider, storage, create2Factory, {
|
await computeDeploymentInfo(
|
||||||
contractName: "WETH9",
|
"infra",
|
||||||
})
|
provider,
|
||||||
|
storage,
|
||||||
|
create2Factory,
|
||||||
|
{
|
||||||
|
contractName: "WETH9",
|
||||||
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
).transaction.predictedAddress;
|
).transaction.predictedAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { deployCreate2Factory } from "./deployCreate2Factory";
|
|||||||
import { convertParamValues } from "./convertParamValues";
|
import { convertParamValues } from "./convertParamValues";
|
||||||
import { AbiInput } from "../../schema";
|
import { AbiInput } from "../../schema";
|
||||||
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
||||||
|
import { fetchPublishedContractFromPolygon } from "./fetchPublishedContractFromPolygon";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Direct deploy a contract at a deterministic address, using Create2 method
|
* Direct deploy a contract at a deterministic address, using Create2 method
|
||||||
@@ -36,7 +37,7 @@ export async function directDeployDeterministic(
|
|||||||
constructorArgs: any[],
|
constructorArgs: any[],
|
||||||
saltForCreate2?: string,
|
saltForCreate2?: string,
|
||||||
gasLimit: number = 7000000,
|
gasLimit: number = 7000000,
|
||||||
) {
|
): Promise<string> {
|
||||||
invariant(signer.provider, "Provider is required");
|
invariant(signer.provider, "Provider is required");
|
||||||
|
|
||||||
const bytecodePrefixed = bytecode.startsWith("0x")
|
const bytecodePrefixed = bytecode.startsWith("0x")
|
||||||
@@ -97,6 +98,8 @@ export async function directDeployDeterministic(
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(`Contract already deployed at ${address}`);
|
throw new Error(`Contract already deployed at ${address}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,13 +121,73 @@ export async function directDeployDeterministicWithUri(
|
|||||||
constructorArgs: any[],
|
constructorArgs: any[],
|
||||||
saltForCreate2?: string,
|
saltForCreate2?: string,
|
||||||
gasLimit: number = 7000000,
|
gasLimit: number = 7000000,
|
||||||
) {
|
): Promise<string> {
|
||||||
const { compilerMetadata } = await fetchAndCacheDeployMetadata(
|
const { compilerMetadata, extendedMetadata } =
|
||||||
publishMetadataUri,
|
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
|
||||||
storage,
|
|
||||||
|
invariant(
|
||||||
|
extendedMetadata?.deployType === "standard",
|
||||||
|
"Must be direct deploy",
|
||||||
);
|
);
|
||||||
|
|
||||||
await directDeployDeterministic(
|
return await directDeployDeterministic(
|
||||||
|
compilerMetadata.bytecode,
|
||||||
|
compilerMetadata.abi,
|
||||||
|
signer,
|
||||||
|
constructorArgs,
|
||||||
|
saltForCreate2,
|
||||||
|
gasLimit,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direct deploy a contract at a deterministic address, using Create2 method
|
||||||
|
* Address depends on the Create2 factory address and salt (if provided).
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @param contractName
|
||||||
|
* @param publisherAddress
|
||||||
|
* @param contractVersion
|
||||||
|
* @param constructorArgs
|
||||||
|
* @param signer
|
||||||
|
* @param storage
|
||||||
|
* @param clientId
|
||||||
|
* @param secretKey
|
||||||
|
* @param constructorArgs
|
||||||
|
* @param saltForCreate2
|
||||||
|
*/
|
||||||
|
export async function directDeployDeterministicPublished(
|
||||||
|
contractName: string,
|
||||||
|
publisherAddress: string,
|
||||||
|
contractVersion: string = "latest",
|
||||||
|
constructorArgs: any[],
|
||||||
|
signer: Signer,
|
||||||
|
storage: ThirdwebStorage,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
|
saltForCreate2?: string,
|
||||||
|
gasLimit: number = 7000000,
|
||||||
|
): Promise<string> {
|
||||||
|
const publishMetadataUri = (
|
||||||
|
await fetchPublishedContractFromPolygon(
|
||||||
|
publisherAddress,
|
||||||
|
contractName,
|
||||||
|
contractVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
|
).metadataUri;
|
||||||
|
const { compilerMetadata, extendedMetadata } =
|
||||||
|
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
|
||||||
|
|
||||||
|
invariant(
|
||||||
|
extendedMetadata?.deployType === "standard",
|
||||||
|
"Must be direct deploy",
|
||||||
|
);
|
||||||
|
|
||||||
|
return await directDeployDeterministic(
|
||||||
compilerMetadata.bytecode,
|
compilerMetadata.bytecode,
|
||||||
compilerMetadata.abi,
|
compilerMetadata.abi,
|
||||||
signer,
|
signer,
|
||||||
@@ -140,7 +203,7 @@ export async function predictAddressDeterministic(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
constructorArgs: any[],
|
constructorArgs: any[],
|
||||||
saltForCreate2?: string,
|
saltForCreate2?: string,
|
||||||
) {
|
): Promise<string> {
|
||||||
const bytecodePrefixed = bytecode.startsWith("0x")
|
const bytecodePrefixed = bytecode.startsWith("0x")
|
||||||
? bytecode
|
? bytecode
|
||||||
: `0x${bytecode}`;
|
: `0x${bytecode}`;
|
||||||
@@ -182,9 +245,50 @@ export async function predictAddressDeterministicWithUri(
|
|||||||
constructorArgs: any[],
|
constructorArgs: any[],
|
||||||
saltForCreate2?: string,
|
saltForCreate2?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { compilerMetadata } = await fetchAndCacheDeployMetadata(
|
const { compilerMetadata, extendedMetadata } =
|
||||||
publishMetadataUri,
|
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
|
||||||
storage,
|
|
||||||
|
invariant(
|
||||||
|
extendedMetadata?.deployType === "standard",
|
||||||
|
"Must be direct deploy",
|
||||||
|
);
|
||||||
|
|
||||||
|
return await predictAddressDeterministic(
|
||||||
|
compilerMetadata.bytecode,
|
||||||
|
compilerMetadata.abi,
|
||||||
|
provider,
|
||||||
|
constructorArgs,
|
||||||
|
saltForCreate2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function predictAddressDeterministicPublished(
|
||||||
|
contractName: string,
|
||||||
|
publisherAddress: string,
|
||||||
|
contractVersion: string = "latest",
|
||||||
|
constructorArgs: any[],
|
||||||
|
provider: providers.Provider,
|
||||||
|
storage: ThirdwebStorage,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
|
saltForCreate2?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const publishMetadataUri = (
|
||||||
|
await fetchPublishedContractFromPolygon(
|
||||||
|
publisherAddress,
|
||||||
|
contractName,
|
||||||
|
contractVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
)
|
||||||
|
).metadataUri;
|
||||||
|
const { compilerMetadata, extendedMetadata } =
|
||||||
|
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
|
||||||
|
|
||||||
|
invariant(
|
||||||
|
extendedMetadata?.deployType === "standard",
|
||||||
|
"Must be direct deploy",
|
||||||
);
|
);
|
||||||
|
|
||||||
return await predictAddressDeterministic(
|
return await predictAddressDeterministic(
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import { Contract } from "ethers";
|
|
||||||
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/dist/abis/ContractPublisher.json";
|
|
||||||
import type { ContractPublisher } from "@thirdweb-dev/contracts-js";
|
|
||||||
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
|
|
||||||
import { getChainProvider } from "../../constants/urls";
|
|
||||||
|
|
||||||
const uriCache: Record<string, string> = {};
|
|
||||||
|
|
||||||
const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
|
|
||||||
|
|
||||||
export async function fetchAndCachePublishedContractURI(
|
|
||||||
contractName: string,
|
|
||||||
): Promise<string> {
|
|
||||||
if (uriCache[contractName]) {
|
|
||||||
return uriCache[contractName];
|
|
||||||
}
|
|
||||||
|
|
||||||
const contract = new Contract(
|
|
||||||
getContractPublisherAddress(),
|
|
||||||
ContractPublisherAbi,
|
|
||||||
getChainProvider("polygon", {}),
|
|
||||||
) as ContractPublisher;
|
|
||||||
|
|
||||||
const model = await contract.getPublishedContract(
|
|
||||||
THIRDWEB_DEPLOYER,
|
|
||||||
contractName,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!model) {
|
|
||||||
throw new Error(
|
|
||||||
`No published contract found for ${contractName} at version by '${THIRDWEB_DEPLOYER}'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uri = model.publishMetadataUri;
|
|
||||||
uriCache[contractName] = uri;
|
|
||||||
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { Contract } from "ethers";
|
||||||
|
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/dist/abis/ContractPublisher.json";
|
||||||
|
import type { ContractPublisher } from "@thirdweb-dev/contracts-js";
|
||||||
|
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
|
||||||
|
import { getChainProvider } from "../../constants/urls";
|
||||||
|
import { AddressOrEns, PublishedContractSchema } from "../../schema";
|
||||||
|
import { resolveAddress } from "../ens/resolveAddress";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
||||||
|
import { getSupportedChains } from "../../constants";
|
||||||
|
import { Polygon } from "@thirdweb-dev/chains";
|
||||||
|
|
||||||
|
export const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
|
||||||
|
|
||||||
|
export async function fetchPublishedContractFromPolygon(
|
||||||
|
publisherAddress: AddressOrEns,
|
||||||
|
contractName: string,
|
||||||
|
version: string = "latest",
|
||||||
|
storage: ThirdwebStorage,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
|
) {
|
||||||
|
const polygonChain = getSupportedChains().find((c) => c.chainId === 137);
|
||||||
|
const chain = polygonChain || Polygon;
|
||||||
|
const publisher = await resolveAddress(publisherAddress);
|
||||||
|
const contract = new Contract(
|
||||||
|
getContractPublisherAddress(),
|
||||||
|
ContractPublisherAbi,
|
||||||
|
getChainProvider(chain, { clientId, secretKey }),
|
||||||
|
) as ContractPublisher;
|
||||||
|
|
||||||
|
let publishedContract;
|
||||||
|
if (!version || version === "latest") {
|
||||||
|
const model = await contract.getPublishedContract(publisher, contractName);
|
||||||
|
publishedContract = PublishedContractSchema.parse({
|
||||||
|
id: model.contractId,
|
||||||
|
timestamp: model.publishTimestamp,
|
||||||
|
metadataUri: model.publishMetadataUri,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const allVersions = (
|
||||||
|
await contract.getPublishedContractVersions(publisher, contractName)
|
||||||
|
).map((c) => {
|
||||||
|
return PublishedContractSchema.parse({
|
||||||
|
id: c.contractId,
|
||||||
|
timestamp: c.publishTimestamp,
|
||||||
|
metadataUri: c.publishMetadataUri,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// get the metadata for each version
|
||||||
|
const versionMetadata = await Promise.all(
|
||||||
|
allVersions.map(async (c) => {
|
||||||
|
return {
|
||||||
|
name: c.id,
|
||||||
|
publishedTimestamp: c.timestamp,
|
||||||
|
publishedMetadata: await fetchAndCacheDeployMetadata(
|
||||||
|
c.metadataUri,
|
||||||
|
storage,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
// find the version that matches the version string
|
||||||
|
const versionMatch = versionMetadata.find(
|
||||||
|
(metadata) =>
|
||||||
|
metadata.publishedMetadata.extendedMetadata?.version === version,
|
||||||
|
);
|
||||||
|
invariant(versionMatch, "Contract version not found");
|
||||||
|
// match the version back to the contract based on the published timestamp
|
||||||
|
publishedContract = allVersions.find(
|
||||||
|
(c) => c.timestamp === versionMatch.publishedTimestamp,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!publishedContract) {
|
||||||
|
throw new Error(
|
||||||
|
`No published contract found for ${contractName} at version by '${THIRDWEB_DEPLOYER}'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return publishedContract;
|
||||||
|
}
|
||||||
@@ -13,9 +13,9 @@ import {
|
|||||||
generateExtensionFunctions,
|
generateExtensionFunctions,
|
||||||
generatePluginFunctions,
|
generatePluginFunctions,
|
||||||
} from "../plugin/generatePluginFunctions";
|
} from "../plugin/generatePluginFunctions";
|
||||||
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
|
|
||||||
import { getMetadataForExtensions } from "../plugin/getMetadataForExtensions";
|
|
||||||
import { Extension } from "../../types/extensions";
|
import { Extension } from "../../types/extensions";
|
||||||
|
import { fetchPublishedContractFromPolygon } from "./fetchPublishedContractFromPolygon";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns txn data for keyless deploys as well as signer deploys.
|
* Returns txn data for keyless deploys as well as signer deploys.
|
||||||
@@ -33,6 +33,8 @@ export async function getDeploymentInfo(
|
|||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
create2Factory?: string,
|
create2Factory?: string,
|
||||||
|
clientId?: string,
|
||||||
|
secretKey?: string,
|
||||||
): Promise<DeploymentPreset[]> {
|
): Promise<DeploymentPreset[]> {
|
||||||
caches.deploymentPresets = {};
|
caches.deploymentPresets = {};
|
||||||
|
|
||||||
@@ -42,18 +44,33 @@ export async function getDeploymentInfo(
|
|||||||
|
|
||||||
const customParams: ConstructorParamMap = {};
|
const customParams: ConstructorParamMap = {};
|
||||||
const finalDeploymentInfo: DeploymentPreset[] = [];
|
const finalDeploymentInfo: DeploymentPreset[] = [];
|
||||||
const { compilerMetadata } = await fetchAndCacheDeployMetadata(
|
const { compilerMetadata, extendedMetadata } =
|
||||||
metadataUri,
|
await fetchAndCacheDeployMetadata(metadataUri, storage);
|
||||||
storage,
|
const defaultExtensions = extendedMetadata?.defaultExtensions;
|
||||||
);
|
|
||||||
const pluginMetadata = await getMetadataForPlugins(metadataUri, storage);
|
if (extendedMetadata?.routerType === "plugin" && defaultExtensions) {
|
||||||
const extensionMetadata = await getMetadataForExtensions(
|
invariant(clientId || secretKey, "Require Client Id / Secret Key");
|
||||||
metadataUri,
|
const publishedExtensions = await Promise.all(
|
||||||
storage,
|
defaultExtensions.map((e) => {
|
||||||
);
|
return fetchPublishedContractFromPolygon(
|
||||||
|
e.publisherAddress,
|
||||||
|
e.extensionName,
|
||||||
|
e.extensionVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const pluginMetadata = (
|
||||||
|
await Promise.all(
|
||||||
|
publishedExtensions.map(async (c) => {
|
||||||
|
return fetchAndCacheDeployMetadata(c.metadataUri, storage);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
|
||||||
|
|
||||||
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
|
|
||||||
if (pluginMetadata.length > 0) {
|
|
||||||
// get deployment info for all plugins
|
// get deployment info for all plugins
|
||||||
const pluginDeploymentInfo = await Promise.all(
|
const pluginDeploymentInfo = await Promise.all(
|
||||||
pluginMetadata.map(async (metadata) => {
|
pluginMetadata.map(async (metadata) => {
|
||||||
@@ -63,6 +80,8 @@ export async function getDeploymentInfo(
|
|||||||
storage,
|
storage,
|
||||||
create2FactoryAddress,
|
create2FactoryAddress,
|
||||||
{ metadata: metadata },
|
{ metadata: metadata },
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
return info;
|
return info;
|
||||||
}),
|
}),
|
||||||
@@ -88,6 +107,8 @@ export async function getDeploymentInfo(
|
|||||||
contractName: "PluginMap",
|
contractName: "PluginMap",
|
||||||
constructorParams: { _pluginsToAdd: { value: mapInput } },
|
constructorParams: { _pluginsToAdd: { value: mapInput } },
|
||||||
},
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
// address of PluginMap is input for MarketplaceV3's constructor
|
// address of PluginMap is input for MarketplaceV3's constructor
|
||||||
@@ -96,7 +117,29 @@ export async function getDeploymentInfo(
|
|||||||
};
|
};
|
||||||
|
|
||||||
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
|
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
|
||||||
} else if (extensionMetadata.length > 0) {
|
} else if (extendedMetadata?.routerType === "dynamic" && defaultExtensions) {
|
||||||
|
invariant(clientId || secretKey, "Require Client Id / Secret Key");
|
||||||
|
const publishedExtensions = await Promise.all(
|
||||||
|
defaultExtensions.map((e) => {
|
||||||
|
return fetchPublishedContractFromPolygon(
|
||||||
|
e.publisherAddress,
|
||||||
|
e.extensionName,
|
||||||
|
e.extensionVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const extensionMetadata = (
|
||||||
|
await Promise.all(
|
||||||
|
publishedExtensions.map(async (c) => {
|
||||||
|
return fetchAndCacheDeployMetadata(c.metadataUri, storage);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
|
||||||
|
|
||||||
// get deployment info for all extensions
|
// get deployment info for all extensions
|
||||||
const extensionDeploymentInfo = await Promise.all(
|
const extensionDeploymentInfo = await Promise.all(
|
||||||
extensionMetadata.map(async (metadata) => {
|
extensionMetadata.map(async (metadata) => {
|
||||||
@@ -106,6 +149,8 @@ export async function getDeploymentInfo(
|
|||||||
storage,
|
storage,
|
||||||
create2FactoryAddress,
|
create2FactoryAddress,
|
||||||
{ metadata: metadata },
|
{ metadata: metadata },
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
return info;
|
return info;
|
||||||
}),
|
}),
|
||||||
@@ -143,6 +188,8 @@ export async function getDeploymentInfo(
|
|||||||
metadata: compilerMetadata,
|
metadata: compilerMetadata,
|
||||||
constructorParams: customParams,
|
constructorParams: customParams,
|
||||||
},
|
},
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
// get clone factory
|
// get clone factory
|
||||||
@@ -152,6 +199,8 @@ export async function getDeploymentInfo(
|
|||||||
storage,
|
storage,
|
||||||
create2FactoryAddress,
|
create2FactoryAddress,
|
||||||
{ contractName: "TWCloneFactory" },
|
{ contractName: "TWCloneFactory" },
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
finalDeploymentInfo.push(factoryInfo);
|
finalDeploymentInfo.push(factoryInfo);
|
||||||
|
|||||||
+26
-5
@@ -3,8 +3,10 @@ import { BytesLike } from "ethers";
|
|||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
import { getChainProvider } from "../../constants/urls";
|
import { getChainProvider } from "../../constants/urls";
|
||||||
import { ConstructorParamMap } from "../../types/any-evm/deploy-data";
|
import { ConstructorParamMap } from "../../types/any-evm/deploy-data";
|
||||||
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
|
import {
|
||||||
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI";
|
THIRDWEB_DEPLOYER,
|
||||||
|
fetchPublishedContractFromPolygon,
|
||||||
|
} from "./fetchPublishedContractFromPolygon";
|
||||||
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
||||||
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
||||||
import { encodeConstructorParamsForImplementation } from "./computeDeploymentInfo";
|
import { encodeConstructorParamsForImplementation } from "./computeDeploymentInfo";
|
||||||
@@ -21,6 +23,7 @@ export async function getEncodedConstructorParamsForThirdwebContract(
|
|||||||
contractName: string,
|
contractName: string,
|
||||||
chainId: number,
|
chainId: number,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
contractVersion: string = "latest",
|
||||||
clientId?: string,
|
clientId?: string,
|
||||||
secretKey?: string,
|
secretKey?: string,
|
||||||
constructorParamMap?: ConstructorParamMap,
|
constructorParamMap?: ConstructorParamMap,
|
||||||
@@ -29,22 +32,38 @@ export async function getEncodedConstructorParamsForThirdwebContract(
|
|||||||
clientId,
|
clientId,
|
||||||
secretKey,
|
secretKey,
|
||||||
});
|
});
|
||||||
const publishUri = await fetchAndCachePublishedContractURI(contractName);
|
const publishedContract = await fetchPublishedContractFromPolygon(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
contractName,
|
||||||
|
contractVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
);
|
||||||
|
const publishUri = publishedContract.metadataUri;
|
||||||
const metadata = await fetchAndCacheDeployMetadata(publishUri, storage);
|
const metadata = await fetchAndCacheDeployMetadata(publishUri, storage);
|
||||||
const create2Factory = await getCreate2FactoryAddress(provider);
|
const create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
invariant(create2Factory, "Thirdweb stack not found");
|
invariant(create2Factory, "Thirdweb stack not found");
|
||||||
|
|
||||||
const pluginMetadata = await getMetadataForPlugins(publishUri, storage);
|
const { extendedMetadata } = await fetchAndCacheDeployMetadata(
|
||||||
|
publishUri,
|
||||||
|
storage,
|
||||||
|
);
|
||||||
|
|
||||||
let encodedArgs;
|
let encodedArgs;
|
||||||
|
|
||||||
// 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 (
|
||||||
|
extendedMetadata?.routerType === "plugin" ||
|
||||||
|
extendedMetadata?.routerType === "dynamic"
|
||||||
|
) {
|
||||||
const deploymentInfo = await getDeploymentInfo(
|
const deploymentInfo = await getDeploymentInfo(
|
||||||
publishUri,
|
publishUri,
|
||||||
storage,
|
storage,
|
||||||
provider,
|
provider,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
encodedArgs = deploymentInfo.find(
|
encodedArgs = deploymentInfo.find(
|
||||||
(contract) => contract.type === "implementation",
|
(contract) => contract.type === "implementation",
|
||||||
@@ -56,6 +75,8 @@ export async function getEncodedConstructorParamsForThirdwebContract(
|
|||||||
storage,
|
storage,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
constructorParamMap,
|
constructorParamMap,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export async function getThirdwebContractAddress(
|
|||||||
contractName: string,
|
contractName: string,
|
||||||
chainId: number,
|
chainId: number,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
contractVersion: string = "latest",
|
||||||
clientId?: string,
|
clientId?: string,
|
||||||
secretKey?: string,
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@@ -27,6 +28,7 @@ export async function getThirdwebContractAddress(
|
|||||||
contractName,
|
contractName,
|
||||||
chainId,
|
chainId,
|
||||||
storage,
|
storage,
|
||||||
|
contractVersion,
|
||||||
clientId,
|
clientId,
|
||||||
secretKey,
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
import { getChainProvider } from "../../constants/urls";
|
import { getChainProvider } from "../../constants/urls";
|
||||||
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
|
import {
|
||||||
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI";
|
THIRDWEB_DEPLOYER,
|
||||||
|
fetchPublishedContractFromPolygon,
|
||||||
|
} from "./fetchPublishedContractFromPolygon";
|
||||||
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
|
||||||
import { computeDeploymentInfo } from "./computeDeploymentInfo";
|
import { computeDeploymentInfo } from "./computeDeploymentInfo";
|
||||||
import { getDeploymentInfo } from "./getDeploymentInfo";
|
import { getDeploymentInfo } from "./getDeploymentInfo";
|
||||||
|
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -18,6 +21,7 @@ export async function predictThirdwebContractAddress(
|
|||||||
contractName: string,
|
contractName: string,
|
||||||
chainId: number,
|
chainId: number,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
contractVersion: string = "latest",
|
||||||
clientId?: string,
|
clientId?: string,
|
||||||
secretKey?: string,
|
secretKey?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@@ -25,19 +29,34 @@ export async function predictThirdwebContractAddress(
|
|||||||
clientId,
|
clientId,
|
||||||
secretKey,
|
secretKey,
|
||||||
});
|
});
|
||||||
const publishUri = await fetchAndCachePublishedContractURI(contractName);
|
const publishedContract = await fetchPublishedContractFromPolygon(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
contractName,
|
||||||
|
contractVersion,
|
||||||
|
storage,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
|
);
|
||||||
|
const publishUri = publishedContract.metadataUri;
|
||||||
const create2Factory = await getCreate2FactoryAddress(provider);
|
const create2Factory = await getCreate2FactoryAddress(provider);
|
||||||
invariant(create2Factory, "Thirdweb stack not found");
|
invariant(create2Factory, "Thirdweb stack not found");
|
||||||
|
|
||||||
const pluginMetadata = await getMetadataForPlugins(publishUri, storage);
|
const { extendedMetadata } = await fetchAndCacheDeployMetadata(
|
||||||
|
publishUri,
|
||||||
|
storage,
|
||||||
|
);
|
||||||
|
|
||||||
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
|
if (
|
||||||
if (pluginMetadata.length > 0) {
|
extendedMetadata?.routerType === "plugin" ||
|
||||||
|
extendedMetadata?.routerType === "dynamic"
|
||||||
|
) {
|
||||||
const deploymentInfo = await getDeploymentInfo(
|
const deploymentInfo = await getDeploymentInfo(
|
||||||
publishUri,
|
publishUri,
|
||||||
storage,
|
storage,
|
||||||
provider,
|
provider,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const implementation = deploymentInfo.find(
|
const implementation = deploymentInfo.find(
|
||||||
@@ -54,6 +73,8 @@ export async function predictThirdwebContractAddress(
|
|||||||
storage,
|
storage,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
{ contractName: contractName },
|
{ contractName: contractName },
|
||||||
|
clientId,
|
||||||
|
secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
return implementation.transaction.predictedAddress;
|
return implementation.transaction.predictedAddress;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { FeatureName } from "../../constants/contract-features";
|
|||||||
import { ContractWrapper } from "../../core/classes/contract-wrapper";
|
import { ContractWrapper } from "../../core/classes/contract-wrapper";
|
||||||
import { AbiSchema } from "../../schema/contracts/custom";
|
import { AbiSchema } from "../../schema/contracts/custom";
|
||||||
import { BaseContract } from "ethers";
|
import { BaseContract } from "ethers";
|
||||||
import { isFeatureEnabled } from "./isFeatureEnabled";
|
import { isExtensionEnabled } from "./isFeatureEnabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type guard for contractWrappers depending on passed feature name
|
* Type guard for contractWrappers depending on passed feature name
|
||||||
@@ -14,5 +14,5 @@ export function detectContractFeature<T extends BaseContract>(
|
|||||||
contractWrapper: ContractWrapper<BaseContract>,
|
contractWrapper: ContractWrapper<BaseContract>,
|
||||||
featureName: FeatureName,
|
featureName: FeatureName,
|
||||||
): contractWrapper is ContractWrapper<T> {
|
): contractWrapper is ContractWrapper<T> {
|
||||||
return isFeatureEnabled(AbiSchema.parse(contractWrapper.abi), featureName);
|
return isExtensionEnabled(AbiSchema.parse(contractWrapper.abi), featureName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
SUPPORTED_FEATURES,
|
SUPPORTED_FEATURES,
|
||||||
} from "../../constants/contract-features";
|
} from "../../constants/contract-features";
|
||||||
import { AbiInput } from "../../schema/contracts/custom";
|
import { AbiInput } from "../../schema/contracts/custom";
|
||||||
import { hasMatchingAbi } from "./hasMatchingAbi";
|
import { hasMatchingAbi, matchesAbiFromBytecode } from "./hasMatchingAbi";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes ALL supported features and sets whether the passed in abi supports each individual feature
|
* Processes ALL supported features and sets whether the passed in abi supports each individual feature
|
||||||
@@ -31,6 +31,24 @@ export function detectFeatures(
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function detectFeaturesFromBytecode(
|
||||||
|
bytecode: string,
|
||||||
|
features: Record<string, Feature> = SUPPORTED_FEATURES,
|
||||||
|
): Record<string, FeatureWithEnabled> {
|
||||||
|
const results: Record<string, FeatureWithEnabled> = {};
|
||||||
|
for (const featureKey in features) {
|
||||||
|
const feature = features[featureKey];
|
||||||
|
const enabled = matchesAbiFromBytecode(bytecode, feature.abis);
|
||||||
|
const childResults = detectFeaturesFromBytecode(bytecode, feature.features);
|
||||||
|
results[featureKey] = {
|
||||||
|
...feature,
|
||||||
|
features: childResults,
|
||||||
|
enabled,
|
||||||
|
} as FeatureWithEnabled;
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @param abi
|
* @param abi
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import {
|
|||||||
FeatureWithEnabled,
|
FeatureWithEnabled,
|
||||||
} from "../../constants/contract-features";
|
} from "../../constants/contract-features";
|
||||||
import { AbiInput } from "../../schema/contracts/custom";
|
import { AbiInput } from "../../schema/contracts/custom";
|
||||||
import { detectFeatures } from "./detectFeatures";
|
import { joinABIs } from "../plugin/joinABIs";
|
||||||
|
import { detectFeatures, detectFeaturesFromBytecode } from "./detectFeatures";
|
||||||
import { extractFeatures } from "./extractFeatures";
|
import { extractFeatures } from "./extractFeatures";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +20,24 @@ export function getAllDetectedFeatures(abi: AbiInput): FeatureWithEnabled[] {
|
|||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAllDetectedExtensionsFromBytecode(
|
||||||
|
bytecode: string,
|
||||||
|
): FeatureWithEnabled[] {
|
||||||
|
const features: FeatureWithEnabled[] = [];
|
||||||
|
extractFeatures(detectFeaturesFromBytecode(bytecode), features);
|
||||||
|
return features;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function constructAbiFromBytecode(bytecode: string): AbiInput {
|
||||||
|
let extensions = getAllDetectedExtensionsFromBytecode(bytecode);
|
||||||
|
// special deduping for ERC721 and ERC20
|
||||||
|
if (extensions.find((f) => f.name === "ERC721")) {
|
||||||
|
extensions = extensions.filter((f) => f.name !== "ERC20");
|
||||||
|
}
|
||||||
|
const abi = joinABIs(extensions.map((f) => joinABIs(f.abis as any)));
|
||||||
|
return abi;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the detected extensions in the abi
|
* Return all the detected extensions in the abi
|
||||||
* @param abi - parsed array of abi entries
|
* @param abi - parsed array of abi entries
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Interface } from "ethers/lib/utils";
|
||||||
import { AbiInput } from "../../schema/contracts/custom";
|
import { AbiInput } from "../../schema/contracts/custom";
|
||||||
import { extractFunctionsFromAbi } from "./extractFunctionsFromAbi";
|
import { extractFunctionsFromAbi } from "./extractFunctionsFromAbi";
|
||||||
|
|
||||||
@@ -38,3 +39,20 @@ export function hasMatchingAbi(
|
|||||||
});
|
});
|
||||||
return intersection.length === interfaceFn.length;
|
return intersection.length === interfaceFn.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function matchesAbiFromBytecode(
|
||||||
|
contractBytecode: string,
|
||||||
|
featureAbis: readonly AbiInput[],
|
||||||
|
) {
|
||||||
|
const interfaces = featureAbis.map((abi) => new Interface(abi));
|
||||||
|
const selectors = interfaces.flatMap((i) => {
|
||||||
|
return Object.values(i.functions).map((fn) =>
|
||||||
|
Number(i.getSighash(fn)).toString(16),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const uniqueSelectors = [...new Set(selectors)];
|
||||||
|
// checks that all unique selectors are found in the bytecode
|
||||||
|
return uniqueSelectors.every((selector) =>
|
||||||
|
contractBytecode.includes(selector),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ export async function resolveContractUriFromAddress(
|
|||||||
address: string,
|
address: string,
|
||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
|
const bytecode = await resolveImplementationBytecode(address, provider);
|
||||||
|
return extractIPFSHashFromBytecode(bytecode);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resolveContractUriAndBytecode(
|
||||||
|
address: string,
|
||||||
|
provider: providers.Provider,
|
||||||
|
): Promise<{ uri: string | undefined; bytecode: string }> {
|
||||||
|
const bytecode = await resolveImplementationBytecode(address, provider);
|
||||||
|
return { uri: extractIPFSHashFromBytecode(bytecode), bytecode };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resolveImplementationBytecode(
|
||||||
|
address: string,
|
||||||
|
provider: providers.Provider,
|
||||||
|
): Promise<string> {
|
||||||
let bytecode;
|
let bytecode;
|
||||||
try {
|
try {
|
||||||
bytecode = await provider.getCode(address);
|
bytecode = await provider.getCode(address);
|
||||||
@@ -26,10 +42,11 @@ export async function resolveContractUriFromAddress(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// TODO support other types of proxies
|
||||||
const implementationAddress =
|
const implementationAddress =
|
||||||
extractMinimalProxyImplementationAddress(bytecode);
|
extractMinimalProxyImplementationAddress(bytecode);
|
||||||
if (implementationAddress) {
|
if (implementationAddress) {
|
||||||
return await resolveContractUriFromAddress(
|
return await resolveImplementationBytecode(
|
||||||
implementationAddress,
|
implementationAddress,
|
||||||
provider,
|
provider,
|
||||||
);
|
);
|
||||||
@@ -51,7 +68,7 @@ export async function resolveContractUriFromAddress(
|
|||||||
utils.isAddress(implementationAddress) &&
|
utils.isAddress(implementationAddress) &&
|
||||||
implementationAddress !== constants.AddressZero
|
implementationAddress !== constants.AddressZero
|
||||||
) {
|
) {
|
||||||
return await resolveContractUriFromAddress(
|
return await resolveImplementationBytecode(
|
||||||
implementationAddress,
|
implementationAddress,
|
||||||
provider,
|
provider,
|
||||||
);
|
);
|
||||||
@@ -59,6 +76,8 @@ export async function resolveContractUriFromAddress(
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
// TODO support other types of proxies
|
if (!bytecode) {
|
||||||
return await extractIPFSHashFromBytecode(bytecode);
|
throw new Error(`Error fetching bytecode for ${address}`);
|
||||||
|
}
|
||||||
|
return bytecode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,21 @@ import {
|
|||||||
} from "../schema/contracts/custom";
|
} from "../schema/contracts/custom";
|
||||||
import type { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import type { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
|
|
||||||
|
const CONTRACT_METADATA_TIMEOUT_SEC = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @param compilerMetadataUri
|
* @param compilerMetadataUri
|
||||||
* @param storage
|
* @param storage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function fetchContractMetadata(
|
export async function fetchContractMetadata(
|
||||||
compilerMetadataUri: string,
|
compilerMetadataUri: string,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
): Promise<PublishedMetadata> {
|
): Promise<PublishedMetadata> {
|
||||||
const metadata = await storage.downloadJSON(compilerMetadataUri);
|
// short timeout to avoid hanging on unpinned contract metadata CIDs
|
||||||
|
const metadata = await storage.downloadJSON(compilerMetadataUri, {
|
||||||
|
timeoutInSeconds: CONTRACT_METADATA_TIMEOUT_SEC,
|
||||||
|
});
|
||||||
if (!metadata || !metadata.output) {
|
if (!metadata || !metadata.output) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not resolve metadata for contract at ${compilerMetadataUri}`,
|
`Could not resolve metadata for contract at ${compilerMetadataUri}`,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export * from "./snapshots";
|
|||||||
export * from "./role";
|
export * from "./role";
|
||||||
export * from "./metadata-resolver";
|
export * from "./metadata-resolver";
|
||||||
export * from "./gas-price";
|
export * from "./gas-price";
|
||||||
|
export * from "./fetchContractMetadata";
|
||||||
|
|
||||||
// feature detection
|
// feature detection
|
||||||
export * from "./feature-detection/matchesPrebuiltAbi";
|
export * from "./feature-detection/matchesPrebuiltAbi";
|
||||||
@@ -73,7 +74,7 @@ export * from "./any-evm-utils/deployWithThrowawayDeployer";
|
|||||||
export * from "./any-evm-utils/computeDeploymentInfo";
|
export * from "./any-evm-utils/computeDeploymentInfo";
|
||||||
export * from "./any-evm-utils/convertParamValues";
|
export * from "./any-evm-utils/convertParamValues";
|
||||||
export * from "./any-evm-utils/getCreate2FactoryDeploymentInfo";
|
export * from "./any-evm-utils/getCreate2FactoryDeploymentInfo";
|
||||||
export * from "./any-evm-utils/fetchAndCachePublishedContractURI";
|
export * from "./any-evm-utils/fetchPublishedContractFromPolygon";
|
||||||
export * from "./any-evm-utils/fetchAndCacheDeployMetadata";
|
export * from "./any-evm-utils/fetchAndCacheDeployMetadata";
|
||||||
export * from "./any-evm-utils/estimateGasForDeploy";
|
export * from "./any-evm-utils/estimateGasForDeploy";
|
||||||
export * from "./any-evm-utils/createTransactionBatches";
|
export * from "./any-evm-utils/createTransactionBatches";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Abi, PublishedMetadata } from "../schema/contracts/custom";
|
import { Abi, PublishedMetadata } from "../schema/contracts/custom";
|
||||||
import { Address } from "../schema/shared/Address";
|
import { Address } from "../schema/shared/Address";
|
||||||
import { resolveContractUriFromAddress } from "./feature-detection/resolveContractUriFromAddress";
|
import { resolveContractUriAndBytecode } from "./feature-detection/resolveContractUriFromAddress";
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import { Contract, providers } from "ethers";
|
import { Contract, providers } from "ethers";
|
||||||
import { fetchContractMetadata } from "./fetchContractMetadata";
|
import { fetchContractMetadata } from "./fetchContractMetadata";
|
||||||
@@ -8,7 +8,9 @@ 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 { constructAbiFromBytecode } from "./feature-detection/getAllDetectedFeatures";
|
||||||
import { SDKOptions } from "../schema";
|
import { SDKOptions } from "../schema";
|
||||||
|
import { Polygon } from "@thirdweb-dev/chains";
|
||||||
|
|
||||||
// Internal static cache
|
// Internal static cache
|
||||||
const metadataCache: Record<string, PublishedMetadata> = {};
|
const metadataCache: Record<string, PublishedMetadata> = {};
|
||||||
@@ -41,61 +43,92 @@ export async function fetchContractMetadataFromAddress(
|
|||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
sdkOptions: SDKOptions = {},
|
sdkOptions: SDKOptions = {},
|
||||||
) {
|
): Promise<PublishedMetadata> {
|
||||||
const chainId = (await provider.getNetwork()).chainId;
|
const chainId = (await provider.getNetwork()).chainId; // TODO resolve from sdk network
|
||||||
const cached = getFromCache(address, chainId);
|
const cached = getFromCache(address, chainId);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
let metadata: PublishedMetadata | undefined;
|
let metadata: PublishedMetadata | undefined;
|
||||||
try {
|
|
||||||
const compilerMetadataUri = await resolveContractUriFromAddress(
|
|
||||||
address,
|
|
||||||
provider,
|
|
||||||
);
|
|
||||||
if (!compilerMetadataUri) {
|
|
||||||
throw new Error(`Could not resolve metadata for contract at ${address}`);
|
|
||||||
}
|
|
||||||
metadata = await fetchContractMetadata(compilerMetadataUri, storage);
|
|
||||||
} catch (e) {
|
|
||||||
console.debug(
|
|
||||||
"Contract Metadata not found on IPFS, defaulting to onchain registry. Original error:",
|
|
||||||
(e as any)?.message,
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
// try from multichain registry
|
|
||||||
if (!multichainRegistry) {
|
|
||||||
// TODO enforce always passing sdk options for clientId/secretKey
|
|
||||||
multichainRegistry = new Contract(
|
|
||||||
getMultichainRegistryAddress(),
|
|
||||||
TWRegistryABI,
|
|
||||||
getChainProvider("polygon", sdkOptions),
|
|
||||||
) as TWMultichainRegistryLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
const importedUri = await multichainRegistry.getMetadataUri(
|
// we can't race here, because the contract URI might resolve first with a non pinned URI
|
||||||
chainId,
|
const [ipfsData, registryData] = await Promise.all([
|
||||||
address,
|
resolveContractUriAndBytecode(address, provider).catch(() => undefined),
|
||||||
|
getMetadataUriFromMultichainRegistry(address, chainId, sdkOptions)
|
||||||
|
.then((uri) => {
|
||||||
|
if (!uri) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
uri,
|
||||||
|
bytecode: "",
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(() => undefined),
|
||||||
|
]);
|
||||||
|
const bytecode = ipfsData?.bytecode;
|
||||||
|
const metadataUri = registryData?.uri || ipfsData?.uri;
|
||||||
|
if (!metadataUri && !bytecode) {
|
||||||
|
throw new Error(
|
||||||
|
`Could not fetch bytecode for contract at ${address} on chain ${chainId}, double check that the address and chainId are correct.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
metadata = await fetchContractMetadata(metadataUri, storage);
|
||||||
|
} catch (e) {
|
||||||
|
// Don't warn here, its common to not have IPFS metadata for a contract, fallback to bytecode
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!metadata && bytecode) {
|
||||||
|
const abi = constructAbiFromBytecode(bytecode);
|
||||||
|
if (abi && abi.length > 0) {
|
||||||
|
console.warn(
|
||||||
|
`Contract metadata could only be partially resolved, some contract functions might be unavailable. Try importing the contract by visiting: https://thirdweb.com/${chainId}/${address}`,
|
||||||
);
|
);
|
||||||
if (!importedUri) {
|
// return partial ABI
|
||||||
throw new Error(
|
metadata = {
|
||||||
`Could not resolve metadata for contract at ${address}`,
|
name: "Unimported Contract",
|
||||||
);
|
abi: abi as Abi,
|
||||||
}
|
metadata: {},
|
||||||
metadata = await fetchContractMetadata(importedUri, storage);
|
info: {},
|
||||||
} catch (err) {
|
licenses: [],
|
||||||
throw new Error(`Could not resolve metadata for contract at ${address}`);
|
isPartialAbi: true,
|
||||||
|
};
|
||||||
|
// return without caching
|
||||||
|
return metadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metadata) {
|
if (!metadata) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No ABI found for this contract. Try importing it by visiting: https://thirdweb.com/${chainId}/${address}`,
|
`Could not resolve contract. Try importing it by visiting: https://thirdweb.com/${chainId}/${address}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
putInCache(address, chainId, metadata);
|
putInCache(address, chainId, metadata);
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getMetadataUriFromMultichainRegistry(
|
||||||
|
address: string,
|
||||||
|
chainId: number,
|
||||||
|
sdkOptions: SDKOptions,
|
||||||
|
) {
|
||||||
|
if (!multichainRegistry) {
|
||||||
|
const polygonChain = sdkOptions?.supportedChains?.find(
|
||||||
|
(c) => c.chainId === 137,
|
||||||
|
);
|
||||||
|
const chain = polygonChain || Polygon;
|
||||||
|
multichainRegistry = new Contract(
|
||||||
|
getMultichainRegistryAddress(),
|
||||||
|
TWRegistryABI,
|
||||||
|
getChainProvider(chain, sdkOptions),
|
||||||
|
) as TWMultichainRegistryLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
const importedUri = await multichainRegistry.getMetadataUri(chainId, address);
|
||||||
|
return importedUri;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @param address
|
* @param address
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ export function generatePluginFunctions(
|
|||||||
const pluginFunctions: Plugin[] = [];
|
const pluginFunctions: Plugin[] = [];
|
||||||
// TODO - filter out common functions like _msgSender(), contractType(), etc.
|
// TODO - filter out common functions like _msgSender(), contractType(), etc.
|
||||||
for (const fnFragment of Object.values(pluginInterface.functions)) {
|
for (const fnFragment of Object.values(pluginInterface.functions)) {
|
||||||
const fn = pluginInterface.getFunction(fnFragment.name);
|
const fn = pluginInterface.getFunction(
|
||||||
|
pluginInterface.getSighash(fnFragment),
|
||||||
|
);
|
||||||
if (fn.name.includes("_")) {
|
if (fn.name.includes("_")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ export async function getCompositePluginABI(
|
|||||||
AbiSchema.parse(abi),
|
AbiSchema.parse(abi),
|
||||||
"PluginRouter",
|
"PluginRouter",
|
||||||
);
|
);
|
||||||
const isExtensionRouter: boolean = isFeatureEnabled(
|
const isbaseRouter: boolean = isFeatureEnabled(
|
||||||
AbiSchema.parse(abi),
|
AbiSchema.parse(abi),
|
||||||
"ExtensionRouter",
|
"DynamicContract",
|
||||||
);
|
);
|
||||||
if (isExtensionRouter) {
|
if (isbaseRouter) {
|
||||||
const contract = new ContractWrapper(
|
const contract = new ContractWrapper(
|
||||||
provider,
|
provider,
|
||||||
address,
|
address,
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
import { getAllPluginsAbi } 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 { fetchContractMetadataFromAddress } from "../metadata-resolver";
|
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
|
||||||
import { Plugin } from "../../types/plugins";
|
|
||||||
import { getChainProvider } from "../../constants/urls";
|
|
||||||
import { fetchAndCachePublishedContractURI } from "../any-evm-utils/fetchAndCachePublishedContractURI";
|
|
||||||
import { fetchAndCacheDeployMetadata } from "../any-evm-utils/fetchAndCacheDeployMetadata";
|
|
||||||
|
|
||||||
export async function getMetadataForPlugins(
|
|
||||||
publishedMetadataUri: string,
|
|
||||||
storage: ThirdwebStorage,
|
|
||||||
): Promise<PreDeployMetadataFetched[]> {
|
|
||||||
let pluginMetadata: PreDeployMetadataFetched[] = [];
|
|
||||||
|
|
||||||
const { compilerMetadata, extendedMetadata } =
|
|
||||||
await fetchAndCacheDeployMetadata(publishedMetadataUri, storage);
|
|
||||||
// check if contract is plugin-pattern
|
|
||||||
const isPluginRouter: boolean = isFeatureEnabled(
|
|
||||||
AbiSchema.parse(compilerMetadata.abi),
|
|
||||||
"PluginRouter",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isPluginRouter) {
|
|
||||||
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,
|
|
||||||
getAllPluginsAbi,
|
|
||||||
{},
|
|
||||||
storage,
|
|
||||||
);
|
|
||||||
|
|
||||||
const pluginMap = await contract.call("getAllPlugins");
|
|
||||||
|
|
||||||
// get extension addresses
|
|
||||||
const allPlugins = pluginMap.map(
|
|
||||||
(item: Plugin) => item.pluginAddress,
|
|
||||||
);
|
|
||||||
const pluginAddresses = Array.from(new Set(allPlugins));
|
|
||||||
|
|
||||||
const pluginNames = (
|
|
||||||
await Promise.all(
|
|
||||||
pluginAddresses.map(async (address) => {
|
|
||||||
const metadata = fetchContractMetadataFromAddress(
|
|
||||||
address as string,
|
|
||||||
provider,
|
|
||||||
storage,
|
|
||||||
);
|
|
||||||
return metadata;
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
).map((metadata) => metadata.name);
|
|
||||||
|
|
||||||
const pluginUris = await Promise.all(
|
|
||||||
pluginNames.map((name) => {
|
|
||||||
return fetchAndCachePublishedContractURI(name);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
pluginMetadata = (
|
|
||||||
await Promise.all(
|
|
||||||
pluginUris.map(async (uri) => {
|
|
||||||
return fetchAndCacheDeployMetadata(uri, storage);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
|
|
||||||
}
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pluginMetadata;
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,9 @@ export function isRouterContract(abi: Abi) {
|
|||||||
AbiSchema.parse(abi),
|
AbiSchema.parse(abi),
|
||||||
"PluginRouter",
|
"PluginRouter",
|
||||||
);
|
);
|
||||||
const isExtensionRouter: boolean = isFeatureEnabled(
|
const isBaseRouter: boolean = isFeatureEnabled(
|
||||||
AbiSchema.parse(abi),
|
AbiSchema.parse(abi),
|
||||||
"ExtensionRouter",
|
"DynamicContract",
|
||||||
);
|
);
|
||||||
return isExtensionRouter || isPluginRouter;
|
return isBaseRouter || isPluginRouter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export async function verifyThirdwebPrebuiltImplementation(
|
|||||||
explorerAPIUrl: string,
|
explorerAPIUrl: string,
|
||||||
explorerAPIKey: string,
|
explorerAPIKey: string,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
contractVersion: string = "latest",
|
||||||
clientId?: string,
|
clientId?: string,
|
||||||
secretKey?: string,
|
secretKey?: string,
|
||||||
constructorArgs?: ConstructorParamMap,
|
constructorArgs?: ConstructorParamMap,
|
||||||
@@ -69,6 +70,7 @@ export async function verifyThirdwebPrebuiltImplementation(
|
|||||||
contractName,
|
contractName,
|
||||||
chainId,
|
chainId,
|
||||||
storage,
|
storage,
|
||||||
|
contractVersion,
|
||||||
clientId,
|
clientId,
|
||||||
secretKey,
|
secretKey,
|
||||||
);
|
);
|
||||||
@@ -76,6 +78,7 @@ export async function verifyThirdwebPrebuiltImplementation(
|
|||||||
contractName,
|
contractName,
|
||||||
chainId,
|
chainId,
|
||||||
storage,
|
storage,
|
||||||
|
contractVersion,
|
||||||
clientId,
|
clientId,
|
||||||
secretKey,
|
secretKey,
|
||||||
constructorArgs,
|
constructorArgs,
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import {
|
|||||||
FEATURE_EDITION_REVEALABLE,
|
FEATURE_EDITION_REVEALABLE,
|
||||||
FEATURE_EDITION_SIGNATURE_MINTABLE,
|
FEATURE_EDITION_SIGNATURE_MINTABLE,
|
||||||
FEATURE_EDITION_CLAIM_PHASES_V1,
|
FEATURE_EDITION_CLAIM_PHASES_V1,
|
||||||
|
FEATURE_EDITION_UPDATABLE_METADATA,
|
||||||
|
FEATURE_EDITION_SUPPLY,
|
||||||
} from "./erc1155-features";
|
} from "./erc1155-features";
|
||||||
import {
|
import {
|
||||||
FEATURE_METADATA,
|
FEATURE_METADATA,
|
||||||
@@ -64,7 +66,10 @@ import {
|
|||||||
FEATURE_DIRECT_LISTINGS,
|
FEATURE_DIRECT_LISTINGS,
|
||||||
FEATURE_ENGLISH_AUCTIONS,
|
FEATURE_ENGLISH_AUCTIONS,
|
||||||
FEATURE_OFFERS,
|
FEATURE_OFFERS,
|
||||||
FEATURE_EXTENSION_ROUTER,
|
FEATURE_DYNAMIC_CONTRACT,
|
||||||
|
FEATURE_AIRDROP_ERC20,
|
||||||
|
FEATURE_AIRDROP_ERC721,
|
||||||
|
FEATURE_AIRDROP_ERC1155,
|
||||||
FEATURE_ACCOUNT,
|
FEATURE_ACCOUNT,
|
||||||
FEATURE_ACCOUNT_FACTORY,
|
FEATURE_ACCOUNT_FACTORY,
|
||||||
FEATURE_ACCOUNT_PERMISSIONS,
|
FEATURE_ACCOUNT_PERMISSIONS,
|
||||||
@@ -119,6 +124,8 @@ export type Feature =
|
|||||||
| typeof FEATURE_EDITION_BATCH_MINTABLE
|
| typeof FEATURE_EDITION_BATCH_MINTABLE
|
||||||
| typeof FEATURE_EDITION_BURNABLE
|
| typeof FEATURE_EDITION_BURNABLE
|
||||||
| typeof FEATURE_EDITION_SIGNATURE_MINTABLE
|
| typeof FEATURE_EDITION_SIGNATURE_MINTABLE
|
||||||
|
| typeof FEATURE_EDITION_UPDATABLE_METADATA
|
||||||
|
| typeof FEATURE_EDITION_SUPPLY
|
||||||
| typeof FEATURE_ROYALTY
|
| typeof FEATURE_ROYALTY
|
||||||
| typeof FEATURE_PLATFORM_FEE
|
| typeof FEATURE_PLATFORM_FEE
|
||||||
| typeof FEATURE_PRIMARY_SALE
|
| typeof FEATURE_PRIMARY_SALE
|
||||||
@@ -130,10 +137,13 @@ export type Feature =
|
|||||||
| typeof FEATURE_GASLESS
|
| typeof FEATURE_GASLESS
|
||||||
| typeof FEATURE_PACK_VRF
|
| typeof FEATURE_PACK_VRF
|
||||||
| typeof FEATURE_PLUGIN_ROUTER
|
| typeof FEATURE_PLUGIN_ROUTER
|
||||||
| typeof FEATURE_EXTENSION_ROUTER
|
| typeof FEATURE_DYNAMIC_CONTRACT
|
||||||
| typeof FEATURE_DIRECT_LISTINGS
|
| typeof FEATURE_DIRECT_LISTINGS
|
||||||
| typeof FEATURE_ENGLISH_AUCTIONS
|
| typeof FEATURE_ENGLISH_AUCTIONS
|
||||||
| typeof FEATURE_OFFERS
|
| typeof FEATURE_OFFERS
|
||||||
|
| typeof FEATURE_AIRDROP_ERC20
|
||||||
|
| typeof FEATURE_AIRDROP_ERC721
|
||||||
|
| typeof FEATURE_AIRDROP_ERC1155
|
||||||
| typeof FEATURE_ACCOUNT
|
| typeof FEATURE_ACCOUNT
|
||||||
| typeof FEATURE_ACCOUNT_PERMISSIONS
|
| typeof FEATURE_ACCOUNT_PERMISSIONS
|
||||||
| typeof FEATURE_ACCOUNT_FACTORY;
|
| typeof FEATURE_ACCOUNT_FACTORY;
|
||||||
@@ -174,10 +184,13 @@ export const SUPPORTED_FEATURES: Record<string, Feature> = /* @__PURE__ */ {
|
|||||||
[FEATURE_GASLESS.name]: FEATURE_GASLESS,
|
[FEATURE_GASLESS.name]: FEATURE_GASLESS,
|
||||||
[FEATURE_PACK_VRF.name]: FEATURE_PACK_VRF,
|
[FEATURE_PACK_VRF.name]: FEATURE_PACK_VRF,
|
||||||
[FEATURE_PLUGIN_ROUTER.name]: FEATURE_PLUGIN_ROUTER,
|
[FEATURE_PLUGIN_ROUTER.name]: FEATURE_PLUGIN_ROUTER,
|
||||||
[FEATURE_EXTENSION_ROUTER.name]: FEATURE_EXTENSION_ROUTER,
|
[FEATURE_DYNAMIC_CONTRACT.name]: FEATURE_DYNAMIC_CONTRACT,
|
||||||
[FEATURE_DIRECT_LISTINGS.name]: FEATURE_DIRECT_LISTINGS,
|
[FEATURE_DIRECT_LISTINGS.name]: FEATURE_DIRECT_LISTINGS,
|
||||||
[FEATURE_ENGLISH_AUCTIONS.name]: FEATURE_ENGLISH_AUCTIONS,
|
[FEATURE_ENGLISH_AUCTIONS.name]: FEATURE_ENGLISH_AUCTIONS,
|
||||||
[FEATURE_OFFERS.name]: FEATURE_OFFERS,
|
[FEATURE_OFFERS.name]: FEATURE_OFFERS,
|
||||||
|
[FEATURE_AIRDROP_ERC20.name]: FEATURE_AIRDROP_ERC20,
|
||||||
|
[FEATURE_AIRDROP_ERC721.name]: FEATURE_AIRDROP_ERC721,
|
||||||
|
[FEATURE_AIRDROP_ERC1155.name]: FEATURE_AIRDROP_ERC1155,
|
||||||
[FEATURE_ACCOUNT_FACTORY.name]: FEATURE_ACCOUNT_FACTORY,
|
[FEATURE_ACCOUNT_FACTORY.name]: FEATURE_ACCOUNT_FACTORY,
|
||||||
[FEATURE_ACCOUNT.name]: FEATURE_ACCOUNT,
|
[FEATURE_ACCOUNT.name]: FEATURE_ACCOUNT,
|
||||||
[FEATURE_NFT_LOYALTY_CARD.name]: FEATURE_NFT_LOYALTY_CARD,
|
[FEATURE_NFT_LOYALTY_CARD.name]: FEATURE_NFT_LOYALTY_CARD,
|
||||||
|
|||||||
@@ -6,11 +6,44 @@ import DropERC1155_V2Abi from "@thirdweb-dev/contracts-js/dist/abis/IDropERC1155
|
|||||||
import IDropSinglePhase1155 from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase1155.json";
|
import IDropSinglePhase1155 from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase1155.json";
|
||||||
import IDropSinglePhase1155_V1 from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase1155_V1.json";
|
import IDropSinglePhase1155_V1 from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase1155_V1.json";
|
||||||
import Erc1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155.json";
|
import Erc1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155.json";
|
||||||
|
import Erc1155MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Metadata.json";
|
||||||
|
import Erc1155SupplyAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Supply.json";
|
||||||
import Erc1155EnumerableAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Enumerable.json";
|
import Erc1155EnumerableAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Enumerable.json";
|
||||||
import ILazyMintAbi from "@thirdweb-dev/contracts-js/dist/abis/ILazyMint.json";
|
import ILazyMintAbi from "@thirdweb-dev/contracts-js/dist/abis/ILazyMint.json";
|
||||||
import IMintableERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC1155.json";
|
import IMintableERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC1155.json";
|
||||||
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
||||||
import ISignatureMintERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC1155.json";
|
import ISignatureMintERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC1155.json";
|
||||||
|
import INFTMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/INFTMetadata.json";
|
||||||
|
|
||||||
|
// TODO could be part of IERC1155Metadata even though its not in the spec
|
||||||
|
const NAME_SYMBOL_ABI = [
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "name",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "string",
|
||||||
|
name: "",
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "symbol",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "string",
|
||||||
|
name: "",
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const FEATURE_EDITION_BURNABLE = {
|
export const FEATURE_EDITION_BURNABLE = {
|
||||||
name: "ERC1155Burnable",
|
name: "ERC1155Burnable",
|
||||||
@@ -172,6 +205,29 @@ export const FEATURE_EDITION_ENUMERABLE = {
|
|||||||
features: {},
|
features: {},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_EDITION_UPDATABLE_METADATA = {
|
||||||
|
name: "ERC1155UpdatableMetadata",
|
||||||
|
namespace: "edition.metadata",
|
||||||
|
docLinks: {
|
||||||
|
// TODO
|
||||||
|
sdk: "",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [Erc1155Abi, INFTMetadataAbi],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_EDITION_SUPPLY = {
|
||||||
|
name: "ERC1155Supply",
|
||||||
|
namespace: "edition.supply",
|
||||||
|
docLinks: {
|
||||||
|
sdk: "",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [Erc1155Abi, Erc1155SupplyAbi],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const FEATURE_EDITION = /* @__PURE__ */ {
|
export const FEATURE_EDITION = /* @__PURE__ */ {
|
||||||
name: "ERC1155",
|
name: "ERC1155",
|
||||||
namespace: "edition",
|
namespace: "edition",
|
||||||
@@ -179,8 +235,9 @@ export const FEATURE_EDITION = /* @__PURE__ */ {
|
|||||||
sdk: "sdk.erc1155enumerable",
|
sdk: "sdk.erc1155enumerable",
|
||||||
contracts: "erc1155",
|
contracts: "erc1155",
|
||||||
},
|
},
|
||||||
abis: [Erc1155Abi],
|
abis: [Erc1155Abi, Erc1155MetadataAbi, NAME_SYMBOL_ABI],
|
||||||
features: {
|
features: {
|
||||||
|
[FEATURE_EDITION_SUPPLY.name]: FEATURE_EDITION_SUPPLY,
|
||||||
[FEATURE_EDITION_BURNABLE.name]: FEATURE_EDITION_BURNABLE,
|
[FEATURE_EDITION_BURNABLE.name]: FEATURE_EDITION_BURNABLE,
|
||||||
[FEATURE_EDITION_ENUMERABLE.name]: FEATURE_EDITION_ENUMERABLE,
|
[FEATURE_EDITION_ENUMERABLE.name]: FEATURE_EDITION_ENUMERABLE,
|
||||||
[FEATURE_EDITION_MINTABLE.name]: FEATURE_EDITION_MINTABLE,
|
[FEATURE_EDITION_MINTABLE.name]: FEATURE_EDITION_MINTABLE,
|
||||||
@@ -195,5 +252,7 @@ export const FEATURE_EDITION = /* @__PURE__ */ {
|
|||||||
[FEATURE_EDITION_CLAIM_CONDITIONS_V2.name]:
|
[FEATURE_EDITION_CLAIM_CONDITIONS_V2.name]:
|
||||||
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
||||||
[FEATURE_EDITION_CLAIM_PHASES_V2.name]: FEATURE_EDITION_CLAIM_PHASES_V2,
|
[FEATURE_EDITION_CLAIM_PHASES_V2.name]: FEATURE_EDITION_CLAIM_PHASES_V2,
|
||||||
|
[FEATURE_EDITION_UPDATABLE_METADATA.name]:
|
||||||
|
FEATURE_EDITION_UPDATABLE_METADATA,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import IERC20PermitAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC20Permit.j
|
|||||||
import IMintableERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC20.json";
|
import IMintableERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC20.json";
|
||||||
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
||||||
import ISignatureMintERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC20.json";
|
import ISignatureMintERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC20.json";
|
||||||
|
import IERC20MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC20Metadata.json";
|
||||||
|
|
||||||
export const FEATURE_TOKEN_CLAIM_CONDITIONS_V1 = {
|
export const FEATURE_TOKEN_CLAIM_CONDITIONS_V1 = {
|
||||||
name: "ERC20ClaimConditionsV1",
|
name: "ERC20ClaimConditionsV1",
|
||||||
@@ -117,7 +118,7 @@ export const FEATURE_TOKEN = /* @__PURE__ */ {
|
|||||||
sdk: "sdk.erc20",
|
sdk: "sdk.erc20",
|
||||||
contracts: "erc20",
|
contracts: "erc20",
|
||||||
},
|
},
|
||||||
abis: [ERC20Abi],
|
abis: [ERC20Abi, IERC20MetadataAbi],
|
||||||
features: {
|
features: {
|
||||||
[FEATURE_TOKEN_BURNABLE.name]: FEATURE_TOKEN_BURNABLE,
|
[FEATURE_TOKEN_BURNABLE.name]: FEATURE_TOKEN_BURNABLE,
|
||||||
[FEATURE_TOKEN_MINTABLE.name]: FEATURE_TOKEN_MINTABLE,
|
[FEATURE_TOKEN_MINTABLE.name]: FEATURE_TOKEN_MINTABLE,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import SharedMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/SharedMetada
|
|||||||
import zora_IDropERC721 from "@thirdweb-dev/contracts-js/dist/abis/zora_IERC721Drop.json";
|
import zora_IDropERC721 from "@thirdweb-dev/contracts-js/dist/abis/zora_IERC721Drop.json";
|
||||||
import ILoyaltyCardAbi from "@thirdweb-dev/contracts-js/dist/abis/ILoyaltyCard.json";
|
import ILoyaltyCardAbi from "@thirdweb-dev/contracts-js/dist/abis/ILoyaltyCard.json";
|
||||||
import INFTMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/INFTMetadata.json";
|
import INFTMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/INFTMetadata.json";
|
||||||
|
import IERC721MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC721Metadata.json";
|
||||||
|
|
||||||
export const FEATURE_NFT_BURNABLE = {
|
export const FEATURE_NFT_BURNABLE = {
|
||||||
name: "ERC721Burnable",
|
name: "ERC721Burnable",
|
||||||
@@ -246,7 +247,7 @@ export const FEATURE_NFT_UPDATABLE_METADATA = {
|
|||||||
sdk: "",
|
sdk: "",
|
||||||
contracts: "",
|
contracts: "",
|
||||||
},
|
},
|
||||||
abis: [INFTMetadataAbi],
|
abis: [Erc721Abi, INFTMetadataAbi],
|
||||||
features: {},
|
features: {},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
@@ -257,7 +258,7 @@ export const FEATURE_NFT = /* @__PURE__ */ {
|
|||||||
sdk: "sdk.erc721",
|
sdk: "sdk.erc721",
|
||||||
contracts: "erc721",
|
contracts: "erc721",
|
||||||
},
|
},
|
||||||
abis: [Erc721Abi],
|
abis: [Erc721Abi, IERC721MetadataAbi],
|
||||||
features: {
|
features: {
|
||||||
[FEATURE_NFT_BURNABLE.name]: FEATURE_NFT_BURNABLE,
|
[FEATURE_NFT_BURNABLE.name]: FEATURE_NFT_BURNABLE,
|
||||||
[FEATURE_NFT_SUPPLY.name]: FEATURE_NFT_SUPPLY,
|
[FEATURE_NFT_SUPPLY.name]: FEATURE_NFT_SUPPLY,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import IERC2771ContextAbi from "@thirdweb-dev/contracts-js/dist/abis/ERC2771Context.json";
|
import IERC2771ContextAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC2771Context.json";
|
||||||
import IAppURI from "@thirdweb-dev/contracts-js/dist/abis/IAppURI.json";
|
import IAppURI from "@thirdweb-dev/contracts-js/dist/abis/IAppURI.json";
|
||||||
import IContractMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IContractMetadata.json";
|
import IContractMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IContractMetadata.json";
|
||||||
import IDirectListingsAbi from "@thirdweb-dev/contracts-js/dist/abis/IDirectListings.json";
|
import IDirectListingsAbi from "@thirdweb-dev/contracts-js/dist/abis/IDirectListings.json";
|
||||||
@@ -11,6 +11,9 @@ import IThirdwebPlatformFeeAbi from "@thirdweb-dev/contracts-js/dist/abis/IPlatf
|
|||||||
import IThirdwebPrimarySaleAbi from "@thirdweb-dev/contracts-js/dist/abis/IPrimarySale.json";
|
import IThirdwebPrimarySaleAbi from "@thirdweb-dev/contracts-js/dist/abis/IPrimarySale.json";
|
||||||
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 IAirdropERC20 from "@thirdweb-dev/contracts-js/dist/abis/IAirdropERC20.json";
|
||||||
|
import IAirdropERC721 from "@thirdweb-dev/contracts-js/dist/abis/IAirdropERC721.json";
|
||||||
|
import IAirdropERC1155 from "@thirdweb-dev/contracts-js/dist/abis/IAirdropERC1155.json";
|
||||||
import IAccountFactory from "@thirdweb-dev/contracts-js/dist/abis/IAccountFactory.json";
|
import IAccountFactory from "@thirdweb-dev/contracts-js/dist/abis/IAccountFactory.json";
|
||||||
import IAccountPermissions from "@thirdweb-dev/contracts-js/dist/abis/IAccountPermissions.json";
|
import IAccountPermissions from "@thirdweb-dev/contracts-js/dist/abis/IAccountPermissions.json";
|
||||||
import IAccount from "@thirdweb-dev/contracts-js/dist/abis/IAccount.json";
|
import IAccount from "@thirdweb-dev/contracts-js/dist/abis/IAccount.json";
|
||||||
@@ -232,9 +235,9 @@ export const FEATURE_PLUGIN_ROUTER = {
|
|||||||
features: {},
|
features: {},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const FEATURE_EXTENSION_ROUTER = {
|
export const FEATURE_DYNAMIC_CONTRACT = {
|
||||||
name: "ExtensionRouter",
|
name: "DynamicContract",
|
||||||
namespace: "extension.router",
|
namespace: "dynamic.contract",
|
||||||
docLinks: {
|
docLinks: {
|
||||||
sdk: "",
|
sdk: "",
|
||||||
//TODO
|
//TODO
|
||||||
@@ -315,3 +318,39 @@ export const FEATURE_ACCOUNT = {
|
|||||||
abis: [IAccount],
|
abis: [IAccount],
|
||||||
features: { [FEATURE_ACCOUNT_PERMISSIONS.name]: FEATURE_ACCOUNT_PERMISSIONS },
|
features: { [FEATURE_ACCOUNT_PERMISSIONS.name]: FEATURE_ACCOUNT_PERMISSIONS },
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_AIRDROP_ERC20 = {
|
||||||
|
name: "AirdropERC20",
|
||||||
|
namespace: "airdrop20",
|
||||||
|
docLinks: {
|
||||||
|
// TODO
|
||||||
|
sdk: "",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [IAirdropERC20],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_AIRDROP_ERC721 = {
|
||||||
|
name: "AirdropERC721",
|
||||||
|
namespace: "airdrop721",
|
||||||
|
docLinks: {
|
||||||
|
// TODO
|
||||||
|
sdk: "",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [IAirdropERC721],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const FEATURE_AIRDROP_ERC1155 = {
|
||||||
|
name: "AirdropERC1155",
|
||||||
|
namespace: "airdrop1155",
|
||||||
|
docLinks: {
|
||||||
|
// TODO
|
||||||
|
sdk: "",
|
||||||
|
contracts: "",
|
||||||
|
},
|
||||||
|
abis: [IAirdropERC1155],
|
||||||
|
features: {},
|
||||||
|
} as const;
|
||||||
|
|||||||
@@ -41,8 +41,11 @@ export function getChainProvider(
|
|||||||
// Add the chain to the supportedChains
|
// Add the chain to the supportedChains
|
||||||
const options = SDKOptionsSchema.parse(sdkOptions);
|
const options = SDKOptionsSchema.parse(sdkOptions);
|
||||||
if (isChainConfig(network)) {
|
if (isChainConfig(network)) {
|
||||||
// @ts-expect-error - we know this is a chain and it will work to build the map
|
options.supportedChains = [
|
||||||
options.supportedChains = [network, ...options.supportedChains];
|
// @ts-expect-error - we know this is a chain and it will work to build the map
|
||||||
|
network,
|
||||||
|
...options.supportedChains.filter((c) => c.chainId !== network.chainId),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a map of chainId -> ChainInfo based on the supportedChains
|
// Build a map of chainId -> ChainInfo based on the supportedChains
|
||||||
@@ -105,10 +108,35 @@ export function getChainIdFromNetwork(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getChainIdOrName(
|
||||||
|
network: NetworkInput,
|
||||||
|
): Promise<number | string> {
|
||||||
|
if (isChainConfig(network)) {
|
||||||
|
// If it's a chain just return the chain id
|
||||||
|
return network.chainId;
|
||||||
|
} else if (typeof network === "number") {
|
||||||
|
// If it's a number (chainId) return it directly
|
||||||
|
return network;
|
||||||
|
} else if (typeof network === "number") {
|
||||||
|
// If it's a string (chain name) return the chain id from the map
|
||||||
|
return network;
|
||||||
|
} else if (isProvider(network)) {
|
||||||
|
return network.getNetwork().then((n) => n.chainId);
|
||||||
|
} else if (isSigner(network)) {
|
||||||
|
if (!network.provider) {
|
||||||
|
throw new Error("Signer does not have a provider");
|
||||||
|
}
|
||||||
|
return network.provider.getNetwork().then((n) => n.chainId);
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot resolve chainId from: ${network}.`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a NetworkInput value is a Chain config (naively, without parsing)
|
* Check whether a NetworkInput value is a Chain config (naively, without parsing)
|
||||||
*/
|
*/
|
||||||
export function isChainConfig(network: NetworkInput): network is Chain {
|
export function isChainConfig(
|
||||||
|
network: NetworkInput,
|
||||||
|
): network is Chain | ChainInfo {
|
||||||
return (
|
return (
|
||||||
typeof network !== "string" &&
|
typeof network !== "string" &&
|
||||||
typeof network !== "number" &&
|
typeof network !== "number" &&
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { fetchAndCachePublishedContractURI } from "../common/any-evm-utils/fetchAndCachePublishedContractURI";
|
import {
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
fetchPublishedContractFromPolygon,
|
||||||
|
} from "../common/any-evm-utils/fetchPublishedContractFromPolygon";
|
||||||
import { getPrebuiltInfo } from "../common/legacy";
|
import { getPrebuiltInfo } from "../common/legacy";
|
||||||
import { fetchAbiFromAddress } from "../common/metadata-resolver";
|
import { fetchAbiFromAddress } from "../common/metadata-resolver";
|
||||||
import { ALL_ROLES } from "../common/role";
|
import { ALL_ROLES } from "../common/role";
|
||||||
@@ -194,7 +197,7 @@ export const MarketplaceV3Initializer = {
|
|||||||
) => {
|
) => {
|
||||||
const [, provider] = getSignerAndProvider(network, options);
|
const [, provider] = getSignerAndProvider(network, options);
|
||||||
const [abi, contract, _network] = await Promise.all([
|
const [abi, contract, _network] = await Promise.all([
|
||||||
MarketplaceV3Initializer.getAbi(address, provider, storage),
|
MarketplaceV3Initializer.getAbi(address, provider, storage, options),
|
||||||
import("./prebuilt-implementations/marketplacev3"),
|
import("./prebuilt-implementations/marketplacev3"),
|
||||||
provider.getNetwork(),
|
provider.getNetwork(),
|
||||||
]);
|
]);
|
||||||
@@ -212,6 +215,7 @@ export const MarketplaceV3Initializer = {
|
|||||||
address: Address,
|
address: Address,
|
||||||
provider: providers.Provider,
|
provider: providers.Provider,
|
||||||
storage: ThirdwebStorage,
|
storage: ThirdwebStorage,
|
||||||
|
options?: SDKOptions,
|
||||||
) => {
|
) => {
|
||||||
const chainId = (await provider.getNetwork()).chainId;
|
const chainId = (await provider.getNetwork()).chainId;
|
||||||
const isZkSync = chainId === 280 || chainId === 324;
|
const isZkSync = chainId === 280 || chainId === 324;
|
||||||
@@ -219,7 +223,15 @@ export const MarketplaceV3Initializer = {
|
|||||||
// Can't resolve IPFS hash from plugin bytecode on ZkSync
|
// Can't resolve IPFS hash from plugin bytecode on ZkSync
|
||||||
// Thus, pull the composite ABI from the release page
|
// Thus, pull the composite ABI from the release page
|
||||||
if (isZkSync) {
|
if (isZkSync) {
|
||||||
const uri = await fetchAndCachePublishedContractURI("MarketplaceV3");
|
const publishedContract = await fetchPublishedContractFromPolygon(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
"MarketplaceV3",
|
||||||
|
"latest",
|
||||||
|
storage,
|
||||||
|
options?.clientId,
|
||||||
|
options?.secretKey,
|
||||||
|
);
|
||||||
|
const uri = publishedContract.metadataUri;
|
||||||
const compositeAbi = await getCompositeABIfromRelease(uri, storage);
|
const compositeAbi = await getCompositeABIfromRelease(uri, storage);
|
||||||
|
|
||||||
return compositeAbi;
|
return compositeAbi;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { FEATURE_TOKEN } from "../constants/erc20-features";
|
|||||||
import { FEATURE_NFT } from "../constants/erc721-features";
|
import { FEATURE_NFT } from "../constants/erc721-features";
|
||||||
import { FEATURE_EDITION } from "../constants/erc1155-features";
|
import { FEATURE_EDITION } from "../constants/erc1155-features";
|
||||||
import {
|
import {
|
||||||
|
FEATURE_AIRDROP_ERC20,
|
||||||
|
FEATURE_AIRDROP_ERC721,
|
||||||
|
FEATURE_AIRDROP_ERC1155,
|
||||||
FEATURE_APPURI,
|
FEATURE_APPURI,
|
||||||
FEATURE_DIRECT_LISTINGS,
|
FEATURE_DIRECT_LISTINGS,
|
||||||
FEATURE_ENGLISH_AUCTIONS,
|
FEATURE_ENGLISH_AUCTIONS,
|
||||||
@@ -53,13 +56,15 @@ import type {
|
|||||||
DirectListingsLogic,
|
DirectListingsLogic,
|
||||||
EnglishAuctionsLogic,
|
EnglishAuctionsLogic,
|
||||||
OffersLogic,
|
OffersLogic,
|
||||||
|
AirdropERC20,
|
||||||
IAccountFactory,
|
IAccountFactory,
|
||||||
IAccountCore,
|
IAccountCore,
|
||||||
|
AirdropERC721,
|
||||||
|
AirdropERC1155,
|
||||||
} from "@thirdweb-dev/contracts-js";
|
} from "@thirdweb-dev/contracts-js";
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import { BaseContract, CallOverrides } from "ethers";
|
import { BaseContract, CallOverrides } from "ethers";
|
||||||
import { BaseContractInterface } from "../types/contract";
|
import { BaseContractInterface } from "../types/contract";
|
||||||
|
|
||||||
import { NetworkInput } from "../core/types";
|
import { NetworkInput } from "../core/types";
|
||||||
import { ContractEncoder } from "../core/classes/contract-encoder";
|
import { ContractEncoder } from "../core/classes/contract-encoder";
|
||||||
import { ContractOwner } from "../core/classes/contract-owner";
|
import { ContractOwner } from "../core/classes/contract-owner";
|
||||||
@@ -68,6 +73,9 @@ import { MarketplaceV3EnglishAuctions } from "../core/classes/marketplacev3-engl
|
|||||||
import { MarketplaceV3Offers } from "../core/classes/marketplacev3-offers";
|
import { MarketplaceV3Offers } from "../core/classes/marketplacev3-offers";
|
||||||
import { AccountFactory } from "../core/classes/account-factory";
|
import { AccountFactory } from "../core/classes/account-factory";
|
||||||
import { Account } from "../core/classes/account";
|
import { Account } from "../core/classes/account";
|
||||||
|
import { Airdrop20 } from "../core/classes/airdrop-erc20";
|
||||||
|
import { Airdrop721 } from "../core/classes/airdrop-erc721";
|
||||||
|
import { Airdrop1155 } from "../core/classes/airdrop-erc1155";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom contract dynamic class with feature detection
|
* Custom contract dynamic class with feature detection
|
||||||
@@ -298,6 +306,18 @@ export class SmartContract<
|
|||||||
return assertEnabled(this.detectOffers(), FEATURE_OFFERS);
|
return assertEnabled(this.detectOffers(), FEATURE_OFFERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get airdrop20(): Airdrop20<AirdropERC20> {
|
||||||
|
return assertEnabled(this.detectAirdrop20(), FEATURE_AIRDROP_ERC20);
|
||||||
|
}
|
||||||
|
|
||||||
|
get airdrop721(): Airdrop721<AirdropERC721> {
|
||||||
|
return assertEnabled(this.detectAirdrop721(), FEATURE_AIRDROP_ERC721);
|
||||||
|
}
|
||||||
|
|
||||||
|
get airdrop1155(): Airdrop1155<AirdropERC1155> {
|
||||||
|
return assertEnabled(this.detectAirdrop1155(), FEATURE_AIRDROP_ERC1155);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account Factory
|
* Account Factory
|
||||||
*
|
*
|
||||||
@@ -563,6 +583,33 @@ export class SmartContract<
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private detectAirdrop20() {
|
||||||
|
if (
|
||||||
|
detectContractFeature<AirdropERC20>(this.contractWrapper, "AirdropERC20")
|
||||||
|
) {
|
||||||
|
return new Airdrop20(this.contractWrapper);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private detectAirdrop721() {
|
||||||
|
if (
|
||||||
|
detectContractFeature<AirdropERC721>(this.contractWrapper, "AirdropERC721")
|
||||||
|
) {
|
||||||
|
return new Airdrop721(this.contractWrapper);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
private detectAirdrop1155() {
|
||||||
|
if (
|
||||||
|
detectContractFeature<AirdropERC1155>(this.contractWrapper, "AirdropERC1155")
|
||||||
|
) {
|
||||||
|
return new Airdrop1155(this.contractWrapper);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
// ========== Account features ==========
|
// ========== Account features ==========
|
||||||
|
|
||||||
private detectAccountFactory() {
|
private detectAccountFactory() {
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import { AirdropFailedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/AirdropERC1155";
|
||||||
|
import { buildTransactionFunction } from "../../common/transactions";
|
||||||
|
import { FEATURE_AIRDROP_ERC1155 } from "../../constants/thirdweb-features";
|
||||||
|
import { Address } from "../../schema";
|
||||||
|
import { Airdrop1155Content, Airdrop1155Output } from "../../types";
|
||||||
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import { Transaction } from "./transactions";
|
||||||
|
import type {
|
||||||
|
AirdropERC1155,
|
||||||
|
IAirdropERC1155,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export class Airdrop1155<T extends IAirdropERC1155 | AirdropERC1155>
|
||||||
|
implements DetectableFeature
|
||||||
|
{
|
||||||
|
featureName = FEATURE_AIRDROP_ERC1155.name;
|
||||||
|
protected contractWrapper: ContractWrapper<T>;
|
||||||
|
|
||||||
|
constructor(contractWrapper: ContractWrapper<T>) {
|
||||||
|
this.contractWrapper = contractWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
getAddress(): Address {
|
||||||
|
return this.contractWrapper.readContract.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ******************************
|
||||||
|
* WRITE FUNCTIONS
|
||||||
|
*******************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform airdrop of ERC1155 tokens
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* // Airdrop content array, with recipients and tokenIds
|
||||||
|
* const contents = [
|
||||||
|
* {
|
||||||
|
* recipient: "0xabc...", // first recipient address
|
||||||
|
* tokenId: 0,
|
||||||
|
* amount: "10" // number of tokens
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* recipient: "0x123...", // second recipient address
|
||||||
|
* tokenId: 0
|
||||||
|
* amount: "20" // number of tokens
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* const tokenAddress = "0x..." // Address of the ERC1155 token being airdropped
|
||||||
|
* const tokenOwner = "0x..." // Address of the owner of the tokens being airdropped
|
||||||
|
*
|
||||||
|
* const output = await contract.airdrop1155.drop(tokenAddress, tokenOwner, contents);
|
||||||
|
*
|
||||||
|
* // the `output` return value above contains:
|
||||||
|
* // - count of successful and failed drops
|
||||||
|
* // - array containing failed drops, if any
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @param tokenAddress
|
||||||
|
* @param tokenOwner
|
||||||
|
* @param contents
|
||||||
|
*
|
||||||
|
* @returns an array of recipients for who the airdrop failed (empty means all transfers were successful)
|
||||||
|
* @twfeature AirdropERC1155
|
||||||
|
*/
|
||||||
|
drop = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
tokenAddress: string,
|
||||||
|
tokenOwner: string,
|
||||||
|
contents: Airdrop1155Content[],
|
||||||
|
): Promise<Transaction<Airdrop1155Output>> => {
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "airdrop",
|
||||||
|
args: [tokenAddress, tokenOwner, contents],
|
||||||
|
parse: (receipt) => {
|
||||||
|
const events = this.contractWrapper.parseLogs<AirdropFailedEvent>(
|
||||||
|
"AirdropFailed",
|
||||||
|
receipt.logs,
|
||||||
|
);
|
||||||
|
|
||||||
|
const failedDrops = events.map((e) => {
|
||||||
|
return {
|
||||||
|
recipient: e.args.recipient,
|
||||||
|
tokenId: e.args.tokenId.toNumber(),
|
||||||
|
amount: e.args.amount.toString(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
successfulDropCount: contents.length - failedDrops.length,
|
||||||
|
failedDropCount: failedDrops.length,
|
||||||
|
failedDrops,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import { AirdropFailedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/AirdropERC1155";
|
||||||
|
import { buildTransactionFunction } from "../../common/transactions";
|
||||||
|
import { FEATURE_AIRDROP_ERC20 } from "../../constants/thirdweb-features";
|
||||||
|
import { Address } from "../../schema";
|
||||||
|
import { Airdrop20Content, Airdrop20Output } from "../../types";
|
||||||
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import { Transaction } from "./transactions";
|
||||||
|
import type { IAirdropERC20, AirdropERC20 } from "@thirdweb-dev/contracts-js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export class Airdrop20<T extends IAirdropERC20 | AirdropERC20>
|
||||||
|
implements DetectableFeature
|
||||||
|
{
|
||||||
|
featureName = FEATURE_AIRDROP_ERC20.name;
|
||||||
|
protected contractWrapper: ContractWrapper<T>;
|
||||||
|
|
||||||
|
constructor(contractWrapper: ContractWrapper<T>) {
|
||||||
|
this.contractWrapper = contractWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
getAddress(): Address {
|
||||||
|
return this.contractWrapper.readContract.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ******************************
|
||||||
|
* WRITE FUNCTIONS
|
||||||
|
*******************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform airdrop of ERC20 tokens
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* // Airdrop content array, with recipients and token amounts
|
||||||
|
* const contents = [
|
||||||
|
* {
|
||||||
|
* recipient: "0xabc...", // first recipient address
|
||||||
|
* amount: "10" // number of tokens in wei units
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* recipient: "0x123...", // second recipient address
|
||||||
|
* amount: "20" // number of tokens in wei units
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* const tokenAddress = "0x..." // Address of the ERC20 token being airdropped
|
||||||
|
* const tokenOwner = "0x..." // Address of the owner of the tokens being airdropped
|
||||||
|
*
|
||||||
|
* const output = await contract.airdrop20.drop(tokenAddress, tokenOwner, contents);
|
||||||
|
*
|
||||||
|
* // the `output` return value above contains:
|
||||||
|
* // - count of successful and failed drops
|
||||||
|
* // - array containing failed drops, if any
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @param tokenAddress
|
||||||
|
* @param tokenOwner
|
||||||
|
* @param contents
|
||||||
|
*
|
||||||
|
* @returns an array of recipients for who the airdrop failed (empty means all transfers were successful)
|
||||||
|
* @twfeature AirdropERC20
|
||||||
|
*/
|
||||||
|
drop = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
tokenAddress: string,
|
||||||
|
tokenOwner: string,
|
||||||
|
contents: Airdrop20Content[],
|
||||||
|
): Promise<Transaction<Airdrop20Output>> => {
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "airdrop",
|
||||||
|
args: [tokenAddress, tokenOwner, contents],
|
||||||
|
parse: (receipt) => {
|
||||||
|
const events = this.contractWrapper.parseLogs<AirdropFailedEvent>(
|
||||||
|
"AirdropFailed",
|
||||||
|
receipt.logs,
|
||||||
|
);
|
||||||
|
|
||||||
|
const failedDrops = events.map((e) => {
|
||||||
|
return {
|
||||||
|
recipient: e.args.recipient,
|
||||||
|
amount: e.args.amount.toString(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
successfulDropCount: contents.length - failedDrops.length,
|
||||||
|
failedDropCount: failedDrops.length,
|
||||||
|
failedDrops,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { AirdropFailedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/AirdropERC1155";
|
||||||
|
import { buildTransactionFunction } from "../../common/transactions";
|
||||||
|
import { FEATURE_AIRDROP_ERC721 } from "../../constants/thirdweb-features";
|
||||||
|
import { Address } from "../../schema";
|
||||||
|
import { Airdrop721Content, Airdrop721Output } from "../../types";
|
||||||
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import { Transaction } from "./transactions";
|
||||||
|
import type { AirdropERC721, IAirdropERC721 } from "@thirdweb-dev/contracts-js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export class Airdrop721<T extends IAirdropERC721 | AirdropERC721>
|
||||||
|
implements DetectableFeature
|
||||||
|
{
|
||||||
|
featureName = FEATURE_AIRDROP_ERC721.name;
|
||||||
|
protected contractWrapper: ContractWrapper<T>;
|
||||||
|
|
||||||
|
constructor(contractWrapper: ContractWrapper<T>) {
|
||||||
|
this.contractWrapper = contractWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
getAddress(): Address {
|
||||||
|
return this.contractWrapper.readContract.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ******************************
|
||||||
|
* WRITE FUNCTIONS
|
||||||
|
*******************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform airdrop of ERC721 tokens
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* // Airdrop content array, with recipients and tokenIds
|
||||||
|
* const contents = [
|
||||||
|
* {
|
||||||
|
* recipient: "0xabc...", // first recipient address
|
||||||
|
* tokenId: 0
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* recipient: "0x123...", // second recipient address
|
||||||
|
* tokenId: 2
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* const tokenAddress = "0x..." // Address of the ERC721 token being airdropped
|
||||||
|
* const tokenOwner = "0x..." // Address of the owner of the tokens being airdropped
|
||||||
|
*
|
||||||
|
* const output = await contract.airdrop721.drop(tokenAddress, tokenOwner, contents);
|
||||||
|
*
|
||||||
|
* // the `output` return value above contains:
|
||||||
|
* // - count of successful and failed drops
|
||||||
|
* // - array containing failed drops, if any
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @param tokenAddress
|
||||||
|
* @param tokenOwner
|
||||||
|
* @param contents
|
||||||
|
*
|
||||||
|
* @returns an array of recipients for who the airdrop failed (empty means all transfers were successful)
|
||||||
|
* @twfeature AirdropERC721
|
||||||
|
*/
|
||||||
|
drop = /* @__PURE__ */ buildTransactionFunction(
|
||||||
|
async (
|
||||||
|
tokenAddress: string,
|
||||||
|
tokenOwner: string,
|
||||||
|
contents: Airdrop721Content[],
|
||||||
|
): Promise<Transaction<Airdrop721Output>> => {
|
||||||
|
return Transaction.fromContractWrapper({
|
||||||
|
contractWrapper: this.contractWrapper,
|
||||||
|
method: "airdrop",
|
||||||
|
args: [tokenAddress, tokenOwner, contents],
|
||||||
|
parse: (receipt) => {
|
||||||
|
const events = this.contractWrapper.parseLogs<AirdropFailedEvent>(
|
||||||
|
"AirdropFailed",
|
||||||
|
receipt.logs,
|
||||||
|
);
|
||||||
|
const failedDrops = events.map((e) => {
|
||||||
|
return {
|
||||||
|
recipient: e.args.recipient,
|
||||||
|
tokenId: e.args.tokenId.toNumber(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
successfulDropCount: contents.length - failedDrops.length,
|
||||||
|
failedDropCount: failedDrops.length,
|
||||||
|
failedDrops,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,11 +8,9 @@ import { resolveContractUriFromAddress } from "../../common/feature-detection/re
|
|||||||
import { fetchContractMetadataFromAddress } from "../../common/metadata-resolver";
|
import { fetchContractMetadataFromAddress } from "../../common/metadata-resolver";
|
||||||
import { fetchContractMetadata } from "../../common/fetchContractMetadata";
|
import { fetchContractMetadata } from "../../common/fetchContractMetadata";
|
||||||
import { fetchSourceFilesFromMetadata } from "../../common/fetchSourceFilesFromMetadata";
|
import { fetchSourceFilesFromMetadata } from "../../common/fetchSourceFilesFromMetadata";
|
||||||
import { getCompositePluginABI } from "../../common/plugin/getCompositePluginABI";
|
|
||||||
import { buildTransactionFunction } from "../../common/transactions";
|
import { buildTransactionFunction } from "../../common/transactions";
|
||||||
import { isIncrementalVersion } from "../../common/version-checker";
|
import { isIncrementalVersion } from "../../common/version-checker";
|
||||||
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
|
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
|
||||||
import { getChainProvider } from "../../constants/urls";
|
|
||||||
import {
|
import {
|
||||||
AbiFunction,
|
AbiFunction,
|
||||||
AbiSchema,
|
AbiSchema,
|
||||||
@@ -44,6 +42,12 @@ import { ContractPublishedEvent } from "@thirdweb-dev/contracts-js/dist/declarat
|
|||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import { constants, utils } from "ethers";
|
import { constants, utils } from "ethers";
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
|
import {
|
||||||
|
fetchAndCacheDeployMetadata,
|
||||||
|
fetchPublishedContractFromPolygon,
|
||||||
|
isFeatureEnabled,
|
||||||
|
} from "../../common";
|
||||||
|
import { joinABIs } from "../../common/plugin/joinABIs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles publishing contracts (EXPERIMENTAL)
|
* Handles publishing contracts (EXPERIMENTAL)
|
||||||
@@ -369,34 +373,59 @@ export class ContractPublisher extends RPCConnectionHandler {
|
|||||||
this.storage,
|
this.storage,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const compilerMetadata = await fetchContractMetadata(
|
||||||
|
predeployMetadata.metadataUri,
|
||||||
|
this.storage,
|
||||||
|
);
|
||||||
|
const isPlugin = isFeatureEnabled(
|
||||||
|
AbiSchema.parse(compilerMetadata.abi),
|
||||||
|
"PluginRouter",
|
||||||
|
);
|
||||||
|
const isDynamic = isFeatureEnabled(
|
||||||
|
AbiSchema.parse(compilerMetadata.abi),
|
||||||
|
"DynamicContract",
|
||||||
|
);
|
||||||
|
extraMetadata.routerType = isPlugin
|
||||||
|
? "plugin"
|
||||||
|
: isDynamic
|
||||||
|
? "dynamic"
|
||||||
|
: "none";
|
||||||
|
|
||||||
// For a dynamic contract Router, try to fetch plugin/extension metadata
|
// For a dynamic contract Router, try to fetch plugin/extension metadata
|
||||||
// from the implementation addresses, if any
|
if (isDynamic || isPlugin) {
|
||||||
if (extraMetadata.factoryDeploymentData?.implementationAddresses) {
|
const defaultExtensions = extraMetadata.defaultExtensions;
|
||||||
const implementationsAddresses = Object.entries(
|
|
||||||
extraMetadata.factoryDeploymentData.implementationAddresses,
|
|
||||||
);
|
|
||||||
|
|
||||||
const entry = implementationsAddresses.find(
|
if (defaultExtensions && defaultExtensions.length > 0) {
|
||||||
([, implementation]) => implementation !== "",
|
|
||||||
);
|
|
||||||
const [network, implementation] = entry ? entry : [];
|
|
||||||
|
|
||||||
if (network && implementation) {
|
|
||||||
try {
|
try {
|
||||||
const compilerMetadata = await fetchContractMetadata(
|
const publishedExtensions = await Promise.all(
|
||||||
predeployMetadata.metadataUri,
|
defaultExtensions.map((e) => {
|
||||||
this.storage,
|
return fetchPublishedContractFromPolygon(
|
||||||
);
|
e.publisherAddress,
|
||||||
const composite = await getCompositePluginABI(
|
e.extensionName,
|
||||||
implementation,
|
e.extensionVersion,
|
||||||
compilerMetadata.abi,
|
this.storage,
|
||||||
getChainProvider(parseInt(network), {
|
this.options.clientId,
|
||||||
clientId: this.options.clientId,
|
this.options.secretKey,
|
||||||
secretKey: this.options.secretKey,
|
);
|
||||||
}),
|
}),
|
||||||
{}, // pass empty object for options instead of this.options
|
|
||||||
this.storage,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const publishedExtensionUris = publishedExtensions.map(
|
||||||
|
(ext) => ext.metadataUri,
|
||||||
|
);
|
||||||
|
|
||||||
|
const extensionABIs = (
|
||||||
|
await Promise.all(
|
||||||
|
publishedExtensionUris.map(async (uri) => {
|
||||||
|
return fetchAndCacheDeployMetadata(uri, this.storage);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata.abi);
|
||||||
|
|
||||||
|
const composite = joinABIs([
|
||||||
|
compilerMetadata.abi,
|
||||||
|
...extensionABIs,
|
||||||
|
]);
|
||||||
extraMetadata.compositeAbi = AbiSchema.parse(composite);
|
extraMetadata.compositeAbi = AbiSchema.parse(composite);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
@@ -430,7 +459,7 @@ export class ContractPublisher extends RPCConnectionHandler {
|
|||||||
const bytecodeHash = utils.solidityKeccak256(["bytes"], [bytecode]);
|
const bytecodeHash = utils.solidityKeccak256(["bytes"], [bytecode]);
|
||||||
const contractId = predeployMetadata.name;
|
const contractId = predeployMetadata.name;
|
||||||
|
|
||||||
const fullMetadata = FullPublishMetadataSchemaInput.parse({
|
const fullMetadata = await FullPublishMetadataSchemaInput.parseAsync({
|
||||||
...extraMetadata,
|
...extraMetadata,
|
||||||
metadataUri: predeployMetadata.metadataUri,
|
metadataUri: predeployMetadata.metadataUri,
|
||||||
bytecodeUri: predeployMetadata.bytecodeUri,
|
bytecodeUri: predeployMetadata.bytecodeUri,
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export class ContractVerifier extends RPCConnectionHandler {
|
|||||||
contractName: string,
|
contractName: string,
|
||||||
explorerAPIUrl: string,
|
explorerAPIUrl: string,
|
||||||
explorerAPIKey: string,
|
explorerAPIKey: string,
|
||||||
|
contractVersion: string = "latest",
|
||||||
constructorArgs?: ConstructorParamMap,
|
constructorArgs?: ConstructorParamMap,
|
||||||
) {
|
) {
|
||||||
const chainId = (await this.getProvider().getNetwork()).chainId;
|
const chainId = (await this.getProvider().getNetwork()).chainId;
|
||||||
@@ -68,6 +69,7 @@ export class ContractVerifier extends RPCConnectionHandler {
|
|||||||
explorerAPIUrl,
|
explorerAPIUrl,
|
||||||
explorerAPIKey,
|
explorerAPIKey,
|
||||||
this.storage,
|
this.storage,
|
||||||
|
contractVersion,
|
||||||
this.options.clientId,
|
this.options.clientId,
|
||||||
this.options.secretKey,
|
this.options.secretKey,
|
||||||
constructorArgs,
|
constructorArgs,
|
||||||
|
|||||||
@@ -797,11 +797,23 @@ export class ContractWrapper<
|
|||||||
? CONTRACT_ADDRESSES[
|
? CONTRACT_ADDRESSES[
|
||||||
transaction.chainId as keyof typeof CONTRACT_ADDRESSES
|
transaction.chainId as keyof typeof CONTRACT_ADDRESSES
|
||||||
].openzeppelinForwarderEOA ||
|
].openzeppelinForwarderEOA ||
|
||||||
(await computeEOAForwarderAddress(this.getProvider(), this.storage))
|
(await computeEOAForwarderAddress(
|
||||||
|
this.getProvider(),
|
||||||
|
this.storage,
|
||||||
|
"",
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
|
))
|
||||||
: CONTRACT_ADDRESSES[
|
: CONTRACT_ADDRESSES[
|
||||||
transaction.chainId as keyof typeof CONTRACT_ADDRESSES
|
transaction.chainId as keyof typeof CONTRACT_ADDRESSES
|
||||||
].openzeppelinForwarder ||
|
].openzeppelinForwarder ||
|
||||||
(await computeForwarderAddress(this.getProvider(), this.storage)));
|
(await computeForwarderAddress(
|
||||||
|
this.getProvider(),
|
||||||
|
this.storage,
|
||||||
|
"",
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
|
)));
|
||||||
|
|
||||||
const forwarder = new Contract(forwarderAddress, ForwarderABI, provider);
|
const forwarder = new Contract(forwarderAddress, ForwarderABI, provider);
|
||||||
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
|
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ export class DropClaimConditions<
|
|||||||
|
|
||||||
if (supplyWithDecimals.lt(quantityWithDecimals)) {
|
if (supplyWithDecimals.lt(quantityWithDecimals)) {
|
||||||
reasons.push(ClaimEligibility.NotEnoughSupply);
|
reasons.push(ClaimEligibility.NotEnoughSupply);
|
||||||
|
return reasons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,6 +465,7 @@ export class DropClaimConditions<
|
|||||||
} else {
|
} else {
|
||||||
reasons.push(ClaimEligibility.WaitBeforeNextClaimTransaction);
|
reasons.push(ClaimEligibility.WaitBeforeNextClaimTransaction);
|
||||||
}
|
}
|
||||||
|
return reasons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ export class DropErc1155ClaimConditions<
|
|||||||
if (claimCondition.availableSupply !== "unlimited") {
|
if (claimCondition.availableSupply !== "unlimited") {
|
||||||
if (BigNumber.from(claimCondition.availableSupply).lt(quantity)) {
|
if (BigNumber.from(claimCondition.availableSupply).lt(quantity)) {
|
||||||
reasons.push(ClaimEligibility.NotEnoughSupply);
|
reasons.push(ClaimEligibility.NotEnoughSupply);
|
||||||
|
return reasons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,6 +471,7 @@ export class DropErc1155ClaimConditions<
|
|||||||
} else {
|
} else {
|
||||||
reasons.push(ClaimEligibility.WaitBeforeNextClaimTransaction);
|
reasons.push(ClaimEligibility.WaitBeforeNextClaimTransaction);
|
||||||
}
|
}
|
||||||
|
return reasons;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not within a browser conetext, check for wallet balance.
|
// if not within a browser conetext, check for wallet balance.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
FEATURE_EDITION_CLAIM_CUSTOM,
|
FEATURE_EDITION_CLAIM_CUSTOM,
|
||||||
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
||||||
FEATURE_EDITION_LAZY_MINTABLE_V2,
|
FEATURE_EDITION_LAZY_MINTABLE_V2,
|
||||||
|
FEATURE_EDITION_SUPPLY,
|
||||||
} from "../../constants/erc1155-features";
|
} from "../../constants/erc1155-features";
|
||||||
import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
|
import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
|
||||||
import { Address } from "../../schema/shared/Address";
|
import { Address } from "../../schema/shared/Address";
|
||||||
@@ -171,7 +172,11 @@ export class Erc1155<
|
|||||||
* @twfeature ERC1155
|
* @twfeature ERC1155
|
||||||
*/
|
*/
|
||||||
public async totalSupply(tokenId: BigNumberish): Promise<BigNumber> {
|
public async totalSupply(tokenId: BigNumberish): Promise<BigNumber> {
|
||||||
return await this.contractWrapper.readContract.totalSupply(tokenId);
|
if (detectContractFeature(this.contractWrapper, "ERC1155Supply")) {
|
||||||
|
return await this.contractWrapper.readContract.totalSupply(tokenId);
|
||||||
|
} else {
|
||||||
|
throw new ExtensionNotImplementedError(FEATURE_EDITION_SUPPLY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import EventEmitter from "eventemitter3";
|
|||||||
export class RPCConnectionHandler extends EventEmitter {
|
export class RPCConnectionHandler extends EventEmitter {
|
||||||
private provider: providers.Provider;
|
private provider: providers.Provider;
|
||||||
private signer: Signer | undefined;
|
private signer: Signer | undefined;
|
||||||
|
public network: NetworkInput;
|
||||||
public readonly options: SDKOptionsOutput;
|
public readonly options: SDKOptionsOutput;
|
||||||
|
|
||||||
constructor(network: NetworkInput, options: SDKOptions) {
|
constructor(network: NetworkInput, options: SDKOptions) {
|
||||||
@@ -29,6 +30,7 @@ export class RPCConnectionHandler extends EventEmitter {
|
|||||||
this.options = SDKOptionsSchema.parse({});
|
this.options = SDKOptionsSchema.parse({});
|
||||||
}
|
}
|
||||||
const [signer, provider] = getSignerAndProvider(network, this.options);
|
const [signer, provider] = getSignerAndProvider(network, this.options);
|
||||||
|
this.network = network;
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,7 @@ export class RPCConnectionHandler extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
public updateSignerOrProvider(network: NetworkInput) {
|
public updateSignerOrProvider(network: NetworkInput) {
|
||||||
const [signer, provider] = getSignerAndProvider(network, this.options);
|
const [signer, provider] = getSignerAndProvider(network, this.options);
|
||||||
|
this.network = network;
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getAllDetectedFeatureNames } from "../common/feature-detection/getAllDetectedFeatureNames";
|
import { getAllDetectedExtensionNames } from "../common/feature-detection/getAllDetectedFeatureNames";
|
||||||
import { resolveAddress } from "../common/ens/resolveAddress";
|
import { resolveAddress } from "../common/ens/resolveAddress";
|
||||||
import { getCompositePluginABI } from "../common/plugin/getCompositePluginABI";
|
import { getCompositePluginABI } from "../common/plugin/getCompositePluginABI";
|
||||||
import { createStorage } from "../common/storage";
|
import { createStorage } from "../common/storage";
|
||||||
@@ -90,6 +90,7 @@ import type {
|
|||||||
DeployMetadata,
|
DeployMetadata,
|
||||||
DeployEvent,
|
DeployEvent,
|
||||||
OpenEditionContractDeployMetadata,
|
OpenEditionContractDeployMetadata,
|
||||||
|
AirdropContractDeployMetadata,
|
||||||
} from "../types/deploy";
|
} from "../types/deploy";
|
||||||
import type { ContractWithMetadata } from "../types/registry";
|
import type { ContractWithMetadata } from "../types/registry";
|
||||||
import { DeploySchemaForPrebuiltContractType } from "../contracts";
|
import { DeploySchemaForPrebuiltContractType } from "../contracts";
|
||||||
@@ -115,6 +116,11 @@ import { getDefaultTrustedForwarders } from "../constants";
|
|||||||
import { checkClientIdOrSecretKey } from "../../core/utils/apiKey";
|
import { checkClientIdOrSecretKey } from "../../core/utils/apiKey";
|
||||||
import { getProcessEnv } from "../../core/utils/process";
|
import { getProcessEnv } from "../../core/utils/process";
|
||||||
import { DropErc721ContractSchema } from "../schema";
|
import { DropErc721ContractSchema } from "../schema";
|
||||||
|
import { AirdropContractDeploy } from "../schema/contracts/airdrop";
|
||||||
|
import {
|
||||||
|
directDeployDeterministicPublished,
|
||||||
|
predictAddressDeterministicPublished,
|
||||||
|
} from "../common";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main entry point for the thirdweb SDK
|
* The main entry point for the thirdweb SDK
|
||||||
@@ -587,20 +593,23 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
metadata.abi,
|
metadata.abi,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// fallback to
|
||||||
// try resolving the contract type (legacy contracts)
|
// try resolving the contract type (legacy contracts)
|
||||||
const resolvedContractType = await this.resolveContractType(address);
|
const resolvedContractType = await this.resolveContractType(
|
||||||
|
resolvedAddress,
|
||||||
|
);
|
||||||
if (resolvedContractType && resolvedContractType !== "custom") {
|
if (resolvedContractType && resolvedContractType !== "custom") {
|
||||||
// otherwise if it's a prebuilt contract we can just use the contract type
|
// otherwise if it's a prebuilt contract we can just use the contract type
|
||||||
const contractAbi = await PREBUILT_CONTRACTS_MAP[
|
const contractAbi = await PREBUILT_CONTRACTS_MAP[
|
||||||
resolvedContractType
|
resolvedContractType
|
||||||
].getAbi(address, this.getProvider(), this.storage);
|
].getAbi(resolvedAddress, this.getProvider(), this.storage);
|
||||||
newContract = await this.getContractFromAbi(address, contractAbi);
|
newContract = await this.getContractFromAbi(
|
||||||
} else {
|
resolvedAddress,
|
||||||
// we cant fetch the ABI, and we don't know the contract type, throw an error
|
contractAbi,
|
||||||
const chainId = (await this.getProvider().getNetwork()).chainId;
|
|
||||||
throw new Error(
|
|
||||||
`No ABI found for this contract. Try importing it by visiting: https://thirdweb.com/${chainId}/${resolvedAddress}`,
|
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// we cant fetch the ABI, and we don't know the contract type, throw the original error
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -698,7 +707,7 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
metadata: async () =>
|
metadata: async () =>
|
||||||
(await this.getContract(address)).metadata.get(),
|
(await this.getContract(address)).metadata.get(),
|
||||||
extensions: async () =>
|
extensions: async () =>
|
||||||
getAllDetectedFeatureNames(
|
getAllDetectedExtensionNames(
|
||||||
(await this.getContract(address)).abi as Abi,
|
(await this.getContract(address)).abi as Abi,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -759,7 +768,7 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
metadata: async () =>
|
metadata: async () =>
|
||||||
(await chainSDK.getContract(address)).metadata.get(),
|
(await chainSDK.getContract(address)).metadata.get(),
|
||||||
extensions: async () =>
|
extensions: async () =>
|
||||||
getAllDetectedFeatureNames(
|
getAllDetectedExtensionNames(
|
||||||
(await chainSDK.getContract(address)).abi as Abi,
|
(await chainSDK.getContract(address)).abi as Abi,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -1418,6 +1427,99 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
deployAirdropERC20 = /* @__PURE__ */ buildDeployTransactionFunction(
|
||||||
|
async (
|
||||||
|
metadata: AirdropContractDeployMetadata,
|
||||||
|
options?: DeployOptions,
|
||||||
|
): Promise<DeployTransaction> => {
|
||||||
|
const parsedMetadata = await AirdropContractDeploy.parseAsync(metadata);
|
||||||
|
const contractURI = await this.storage.upload(parsedMetadata);
|
||||||
|
|
||||||
|
const chainId = (await this.getProvider().getNetwork()).chainId;
|
||||||
|
const trustedForwarders = getDefaultTrustedForwarders(chainId);
|
||||||
|
// add default forwarders to any custom forwarders passed in
|
||||||
|
if (
|
||||||
|
metadata.trusted_forwarders &&
|
||||||
|
metadata.trusted_forwarders.length > 0
|
||||||
|
) {
|
||||||
|
trustedForwarders.push(...metadata.trusted_forwarders);
|
||||||
|
}
|
||||||
|
|
||||||
|
const signerAddress = await this.getSigner()?.getAddress();
|
||||||
|
|
||||||
|
const deployArgs = [signerAddress, contractURI, trustedForwarders];
|
||||||
|
|
||||||
|
return await this.deployReleasedContract.prepare(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
"AirdropERC20",
|
||||||
|
deployArgs,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
deployAirdropERC721 = /* @__PURE__ */ buildDeployTransactionFunction(
|
||||||
|
async (
|
||||||
|
metadata: AirdropContractDeployMetadata,
|
||||||
|
options?: DeployOptions,
|
||||||
|
): Promise<DeployTransaction> => {
|
||||||
|
const parsedMetadata = await AirdropContractDeploy.parseAsync(metadata);
|
||||||
|
const contractURI = await this.storage.upload(parsedMetadata);
|
||||||
|
|
||||||
|
const chainId = (await this.getProvider().getNetwork()).chainId;
|
||||||
|
const trustedForwarders = getDefaultTrustedForwarders(chainId);
|
||||||
|
// add default forwarders to any custom forwarders passed in
|
||||||
|
if (
|
||||||
|
metadata.trusted_forwarders &&
|
||||||
|
metadata.trusted_forwarders.length > 0
|
||||||
|
) {
|
||||||
|
trustedForwarders.push(...metadata.trusted_forwarders);
|
||||||
|
}
|
||||||
|
|
||||||
|
const signerAddress = await this.getSigner()?.getAddress();
|
||||||
|
|
||||||
|
const deployArgs = [signerAddress, contractURI, trustedForwarders];
|
||||||
|
|
||||||
|
return await this.deployReleasedContract.prepare(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
"AirdropERC721",
|
||||||
|
deployArgs,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
deployAirdropERC1155 = /* @__PURE__ */ buildDeployTransactionFunction(
|
||||||
|
async (
|
||||||
|
metadata: AirdropContractDeployMetadata,
|
||||||
|
options?: DeployOptions,
|
||||||
|
): Promise<DeployTransaction> => {
|
||||||
|
const parsedMetadata = await AirdropContractDeploy.parseAsync(metadata);
|
||||||
|
const contractURI = await this.storage.upload(parsedMetadata);
|
||||||
|
|
||||||
|
const chainId = (await this.getProvider().getNetwork()).chainId;
|
||||||
|
const trustedForwarders = getDefaultTrustedForwarders(chainId);
|
||||||
|
// add default forwarders to any custom forwarders passed in
|
||||||
|
if (
|
||||||
|
metadata.trusted_forwarders &&
|
||||||
|
metadata.trusted_forwarders.length > 0
|
||||||
|
) {
|
||||||
|
trustedForwarders.push(...metadata.trusted_forwarders);
|
||||||
|
}
|
||||||
|
|
||||||
|
const signerAddress = await this.getSigner()?.getAddress();
|
||||||
|
|
||||||
|
const deployArgs = [signerAddress, contractURI, trustedForwarders];
|
||||||
|
|
||||||
|
return await this.deployReleasedContract.prepare(
|
||||||
|
THIRDWEB_DEPLOYER,
|
||||||
|
"AirdropERC1155",
|
||||||
|
deployArgs,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deploys a new contract
|
* Deploys a new contract
|
||||||
*
|
*
|
||||||
@@ -1558,6 +1660,68 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
*/
|
*/
|
||||||
deployPublishedContract = this.deployReleasedContract;
|
deployPublishedContract = this.deployReleasedContract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deploy any published contract by its name
|
||||||
|
* @param contractName the name of the contract to deploy
|
||||||
|
* @param constructorParams the constructor params to pass to the contract
|
||||||
|
* @param publisherAddress the address of the publisher
|
||||||
|
* @param version Optional: the version of the contract to deploy or "latest"
|
||||||
|
* @param saltForCreate2 Optional: salt for create2 deployment, will determine deployment address
|
||||||
|
*/
|
||||||
|
async deployPublishedContractDeterministic(
|
||||||
|
contractName: string,
|
||||||
|
constructorParams: any[],
|
||||||
|
publisherAddress: string = THIRDWEB_DEPLOYER,
|
||||||
|
contractVersion: string = "latest",
|
||||||
|
saltForCreate2?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const signer = this.getSigner();
|
||||||
|
invariant(signer, "Signer is required");
|
||||||
|
|
||||||
|
return directDeployDeterministicPublished(
|
||||||
|
contractName,
|
||||||
|
publisherAddress,
|
||||||
|
contractVersion,
|
||||||
|
constructorParams,
|
||||||
|
signer,
|
||||||
|
this.storage,
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
|
saltForCreate2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predict Create2 address of a contract
|
||||||
|
* @param contractName the name of the contract
|
||||||
|
* @param constructorParams the constructor params to pass to the contract
|
||||||
|
* @param publisherAddress the address of the publisher
|
||||||
|
* @param version Optional: the version of the contract to deploy or "latest"
|
||||||
|
* @param saltForCreate2 Optional: salt for create2 deployment, will determine deployment address
|
||||||
|
*/
|
||||||
|
async predictAddressDeterministic(
|
||||||
|
contractName: string,
|
||||||
|
constructorParams: any[],
|
||||||
|
publisherAddress: string = THIRDWEB_DEPLOYER,
|
||||||
|
contractVersion: string = "latest",
|
||||||
|
saltForCreate2?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const provider = this.getProvider();
|
||||||
|
invariant(provider, "Provider is required");
|
||||||
|
|
||||||
|
return predictAddressDeterministicPublished(
|
||||||
|
contractName,
|
||||||
|
publisherAddress,
|
||||||
|
contractVersion,
|
||||||
|
constructorParams,
|
||||||
|
provider,
|
||||||
|
this.storage,
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
|
saltForCreate2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deploy a proxy contract of a given implementation via the given factory
|
* Deploy a proxy contract of a given implementation via the given factory
|
||||||
* @param factoryAddress
|
* @param factoryAddress
|
||||||
@@ -1662,6 +1826,8 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
this.storage,
|
this.storage,
|
||||||
this.getProvider(),
|
this.getProvider(),
|
||||||
create2Factory,
|
create2Factory,
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const implementationAddress = deploymentInfo.find(
|
const implementationAddress = deploymentInfo.find(
|
||||||
@@ -1693,11 +1859,17 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// send each transaction directly to Create2 factory
|
// send each transaction directly to Create2 factory
|
||||||
await Promise.all(
|
// process txns one at a time
|
||||||
transactionsforDirectDeploy.map((tx) => {
|
for (const tx of transactionsforDirectDeploy) {
|
||||||
return deployContractDeterministic(signer, tx, options);
|
try {
|
||||||
}),
|
await deployContractDeterministic(signer, tx, options);
|
||||||
);
|
} catch (e) {
|
||||||
|
console.debug(
|
||||||
|
`Error deploying contract at ${tx.predictedAddress}`,
|
||||||
|
(e as any)?.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const resolvedImplementationAddress = await resolveAddress(
|
const resolvedImplementationAddress = await resolveAddress(
|
||||||
implementationAddress,
|
implementationAddress,
|
||||||
@@ -1708,6 +1880,8 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
this.getProvider(),
|
this.getProvider(),
|
||||||
this.storage,
|
this.storage,
|
||||||
create2Factory,
|
create2Factory,
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
options?.notifier?.("deploying", "proxy");
|
options?.notifier?.("deploying", "proxy");
|
||||||
@@ -2103,6 +2277,8 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
this.storage,
|
this.storage,
|
||||||
this.getProvider(),
|
this.getProvider(),
|
||||||
create2FactoryAddress,
|
create2FactoryAddress,
|
||||||
|
this.options.clientId,
|
||||||
|
this.options.secretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const transactionsToSend = deploymentInfo.filter(
|
const transactionsToSend = deploymentInfo.filter(
|
||||||
@@ -2203,6 +2379,8 @@ export class ContractDeployer extends RPCConnectionHandler {
|
|||||||
version: string,
|
version: string,
|
||||||
) {
|
) {
|
||||||
const address = await resolveAddress(publisherAddress);
|
const address = await resolveAddress(publisherAddress);
|
||||||
|
// TODO don't create a new sdk instance here, instead read from contract directly with provider
|
||||||
|
// this will allow moving deployer out of this file and help with tree shaking
|
||||||
const publishedContract = await new ThirdwebSDK(
|
const publishedContract = await new ThirdwebSDK(
|
||||||
"polygon",
|
"polygon",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type {
|
|||||||
Signer,
|
Signer,
|
||||||
providers,
|
providers,
|
||||||
} from "ethers";
|
} from "ethers";
|
||||||
|
import { ChainInfo } from "../schema";
|
||||||
|
|
||||||
// --- utility types extracted from from ts-toolbelt --- //
|
// --- utility types extracted from from ts-toolbelt --- //
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ export type ChainOrRpc = ChainSlug | (string & {});
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type ChainIdOrNumber = ChainId | (number & {});
|
export type ChainIdOrNumber = ChainId | (number & {});
|
||||||
export type ChainIdOrName = ChainIdOrNumber | ChainOrRpc;
|
export type ChainIdOrName = ChainIdOrNumber | ChainOrRpc;
|
||||||
export type ChainOrRpcUrl = ChainIdOrName | Chain;
|
export type ChainOrRpcUrl = ChainIdOrName | Chain | ChainInfo;
|
||||||
export type NetworkInput = ChainOrRpcUrl | Signer | providers.Provider;
|
export type NetworkInput = ChainOrRpcUrl | Signer | providers.Provider;
|
||||||
|
|
||||||
export type ValueOf<T> = T[keyof T];
|
export type ValueOf<T> = T[keyof T];
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import {
|
||||||
|
CommonContractOutputSchema,
|
||||||
|
CommonContractSchema,
|
||||||
|
CommonSymbolSchema,
|
||||||
|
CommonTrustedForwarderSchema,
|
||||||
|
} from "./common";
|
||||||
|
|
||||||
|
export const AirdropContractInput =
|
||||||
|
/* @__PURE__ */ CommonContractSchema.merge(CommonSymbolSchema);
|
||||||
|
|
||||||
|
export const AirdropContractOutput =
|
||||||
|
/* @__PURE__ */ CommonContractOutputSchema.merge(CommonSymbolSchema);
|
||||||
|
|
||||||
|
export const AirdropContractDeploy = /* @__PURE__ */ AirdropContractInput.merge(
|
||||||
|
CommonTrustedForwarderSchema,
|
||||||
|
);
|
||||||
@@ -28,3 +28,61 @@ export const AirdropInputSchema = /* @__PURE__ */ (() =>
|
|||||||
),
|
),
|
||||||
z.array(AirdropAddressInput),
|
z.array(AirdropAddressInput),
|
||||||
]))();
|
]))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop20ContentInput = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
recipient: AddressOrEnsSchema,
|
||||||
|
amount: AmountSchema.default(1),
|
||||||
|
}))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop20OutputSchema = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
successfulDropCount: z.number(),
|
||||||
|
failedDropCount: z.number(),
|
||||||
|
failedDrops: z.array(Airdrop20ContentInput),
|
||||||
|
}))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop721ContentInput = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
recipient: AddressOrEnsSchema,
|
||||||
|
tokenId: z.number(),
|
||||||
|
}))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop721OutputSchema = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
successfulDropCount: z.number(),
|
||||||
|
failedDropCount: z.number(),
|
||||||
|
failedDrops: z.array(Airdrop721ContentInput),
|
||||||
|
}))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop1155ContentInput = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
recipient: AddressOrEnsSchema,
|
||||||
|
tokenId: z.number(),
|
||||||
|
amount: AmountSchema.default(1),
|
||||||
|
}))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const Airdrop1155OutputSchema = /* @__PURE__ */ (() =>
|
||||||
|
z.object({
|
||||||
|
successfulDropCount: z.number(),
|
||||||
|
failedDropCount: z.number(),
|
||||||
|
failedDrops: z.array(Airdrop1155ContentInput),
|
||||||
|
}))();
|
||||||
|
|||||||
@@ -164,6 +164,12 @@ export const DeployTypeInput = /* @__PURE__ */ (() =>
|
|||||||
z.literal("customFactory"),
|
z.literal("customFactory"),
|
||||||
]))();
|
]))();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const RouterTypeInput = /* @__PURE__ */ (() =>
|
||||||
|
z.union([z.literal("none"), z.literal("plugin"), z.literal("dynamic")]))();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@@ -206,6 +212,16 @@ export const ExtraPublishMetadataSchemaInput = /* @__PURE__ */ (() =>
|
|||||||
isDeployableViaProxy: z.boolean().optional(),
|
isDeployableViaProxy: z.boolean().optional(),
|
||||||
factoryDeploymentData: FactoryDeploymentSchema.optional(),
|
factoryDeploymentData: FactoryDeploymentSchema.optional(),
|
||||||
deployType: DeployTypeInput.optional(),
|
deployType: DeployTypeInput.optional(),
|
||||||
|
routerType: RouterTypeInput.optional(),
|
||||||
|
defaultExtensions: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
extensionName: z.string(),
|
||||||
|
extensionVersion: z.string().default("latest"),
|
||||||
|
publisherAddress: AddressOrEnsSchema,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
networksForDeployment: DeploymentNetworkInput.optional(),
|
networksForDeployment: DeploymentNetworkInput.optional(),
|
||||||
constructorParams: z
|
constructorParams: z
|
||||||
.record(
|
.record(
|
||||||
@@ -321,6 +337,7 @@ export const CompilerMetadataFetchedSchema = /* @__PURE__ */ (() =>
|
|||||||
.transform((v) => {
|
.transform((v) => {
|
||||||
return v.filter((license) => license !== undefined) as string[];
|
return v.filter((license) => license !== undefined) as string[];
|
||||||
}),
|
}),
|
||||||
|
isPartialAbi: z.boolean().optional(),
|
||||||
}))();
|
}))();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import { AirdropInputSchema } from "../../schema/contracts/common/airdrop";
|
import {
|
||||||
|
Airdrop1155ContentInput,
|
||||||
|
Airdrop1155OutputSchema,
|
||||||
|
Airdrop20ContentInput,
|
||||||
|
Airdrop20OutputSchema,
|
||||||
|
Airdrop721ContentInput,
|
||||||
|
Airdrop721OutputSchema,
|
||||||
|
AirdropInputSchema,
|
||||||
|
} from "../../schema/contracts/common/airdrop";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,3 +14,12 @@ import { z } from "zod";
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type AirdropInput = z.input<typeof AirdropInputSchema>;
|
export type AirdropInput = z.input<typeof AirdropInputSchema>;
|
||||||
|
|
||||||
|
export type Airdrop20Content = z.input<typeof Airdrop20ContentInput>;
|
||||||
|
export type Airdrop20Output = z.input<typeof Airdrop20OutputSchema>;
|
||||||
|
|
||||||
|
export type Airdrop721Content = z.input<typeof Airdrop721ContentInput>;
|
||||||
|
export type Airdrop721Output = z.input<typeof Airdrop721OutputSchema>;
|
||||||
|
|
||||||
|
export type Airdrop1155Content = z.input<typeof Airdrop1155ContentInput>;
|
||||||
|
export type Airdrop1155Output = z.input<typeof Airdrop1155OutputSchema>;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BytesLike } from "ethers";
|
import { BytesLike } from "ethers";
|
||||||
import { PreDeployMetadataFetched } from "../../schema/contracts/custom";
|
import { PreDeployMetadataFetched } from "../../schema/contracts/custom";
|
||||||
|
import { AddressOrEns } from "../../schema";
|
||||||
|
|
||||||
export type PrecomputedDeploymentTransaction = {
|
export type PrecomputedDeploymentTransaction = {
|
||||||
predictedAddress: string;
|
predictedAddress: string;
|
||||||
@@ -49,6 +50,8 @@ export type ConstructorParamMap = Record<string, ConstructorParam>;
|
|||||||
|
|
||||||
export type ContractOptions = {
|
export type ContractOptions = {
|
||||||
contractName?: string;
|
contractName?: string;
|
||||||
|
publisherAddress?: AddressOrEns;
|
||||||
|
version?: string;
|
||||||
metadata?: PreDeployMetadataFetched;
|
metadata?: PreDeployMetadataFetched;
|
||||||
constructorParams?: ConstructorParamMap;
|
constructorParams?: ConstructorParamMap;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -376,3 +376,34 @@ export interface MultiwrapContractDeployMetadata {
|
|||||||
*/
|
*/
|
||||||
app_uri?: string;
|
app_uri?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for deploying Airdrop contract
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export interface AirdropContractDeployMetadata {
|
||||||
|
/**
|
||||||
|
* name of the contract
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* Optional description of the contract
|
||||||
|
*/
|
||||||
|
description?: string;
|
||||||
|
/**
|
||||||
|
* Optional image for the contract
|
||||||
|
*/
|
||||||
|
image?: FileOrBufferOrString;
|
||||||
|
/**
|
||||||
|
* Optional url for the contract
|
||||||
|
*/
|
||||||
|
external_link?: string;
|
||||||
|
/**
|
||||||
|
* Custom gasless trusted forwarder addresses
|
||||||
|
*/
|
||||||
|
trusted_forwarders?: AddressOrEns[];
|
||||||
|
/**
|
||||||
|
* The default app for this contract
|
||||||
|
*/
|
||||||
|
app_uri?: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,230 @@
|
|||||||
|
import {
|
||||||
|
Edition,
|
||||||
|
EditionInitializer,
|
||||||
|
SmartContract,
|
||||||
|
ThirdwebSDK,
|
||||||
|
} from "../../src/evm";
|
||||||
|
import {
|
||||||
|
extendedMetadataMock,
|
||||||
|
jsonProvider,
|
||||||
|
sdk,
|
||||||
|
signers,
|
||||||
|
} from "./before-setup";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { expect, assert } from "chai";
|
||||||
|
import { ethers } from "ethers";
|
||||||
|
import { mockUploadMetadataWithBytecode } from "./utils";
|
||||||
|
import {
|
||||||
|
bytecode as TWCloneFactoryBytecode,
|
||||||
|
abi as TWCloneFactoryAbi,
|
||||||
|
} from "./metadata/TWCloneFactory";
|
||||||
|
import {
|
||||||
|
AirdropERC1155__factory,
|
||||||
|
Forwarder__factory,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
|
||||||
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throughout these tests, the admin wallet will be performing the airdrops.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
describe("Airdrop ERC1155", async () => {
|
||||||
|
let airdropContract: SmartContract;
|
||||||
|
let dummyBundleContract: Edition;
|
||||||
|
let dummyBundleContractAddress: string;
|
||||||
|
|
||||||
|
let adminWallet: SignerWithAddress,
|
||||||
|
samWallet: SignerWithAddress,
|
||||||
|
bobWallet: SignerWithAddress,
|
||||||
|
randomWallet: SignerWithAddress,
|
||||||
|
w4: SignerWithAddress;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await jsonProvider.send("hardhat_reset", []);
|
||||||
|
[adminWallet, samWallet, bobWallet, randomWallet, , , , w4] = signers;
|
||||||
|
|
||||||
|
sdk.updateSignerOrProvider(adminWallet);
|
||||||
|
|
||||||
|
const mockPublisher = process.env.contractPublisherAddress;
|
||||||
|
process.env.contractPublisherAddress =
|
||||||
|
"0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7";
|
||||||
|
await mockPublishAirdrop();
|
||||||
|
airdropContract = await sdk.getContract(
|
||||||
|
await sdk.deployer.deployAirdropERC1155({
|
||||||
|
name: "Test Airdrop ERC1155",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
process.env.contractPublisherAddress = mockPublisher;
|
||||||
|
|
||||||
|
dummyBundleContract = await sdk.getEdition(
|
||||||
|
await sdk.deployer.deployBuiltInContract(
|
||||||
|
EditionInitializer.contractType,
|
||||||
|
{
|
||||||
|
name: "TEST BUNDLE",
|
||||||
|
seller_fee_basis_points: 100,
|
||||||
|
primary_sale_recipient: adminWallet.address,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await dummyBundleContract.mintBatch([
|
||||||
|
{
|
||||||
|
metadata: {
|
||||||
|
name: "Test 0",
|
||||||
|
},
|
||||||
|
supply: 100000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
metadata: {
|
||||||
|
name: "Test 1",
|
||||||
|
},
|
||||||
|
supply: 100000,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
await dummyBundleContract.setApprovalForAll(
|
||||||
|
airdropContract.getAddress(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
dummyBundleContractAddress = dummyBundleContract.getAddress();
|
||||||
|
});
|
||||||
|
|
||||||
|
before("Mock upload infra contracts", async () => {
|
||||||
|
// mock upload Forwarder
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
Forwarder__factory.abi,
|
||||||
|
Forwarder__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://Qmcu8FaqerUvQYb4qPg7PwkXa6dRtEe45LedLJPN42Jwqe/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock upload TWCloneFactory
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
TWCloneFactoryAbi,
|
||||||
|
TWCloneFactoryBytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://QmYfw13Zykqf9jAmJobNgYrEpatEF9waWcQPUHvJ7sctRb/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockPublishAirdrop = async () => {
|
||||||
|
const publishedContract = await new ThirdwebSDK("polygon", {
|
||||||
|
secretKey: process.env.TW_SECRET_KEY,
|
||||||
|
})
|
||||||
|
.getPublisher()
|
||||||
|
.getVersion(
|
||||||
|
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
"AirdropERC1155",
|
||||||
|
"latest",
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock publish as a autoFactory-deploy contract
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"AirdropERC1155",
|
||||||
|
AirdropERC1155__factory.abi,
|
||||||
|
AirdropERC1155__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "autoFactory",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
publisher: "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
},
|
||||||
|
publishedContract?.metadataUri,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =========== Airdrop Tests ============
|
||||||
|
*/
|
||||||
|
describe("Drop", () => {
|
||||||
|
it("check contract", async () => {
|
||||||
|
const contractTypeBytes =
|
||||||
|
ethers.utils.formatBytes32String("AirdropERC1155");
|
||||||
|
const contractType = await airdropContract.call("contractType");
|
||||||
|
|
||||||
|
assert(contractType, contractTypeBytes);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should perform airdrop", async () => {
|
||||||
|
await airdropContract.airdrop1155.drop(
|
||||||
|
dummyBundleContractAddress,
|
||||||
|
adminWallet.address,
|
||||||
|
[
|
||||||
|
{ recipient: samWallet.address, tokenId: 0, amount: 10 },
|
||||||
|
{ recipient: bobWallet.address, tokenId: 0, amount: 12 },
|
||||||
|
{ recipient: randomWallet.address, tokenId: 1, amount: 5 },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(await dummyBundleContract.balanceOf(samWallet.address, 0)).toNumber(),
|
||||||
|
).to.equal(10);
|
||||||
|
expect(
|
||||||
|
(await dummyBundleContract.balanceOf(bobWallet.address, 0)).toNumber(),
|
||||||
|
).to.equal(12);
|
||||||
|
expect(
|
||||||
|
(
|
||||||
|
await dummyBundleContract.balanceOf(randomWallet.address, 1)
|
||||||
|
).toNumber(),
|
||||||
|
).to.equal(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should correctly return failed airdrop recipients", async () => {
|
||||||
|
const randomContractAsRecipient = process.env
|
||||||
|
.contractPublisherAddress as string;
|
||||||
|
|
||||||
|
const output = await airdropContract.airdrop1155.drop(
|
||||||
|
dummyBundleContractAddress,
|
||||||
|
adminWallet.address,
|
||||||
|
[
|
||||||
|
{ recipient: samWallet.address, tokenId: 0, amount: 10 },
|
||||||
|
{ recipient: bobWallet.address, tokenId: 0, amount: 12 },
|
||||||
|
{ recipient: randomWallet.address, tokenId: 1, amount: 5 },
|
||||||
|
{ recipient: randomContractAsRecipient, tokenId: 1, amount: 1 },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(await dummyBundleContract.balanceOf(samWallet.address, 0)).toNumber(),
|
||||||
|
).to.equal(10);
|
||||||
|
expect(
|
||||||
|
(await dummyBundleContract.balanceOf(bobWallet.address, 0)).toNumber(),
|
||||||
|
).to.equal(12);
|
||||||
|
expect(
|
||||||
|
(
|
||||||
|
await dummyBundleContract.balanceOf(randomWallet.address, 1)
|
||||||
|
).toNumber(),
|
||||||
|
).to.equal(5);
|
||||||
|
|
||||||
|
// check failed
|
||||||
|
assert(randomContractAsRecipient === output.failedDrops[0].recipient);
|
||||||
|
assert(output.failedDropCount === 1);
|
||||||
|
assert(output.successfulDropCount === 3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
import {
|
||||||
|
NATIVE_TOKEN_ADDRESS,
|
||||||
|
Token,
|
||||||
|
TokenInitializer,
|
||||||
|
SmartContract,
|
||||||
|
ThirdwebSDK,
|
||||||
|
} from "../../src/evm";
|
||||||
|
import {
|
||||||
|
extendedMetadataMock,
|
||||||
|
jsonProvider,
|
||||||
|
sdk,
|
||||||
|
signers,
|
||||||
|
} from "./before-setup";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import {
|
||||||
|
AirdropERC20__factory,
|
||||||
|
Forwarder__factory,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import { expect, assert } from "chai";
|
||||||
|
import { BigNumber, ethers } from "ethers";
|
||||||
|
import { mockUploadMetadataWithBytecode } from "./utils";
|
||||||
|
import {
|
||||||
|
bytecode as TWCloneFactoryBytecode,
|
||||||
|
abi as TWCloneFactoryAbi,
|
||||||
|
} from "./metadata/TWCloneFactory";
|
||||||
|
|
||||||
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
let tokenAddress = NATIVE_TOKEN_ADDRESS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throughout these tests, the admin wallet will be performing the airdrops.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
describe("Airdrop ERC20", async () => {
|
||||||
|
let airdropContract: SmartContract;
|
||||||
|
let customTokenContract: Token;
|
||||||
|
|
||||||
|
let adminWallet: SignerWithAddress,
|
||||||
|
samWallet: SignerWithAddress,
|
||||||
|
bobWallet: SignerWithAddress,
|
||||||
|
randomWallet: SignerWithAddress,
|
||||||
|
w4: SignerWithAddress;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await jsonProvider.send("hardhat_reset", []);
|
||||||
|
[adminWallet, samWallet, bobWallet, randomWallet, , , , w4] = signers;
|
||||||
|
|
||||||
|
sdk.updateSignerOrProvider(adminWallet);
|
||||||
|
|
||||||
|
const mockPublisher = process.env.contractPublisherAddress;
|
||||||
|
process.env.contractPublisherAddress =
|
||||||
|
"0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7";
|
||||||
|
await mockPublishAirdrop();
|
||||||
|
airdropContract = await sdk.getContract(
|
||||||
|
await sdk.deployer.deployAirdropERC20({
|
||||||
|
name: "Test Airdrop ERC20",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
process.env.contractPublisherAddress = mockPublisher;
|
||||||
|
|
||||||
|
customTokenContract = await sdk.getToken(
|
||||||
|
await sdk.deployer.deployBuiltInContract(TokenInitializer.contractType, {
|
||||||
|
name: "Test",
|
||||||
|
symbol: "TEST",
|
||||||
|
primary_sale_recipient: adminWallet.address,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await customTokenContract.mintBatchTo([
|
||||||
|
{
|
||||||
|
toAddress: adminWallet.address,
|
||||||
|
amount: 1000,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
tokenAddress = customTokenContract.getAddress();
|
||||||
|
|
||||||
|
await customTokenContract.setAllowance(airdropContract.getAddress(), 1000);
|
||||||
|
});
|
||||||
|
before("Mock upload infra contracts", async () => {
|
||||||
|
// mock upload Forwarder
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
Forwarder__factory.abi,
|
||||||
|
Forwarder__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://Qmcu8FaqerUvQYb4qPg7PwkXa6dRtEe45LedLJPN42Jwqe/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock upload TWCloneFactory
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
TWCloneFactoryAbi,
|
||||||
|
TWCloneFactoryBytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://QmYfw13Zykqf9jAmJobNgYrEpatEF9waWcQPUHvJ7sctRb/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockPublishAirdrop = async () => {
|
||||||
|
const publishedContract = await new ThirdwebSDK("polygon", {
|
||||||
|
secretKey: process.env.TW_SECRET_KEY,
|
||||||
|
})
|
||||||
|
.getPublisher()
|
||||||
|
.getVersion(
|
||||||
|
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
"AirdropERC20",
|
||||||
|
"latest",
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock publish as a autoFactory-deploy contract
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"AirdropERC20",
|
||||||
|
AirdropERC20__factory.abi,
|
||||||
|
AirdropERC20__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "autoFactory",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
publisher: "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
},
|
||||||
|
publishedContract?.metadataUri,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =========== Airdrop Tests ============
|
||||||
|
*/
|
||||||
|
describe("Drop", () => {
|
||||||
|
it("check contract", async () => {
|
||||||
|
const contractTypeBytes =
|
||||||
|
ethers.utils.formatBytes32String("AirdropERC20");
|
||||||
|
const contractType = await airdropContract.call("contractType");
|
||||||
|
|
||||||
|
assert(contractType, contractTypeBytes);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should perform airdrop", async () => {
|
||||||
|
await airdropContract.airdrop20.drop(tokenAddress, adminWallet.address, [
|
||||||
|
{ recipient: samWallet.address, amount: 10 },
|
||||||
|
{ recipient: bobWallet.address, amount: 15 },
|
||||||
|
{ recipient: randomWallet.address, amount: 20 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const samBalance = (
|
||||||
|
await customTokenContract.balanceOf(samWallet.address)
|
||||||
|
).value;
|
||||||
|
const bobBalance = (
|
||||||
|
await customTokenContract.balanceOf(bobWallet.address)
|
||||||
|
).value;
|
||||||
|
const randomBalance = (
|
||||||
|
await customTokenContract.balanceOf(randomWallet.address)
|
||||||
|
).value;
|
||||||
|
const adminBalance = (
|
||||||
|
await customTokenContract.balanceOf(adminWallet.address)
|
||||||
|
).value;
|
||||||
|
|
||||||
|
expect(samBalance.toNumber()).to.equal(10);
|
||||||
|
expect(bobBalance.toNumber()).to.equal(15);
|
||||||
|
expect(randomBalance.toNumber()).to.equal(20);
|
||||||
|
|
||||||
|
expect(adminBalance.toString()).to.equal(
|
||||||
|
BigNumber.from(ethers.utils.parseEther("1000"))
|
||||||
|
.sub(samBalance.toString())
|
||||||
|
.sub(bobBalance.toString())
|
||||||
|
.sub(randomBalance.toString())
|
||||||
|
.toString(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
import {
|
||||||
|
NFTCollection,
|
||||||
|
NFTCollectionInitializer,
|
||||||
|
SmartContract,
|
||||||
|
ThirdwebSDK,
|
||||||
|
} from "../../src/evm";
|
||||||
|
import {
|
||||||
|
extendedMetadataMock,
|
||||||
|
jsonProvider,
|
||||||
|
sdk,
|
||||||
|
signers,
|
||||||
|
} from "./before-setup";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import {
|
||||||
|
AirdropERC721__factory,
|
||||||
|
Forwarder__factory,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import { expect, assert } from "chai";
|
||||||
|
import { ethers } from "ethers";
|
||||||
|
import { mockUploadMetadataWithBytecode } from "./utils";
|
||||||
|
import {
|
||||||
|
bytecode as TWCloneFactoryBytecode,
|
||||||
|
abi as TWCloneFactoryAbi,
|
||||||
|
} from "./metadata/TWCloneFactory";
|
||||||
|
|
||||||
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throughout these tests, the admin wallet will be performing the airdrops.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
describe("Airdrop ERC721", async () => {
|
||||||
|
let airdropContract: SmartContract;
|
||||||
|
let dummyNftContract: NFTCollection;
|
||||||
|
let dummyNftContractAddress: string;
|
||||||
|
|
||||||
|
let adminWallet: SignerWithAddress,
|
||||||
|
samWallet: SignerWithAddress,
|
||||||
|
bobWallet: SignerWithAddress,
|
||||||
|
randomWallet: SignerWithAddress,
|
||||||
|
w4: SignerWithAddress;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await jsonProvider.send("hardhat_reset", []);
|
||||||
|
[adminWallet, samWallet, bobWallet, randomWallet, , , , w4] = signers;
|
||||||
|
|
||||||
|
sdk.updateSignerOrProvider(adminWallet);
|
||||||
|
|
||||||
|
const mockPublisher = process.env.contractPublisherAddress;
|
||||||
|
process.env.contractPublisherAddress =
|
||||||
|
"0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7";
|
||||||
|
await mockPublishAirdrop();
|
||||||
|
airdropContract = await sdk.getContract(
|
||||||
|
await sdk.deployer.deployAirdropERC721({
|
||||||
|
name: "Test Airdrop ERC721",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
process.env.contractPublisherAddress = mockPublisher;
|
||||||
|
|
||||||
|
dummyNftContract = await sdk.getNFTCollection(
|
||||||
|
await sdk.deployer.deployBuiltInContract(
|
||||||
|
NFTCollectionInitializer.contractType,
|
||||||
|
{
|
||||||
|
name: "TEST NFT",
|
||||||
|
seller_fee_basis_points: 200,
|
||||||
|
fee_recipient: adminWallet.address,
|
||||||
|
primary_sale_recipient: adminWallet.address,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await dummyNftContract.mintBatch([
|
||||||
|
{
|
||||||
|
name: "Test 0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Test 2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Test 3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Test 4",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
await dummyNftContract.setApprovalForAll(
|
||||||
|
airdropContract.getAddress(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
dummyNftContractAddress = dummyNftContract.getAddress();
|
||||||
|
});
|
||||||
|
|
||||||
|
before("Mock upload infra contracts", async () => {
|
||||||
|
// mock upload Forwarder
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
Forwarder__factory.abi,
|
||||||
|
Forwarder__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://Qmcu8FaqerUvQYb4qPg7PwkXa6dRtEe45LedLJPN42Jwqe/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock upload TWCloneFactory
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"Forwarder",
|
||||||
|
TWCloneFactoryAbi,
|
||||||
|
TWCloneFactoryBytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "standard",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ipfs://QmYfw13Zykqf9jAmJobNgYrEpatEF9waWcQPUHvJ7sctRb/0",
|
||||||
|
// ^ we use actual publish uri as mock uri here, because this contract's uri is fetched from publisher by contractName
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockPublishAirdrop = async () => {
|
||||||
|
const publishedContract = await new ThirdwebSDK("polygon", {
|
||||||
|
secretKey: process.env.TW_SECRET_KEY,
|
||||||
|
})
|
||||||
|
.getPublisher()
|
||||||
|
.getVersion(
|
||||||
|
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
"AirdropERC721",
|
||||||
|
"latest",
|
||||||
|
);
|
||||||
|
|
||||||
|
// mock publish as a autoFactory-deploy contract
|
||||||
|
await mockUploadMetadataWithBytecode(
|
||||||
|
"AirdropERC721",
|
||||||
|
AirdropERC721__factory.abi,
|
||||||
|
AirdropERC721__factory.bytecode,
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
...extendedMetadataMock,
|
||||||
|
deployType: "autoFactory",
|
||||||
|
networksForDeployment: {
|
||||||
|
allNetworks: true,
|
||||||
|
networksEnabled: [],
|
||||||
|
},
|
||||||
|
publisher: "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024",
|
||||||
|
},
|
||||||
|
publishedContract?.metadataUri,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =========== Airdrop Tests ============
|
||||||
|
*/
|
||||||
|
describe("Drop", () => {
|
||||||
|
it("check contract", async () => {
|
||||||
|
const contractTypeBytes =
|
||||||
|
ethers.utils.formatBytes32String("AirdropERC721");
|
||||||
|
const contractType = await airdropContract.call("contractType");
|
||||||
|
|
||||||
|
assert(contractType, contractTypeBytes);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should perform airdrop", async () => {
|
||||||
|
await airdropContract.airdrop721.drop(
|
||||||
|
dummyNftContractAddress,
|
||||||
|
adminWallet.address,
|
||||||
|
[
|
||||||
|
{ recipient: samWallet.address, tokenId: 0 },
|
||||||
|
{ recipient: bobWallet.address, tokenId: 1 },
|
||||||
|
{ recipient: randomWallet.address, tokenId: 2 },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await dummyNftContract.ownerOf(0)).to.equal(samWallet.address);
|
||||||
|
expect(await dummyNftContract.ownerOf(1)).to.equal(bobWallet.address);
|
||||||
|
expect(await dummyNftContract.ownerOf(2)).to.equal(randomWallet.address);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should correctly return failed airdrop recipients", async () => {
|
||||||
|
const randomContractAsRecipient = process.env
|
||||||
|
.contractPublisherAddress as string;
|
||||||
|
|
||||||
|
const output = await airdropContract.airdrop721.drop(
|
||||||
|
dummyNftContractAddress,
|
||||||
|
adminWallet.address,
|
||||||
|
[
|
||||||
|
{ recipient: samWallet.address, tokenId: 0 },
|
||||||
|
{ recipient: bobWallet.address, tokenId: 1 },
|
||||||
|
{ recipient: randomWallet.address, tokenId: 2 },
|
||||||
|
{ recipient: randomContractAsRecipient, tokenId: 3 },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await dummyNftContract.ownerOf(0)).to.equal(samWallet.address);
|
||||||
|
expect(await dummyNftContract.ownerOf(1)).to.equal(bobWallet.address);
|
||||||
|
expect(await dummyNftContract.ownerOf(2)).to.equal(randomWallet.address);
|
||||||
|
|
||||||
|
// check failed
|
||||||
|
assert(randomContractAsRecipient === output.failedDrops[0].recipient);
|
||||||
|
assert(output.failedDropCount === 1);
|
||||||
|
assert(output.successfulDropCount === 3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -64,7 +64,8 @@ describe("Any EVM Keyless Deploy", async () => {
|
|||||||
// const publishUri = "ipfs://QmP2QPzc81zg5rqhU9u7cDeSyD4aZH8RdVF8Nuh6rCCgxV";
|
// const publishUri = "ipfs://QmP2QPzc81zg5rqhU9u7cDeSyD4aZH8RdVF8Nuh6rCCgxV";
|
||||||
// "ipfs://QmaibbXVEJSdW2xkbsVpGq6PKiqspi9LKaT22hoLjigtMt/0";
|
// "ipfs://QmaibbXVEJSdW2xkbsVpGq6PKiqspi9LKaT22hoLjigtMt/0";
|
||||||
const publishUri =
|
const publishUri =
|
||||||
"ipfs://QmVMYjPmtsQCxzbPALaXE2WwhnGE8F6mNn4FQE8iAqUTuD/0";
|
// "ipfs://QmVMYjPmtsQCxzbPALaXE2WwhnGE8F6mNn4FQE8iAqUTuD/0";
|
||||||
|
"ipfs://QmaE7HVb4nwHp96omxmyPc7nKPZqsGB7ZbW6psznN6cSMk/";
|
||||||
transactionCount = (await sdk.deployer.getTransactionsForDeploy(publishUri))
|
transactionCount = (await sdk.deployer.getTransactionsForDeploy(publishUri))
|
||||||
.length;
|
.length;
|
||||||
|
|
||||||
|
|||||||
@@ -417,5 +417,5 @@ export {
|
|||||||
implementations,
|
implementations,
|
||||||
hardhatEthers,
|
hardhatEthers,
|
||||||
thirdwebFactory,
|
thirdwebFactory,
|
||||||
extendedMetadataMock
|
extendedMetadataMock,
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user