Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b052d63e9 | ||
|
|
a3f6878649 | ||
|
|
74a92dcb7d | ||
|
|
38fc0b796a | ||
|
|
ef76a96c2d | ||
|
|
2667706d8d | ||
|
|
047fbe2918 |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
|
||||
## 4.1.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.36",
|
||||
"version": "4.1.37",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/chains
|
||||
|
||||
## 0.1.77
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2406](https://github.com/thirdweb-dev/js/pull/2406) [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
|
||||
|
||||
## 0.1.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 51277,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "QI0344s1 Testne",
|
||||
"nativeCurrency": {
|
||||
"name": "QI0344s1 Testne Token",
|
||||
"symbol": "LKG",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 51277,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://51277.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "QI0344s1 Testne",
|
||||
"slug": "qi0344s1-testne",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 57021,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "QIM2403061",
|
||||
"nativeCurrency": {
|
||||
"name": "QIM2403061 Token",
|
||||
"symbol": "VVC",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 57021,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://57021.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "QIM2403061",
|
||||
"slug": "qim2403061",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 72877,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "QaUser4 Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "QaUser4 Testnet Token",
|
||||
"symbol": "ZAG",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 72877,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://72877.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "QaUser4 Testnet",
|
||||
"slug": "qauser4-testnet-qauser4 testnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/chains",
|
||||
"version": "0.1.76",
|
||||
"version": "0.1.77",
|
||||
"main": "dist/thirdweb-dev-chains.cjs.js",
|
||||
"module": "dist/thirdweb-dev-chains.esm.js",
|
||||
"exports": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,17 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2400](https://github.com/thirdweb-dev/js/pull/2400) [`ef76a96`](https://github.com/thirdweb-dev/js/commit/ef76a96c2dda21e28195371fd48e57350721b717) Thanks [@kumaryash90](https://github.com/kumaryash90)! - "Option to link external libraries"
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f), [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/auth@4.1.37
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 0.13.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.44",
|
||||
"version": "0.13.45",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -20,6 +20,7 @@ import { generate } from "../generate/command";
|
||||
import { findPackageInstallation } from "../helpers/detect-local-packages";
|
||||
import { install } from "../install";
|
||||
import { upload } from "../storage/command";
|
||||
import { parseLinkLibOption } from "../common/link-lib-helper";
|
||||
|
||||
const main = async () => {
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
@@ -331,6 +332,12 @@ const main = async () => {
|
||||
"Deploy a dynamic smart contract made up of extensions to blockchains",
|
||||
)
|
||||
.option("--zksync", "Deploy on ZKSync")
|
||||
.option(
|
||||
"--link-lib <library:address...>",
|
||||
"Specify library names and addresses",
|
||||
parseLinkLibOption,
|
||||
[],
|
||||
)
|
||||
.option("-k, --key <key>", "API secret key to authorize usage")
|
||||
.action(async (options) => {
|
||||
let secretKey = "";
|
||||
@@ -370,6 +377,12 @@ const main = async () => {
|
||||
.option("--dry-run", "dry run (skip actually publishing)")
|
||||
.option("-d, --debug", "show debug logs")
|
||||
.option("--ci", "Continuous Integration mode")
|
||||
.option(
|
||||
"--link-lib <library:address...>",
|
||||
"Specify library names and addresses",
|
||||
parseLinkLibOption,
|
||||
[],
|
||||
)
|
||||
.option("-k, --key <key>", "API secret key to authorize usage")
|
||||
.action(async (options) => {
|
||||
let secretKey = "";
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { utils } from "ethers";
|
||||
import { isAddress } from "ethers/lib/utils";
|
||||
|
||||
export interface Link {
|
||||
library: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
// Custom array option parser for --link-lib
|
||||
export function parseLinkLibOption(
|
||||
value: string,
|
||||
previousValue: Link[] | undefined,
|
||||
): Link[] {
|
||||
const links = previousValue || [];
|
||||
const [library, address] = value.split(":");
|
||||
if (!isAddress(address)) {
|
||||
throw new Error(`Invalid address ${address} `);
|
||||
}
|
||||
links.push({ library, address });
|
||||
return links;
|
||||
}
|
||||
|
||||
// replace placeholder in bytecode with library address
|
||||
export function linkLibrary(
|
||||
bytecode: string,
|
||||
libraries: {
|
||||
[key: string]: string;
|
||||
} = {},
|
||||
): string {
|
||||
let linkedBytecode = bytecode;
|
||||
for (const [key, address] of Object.entries(libraries)) {
|
||||
const placeholder = `__\$${utils
|
||||
.solidityKeccak256(["string"], [key])
|
||||
.slice(2, 36)}\$__`;
|
||||
const formattedAddress = utils
|
||||
.getAddress(address)
|
||||
.toLowerCase()
|
||||
.replace("0x", "");
|
||||
|
||||
linkedBytecode = linkedBytecode.replaceAll(placeholder, formattedAddress);
|
||||
}
|
||||
return linkedBytecode;
|
||||
}
|
||||
@@ -41,5 +41,6 @@ export default async function build(
|
||||
projectPath: path,
|
||||
clean: options.clean,
|
||||
zksync: options.zksync,
|
||||
linkLib: options.linkLib,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { findFiles } from "../../common/file-helper";
|
||||
import { Link, linkLibrary } from "../../common/link-lib-helper";
|
||||
import { hasForge } from "../../create/helpers/has-forge";
|
||||
import { execute } from "../helpers/exec";
|
||||
import { logger } from "../helpers/logger";
|
||||
@@ -43,6 +44,24 @@ export class FoundryBuilder extends BaseBuilder {
|
||||
const files: string[] = [];
|
||||
findFiles(outPath, /^.*(?<!metadata)\.json$/, files);
|
||||
|
||||
const libraries: { [key: string]: string } = {};
|
||||
if (Array.isArray(options.linkLib) && options.linkLib.length > 0) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const contractName = basename(file, ".json");
|
||||
const contractJsonFile = readFileSync(file, "utf-8");
|
||||
const contractInfo = JSON.parse(contractJsonFile);
|
||||
|
||||
options.linkLib.forEach((link: Link) => {
|
||||
if (contractName === link.library) {
|
||||
const key = `${contractInfo.ast.absolutePath}:${link.library}`;
|
||||
libraries[key] = link.address;
|
||||
}
|
||||
});
|
||||
}
|
||||
logger.debug(`Found libraries to link: ${JSON.stringify(libraries)}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const contractName = basename(file, ".json");
|
||||
@@ -76,8 +95,13 @@ export class FoundryBuilder extends BaseBuilder {
|
||||
continue;
|
||||
}
|
||||
|
||||
const bytecode = contractInfo.bytecode.object;
|
||||
const deployedBytecode = contractInfo.deployedBytecode.object;
|
||||
let bytecode = contractInfo.bytecode.object;
|
||||
let deployedBytecode = contractInfo.deployedBytecode.object;
|
||||
|
||||
// link external libraries if any
|
||||
bytecode = linkLibrary(bytecode, libraries);
|
||||
deployedBytecode = linkLibrary(deployedBytecode, libraries);
|
||||
|
||||
const parsedMetadata = contractInfo.metadata;
|
||||
const metadata =
|
||||
contractInfo.rawMetadata ||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { findFiles } from "../../common/file-helper";
|
||||
import { Link, linkLibrary } from "../../common/link-lib-helper";
|
||||
import { execute } from "../helpers/exec";
|
||||
import { logger } from "../helpers/logger";
|
||||
import { ContractPayload } from "../interfaces/ContractPayload";
|
||||
@@ -85,6 +86,22 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
|
||||
const contractBuildOutputs = buildJson.output.contracts;
|
||||
|
||||
const libraries: { [key: string]: string } = {};
|
||||
if (Array.isArray(options.linkLib) && options.linkLib.length > 0) {
|
||||
for (const [contractPath, contractInfos] of Object.entries(
|
||||
contractBuildOutputs,
|
||||
)) {
|
||||
const contractNames = Object.keys(contractInfos as any);
|
||||
options.linkLib.forEach((link: Link) => {
|
||||
if (contractNames.includes(link.library)) {
|
||||
const key = `${contractPath}:${link.library}`;
|
||||
libraries[key] = link.address;
|
||||
}
|
||||
});
|
||||
}
|
||||
logger.debug(`Found libraries to link: ${JSON.stringify(libraries)}`);
|
||||
}
|
||||
|
||||
for (const [contractPath, contractInfos] of Object.entries(
|
||||
contractBuildOutputs,
|
||||
)) {
|
||||
@@ -109,9 +126,13 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
continue;
|
||||
}
|
||||
|
||||
const bytecode = info.evm.bytecode.object;
|
||||
const deployedBytecode =
|
||||
info.evm.deployedBytecode?.object || bytecode;
|
||||
let bytecode = info.evm.bytecode.object;
|
||||
let deployedBytecode = info.evm.deployedBytecode?.object || bytecode;
|
||||
|
||||
// link external libraries if any
|
||||
bytecode = linkLibrary(bytecode, libraries);
|
||||
deployedBytecode = linkLibrary(deployedBytecode, libraries);
|
||||
|
||||
const { metadata, abi } = info;
|
||||
|
||||
const meta = metadata.solc_metadata
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Link } from "../../common/link-lib-helper";
|
||||
import { ContractPayload } from "./ContractPayload";
|
||||
|
||||
export type CompileOptions = {
|
||||
@@ -5,6 +6,7 @@ export type CompileOptions = {
|
||||
projectPath: string;
|
||||
name: string;
|
||||
zksync?: boolean;
|
||||
linkLib?: Link[];
|
||||
};
|
||||
|
||||
export interface IBuilder {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.4.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f), [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/auth@4.1.37
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 4.4.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.4.12",
|
||||
"version": "4.4.13",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.7.10
|
||||
|
||||
## 0.7.9
|
||||
|
||||
## 0.7.8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.7.9",
|
||||
"version": "0.7.10",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.7.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f), [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/react-core@4.4.13
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 0.7.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.7.9",
|
||||
"version": "0.7.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.4.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f), [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/react-core@4.4.13
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 4.4.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.4.12",
|
||||
"version": "4.4.13",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
|
||||
## 4.0.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.39",
|
||||
"version": "4.0.40",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,17 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.4.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2415](https://github.com/thirdweb-dev/js/pull/2415) [`a3f6878`](https://github.com/thirdweb-dev/js/commit/a3f6878649345ea7b647d085d5d7d536af82948f) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Remove unnecessary logs, add getEmail check
|
||||
|
||||
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f), [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/wallets@2.4.15
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/auth@4.1.37
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 0.4.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.3",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -144,11 +144,10 @@ class ThirdwebBridge implements TWBridge {
|
||||
}
|
||||
(globalThis as any).X_SDK_NAME = "UnitySDK_WebGL";
|
||||
(globalThis as any).X_SDK_PLATFORM = "unity";
|
||||
(globalThis as any).X_SDK_VERSION = "4.7.5";
|
||||
(globalThis as any).X_SDK_VERSION = "4.7.6";
|
||||
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
|
||||
}
|
||||
this.initializedChain = chain;
|
||||
console.debug("thirdwebSDK initialization:", chain, options);
|
||||
const sdkOptions = JSON.parse(options);
|
||||
let supportedChains;
|
||||
if (sdkOptions?.supportedChains) {
|
||||
@@ -167,7 +166,7 @@ class ThirdwebBridge implements TWBridge {
|
||||
supportedChains = defaultChains;
|
||||
}
|
||||
} else {
|
||||
console.debug("no supportedChains passed, using default chains");
|
||||
console.warn("no supportedChains passed, using default chains");
|
||||
supportedChains = defaultChains;
|
||||
}
|
||||
sdkOptions.supportedChains = supportedChains;
|
||||
@@ -446,7 +445,7 @@ class ThirdwebBridge implements TWBridge {
|
||||
return arg;
|
||||
}
|
||||
});
|
||||
console.debug("thirdwebSDK call:", route, parsedArgs);
|
||||
// console.debug("thirdwebSDK call:", route, parsedArgs);
|
||||
|
||||
// wallet call
|
||||
if (addrOrSDK.startsWith("sdk")) {
|
||||
@@ -601,14 +600,6 @@ class ThirdwebBridge implements TWBridge {
|
||||
}
|
||||
});
|
||||
|
||||
console.debug(
|
||||
"thirdwebSDK invoke listener:",
|
||||
taskId,
|
||||
route,
|
||||
parsedFnArgs,
|
||||
action,
|
||||
);
|
||||
|
||||
// contract call
|
||||
if (addrOrSDK.startsWith("0x")) {
|
||||
let typeOrAbi: string | ContractInterface | undefined;
|
||||
@@ -673,14 +664,6 @@ class ThirdwebBridge implements TWBridge {
|
||||
personalWallet: AbstractClientWallet,
|
||||
accountAddress?: string,
|
||||
) {
|
||||
if (accountAddress) {
|
||||
console.debug(
|
||||
"Initializing smart wallet with account address override:",
|
||||
accountAddress,
|
||||
);
|
||||
}
|
||||
const personalWalletAddress = await personalWallet.getAddress();
|
||||
console.debug("Personal wallet address:", personalWalletAddress);
|
||||
await sw.connect({
|
||||
personalWallet,
|
||||
accountAddress: accountAddress,
|
||||
@@ -808,6 +791,9 @@ class ThirdwebBridge implements TWBridge {
|
||||
}
|
||||
|
||||
public async getEmail() {
|
||||
if (!this.activeWallet) {
|
||||
throw new Error("No wallet connected");
|
||||
}
|
||||
const embeddedWallet = this.walletMap.get(
|
||||
walletIds.embeddedWallet,
|
||||
) as EmbeddedWallet;
|
||||
@@ -825,9 +811,6 @@ class ThirdwebBridge implements TWBridge {
|
||||
const res = await signer?.getAddress();
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
} catch {
|
||||
console.debug(
|
||||
"Could not find a smart wallet, defaulting to normal signer",
|
||||
);
|
||||
const signer = await this.activeWallet.getSigner();
|
||||
const res = await signer.getAddress();
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.4.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2414](https://github.com/thirdweb-dev/js/pull/2414) [`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f) Thanks [@jnsdls](https://github.com/jnsdls)! - properly pass through clientId and secretKey variables to verifySignature functions
|
||||
|
||||
- Updated dependencies [[`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d)]:
|
||||
- @thirdweb-dev/chains@0.1.77
|
||||
- @thirdweb-dev/sdk@4.0.40
|
||||
|
||||
## 2.4.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.4.14",
|
||||
"version": "2.4.15",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
checkContractWalletSignature,
|
||||
chainIdToThirdwebRpc,
|
||||
} from "../../../wallets/abstract";
|
||||
import { setAnalyticsHeaders } from "../../../utils/headers";
|
||||
import { isTwUrl } from "../../../utils/url";
|
||||
|
||||
export class ERC4337EthersSigner extends Signer {
|
||||
config: ProviderConfig;
|
||||
@@ -103,7 +105,7 @@ export class ERC4337EthersSigner extends Signer {
|
||||
errorIn.reason;
|
||||
|
||||
if (failedOpMessage?.includes("FailedOp")) {
|
||||
let paymasterInfo: string = "";
|
||||
let paymasterInfo = "";
|
||||
// TODO: better error extraction methods will be needed
|
||||
const matched = failedOpMessage.match(/FailedOp\((.*)\)/);
|
||||
|
||||
@@ -179,9 +181,58 @@ Code: ${errorCode}`;
|
||||
let factorySupports712: boolean;
|
||||
let signature: string;
|
||||
|
||||
const rpcUrl = chainIdToThirdwebRpc(chainId, this.config.clientId);
|
||||
|
||||
const headers: Record<string, string> = {};
|
||||
|
||||
if (isTwUrl(rpcUrl)) {
|
||||
const bundleId =
|
||||
typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis
|
||||
? ((globalThis as any).APP_BUNDLE_ID as string)
|
||||
: undefined;
|
||||
|
||||
if (this.config.secretKey) {
|
||||
headers["x-secret-key"] = this.config.secretKey;
|
||||
} else if (this.config.clientId) {
|
||||
headers["x-client-id"] = this.config.clientId;
|
||||
|
||||
if (bundleId) {
|
||||
headers["x-bundle-id"] = bundleId;
|
||||
}
|
||||
}
|
||||
|
||||
// Dashboard token
|
||||
if (
|
||||
typeof globalThis !== "undefined" &&
|
||||
"TW_AUTH_TOKEN" in globalThis &&
|
||||
typeof (globalThis as any).TW_AUTH_TOKEN === "string"
|
||||
) {
|
||||
headers["authorization"] = `Bearer ${
|
||||
(globalThis as any).TW_AUTH_TOKEN as string
|
||||
}`;
|
||||
}
|
||||
|
||||
// CLI token
|
||||
if (
|
||||
typeof globalThis !== "undefined" &&
|
||||
"TW_CLI_AUTH_TOKEN" in globalThis &&
|
||||
typeof (globalThis as any).TW_CLI_AUTH_TOKEN === "string"
|
||||
) {
|
||||
headers["authorization"] = `Bearer ${
|
||||
(globalThis as any).TW_CLI_AUTH_TOKEN as string
|
||||
}`;
|
||||
headers["x-authorize-wallet"] = "true";
|
||||
}
|
||||
|
||||
setAnalyticsHeaders(headers);
|
||||
}
|
||||
|
||||
try {
|
||||
const provider = new providers.JsonRpcProvider(
|
||||
chainIdToThirdwebRpc(chainId, this.config.clientId),
|
||||
const provider = new providers.StaticJsonRpcProvider(
|
||||
{
|
||||
url: chainIdToThirdwebRpc(chainId, this.config.clientId),
|
||||
headers,
|
||||
},
|
||||
chainId,
|
||||
);
|
||||
const walletContract = new Contract(
|
||||
@@ -222,6 +273,8 @@ Code: ${errorCode}`;
|
||||
signature,
|
||||
address,
|
||||
chainId,
|
||||
this.config.clientId,
|
||||
this.config.secretKey,
|
||||
);
|
||||
|
||||
if (isValid) {
|
||||
|
||||
@@ -69,7 +69,7 @@ export class HttpRpcClient {
|
||||
setAnalyticsHeaders(headers);
|
||||
}
|
||||
|
||||
this.userOpJsonRpcProvider = new providers.JsonRpcProvider(
|
||||
this.userOpJsonRpcProvider = new providers.StaticJsonRpcProvider(
|
||||
{
|
||||
url: this.bundlerUrl,
|
||||
headers,
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
normalizePriceValue,
|
||||
} from "@thirdweb-dev/sdk";
|
||||
import { createErc20 } from "../utils/currency";
|
||||
import { isTwUrl } from "../utils/url";
|
||||
import { setAnalyticsHeaders } from "../utils/headers";
|
||||
|
||||
// TODO improve this
|
||||
export function chainIdToThirdwebRpc(chainId: number, clientId?: string) {
|
||||
@@ -49,6 +51,8 @@ export async function checkContractWalletSignature(
|
||||
signature: string,
|
||||
address: string,
|
||||
chainId: number,
|
||||
clientId?: string,
|
||||
secretKey?: string,
|
||||
): Promise<boolean> {
|
||||
// TODO: remove below `skipFetchSetup` logic when ethers.js v6 support arrives
|
||||
let _skipFetchSetup = false;
|
||||
@@ -60,11 +64,60 @@ export async function checkContractWalletSignature(
|
||||
_skipFetchSetup = (globalThis as any).TW_SKIP_FETCH_SETUP as boolean;
|
||||
}
|
||||
|
||||
//TODO: A provider should be passed in instead of creating a new one here.
|
||||
const provider = new providers.JsonRpcProvider({
|
||||
url: chainIdToThirdwebRpc(chainId),
|
||||
skipFetchSetup: _skipFetchSetup,
|
||||
});
|
||||
const rpcUrl = chainIdToThirdwebRpc(chainId, clientId);
|
||||
|
||||
const headers: Record<string, string> = {};
|
||||
|
||||
if (isTwUrl(rpcUrl)) {
|
||||
const bundleId =
|
||||
typeof globalThis !== "undefined" && "APP_BUNDLE_ID" in globalThis
|
||||
? ((globalThis as any).APP_BUNDLE_ID as string)
|
||||
: undefined;
|
||||
|
||||
if (secretKey) {
|
||||
headers["x-secret-key"] = secretKey;
|
||||
} else if (clientId) {
|
||||
headers["x-client-id"] = clientId;
|
||||
|
||||
if (bundleId) {
|
||||
headers["x-bundle-id"] = bundleId;
|
||||
}
|
||||
}
|
||||
|
||||
// Dashboard token
|
||||
if (
|
||||
typeof globalThis !== "undefined" &&
|
||||
"TW_AUTH_TOKEN" in globalThis &&
|
||||
typeof (globalThis as any).TW_AUTH_TOKEN === "string"
|
||||
) {
|
||||
headers["authorization"] = `Bearer ${
|
||||
(globalThis as any).TW_AUTH_TOKEN as string
|
||||
}`;
|
||||
}
|
||||
|
||||
// CLI token
|
||||
if (
|
||||
typeof globalThis !== "undefined" &&
|
||||
"TW_CLI_AUTH_TOKEN" in globalThis &&
|
||||
typeof (globalThis as any).TW_CLI_AUTH_TOKEN === "string"
|
||||
) {
|
||||
headers["authorization"] = `Bearer ${
|
||||
(globalThis as any).TW_CLI_AUTH_TOKEN as string
|
||||
}`;
|
||||
headers["x-authorize-wallet"] = "true";
|
||||
}
|
||||
|
||||
setAnalyticsHeaders(headers);
|
||||
}
|
||||
|
||||
const provider = new providers.StaticJsonRpcProvider(
|
||||
{
|
||||
url: chainIdToThirdwebRpc(chainId),
|
||||
skipFetchSetup: _skipFetchSetup,
|
||||
headers,
|
||||
},
|
||||
chainId,
|
||||
);
|
||||
const walletContract = new Contract(address, EIP1271_ABI, provider);
|
||||
try {
|
||||
const res = await walletContract.isValidSignature(
|
||||
@@ -201,6 +254,8 @@ export abstract class AbstractWallet
|
||||
signature: string,
|
||||
address: string,
|
||||
chainId?: number,
|
||||
clientId?: string,
|
||||
secretKey?: string,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const messageHash = utils.hashMessage(message);
|
||||
@@ -225,6 +280,8 @@ export abstract class AbstractWallet
|
||||
signature,
|
||||
address,
|
||||
chainId || 1,
|
||||
clientId,
|
||||
secretKey,
|
||||
);
|
||||
return isValid;
|
||||
} catch {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ThirdwebSDK, SmartContract } from "@thirdweb-dev/sdk";
|
||||
import { BigNumber, ethers } from "ethers";
|
||||
|
||||
require("dotenv-mono").load();
|
||||
|
||||
jest.setTimeout(240_000);
|
||||
|
||||
let smartWallet: SmartWallet;
|
||||
@@ -33,7 +34,9 @@ beforeAll(async () => {
|
||||
erc20TokenAddress: erc20TokenAddress,
|
||||
});
|
||||
smartWalletAddress = await smartWallet.connect({ personalWallet });
|
||||
sdk = await ThirdwebSDK.fromWallet(smartWallet, chain);
|
||||
sdk = await ThirdwebSDK.fromWallet(smartWallet, chain, {
|
||||
secretKey: process.env.TW_SECRET_KEY,
|
||||
});
|
||||
contract = await sdk.getContract(
|
||||
"0xF7235993A1BB401620e7c384D541e78D18081090", // using same token for payment and claim
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ThirdwebSDK, SmartContract } from "@thirdweb-dev/sdk";
|
||||
import { checkContractWalletSignature } from "../src/evm/wallets/abstract";
|
||||
|
||||
require("dotenv-mono").load();
|
||||
|
||||
jest.setTimeout(240_000);
|
||||
|
||||
let smartWallet: SmartWallet;
|
||||
@@ -15,6 +16,7 @@ let contract: SmartContract;
|
||||
const factoryAddress = "0x13947435c2fe6BE51ED82F6f59C38617a323dB9B"; // pre 712
|
||||
const factoryAddressV2 = "0xC64d04AedecA895b3F20DC6866b4b532e0b22634"; // post 712
|
||||
const chain = Mumbai;
|
||||
const SECRET_KEY = process.env.TW_SECRET_KEY;
|
||||
|
||||
const describeIf = (condition: boolean) =>
|
||||
condition ? describe : describe.skip;
|
||||
@@ -26,16 +28,18 @@ beforeAll(async () => {
|
||||
chain,
|
||||
factoryAddress,
|
||||
gasless: true,
|
||||
secretKey: process.env.TW_SECRET_KEY,
|
||||
secretKey: SECRET_KEY,
|
||||
});
|
||||
smartWalletAddress = await smartWallet.connect({ personalWallet });
|
||||
const sdk = await ThirdwebSDK.fromWallet(smartWallet, chain);
|
||||
const sdk = await ThirdwebSDK.fromWallet(smartWallet, chain, {
|
||||
secretKey: SECRET_KEY,
|
||||
});
|
||||
contract = await sdk.getContract(
|
||||
"0xD170A53dADb19f62C78AB9982236857B71dbc83A", // mumbai edition drop
|
||||
);
|
||||
});
|
||||
|
||||
describeIf(!!process.env.TW_SECRET_KEY)("SmartWallet core tests", () => {
|
||||
describeIf(!!SECRET_KEY)("SmartWallet core tests", () => {
|
||||
it("can connect", async () => {
|
||||
expect(smartWalletAddress).toHaveLength(42);
|
||||
});
|
||||
@@ -107,6 +111,8 @@ describeIf(!!process.env.TW_SECRET_KEY)("SmartWallet core tests", () => {
|
||||
sig,
|
||||
smartWalletAddress,
|
||||
chain.chainId,
|
||||
undefined,
|
||||
SECRET_KEY,
|
||||
);
|
||||
expect(isValidV1).toEqual(true);
|
||||
const isValidV2 = await checkContractWalletSignature(
|
||||
@@ -114,6 +120,8 @@ describeIf(!!process.env.TW_SECRET_KEY)("SmartWallet core tests", () => {
|
||||
sig,
|
||||
smartWalletAddress,
|
||||
chain.chainId,
|
||||
undefined,
|
||||
SECRET_KEY,
|
||||
);
|
||||
expect(isValidV2).toEqual(true);
|
||||
});
|
||||
@@ -133,6 +141,8 @@ describeIf(!!process.env.TW_SECRET_KEY)("SmartWallet core tests", () => {
|
||||
sig,
|
||||
smartWalletAddress,
|
||||
chain.chainId,
|
||||
undefined,
|
||||
SECRET_KEY,
|
||||
);
|
||||
expect(isValidV1).toEqual(true);
|
||||
const isValidV2 = await checkContractWalletSignature(
|
||||
@@ -140,6 +150,8 @@ describeIf(!!process.env.TW_SECRET_KEY)("SmartWallet core tests", () => {
|
||||
sig,
|
||||
smartWalletAddress,
|
||||
chain.chainId,
|
||||
undefined,
|
||||
SECRET_KEY,
|
||||
);
|
||||
expect(isValidV2).toEqual(true);
|
||||
});
|
||||
|
||||
Binary file not shown.
@@ -1882,7 +1882,7 @@
|
||||
],
|
||||
"ERC721UpdatableMetadata": [
|
||||
{
|
||||
"name": "update",
|
||||
"name": "updateMetadata",
|
||||
"summary": "Update the metadata of an NFT\n\n",
|
||||
"remarks": "\n\nUpdate the metadata of an NFT\n\n",
|
||||
"examples": {
|
||||
|
||||
Reference in New Issue
Block a user