Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8696199849 | ||
|
|
05353fd8da | ||
|
|
baa87a1fbd | ||
|
|
407932680f | ||
|
|
6bec17c07a | ||
|
|
c379d19dfb | ||
|
|
3e2bec8a47 | ||
|
|
8b028c29d5 | ||
|
|
cc286841e2 | ||
|
|
576d968a89 | ||
|
|
f2bdf47b4f | ||
|
|
b92d3f7006 | ||
|
|
c9457bc2e7 | ||
|
|
3308bddd70 | ||
|
|
8954b8c5b6 | ||
|
|
3287c2b0f2 | ||
|
|
a5cdd85c77 | ||
|
|
e9e71cfcd8 | ||
|
|
27b3475d64 | ||
|
|
6ba9cad8d8 | ||
|
|
a5ad3d6828 | ||
|
|
9c817de558 |
@@ -17,9 +17,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
uses: ./.github/composite-actions/install
|
uses: ./.github/composite-actions/install
|
||||||
|
|
||||||
|
- name: Install Playwright
|
||||||
|
run: npx playwright install --with-deps
|
||||||
|
|
||||||
- name: Run e2e tests
|
- name: Run e2e tests
|
||||||
run: yarn e2e
|
run: yarn e2e
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
id: validate_user
|
id: validate_user
|
||||||
if: ${{ steps.check.outputs.triggered == 'true' }}
|
if: ${{ steps.check.outputs.triggered == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "${AUTHOR_ASSOCIATION}" != 'MEMBER' && "${AUTHOR_ASSOCIATION}" != 'OWNER' ]]
|
if [[ "${AUTHOR_ASSOCIATION}" != 'MEMBER' && "${AUTHOR_ASSOCIATION}" != 'OWNER' && "${AUTHOR_ASSOCIATION}" != 'CONTRIBUTOR' ]]
|
||||||
then
|
then
|
||||||
echo "User authorization failed"
|
echo "User authorization failed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -59,6 +59,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: true
|
persist-credentials: true
|
||||||
repository: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
|
repository: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
|
||||||
|
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }}
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
uses: ./.github/composite-actions/install
|
uses: ./.github/composite-actions/install
|
||||||
@@ -74,7 +75,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Deploy pre-release
|
- name: Deploy pre-release
|
||||||
run: |
|
run: |
|
||||||
yarn changeset version --snapshot pr${{ github.event.issue.number }}
|
yarn changeset version --snapshot dev
|
||||||
yarn yarn changeset publish --tag pr${{ github.event.issue.number }} --no-git-tag
|
yarn changeset publish --tag dev --no-git-tag
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ jobs:
|
|||||||
uses: changesets/action@v1
|
uses: changesets/action@v1
|
||||||
with:
|
with:
|
||||||
publish: yarn release
|
publish: yarn release
|
||||||
|
version: yarn version-packages
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@@ -41,7 +42,7 @@ jobs:
|
|||||||
if: steps.changesets.outputs.published != 'true'
|
if: steps.changesets.outputs.published != 'true'
|
||||||
run: |
|
run: |
|
||||||
git checkout main
|
git checkout main
|
||||||
yarn version:nightly
|
yarn version-packages:nightly
|
||||||
yarn release:nightly
|
yarn release:nightly
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
| Package | Description | Latest Version |
|
| Package | Description | Latest Version |
|
||||||
| ---------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ---------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [/sdk](./packages/sdk/README.md) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/sdk](./packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
| [/react](./packages/react/README.md) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/react](./packages/react) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
| [/auth](./packages/auth/README.md) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/auth](./packages/auth) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
| [/storage](./packages/storage/README.md) | Best in class decentralized storage SDK for Browser and Node | <a href="https://www.npmjs.com/package/@thirdweb-dev/storage"><img src="https://img.shields.io/npm/v/@thirdweb-dev/storage?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/storage](./packages/storage) | Best in class decentralized storage SDK for Browser and Node | <a href="https://www.npmjs.com/package/@thirdweb-dev/storage"><img src="https://img.shields.io/npm/v/@thirdweb-dev/storage?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
| [/cli](./packages/cli/README.md) | Publish and deploy smart contracts without dealing with private keys | <a href="https://www.npmjs.com/package/thirdweb"><img src="https://img.shields.io/npm/v/thirdweb?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/cli](./packages/cli) | Publish and deploy smart contracts without dealing with private keys | <a href="https://www.npmjs.com/package/thirdweb"><img src="https://img.shields.io/npm/v/thirdweb?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
| [/solana](./packages/solana/README.md) | Solana SDK for Browser, Node and React Native | <a href="https://www.npmjs.com/package/@thirdweb-dev/solana"><img src="https://img.shields.io/npm/v/@thirdweb-dev/solana?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
| [/solana](./packages/solana) | Solana SDK for Browser, Node and React Native | <a href="https://www.npmjs.com/package/@thirdweb-dev/solana"><img src="https://img.shields.io/npm/v/@thirdweb-dev/solana?color=red&label=npm&logo=npm" alt="npm version"/></a> |
|
||||||
|
|
||||||
## How this monorepo functions
|
## How this monorepo functions
|
||||||
|
|
||||||
|
|||||||
+20
-16
@@ -2,7 +2,7 @@
|
|||||||
"name": "@thirdweb-dev/js",
|
"name": "@thirdweb-dev/js",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:thirdweb-dev/js.git",
|
"repository": "https://github.com/thirdweb-dev/js",
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -11,30 +11,20 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
|
||||||
"@changesets/changelog-github": "^0.4.6",
|
|
||||||
"@changesets/cli": "^2.24.3",
|
|
||||||
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
|
|
||||||
"eslint": "^8.23.0",
|
|
||||||
"postinstall-postinstall": "^2.1.0",
|
|
||||||
"prettier": "^2.7.1",
|
|
||||||
"turbo": "latest",
|
|
||||||
"yarn-deduplicate": "^5.0.2"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "yarn-deduplicate yarn.lock",
|
|
||||||
"test": "turbo run test",
|
"test": "turbo run test",
|
||||||
"e2e": "turbo run e2e",
|
"e2e": "turbo run e2e",
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"build:release": "turbo run build --force",
|
"build:release": "turbo run build --force",
|
||||||
"dev": "turbo run dev --no-cache --parallel --continue",
|
"dev": "turbo run dev --no-cache --parallel --continue",
|
||||||
|
"fix:repo": "manypkg fix",
|
||||||
"lint": "turbo run lint",
|
"lint": "turbo run lint",
|
||||||
"clean": "turbo run clean && rm -rf node_modules",
|
"clean": "turbo run clean && rm -rf node_modules",
|
||||||
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
||||||
"changeset": "changeset",
|
"changeset": "changeset",
|
||||||
"version": "changeset version",
|
"version-packages": "changeset version",
|
||||||
"release": "changeset publish",
|
"release": "node ./scripts/pre-release.mjs && changeset publish",
|
||||||
"version:nightly": "changeset version --snapshot nightly",
|
"version-packages:nightly": "changeset version --snapshot nightly",
|
||||||
"release:nightly": "changeset publish --tag nightly"
|
"release:nightly": "changeset publish --tag nightly"
|
||||||
},
|
},
|
||||||
"preconstruct": {
|
"preconstruct": {
|
||||||
@@ -42,5 +32,19 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"packageManager": "[email protected]"
|
"packageManager": "[email protected]",
|
||||||
|
"dependencies": {
|
||||||
|
"@changesets/changelog-github": "^0.4.6",
|
||||||
|
"@changesets/cli": "^2.24.3",
|
||||||
|
"@manypkg/cli": "^0.19.1",
|
||||||
|
"@manypkg/get-packages": "^1.1.3",
|
||||||
|
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
|
||||||
|
"eslint": "^8.21.0",
|
||||||
|
"postinstall-postinstall": "^2.1.0",
|
||||||
|
"prettier": "^2.7.1",
|
||||||
|
"turbo": "latest"
|
||||||
|
},
|
||||||
|
"manypkg": {
|
||||||
|
"defaultBranch": "main"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,28 @@
|
|||||||
# @thirdweb-dev/auth
|
# @thirdweb-dev/auth
|
||||||
|
|
||||||
|
## 1.0.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`baa87a1`](https://github.com/thirdweb-dev/js/commit/baa87a1fbd7eee24ce9a95e16028de8435f85e69), [`4079326`](https://github.com/thirdweb-dev/js/commit/407932680fb024f17f12f578aa22c7f8c0c13339), [`05353fd`](https://github.com/thirdweb-dev/js/commit/05353fd8da82f77fb642bb38a533fb99801aed30)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.9
|
||||||
|
|
||||||
|
## 1.0.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
|
- Updated dependencies [[`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.8
|
||||||
|
|
||||||
|
## 1.0.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.7
|
||||||
|
|
||||||
## 1.0.5
|
## 1.0.5
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/auth",
|
"name": "@thirdweb-dev/auth",
|
||||||
"version": "1.0.5",
|
"version": "1.0.8",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./package.json": "./package.json",
|
"./package.json": "./package.json",
|
||||||
"./express": {
|
"./express": {
|
||||||
@@ -16,11 +16,7 @@
|
|||||||
"default": "./next-auth/dist/thirdweb-dev-auth-next-auth.cjs.js"
|
"default": "./next-auth/dist/thirdweb-dev-auth-next-auth.cjs.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/auth",
|
||||||
"directory": "packages/auth",
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/thirdweb-dev/js.git"
|
|
||||||
},
|
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -54,12 +50,12 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
||||||
"@typescript-eslint/parser": "^5.33.0",
|
"@typescript-eslint/parser": "^5.33.0",
|
||||||
"eslint": "^8.21.0",
|
"eslint": "^8.21.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-inclusive-language": "^2.2.0",
|
"eslint-plugin-inclusive-language": "^2.2.0",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-tsdoc": "^0.2.16",
|
"eslint-plugin-tsdoc": "^0.2.16",
|
||||||
"ethers": ">=5.5.1",
|
"ethers": "^5.7.0",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"next": "12.2.0",
|
"next": "12.2.0",
|
||||||
"next-auth": "^4.10.3",
|
"next-auth": "^4.10.3",
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
# thirdweb
|
# thirdweb
|
||||||
|
|
||||||
|
## 0.7.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`baa87a1`](https://github.com/thirdweb-dev/js/commit/baa87a1fbd7eee24ce9a95e16028de8435f85e69), [`4079326`](https://github.com/thirdweb-dev/js/commit/407932680fb024f17f12f578aa22c7f8c0c13339), [`05353fd`](https://github.com/thirdweb-dev/js/commit/05353fd8da82f77fb642bb38a533fb99801aed30)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.9
|
||||||
|
|
||||||
|
## 0.7.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
|
- [#56](https://github.com/thirdweb-dev/js/pull/56) [`e9e71cf`](https://github.com/thirdweb-dev/js/commit/e9e71cfcd892611cd653431dc433b27532e9e3cc) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add basic tests
|
||||||
|
|
||||||
|
- Updated dependencies [[`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.8
|
||||||
|
|
||||||
|
## 0.7.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.7
|
||||||
|
|
||||||
## 0.7.7
|
## 0.7.7
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export const CREATE_MESSAGES = {
|
||||||
|
typeOfProject: "What type of project do you want to create?",
|
||||||
|
projectName: "What is your project named?",
|
||||||
|
framework: "What framework do you want to use?",
|
||||||
|
language: "What language do you want to use?",
|
||||||
|
contract: "What contract do you want to start from?",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const ERROR_MESSAGES = {
|
||||||
|
noConfiguration: "Failed to find a supported project configuration file in current directory"
|
||||||
|
}
|
||||||
@@ -1,36 +1,34 @@
|
|||||||
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
|
import { CREATE_MESSAGES } from "../constants/constants";
|
||||||
|
|
||||||
// this creates an app, can take some time that's fine
|
// this creates an app, can take some time that's fine
|
||||||
jest.setTimeout(120_000);
|
jest.setTimeout(120_000);
|
||||||
|
|
||||||
describe("npx thirdweb create", () => {
|
describe("npx thirdweb create", () => {
|
||||||
it("should create app successfully", async () => {
|
it("should create app (CRA) successfully", async () => {
|
||||||
const { spawn, cleanup, exists } = await prepareEnvironment();
|
const { spawn, cleanup, exists } = await prepareEnvironment();
|
||||||
const {
|
const {
|
||||||
// wait,
|
|
||||||
waitForText,
|
waitForText,
|
||||||
waitForFinish,
|
waitForFinish,
|
||||||
// getStdout,
|
|
||||||
// getStderr,
|
|
||||||
getExitCode,
|
getExitCode,
|
||||||
// debug,
|
|
||||||
pressKey,
|
pressKey,
|
||||||
} = await spawn("node", "./dist/cli/index.js create");
|
} = await spawn("node", "./dist/cli/index.js create");
|
||||||
|
|
||||||
await waitForText("What type of project do you want to create?");
|
await waitForText(CREATE_MESSAGES.typeOfProject);
|
||||||
await pressKey("enter");
|
await pressKey("enter");
|
||||||
await waitForText("What is your project named?");
|
await waitForText(CREATE_MESSAGES.projectName);
|
||||||
await pressKey("enter");
|
await pressKey("enter");
|
||||||
await waitForText("What framework do you want to use?");
|
await waitForText(CREATE_MESSAGES.framework);
|
||||||
|
// select CRA
|
||||||
await pressKey("arrowDown");
|
await pressKey("arrowDown");
|
||||||
await pressKey("enter");
|
await pressKey("enter");
|
||||||
await waitForText("What language do you want to use?");
|
await waitForText(CREATE_MESSAGES.language);
|
||||||
await pressKey("enter");
|
await pressKey("enter");
|
||||||
|
|
||||||
// wait for program to finish
|
// wait for program to finish
|
||||||
await waitForFinish();
|
await waitForFinish();
|
||||||
|
|
||||||
//check if the app was created
|
// check if the app was created
|
||||||
expect(await exists("thirdweb-app/package.json")).toEqual(true);
|
expect(await exists("thirdweb-app/package.json")).toEqual(true);
|
||||||
|
|
||||||
// the process should exit with code 0
|
// the process should exit with code 0
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
|
import { copyFile } from "fs/promises";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { ERROR_MESSAGES } from "../constants/constants";
|
||||||
|
|
||||||
|
// this creates an app, can take some time that's fine
|
||||||
|
jest.setTimeout(120_000);
|
||||||
|
|
||||||
|
describe("npx thirdweb deploy", () => {
|
||||||
|
it("should return deploy page url", async () => {
|
||||||
|
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
||||||
|
|
||||||
|
await copyFile(resolve("./e2e/files/BasicContract.sol"), `${path}/BasicContract.sol`);
|
||||||
|
|
||||||
|
const {
|
||||||
|
waitForText,
|
||||||
|
waitForFinish,
|
||||||
|
getExitCode,
|
||||||
|
writeText,
|
||||||
|
getStdout,
|
||||||
|
} = await spawn("node", "./dist/cli/index.js deploy");
|
||||||
|
|
||||||
|
expect(await exists("BasicContract.sol")).toEqual(true);
|
||||||
|
|
||||||
|
await waitForText(ERROR_MESSAGES.noConfiguration);
|
||||||
|
await writeText("y")
|
||||||
|
|
||||||
|
// wait for program to finish
|
||||||
|
await waitForFinish();
|
||||||
|
|
||||||
|
expect(getStdout().at(-1)).toContain("https://thirdweb.com/contracts/deploy/");
|
||||||
|
|
||||||
|
// the process should exit with code 0
|
||||||
|
expect(getExitCode()).toEqual(0);
|
||||||
|
|
||||||
|
await cleanup(); // cleanup after test
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { CREATE_MESSAGES } from "../constants/constants";
|
||||||
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
|
|
||||||
|
// this creates an app, can take some time that's fine
|
||||||
|
jest.setTimeout(120_000);
|
||||||
|
|
||||||
|
describe("npx thirdweb detect", () => {
|
||||||
|
it("should detect ERC721Base extensions", async () => {
|
||||||
|
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
||||||
|
const create = await spawn("node", "./dist/cli/index.js create");
|
||||||
|
|
||||||
|
await create.waitForText(CREATE_MESSAGES.typeOfProject);
|
||||||
|
// select contract
|
||||||
|
await create.pressKey("arrowDown");
|
||||||
|
await create.pressKey("enter");
|
||||||
|
await create.waitForText(CREATE_MESSAGES.projectName);
|
||||||
|
// use default name
|
||||||
|
await create.pressKey("enter");
|
||||||
|
await create.waitForText(CREATE_MESSAGES.framework);
|
||||||
|
// select hardhat
|
||||||
|
await create.pressKey("enter");
|
||||||
|
await create.waitForText(CREATE_MESSAGES.contract);
|
||||||
|
// select ERC721Base
|
||||||
|
await create.pressKey("arrowDown");
|
||||||
|
await create.pressKey("enter");
|
||||||
|
|
||||||
|
// wait for program to finish
|
||||||
|
await create.waitForFinish();
|
||||||
|
|
||||||
|
// the process should exit with code 0
|
||||||
|
expect(create.getExitCode()).toEqual(0);
|
||||||
|
|
||||||
|
// check if the contract was created
|
||||||
|
expect(await exists("thirdweb-contracts/contracts/Contract.sol")).toEqual(
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// check that hardhat config exists
|
||||||
|
expect(await exists("thirdweb-contracts/hardhat.config.js")).toEqual(true);
|
||||||
|
|
||||||
|
await create.writeText("cd thirdweb-contracts");
|
||||||
|
await create.pressKey("enter");
|
||||||
|
await create.writeText("npm install");
|
||||||
|
await create.pressKey("enter");
|
||||||
|
|
||||||
|
const detect = await spawn(
|
||||||
|
"node",
|
||||||
|
"./dist/cli/index.js detect",
|
||||||
|
"./thirdweb-contracts",
|
||||||
|
);
|
||||||
|
|
||||||
|
// wait for program to finish
|
||||||
|
await detect.waitForFinish();
|
||||||
|
|
||||||
|
const lines = detect.getStdout();
|
||||||
|
|
||||||
|
// Detected extensions
|
||||||
|
expect(lines.findIndex((line) => line.includes("ERC721"))).toBeGreaterThan(
|
||||||
|
-1,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
lines.findIndex((line) => line.includes("ERC721Burnable")),
|
||||||
|
).toBeGreaterThan(-1);
|
||||||
|
expect(
|
||||||
|
lines.findIndex((line) => line.includes("ERC721Mintable")),
|
||||||
|
).toBeGreaterThan(-1);
|
||||||
|
|
||||||
|
// Suggested extensions
|
||||||
|
expect(
|
||||||
|
lines.findIndex((line) => line.includes("- ERC721Enumerable")),
|
||||||
|
).toBeGreaterThan(-1);
|
||||||
|
expect(
|
||||||
|
lines.findIndex((line) => line.includes("- ERC721Droppable")),
|
||||||
|
).toBeGreaterThan(-1);
|
||||||
|
expect(
|
||||||
|
lines.findIndex((line) => line.includes("- ERC721SignatureMint")),
|
||||||
|
).toBeGreaterThan(-1);
|
||||||
|
|
||||||
|
// the process should exit with code 0
|
||||||
|
expect(detect.getExitCode()).toEqual(0);
|
||||||
|
|
||||||
|
await cleanup(); // cleanup after test
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
contract BasicContract {
|
||||||
|
constructor() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
|
import { copyFile } from "fs/promises";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { ERROR_MESSAGES } from "../constants/constants";
|
||||||
|
|
||||||
|
// this creates an app, can take some time that's fine
|
||||||
|
jest.setTimeout(120_000);
|
||||||
|
|
||||||
|
describe("npx thirdweb release", () => {
|
||||||
|
it("should return release page url", async () => {
|
||||||
|
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
||||||
|
|
||||||
|
await copyFile(resolve("./e2e/files/BasicContract.sol"), `${path}/BasicContract.sol`);
|
||||||
|
|
||||||
|
const {
|
||||||
|
waitForText,
|
||||||
|
waitForFinish,
|
||||||
|
getExitCode,
|
||||||
|
writeText,
|
||||||
|
getStdout,
|
||||||
|
} = await spawn("node", "./dist/cli/index.js release");
|
||||||
|
|
||||||
|
expect(await exists("BasicContract.sol")).toEqual(true);
|
||||||
|
|
||||||
|
await waitForText(ERROR_MESSAGES.noConfiguration);
|
||||||
|
await writeText("y")
|
||||||
|
|
||||||
|
// wait for program to finish
|
||||||
|
await waitForFinish();
|
||||||
|
|
||||||
|
expect(getStdout().at(-1)).toContain("https://thirdweb.com/contracts/release/");
|
||||||
|
|
||||||
|
// the process should exit with code 0
|
||||||
|
expect(getExitCode()).toEqual(0);
|
||||||
|
|
||||||
|
await cleanup(); // cleanup after test
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "thirdweb",
|
"name": "thirdweb",
|
||||||
"main": "dist/cli/index.js",
|
"main": "dist/cli/index.js",
|
||||||
"version": "0.7.7",
|
"version": "0.7.10",
|
||||||
"repository": {
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com:thirdweb-dev/js.git",
|
|
||||||
"directory": "packages/cli"
|
|
||||||
},
|
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -26,12 +22,12 @@
|
|||||||
"@types/validate-npm-package-name": "^4.0.0",
|
"@types/validate-npm-package-name": "^4.0.0",
|
||||||
"hardhat": "^2.9.3",
|
"hardhat": "^2.9.3",
|
||||||
"jest": "^29.0.1",
|
"jest": "^29.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.7.1",
|
||||||
"ts-jest": "^28.0.8",
|
"ts-jest": "^28.0.8",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.7.0",
|
||||||
"tsc": "^2.0.4",
|
"tsc": "^2.0.4",
|
||||||
"tsup": "^6.2.3",
|
"tsup": "^6.2.3",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thirdweb-dev/sdk": "*",
|
"@thirdweb-dev/sdk": "*",
|
||||||
@@ -40,7 +36,7 @@
|
|||||||
"commander": "^9.1.0",
|
"commander": "^9.1.0",
|
||||||
"cpy": "^9.0.1",
|
"cpy": "^9.0.1",
|
||||||
"enquirer": "^2.3.6",
|
"enquirer": "^2.3.6",
|
||||||
"ethers": "^5.6.9",
|
"ethers": "^5.7.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"got": "11.8.5",
|
"got": "11.8.5",
|
||||||
"inquirer": "^8.2.3",
|
"inquirer": "^8.2.3",
|
||||||
@@ -56,7 +52,7 @@
|
|||||||
"update-check": "^1.5.4",
|
"update-check": "^1.5.4",
|
||||||
"update-notifier": "^6.0.2",
|
"update-notifier": "^6.0.2",
|
||||||
"validate-npm-package-name": "^4.0.0",
|
"validate-npm-package-name": "^4.0.0",
|
||||||
"yaml": "^2.0.1"
|
"yaml": "^2.1.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"thirdweb": "./dist/cli/index.js"
|
"thirdweb": "./dist/cli/index.js"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $$$$$$\\ $$$$$$$\\ $$\\ $$$$$$\\ $$$$$$$ |$$\\ $$\\ $$\\ $$$$$$\\ $$$$
|
|||||||
updateNotifier({
|
updateNotifier({
|
||||||
pkg,
|
pkg,
|
||||||
shouldNotifyInNpmScript: true,
|
shouldNotifyInNpmScript: true,
|
||||||
//check every time while we're still building the CLI
|
// check every time while we're still building the CLI
|
||||||
updateCheckInterval: 0,
|
updateCheckInterval: 0,
|
||||||
}).notify();
|
}).notify();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export async function detectExtensions(options: any) {
|
|||||||
`Detected extension on ${chalk.blueBright(contractWithFeatures.name)}`,
|
`Detected extension on ${chalk.blueBright(contractWithFeatures.name)}`,
|
||||||
).stopAndPersist({ symbol: "🔎" });
|
).stopAndPersist({ symbol: "🔎" });
|
||||||
contractWithFeatures.enabledFeatures.map((feature) => {
|
contractWithFeatures.enabledFeatures.map((feature) => {
|
||||||
info(`${chalk.green(feature.name)}`);
|
logger.info(`✔️ ${chalk.green(feature.name)}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
logger.info(``);
|
logger.info(``);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import FoundryDetector from "./foundry";
|
|||||||
import HardhatDetector from "./hardhat";
|
import HardhatDetector from "./hardhat";
|
||||||
import TruffleDetector from "./truffle";
|
import TruffleDetector from "./truffle";
|
||||||
import inquirer from "inquirer";
|
import inquirer from "inquirer";
|
||||||
|
import { ERROR_MESSAGES } from "../../../constants/constants";
|
||||||
|
|
||||||
const { Confirm } = require("enquirer");
|
const { Confirm } = require("enquirer");
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ export default async function detect(
|
|||||||
|
|
||||||
//if there is no project returned at all then just return unknown}
|
//if there is no project returned at all then just return unknown}
|
||||||
if (!possibleProjectTypes.length) {
|
if (!possibleProjectTypes.length) {
|
||||||
warn("Failed to find a supported project configuration file in current directory " + path);
|
warn(`${ERROR_MESSAGES.noConfiguration} ${path}`);
|
||||||
const prompt = new Confirm({
|
const prompt = new Confirm({
|
||||||
name: "continue",
|
name: "continue",
|
||||||
message: "Do you want to continue and compile this project with solc instead?",
|
message: "Do you want to continue and compile this project with solc instead?",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { validateNpmName } from "./helpers/validate-pkg";
|
|||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import prompts from "prompts";
|
import prompts from "prompts";
|
||||||
|
import { CREATE_MESSAGES } from "../../constants/constants";
|
||||||
|
|
||||||
let projectType: string = "";
|
let projectType: string = "";
|
||||||
let projectPath: string = "";
|
let projectPath: string = "";
|
||||||
@@ -65,7 +66,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "select",
|
type: "select",
|
||||||
name: "projectType",
|
name: "projectType",
|
||||||
message: "What type of project do you want to create?",
|
message: CREATE_MESSAGES.typeOfProject,
|
||||||
choices: [
|
choices: [
|
||||||
{ title: "App", value: "app" },
|
{ title: "App", value: "app" },
|
||||||
{ title: "Contract", value: "contract" },
|
{ title: "Contract", value: "contract" },
|
||||||
@@ -87,7 +88,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "text",
|
type: "text",
|
||||||
name: "path",
|
name: "path",
|
||||||
message: "What is your project named?",
|
message: CREATE_MESSAGES.projectName,
|
||||||
initial: options.template || defaultName,
|
initial: options.template || defaultName,
|
||||||
validate: (name) => {
|
validate: (name) => {
|
||||||
const validation = validateNpmName(path.basename(path.resolve(name)));
|
const validation = validateNpmName(path.basename(path.resolve(name)));
|
||||||
@@ -123,7 +124,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "select",
|
type: "select",
|
||||||
name: "framework",
|
name: "framework",
|
||||||
message: "What framework do you want to use?",
|
message: CREATE_MESSAGES.framework,
|
||||||
choices: [
|
choices: [
|
||||||
{ title: "Next.js", value: "next" },
|
{ title: "Next.js", value: "next" },
|
||||||
{ title: "Create React App", value: "cra" },
|
{ title: "Create React App", value: "cra" },
|
||||||
@@ -140,7 +141,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "select",
|
type: "select",
|
||||||
name: "language",
|
name: "language",
|
||||||
message: "What language do you want to use?",
|
message: CREATE_MESSAGES.language,
|
||||||
choices: [
|
choices: [
|
||||||
{ title: "JavaScript", value: "javascript" },
|
{ title: "JavaScript", value: "javascript" },
|
||||||
{ title: "TypeScript", value: "typescript" },
|
{ title: "TypeScript", value: "typescript" },
|
||||||
@@ -160,7 +161,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "select",
|
type: "select",
|
||||||
name: "framework",
|
name: "framework",
|
||||||
message: "What framework do you want to use?",
|
message: CREATE_MESSAGES.framework,
|
||||||
choices: [
|
choices: [
|
||||||
{ title: "Hardhat", value: "hardhat" },
|
{ title: "Hardhat", value: "hardhat" },
|
||||||
{ title: "Forge", value: "forge" },
|
{ title: "Forge", value: "forge" },
|
||||||
@@ -177,7 +178,7 @@ export async function twCreate(options: any) {
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "select",
|
type: "select",
|
||||||
name: "baseContract",
|
name: "baseContract",
|
||||||
message: "What contract do you want to start from?",
|
message: CREATE_MESSAGES.contract,
|
||||||
choices: [
|
choices: [
|
||||||
{ title: "Empty Contract", value: "" },
|
{ title: "Empty Contract", value: "" },
|
||||||
{ title: "ERC721 Base", value: "ERC721Base" },
|
{ title: "ERC721 Base", value: "ERC721Base" },
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
(BigInt.prototype as any).toJSON = function () {
|
||||||
|
return this.toString();
|
||||||
|
};
|
||||||
|
|
||||||
console.log(`__tw__${JSON.stringify((globalThis as any).config)}__tw__`);
|
console.log(`__tw__${JSON.stringify((globalThis as any).config)}__tw__`);
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": "@thirdweb-dev/tsconfig/sdk.json",
|
"extends": "@thirdweb-dev/tsconfig/sdk.json",
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["dist", "build", "node_modules"]
|
"exclude": ["dist", "build", "node_modules"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
abis
|
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
# @thirdweb-dev/contracts-js
|
# @thirdweb-dev/contracts-js
|
||||||
|
|
||||||
|
## 1.1.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
|
## 1.1.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#59](https://github.com/thirdweb-dev/js/pull/59) [`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b) Thanks [@jnsdls](https://github.com/jnsdls)! - move `abis` from top level into `dist` in contracts-js
|
||||||
|
|
||||||
## 1.1.5
|
## 1.1.5
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/contracts-js",
|
"name": "@thirdweb-dev/contracts-js",
|
||||||
"version": "1.1.5",
|
"version": "1.1.7",
|
||||||
"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",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
|
||||||
"directory": "packages/contracts-js",
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/thirdweb-dev/js.git"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thirdweb-dev/contracts": "3.1.6-1"
|
"@thirdweb-dev/contracts": "3.1.6-1"
|
||||||
},
|
},
|
||||||
@@ -18,23 +14,17 @@
|
|||||||
"@preconstruct/cli": "^2.2.1",
|
"@preconstruct/cli": "^2.2.1",
|
||||||
"ethers": "^5.7.0",
|
"ethers": "^5.7.0",
|
||||||
"typechain": "^8.1.0",
|
"typechain": "^8.1.0",
|
||||||
"typescript": "^4.8.2"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"ethers": "^5.7.0"
|
"ethers": "^5.7.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"abis/",
|
|
||||||
"dist/"
|
"dist/"
|
||||||
],
|
],
|
||||||
"preconstruct": {
|
|
||||||
"entrypoints": [
|
|
||||||
"index.ts"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"typechain": "rm -rf ./src && typechain --target ethers-v5 --out-dir src '../../node_modules/@thirdweb-dev/contracts/abi/*.json'",
|
"typechain": "rm -rf ./src && typechain --target ethers-v5 --out-dir src '../../node_modules/@thirdweb-dev/contracts/abi/*.json'",
|
||||||
"extract-abi": "node ./scripts/extract-abis.mjs",
|
"extract-abi": "node ./scripts/extract-abis.mjs",
|
||||||
"build": "yarn typechain && yarn extract-abi && tsc && yarn preconstruct build"
|
"build": "yarn typechain && tsc && yarn preconstruct build && yarn extract-abi"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const main = () => {
|
|||||||
"node_modules",
|
"node_modules",
|
||||||
"@thirdweb-dev/contracts/abi",
|
"@thirdweb-dev/contracts/abi",
|
||||||
);
|
);
|
||||||
const destinationFolder = "./abis";
|
const destinationFolder = "./dist/abis";
|
||||||
if (existsSync(destinationFolder)) {
|
if (existsSync(destinationFolder)) {
|
||||||
rmSync(destinationFolder, { recursive: true });
|
rmSync(destinationFolder, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# eslint-config-thirdweb
|
# eslint-config-thirdweb
|
||||||
|
|
||||||
|
## 0.1.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
## 0.1.2
|
## 0.1.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-config-thirdweb",
|
"name": "eslint-config-thirdweb",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"eslint-config-next": "^12.0.8",
|
"eslint-config-next": "^12.0.8",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-react": "^7.28.0",
|
"eslint-config-turbo": "latest",
|
||||||
"eslint-config-turbo": "latest"
|
"eslint-plugin-react": "^7.28.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
}
|
},
|
||||||
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/eslint-config-thirdweb"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
# @thirdweb-dev/react
|
# @thirdweb-dev/react
|
||||||
|
|
||||||
|
## 2.9.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`baa87a1`](https://github.com/thirdweb-dev/js/commit/baa87a1fbd7eee24ce9a95e16028de8435f85e69), [`f2bdf47`](https://github.com/thirdweb-dev/js/commit/f2bdf47b4fd06433be367c9aac6d11a8dbbf1a1a), [`4079326`](https://github.com/thirdweb-dev/js/commit/407932680fb024f17f12f578aa22c7f8c0c13339), [`05353fd`](https://github.com/thirdweb-dev/js/commit/05353fd8da82f77fb642bb38a533fb99801aed30)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.9
|
||||||
|
- @thirdweb-dev/storage@0.2.8
|
||||||
|
|
||||||
|
## 2.9.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
|
- Updated dependencies [[`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.8
|
||||||
|
- @thirdweb-dev/storage@0.2.7
|
||||||
|
|
||||||
|
## 2.9.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b)]:
|
||||||
|
- @thirdweb-dev/sdk@2.4.7
|
||||||
|
|
||||||
## 2.9.4
|
## 2.9.4
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
+14
-18
@@ -1,11 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react",
|
"name": "@thirdweb-dev/react",
|
||||||
"version": "2.9.4",
|
"version": "2.9.7",
|
||||||
"repository": {
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com:thirdweb-dev/js.git",
|
|
||||||
"directory": "packages/react"
|
|
||||||
},
|
|
||||||
"author": "thirdweb eng <[email protected]>",
|
"author": "thirdweb eng <[email protected]>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "dist/thirdweb-dev-react.cjs.js",
|
"main": "dist/thirdweb-dev-react.cjs.js",
|
||||||
@@ -32,8 +28,8 @@
|
|||||||
"@babel/preset-env": "^7.18.10",
|
"@babel/preset-env": "^7.18.10",
|
||||||
"@babel/preset-react": "^7.18.6",
|
"@babel/preset-react": "^7.18.6",
|
||||||
"@babel/preset-typescript": "^7.18.6",
|
"@babel/preset-typescript": "^7.18.6",
|
||||||
"@microsoft/api-documenter": "^7.15.3",
|
"@microsoft/api-documenter": "^7.19.4",
|
||||||
"@microsoft/api-extractor": "^7.19.4",
|
"@microsoft/api-extractor": "^7.29.2",
|
||||||
"@microsoft/tsdoc": "^0.14.1",
|
"@microsoft/tsdoc": "^0.14.1",
|
||||||
"@playwright/experimental-ct-react": "^1.25.1",
|
"@playwright/experimental-ct-react": "^1.25.1",
|
||||||
"@playwright/test": "^1.25.1",
|
"@playwright/test": "^1.25.1",
|
||||||
@@ -42,19 +38,19 @@
|
|||||||
"@types/mime": "^3.0.1",
|
"@types/mime": "^3.0.1",
|
||||||
"@types/react": "^18.0.5",
|
"@types/react": "^18.0.5",
|
||||||
"@types/react-dom": "^18.0.6",
|
"@types/react-dom": "^18.0.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
||||||
"@typescript-eslint/parser": "^5.2.0",
|
"@typescript-eslint/parser": "^5.33.0",
|
||||||
"eslint": "^8.9.0",
|
"eslint": "^8.21.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.24.2",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-inclusive-language": "^2.1.1",
|
"eslint-plugin-inclusive-language": "^2.2.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-tsdoc": "^0.2.14",
|
"eslint-plugin-tsdoc": "^0.2.16",
|
||||||
"ethers": "^5.6.1",
|
"ethers": "^5.7.0",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.7.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"typescript": "^4.6.2"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.10.0",
|
"@emotion/react": "^11.10.0",
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extension": ["ts"],
|
||||||
|
"require": ["@swc-node/register", "./test/hooks.ts"]
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
@@ -1,5 +1,37 @@
|
|||||||
# @thirdweb-dev/sdk
|
# @thirdweb-dev/sdk
|
||||||
|
|
||||||
|
## 2.4.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#74](https://github.com/thirdweb-dev/js/pull/74) [`baa87a1`](https://github.com/thirdweb-dev/js/commit/baa87a1fbd7eee24ce9a95e16028de8435f85e69) Thanks [@nkrishang](https://github.com/nkrishang)! - Updated forwarder address for Goerli
|
||||||
|
|
||||||
|
- [#75](https://github.com/thirdweb-dev/js/pull/75) [`4079326`](https://github.com/thirdweb-dev/js/commit/407932680fb024f17f12f578aa22c7f8c0c13339) Thanks [@jnsdls](https://github.com/jnsdls)! - add a default for factory deployments initializer function ("initialize")
|
||||||
|
|
||||||
|
- [#71](https://github.com/thirdweb-dev/js/pull/71) [`05353fd`](https://github.com/thirdweb-dev/js/commit/05353fd8da82f77fb642bb38a533fb99801aed30) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Allow for chain agnostic gasless tx
|
||||||
|
|
||||||
|
- Updated dependencies [[`f2bdf47`](https://github.com/thirdweb-dev/js/commit/f2bdf47b4fd06433be367c9aac6d11a8dbbf1a1a)]:
|
||||||
|
- @thirdweb-dev/storage@0.2.8
|
||||||
|
|
||||||
|
## 2.4.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#61](https://github.com/thirdweb-dev/js/pull/61) [`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6) Thanks [@jnsdls](https://github.com/jnsdls)! - fix versions in dependencies before releasing stable
|
||||||
|
|
||||||
|
- Updated dependencies [[`3287c2b`](https://github.com/thirdweb-dev/js/commit/3287c2b0f233332fe4a095f973deed8efab91db6)]:
|
||||||
|
- @thirdweb-dev/contracts-js@1.1.7
|
||||||
|
- @thirdweb-dev/storage@0.2.7
|
||||||
|
|
||||||
|
## 2.4.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#59](https://github.com/thirdweb-dev/js/pull/59) [`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b) Thanks [@jnsdls](https://github.com/jnsdls)! - move `abis` from top level into `dist` in contracts-js
|
||||||
|
|
||||||
|
- Updated dependencies [[`6ba9cad`](https://github.com/thirdweb-dev/js/commit/6ba9cad8d8b933256599dc3b147601cd4828c89b)]:
|
||||||
|
- @thirdweb-dev/contracts-js@1.1.6
|
||||||
|
|
||||||
## 2.4.6
|
## 2.4.6
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -3,13 +3,9 @@
|
|||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
build:
|
|
||||||
yarn run build
|
|
||||||
|
|
||||||
test: FORCE
|
test: FORCE
|
||||||
docker start hh-node || docker run --name hh-node -d -p 8545:8545 ethereumoptimism/hardhat
|
docker start hh-node || docker run --name hh-node -d -p 8545:8545 ethereumoptimism/hardhat
|
||||||
./test/scripts/waitForHardhatNode.sh
|
./test/scripts/waitForHardhatNode.sh
|
||||||
yarn run build
|
|
||||||
yarn run test:all
|
yarn run test:all
|
||||||
|
|
||||||
FORCE: ;
|
FORCE: ;
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
|
||||||
import { expect } from "chai";
|
|
||||||
|
|
||||||
describe("node", () => {
|
|
||||||
it("getContract().metadata.get()", async () => {
|
|
||||||
const { execute, cleanup } = await prepareEnvironment();
|
|
||||||
|
|
||||||
const { code, stdout, stderr } = await execute(
|
|
||||||
"node",
|
|
||||||
"./e2e/node-scripts/basic.js",
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log("stderr", stderr);
|
|
||||||
|
|
||||||
expect(code).to.equal(0);
|
|
||||||
expect(stdout[0]).to.contain("mintED Toasts");
|
|
||||||
expect(stderr.length).to.equal(0);
|
|
||||||
|
|
||||||
await cleanup();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
const { ThirdwebSDK } = require("../..");
|
|
||||||
|
|
||||||
(async function () {
|
|
||||||
const sdk = new ThirdwebSDK("rinkeby");
|
|
||||||
const c = await sdk.getContract("0x10fDF181eDceAEF044328BeF07979FfaE209023f");
|
|
||||||
console.log(await c.metadata.get());
|
|
||||||
})();
|
|
||||||
+22
-29
@@ -1,12 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/sdk",
|
"name": "@thirdweb-dev/sdk",
|
||||||
"version": "2.4.6",
|
"version": "2.4.9",
|
||||||
"description": "The main thirdweb SDK.",
|
"description": "The main thirdweb SDK.",
|
||||||
"repository": {
|
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||||
"directory": "packages/sdk",
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/thirdweb-dev/js.git"
|
|
||||||
},
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"main": "dist/thirdweb-dev-sdk.cjs.js",
|
"main": "dist/thirdweb-dev-sdk.cjs.js",
|
||||||
"module": "dist/thirdweb-dev-sdk.esm.js",
|
"module": "dist/thirdweb-dev-sdk.esm.js",
|
||||||
@@ -25,48 +21,46 @@
|
|||||||
"generate-docs": "yarn full-build && yarn generate-md-docs",
|
"generate-docs": "yarn full-build && yarn generate-md-docs",
|
||||||
"generate-snippets": "node ./scripts/generate-snippets.mjs && node ./scripts/generate-feature-snippets.mjs",
|
"generate-snippets": "node ./scripts/generate-snippets.mjs && node ./scripts/generate-feature-snippets.mjs",
|
||||||
"build": "tsc && preconstruct build",
|
"build": "tsc && preconstruct build",
|
||||||
"test:all": "ts-mocha --parallel --paths -t 120000 -r esm -p tsconfig.testing.json './test/**/*.test.ts'",
|
"test:all": "SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000 --parallel './test/**/*.test.ts'",
|
||||||
"test": "make test",
|
"test": "make test",
|
||||||
"test:single": "ts-mocha --paths -t 120000 -r esm -p tsconfig.testing.json",
|
"test:single": "SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000 --"
|
||||||
"e2e": "ts-mocha --parallel --paths -t 120000 -r esm -p tsconfig.testing.json './e2e/**/*.test.ts'"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cbor": "^8.1.0",
|
|
||||||
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
||||||
"@gmrchk/cli-testing-library": "^0.1.2",
|
"@gmrchk/cli-testing-library": "^0.1.2",
|
||||||
"@microsoft/api-documenter": "^7.13.53",
|
"@microsoft/api-documenter": "^7.19.4",
|
||||||
"@microsoft/api-extractor": "^7.18.10",
|
"@microsoft/api-extractor": "^7.29.2",
|
||||||
"@microsoft/tsdoc": "^0.14.1",
|
"@microsoft/tsdoc": "^0.14.1",
|
||||||
"@nomiclabs/hardhat-ethers": "2.0.5",
|
"@nomiclabs/hardhat-ethers": "2.0.5",
|
||||||
"@preconstruct/cli": "^2.2.1",
|
"@preconstruct/cli": "^2.2.1",
|
||||||
|
"@swc-node/register": "^1.5.1",
|
||||||
"@swc/core": "^1.2.177",
|
"@swc/core": "^1.2.177",
|
||||||
"@typechain/ethers-v5": "10.0.0",
|
"@typechain/ethers-v5": "10.0.0",
|
||||||
"@types/chai": "^4.3.1",
|
"@types/chai": "^4.3.3",
|
||||||
"@types/deep-equal-in-any-order": "^1.0.1",
|
"@types/deep-equal-in-any-order": "^1.0.1",
|
||||||
"@types/expect": "^24.3.0",
|
"@types/expect": "^24.3.0",
|
||||||
"@types/mocha": "^9.1.1",
|
"@types/mocha": "^9.1.1",
|
||||||
"@types/node": "^17.0.0",
|
"@types/node": "^18.0.0",
|
||||||
"@types/uuid": "^8.3.3",
|
"@types/uuid": "^8.3.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
||||||
"@typescript-eslint/parser": "^5.2.0",
|
"@typescript-eslint/parser": "^5.33.0",
|
||||||
|
"cbor": "^8.1.0",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"deep-equal-in-any-order": "^1.1.18",
|
"deep-equal-in-any-order": "^1.1.18",
|
||||||
"eslint": "^8",
|
"eslint": "^8.21.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.24.2",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-inclusive-language": "^2.1.1",
|
"eslint-plugin-inclusive-language": "^2.2.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-tsdoc": "^0.2.14",
|
"eslint-plugin-tsdoc": "^0.2.16",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"ethers": "^5.6.2",
|
"ethers": "^5.7.0",
|
||||||
"hardhat": "2.9.3",
|
"hardhat": "^2.9.3",
|
||||||
"mocha": "^10.0.0",
|
"mocha": "^10.0.0",
|
||||||
"node-stdlib-browser": "^1.2.0",
|
"node-stdlib-browser": "^1.2.0",
|
||||||
"prettier": "^2.4.1",
|
"prettier": "^2.7.1",
|
||||||
"ts-mocha": "^10.0.0",
|
"typechain": "^8.1.0",
|
||||||
"ts-node": "^10.7.0",
|
"typescript": "^4.7.4"
|
||||||
"typechain": "^8.0.0",
|
|
||||||
"typescript": "^4.6.2"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"ethers": "^5"
|
"ethers": "^5"
|
||||||
@@ -93,6 +87,5 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/thirdweb-dev/js/issues"
|
"url": "https://github.com/thirdweb-dev/js/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/thirdweb-dev/js/blob/main/packages/sdk/README.md",
|
|
||||||
"author": "thirdweb eng <[email protected]>"
|
"author": "thirdweb eng <[email protected]>"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,14 @@ export async function prepareClaim(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Snapshot =
|
||||||
|
| {
|
||||||
|
address: string;
|
||||||
|
proof: string[];
|
||||||
|
maxClaimable: string;
|
||||||
|
}[]
|
||||||
|
| undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @param merkleRoot
|
* @param merkleRoot
|
||||||
@@ -122,12 +130,12 @@ export async function fetchSnapshot(
|
|||||||
merkleRoot: string,
|
merkleRoot: string,
|
||||||
merkleMetadata: Record<string, string> | undefined,
|
merkleMetadata: Record<string, string> | undefined,
|
||||||
storage: IStorage,
|
storage: IStorage,
|
||||||
) {
|
): Promise<Snapshot> {
|
||||||
if (!merkleMetadata) {
|
if (!merkleMetadata) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const snapshotUri = merkleMetadata[merkleRoot];
|
const snapshotUri = merkleMetadata[merkleRoot];
|
||||||
let snapshot = undefined;
|
let snapshot: Snapshot = undefined;
|
||||||
if (snapshotUri) {
|
if (snapshotUri) {
|
||||||
const raw = await storage.get(snapshotUri);
|
const raw = await storage.get(snapshotUri);
|
||||||
const snapshotData = SnapshotSchema.parse(raw);
|
const snapshotData = SnapshotSchema.parse(raw);
|
||||||
@@ -203,7 +211,11 @@ export async function getClaimerProofs(
|
|||||||
merkleMetadata: Record<string, string>,
|
merkleMetadata: Record<string, string>,
|
||||||
storage: IStorage,
|
storage: IStorage,
|
||||||
): Promise<{ maxClaimable: BigNumber; proof: string[] }> {
|
): Promise<{ maxClaimable: BigNumber; proof: string[] }> {
|
||||||
const claims = await fetchSnapshot(merkleRoot, merkleMetadata, storage);
|
const claims: Snapshot = await fetchSnapshot(
|
||||||
|
merkleRoot,
|
||||||
|
merkleMetadata,
|
||||||
|
storage,
|
||||||
|
);
|
||||||
if (claims === undefined) {
|
if (claims === undefined) {
|
||||||
return {
|
return {
|
||||||
proof: [],
|
proof: [],
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
|
import {
|
||||||
|
getNativeTokenByChainId,
|
||||||
|
NATIVE_TOKEN_ADDRESS,
|
||||||
|
} from "../constants/currency";
|
||||||
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
||||||
|
import { AmountSchema } from "../schema/shared";
|
||||||
|
import { Amount, Currency, CurrencyValue, Price } from "../types/currency";
|
||||||
|
import { BaseERC20 } from "../types/eips";
|
||||||
|
import { IERC20, IERC20Metadata } from "@thirdweb-dev/contracts-js";
|
||||||
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
|
import ERC20MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC20Metadata.json";
|
||||||
import {
|
import {
|
||||||
BigNumber,
|
BigNumber,
|
||||||
BigNumberish,
|
BigNumberish,
|
||||||
@@ -8,16 +18,6 @@ import {
|
|||||||
utils,
|
utils,
|
||||||
ethers,
|
ethers,
|
||||||
} from "ethers";
|
} from "ethers";
|
||||||
import {
|
|
||||||
getNativeTokenByChainId,
|
|
||||||
NATIVE_TOKEN_ADDRESS,
|
|
||||||
} from "../constants/currency";
|
|
||||||
import { Amount, Currency, CurrencyValue, Price } from "../types/currency";
|
|
||||||
import { AmountSchema } from "../schema/shared";
|
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
|
||||||
import ERC20MetadataAbi from "@thirdweb-dev/contracts-js/abis/IERC20Metadata.json";
|
|
||||||
import { BaseERC20 } from "../types/eips";
|
|
||||||
import { IERC20, IERC20Metadata } from "@thirdweb-dev/contracts-js";
|
|
||||||
|
|
||||||
export function isNativeToken(tokenAddress: string): boolean {
|
export function isNativeToken(tokenAddress: string): boolean {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ function hexToBytes(hex: string | number) {
|
|||||||
throw new Error(`Given value "${hex}" is not a valid hex string.`);
|
throw new Error(`Given value "${hex}" is not a valid hex string.`);
|
||||||
}
|
}
|
||||||
hex = hex.replace(/^0x/i, "");
|
hex = hex.replace(/^0x/i, "");
|
||||||
const bytes = [];
|
const bytes: number[] = [];
|
||||||
for (let c = 0; c < hex.length; c += 2) {
|
for (let c = 0; c < hex.length; c += 2) {
|
||||||
bytes.push(parseInt(hex.slice(c, c + 2), 16));
|
bytes.push(parseInt(hex.slice(c, c + 2), 16));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ export const ForwardRequest = [
|
|||||||
{ name: "data", type: "bytes" },
|
{ name: "data", type: "bytes" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const ChainAwareForwardRequest = [
|
||||||
|
{ name: "from", type: "address" },
|
||||||
|
{ name: "to", type: "address" },
|
||||||
|
{ name: "value", type: "uint256" },
|
||||||
|
{ name: "gas", type: "uint256" },
|
||||||
|
{ name: "nonce", type: "uint256" },
|
||||||
|
{ name: "data", type: "bytes" },
|
||||||
|
{ name: "chainid", type: "uint256" },
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import { BigNumber, BigNumberish, Contract, providers } from "ethers";
|
|
||||||
import {
|
import {
|
||||||
InterfaceId_IERC1155,
|
InterfaceId_IERC1155,
|
||||||
InterfaceId_IERC721,
|
InterfaceId_IERC721,
|
||||||
} from "../constants/contract";
|
} from "../constants/contract";
|
||||||
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
|
||||||
import { SignerOrProvider } from "../core";
|
import { SignerOrProvider } from "../core";
|
||||||
|
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
||||||
|
import { MAX_BPS } from "../schema/shared";
|
||||||
import {
|
import {
|
||||||
NewAuctionListing,
|
NewAuctionListing,
|
||||||
NewDirectListing,
|
NewDirectListing,
|
||||||
Offer,
|
Offer,
|
||||||
} from "../types/marketplace";
|
} from "../types/marketplace";
|
||||||
import invariant from "tiny-invariant";
|
|
||||||
import { fetchCurrencyValue } from "./currency";
|
import { fetchCurrencyValue } from "./currency";
|
||||||
import { MAX_BPS } from "../schema/shared";
|
|
||||||
import { IERC1155, IERC165, IERC721 } from "@thirdweb-dev/contracts-js";
|
import { IERC1155, IERC165, IERC721 } from "@thirdweb-dev/contracts-js";
|
||||||
import ERC1155Abi from "@thirdweb-dev/contracts-js/abis/IERC1155.json";
|
import ERC165Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC165.json";
|
||||||
import ERC721Abi from "@thirdweb-dev/contracts-js/abis/IERC721.json";
|
import ERC721Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC721.json";
|
||||||
import ERC165Abi from "@thirdweb-dev/contracts-js/abis/IERC165.json";
|
import ERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155.json";
|
||||||
|
import { BigNumber, BigNumberish, Contract, providers } from "ethers";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method checks if the given token is approved for the transferrerContractAddress contract.
|
* This method checks if the given token is approved for the transferrerContractAddress contract.
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { BigNumber, BigNumberish, Contract, ethers, providers } from "ethers";
|
import {
|
||||||
|
InterfaceId_IERC1155,
|
||||||
|
InterfaceId_IERC721,
|
||||||
|
} from "../constants/contract";
|
||||||
import {
|
import {
|
||||||
CommonNFTInput,
|
CommonNFTInput,
|
||||||
CommonNFTOutput,
|
CommonNFTOutput,
|
||||||
@@ -6,17 +9,18 @@ import {
|
|||||||
NFTMetadataInput,
|
NFTMetadataInput,
|
||||||
NFTMetadataOrUri,
|
NFTMetadataOrUri,
|
||||||
} from "../schema/tokens/common";
|
} from "../schema/tokens/common";
|
||||||
import type { IStorage } from "@thirdweb-dev/storage";
|
import { UploadProgressEvent } from "../types/index";
|
||||||
import { IERC1155Metadata, IERC165, IERC721Metadata } from "@thirdweb-dev/contracts-js";
|
|
||||||
import { NotFoundError } from "./error";
|
import { NotFoundError } from "./error";
|
||||||
import {
|
import {
|
||||||
InterfaceId_IERC1155,
|
IERC1155Metadata,
|
||||||
InterfaceId_IERC721,
|
IERC165,
|
||||||
} from "../constants/contract";
|
IERC721Metadata,
|
||||||
import ERC721MetadataAbi from "@thirdweb-dev/contracts-js/abis/IERC721Metadata.json";
|
} from "@thirdweb-dev/contracts-js";
|
||||||
import ERC1155MetadataAbi from "@thirdweb-dev/contracts-js/abis/IERC1155Metadata.json";
|
import ERC165MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC165.json";
|
||||||
import ERC165MetadataAbi from "@thirdweb-dev/contracts-js/abis/IERC165.json";
|
import ERC721MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC721Metadata.json";
|
||||||
import { UploadProgressEvent } from "../types/index";
|
import ERC1155MetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Metadata.json";
|
||||||
|
import type { IStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { BigNumber, BigNumberish, Contract, ethers, providers } from "ethers";
|
||||||
|
|
||||||
const FALLBACK_METADATA = {
|
const FALLBACK_METADATA = {
|
||||||
name: "Failed to load NFT metadata",
|
name: "Failed to load NFT metadata",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { ethers, Signer, providers } from "ethers";
|
|||||||
export interface EIP712StandardDomain {
|
export interface EIP712StandardDomain {
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
chainId: number;
|
chainId?: number;
|
||||||
verifyingContract: string;
|
verifyingContract: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const OZ_DEFENDER_FORWARDER_ADDRESS =
|
|||||||
|
|
||||||
const TWRegistry_address = "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd";
|
const TWRegistry_address = "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd";
|
||||||
const TWFactory_address = "0x5DBC7B840baa9daBcBe9D2492E45D7244B54A2A0";
|
const TWFactory_address = "0x5DBC7B840baa9daBcBe9D2492E45D7244B54A2A0";
|
||||||
const ContractPublisher_address = "0x58c892e6bc196371f7fb425177b0E2aA906BC007"; // Polygon only
|
const ContractPublisher_address = "0x664244560eBa21Bf82d7150C791bE1AbcD5B4cd7"; // Polygon only
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -17,6 +17,7 @@ const ContractPublisher_address = "0x58c892e6bc196371f7fb425177b0E2aA906BC007";
|
|||||||
export const CONTRACT_ADDRESSES: Record<
|
export const CONTRACT_ADDRESSES: Record<
|
||||||
SUPPORTED_CHAIN_ID,
|
SUPPORTED_CHAIN_ID,
|
||||||
{
|
{
|
||||||
|
openzeppelinForwarder: string;
|
||||||
biconomyForwarder: string;
|
biconomyForwarder: string;
|
||||||
twFactory: string;
|
twFactory: string;
|
||||||
twRegistry: string;
|
twRegistry: string;
|
||||||
@@ -24,90 +25,105 @@ export const CONTRACT_ADDRESSES: Record<
|
|||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
[ChainId.Mainnet]: {
|
[ChainId.Mainnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0x84a0856b038eaAd1cC7E297cF34A7e72685A8693",
|
biconomyForwarder: "0x84a0856b038eaAd1cC7E297cF34A7e72685A8693",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.Rinkeby]: {
|
[ChainId.Rinkeby]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0xFD4973FeB2031D4409fB57afEE5dF2051b171104",
|
biconomyForwarder: "0xFD4973FeB2031D4409fB57afEE5dF2051b171104",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
||||||
},
|
},
|
||||||
[ChainId.Goerli]: {
|
[ChainId.Goerli]: {
|
||||||
|
openzeppelinForwarder: "0x5001A14CA6163143316a7C614e30e6041033Ac20",
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0xB1Bd9d7942A250BA2Dce27DD601F2ED4211A60C4",
|
twBYOCRegistry: "0xB1Bd9d7942A250BA2Dce27DD601F2ED4211A60C4",
|
||||||
},
|
},
|
||||||
[ChainId.Polygon]: {
|
[ChainId.Polygon]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0x86C80a8aa58e0A4fa09A69624c31Ab2a6CAD56b8",
|
biconomyForwarder: "0x86C80a8aa58e0A4fa09A69624c31Ab2a6CAD56b8",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0x308473Be900F4185A56587dE54bDFF5E8f7a6AE7",
|
twBYOCRegistry: "0x308473Be900F4185A56587dE54bDFF5E8f7a6AE7",
|
||||||
},
|
},
|
||||||
[ChainId.Mumbai]: {
|
[ChainId.Mumbai]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0x9399BB24DBB5C4b782C70c2969F58716Ebbd6a3b",
|
biconomyForwarder: "0x9399BB24DBB5C4b782C70c2969F58716Ebbd6a3b",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0x3F17972CB27506eb4a6a3D59659e0B57a43fd16C",
|
twBYOCRegistry: "0x3F17972CB27506eb4a6a3D59659e0B57a43fd16C",
|
||||||
},
|
},
|
||||||
[ChainId.Avalanche]: {
|
[ChainId.Avalanche]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0x64CD353384109423a966dCd3Aa30D884C9b2E057",
|
biconomyForwarder: "0x64CD353384109423a966dCd3Aa30D884C9b2E057",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.AvalancheFujiTestnet]: {
|
[ChainId.AvalancheFujiTestnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: "0x6271Ca63D30507f2Dcbf99B52787032506D75BBF",
|
biconomyForwarder: "0x6271Ca63D30507f2Dcbf99B52787032506D75BBF",
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
||||||
},
|
},
|
||||||
[ChainId.Fantom]: {
|
[ChainId.Fantom]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: "0x97EA0Fcc552D5A8Fb5e9101316AAd0D62Ea0876B",
|
twFactory: "0x97EA0Fcc552D5A8Fb5e9101316AAd0D62Ea0876B",
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.FantomTestnet]: {
|
[ChainId.FantomTestnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: TWFactory_address,
|
twFactory: TWFactory_address,
|
||||||
twRegistry: TWRegistry_address,
|
twRegistry: TWRegistry_address,
|
||||||
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
|
||||||
},
|
},
|
||||||
[ChainId.Arbitrum]: {
|
[ChainId.Arbitrum]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
||||||
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.ArbitrumTestnet]: {
|
[ChainId.ArbitrumTestnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: "0xb0435b47ad26115A39c59735b814f3769F07C2c1",
|
twFactory: "0xb0435b47ad26115A39c59735b814f3769F07C2c1",
|
||||||
twRegistry: "0xcF4c511551aE4dab1F997866FC3900cd2aaeC40D",
|
twRegistry: "0xcF4c511551aE4dab1F997866FC3900cd2aaeC40D",
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.Optimism]: {
|
[ChainId.Optimism]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
||||||
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.OptimismTestnet]: {
|
[ChainId.OptimismTestnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
||||||
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
},
|
},
|
||||||
[ChainId.BinanceSmartChainMainnet]: {
|
[ChainId.BinanceSmartChainMainnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
||||||
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
twRegistry: "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd",
|
||||||
},
|
},
|
||||||
[ChainId.BinanceSmartChainTestnet]: {
|
[ChainId.BinanceSmartChainTestnet]: {
|
||||||
|
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
|
||||||
biconomyForwarder: constants.AddressZero,
|
biconomyForwarder: constants.AddressZero,
|
||||||
twBYOCRegistry: constants.AddressZero,
|
twBYOCRegistry: constants.AddressZero,
|
||||||
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import DelayedRevealAbi from "@thirdweb-dev/contracts-js/abis/DelayedReveal.json";
|
import DelayedRevealAbi from "@thirdweb-dev/contracts-js/dist/abis/DelayedReveal.json";
|
||||||
import DropSinglePhase1155 from "@thirdweb-dev/contracts-js/abis/DropSinglePhase1155.json";
|
import DropSinglePhase1155 from "@thirdweb-dev/contracts-js/dist/abis/DropSinglePhase1155.json";
|
||||||
import IBurnableERC1155Abi from "@thirdweb-dev/contracts-js/abis/IBurnableERC1155.json";
|
import IBurnableERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IBurnableERC1155.json";
|
||||||
import Erc1155Abi from "@thirdweb-dev/contracts-js/abis/IERC1155.json";
|
import Erc1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155.json";
|
||||||
import Erc1155EnumerableAbi from "@thirdweb-dev/contracts-js/abis/IERC1155Enumerable.json";
|
import Erc1155EnumerableAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155Enumerable.json";
|
||||||
import ILazyMintAbi from "@thirdweb-dev/contracts-js/abis/ILazyMint.json";
|
import ILazyMintAbi from "@thirdweb-dev/contracts-js/dist/abis/ILazyMint.json";
|
||||||
import IMintableERC1155Abi from "@thirdweb-dev/contracts-js/abis/IMintableERC1155.json";
|
import IMintableERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC1155.json";
|
||||||
import MulticallAbi from "@thirdweb-dev/contracts-js/abis/IMulticall.json";
|
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
||||||
import ISignatureMintERC1155Abi from "@thirdweb-dev/contracts-js/abis/ISignatureMintERC1155.json";
|
import ISignatureMintERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC1155.json";
|
||||||
|
|
||||||
export const FEATURE_EDITION_BURNABLE = {
|
export const FEATURE_EDITION_BURNABLE = {
|
||||||
name: "ERC1155Burnable",
|
name: "ERC1155Burnable",
|
||||||
@@ -114,6 +114,7 @@ export const FEATURE_EDITION = {
|
|||||||
[FEATURE_EDITION_MINTABLE.name]: FEATURE_EDITION_MINTABLE,
|
[FEATURE_EDITION_MINTABLE.name]: FEATURE_EDITION_MINTABLE,
|
||||||
[FEATURE_EDITION_DROPPABLE.name]: FEATURE_EDITION_DROPPABLE,
|
[FEATURE_EDITION_DROPPABLE.name]: FEATURE_EDITION_DROPPABLE,
|
||||||
[FEATURE_EDITION_REVEALABLE.name]: FEATURE_EDITION_REVEALABLE,
|
[FEATURE_EDITION_REVEALABLE.name]: FEATURE_EDITION_REVEALABLE,
|
||||||
[FEATURE_EDITION_SIGNATURE_MINTABLE.name]: FEATURE_EDITION_SIGNATURE_MINTABLE,
|
[FEATURE_EDITION_SIGNATURE_MINTABLE.name]:
|
||||||
|
FEATURE_EDITION_SIGNATURE_MINTABLE,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import IBurnableERC20Abi from "@thirdweb-dev/contracts-js/abis/IBurnableERC20.json";
|
import IBurnableERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IBurnableERC20.json";
|
||||||
import IDropSinglePhase from "@thirdweb-dev/contracts-js/abis/IDropSinglePhase.json";
|
import IDropSinglePhase from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase.json";
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
import IMintableERC20Abi from "@thirdweb-dev/contracts-js/abis/IMintableERC20.json";
|
import IMintableERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC20.json";
|
||||||
import MulticallAbi from "@thirdweb-dev/contracts-js/abis/IMulticall.json";
|
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
||||||
import ISignatureMintERC20Abi from "@thirdweb-dev/contracts-js/abis/ISignatureMintERC20.json";
|
import ISignatureMintERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/ISignatureMintERC20.json";
|
||||||
|
|
||||||
export const FEATURE_TOKEN_DROPPABLE = {
|
export const FEATURE_TOKEN_DROPPABLE = {
|
||||||
name: "ERC20Droppable",
|
name: "ERC20Droppable",
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import Erc721Abi from "@thirdweb-dev/contracts-js/abis/IERC721.json";
|
import IBurnableERC721Abi from "@thirdweb-dev/contracts-js/dist/abis/IBurnableERC721.json";
|
||||||
import Erc721EnumerableAbi from "@thirdweb-dev/contracts-js/abis/IERC721Enumerable.json";
|
import DelayedRevealAbi from "@thirdweb-dev/contracts-js/dist/abis/IDelayedReveal.json";
|
||||||
import Erc721SupplyAbi from "@thirdweb-dev/contracts-js/abis/IERC721Supply.json";
|
import IDropSinglePhase from "@thirdweb-dev/contracts-js/dist/abis/IDropSinglePhase.json";
|
||||||
import IMintableERC721Abi from "@thirdweb-dev/contracts-js/abis/IMintableERC721.json";
|
import Erc721Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC721.json";
|
||||||
import MulticallAbi from "@thirdweb-dev/contracts-js/abis/IMulticall.json";
|
import Erc721EnumerableAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC721Enumerable.json";
|
||||||
import DelayedRevealAbi from "@thirdweb-dev/contracts-js/abis/IDelayedReveal.json";
|
import Erc721SupplyAbi from "@thirdweb-dev/contracts-js/dist/abis/IERC721Supply.json";
|
||||||
import ILazyMintAbi from "@thirdweb-dev/contracts-js/abis/ILazyMint.json";
|
import ILazyMintAbi from "@thirdweb-dev/contracts-js/dist/abis/ILazyMint.json";
|
||||||
import IDropSinglePhase from "@thirdweb-dev/contracts-js/abis/IDropSinglePhase.json";
|
import IMintableERC721Abi from "@thirdweb-dev/contracts-js/dist/abis/IMintableERC721.json";
|
||||||
import SignatureMintERC721Abi from "@thirdweb-dev/contracts-js/abis/SignatureMintERC721.json";
|
import MulticallAbi from "@thirdweb-dev/contracts-js/dist/abis/IMulticall.json";
|
||||||
import IBurnableERC721Abi from "@thirdweb-dev/contracts-js/abis/IBurnableERC721.json";
|
import SignatureMintERC721Abi from "@thirdweb-dev/contracts-js/dist/abis/SignatureMintERC721.json";
|
||||||
|
|
||||||
export const FEATURE_NFT_BURNABLE = {
|
export const FEATURE_NFT_BURNABLE = {
|
||||||
name: "ERC721Burnable",
|
name: "ERC721Burnable",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import IContractMetadataAbi from "@thirdweb-dev/contracts-js/abis/IContractMetadata.json";
|
import IContractMetadataAbi from "@thirdweb-dev/contracts-js/dist/abis/IContractMetadata.json";
|
||||||
import IPermissionsAbi from "@thirdweb-dev/contracts-js/abis/IPermissions.json";
|
import IPermissionsAbi from "@thirdweb-dev/contracts-js/dist/abis/IPermissions.json";
|
||||||
import IThirdwebPlatformFeeAbi from "@thirdweb-dev/contracts-js/abis/IPlatformFee.json";
|
import IThirdwebPlatformFeeAbi from "@thirdweb-dev/contracts-js/dist/abis/IPlatformFee.json";
|
||||||
import IThirdwebPrimarySaleAbi from "@thirdweb-dev/contracts-js/abis/IPrimarySale.json";
|
import IThirdwebPrimarySaleAbi from "@thirdweb-dev/contracts-js/dist/abis/IPrimarySale.json";
|
||||||
import IThirdwebRoyaltyAbi from "@thirdweb-dev/contracts-js/abis/IRoyalty.json";
|
import IThirdwebRoyaltyAbi from "@thirdweb-dev/contracts-js/dist/abis/IRoyalty.json";
|
||||||
|
|
||||||
export const FEATURE_ROYALTY = {
|
export const FEATURE_ROYALTY = {
|
||||||
name: "Royalty",
|
name: "Royalty",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import { SDKOptions } from "../schema/sdk-options";
|
|||||||
import { NFTMetadata, NFTMetadataOrUri } from "../schema/tokens/common";
|
import { NFTMetadata, NFTMetadataOrUri } from "../schema/tokens/common";
|
||||||
import { QueryAllParams, UploadProgressEvent } from "../types";
|
import { QueryAllParams, UploadProgressEvent } from "../types";
|
||||||
import { DropERC1155 } from "@thirdweb-dev/contracts-js";
|
import { DropERC1155 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/DropERC1155.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/DropERC1155.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import {
|
|||||||
} from "../schema/tokens/edition";
|
} from "../schema/tokens/edition";
|
||||||
import { QueryAllParams } from "../types";
|
import { QueryAllParams } from "../types";
|
||||||
import { TokenERC1155 } from "@thirdweb-dev/contracts-js";
|
import { TokenERC1155 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/TokenERC1155.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/TokenERC1155.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { NFTCollection } from "./nft-collection";
|
|
||||||
import { EditionDrop } from "./edition-drop";
|
|
||||||
import { Edition } from "./edition";
|
import { Edition } from "./edition";
|
||||||
import { Token } from "./token";
|
import { EditionDrop } from "./edition-drop";
|
||||||
import { Vote } from "./vote";
|
|
||||||
import { Split } from "./split";
|
|
||||||
import { Marketplace } from "./marketplace";
|
import { Marketplace } from "./marketplace";
|
||||||
import { Pack } from "./pack";
|
|
||||||
import { NFTDrop } from "./nft-drop";
|
|
||||||
import { TokenDrop } from "./token-drop";
|
|
||||||
import { SmartContract } from "./smart-contract";
|
|
||||||
import { SignatureDrop } from "./signature-drop";
|
|
||||||
import { Multiwrap } from "./multiwrap";
|
import { Multiwrap } from "./multiwrap";
|
||||||
|
import { NFTCollection } from "./nft-collection";
|
||||||
|
import { NFTDrop } from "./nft-drop";
|
||||||
|
import { Pack } from "./pack";
|
||||||
|
import { SignatureDrop } from "./signature-drop";
|
||||||
|
import { SmartContract } from "./smart-contract";
|
||||||
|
import { Split } from "./split";
|
||||||
|
import { Token } from "./token";
|
||||||
|
import { TokenDrop } from "./token-drop";
|
||||||
|
import { Vote } from "./vote";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { DEFAULT_QUERY_ALL_COUNT } from "../types/QueryParams";
|
|||||||
import { AuctionListing, DirectListing } from "../types/marketplace";
|
import { AuctionListing, DirectListing } from "../types/marketplace";
|
||||||
import { MarketplaceFilter } from "../types/marketplace/MarketPlaceFilter";
|
import { MarketplaceFilter } from "../types/marketplace/MarketPlaceFilter";
|
||||||
import { Marketplace as MarketplaceContract } from "@thirdweb-dev/contracts-js";
|
import { Marketplace as MarketplaceContract } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/Marketplace.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/Marketplace.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
@@ -404,7 +404,7 @@ export class Marketplace implements UpdateableNetwork {
|
|||||||
* @param contractAddress - the NFT contract address
|
* @param contractAddress - the NFT contract address
|
||||||
*/
|
*/
|
||||||
public async allowListingFromSpecificAssetOnly(contractAddress: string) {
|
public async allowListingFromSpecificAssetOnly(contractAddress: string) {
|
||||||
const encoded = [];
|
const encoded: string[] = [];
|
||||||
const members = await this.roles.get("asset");
|
const members = await this.roles.get("asset");
|
||||||
if (members.includes(constants.AddressZero)) {
|
if (members.includes(constants.AddressZero)) {
|
||||||
encoded.push(
|
encoded.push(
|
||||||
@@ -425,7 +425,7 @@ export class Marketplace implements UpdateableNetwork {
|
|||||||
* Allow listings from any NFT contract
|
* Allow listings from any NFT contract
|
||||||
*/
|
*/
|
||||||
public async allowListingFromAnyAsset() {
|
public async allowListingFromAnyAsset() {
|
||||||
const encoded = [];
|
const encoded: string[] = [];
|
||||||
const members = await this.roles.get("asset");
|
const members = await this.roles.get("asset");
|
||||||
for (const addr in members) {
|
for (const addr in members) {
|
||||||
encoded.push(
|
encoded.push(
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
WrappedTokens,
|
WrappedTokens,
|
||||||
} from "../types/multiwrap";
|
} from "../types/multiwrap";
|
||||||
import { Multiwrap as MultiwrapContract } from "@thirdweb-dev/contracts-js";
|
import { Multiwrap as MultiwrapContract } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/Multiwrap.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/Multiwrap.json";
|
||||||
import {
|
import {
|
||||||
ITokenBundle,
|
ITokenBundle,
|
||||||
TokensWrappedEvent,
|
TokensWrappedEvent,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { getRoleHash } from "../common";
|
import { getRoleHash } from "../common";
|
||||||
import { Erc721WithQuantitySignatureMintable } from "../core";
|
|
||||||
import { ContractEncoder } from "../core/classes/contract-encoder";
|
import { ContractEncoder } from "../core/classes/contract-encoder";
|
||||||
import { ContractEvents } from "../core/classes/contract-events";
|
import { ContractEvents } from "../core/classes/contract-events";
|
||||||
import { ContractInterceptor } from "../core/classes/contract-interceptor";
|
import { ContractInterceptor } from "../core/classes/contract-interceptor";
|
||||||
@@ -15,6 +14,7 @@ import { Erc721Burnable } from "../core/classes/erc-721-burnable";
|
|||||||
import { Erc721Enumerable } from "../core/classes/erc-721-enumerable";
|
import { Erc721Enumerable } from "../core/classes/erc-721-enumerable";
|
||||||
import { Erc721Mintable } from "../core/classes/erc-721-mintable";
|
import { Erc721Mintable } from "../core/classes/erc-721-mintable";
|
||||||
import { Erc721Supply } from "../core/classes/erc-721-supply";
|
import { Erc721Supply } from "../core/classes/erc-721-supply";
|
||||||
|
import { Erc721WithQuantitySignatureMintable } from "../core/classes/erc-721-with-quantity-signature-mintable";
|
||||||
import { GasCostEstimator } from "../core/classes/gas-cost-estimator";
|
import { GasCostEstimator } from "../core/classes/gas-cost-estimator";
|
||||||
import type {
|
import type {
|
||||||
NetworkOrSignerOrProvider,
|
NetworkOrSignerOrProvider,
|
||||||
@@ -26,7 +26,7 @@ import { TokenErc721ContractSchema } from "../schema/contracts/token-erc721";
|
|||||||
import { SDKOptions } from "../schema/sdk-options";
|
import { SDKOptions } from "../schema/sdk-options";
|
||||||
import { QueryAllParams } from "../types";
|
import { QueryAllParams } from "../types";
|
||||||
import { TokenERC721 } from "@thirdweb-dev/contracts-js";
|
import { TokenERC721 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/TokenERC721.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/TokenERC721.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { ClaimVerification } from "../types";
|
|||||||
import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../types/QueryParams";
|
import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../types/QueryParams";
|
||||||
import { UploadProgressEvent } from "../types/events";
|
import { UploadProgressEvent } from "../types/events";
|
||||||
import { DropERC721 } from "@thirdweb-dev/contracts-js";
|
import { DropERC721 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/DropERC721.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/DropERC721.json";
|
||||||
import {
|
import {
|
||||||
TokensClaimedEvent,
|
TokensClaimedEvent,
|
||||||
TokensLazyMintedEvent,
|
TokensLazyMintedEvent,
|
||||||
@@ -442,7 +442,7 @@ export class NFTDrop extends Erc721<DropERC721> {
|
|||||||
);
|
);
|
||||||
const startingIndex = event[0].args.startTokenId;
|
const startingIndex = event[0].args.startTokenId;
|
||||||
const endingIndex = event[0].args.endTokenId;
|
const endingIndex = event[0].args.endTokenId;
|
||||||
const results = [];
|
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
@@ -523,7 +523,7 @@ export class NFTDrop extends Erc721<DropERC721> {
|
|||||||
);
|
);
|
||||||
const startingIndex: BigNumber = event[0].args.startTokenId;
|
const startingIndex: BigNumber = event[0].args.startTokenId;
|
||||||
const endingIndex = startingIndex.add(quantity);
|
const endingIndex = startingIndex.add(quantity);
|
||||||
const results = [];
|
const results: TransactionResultWithId<NFTMetadataOwner>[] = [];
|
||||||
for (let id = startingIndex; id.lt(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lt(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import {
|
|||||||
} from "../schema/tokens/pack";
|
} from "../schema/tokens/pack";
|
||||||
import { QueryAllParams } from "../types";
|
import { QueryAllParams } from "../types";
|
||||||
import { Pack as PackContract } from "@thirdweb-dev/contracts-js";
|
import { Pack as PackContract } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/Pack.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/Pack.json";
|
||||||
import {
|
import {
|
||||||
ITokenBundle,
|
ITokenBundle,
|
||||||
PackCreatedEvent,
|
PackCreatedEvent,
|
||||||
@@ -207,9 +207,9 @@ export class Pack extends Erc1155<PackContract> {
|
|||||||
const { contents, perUnitAmounts } =
|
const { contents, perUnitAmounts } =
|
||||||
await this.contractWrapper.readContract.getPackContents(packId);
|
await this.contractWrapper.readContract.getPackContents(packId);
|
||||||
|
|
||||||
const erc20Rewards = [];
|
const erc20Rewards: PackRewardsOutput["erc20Rewards"] = [];
|
||||||
const erc721Rewards = [];
|
const erc721Rewards: PackRewardsOutput["erc721Rewards"] = [];
|
||||||
const erc1155Rewards = [];
|
const erc1155Rewards: PackRewardsOutput["erc1155Rewards"] = [];
|
||||||
|
|
||||||
for (let i = 0; i < contents.length; i++) {
|
for (let i = 0; i < contents.length; i++) {
|
||||||
const reward = contents[i];
|
const reward = contents[i];
|
||||||
@@ -435,9 +435,9 @@ export class Pack extends Erc1155<PackContract> {
|
|||||||
}
|
}
|
||||||
const rewards = event[0].args.rewardUnitsDistributed;
|
const rewards = event[0].args.rewardUnitsDistributed;
|
||||||
|
|
||||||
const erc20Rewards = [];
|
const erc20Rewards: PackRewards["erc20Rewards"] = [];
|
||||||
const erc721Rewards = [];
|
const erc721Rewards: PackRewards["erc721Rewards"] = [];
|
||||||
const erc1155Rewards = [];
|
const erc1155Rewards: PackRewards["erc1155Rewards"] = [];
|
||||||
|
|
||||||
for (const reward of rewards) {
|
for (const reward of rewards) {
|
||||||
switch (reward.tokenType) {
|
switch (reward.tokenType) {
|
||||||
@@ -485,7 +485,7 @@ export class Pack extends Erc1155<PackContract> {
|
|||||||
|
|
||||||
private async toPackContentArgs(metadataWithRewards: PackMetadataOutput) {
|
private async toPackContentArgs(metadataWithRewards: PackMetadataOutput) {
|
||||||
const contents: ITokenBundle.TokenStruct[] = [];
|
const contents: ITokenBundle.TokenStruct[] = [];
|
||||||
const numOfRewardUnits = [];
|
const numOfRewardUnits: string[] = [];
|
||||||
const { erc20Rewards, erc721Rewards, erc1155Rewards } = metadataWithRewards;
|
const { erc20Rewards, erc721Rewards, erc1155Rewards } = metadataWithRewards;
|
||||||
|
|
||||||
const provider = this.contractWrapper.getProvider();
|
const provider = this.contractWrapper.getProvider();
|
||||||
@@ -544,7 +544,7 @@ export class Pack extends Erc1155<PackContract> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfRewardUnits.push(1);
|
numOfRewardUnits.push("1");
|
||||||
contents.push({
|
contents.push({
|
||||||
assetContract: erc721.contractAddress,
|
assetContract: erc721.contractAddress,
|
||||||
tokenType: 1,
|
tokenType: 1,
|
||||||
|
|||||||
@@ -10,18 +10,16 @@ import { ContractRoles } from "../core/classes/contract-roles";
|
|||||||
import { ContractRoyalty } from "../core/classes/contract-royalty";
|
import { ContractRoyalty } from "../core/classes/contract-royalty";
|
||||||
import { ContractPrimarySale } from "../core/classes/contract-sales";
|
import { ContractPrimarySale } from "../core/classes/contract-sales";
|
||||||
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
import { ContractWrapper } from "../core/classes/contract-wrapper";
|
||||||
|
import { DelayedReveal } from "../core/classes/delayed-reveal";
|
||||||
|
import { DropClaimConditions } from "../core/classes/drop-claim-conditions";
|
||||||
import { Erc721 } from "../core/classes/erc-721";
|
import { Erc721 } from "../core/classes/erc-721";
|
||||||
import { Erc721Burnable } from "../core/classes/erc-721-burnable";
|
import { Erc721Burnable } from "../core/classes/erc-721-burnable";
|
||||||
|
import { Erc721Claimable } from "../core/classes/erc-721-claimable";
|
||||||
|
import { Erc721Droppable } from "../core/classes/erc-721-droppable";
|
||||||
import { Erc721Enumerable } from "../core/classes/erc-721-enumerable";
|
import { Erc721Enumerable } from "../core/classes/erc-721-enumerable";
|
||||||
import { Erc721Supply } from "../core/classes/erc-721-supply";
|
import { Erc721Supply } from "../core/classes/erc-721-supply";
|
||||||
import { Erc721WithQuantitySignatureMintable } from "../core/classes/erc-721-with-quantity-signature-mintable";
|
import { Erc721WithQuantitySignatureMintable } from "../core/classes/erc-721-with-quantity-signature-mintable";
|
||||||
import { GasCostEstimator } from "../core/classes/gas-cost-estimator";
|
import { GasCostEstimator } from "../core/classes/gas-cost-estimator";
|
||||||
import {
|
|
||||||
DelayedReveal,
|
|
||||||
DropClaimConditions,
|
|
||||||
Erc721Claimable,
|
|
||||||
Erc721Droppable,
|
|
||||||
} from "../core/index";
|
|
||||||
import {
|
import {
|
||||||
NetworkOrSignerOrProvider,
|
NetworkOrSignerOrProvider,
|
||||||
TransactionResult,
|
TransactionResult,
|
||||||
@@ -37,7 +35,7 @@ import {
|
|||||||
import { UploadProgressEvent } from "../types";
|
import { UploadProgressEvent } from "../types";
|
||||||
import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../types/QueryParams";
|
import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../types/QueryParams";
|
||||||
import { SignatureDrop as SignatureDropContract } from "@thirdweb-dev/contracts-js";
|
import { SignatureDrop as SignatureDropContract } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/SignatureDrop.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/SignatureDrop.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import { SDKOptions } from "../schema/sdk-options";
|
|||||||
import { SplitRecipient } from "../types/SplitRecipient";
|
import { SplitRecipient } from "../types/SplitRecipient";
|
||||||
import { CurrencyValue } from "../types/currency";
|
import { CurrencyValue } from "../types/currency";
|
||||||
import { IERC20, Split as SplitContract } from "@thirdweb-dev/contracts-js";
|
import { IERC20, Split as SplitContract } from "@thirdweb-dev/contracts-js";
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/Split.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/Split.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, Contract } from "ethers";
|
import { BigNumber, Contract } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { DropErc20ContractSchema } from "../schema/contracts/drop-erc20";
|
|||||||
import { SDKOptions } from "../schema/sdk-options";
|
import { SDKOptions } from "../schema/sdk-options";
|
||||||
import { Amount, CurrencyValue } from "../types";
|
import { Amount, CurrencyValue } from "../types";
|
||||||
import { DropERC20 } from "@thirdweb-dev/contracts-js";
|
import { DropERC20 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/DropERC20.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/DropERC20.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { constants } from "ethers";
|
import { constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { SDKOptions } from "../schema/sdk-options";
|
|||||||
import { TokenMintInput } from "../schema/tokens/token";
|
import { TokenMintInput } from "../schema/tokens/token";
|
||||||
import { Amount, CurrencyValue } from "../types";
|
import { Amount, CurrencyValue } from "../types";
|
||||||
import { TokenERC20 } from "@thirdweb-dev/contracts-js";
|
import { TokenERC20 } from "@thirdweb-dev/contracts-js";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/TokenERC20.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/TokenERC20.json";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { constants } from "ethers";
|
import { constants } from "ethers";
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import {
|
|||||||
VoteSettings,
|
VoteSettings,
|
||||||
} from "../types/vote";
|
} from "../types/vote";
|
||||||
import { IERC20, VoteERC20 } from "@thirdweb-dev/contracts-js";
|
import { IERC20, VoteERC20 } from "@thirdweb-dev/contracts-js";
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
import ABI from "@thirdweb-dev/contracts-js/abis/VoteERC20.json";
|
import ABI from "@thirdweb-dev/contracts-js/dist/abis/VoteERC20.json";
|
||||||
import { ProposalCreatedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/VoteERC20";
|
import { ProposalCreatedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/VoteERC20";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { BigNumber, BigNumberish, Contract, ethers } from "ethers";
|
import { BigNumber, BigNumberish, Contract, ethers } from "ethers";
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import {
|
|||||||
ContractPublisher as OnChainContractPublisher,
|
ContractPublisher as OnChainContractPublisher,
|
||||||
IContractPublisher,
|
IContractPublisher,
|
||||||
} from "@thirdweb-dev/contracts-js";
|
} from "@thirdweb-dev/contracts-js";
|
||||||
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/abis/ContractPublisher.json";
|
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/dist/abis/ContractPublisher.json";
|
||||||
import { ContractPublishedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/ContractPublisher";
|
import { ContractPublishedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/ContractPublisher";
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import { constants, utils } from "ethers";
|
import { constants, utils } from "ethers";
|
||||||
@@ -245,15 +245,15 @@ export class ContractPublisher extends RPCConnectionHandler {
|
|||||||
publisherAddress,
|
publisherAddress,
|
||||||
);
|
);
|
||||||
// since we can fetch from multiple publisher contracts, just keep the latest one in the list
|
// since we can fetch from multiple publisher contracts, just keep the latest one in the list
|
||||||
const map = data.reduce<
|
const map = data.reduce((acc, curr) => {
|
||||||
Record<string, IContractPublisher.CustomContractInstanceStruct>
|
|
||||||
>((acc, curr) => {
|
|
||||||
// replaces the previous contract with the latest one
|
// replaces the previous contract with the latest one
|
||||||
acc[curr.contractId] = curr;
|
acc[curr.contractId] = curr;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {} as Record<string, IContractPublisher.CustomContractInstanceStruct>);
|
||||||
return Object.entries(map).map(([_, struct]) =>
|
return Object.entries(map).map(([_, struct]) =>
|
||||||
this.toPublishedContract(struct),
|
this.toPublishedContract(
|
||||||
|
struct as IContractPublisher.CustomContractInstanceStruct,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { convertToTWError } from "../../common";
|
import { convertToTWError } from "../../common";
|
||||||
import {
|
import {
|
||||||
BiconomyForwarderAbi,
|
BiconomyForwarderAbi,
|
||||||
|
ChainAwareForwardRequest,
|
||||||
ForwardRequest,
|
ForwardRequest,
|
||||||
getAndIncrementNonce,
|
getAndIncrementNonce,
|
||||||
} from "../../common/forwarder";
|
} from "../../common/forwarder";
|
||||||
@@ -8,7 +9,7 @@ import { getPolygonGasPriorityFee } from "../../common/gas-price";
|
|||||||
import { signEIP2612Permit } from "../../common/permit";
|
import { signEIP2612Permit } from "../../common/permit";
|
||||||
import { signTypedDataInternal } from "../../common/sign";
|
import { signTypedDataInternal } from "../../common/sign";
|
||||||
import { isBrowser } from "../../common/utils";
|
import { isBrowser } from "../../common/utils";
|
||||||
import { ChainId } from "../../constants";
|
import { CONTRACT_ADDRESSES, ChainId } from "../../constants";
|
||||||
import { getContractAddressByChainId } from "../../constants/addresses";
|
import { getContractAddressByChainId } from "../../constants/addresses";
|
||||||
import { EventType } from "../../constants/events";
|
import { EventType } from "../../constants/events";
|
||||||
import { SDKOptions } from "../../schema/sdk-options";
|
import { SDKOptions } from "../../schema/sdk-options";
|
||||||
@@ -264,17 +265,6 @@ export class ContractWrapper<
|
|||||||
args: any[],
|
args: any[],
|
||||||
callOverrides?: CallOverrides,
|
callOverrides?: CallOverrides,
|
||||||
): Promise<providers.TransactionReceipt> {
|
): Promise<providers.TransactionReceipt> {
|
||||||
// one time verification that this is a valid contract (to avoid sending funds to wrong addresses)
|
|
||||||
if (!this.isValidContract) {
|
|
||||||
const code = await this.getProvider().getCode(this.readContract.address);
|
|
||||||
this.isValidContract = code !== "0x";
|
|
||||||
if (!this.isValidContract) {
|
|
||||||
throw new Error(
|
|
||||||
"The address you're trying to send a transaction to is not a smart contract. Make sure you are on the correct network and the contract address is correct",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!callOverrides) {
|
if (!callOverrides) {
|
||||||
callOverrides = await this.getCallOverrides();
|
callOverrides = await this.getCallOverrides();
|
||||||
}
|
}
|
||||||
@@ -297,6 +287,18 @@ export class ContractWrapper<
|
|||||||
this.emitTransactionEvent("completed", txHash);
|
this.emitTransactionEvent("completed", txHash);
|
||||||
return receipt;
|
return receipt;
|
||||||
} else {
|
} else {
|
||||||
|
// one time verification that this is a valid contract (to avoid sending funds to wrong addresses)
|
||||||
|
if (!this.isValidContract) {
|
||||||
|
const code = await this.getProvider().getCode(
|
||||||
|
this.readContract.address,
|
||||||
|
);
|
||||||
|
this.isValidContract = code !== "0x";
|
||||||
|
if (!this.isValidContract) {
|
||||||
|
throw new Error(
|
||||||
|
"The address you're trying to send a transaction to is not a smart contract. Make sure you are on the correct network and the contract address is correct",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
const tx = await this.sendTransactionByFunction(
|
const tx = await this.sendTransactionByFunction(
|
||||||
fn as keyof TContract["functions"],
|
fn as keyof TContract["functions"],
|
||||||
args,
|
args,
|
||||||
@@ -375,9 +377,8 @@ export class ContractWrapper<
|
|||||||
let gas = gasEstimate.mul(2);
|
let gas = gasEstimate.mul(2);
|
||||||
|
|
||||||
// in some cases WalletConnect doesn't properly gives an estimate for how much gas it would actually use.
|
// in some cases WalletConnect doesn't properly gives an estimate for how much gas it would actually use.
|
||||||
// it'd estimate ~21740 on polygon.
|
|
||||||
// as a fix, we're setting it to a high arbitrary number (500k) as the gas limit that should cover for most function calls.
|
// as a fix, we're setting it to a high arbitrary number (500k) as the gas limit that should cover for most function calls.
|
||||||
if (gasEstimate.lt(25000)) {
|
if (gasEstimate.lt(50000)) {
|
||||||
gas = BigNumber.from(500000);
|
gas = BigNumber.from(500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,37 +562,60 @@ export class ContractWrapper<
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
invariant(
|
invariant(
|
||||||
this.options.gasless && "openzeppelin" in this.options.gasless,
|
this.options.gasless && "openzeppelin" in this.options.gasless,
|
||||||
"calling biconomySendFunction without biconomy",
|
"calling openzeppelin gasless transaction without openzeppelin config in the SDK options",
|
||||||
);
|
);
|
||||||
const signer = this.getSigner();
|
const signer = this.getSigner();
|
||||||
const provider = this.getProvider();
|
const provider = this.getProvider();
|
||||||
invariant(signer, "provider is not set");
|
invariant(signer, "provider is not set");
|
||||||
invariant(provider, "provider is not set");
|
invariant(provider, "provider is not set");
|
||||||
const forwarderAddress =
|
const forwarderAddress =
|
||||||
this.options.gasless.openzeppelin.relayerForwarderAddress;
|
this.options.gasless.openzeppelin.relayerForwarderAddress ||
|
||||||
|
CONTRACT_ADDRESSES[transaction.chainId as keyof typeof CONTRACT_ADDRESSES]
|
||||||
|
.openzeppelinForwarder;
|
||||||
const forwarder = Forwarder__factory.connect(forwarderAddress, provider);
|
const forwarder = Forwarder__factory.connect(forwarderAddress, provider);
|
||||||
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
|
const nonce = await getAndIncrementNonce(forwarder, "getNonce", [
|
||||||
transaction.from,
|
transaction.from,
|
||||||
]);
|
]);
|
||||||
const domain = {
|
let domain;
|
||||||
name: "GSNv2 Forwarder",
|
let types;
|
||||||
version: "0.0.1",
|
let message: ForwardRequestMessage | PermitRequestMessage;
|
||||||
chainId: transaction.chainId,
|
if (this.options.gasless.experimentalChainlessSupport) {
|
||||||
verifyingContract: forwarderAddress,
|
domain = {
|
||||||
};
|
name: "GSNv2 Forwarder",
|
||||||
|
version: "0.0.1",
|
||||||
const types = {
|
verifyingContract: forwarderAddress,
|
||||||
ForwardRequest,
|
};
|
||||||
};
|
types = {
|
||||||
|
ForwardRequest: ChainAwareForwardRequest,
|
||||||
let message: ForwardRequestMessage | PermitRequestMessage = {
|
};
|
||||||
from: transaction.from,
|
message = {
|
||||||
to: transaction.to,
|
from: transaction.from,
|
||||||
value: BigNumber.from(0).toString(),
|
to: transaction.to,
|
||||||
gas: BigNumber.from(transaction.gasLimit).toString(),
|
value: BigNumber.from(0).toString(),
|
||||||
nonce: BigNumber.from(nonce).toString(),
|
gas: BigNumber.from(transaction.gasLimit).toString(),
|
||||||
data: transaction.data,
|
nonce: BigNumber.from(nonce).toString(),
|
||||||
};
|
data: transaction.data,
|
||||||
|
chainid: BigNumber.from(transaction.chainId).toString(),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
domain = {
|
||||||
|
name: "GSNv2 Forwarder",
|
||||||
|
version: "0.0.1",
|
||||||
|
chainId: transaction.chainId,
|
||||||
|
verifyingContract: forwarderAddress,
|
||||||
|
};
|
||||||
|
types = {
|
||||||
|
ForwardRequest,
|
||||||
|
};
|
||||||
|
message = {
|
||||||
|
from: transaction.from,
|
||||||
|
to: transaction.to,
|
||||||
|
value: BigNumber.from(0).toString(),
|
||||||
|
gas: BigNumber.from(transaction.gasLimit).toString(),
|
||||||
|
nonce: BigNumber.from(nonce).toString(),
|
||||||
|
data: transaction.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let signature: BytesLike;
|
let signature: BytesLike;
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
import { BigNumber, BigNumberish, ethers } from "ethers";
|
import { hasFunction } from "../../common";
|
||||||
import { ContractWrapper } from "./contract-wrapper";
|
import { fetchTokenMetadataForContract } from "../../common/nft";
|
||||||
import { DropERC721, IThirdwebContract, SignatureDrop } from "@thirdweb-dev/contracts-js";
|
import { FeatureName } from "../../constants/contract-features";
|
||||||
import {
|
import {
|
||||||
CommonNFTInput,
|
CommonNFTInput,
|
||||||
NFTMetadata,
|
NFTMetadata,
|
||||||
NFTMetadataInput,
|
NFTMetadataInput,
|
||||||
} from "../../schema/tokens/common";
|
} from "../../schema/tokens/common";
|
||||||
import { TransactionResult, TransactionResultWithId } from "../index";
|
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
|
||||||
import { fetchTokenMetadataForContract } from "../../common/nft";
|
|
||||||
import { BatchToReveal } from "../../types/delayed-reveal";
|
import { BatchToReveal } from "../../types/delayed-reveal";
|
||||||
import { UploadProgressEvent } from "../../types/events";
|
|
||||||
import {
|
import {
|
||||||
BaseDelayedRevealERC1155,
|
BaseDelayedRevealERC1155,
|
||||||
BaseDelayedRevealERC721,
|
BaseDelayedRevealERC721,
|
||||||
} from "../../types/eips";
|
} from "../../types/eips";
|
||||||
import { hasFunction } from "../../common";
|
import { UploadProgressEvent } from "../../types/events";
|
||||||
import DeprecatedAbi from "@thirdweb-dev/contracts-js/abis/IDelayedRevealDeprecated.json";
|
import { TransactionResult, TransactionResultWithId } from "../index";
|
||||||
import { FeatureName } from "../../constants/contract-features";
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import {
|
||||||
|
DropERC721,
|
||||||
|
IThirdwebContract,
|
||||||
|
SignatureDrop,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import DeprecatedAbi from "@thirdweb-dev/contracts-js/dist/abis/IDelayedRevealDeprecated.json";
|
||||||
import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/DropERC721";
|
import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/DropERC721";
|
||||||
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { BigNumber, BigNumberish, ethers } from "ethers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles delayed reveal logic
|
* Handles delayed reveal logic
|
||||||
@@ -75,9 +79,6 @@ export class DelayedReveal<
|
|||||||
* realNFTs,
|
* realNFTs,
|
||||||
* "my secret password",
|
* "my secret password",
|
||||||
* );
|
* );
|
||||||
* // Whenever you're ready, reveal your NFTs at any time!
|
|
||||||
* const batchId = 0; // the batch to reveal
|
|
||||||
* await contract.revealer.reveal(batchId, "my secret password");
|
|
||||||
* ```
|
* ```
|
||||||
* @public
|
* @public
|
||||||
* @param placeholder - the placeholder NFT to show before the reveal
|
* @param placeholder - the placeholder NFT to show before the reveal
|
||||||
@@ -156,7 +157,7 @@ export class DelayedReveal<
|
|||||||
);
|
);
|
||||||
const startingIndex = events[0].args.startTokenId;
|
const startingIndex = events[0].args.startTokenId;
|
||||||
const endingIndex = events[0].args.endTokenId;
|
const endingIndex = events[0].args.endTokenId;
|
||||||
const results = [];
|
const results: TransactionResultWithId[] = [];
|
||||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
import { IStorage } from "@thirdweb-dev/storage";
|
import { includesErrorMessage } from "../../common";
|
||||||
|
import {
|
||||||
|
getClaimerProofs,
|
||||||
|
prepareClaim,
|
||||||
|
processClaimConditionInputs,
|
||||||
|
transformResultToClaimCondition,
|
||||||
|
updateExistingClaimConditions,
|
||||||
|
} from "../../common/claim-conditions";
|
||||||
|
import { isNativeToken } from "../../common/currency";
|
||||||
|
import {
|
||||||
|
detectContractFeature,
|
||||||
|
hasFunction,
|
||||||
|
} from "../../common/feature-detection";
|
||||||
|
import { isNode } from "../../common/utils";
|
||||||
|
import { NATIVE_TOKEN_ADDRESS } from "../../constants/index";
|
||||||
|
import { ClaimEligibility } from "../../enums";
|
||||||
|
import { AmountSchema } from "../../schema";
|
||||||
|
import {
|
||||||
|
Amount,
|
||||||
|
ClaimCondition,
|
||||||
|
ClaimConditionInput,
|
||||||
|
ClaimVerification,
|
||||||
|
} from "../../types";
|
||||||
|
import { BaseClaimConditionERC721, BaseDropERC20 } from "../../types/eips";
|
||||||
|
import { TransactionResult } from "../types";
|
||||||
import { ContractMetadata } from "./contract-metadata";
|
import { ContractMetadata } from "./contract-metadata";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
import {
|
import {
|
||||||
ContractMetadata as ContractMetadataContract,
|
ContractMetadata as ContractMetadataContract,
|
||||||
DropERC20,
|
DropERC20,
|
||||||
@@ -9,36 +34,11 @@ import {
|
|||||||
IERC20Metadata,
|
IERC20Metadata,
|
||||||
SignatureDrop,
|
SignatureDrop,
|
||||||
} from "@thirdweb-dev/contracts-js";
|
} from "@thirdweb-dev/contracts-js";
|
||||||
import { BigNumber, BigNumberish, constants, ethers, utils } from "ethers";
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
import { isNativeToken } from "../../common/currency";
|
|
||||||
import { ContractWrapper } from "./contract-wrapper";
|
|
||||||
import {
|
|
||||||
Amount,
|
|
||||||
ClaimCondition,
|
|
||||||
ClaimConditionInput,
|
|
||||||
ClaimVerification,
|
|
||||||
} from "../../types";
|
|
||||||
import { ClaimEligibility } from "../../enums";
|
|
||||||
import { TransactionResult } from "../types";
|
|
||||||
import {
|
|
||||||
getClaimerProofs,
|
|
||||||
prepareClaim,
|
|
||||||
processClaimConditionInputs,
|
|
||||||
transformResultToClaimCondition,
|
|
||||||
updateExistingClaimConditions,
|
|
||||||
} from "../../common/claim-conditions";
|
|
||||||
import {
|
|
||||||
detectContractFeature,
|
|
||||||
hasFunction,
|
|
||||||
} from "../../common/feature-detection";
|
|
||||||
import { AmountSchema } from "../../schema";
|
|
||||||
import { includesErrorMessage } from "../../common";
|
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
|
||||||
import { isNode } from "../../common/utils";
|
|
||||||
import deepEqual from "fast-deep-equal";
|
|
||||||
import { BaseClaimConditionERC721, BaseDropERC20 } from "../../types/eips";
|
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../../constants/index";
|
|
||||||
import { IDropClaimCondition } from "@thirdweb-dev/contracts-js/dist/declarations/src/DropERC20";
|
import { IDropClaimCondition } from "@thirdweb-dev/contracts-js/dist/declarations/src/DropERC20";
|
||||||
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { BigNumber, BigNumberish, constants, ethers, utils } from "ethers";
|
||||||
|
import deepEqual from "fast-deep-equal";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages claim conditions for NFT Drop contracts
|
* Manages claim conditions for NFT Drop contracts
|
||||||
@@ -113,7 +113,7 @@ export class DropClaimConditions<
|
|||||||
};
|
};
|
||||||
const startId = claimCondition.currentStartId.toNumber();
|
const startId = claimCondition.currentStartId.toNumber();
|
||||||
const count = claimCondition.count.toNumber();
|
const count = claimCondition.count.toNumber();
|
||||||
const conditions = [];
|
const conditions: IDropClaimCondition.ClaimConditionStructOutput[] = [];
|
||||||
for (let i = startId; i < startId + count; i++) {
|
for (let i = startId; i < startId + count; i++) {
|
||||||
conditions.push(
|
conditions.push(
|
||||||
await this.contractWrapper.readContract.getClaimConditionById(i),
|
await this.contractWrapper.readContract.getClaimConditionById(i),
|
||||||
@@ -411,7 +411,7 @@ export class DropClaimConditions<
|
|||||||
merkleInfo[s.merkleRoot] = s.snapshotUri;
|
merkleInfo[s.merkleRoot] = s.snapshotUri;
|
||||||
});
|
});
|
||||||
const metadata = await this.metadata.get();
|
const metadata = await this.metadata.get();
|
||||||
const encoded = [];
|
const encoded: string[] = [];
|
||||||
|
|
||||||
// upload new merkle roots to snapshot URIs if updated
|
// upload new merkle roots to snapshot URIs if updated
|
||||||
if (!deepEqual(metadata.merkle, merkleInfo)) {
|
if (!deepEqual(metadata.merkle, merkleInfo)) {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export class DropErc1155ClaimConditions<
|
|||||||
};
|
};
|
||||||
const startId = claimCondition.currentStartId.toNumber();
|
const startId = claimCondition.currentStartId.toNumber();
|
||||||
const count = claimCondition.count.toNumber();
|
const count = claimCondition.count.toNumber();
|
||||||
const conditions = [];
|
const conditions: IDropClaimCondition.ClaimConditionStructOutput[] = [];
|
||||||
for (let i = startId; i < startId + count; i++) {
|
for (let i = startId; i < startId + count; i++) {
|
||||||
conditions.push(
|
conditions.push(
|
||||||
await this.contractWrapper.readContract.getClaimConditionById(
|
await this.contractWrapper.readContract.getClaimConditionById(
|
||||||
@@ -471,7 +471,7 @@ export class DropErc1155ClaimConditions<
|
|||||||
);
|
);
|
||||||
|
|
||||||
const metadata = await this.metadata.get();
|
const metadata = await this.metadata.get();
|
||||||
const encoded = [];
|
const encoded: string[] = [];
|
||||||
|
|
||||||
// keep the old merkle roots from other tokenIds
|
// keep the old merkle roots from other tokenIds
|
||||||
for (const key of Object.keys(metadata.merkle || {})) {
|
for (const key of Object.keys(metadata.merkle || {})) {
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ import { BigNumberish, ethers } from "ethers";
|
|||||||
import { TransactionResult } from "../types";
|
import { TransactionResult } from "../types";
|
||||||
import { TransactionTask } from "./TransactionTask";
|
import { TransactionTask } from "./TransactionTask";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure and claim ERC1155 NFTs
|
||||||
|
* @remarks Manage claim phases and claim ERC1155 NFTs that have been lazily minted.
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const contract = await sdk.getContract("{{contract_address}}");
|
||||||
|
* await contract.edition.drop.claim.to("0x...", tokenId, quantity);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
export class Erc1155Claimable implements DetectableFeature {
|
export class Erc1155Claimable implements DetectableFeature {
|
||||||
featureName = FEATURE_NFT_CLAIMABLE.name;
|
featureName = FEATURE_NFT_CLAIMABLE.name;
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ export class Erc1155Droppable implements DetectableFeature {
|
|||||||
);
|
);
|
||||||
const startingIndex = event[0].args.startTokenId;
|
const startingIndex = event[0].args.startTokenId;
|
||||||
const endingIndex = event[0].args.endTokenId;
|
const endingIndex = event[0].args.endTokenId;
|
||||||
const results = [];
|
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -107,6 +107,16 @@ export class Erc1155Mintable implements DetectableFeature {
|
|||||||
* @param to - the address to mint to
|
* @param to - the address to mint to
|
||||||
* @param tokenId - the token id of the NFT to increase supply of
|
* @param tokenId - the token id of the NFT to increase supply of
|
||||||
* @param additionalSupply - the additional amount to mint
|
* @param additionalSupply - the additional amount to mint
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* // Address of the wallet you want to mint the NFT to
|
||||||
|
* const toAddress = "{{wallet_address}}"
|
||||||
|
* const tokenId = 0;
|
||||||
|
* const additionalSupply = 1000;
|
||||||
|
*
|
||||||
|
* const tx = await contract.edition.mint.additionalSupplyTo(toAddress, tokenId, additionalSupply);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
public async additionalSupplyTo(
|
public async additionalSupplyTo(
|
||||||
to: string,
|
to: string,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { ContractWrapper } from "./contract-wrapper";
|
|
||||||
import { IMintableERC20, IMulticall } from "@thirdweb-dev/contracts-js";
|
|
||||||
import { Erc20 } from "./erc-20";
|
|
||||||
import { TokenMintInput } from "../../schema";
|
|
||||||
import { TransactionResult } from "../types";
|
|
||||||
import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../constants/erc20-features";
|
import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../constants/erc20-features";
|
||||||
|
import { TokenMintInput } from "../../schema";
|
||||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||||
|
import { TransactionResult } from "../types";
|
||||||
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
|
import { Erc20 } from "./erc-20";
|
||||||
|
import { IMintableERC20, IMulticall } from "@thirdweb-dev/contracts-js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mint Many ERC20 Tokens at once
|
* Mint Many ERC20 Tokens at once
|
||||||
@@ -52,7 +52,7 @@ export class Erc20BatchMintable implements DetectableFeature {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
public async to(args: TokenMintInput[]): Promise<TransactionResult> {
|
public async to(args: TokenMintInput[]): Promise<TransactionResult> {
|
||||||
const encoded = [];
|
const encoded: string[] = [];
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
encoded.push(
|
encoded.push(
|
||||||
this.contractWrapper.readContract.interface.encodeFunctionData(
|
this.contractWrapper.readContract.interface.encodeFunctionData(
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export class Erc721Claimable implements DetectableFeature {
|
|||||||
);
|
);
|
||||||
const startingIndex: BigNumber = event[0].args.startTokenId;
|
const startingIndex: BigNumber = event[0].args.startTokenId;
|
||||||
const endingIndex = startingIndex.add(quantity);
|
const endingIndex = startingIndex.add(quantity);
|
||||||
const results = [];
|
const results: TransactionResultWithId<NFTMetadataOwner>[] = [];
|
||||||
for (let id = startingIndex; id.lt(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lt(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export class Erc721Droppable implements DetectableFeature {
|
|||||||
);
|
);
|
||||||
const startingIndex = event[0].args.startTokenId;
|
const startingIndex = event[0].args.startTokenId;
|
||||||
const endingIndex = event[0].args.endTokenId;
|
const endingIndex = event[0].args.endTokenId;
|
||||||
const results = [];
|
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||||
results.push({
|
results.push({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -257,8 +257,11 @@ export class ContractFactory extends ContractWrapper<TWFactory> {
|
|||||||
const biconomyForwarder = chainEnum
|
const biconomyForwarder = chainEnum
|
||||||
? CONTRACT_ADDRESSES[chainEnum].biconomyForwarder
|
? CONTRACT_ADDRESSES[chainEnum].biconomyForwarder
|
||||||
: constants.AddressZero;
|
: constants.AddressZero;
|
||||||
|
const openzeppelinForwarder = chainEnum
|
||||||
|
? CONTRACT_ADDRESSES[chainEnum].openzeppelinForwarder
|
||||||
|
: constants.AddressZero;
|
||||||
return biconomyForwarder !== constants.AddressZero
|
return biconomyForwarder !== constants.AddressZero
|
||||||
? [OZ_DEFENDER_FORWARDER_ADDRESS, biconomyForwarder]
|
? [openzeppelinForwarder, biconomyForwarder]
|
||||||
: [OZ_DEFENDER_FORWARDER_ADDRESS];
|
: [openzeppelinForwarder];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,29 @@
|
|||||||
|
import { ListingNotFoundError, WrongListingTypeError } from "../../common";
|
||||||
|
import {
|
||||||
|
fetchCurrencyValue,
|
||||||
|
isNativeToken,
|
||||||
|
normalizePriceValue,
|
||||||
|
setErc20Allowance,
|
||||||
|
} from "../../common/currency";
|
||||||
|
import {
|
||||||
|
handleTokenApproval,
|
||||||
|
isTokenApprovedForTransfer,
|
||||||
|
mapOffer,
|
||||||
|
validateNewListingParam,
|
||||||
|
} from "../../common/marketplace";
|
||||||
|
import { fetchTokenMetadataForContract } from "../../common/nft";
|
||||||
|
import {
|
||||||
|
InterfaceId_IERC1155,
|
||||||
|
InterfaceId_IERC721,
|
||||||
|
} from "../../constants/contract";
|
||||||
|
import { ListingType } from "../../enums";
|
||||||
|
import { Price } from "../../types/currency";
|
||||||
|
import {
|
||||||
|
DirectListing,
|
||||||
|
NewDirectListing,
|
||||||
|
Offer,
|
||||||
|
} from "../../types/marketplace";
|
||||||
|
import { TransactionResult, TransactionResultWithId } from "../types";
|
||||||
import { ContractWrapper } from "./contract-wrapper";
|
import { ContractWrapper } from "./contract-wrapper";
|
||||||
import {
|
import {
|
||||||
IERC1155,
|
IERC1155,
|
||||||
@@ -6,6 +32,11 @@ import {
|
|||||||
IMarketplace,
|
IMarketplace,
|
||||||
Marketplace,
|
Marketplace,
|
||||||
} from "@thirdweb-dev/contracts-js";
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import ERC165Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC165.json";
|
||||||
|
import ERC721Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC721.json";
|
||||||
|
import ERC1155Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC1155.json";
|
||||||
|
import { ListingAddedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/Marketplace";
|
||||||
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
import {
|
import {
|
||||||
BigNumber,
|
BigNumber,
|
||||||
BigNumberish,
|
BigNumberish,
|
||||||
@@ -14,38 +45,7 @@ import {
|
|||||||
constants,
|
constants,
|
||||||
utils,
|
utils,
|
||||||
} from "ethers";
|
} from "ethers";
|
||||||
import {
|
|
||||||
DirectListing,
|
|
||||||
NewDirectListing,
|
|
||||||
Offer,
|
|
||||||
} from "../../types/marketplace";
|
|
||||||
import { ListingNotFoundError, WrongListingTypeError } from "../../common";
|
|
||||||
import { ListingType } from "../../enums";
|
|
||||||
import { TransactionResult, TransactionResultWithId } from "../types";
|
|
||||||
import {
|
|
||||||
fetchCurrencyValue,
|
|
||||||
isNativeToken,
|
|
||||||
normalizePriceValue,
|
|
||||||
setErc20Allowance,
|
|
||||||
} from "../../common/currency";
|
|
||||||
import { Price } from "../../types/currency";
|
|
||||||
import { fetchTokenMetadataForContract } from "../../common/nft";
|
|
||||||
import {
|
|
||||||
InterfaceId_IERC1155,
|
|
||||||
InterfaceId_IERC721,
|
|
||||||
} from "../../constants/contract";
|
|
||||||
import {
|
|
||||||
handleTokenApproval,
|
|
||||||
isTokenApprovedForTransfer,
|
|
||||||
mapOffer,
|
|
||||||
validateNewListingParam,
|
|
||||||
} from "../../common/marketplace";
|
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
import ERC1155Abi from "@thirdweb-dev/contracts-js/abis/IERC1155.json";
|
|
||||||
import ERC721Abi from "@thirdweb-dev/contracts-js/abis/IERC721.json";
|
|
||||||
import ERC165Abi from "@thirdweb-dev/contracts-js/abis/IERC165.json";
|
|
||||||
import { ListingAddedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/Marketplace";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles direct listings
|
* Handles direct listings
|
||||||
|
|||||||
@@ -183,7 +183,6 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
* Get an instance of a SignatureDrop contract
|
* Get an instance of a SignatureDrop contract
|
||||||
* @param contractAddress - the address of the deployed contract
|
* @param contractAddress - the address of the deployed contract
|
||||||
* @returns the contract
|
* @returns the contract
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
public getSignatureDrop(contractAddress: string): SignatureDrop {
|
public getSignatureDrop(contractAddress: string): SignatureDrop {
|
||||||
return this.getBuiltInContract(
|
return this.getBuiltInContract(
|
||||||
@@ -361,6 +360,10 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
/**
|
/**
|
||||||
* Return all the contracts deployed by the specified address
|
* Return all the contracts deployed by the specified address
|
||||||
* @param walletAddress - the deployed address
|
* @param walletAddress - the deployed address
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const contracts = sdk.getContractList("{{wallet_address}}");
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
public async getContractList(walletAddress: string) {
|
public async getContractList(walletAddress: string) {
|
||||||
const addresses = await (
|
const addresses = await (
|
||||||
@@ -431,6 +434,10 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
* @param address - the address of the deployed contract
|
* @param address - the address of the deployed contract
|
||||||
* @returns the contract
|
* @returns the contract
|
||||||
* @beta
|
* @beta
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const contract = sdk.getContract("{{contract_address}}");
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
public async getContract(address: string) {
|
public async getContract(address: string) {
|
||||||
if (this.contractCache.has(address)) {
|
if (this.contractCache.has(address)) {
|
||||||
@@ -460,6 +467,17 @@ export class ThirdwebSDK extends RPCConnectionHandler {
|
|||||||
* @param abi - the JSON abi
|
* @param abi - the JSON abi
|
||||||
* @returns the contract
|
* @returns the contract
|
||||||
* @beta
|
* @beta
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* // Import your ABI from a JSON file
|
||||||
|
* import myABI from "./path/to/myABI.json";
|
||||||
|
*
|
||||||
|
* const contract = sdk.getContractFromAbi(
|
||||||
|
* "{{contract_address}}",
|
||||||
|
* // Pass in the "abi" field from the JSON file
|
||||||
|
* myABI.abi
|
||||||
|
* );
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
public getContractFromAbi(address: string, abi: ContractInterface) {
|
public getContractFromAbi(address: string, abi: ContractInterface) {
|
||||||
if (this.contractCache.has(address)) {
|
if (this.contractCache.has(address)) {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export type ForwardRequestMessage = {
|
|||||||
gas: string;
|
gas: string;
|
||||||
nonce: string;
|
nonce: string;
|
||||||
data: BytesLike;
|
data: BytesLike;
|
||||||
|
chainid?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { RPCConnectionHandler } from "../classes/rpc-connection-handler";
|
|
||||||
import { NetworkOrSignerOrProvider, TransactionResult } from "../types";
|
|
||||||
import { SDKOptions } from "../../schema";
|
|
||||||
import invariant from "tiny-invariant";
|
|
||||||
import { Amount, CurrencyValue } from "../../types";
|
|
||||||
import {
|
import {
|
||||||
fetchCurrencyValue,
|
fetchCurrencyValue,
|
||||||
isNativeToken,
|
isNativeToken,
|
||||||
normalizePriceValue,
|
normalizePriceValue,
|
||||||
} from "../../common/currency";
|
} from "../../common/currency";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../../constants";
|
import { NATIVE_TOKEN_ADDRESS } from "../../constants";
|
||||||
import ERC20Abi from "@thirdweb-dev/contracts-js/abis/IERC20.json";
|
import { SDKOptions } from "../../schema";
|
||||||
|
import { Amount, CurrencyValue } from "../../types";
|
||||||
import { ContractWrapper } from "../classes/contract-wrapper";
|
import { ContractWrapper } from "../classes/contract-wrapper";
|
||||||
|
import { RPCConnectionHandler } from "../classes/rpc-connection-handler";
|
||||||
|
import { NetworkOrSignerOrProvider, TransactionResult } from "../types";
|
||||||
import { IERC20 } from "@thirdweb-dev/contracts-js";
|
import { IERC20 } from "@thirdweb-dev/contracts-js";
|
||||||
|
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
|
||||||
import { ethers, BigNumber, providers } from "ethers";
|
import { ethers, BigNumber, providers } from "ethers";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect and Interact with a user wallet
|
* Connect and Interact with a user wallet
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ export const ChainIdToAddressSchema = z.record(z.string(), z.string());
|
|||||||
*/
|
*/
|
||||||
export const FactoryDeploymentSchema = z.object({
|
export const FactoryDeploymentSchema = z.object({
|
||||||
implementationAddresses: ChainIdToAddressSchema,
|
implementationAddresses: ChainIdToAddressSchema,
|
||||||
implementationInitializerFunction: z.string(),
|
implementationInitializerFunction: z.string().default("initialize"),
|
||||||
factoryAddresses: ChainIdToAddressSchema,
|
factoryAddresses: ChainIdToAddressSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ export const SDKOptionsSchema = z
|
|||||||
relayerUrl: z.string().url(),
|
relayerUrl: z.string().url(),
|
||||||
relayerForwarderAddress: z
|
relayerForwarderAddress: z
|
||||||
.string()
|
.string()
|
||||||
.default(OZ_DEFENDER_FORWARDER_ADDRESS),
|
.optional(),
|
||||||
}),
|
}),
|
||||||
|
experimentalChainlessSupport: z.boolean().default(false),
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
biconomy: z.object({
|
biconomy: z.object({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { signers } from "./before-setup";
|
|
||||||
import { expect } from "chai";
|
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { ThirdwebSDK } from "../src";
|
import { ThirdwebSDK } from "../src";
|
||||||
|
import { signers } from "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
describe("Wallet Authentication", async () => {
|
describe("Wallet Authentication", async () => {
|
||||||
let adminWallet: SignerWithAddress,
|
let adminWallet: SignerWithAddress,
|
||||||
|
|||||||
@@ -1,250 +0,0 @@
|
|||||||
import {
|
|
||||||
CONTRACTS_MAP,
|
|
||||||
ContractType,
|
|
||||||
DEFAULT_IPFS_GATEWAY,
|
|
||||||
Edition,
|
|
||||||
EditionDrop,
|
|
||||||
getNativeTokenByChainId,
|
|
||||||
Marketplace,
|
|
||||||
Multiwrap,
|
|
||||||
NFTCollection,
|
|
||||||
NFTDrop,
|
|
||||||
Pack,
|
|
||||||
SignatureDrop,
|
|
||||||
Split,
|
|
||||||
ThirdwebSDK,
|
|
||||||
Token,
|
|
||||||
TokenDrop,
|
|
||||||
Vote,
|
|
||||||
} from "../src";
|
|
||||||
import { ChainId } from "../src/constants/chains";
|
|
||||||
import { MockStorage } from "./mock/MockStorage";
|
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import {
|
|
||||||
ContractPublisher,
|
|
||||||
ContractPublisher__factory,
|
|
||||||
DropERC1155__factory,
|
|
||||||
DropERC20__factory,
|
|
||||||
DropERC721__factory,
|
|
||||||
Marketplace__factory,
|
|
||||||
MockContractPublisher,
|
|
||||||
MockContractPublisher__factory,
|
|
||||||
Multiwrap__factory,
|
|
||||||
Pack__factory,
|
|
||||||
SignatureDrop__factory,
|
|
||||||
Split__factory,
|
|
||||||
TokenERC1155__factory,
|
|
||||||
TokenERC20__factory,
|
|
||||||
TokenERC721__factory,
|
|
||||||
TWFactory,
|
|
||||||
TWFactory__factory,
|
|
||||||
TWFee__factory,
|
|
||||||
TWRegistry,
|
|
||||||
TWRegistry__factory,
|
|
||||||
VoteERC20__factory,
|
|
||||||
} from "@thirdweb-dev/contracts-js";
|
|
||||||
import { IStorage } from "@thirdweb-dev/storage";
|
|
||||||
import { ethers } from "ethers";
|
|
||||||
//@ts-expext-error TS2551: Cannot find name 'ethers'.
|
|
||||||
import { ethers as hardhatEthers } from "hardhat";
|
|
||||||
|
|
||||||
const RPC_URL = "http://localhost:8545";
|
|
||||||
|
|
||||||
const jsonProvider = new ethers.providers.JsonRpcProvider(RPC_URL);
|
|
||||||
const defaultProvider = hardhatEthers.provider;
|
|
||||||
|
|
||||||
let registryAddress: string;
|
|
||||||
let sdk: ThirdwebSDK;
|
|
||||||
const ipfsGatewayUrl = DEFAULT_IPFS_GATEWAY;
|
|
||||||
let signer: SignerWithAddress;
|
|
||||||
let signers: SignerWithAddress[];
|
|
||||||
let storage: IStorage;
|
|
||||||
let implementations: { [key in ContractType]?: string };
|
|
||||||
|
|
||||||
const fastForwardTime = async (timeInSeconds: number): Promise<void> => {
|
|
||||||
const now = Math.floor(Date.now() / 1000);
|
|
||||||
await defaultProvider.send("evm_mine", [now + timeInSeconds]);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const expectError = (e: unknown, message: string) => {
|
|
||||||
if (e instanceof Error) {
|
|
||||||
if (!e.message.includes(message)) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
signers = await hardhatEthers.getSigners();
|
|
||||||
implementations = {};
|
|
||||||
|
|
||||||
[signer] = signers;
|
|
||||||
|
|
||||||
const trustedForwarderAddress = "0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81";
|
|
||||||
await jsonProvider.send("hardhat_reset", []);
|
|
||||||
|
|
||||||
const registry = (await new ethers.ContractFactory(
|
|
||||||
TWRegistry__factory.abi,
|
|
||||||
TWRegistry__factory.bytecode,
|
|
||||||
)
|
|
||||||
.connect(signer)
|
|
||||||
.deploy(trustedForwarderAddress)) as TWRegistry;
|
|
||||||
const registryContract = await registry.deployed();
|
|
||||||
|
|
||||||
const thirdwebFactoryDeployer = (await new ethers.ContractFactory(
|
|
||||||
TWFactory__factory.abi,
|
|
||||||
TWFactory__factory.bytecode,
|
|
||||||
)
|
|
||||||
.connect(signer)
|
|
||||||
.deploy(trustedForwarderAddress, registry.address)) as TWFactory;
|
|
||||||
|
|
||||||
const deployTxFactory = thirdwebFactoryDeployer.deployTransaction;
|
|
||||||
await deployTxFactory.wait();
|
|
||||||
const thirdwebRegistryAddress = await thirdwebFactoryDeployer.registry();
|
|
||||||
registryAddress = thirdwebFactoryDeployer.address;
|
|
||||||
|
|
||||||
await registryContract.grantRole(
|
|
||||||
await registryContract.OPERATOR_ROLE(),
|
|
||||||
thirdwebFactoryDeployer.address,
|
|
||||||
);
|
|
||||||
|
|
||||||
const thirdwebFeeDeployer = await new ethers.ContractFactory(
|
|
||||||
TWFee__factory.abi,
|
|
||||||
TWFee__factory.bytecode,
|
|
||||||
)
|
|
||||||
.connect(signer)
|
|
||||||
.deploy(trustedForwarderAddress, thirdwebFactoryDeployer.address);
|
|
||||||
await thirdwebFactoryDeployer.deployed();
|
|
||||||
|
|
||||||
// Mock publisher for tests
|
|
||||||
const mockPublisher = (await new ethers.ContractFactory(
|
|
||||||
MockContractPublisher__factory.abi,
|
|
||||||
MockContractPublisher__factory.bytecode,
|
|
||||||
)
|
|
||||||
.connect(signer)
|
|
||||||
.deploy()) as MockContractPublisher;
|
|
||||||
const contractPublisher = (await new ethers.ContractFactory(
|
|
||||||
ContractPublisher__factory.abi,
|
|
||||||
ContractPublisher__factory.bytecode,
|
|
||||||
)
|
|
||||||
.connect(signer)
|
|
||||||
.deploy(
|
|
||||||
trustedForwarderAddress,
|
|
||||||
mockPublisher.address,
|
|
||||||
)) as ContractPublisher; // TODO needs MockPublisher here
|
|
||||||
await contractPublisher.deployed();
|
|
||||||
|
|
||||||
async function deployContract(
|
|
||||||
contractFactory: ethers.ContractFactory,
|
|
||||||
contractType: ContractType,
|
|
||||||
): Promise<ethers.Contract> {
|
|
||||||
switch (contractType) {
|
|
||||||
case Marketplace.contractType:
|
|
||||||
case Multiwrap.contractType:
|
|
||||||
const nativeTokenWrapperAddress = getNativeTokenByChainId(
|
|
||||||
ChainId.Hardhat,
|
|
||||||
).wrapped.address;
|
|
||||||
return await contractFactory.deploy(nativeTokenWrapperAddress);
|
|
||||||
case Pack.contractType:
|
|
||||||
const addr = getNativeTokenByChainId(ChainId.Hardhat).wrapped.address;
|
|
||||||
return await contractFactory.deploy(addr, trustedForwarderAddress);
|
|
||||||
default:
|
|
||||||
return await contractFactory.deploy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const contractType in CONTRACTS_MAP) {
|
|
||||||
if (contractType === "custom") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let factory;
|
|
||||||
switch (contractType) {
|
|
||||||
case Token.contractType:
|
|
||||||
factory = TokenERC20__factory;
|
|
||||||
break;
|
|
||||||
case TokenDrop.contractType:
|
|
||||||
factory = DropERC20__factory;
|
|
||||||
break;
|
|
||||||
case NFTCollection.contractType:
|
|
||||||
factory = TokenERC721__factory;
|
|
||||||
break;
|
|
||||||
case NFTDrop.contractType:
|
|
||||||
factory = DropERC721__factory;
|
|
||||||
break;
|
|
||||||
case SignatureDrop.contractType:
|
|
||||||
factory = SignatureDrop__factory;
|
|
||||||
break;
|
|
||||||
case Edition.contractType:
|
|
||||||
factory = TokenERC1155__factory;
|
|
||||||
break;
|
|
||||||
case EditionDrop.contractType:
|
|
||||||
factory = DropERC1155__factory;
|
|
||||||
break;
|
|
||||||
case Split.contractType:
|
|
||||||
factory = Split__factory;
|
|
||||||
break;
|
|
||||||
case Vote.contractType:
|
|
||||||
factory = VoteERC20__factory;
|
|
||||||
break;
|
|
||||||
case Marketplace.contractType:
|
|
||||||
factory = Marketplace__factory;
|
|
||||||
break;
|
|
||||||
case Pack.contractType:
|
|
||||||
factory = Pack__factory;
|
|
||||||
break;
|
|
||||||
case Multiwrap.contractType:
|
|
||||||
factory = Multiwrap__factory;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`No factory for contract: ${contractType}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const contractFactory = new ethers.ContractFactory(
|
|
||||||
factory.abi,
|
|
||||||
factory.bytecode,
|
|
||||||
).connect(signer);
|
|
||||||
|
|
||||||
const deployedContract: ethers.Contract = await deployContract(
|
|
||||||
contractFactory,
|
|
||||||
contractType as ContractType,
|
|
||||||
);
|
|
||||||
|
|
||||||
await deployedContract.deployed();
|
|
||||||
const tx = await thirdwebFactoryDeployer.addImplementation(
|
|
||||||
deployedContract.address,
|
|
||||||
);
|
|
||||||
await tx.wait();
|
|
||||||
implementations[contractType as ContractType] = deployedContract.address;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
||||||
process.env.registryAddress = thirdwebRegistryAddress;
|
|
||||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
||||||
process.env.factoryAddress = thirdwebFactoryDeployer.address;
|
|
||||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
||||||
process.env.contractPublisherAddress = contractPublisher.address;
|
|
||||||
|
|
||||||
storage = new MockStorage();
|
|
||||||
sdk = new ThirdwebSDK(
|
|
||||||
signer,
|
|
||||||
{
|
|
||||||
gasSettings: {
|
|
||||||
maxPriceInGwei: 10000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
storage,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
export {
|
|
||||||
ipfsGatewayUrl,
|
|
||||||
sdk,
|
|
||||||
signers,
|
|
||||||
jsonProvider,
|
|
||||||
defaultProvider,
|
|
||||||
registryAddress,
|
|
||||||
fastForwardTime,
|
|
||||||
storage,
|
|
||||||
implementations,
|
|
||||||
};
|
|
||||||
@@ -1,21 +1,20 @@
|
|||||||
import { expectError, signers } from "./before-setup";
|
|
||||||
import { assert, expect } from "chai";
|
|
||||||
import invariant from "tiny-invariant";
|
|
||||||
import {
|
|
||||||
TokenERC20__factory,
|
|
||||||
TokenERC721__factory,
|
|
||||||
VoteERC20__factory,
|
|
||||||
} from "@thirdweb-dev/contracts-js";
|
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import {
|
import {
|
||||||
NATIVE_TOKEN_ADDRESS,
|
NATIVE_TOKEN_ADDRESS,
|
||||||
PayloadToSign20,
|
PayloadToSign20,
|
||||||
SignedPayload721WithQuantitySignature,
|
SignedPayload721WithQuantitySignature,
|
||||||
ThirdwebSDK,
|
ThirdwebSDK,
|
||||||
} from "../src";
|
} from "../src";
|
||||||
|
import { expectError, signers } from "./hooks";
|
||||||
|
import "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import {
|
||||||
|
TokenERC20__factory,
|
||||||
|
TokenERC721__factory,
|
||||||
|
VoteERC20__factory,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import { assert, expect } from "chai";
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
require("./before-setup");
|
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ describe("Custom Contracts", async () => {
|
|||||||
let sdk: ThirdwebSDK;
|
let sdk: ThirdwebSDK;
|
||||||
let simpleContractUri: string;
|
let simpleContractUri: string;
|
||||||
|
|
||||||
before(async () => {
|
beforeAll(async () => {
|
||||||
[adminWallet, samWallet, bobWallet] = signers;
|
[adminWallet, samWallet, bobWallet] = signers;
|
||||||
sdk = new ThirdwebSDK(adminWallet);
|
sdk = new ThirdwebSDK(adminWallet);
|
||||||
simpleContractUri =
|
simpleContractUri =
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { ClaimEligibility } from "../src/enums";
|
import { ClaimEligibility } from "../src/enums";
|
||||||
import { EditionDrop, Token } from "../src/index";
|
import { EditionDrop, Token } from "../src/index";
|
||||||
import { expectError, sdk, signers } from "./before-setup";
|
import { expectError, sdk, signers } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect, use } from "chai";
|
import { assert, expect, use } from "chai";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Edition } from "../src/index";
|
import { Edition } from "../src/index";
|
||||||
import { expectError, sdk, signers, storage } from "./before-setup";
|
import { expectError, sdk, signers, storage } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ethers, Wallet } from "ethers";
|
|
||||||
import { sdk, signers } from "./before-setup";
|
|
||||||
import { expect } from "chai";
|
|
||||||
import { ContractEvent, NFTDrop, NFTCollection } from "../src";
|
import { ContractEvent, NFTDrop, NFTCollection } from "../src";
|
||||||
|
import { sdk, signers } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { expect } from "chai";
|
||||||
|
import { ethers, Wallet } from "ethers";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
@@ -35,17 +35,17 @@ describe("Events", async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
dropContract2 = sdk.getNFTDrop(
|
dropContract2 = sdk.getNFTDrop(
|
||||||
await sdk.deployer.deployBuiltInContract(NFTDrop.contractType, {
|
await sdk.deployer.deployBuiltInContract(NFTDrop.contractType, {
|
||||||
name: `Testing drop from SDK`,
|
name: `Testing drop from SDK`,
|
||||||
description: "Test contract from tests",
|
description: "Test contract from tests",
|
||||||
image:
|
image:
|
||||||
"https://pbs.twimg.com/profile_images/1433508973215367176/XBCfBn3g_400x400.jpg",
|
"https://pbs.twimg.com/profile_images/1433508973215367176/XBCfBn3g_400x400.jpg",
|
||||||
primary_sale_recipient: AddressZero,
|
primary_sale_recipient: AddressZero,
|
||||||
seller_fee_basis_points: 500,
|
seller_fee_basis_points: 500,
|
||||||
fee_recipient: AddressZero,
|
fee_recipient: AddressZero,
|
||||||
platform_fee_basis_points: 10,
|
platform_fee_basis_points: 10,
|
||||||
platform_fee_recipient: AddressZero,
|
platform_fee_recipient: AddressZero,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
nftContract = sdk.getNFTCollection(
|
nftContract = sdk.getNFTCollection(
|
||||||
@@ -79,9 +79,12 @@ describe("Events", async () => {
|
|||||||
|
|
||||||
it("should emit Contract events", async () => {
|
it("should emit Contract events", async () => {
|
||||||
const events: ContractEvent[] = [];
|
const events: ContractEvent[] = [];
|
||||||
const remove = dropContract.events.addEventListener("TokensLazyMinted", (event) => {
|
const remove = dropContract.events.addEventListener(
|
||||||
events.push(event);
|
"TokensLazyMinted",
|
||||||
});
|
(event) => {
|
||||||
|
events.push(event);
|
||||||
|
},
|
||||||
|
);
|
||||||
await dropContract.createBatch([
|
await dropContract.createBatch([
|
||||||
{
|
{
|
||||||
name: "1",
|
name: "1",
|
||||||
@@ -110,7 +113,7 @@ describe("Events", async () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
await dropContract2.claimConditions.set([{}]);
|
await dropContract2.claimConditions.set([{}]);
|
||||||
await dropContract2.claim(1)
|
await dropContract2.claim(1);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||||
remove();
|
remove();
|
||||||
expect(events.length).to.be.gt(0);
|
expect(events.length).to.be.gt(0);
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
import {
|
||||||
|
CONTRACTS_MAP,
|
||||||
|
ContractType,
|
||||||
|
DEFAULT_IPFS_GATEWAY,
|
||||||
|
Edition,
|
||||||
|
EditionDrop,
|
||||||
|
getNativeTokenByChainId,
|
||||||
|
Marketplace,
|
||||||
|
Multiwrap,
|
||||||
|
NFTCollection,
|
||||||
|
NFTDrop,
|
||||||
|
Pack,
|
||||||
|
SignatureDrop,
|
||||||
|
Split,
|
||||||
|
ThirdwebSDK,
|
||||||
|
Token,
|
||||||
|
TokenDrop,
|
||||||
|
Vote,
|
||||||
|
} from "../src";
|
||||||
|
import { ChainId } from "../src/constants/chains";
|
||||||
|
import { MockStorage } from "./mock/MockStorage";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import {
|
||||||
|
ContractPublisher,
|
||||||
|
ContractPublisher__factory,
|
||||||
|
DropERC1155__factory,
|
||||||
|
DropERC20__factory,
|
||||||
|
DropERC721__factory,
|
||||||
|
Marketplace__factory,
|
||||||
|
MockContractPublisher,
|
||||||
|
MockContractPublisher__factory,
|
||||||
|
Multiwrap__factory,
|
||||||
|
Pack__factory,
|
||||||
|
SignatureDrop__factory,
|
||||||
|
Split__factory,
|
||||||
|
TokenERC1155__factory,
|
||||||
|
TokenERC20__factory,
|
||||||
|
TokenERC721__factory,
|
||||||
|
TWFactory,
|
||||||
|
TWFactory__factory,
|
||||||
|
TWFee__factory,
|
||||||
|
TWRegistry,
|
||||||
|
TWRegistry__factory,
|
||||||
|
VoteERC20__factory,
|
||||||
|
} from "@thirdweb-dev/contracts-js";
|
||||||
|
import { IStorage } from "@thirdweb-dev/storage";
|
||||||
|
import { ethers } from "ethers";
|
||||||
|
//@ts-expext-error TS2551: Cannot find name 'ethers'.
|
||||||
|
import { ethers as hardhatEthers } from "hardhat";
|
||||||
|
|
||||||
|
const RPC_URL = "http://localhost:8545";
|
||||||
|
|
||||||
|
const jsonProvider = new ethers.providers.JsonRpcProvider(RPC_URL);
|
||||||
|
const defaultProvider = hardhatEthers.provider;
|
||||||
|
|
||||||
|
let registryAddress: string;
|
||||||
|
let sdk: ThirdwebSDK;
|
||||||
|
const ipfsGatewayUrl = DEFAULT_IPFS_GATEWAY;
|
||||||
|
let signer: SignerWithAddress;
|
||||||
|
let signers: SignerWithAddress[];
|
||||||
|
let storage: IStorage;
|
||||||
|
let implementations: { [key in ContractType]?: string };
|
||||||
|
|
||||||
|
const fastForwardTime = async (timeInSeconds: number): Promise<void> => {
|
||||||
|
const now = Math.floor(Date.now() / 1000);
|
||||||
|
await defaultProvider.send("evm_mine", [now + timeInSeconds]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const expectError = (e: unknown, message: string) => {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
if (!e.message.includes(message)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mochaHooks = {
|
||||||
|
beforeAll: async () => {
|
||||||
|
signers = await hardhatEthers.getSigners();
|
||||||
|
implementations = {};
|
||||||
|
|
||||||
|
[signer] = signers;
|
||||||
|
|
||||||
|
const trustedForwarderAddress =
|
||||||
|
"0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81";
|
||||||
|
await jsonProvider.send("hardhat_reset", []);
|
||||||
|
|
||||||
|
const registry = (await new ethers.ContractFactory(
|
||||||
|
TWRegistry__factory.abi,
|
||||||
|
TWRegistry__factory.bytecode,
|
||||||
|
)
|
||||||
|
.connect(signer)
|
||||||
|
.deploy(trustedForwarderAddress)) as TWRegistry;
|
||||||
|
const registryContract = await registry.deployed();
|
||||||
|
|
||||||
|
const thirdwebFactoryDeployer = (await new ethers.ContractFactory(
|
||||||
|
TWFactory__factory.abi,
|
||||||
|
TWFactory__factory.bytecode,
|
||||||
|
)
|
||||||
|
.connect(signer)
|
||||||
|
.deploy(trustedForwarderAddress, registry.address)) as TWFactory;
|
||||||
|
|
||||||
|
const deployTxFactory = thirdwebFactoryDeployer.deployTransaction;
|
||||||
|
await deployTxFactory.wait();
|
||||||
|
const thirdwebRegistryAddress = await thirdwebFactoryDeployer.registry();
|
||||||
|
registryAddress = thirdwebFactoryDeployer.address;
|
||||||
|
|
||||||
|
await registryContract.grantRole(
|
||||||
|
await registryContract.OPERATOR_ROLE(),
|
||||||
|
thirdwebFactoryDeployer.address,
|
||||||
|
);
|
||||||
|
|
||||||
|
const thirdwebFeeDeployer = await new ethers.ContractFactory(
|
||||||
|
TWFee__factory.abi,
|
||||||
|
TWFee__factory.bytecode,
|
||||||
|
)
|
||||||
|
.connect(signer)
|
||||||
|
.deploy(trustedForwarderAddress, thirdwebFactoryDeployer.address);
|
||||||
|
await thirdwebFactoryDeployer.deployed();
|
||||||
|
|
||||||
|
// Mock publisher for tests
|
||||||
|
const mockPublisher = (await new ethers.ContractFactory(
|
||||||
|
MockContractPublisher__factory.abi,
|
||||||
|
MockContractPublisher__factory.bytecode,
|
||||||
|
)
|
||||||
|
.connect(signer)
|
||||||
|
.deploy()) as MockContractPublisher;
|
||||||
|
const contractPublisher = (await new ethers.ContractFactory(
|
||||||
|
ContractPublisher__factory.abi,
|
||||||
|
ContractPublisher__factory.bytecode,
|
||||||
|
)
|
||||||
|
.connect(signer)
|
||||||
|
.deploy(
|
||||||
|
trustedForwarderAddress,
|
||||||
|
mockPublisher.address,
|
||||||
|
)) as ContractPublisher; // TODO needs MockPublisher here
|
||||||
|
await contractPublisher.deployed();
|
||||||
|
|
||||||
|
async function deployContract(
|
||||||
|
contractFactory: ethers.ContractFactory,
|
||||||
|
contractType: ContractType,
|
||||||
|
): Promise<ethers.Contract> {
|
||||||
|
switch (contractType) {
|
||||||
|
case Marketplace.contractType:
|
||||||
|
case Multiwrap.contractType:
|
||||||
|
const nativeTokenWrapperAddress = getNativeTokenByChainId(
|
||||||
|
ChainId.Hardhat,
|
||||||
|
).wrapped.address;
|
||||||
|
return await contractFactory.deploy(nativeTokenWrapperAddress);
|
||||||
|
case Pack.contractType:
|
||||||
|
const addr = getNativeTokenByChainId(ChainId.Hardhat).wrapped.address;
|
||||||
|
return await contractFactory.deploy(addr, trustedForwarderAddress);
|
||||||
|
default:
|
||||||
|
return await contractFactory.deploy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const contractType in CONTRACTS_MAP) {
|
||||||
|
if (contractType === "custom") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let factory;
|
||||||
|
switch (contractType) {
|
||||||
|
case Token.contractType:
|
||||||
|
factory = TokenERC20__factory;
|
||||||
|
break;
|
||||||
|
case TokenDrop.contractType:
|
||||||
|
factory = DropERC20__factory;
|
||||||
|
break;
|
||||||
|
case NFTCollection.contractType:
|
||||||
|
factory = TokenERC721__factory;
|
||||||
|
break;
|
||||||
|
case NFTDrop.contractType:
|
||||||
|
factory = DropERC721__factory;
|
||||||
|
break;
|
||||||
|
case SignatureDrop.contractType:
|
||||||
|
factory = SignatureDrop__factory;
|
||||||
|
break;
|
||||||
|
case Edition.contractType:
|
||||||
|
factory = TokenERC1155__factory;
|
||||||
|
break;
|
||||||
|
case EditionDrop.contractType:
|
||||||
|
factory = DropERC1155__factory;
|
||||||
|
break;
|
||||||
|
case Split.contractType:
|
||||||
|
factory = Split__factory;
|
||||||
|
break;
|
||||||
|
case Vote.contractType:
|
||||||
|
factory = VoteERC20__factory;
|
||||||
|
break;
|
||||||
|
case Marketplace.contractType:
|
||||||
|
factory = Marketplace__factory;
|
||||||
|
break;
|
||||||
|
case Pack.contractType:
|
||||||
|
factory = Pack__factory;
|
||||||
|
break;
|
||||||
|
case Multiwrap.contractType:
|
||||||
|
factory = Multiwrap__factory;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`No factory for contract: ${contractType}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const contractFactory = new ethers.ContractFactory(
|
||||||
|
factory.abi,
|
||||||
|
factory.bytecode,
|
||||||
|
).connect(signer);
|
||||||
|
|
||||||
|
const deployedContract: ethers.Contract = await deployContract(
|
||||||
|
contractFactory,
|
||||||
|
contractType as ContractType,
|
||||||
|
);
|
||||||
|
|
||||||
|
await deployedContract.deployed();
|
||||||
|
const tx = await thirdwebFactoryDeployer.addImplementation(
|
||||||
|
deployedContract.address,
|
||||||
|
);
|
||||||
|
await tx.wait();
|
||||||
|
implementations[contractType as ContractType] = deployedContract.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
|
process.env.registryAddress = thirdwebRegistryAddress;
|
||||||
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
|
process.env.factoryAddress = thirdwebFactoryDeployer.address;
|
||||||
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
|
process.env.contractPublisherAddress = contractPublisher.address;
|
||||||
|
|
||||||
|
storage = new MockStorage();
|
||||||
|
sdk = new ThirdwebSDK(
|
||||||
|
signer,
|
||||||
|
{
|
||||||
|
gasSettings: {
|
||||||
|
maxPriceInGwei: 10000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
storage,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
ipfsGatewayUrl,
|
||||||
|
sdk,
|
||||||
|
signers,
|
||||||
|
jsonProvider,
|
||||||
|
defaultProvider,
|
||||||
|
registryAddress,
|
||||||
|
fastForwardTime,
|
||||||
|
storage,
|
||||||
|
implementations,
|
||||||
|
};
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { assert, expect } from "chai";
|
|
||||||
import { BigNumber, BigNumberish, ethers } from "ethers";
|
|
||||||
import {
|
import {
|
||||||
AuctionAlreadyStartedError,
|
AuctionAlreadyStartedError,
|
||||||
ListingNotFoundError,
|
ListingNotFoundError,
|
||||||
WrongListingTypeError,
|
WrongListingTypeError,
|
||||||
} from "../src/common/error";
|
} from "../src/common/error";
|
||||||
|
import { isWinningBid } from "../src/common/marketplace";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { ListingType } from "../src/enums/marketplace";
|
|
||||||
import { Edition, Marketplace, NFTCollection, Token } from "../src/contracts";
|
import { Edition, Marketplace, NFTCollection, Token } from "../src/contracts";
|
||||||
|
import { ListingType } from "../src/enums/marketplace";
|
||||||
import { AuctionListing, DirectListing, Offer } from "../src/types/marketplace";
|
import { AuctionListing, DirectListing, Offer } from "../src/types/marketplace";
|
||||||
import {
|
import {
|
||||||
expectError,
|
expectError,
|
||||||
@@ -16,8 +14,10 @@ import {
|
|||||||
jsonProvider,
|
jsonProvider,
|
||||||
sdk,
|
sdk,
|
||||||
signers,
|
signers,
|
||||||
} from "./before-setup";
|
} from "./hooks";
|
||||||
import { isWinningBid } from "../src/common/marketplace";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { assert, expect } from "chai";
|
||||||
|
import { BigNumber, BigNumberish, ethers } from "ethers";
|
||||||
import { ethers as hardhatEthers } from "hardhat";
|
import { ethers as hardhatEthers } from "hardhat";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
@@ -215,7 +215,7 @@ describe("Marketplace Contract", async () => {
|
|||||||
assert.isDefined(listingId);
|
assert.isDefined(listingId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to restrict listing", async () => {
|
it.skip("should be able to restrict listing", async () => {
|
||||||
await marketplaceContract.allowListingFromSpecificAssetOnly(
|
await marketplaceContract.allowListingFromSpecificAssetOnly(
|
||||||
dummyBundleContract.getAddress(),
|
dummyBundleContract.getAddress(),
|
||||||
);
|
);
|
||||||
@@ -1087,9 +1087,7 @@ describe("Marketplace Contract", async () => {
|
|||||||
try {
|
try {
|
||||||
await marketplaceContract.direct.buyoutListing(directListingId, 1);
|
await marketplaceContract.direct.buyoutListing(directListingId, 1);
|
||||||
assert.fail("should have thrown");
|
assert.fail("should have thrown");
|
||||||
} catch (err: any) {
|
} catch (err: any) {}
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not return invalid direct listings", async () => {
|
it("should not return invalid direct listings", async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { sdk, signers } from "./before-setup";
|
|
||||||
import { Edition, Multiwrap, NFTCollection, Token } from "../src/contracts";
|
import { Edition, Multiwrap, NFTCollection, Token } from "../src/contracts";
|
||||||
|
import { sdk, signers } from "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
describe("Multiwrap Contract", async () => {
|
describe("Multiwrap Contract", async () => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NFTDrop, NFTMetadata, NFTMetadataInput, Token } from "../src";
|
|||||||
import { createSnapshot } from "../src/common";
|
import { createSnapshot } from "../src/common";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { ClaimEligibility } from "../src/enums";
|
import { ClaimEligibility } from "../src/enums";
|
||||||
import { expectError, sdk, signers, storage } from "./before-setup";
|
import { expectError, sdk, signers, storage } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { NFTMetadataInput } from "../src";
|
import { NFTMetadataInput } from "../src";
|
||||||
import { NFTCollection } from "../src/contracts";
|
import { NFTCollection } from "../src/contracts";
|
||||||
import { sdk, signers, storage } from "./before-setup";
|
import { sdk, signers, storage } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
import { EditionMetadataInput, Pack, Edition } from "../src";
|
||||||
|
import { sdk, signers } from "./hooks";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { sdk, signers } from "./before-setup";
|
|
||||||
|
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
import { BigNumber } from "ethers";
|
import { BigNumber } from "ethers";
|
||||||
import { EditionMetadataInput, Pack, Edition } from "../src";
|
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
resolveContractUriFromAddress,
|
resolveContractUriFromAddress,
|
||||||
ThirdwebSDK,
|
ThirdwebSDK,
|
||||||
} from "../src";
|
} from "../src";
|
||||||
import { implementations, signers } from "./before-setup";
|
import { implementations, signers } from "./hooks";
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { sdk, signers } from "./before-setup";
|
|
||||||
import { expect } from "chai";
|
|
||||||
import { ContractRegistry } from "../src/core/classes/registry";
|
import { ContractRegistry } from "../src/core/classes/registry";
|
||||||
|
import { sdk, signers } from "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
describe("Contract Registry", () => {
|
describe("Contract Registry", () => {
|
||||||
let registry: ContractRegistry;
|
let registry: ContractRegistry;
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { Edition } from "../src/index";
|
import { Edition } from "../src/index";
|
||||||
import { sdk, signers } from "./before-setup";
|
import { sdk, signers } from "./hooks";
|
||||||
|
|
||||||
import { assert } from "chai";
|
|
||||||
import { AddressZero } from "@ethersproject/constants";
|
import { AddressZero } from "@ethersproject/constants";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { assert } from "chai";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { Edition } from "../src/index";
|
import { Edition } from "../src/index";
|
||||||
import { sdk, signers } from "./before-setup";
|
import { sdk, signers } from "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from "../src";
|
} from "../src";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { SignedPayload721WithQuantitySignature } from "../src/schema/contracts/common/signature";
|
import { SignedPayload721WithQuantitySignature } from "../src/schema/contracts/common/signature";
|
||||||
import { expectError, sdk, signers, storage } from "./before-setup";
|
import { expectError, sdk, signers, storage } from "./hooks";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import { BigNumber, ethers } from "ethers";
|
import { BigNumber, ethers } from "ethers";
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
||||||
import { assert, expect } from "chai";
|
|
||||||
import { BigNumber, ethers } from "ethers";
|
|
||||||
import { Edition, Token } from "../src";
|
import { Edition, Token } from "../src";
|
||||||
import { sdk, signers, storage } from "./before-setup";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import {
|
import {
|
||||||
PayloadToSign1155,
|
PayloadToSign1155,
|
||||||
SignedPayload1155,
|
SignedPayload1155,
|
||||||
} from "../src/schema/contracts/common/signature";
|
} from "../src/schema/contracts/common/signature";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { sdk, signers, storage } from "./hooks";
|
||||||
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
|
import { assert, expect } from "chai";
|
||||||
|
import { BigNumber, ethers } from "ethers";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { PayloadToSign20, SignedPayload20, Token } from "../src";
|
import { PayloadToSign20, SignedPayload20, Token } from "../src";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { sdk, signers } from "./before-setup";
|
import { sdk, signers } from "./hooks";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import { BigNumber } from "ethers";
|
import { BigNumber } from "ethers";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
Token,
|
Token,
|
||||||
} from "../src";
|
} from "../src";
|
||||||
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
import { NATIVE_TOKEN_ADDRESS } from "../src/constants/currency";
|
||||||
import { sdk, signers, storage } from "./before-setup";
|
import { sdk, signers, storage } from "./hooks";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import { BigNumber } from "ethers";
|
import { BigNumber } from "ethers";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { Split, Token } from "../src";
|
||||||
|
import { sdk, signers } from "./hooks";
|
||||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import { sdk, signers } from "./before-setup";
|
|
||||||
import { Split, Token } from "../src";
|
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
|
||||||
global.fetch = require("cross-fetch");
|
global.fetch = require("cross-fetch");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user