Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
755cffe590 | ||
|
|
dd1141f9af | ||
|
|
968fdc3ebe | ||
|
|
2ef20589b7 | ||
|
|
6d63920c0a | ||
|
|
3ef378659e | ||
|
|
eba8f1c198 | ||
|
|
52f827e8f2 | ||
|
|
6063f40f87 | ||
|
|
6bd1b82a58 | ||
|
|
052892b396 |
@@ -1,5 +1,19 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.52
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
|
||||
## 4.1.51
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
|
||||
## 4.1.50
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.50",
|
||||
"version": "4.1.52",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/chains
|
||||
|
||||
## 0.1.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2590](https://github.com/thirdweb-dev/js/pull/2590) [`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
|
||||
|
||||
## 0.1.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "NetMind",
|
||||
"chainId": 1100789,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "NetMind Testnet Explorer",
|
||||
"url": "https://testbrower.protago-dev.com",
|
||||
"standard": "EIP3091",
|
||||
"icon": {
|
||||
"url": "ipfs://QmQNipd6uen7sm7HZXGbqhcSVkUXxu3Tp6c3BoeFpvmywp",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmQNipd6uen7sm7HZXGbqhcSVkUXxu3Tp6c3BoeFpvmywp",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://netmind.ai",
|
||||
"name": "Netmind Chain Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "NMT",
|
||||
"symbol": "NMT",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 1100789,
|
||||
"rpc": [
|
||||
"https://1100789.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://testblock.protago-dev.com"
|
||||
],
|
||||
"shortName": "nmtTest",
|
||||
"slug": "netmind-chain-testnet",
|
||||
"testnet": true,
|
||||
"title": "NetMind Chain Testnet"
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Azra Testnet",
|
||||
"chainId": 5106,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "blockscout",
|
||||
"url": "https://explorerl2new-azra-testnet-6hz86owb1n.t.conduit.xyz",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"infoURL": "https://azragames.com",
|
||||
"name": "Azra Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "ETH",
|
||||
"symbol": "ETH",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 5106,
|
||||
"rpc": [
|
||||
"https://5106.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc-azra-testnet-6hz86owb1n.t.conduit.xyz"
|
||||
],
|
||||
"shortName": "azra-testnet",
|
||||
"slug": "azra-testnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -39,6 +39,7 @@ export default {
|
||||
"shortName": "maticmum",
|
||||
"slip44": 1,
|
||||
"slug": "mumbai",
|
||||
"status": "active",
|
||||
"testnet": true,
|
||||
"title": "Polygon Testnet Mumbai"
|
||||
} as const satisfies Chain;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/chains",
|
||||
"version": "0.1.84",
|
||||
"version": "0.1.85",
|
||||
"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,26 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.60
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
- @thirdweb-dev/auth@4.1.52
|
||||
|
||||
## 0.13.59
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2584](https://github.com/thirdweb-dev/js/pull/2584) [`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0) Thanks [@kumaryash90](https://github.com/kumaryash90)! - cli changes for zksync publish
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
- @thirdweb-dev/auth@4.1.51
|
||||
|
||||
## 0.13.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/cli",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.58",
|
||||
"version": "0.13.60",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -377,6 +377,7 @@ const main = async () => {
|
||||
.option("--dry-run", "dry run (skip actually publishing)")
|
||||
.option("-d, --debug", "show debug logs")
|
||||
.option("--ci", "Continuous Integration mode")
|
||||
.option("--zksync", "Publish with ZKSync settings")
|
||||
.option(
|
||||
"--link-lib <library:address...>",
|
||||
"Specify library names and addresses",
|
||||
|
||||
@@ -61,9 +61,7 @@ export async function processProject(
|
||||
|
||||
logger.debug("Processing project at path " + projectPath);
|
||||
|
||||
const projectType = options.zksync
|
||||
? "hardhat"
|
||||
: await detect(projectPath, options);
|
||||
const projectType = await detect(projectPath, options);
|
||||
|
||||
if (projectType === "none") {
|
||||
if (command === "deploy") {
|
||||
@@ -106,9 +104,25 @@ export async function processProject(
|
||||
}
|
||||
|
||||
let compiledResult: { contracts: ContractPayload[] };
|
||||
let zkCompiledResult: { contracts: ContractPayload[] };
|
||||
const compileLoader = spinner("Compiling project...");
|
||||
try {
|
||||
compiledResult = await build(projectPath, projectType, options);
|
||||
|
||||
if (options.zksync) {
|
||||
zkCompiledResult = await build(projectPath, "zk-hardhat", options);
|
||||
|
||||
if (
|
||||
compiledResult.contracts.length !== zkCompiledResult.contracts.length
|
||||
) {
|
||||
logger.error(
|
||||
"Length mismatch: zksolc and solc compiled contracts differ.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
zkCompiledResult = { contracts: [] };
|
||||
}
|
||||
} catch (e) {
|
||||
compileLoader.fail("Compilation failed");
|
||||
logger.error(e);
|
||||
@@ -223,6 +237,23 @@ export async function processProject(
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let zkSelectedContracts: ContractPayload[] = [];
|
||||
if (options.zksync) {
|
||||
const fileNames = selectedContracts.map((selected) => selected.fileName);
|
||||
zkSelectedContracts = zkCompiledResult.contracts.filter((contract) => {
|
||||
const index = fileNames.indexOf(contract.fileName);
|
||||
|
||||
return index !== -1;
|
||||
});
|
||||
|
||||
if (zkSelectedContracts.length !== selectedContracts.length) {
|
||||
info(
|
||||
"Selected contract not present in zksolc compiled contracts. Aborting.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
info("Dry run, skipping deployment");
|
||||
process.exit(0);
|
||||
@@ -332,6 +363,81 @@ export async function processProject(
|
||||
metadataUri: metadataURIs[i],
|
||||
bytecodeUri: bytecodeURIs[i],
|
||||
analytics,
|
||||
compilers: {
|
||||
solc: [
|
||||
{
|
||||
compilerVersion: compiledResult.contracts[0].compilerVersion,
|
||||
evmVersion: compiledResult.contracts[0].evmVersion,
|
||||
metadataUri: metadataURIs[i],
|
||||
bytecodeUri: bytecodeURIs[i],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// upload zk-contracts if present
|
||||
if (zkSelectedContracts.length > 0) {
|
||||
for (let i = 0; i < zkSelectedContracts.length; i++) {
|
||||
const contract = zkSelectedContracts[i];
|
||||
if (contract.sources) {
|
||||
// upload sources in batches to avoid getting rate limited (needs to be single uploads)
|
||||
const batchSize = 3;
|
||||
for (let j = 0; j < contract.sources.length; j = j + batchSize) {
|
||||
const batch = contract.sources.slice(j, j + batchSize);
|
||||
logger.debug(`Uploading Sources:\n${batch.join("\n")}\n`);
|
||||
await Promise.all(
|
||||
batch.map(async (c) => {
|
||||
const file = readFileSync(c, "utf-8");
|
||||
if (file.includes(soliditySDKPackage)) {
|
||||
usesSoliditySDK = true;
|
||||
}
|
||||
return await storage.upload(file, {
|
||||
uploadWithoutDirectory: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Upload build output metadatas (need to be single uploads)
|
||||
const zkMetadataURIs = await Promise.all(
|
||||
zkSelectedContracts.map(async (c) => {
|
||||
logger.debug(`Uploading ${c.name}...`);
|
||||
|
||||
return await storage.upload(JSON.parse(JSON.stringify(c.metadata)), {
|
||||
uploadWithoutDirectory: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
// Upload batch all bytecodes
|
||||
const zkBytecodes = zkSelectedContracts.map((c) => c.bytecode);
|
||||
const zkBytecodeURIs = await storage.uploadBatch(zkBytecodes);
|
||||
|
||||
combinedContents = combinedContents.map((c, i) => {
|
||||
return {
|
||||
...c,
|
||||
compilers: {
|
||||
zksolc: [
|
||||
{
|
||||
compilerVersion: zkCompiledResult.contracts[0].compilerVersion,
|
||||
evmVersion: zkCompiledResult.contracts[0].evmVersion,
|
||||
metadataUri: zkMetadataURIs[i],
|
||||
bytecodeUri: zkBytecodeURIs[i],
|
||||
},
|
||||
],
|
||||
solc: [
|
||||
{
|
||||
compilerVersion: compiledResult.contracts[0].compilerVersion,
|
||||
evmVersion: compiledResult.contracts[0].evmVersion,
|
||||
metadataUri: metadataURIs[i],
|
||||
bytecodeUri: bytecodeURIs[i],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -362,8 +468,8 @@ export function getUrl(hashes: string[], command: string) {
|
||||
if (hashes.length === 1) {
|
||||
url = new URL(
|
||||
THIRDWEB_URL +
|
||||
`/contracts/${command}/` +
|
||||
encodeURIComponent(hashes[0].replace("ipfs://", "")),
|
||||
`/contracts/${command}/` +
|
||||
encodeURIComponent(hashes[0].replace("ipfs://", "")),
|
||||
);
|
||||
} else {
|
||||
url = new URL(THIRDWEB_URL + "/contracts/" + command);
|
||||
|
||||
@@ -56,6 +56,8 @@ export class BrownieBuilder extends BaseBuilder {
|
||||
sources: [], // TODO
|
||||
fileName: "", // TODO
|
||||
name: contractName,
|
||||
compilerVersion: "",
|
||||
evmVersion: "",
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { FoundryBuilder } from "./foundry";
|
||||
import { HardhatBuilder } from "./hardhat";
|
||||
import { SolcBuilder } from "./solc";
|
||||
import { TruffleBuilder } from "./truffle";
|
||||
import { ZKHardhatBuilder } from "./zkHardhat";
|
||||
|
||||
export default async function build(
|
||||
path: string,
|
||||
@@ -19,6 +20,10 @@ export default async function build(
|
||||
builder = new HardhatBuilder();
|
||||
break;
|
||||
}
|
||||
case "zk-hardhat": {
|
||||
builder = new ZKHardhatBuilder();
|
||||
break;
|
||||
}
|
||||
case "foundry": {
|
||||
builder = new FoundryBuilder();
|
||||
break;
|
||||
|
||||
@@ -107,6 +107,9 @@ export class FoundryBuilder extends BaseBuilder {
|
||||
contractInfo.rawMetadata ||
|
||||
this.sanitizeParsedMetadata(parsedMetadata, contractInfo.abi);
|
||||
|
||||
const evmVersion = metadata.settings?.evmVersion || "";
|
||||
const compilerVersion = metadata.compiler?.version || "";
|
||||
|
||||
const sources = Object.keys(parsedMetadata.sources)
|
||||
.map((path) => {
|
||||
if (path.startsWith("/") && existsSync(path)) {
|
||||
@@ -146,6 +149,8 @@ export class FoundryBuilder extends BaseBuilder {
|
||||
bytecode,
|
||||
fileName,
|
||||
sources,
|
||||
compilerVersion,
|
||||
evmVersion,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,22 +36,7 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
logger.debug("successfully extracted hardhat config", actualHardhatConfig);
|
||||
|
||||
await execute("npx hardhat clean", options.projectPath);
|
||||
|
||||
let ignoreIpfsHash = false;
|
||||
if (options.zksync) {
|
||||
const zkNetwork = Object.entries(actualHardhatConfig.networks).find(
|
||||
(network) => {
|
||||
return (network[1] as any).zksync;
|
||||
},
|
||||
);
|
||||
ignoreIpfsHash = (zkNetwork?.[1] as any).zksync; // IPFS hash can't be recovered from ZKSync bytecode
|
||||
await execute(
|
||||
`npx hardhat compile --network ${zkNetwork?.[0]}`,
|
||||
options.projectPath,
|
||||
);
|
||||
} else {
|
||||
await execute(`npx hardhat compile`, options.projectPath);
|
||||
}
|
||||
await execute(`npx hardhat compile`, options.projectPath);
|
||||
|
||||
const solcConfigs = actualHardhatConfig.solidity.compilers;
|
||||
if (solcConfigs) {
|
||||
@@ -127,7 +112,7 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
}
|
||||
|
||||
let bytecode = info.evm.bytecode.object;
|
||||
let deployedBytecode = info.evm.deployedBytecode?.object || bytecode;
|
||||
let deployedBytecode = info.evm.deployedBytecode.object;
|
||||
|
||||
// link external libraries if any
|
||||
bytecode = linkLibrary(bytecode, libraries);
|
||||
@@ -135,9 +120,10 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
|
||||
const { metadata, abi } = info;
|
||||
|
||||
const meta = metadata.solc_metadata
|
||||
? JSON.parse(metadata.solc_metadata)
|
||||
: JSON.parse(metadata);
|
||||
const meta = JSON.parse(metadata);
|
||||
|
||||
const evmVersion = meta.settings?.evmVersion || "";
|
||||
const compilerVersion = meta.compiler?.version || "";
|
||||
const sources = Object.keys(meta.sources)
|
||||
.map((path) => {
|
||||
const directPath = join(options.projectPath, path);
|
||||
@@ -165,20 +151,15 @@ export class HardhatBuilder extends BaseBuilder {
|
||||
);
|
||||
const fileName = fileNames.length > 0 ? fileNames[0] : "";
|
||||
|
||||
if (
|
||||
this.shouldProcessContract(
|
||||
abi,
|
||||
deployedBytecode,
|
||||
contractName,
|
||||
ignoreIpfsHash,
|
||||
)
|
||||
) {
|
||||
if (this.shouldProcessContract(abi, deployedBytecode, contractName)) {
|
||||
contracts.push({
|
||||
metadata: JSON.stringify(meta),
|
||||
metadata,
|
||||
bytecode,
|
||||
name: contractName,
|
||||
fileName,
|
||||
sources,
|
||||
compilerVersion,
|
||||
evmVersion,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ export class SolcBuilder extends BaseBuilder {
|
||||
const parsedMetadata = JSON.parse(metadata);
|
||||
const abi = parsedMetadata.output.abi;
|
||||
|
||||
const evmVersion = parsedMetadata.settings?.evmVersion || "";
|
||||
const compilerVersion = parsedMetadata.compiler?.version || "";
|
||||
|
||||
const target = parsedMetadata.settings.compilationTarget;
|
||||
if (
|
||||
Object.keys(target).length === 0 ||
|
||||
@@ -156,6 +159,8 @@ export class SolcBuilder extends BaseBuilder {
|
||||
name: contractName,
|
||||
fileName,
|
||||
sources: _sources,
|
||||
compilerVersion,
|
||||
evmVersion,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,9 @@ export class TruffleBuilder extends BaseBuilder {
|
||||
}> {
|
||||
// get the current config first
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const truffleConfig = require(join(
|
||||
options.projectPath,
|
||||
"truffle-config.js",
|
||||
));
|
||||
const truffleConfig = require(
|
||||
join(options.projectPath, "truffle-config.js"),
|
||||
);
|
||||
|
||||
const buildPath = join(
|
||||
options.projectPath,
|
||||
@@ -42,6 +41,9 @@ export class TruffleBuilder extends BaseBuilder {
|
||||
const meta = JSON.parse(metadata);
|
||||
const abi = meta.output.abi;
|
||||
|
||||
const evmVersion = meta.settings?.evmVersion || "";
|
||||
const compilerVersion = meta.compiler?.version || "";
|
||||
|
||||
const target = meta.settings.compilationTarget;
|
||||
if (
|
||||
Object.keys(target).length === 0 ||
|
||||
@@ -81,6 +83,8 @@ export class TruffleBuilder extends BaseBuilder {
|
||||
name: contractName,
|
||||
fileName,
|
||||
sources,
|
||||
compilerVersion,
|
||||
evmVersion,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
import { findFiles } from "../../common/file-helper";
|
||||
import { execute } from "../helpers/exec";
|
||||
import { logger } from "../helpers/logger";
|
||||
import { ContractPayload } from "../interfaces/ContractPayload";
|
||||
import { BaseBuilder } from "./builder-base";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { HardhatConfig } from "hardhat/types";
|
||||
import { join, resolve } from "path";
|
||||
|
||||
export class ZKHardhatBuilder extends BaseBuilder {
|
||||
public async compile(options: any): Promise<{
|
||||
contracts: ContractPayload[];
|
||||
}> {
|
||||
//we get our very own extractor script from the dir that we're in during execution
|
||||
// this is `./dist/cli` (for all purposes of the CLI)
|
||||
// then we look up the hardhat config extractor file path from there
|
||||
const configExtractorScriptPath = resolve(
|
||||
__dirname,
|
||||
"../helpers/hardhat-config-extractor.js",
|
||||
);
|
||||
|
||||
//the hardhat extractor **logs out** the runtime config of hardhat, we take that stdout and parse it
|
||||
const stringifiedConfig = (
|
||||
await execute(
|
||||
`npx hardhat run "${configExtractorScriptPath}" --no-compile`,
|
||||
options.projectPath,
|
||||
)
|
||||
).stdout;
|
||||
//voila the hardhat config
|
||||
|
||||
const actualHardhatConfig = JSON.parse(
|
||||
stringifiedConfig.split("__tw__")[1],
|
||||
) as HardhatConfig;
|
||||
|
||||
logger.debug("successfully extracted hardhat config", actualHardhatConfig);
|
||||
|
||||
await execute("npx hardhat clean", options.projectPath);
|
||||
|
||||
let ignoreIpfsHash = false;
|
||||
|
||||
const zkNetwork = Object.entries(actualHardhatConfig.networks).find(
|
||||
(network) => {
|
||||
return (network[1] as any).zksync;
|
||||
},
|
||||
);
|
||||
|
||||
if (!(zkNetwork?.[1] as any).zksync) {
|
||||
logger.warn("ZKSync settings not found. Aborting.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
ignoreIpfsHash = (zkNetwork?.[1] as any).zksync; // IPFS hash can't be recovered from ZKSync bytecode
|
||||
await execute(
|
||||
`npx hardhat compile --network ${zkNetwork?.[0]}`,
|
||||
options.projectPath,
|
||||
);
|
||||
|
||||
const artifactsPath = actualHardhatConfig.paths.artifacts;
|
||||
const sourcesDir = actualHardhatConfig.paths.sources.replace(
|
||||
options.projectPath,
|
||||
"",
|
||||
);
|
||||
const contractsPath = join(artifactsPath, sourcesDir);
|
||||
|
||||
const contracts: ContractPayload[] = [];
|
||||
const files: string[] = [];
|
||||
findFiles(contractsPath, /^.*(?<!dbg)\.json$/, files);
|
||||
|
||||
const buildOutputPath = join(artifactsPath, "build-info");
|
||||
const buildFiles: string[] = [];
|
||||
findFiles(buildOutputPath, /^.*(?<!dbg)\.json$/, buildFiles);
|
||||
|
||||
for (const buildFile of buildFiles) {
|
||||
const buildJsonFile = readFileSync(buildFile, "utf-8");
|
||||
const buildJson = JSON.parse(buildJsonFile);
|
||||
|
||||
const contractBuildOutputs = buildJson.output.contracts;
|
||||
|
||||
for (const [contractPath, contractInfos] of Object.entries(
|
||||
contractBuildOutputs,
|
||||
)) {
|
||||
if (contractPath.includes("@")) {
|
||||
// skip library contracts
|
||||
logger.debug("Skipping", contractPath, "(not a source target)");
|
||||
continue;
|
||||
}
|
||||
for (const [contractName, contractInfo] of Object.entries(
|
||||
contractInfos as any,
|
||||
)) {
|
||||
const info = contractInfo as any;
|
||||
|
||||
if (
|
||||
!info.evm ||
|
||||
!info.evm.bytecode ||
|
||||
!info.evm.bytecode.object ||
|
||||
!info.metadata ||
|
||||
!info.abi
|
||||
) {
|
||||
logger.debug("Skipping", contractPath, "(no bytecode or metadata)");
|
||||
continue;
|
||||
}
|
||||
|
||||
const bytecode = info.evm.bytecode.object;
|
||||
const deployedBytecode =
|
||||
info.evm.deployedBytecode?.object || bytecode;
|
||||
const { metadata, abi } = info;
|
||||
|
||||
const meta = metadata.solc_metadata
|
||||
? JSON.parse(metadata.solc_metadata)
|
||||
: JSON.parse(metadata);
|
||||
|
||||
// Find and add zk_version to solc_metadata settings - needed for verification
|
||||
// TODO: it's a workaround. remove it (e.g. when ipfs hash issue is resolved)
|
||||
const zkVersion = metadata.zk_version;
|
||||
meta.settings["zkVersion"] = zkVersion;
|
||||
|
||||
const evmVersion = meta.settings?.evmVersion || "";
|
||||
const compilerVersion = zkVersion || "";
|
||||
const sources = Object.keys(meta.sources)
|
||||
.map((path) => {
|
||||
const directPath = join(options.projectPath, path);
|
||||
if (existsSync(directPath)) {
|
||||
return directPath;
|
||||
}
|
||||
const sourcePath = join(options.projectPath, sourcesDir, path);
|
||||
if (existsSync(sourcePath)) {
|
||||
return sourcePath;
|
||||
}
|
||||
const nodeModulesPath = join(
|
||||
options.projectPath,
|
||||
"node_modules",
|
||||
path,
|
||||
);
|
||||
if (existsSync(nodeModulesPath)) {
|
||||
return nodeModulesPath;
|
||||
}
|
||||
return undefined;
|
||||
})
|
||||
.filter((path) => path !== undefined) as string[];
|
||||
|
||||
const fileNames = Object.keys(
|
||||
meta?.settings?.compilationTarget || {},
|
||||
);
|
||||
const fileName = fileNames.length > 0 ? fileNames[0] : "";
|
||||
|
||||
if (
|
||||
this.shouldProcessContract(
|
||||
abi,
|
||||
deployedBytecode,
|
||||
contractName,
|
||||
ignoreIpfsHash,
|
||||
)
|
||||
) {
|
||||
contracts.push({
|
||||
metadata: JSON.stringify(meta),
|
||||
bytecode,
|
||||
name: contractName,
|
||||
fileName,
|
||||
sources,
|
||||
compilerVersion,
|
||||
evmVersion,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
contracts,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,17 @@ export default async function detect(
|
||||
.filter((detector) => detector.matches(path))
|
||||
.map((detector) => detector.projectType);
|
||||
|
||||
if (options.zksync) {
|
||||
const hardhatProject = possibleProjectTypes.filter(
|
||||
(projectType) => projectType === "hardhat",
|
||||
);
|
||||
|
||||
if (hardhatProject.length === 0) {
|
||||
logger.warn("ZKSync compilation requires hardhat plugins. Aborting.");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
//if there is no project returned at all then just return unknown}
|
||||
if (!possibleProjectTypes.length) {
|
||||
const canCompile = hasContracts(path);
|
||||
@@ -51,15 +62,28 @@ export default async function detect(
|
||||
}
|
||||
//if there is only one possible option just return it
|
||||
if (possibleProjectTypes.length === 1) {
|
||||
info(`Detected project type: ${possibleProjectTypes[0]}`);
|
||||
if (options.zksync) {
|
||||
info("ZKSync compilation will use hardhat");
|
||||
} else {
|
||||
info(`Detected project type: ${possibleProjectTypes[0]}`);
|
||||
}
|
||||
return possibleProjectTypes[0];
|
||||
}
|
||||
|
||||
info(
|
||||
`Detected multiple possible build tools: ${possibleProjectTypes
|
||||
.map((s) => `"${s}"`)
|
||||
.join(", ")}`,
|
||||
);
|
||||
if (options.zksync) {
|
||||
info("ZKSync compilation will use hardhat");
|
||||
info(
|
||||
`For regular solc compilation, these are the available options: ${possibleProjectTypes
|
||||
.map((s) => `"${s}"`)
|
||||
.join(", ")}`,
|
||||
);
|
||||
} else {
|
||||
info(
|
||||
`Detected multiple possible build tools: ${possibleProjectTypes
|
||||
.map((s) => `"${s}"`)
|
||||
.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
const question = "How would you like to compile your contracts";
|
||||
|
||||
|
||||
@@ -26,4 +26,8 @@ export interface ContractPayload {
|
||||
* The source file paths
|
||||
*/
|
||||
sources: string[];
|
||||
|
||||
compilerVersion: string;
|
||||
|
||||
evmVersion: string;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ export type ProjectType =
|
||||
| "brownie"
|
||||
| "foundry"
|
||||
| "hardhat"
|
||||
| "zk-hardhat"
|
||||
| "truffle"
|
||||
| "solc"
|
||||
| "vite"
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.4.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
- @thirdweb-dev/auth@4.1.52
|
||||
|
||||
## 4.4.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
- @thirdweb-dev/auth@4.1.51
|
||||
|
||||
## 4.4.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.4.26",
|
||||
"version": "4.4.28",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,9 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.7.25
|
||||
|
||||
## 0.7.24
|
||||
|
||||
## 0.7.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.7.23",
|
||||
"version": "0.7.25",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.7.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/react-core@4.4.28
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
|
||||
## 0.7.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
- @thirdweb-dev/react-core@4.4.27
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
|
||||
## 0.7.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.7.23",
|
||||
"version": "0.7.25",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,24 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.4.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/react-core@4.4.28
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
|
||||
## 4.4.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
- @thirdweb-dev/react-core@4.4.27
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
|
||||
## 4.4.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.4.26",
|
||||
"version": "4.4.28",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,18 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
|
||||
## 4.0.53
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2584](https://github.com/thirdweb-dev/js/pull/2584) [`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0) Thanks [@kumaryash90](https://github.com/kumaryash90)! - cli changes for zksync publish
|
||||
|
||||
## 4.0.52
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.52",
|
||||
"version": "4.0.54",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -487,6 +487,7 @@ export class ContractPublisher extends RPCConnectionHandler {
|
||||
bytecodeUri: predeployMetadata.bytecodeUri,
|
||||
name: predeployMetadata.name,
|
||||
analytics: predeployMetadata.analytics,
|
||||
compilers: predeployMetadata.compilers,
|
||||
publisher,
|
||||
});
|
||||
const fullMetadataUri = await this.storage.upload(fullMetadata);
|
||||
|
||||
@@ -112,6 +112,14 @@ export type Abi = z.output<typeof AbiSchema>;
|
||||
*/
|
||||
export type AbiInput = z.input<typeof AbiSchema>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const CompilerTypeInput = /* @__PURE__ */ (() =>
|
||||
z.union([z.literal("solc"), z.literal("zksolc")]))();
|
||||
|
||||
export type CompilerType = z.input<typeof CompilerTypeInput>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@@ -122,6 +130,21 @@ export const PreDeployMetadata = /* @__PURE__ */ (() =>
|
||||
metadataUri: z.string(),
|
||||
bytecodeUri: z.string(),
|
||||
analytics: z.any().optional(),
|
||||
compilers: z
|
||||
.record(
|
||||
CompilerTypeInput,
|
||||
// z.record(
|
||||
z.array(
|
||||
z.object({
|
||||
compilerVersion: z.string().optional(),
|
||||
evmVersion: z.string().optional(),
|
||||
metadataUri: z.string(),
|
||||
bytecodeUri: z.string(),
|
||||
}),
|
||||
),
|
||||
// ),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
.catchall(z.any()))();
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import { getChainProvider } from "../constants/urls";
|
||||
import { Abi } from "../schema/contracts/custom";
|
||||
import { twProxyArtifactZK } from "./temp-artifact/TWProxy";
|
||||
import { fetchSourceFilesFromMetadata } from "../common/fetchSourceFilesFromMetadata";
|
||||
import { fetchRawPredeployMetadata } from "../common/feature-detection/fetchRawPredeployMetadata";
|
||||
import { fetchContractMetadata } from "../common/fetchContractMetadata";
|
||||
import { checkVerificationStatus } from "../common/verification";
|
||||
import { ThirdwebSDK } from "../core/sdk";
|
||||
|
||||
const RequestStatus = {
|
||||
OK: "1",
|
||||
@@ -27,7 +27,8 @@ export async function zkVerify(
|
||||
explorerAPIUrl: string,
|
||||
explorerAPIKey: string,
|
||||
storage: ThirdwebStorage,
|
||||
contractUri?: string,
|
||||
metadataUri?: string,
|
||||
zkVersion?: string,
|
||||
encodedConstructorArgs?: string,
|
||||
) {
|
||||
try {
|
||||
@@ -43,18 +44,24 @@ export async function zkVerify(
|
||||
};
|
||||
compilerMetadata.metadata.sources = twProxyArtifactZK.sources;
|
||||
} else {
|
||||
invariant(contractUri, "No contract URI provided");
|
||||
const rawMeta = await fetchRawPredeployMetadata(contractUri, storage);
|
||||
const metadataUri = rawMeta.compilers?.zksolc?.metadataUri;
|
||||
if (!metadataUri || metadataUri.length === 0) {
|
||||
metadataUri = await fetchFromMultiChainRegistry(
|
||||
contractAddress,
|
||||
chainId,
|
||||
);
|
||||
}
|
||||
invariant(metadataUri && metadataUri.length > 0, "No contract URI found");
|
||||
|
||||
invariant(metadataUri, "ZkSolc metadata not found");
|
||||
const parsedMetadata = await fetchContractMetadata(metadataUri, storage);
|
||||
const zk_version =
|
||||
parsedMetadata.metadata.settings.zk_version || zkVersion;
|
||||
invariant(zk_version, "zk version not found");
|
||||
|
||||
compilerMetadata = {
|
||||
name: parsedMetadata.name,
|
||||
abi: parsedMetadata.abi,
|
||||
metadata: parsedMetadata.metadata,
|
||||
zk_version: rawMeta.zk_version,
|
||||
zk_version,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,13 +179,28 @@ async function zkFetchConstructorParams(
|
||||
utils.hexDataSlice(transaction.data, 4),
|
||||
);
|
||||
|
||||
return decoded[2];
|
||||
return decoded[2].startsWith("0x") ? decoded[2] : `0x${decoded[2]}`;
|
||||
} else {
|
||||
// TODO: decode for create2 deployments via factory
|
||||
return "";
|
||||
return "0x";
|
||||
}
|
||||
} else {
|
||||
// Could not retrieve constructor parameters, using empty parameters as fallback
|
||||
return "";
|
||||
return "0x";
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchFromMultiChainRegistry(
|
||||
address: string,
|
||||
chainId: number,
|
||||
): Promise<string | undefined> {
|
||||
try {
|
||||
// random wallet is fine here, we're doing gasless calls
|
||||
const sdk = new ThirdwebSDK("polygon");
|
||||
const uri = await sdk.multiChainRegistry.getContractMetadataURI(
|
||||
chainId,
|
||||
address,
|
||||
);
|
||||
return uri;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,20 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.4.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
|
||||
## 2.4.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
|
||||
## 2.4.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.4.28",
|
||||
"version": "2.4.30",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,23 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2595](https://github.com/thirdweb-dev/js/pull/2595) [`dd1141f`](https://github.com/thirdweb-dev/js/commit/dd1141f9af002817fb4fd4c002f5d77fde4ac950) Thanks [@MananTank](https://github.com/MananTank)! - Do not subscribe to `session_request_sent` event when using `walletConnect` because that is already handled when connecting with official Modal
|
||||
|
||||
- [#2591](https://github.com/thirdweb-dev/js/pull/2591) [`6d63920`](https://github.com/thirdweb-dev/js/commit/6d63920c0a25a395fed091f749e6e5438dce0b5d) Thanks [@MananTank](https://github.com/MananTank)! - Add `walletConnect`, fix WC connection issues
|
||||
|
||||
- [#2588](https://github.com/thirdweb-dev/js/pull/2588) [`eba8f1c`](https://github.com/thirdweb-dev/js/commit/eba8f1c19839ad89391d03271ef96b51d5f515ed) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix 721/1155 claimTo
|
||||
|
||||
## 5.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2585](https://github.com/thirdweb-dev/js/pull/2585) [`052892b`](https://github.com/thirdweb-dev/js/commit/052892b39677755b3167da7520d48446a5ce7c59) Thanks [@MananTank](https://github.com/MananTank)! - Fix wallet not opened on WC sessions request event on page reload on mobile
|
||||
|
||||
- [#2587](https://github.com/thirdweb-dev/js/pull/2587) [`6063f40`](https://github.com/thirdweb-dev/js/commit/6063f40f87b2a108840cb08e1e9025542931b7e0) Thanks [@jnsdls](https://github.com/jnsdls)! - [CLI] - fix execution on windows and when prettier is not installed
|
||||
|
||||
## 5.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
||||
|
||||
@@ -89,6 +89,21 @@ const walletInfos = allSupportedWallets.map((wallet) => {
|
||||
return { id: wallet.id, name: wallet.name };
|
||||
});
|
||||
|
||||
const customWalletInfos = [
|
||||
{
|
||||
id: "smart",
|
||||
name: "Smart Wallet",
|
||||
},
|
||||
{
|
||||
id: "embedded",
|
||||
name: "Embedded Wallet",
|
||||
},
|
||||
{
|
||||
id: "walletConnect",
|
||||
name: "WalletConnect",
|
||||
},
|
||||
];
|
||||
|
||||
// clean the __geneated__ folder within `src/wallets/` directory
|
||||
const OUT_PATH = join(__dirname, "../../src/wallets/__generated__");
|
||||
|
||||
@@ -141,7 +156,7 @@ export type MinimalWalletInfo = {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const ALL_MINIMAL_WALLET_INFOS = <const>${JSON.stringify(walletInfos, null, 2)} satisfies MinimalWalletInfo[];
|
||||
const ALL_MINIMAL_WALLET_INFOS = <const>${JSON.stringify([...walletInfos, ...customWalletInfos], null, 2)} satisfies MinimalWalletInfo[];
|
||||
|
||||
export default ALL_MINIMAL_WALLET_INFOS;
|
||||
`,
|
||||
@@ -222,6 +237,19 @@ const walletImports = allSupportedWallets
|
||||
)
|
||||
.join("\n");
|
||||
|
||||
const customWalletImports = ["smart", "embedded", "walletConnect"]
|
||||
.map(
|
||||
(walletId) =>
|
||||
`case "${walletId}": {
|
||||
return (
|
||||
image
|
||||
? import("../custom/${walletId}/image.js").then((img) => img.default)
|
||||
: import("../custom/${walletId}/index.js").then((w) => w.wallet)
|
||||
) as Promise<[TImage] extends [true] ? string : any>;
|
||||
}`,
|
||||
)
|
||||
.join("\n");
|
||||
|
||||
await writeFile(
|
||||
join(OUT_PATH, "getWalletInfo.ts"),
|
||||
await format(
|
||||
@@ -238,6 +266,7 @@ import type { WalletId } from "../wallet-types.js";
|
||||
*/
|
||||
export async function getWalletInfo<TImage extends boolean>(id: WalletId, image?: TImage): Promise<[TImage] extends [true] ? string : WalletInfo> {
|
||||
switch (id) {
|
||||
${customWalletImports}
|
||||
${walletImports}
|
||||
default: {
|
||||
throw new Error(\`Wallet with id \${id} not found\`);
|
||||
|
||||
@@ -23,21 +23,39 @@ async function main() {
|
||||
}
|
||||
|
||||
default: {
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
let bunAvailable = false;
|
||||
try {
|
||||
const res = execSync("bun --version", {
|
||||
stdio: "ignore",
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (typeof res === "string" && res.indexOf(".") > -1) {
|
||||
bunAvailable = true;
|
||||
// bun has no windows support yet anyways
|
||||
if (!isWindows) {
|
||||
try {
|
||||
const res = execSync("bun --version", {
|
||||
stdio: "ignore",
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (typeof res === "string" && res.indexOf(".") > -1) {
|
||||
bunAvailable = true;
|
||||
}
|
||||
} catch {
|
||||
bunAvailable = false;
|
||||
}
|
||||
} catch {
|
||||
bunAvailable = false;
|
||||
}
|
||||
const runner = bunAvailable ? "bunx" : "npx";
|
||||
let runner = "npx";
|
||||
|
||||
switch (true) {
|
||||
case bunAvailable:
|
||||
runner = "bun";
|
||||
break;
|
||||
case isWindows:
|
||||
runner = "npx.cmd";
|
||||
break;
|
||||
}
|
||||
|
||||
const args = command
|
||||
? ["--yes", "@thirdweb-dev/cli@latest", command, ...rest]
|
||||
: ["--yes", "@thirdweb-dev/cli@latest", ...rest];
|
||||
|
||||
// eslint-disable-next-line better-tree-shaking/no-top-level-side-effects
|
||||
spawn(runner, ["--yes", "@thirdweb-dev/cli@latest", command, ...rest], {
|
||||
spawn(runner, args, {
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@ import {
|
||||
type AbiFunction,
|
||||
formatAbiItem,
|
||||
} from "abitype";
|
||||
import { format } from "prettier";
|
||||
|
||||
import { prepareMethod } from "../../../utils/abi/prepare-method.js";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { packageDirectory } from "./utils.js";
|
||||
import { join } from "node:path";
|
||||
import { existsSync } from "node:fs";
|
||||
import type { Options } from "prettier";
|
||||
|
||||
const client = createThirdwebClient({ clientId: "test" });
|
||||
|
||||
@@ -150,7 +151,7 @@ async function generateFromAbi(abi: Abi | string[]) {
|
||||
);
|
||||
}
|
||||
|
||||
const prettified = await format(body, {
|
||||
const prettified = await prettifyCode(body, {
|
||||
parser: "babel-ts",
|
||||
});
|
||||
return prettified;
|
||||
@@ -330,3 +331,18 @@ function lowercaseFirstLetter(str: string) {
|
||||
function eventNameToPreparedEventName(name: string) {
|
||||
return `${lowercaseFirstLetter(name)}Event`;
|
||||
}
|
||||
|
||||
const printedPrettierWarning = false;
|
||||
|
||||
async function prettifyCode(code: string, options: Options) {
|
||||
try {
|
||||
const { format } = await import("prettier/standalone.js");
|
||||
return await format(code, options);
|
||||
} catch (e) {
|
||||
if (!printedPrettierWarning) {
|
||||
console.info("Prettier not found, skipping code formatting.");
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ export {
|
||||
createWallet,
|
||||
smartWallet,
|
||||
embeddedWallet,
|
||||
walletConnect,
|
||||
} from "../wallets/create-wallet.js";
|
||||
|
||||
export type { Wallet, Account } from "../wallets/interfaces/wallet.js";
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
export { smartWallet } from "../../wallets/create-wallet.js";
|
||||
|
||||
export type {
|
||||
SmartWalletConnectionOptions,
|
||||
SmartWalletOptions,
|
||||
UserOperation,
|
||||
PaymasterResult,
|
||||
} from "../../wallets/smart/types.js";
|
||||
|
||||
// TODO: add exports for smart wallet utils here
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../transaction/prepare-contract-call.js";
|
||||
import { getActiveClaimCondition } from "../read/getActiveClaimCondition.js";
|
||||
import { padHex } from "../../../../utils/encoding/hex.js";
|
||||
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
||||
|
||||
const CLAIM_ABI = {
|
||||
inputs: [
|
||||
@@ -129,7 +130,11 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
|
||||
contract: options.contract,
|
||||
tokenId: options.tokenId,
|
||||
});
|
||||
return cc.pricePerToken * BigInt(options.quantity);
|
||||
if (cc.currency === NATIVE_TOKEN_ADDRESS) {
|
||||
return cc.pricePerToken * BigInt(options.quantity);
|
||||
} else {
|
||||
return 0n;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../transaction/prepare-contract-call.js";
|
||||
import { getActiveClaimCondition } from "../read/getActiveClaimCondition.js";
|
||||
import { padHex } from "../../../../utils/encoding/hex.js";
|
||||
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
||||
/**
|
||||
* Represents the parameters for claiming an ERC721 token.
|
||||
*/
|
||||
@@ -117,7 +118,11 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
|
||||
const cc = await getActiveClaimCondition({
|
||||
contract: options.contract,
|
||||
});
|
||||
return cc.pricePerToken * BigInt(options.quantity);
|
||||
if (cc.currency === NATIVE_TOKEN_ADDRESS) {
|
||||
return cc.pricePerToken * BigInt(options.quantity);
|
||||
} else {
|
||||
return 0n;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ import type {
|
||||
Wallet,
|
||||
// WalletWithPersonalAccount,
|
||||
} from "../../../../wallets/interfaces/wallet.js";
|
||||
import { asyncLocalStorage } from "../../utils/asyncLocalStorage.js";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import type { AppMetadata } from "../../../../wallets/types.js";
|
||||
import { timeoutPromise } from "../../utils/timeoutPromise.js";
|
||||
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
|
||||
import { createWallet } from "../../../../wallets/create-wallet.js";
|
||||
import { getSavedConnectParamsFromStorage } from "../../../../wallets/storage/walletStorage.js";
|
||||
import { asyncLocalStorage } from "../../../../wallets/storage/asyncLocalStorage.js";
|
||||
|
||||
let autoConnectAttempted = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AsyncStorage } from "../../wallets/storage/AsyncStorage.js";
|
||||
import { asyncLocalStorage } from "./utils/asyncLocalStorage.js";
|
||||
import { asyncLocalStorage } from "../../wallets/storage/asyncLocalStorage.js";
|
||||
|
||||
let storage: AsyncStorage;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { isAndroid, isIOS } from "./isMobile.js";
|
||||
import { openWindow } from "./openWindow.js";
|
||||
|
||||
export type PlatformURIs = {
|
||||
android: string;
|
||||
ios: string;
|
||||
other: string;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function handelWCSessionRequest(uris: PlatformURIs) {
|
||||
if (isAndroid()) {
|
||||
openWindow(uris.android);
|
||||
} else if (isIOS()) {
|
||||
openWindow(uris.ios);
|
||||
} else {
|
||||
openWindow(uris.other);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,10 @@ import type { InjectedWalletLocale } from "../../../wallets/injected/locale/type
|
||||
import { getInjectedWalletLocale } from "../../../wallets/injected/locale/getInjectedWalletLocale.js";
|
||||
import { useWalletConnectionCtx } from "../../../../core/hooks/others/useWalletConnectionCtx.js";
|
||||
import { GetStartedScreen } from "../../../wallets/shared/GetStartedScreen.js";
|
||||
import { WalletConnectConnection } from "../../../wallets/shared/WalletConnectConnection.js";
|
||||
import {
|
||||
WalletConnectConnection,
|
||||
WalletConnectStandaloneConnection,
|
||||
} from "../../../wallets/shared/WalletConnectConnection.js";
|
||||
|
||||
const CoinbaseSDKWalletConnectUI = /* @__PURE__ */ lazy(
|
||||
() => import("../../../wallets/shared/CoinbaseSDKConnection.js"),
|
||||
@@ -28,6 +31,7 @@ export function AnyWalletConnectUI(props: {
|
||||
wallet: Wallet;
|
||||
done: () => void;
|
||||
onBack?: () => void;
|
||||
setModalVisibility: (value: boolean) => void;
|
||||
}) {
|
||||
const [screen, setScreen] = useState<"main" | "get-started">("main");
|
||||
const walletInfo = useWalletInfo(props.wallet.id);
|
||||
@@ -114,6 +118,20 @@ export function AnyWalletConnectUI(props: {
|
||||
);
|
||||
}
|
||||
|
||||
// wallet connect
|
||||
if (props.wallet.id === "walletConnect") {
|
||||
return (
|
||||
<WalletConnectStandaloneConnection
|
||||
locale={locale}
|
||||
onBack={props.onBack}
|
||||
done={props.done}
|
||||
wallet={props.wallet as Wallet<"walletConnect">}
|
||||
walletInfo={walletInfo.data}
|
||||
setModalVisibility={props.setModalVisibility}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.wallet.id === "embedded") {
|
||||
return (
|
||||
<Suspense fallback={<LoadingScreen />}>
|
||||
|
||||
@@ -430,10 +430,7 @@ const ConnectEmbedContent = (
|
||||
onClose={() => {
|
||||
setScreen(initialScreen);
|
||||
}}
|
||||
onHide={() => {
|
||||
// no op
|
||||
}}
|
||||
onShow={() => {
|
||||
setModalVisibility={() => {
|
||||
// no op
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -74,8 +74,10 @@ const ConnectModal = () => {
|
||||
}
|
||||
}, [isWalletModalOpen, setIsWalletModalOpen, screen]);
|
||||
|
||||
const onHide = useCallback(() => setHideModal(true), []);
|
||||
const onShow = useCallback(() => setHideModal(false), []);
|
||||
const setModalVisibility = useCallback(
|
||||
(value: boolean) => setHideModal(!value),
|
||||
[],
|
||||
);
|
||||
|
||||
// if wallet is suddenly disconnected when showing the sign in screen, close the modal and reset the screen
|
||||
useEffect(() => {
|
||||
@@ -122,8 +124,7 @@ const ConnectModal = () => {
|
||||
>
|
||||
<ConnectModalContent
|
||||
screenSetup={screenSetup}
|
||||
onHide={onHide}
|
||||
onShow={onShow}
|
||||
setModalVisibility={setModalVisibility}
|
||||
isOpen={isWalletModalOpen}
|
||||
onClose={closeModal}
|
||||
/>
|
||||
|
||||
@@ -22,16 +22,16 @@ const AllWalletsUI = /* @__PURE__ */ lazy(() => import("./AllWalletsUI.js"));
|
||||
*/
|
||||
export const ConnectModalContent = (props: {
|
||||
screenSetup: ScreenSetup;
|
||||
onHide: () => void;
|
||||
onShow: () => void;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
isOpen: boolean;
|
||||
setModalVisibility: (value: boolean) => void;
|
||||
}) => {
|
||||
const { onShow, onClose } = props;
|
||||
const { setModalVisibility, onClose } = props;
|
||||
const { screen, setScreen, initialScreen } = props.screenSetup;
|
||||
const { wallets, accountAbstraction } = useWalletConnectionCtx();
|
||||
// const disconnect = useDisconnect();
|
||||
const modalConfig = useContext(ModalConfigCtx);
|
||||
|
||||
// const setModalConfig = useContext(SetModalConfigCtx);
|
||||
// const activeWalletConnectionStatus = useActiveWalletConnectionStatus();
|
||||
// const activeWallet = useActiveWallet();
|
||||
@@ -59,7 +59,7 @@ export const ConnectModalContent = (props: {
|
||||
// : !!authConfig?.authUrl && !user?.address;
|
||||
|
||||
onModalUnmount(() => {
|
||||
onShow();
|
||||
setModalVisibility(true);
|
||||
});
|
||||
|
||||
// show sign in screen if required
|
||||
@@ -77,7 +77,7 @@ export const ConnectModalContent = (props: {
|
||||
// authConfig?.authUrl,
|
||||
// user?.address,
|
||||
setScreen,
|
||||
onShow,
|
||||
setModalVisibility,
|
||||
onClose,
|
||||
onConnect,
|
||||
connect,
|
||||
@@ -138,6 +138,7 @@ export const ConnectModalContent = (props: {
|
||||
}}
|
||||
personalWallet={wallet}
|
||||
onBack={goBack}
|
||||
setModalVisibility={props.setModalVisibility}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -150,6 +151,7 @@ export const ConnectModalContent = (props: {
|
||||
done={() => {
|
||||
handleConnected(wallet);
|
||||
}}
|
||||
setModalVisibility={props.setModalVisibility}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -90,16 +90,13 @@ function ConnectModalInlineContent(props: {
|
||||
<>
|
||||
<ConnectModalContent
|
||||
screenSetup={screenSetup}
|
||||
onHide={() => {
|
||||
// no op
|
||||
setModalVisibility={() => {
|
||||
// noop
|
||||
}}
|
||||
isOpen={true}
|
||||
onClose={() => {
|
||||
// no op
|
||||
}}
|
||||
onShow={() => {
|
||||
// no op
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* close icon */}
|
||||
|
||||
@@ -18,7 +18,7 @@ import { createWallet } from "../../../../../wallets/create-wallet.js";
|
||||
import { useWalletInfo } from "../../hooks/useWalletInfo.js";
|
||||
import type { WalletInfo } from "../../../../../wallets/wallet-info.js";
|
||||
import { saveConnectParamsToStorage } from "../../../../../wallets/storage/walletStorage.js";
|
||||
import { asyncLocalStorage } from "../../../../core/utils/asyncLocalStorage.js";
|
||||
import { asyncLocalStorage } from "../../../../../wallets/storage/asyncLocalStorage.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -28,6 +28,7 @@ export function SmartConnectUI(props: {
|
||||
done: (smartWallet: Wallet) => void;
|
||||
onBack?: () => void;
|
||||
accountAbstraction: SmartWalletOptions;
|
||||
setModalVisibility: (value: boolean) => void;
|
||||
}) {
|
||||
const personalWalletInfo = useWalletInfo(props.personalWallet.id);
|
||||
const [keyConnected, setKeyConnected] = useState(false);
|
||||
@@ -45,6 +46,7 @@ export function SmartConnectUI(props: {
|
||||
setKeyConnected(true);
|
||||
}}
|
||||
onBack={props.onBack}
|
||||
setModalVisibility={props.setModalVisibility}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { StyledDiv } from "../design-system/elements.js";
|
||||
import { Container } from "./basic.js";
|
||||
import { Text } from "./text.js";
|
||||
import type { IconFC } from "../ConnectWallet/icons/types.js";
|
||||
import { isMobile } from "../../../core/utils/isMobile.js";
|
||||
import { isMobile } from "../../../../utils/web/isMobile.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
||||
@@ -10,98 +10,7 @@ export function useWalletInfo(id: WalletId) {
|
||||
return useQuery<WalletInfo>({
|
||||
queryKey: ["wallet-info", id],
|
||||
queryFn: () => {
|
||||
switch (id) {
|
||||
// case "local": {
|
||||
// return {
|
||||
// id: "local",
|
||||
// name: "Local Wallet",
|
||||
// homepage: "https://thirdweb.com",
|
||||
// app: {
|
||||
// browser: null,
|
||||
// ios: null,
|
||||
// android: null,
|
||||
// mac: null,
|
||||
// windows: null,
|
||||
// linux: null,
|
||||
// chrome: null,
|
||||
// firefox: null,
|
||||
// safari: null,
|
||||
// edge: null,
|
||||
// opera: null,
|
||||
// },
|
||||
// rdns: null,
|
||||
// mobile: {
|
||||
// native: null,
|
||||
// universal: null,
|
||||
// },
|
||||
// desktop: {
|
||||
// native: null,
|
||||
// universal: null,
|
||||
// },
|
||||
// } as WalletInfo;
|
||||
// }
|
||||
case "embedded": {
|
||||
return {
|
||||
id: "embedded",
|
||||
name: "Social Login",
|
||||
homepage: "https://thirdweb.com",
|
||||
app: {
|
||||
browser: null,
|
||||
ios: null,
|
||||
android: null,
|
||||
mac: null,
|
||||
windows: null,
|
||||
linux: null,
|
||||
chrome: null,
|
||||
firefox: null,
|
||||
safari: null,
|
||||
edge: null,
|
||||
opera: null,
|
||||
},
|
||||
rdns: null,
|
||||
mobile: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
desktop: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
} as WalletInfo;
|
||||
}
|
||||
case "smart": {
|
||||
return {
|
||||
id: "smart",
|
||||
name: "SmartWallet",
|
||||
homepage: "https://thirdweb.com",
|
||||
app: {
|
||||
browser: null,
|
||||
ios: null,
|
||||
android: null,
|
||||
mac: null,
|
||||
windows: null,
|
||||
linux: null,
|
||||
chrome: null,
|
||||
firefox: null,
|
||||
safari: null,
|
||||
edge: null,
|
||||
opera: null,
|
||||
},
|
||||
rdns: null,
|
||||
mobile: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
desktop: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
} as WalletInfo;
|
||||
}
|
||||
default: {
|
||||
return getWalletInfo(id, false);
|
||||
}
|
||||
}
|
||||
return getWalletInfo(id, false);
|
||||
},
|
||||
retry: false,
|
||||
});
|
||||
@@ -114,20 +23,7 @@ export function useWalletImage(id: WalletId) {
|
||||
return useQuery({
|
||||
queryKey: ["wallet-image", id],
|
||||
queryFn: () => {
|
||||
switch (id) {
|
||||
// case "local": {
|
||||
// return "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiByeD0iMTIiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8xXzY0KSIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMV82NCkiPgo8cGF0aCBkPSJNNTguNzUgMTkuMTY2N0gyMS4yNUMxOC45NTgzIDE5LjE2NjcgMTcuMDgzMyAyMS4wNDE3IDE3LjA4MzMgMjMuMzMzNFY0OC4zMzM0QzE3LjA4MzMgNTAuNjI1IDE4Ljk1ODMgNTIuNSAyMS4yNSA1Mi41SDM1LjgzMzNMMzEuNjY2NyA1OC43NVY2MC44MzM0SDQ4LjMzMzNWNTguNzVMNDQuMTY2NyA1Mi41SDU4Ljc1QzYx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wLWNvbG9yPSIjN0MyMEY0Ii8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xXzkxIiB4MT0iNDAiIHkxPSIxOCIgeDI9IjQwIiB5Mj0iNjIuNDQ0NSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSJ3aGl0ZSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNFMUQ4RkIiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K";
|
||||
}
|
||||
default: {
|
||||
return getWalletInfo(id, true);
|
||||
}
|
||||
}
|
||||
return getWalletInfo(id, true);
|
||||
},
|
||||
retry: false,
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ export const ConnectingScreen: React.FC<{
|
||||
onBack?: () => void;
|
||||
walletId: WalletId;
|
||||
walletName: string;
|
||||
onGetStarted: () => void;
|
||||
onGetStarted?: () => void;
|
||||
errorConnecting: boolean;
|
||||
onRetry: () => void;
|
||||
locale: {
|
||||
@@ -92,14 +92,17 @@ export const ConnectingScreen: React.FC<{
|
||||
</Container>
|
||||
</Container>
|
||||
|
||||
<Spacer y="xl" />
|
||||
<Line />
|
||||
|
||||
<Container flex="row" center="x" p="lg">
|
||||
<Button variant="link" onClick={props.onGetStarted}>
|
||||
{locale.getStartedLink}
|
||||
</Button>
|
||||
</Container>
|
||||
{props.onGetStarted && (
|
||||
<>
|
||||
<Spacer y="xl" />
|
||||
<Line />
|
||||
<Container flex="row" center="x" p="lg">
|
||||
<Button variant="link" onClick={props.onGetStarted}>
|
||||
{locale.getStartedLink}
|
||||
</Button>
|
||||
</Container>
|
||||
</>
|
||||
)}
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { isMobile } from "../../../core/utils/isMobile.js";
|
||||
import { QRCode } from "../../ui/components/QRCode.js";
|
||||
import { Spacer } from "../../ui/components/Spacer.js";
|
||||
import { Container, ModalHeader } from "../../ui/components/basic.js";
|
||||
@@ -10,12 +9,13 @@ import { AppleIcon } from "../../ui/ConnectWallet/icons/AppleIcon.js";
|
||||
import { ChromeIcon } from "../../ui/ConnectWallet/icons/ChromeIcon.js";
|
||||
import { PlayStoreIcon } from "../../ui/ConnectWallet/icons/PlayStoreIcon.js";
|
||||
import { Text } from "../../ui/components/text.js";
|
||||
import { openWindow } from "../../../core/utils/openWindow.js";
|
||||
import type { InjectedWalletLocale } from "../injected/locale/types.js";
|
||||
import type { WalletInfo } from "../../../../wallets/wallet-info.js";
|
||||
import { WalletImage } from "../../ui/components/WalletImage.js";
|
||||
import type { WalletId } from "../../../../wallets/wallet-types.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import { isMobile } from "../../../../utils/web/isMobile.js";
|
||||
import { openWindow } from "../../../../utils/web/openWindow.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
||||
@@ -18,7 +18,7 @@ import { WalletImage } from "../../ui/components/WalletImage.js";
|
||||
*/
|
||||
export const ScanScreen: React.FC<{
|
||||
onBack?: () => void;
|
||||
onGetStarted: () => void;
|
||||
onGetStarted?: () => void;
|
||||
qrCodeUri?: string;
|
||||
walletName: string;
|
||||
walletId: WalletId;
|
||||
@@ -62,22 +62,24 @@ export const ScanScreen: React.FC<{
|
||||
|
||||
<Spacer y="lg" />
|
||||
|
||||
<ScreenBottomContainer
|
||||
style={{
|
||||
border: modalConfig.modalSize === "compact" ? undefined : "none",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="link"
|
||||
onClick={props.onGetStarted}
|
||||
{props.onGetStarted && (
|
||||
<ScreenBottomContainer
|
||||
style={{
|
||||
fontSize: fontSize.sm,
|
||||
textAlign: "center",
|
||||
border: modalConfig.modalSize === "compact" ? undefined : "none",
|
||||
}}
|
||||
>
|
||||
{props.getStartedLink}
|
||||
</Button>
|
||||
</ScreenBottomContainer>
|
||||
<Button
|
||||
variant="link"
|
||||
onClick={props.onGetStarted}
|
||||
style={{
|
||||
fontSize: fontSize.sm,
|
||||
textAlign: "center",
|
||||
}}
|
||||
>
|
||||
{props.getStartedLink}
|
||||
</Button>
|
||||
</ScreenBottomContainer>
|
||||
)}
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { ScanScreen } from "./ScanScreen.js";
|
||||
import { useState, useRef, useEffect, useCallback } from "react";
|
||||
import { isAndroid, isIOS, isMobile } from "../../../core/utils/isMobile.js";
|
||||
import { handelWCSessionRequest } from "../../../core/utils/handleWCSessionRequest.js";
|
||||
import { ConnectingScreen } from "./ConnectingScreen.js";
|
||||
import { openWindow } from "../../../core/utils/openWindow.js";
|
||||
import { useWalletConnectionCtx } from "../../../core/hooks/others/useWalletConnectionCtx.js";
|
||||
import type { InjectedWalletLocale } from "../injected/locale/types.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import type { WalletInfo } from "../../../../wallets/wallet-info.js";
|
||||
import type { WCSupportedWalletIds } from "../../../../wallets/__generated__/wallet-ids.js";
|
||||
import { isMobile, isAndroid, isIOS } from "../../../../utils/web/isMobile.js";
|
||||
import { openWindow } from "../../../../utils/web/openWindow.js";
|
||||
import { wait } from "../../../../utils/promise/wait.js";
|
||||
|
||||
/**
|
||||
* QR Scan UI for connecting a specific wallet on desktop.
|
||||
@@ -31,16 +31,6 @@ export const WalletConnectConnection: React.FC<{
|
||||
const connect = useCallback(() => {
|
||||
setErrorConnecting(false);
|
||||
|
||||
const platformUris = {
|
||||
ios: walletInfo.mobile.native || "",
|
||||
android: walletInfo.mobile.universal || "",
|
||||
other: walletInfo.mobile.universal || "",
|
||||
};
|
||||
|
||||
const onSessionRequestSent = isMobile()
|
||||
? () => handelWCSessionRequest(platformUris)
|
||||
: undefined;
|
||||
|
||||
wallet
|
||||
.connect({
|
||||
chain,
|
||||
@@ -49,6 +39,12 @@ export const WalletConnectConnection: React.FC<{
|
||||
projectId: walletConnect?.projectId,
|
||||
showQrModal: false,
|
||||
onDisplayUri(uri) {
|
||||
const platformUris = {
|
||||
ios: walletInfo.mobile.native || "",
|
||||
android: walletInfo.mobile.universal || "",
|
||||
other: walletInfo.mobile.universal || "",
|
||||
};
|
||||
|
||||
setQrCodeUri(uri);
|
||||
if (isMobile()) {
|
||||
if (isAndroid()) {
|
||||
@@ -66,7 +62,6 @@ export const WalletConnectConnection: React.FC<{
|
||||
}
|
||||
}
|
||||
},
|
||||
onSessionRequestSent,
|
||||
optionalChains: chains,
|
||||
},
|
||||
})
|
||||
@@ -129,3 +124,148 @@ export const WalletConnectConnection: React.FC<{
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* QR Scan UI for connecting a specific wallet on desktop.
|
||||
* shows a "Connecting" screen and opens the app on mobile.
|
||||
* @internal
|
||||
*/
|
||||
export const WalletConnectStandaloneConnection: React.FC<{
|
||||
onBack?: () => void;
|
||||
locale: InjectedWalletLocale;
|
||||
wallet: Wallet<"walletConnect">;
|
||||
walletInfo: WalletInfo;
|
||||
done: () => void;
|
||||
setModalVisibility: (value: boolean) => void;
|
||||
}> = (props) => {
|
||||
const { onBack, wallet, walletInfo, locale, done, setModalVisibility } =
|
||||
props;
|
||||
const [qrCodeUri, setQrCodeUri] = useState<string | undefined>();
|
||||
const [errorConnecting, setErrorConnecting] = useState(false);
|
||||
const { chain, chains, client, walletConnect } = useWalletConnectionCtx();
|
||||
|
||||
const connect = useCallback(() => {
|
||||
setErrorConnecting(false);
|
||||
|
||||
if (isMobile()) {
|
||||
let wcModalClosed = false;
|
||||
|
||||
// show spinner while the wallet connect modal loads in the background
|
||||
wait(2000).then(() => {
|
||||
// don't hide the modal if wc closed already
|
||||
if (!wcModalClosed) {
|
||||
setModalVisibility(false);
|
||||
}
|
||||
});
|
||||
|
||||
wallet
|
||||
.connect({
|
||||
chain,
|
||||
client: client,
|
||||
projectId: walletConnect?.projectId,
|
||||
showQrModal: true,
|
||||
optionalChains: chains,
|
||||
})
|
||||
.then(() => {
|
||||
wcModalClosed = true;
|
||||
setModalVisibility(true);
|
||||
done();
|
||||
})
|
||||
.catch((e) => {
|
||||
wcModalClosed = true;
|
||||
setModalVisibility(true);
|
||||
setErrorConnecting(true);
|
||||
console.error(e);
|
||||
});
|
||||
} else {
|
||||
wallet
|
||||
.connect({
|
||||
chain,
|
||||
client: client,
|
||||
projectId: walletConnect?.projectId,
|
||||
showQrModal: false,
|
||||
onDisplayUri(uri) {
|
||||
const platformUris = {
|
||||
ios: walletInfo.mobile.native || "",
|
||||
android: walletInfo.mobile.universal || "",
|
||||
other: walletInfo.mobile.universal || "",
|
||||
};
|
||||
|
||||
setQrCodeUri(uri);
|
||||
if (isMobile()) {
|
||||
if (isAndroid()) {
|
||||
openWindow(
|
||||
`${platformUris.android}wc?uri=${encodeURIComponent(uri)}`,
|
||||
);
|
||||
} else if (isIOS()) {
|
||||
openWindow(
|
||||
`${platformUris.ios}wc?uri=${encodeURIComponent(uri)}`,
|
||||
);
|
||||
} else {
|
||||
openWindow(
|
||||
`${platformUris.other}wc?uri=${encodeURIComponent(uri)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
optionalChains: chains,
|
||||
})
|
||||
.then(() => {
|
||||
done();
|
||||
})
|
||||
.catch((e) => {
|
||||
setErrorConnecting(true);
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
}, [
|
||||
walletConnect,
|
||||
walletInfo.mobile.native,
|
||||
walletInfo.mobile.universal,
|
||||
wallet,
|
||||
chain,
|
||||
client,
|
||||
chains,
|
||||
done,
|
||||
setModalVisibility,
|
||||
]);
|
||||
|
||||
const scanStarted = useRef(false);
|
||||
useEffect(() => {
|
||||
if (scanStarted.current) {
|
||||
return;
|
||||
}
|
||||
scanStarted.current = true;
|
||||
connect();
|
||||
}, [connect]);
|
||||
|
||||
if (isMobile()) {
|
||||
return (
|
||||
<ConnectingScreen
|
||||
locale={{
|
||||
getStartedLink: locale.getStartedLink,
|
||||
instruction: locale.connectionScreen.instruction,
|
||||
tryAgain: locale.connectionScreen.retry,
|
||||
inProgress: locale.connectionScreen.inProgress,
|
||||
failed: locale.connectionScreen.failed,
|
||||
}}
|
||||
onBack={onBack}
|
||||
walletName={walletInfo.name}
|
||||
walletId={wallet.id}
|
||||
errorConnecting={errorConnecting}
|
||||
onRetry={connect}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ScanScreen
|
||||
qrScanInstruction={locale.scanScreen.instruction}
|
||||
onBack={onBack}
|
||||
qrCodeUri={qrCodeUri}
|
||||
walletName={walletInfo.name}
|
||||
walletId={wallet.id}
|
||||
getStartedLink={locale.getStartedLink}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { detectOS } from "../../../utils/detect-platform.js";
|
||||
import { detectOS } from "../detect-platform.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -14,6 +14,29 @@ export async function getWalletInfo<TImage extends boolean>(
|
||||
image?: TImage,
|
||||
): Promise<[TImage] extends [true] ? string : WalletInfo> {
|
||||
switch (id) {
|
||||
case "smart": {
|
||||
return (
|
||||
image
|
||||
? import("../custom/smart/image.js").then((img) => img.default)
|
||||
: import("../custom/smart/index.js").then((w) => w.wallet)
|
||||
) as Promise<[TImage] extends [true] ? string : any>;
|
||||
}
|
||||
case "embedded": {
|
||||
return (
|
||||
image
|
||||
? import("../custom/embedded/image.js").then((img) => img.default)
|
||||
: import("../custom/embedded/index.js").then((w) => w.wallet)
|
||||
) as Promise<[TImage] extends [true] ? string : any>;
|
||||
}
|
||||
case "walletConnect": {
|
||||
return (
|
||||
image
|
||||
? import("../custom/walletConnect/image.js").then(
|
||||
(img) => img.default,
|
||||
)
|
||||
: import("../custom/walletConnect/index.js").then((w) => w.wallet)
|
||||
) as Promise<[TImage] extends [true] ? string : any>;
|
||||
}
|
||||
case "io.metamask": {
|
||||
return (
|
||||
image
|
||||
|
||||
@@ -1313,6 +1313,18 @@ const ALL_MINIMAL_WALLET_INFOS = (<const>[
|
||||
id: "app.backpack",
|
||||
name: "Backpack",
|
||||
},
|
||||
{
|
||||
id: "smart",
|
||||
name: "Smart Wallet",
|
||||
},
|
||||
{
|
||||
id: "embedded",
|
||||
name: "Embedded Wallet",
|
||||
},
|
||||
{
|
||||
id: "walletConnect",
|
||||
name: "WalletConnect",
|
||||
},
|
||||
]) satisfies MinimalWalletInfo[];
|
||||
|
||||
export default ALL_MINIMAL_WALLET_INFOS;
|
||||
|
||||
@@ -6,10 +6,14 @@ import type {
|
||||
import type { Account, Wallet } from "./interfaces/wallet.js";
|
||||
import type { Chain } from "../chains/types.js";
|
||||
import { injectedProvider } from "./injected/mipdStore.js";
|
||||
import type { InjectedSupportedWalletIds } from "./__generated__/wallet-ids.js";
|
||||
import type {
|
||||
InjectedSupportedWalletIds,
|
||||
WCSupportedWalletIds,
|
||||
} from "./__generated__/wallet-ids.js";
|
||||
|
||||
import { createWalletEmitter } from "./wallet-emitter.js";
|
||||
import { trackConnect } from "../analytics/track.js";
|
||||
import type { WCConnectOptions } from "./wallet-connect/types.js";
|
||||
|
||||
// TODO: figure out how to define the type without tuple args type and using function overloads
|
||||
|
||||
@@ -34,11 +38,11 @@ export function createWallet<const ID extends WalletId>(
|
||||
): Wallet<ID> {
|
||||
const [id, creationOptions] = args;
|
||||
|
||||
switch (true) {
|
||||
switch (id) {
|
||||
/**
|
||||
* SMART WALLET
|
||||
*/
|
||||
case id === "smart": {
|
||||
case "smart": {
|
||||
return smartWallet(
|
||||
creationOptions as CreateWalletArgs<"smart">[1],
|
||||
) as Wallet<ID>;
|
||||
@@ -46,7 +50,7 @@ export function createWallet<const ID extends WalletId>(
|
||||
/**
|
||||
* EMBEDDED WALLET
|
||||
*/
|
||||
case id === "embedded": {
|
||||
case "embedded": {
|
||||
return embeddedWallet(
|
||||
creationOptions as CreateWalletArgs<"embedded">[1],
|
||||
) as Wallet<ID>;
|
||||
@@ -56,12 +60,12 @@ export function createWallet<const ID extends WalletId>(
|
||||
* COINBASE WALLET VIA SDK
|
||||
* -> if no injected coinbase found, we'll use the coinbase SDK
|
||||
*/
|
||||
case id === "com.coinbase.wallet": {
|
||||
case "com.coinbase.wallet": {
|
||||
return coinbaseWalletSDK() as Wallet<ID>;
|
||||
}
|
||||
|
||||
/**
|
||||
* WALLET CONNECT AND INJECTED WALLETS
|
||||
* WALLET CONNECT AND INJECTED WALLETS + walletConnect standalone
|
||||
*/
|
||||
default: {
|
||||
const emitter = createWalletEmitter<ID>();
|
||||
@@ -87,6 +91,7 @@ export function createWallet<const ID extends WalletId>(
|
||||
account = undefined;
|
||||
chain = undefined;
|
||||
};
|
||||
|
||||
const wallet: Wallet<ID> = {
|
||||
id,
|
||||
subscribe: emitter.subscribe,
|
||||
@@ -95,7 +100,7 @@ export function createWallet<const ID extends WalletId>(
|
||||
getAccount: () => account,
|
||||
autoConnect: async (options) => {
|
||||
// injected wallet priority for autoConnect
|
||||
if (injectedProvider(id)) {
|
||||
if (id !== "walletConnect" && injectedProvider(id)) {
|
||||
const { autoConnectInjectedWallet } = await import(
|
||||
"./injected/index.js"
|
||||
);
|
||||
@@ -131,7 +136,11 @@ export function createWallet<const ID extends WalletId>(
|
||||
connectedChain,
|
||||
doDisconnect,
|
||||
doSwitchChain,
|
||||
] = await autoConnectWC(options, emitter);
|
||||
] = await autoConnectWC(
|
||||
options,
|
||||
emitter,
|
||||
wallet.id as WCSupportedWalletIds,
|
||||
);
|
||||
// set the states
|
||||
account = connectedAccount;
|
||||
chain = connectedChain;
|
||||
@@ -148,8 +157,7 @@ export function createWallet<const ID extends WalletId>(
|
||||
throw new Error("Failed to auto connect");
|
||||
},
|
||||
connect: async (options) => {
|
||||
// prefer walletconnect over injected for connect (more explicit)
|
||||
if (options && "walletConnect" in options) {
|
||||
async function wcConnect(wcOptions: WCConnectOptions) {
|
||||
const { connectWC } = await import("./wallet-connect/index.js");
|
||||
|
||||
const [
|
||||
@@ -157,20 +165,45 @@ export function createWallet<const ID extends WalletId>(
|
||||
connectedChain,
|
||||
doDisconnect,
|
||||
doSwitchChain,
|
||||
] = await connectWC(options, emitter);
|
||||
] = await connectWC(
|
||||
wcOptions,
|
||||
emitter,
|
||||
wallet.id as WCSupportedWalletIds | "walletConnect",
|
||||
);
|
||||
// set the states
|
||||
account = connectedAccount;
|
||||
chain = connectedChain;
|
||||
handleDisconnect = doDisconnect;
|
||||
handleDisconnect = () => {
|
||||
doDisconnect();
|
||||
account = undefined;
|
||||
chain = undefined;
|
||||
};
|
||||
handleSwitchChain = doSwitchChain;
|
||||
trackConnect({
|
||||
client: options.client,
|
||||
client: wcOptions.client,
|
||||
walletType: id,
|
||||
walletAddress: account.address,
|
||||
});
|
||||
// return account
|
||||
return account;
|
||||
}
|
||||
|
||||
if (id === "walletConnect") {
|
||||
const { client, chain: _chain, ...walletConnectOptions } = options;
|
||||
|
||||
return wcConnect({
|
||||
client,
|
||||
chain: _chain,
|
||||
walletConnect: {
|
||||
...walletConnectOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// prefer walletconnect over injected for connect (more explicit)
|
||||
if (options && "walletConnect" in options) {
|
||||
return wcConnect(options);
|
||||
}
|
||||
|
||||
if (injectedProvider(id)) {
|
||||
const { connectInjectedWallet } = await import(
|
||||
"./injected/index.js"
|
||||
@@ -189,7 +222,11 @@ export function createWallet<const ID extends WalletId>(
|
||||
// set the states
|
||||
account = connectedAccount;
|
||||
chain = connectedChain;
|
||||
handleDisconnect = doDisconnect;
|
||||
handleDisconnect = () => {
|
||||
doDisconnect();
|
||||
account = undefined;
|
||||
chain = undefined;
|
||||
};
|
||||
handleSwitchChain = doSwitchChain;
|
||||
trackConnect({
|
||||
client: options.client,
|
||||
@@ -201,7 +238,7 @@ export function createWallet<const ID extends WalletId>(
|
||||
}
|
||||
throw new Error("Failed to connect");
|
||||
},
|
||||
// these get overridden in connect and autoconnect
|
||||
// these get overridden in connect and autoConnect
|
||||
disconnect: async () => handleDisconnect(),
|
||||
switchChain: (c) => handleSwitchChain(c),
|
||||
};
|
||||
@@ -210,6 +247,25 @@ export function createWallet<const ID extends WalletId>(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that allows connecting to any wallet that supports the WalletConnect protocol.
|
||||
* @returns The created smart wallet.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { walletConnect } from "thirdweb/wallets";
|
||||
*
|
||||
* const wallet = walletConnect();
|
||||
*
|
||||
* const account = await wallet.connect({
|
||||
* client
|
||||
* });
|
||||
* ```
|
||||
* @wallet
|
||||
*/
|
||||
export function walletConnect() {
|
||||
return createWallet("walletConnect");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a smart wallet.
|
||||
* @param createOptions - The options for creating the wallet.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
const image =
|
||||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzM1ODlfODY0OSkiPgo8cmVjdCB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHJ4PSI4IiBmaWxsPSJ1cmwoI3BhaW50MF9saW5lYXJfMzU4OV84NjQ5KSIvPgo8cmVjdCB4PSItMSIgeT0iLTEiIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgcng9IjkuOCIgZmlsbD0idXJsKCNwYWludDFfbGluZWFyXzM1ODlfODY0OSkiLz4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAxXzM1ODlfODY0OSkiPgo8cGF0aCBkPSJNMjQgMTQuMjVDMTguNjE3MiAxNC4yNSAxNC4yNSAxOC42MTcyIDE0LjI1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zNTg5Xzg2NDkiPgo8cmVjdCB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIGZpbGw9IndoaXRlIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMSAxMSkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K";
|
||||
|
||||
export default image;
|
||||
@@ -0,0 +1,27 @@
|
||||
export const wallet = {
|
||||
id: "embedded",
|
||||
name: "Social Login",
|
||||
homepage: "https://thirdweb.com",
|
||||
app: {
|
||||
browser: null,
|
||||
ios: null,
|
||||
android: null,
|
||||
mac: null,
|
||||
windows: null,
|
||||
linux: null,
|
||||
chrome: null,
|
||||
firefox: null,
|
||||
safari: null,
|
||||
edge: null,
|
||||
opera: null,
|
||||
},
|
||||
rdns: null,
|
||||
mobile: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
desktop: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1,4 @@
|
||||
const image =
|
||||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiByeD0iMTIiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8xXzkxKSIvPgo8cGF0aCBkPSJNMzkuOTk2OSAxOEw0MC4yMzMzIDE4LjAxNTZMNDAuMzUxMyAxOC4wMzMzTDQwLjQ3MzYgMTguMDYyMkw0MC42OTU4IDE4LjEzNzhDNDAuODQ5NCAxOC4yMDA2IDQwLjk5NTQgMTguMjg0MiA0MS4xMzA1IDE4LjM4NjdMNDEuMzM4NyAxOC41Njg5TDQxLjg0OTMgMTkuMDUzM0M0NS44ODkxIDIyLjc3NjggNTAuOTk0NyAyNC43NzYyIDU2LjI0NTggMjQu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SJwYWludDBfbGluZWFyXzFfOTEiIHgxPSI0MCIgeTE9IjAiIHgyPSI0MCIgeTI9IjgwIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiM4MzU2QkQiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN0MyMEY0Ii8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xXzkxIiB4MT0iNDAiIHkxPSIxOCIgeDI9IjQwIiB5Mj0iNjIuNDQ0NSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSJ3aGl0ZSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNFMUQ4RkIiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K";
|
||||
|
||||
export default image;
|
||||
@@ -0,0 +1,27 @@
|
||||
export const wallet = {
|
||||
id: "smart",
|
||||
name: "SmartWallet",
|
||||
homepage: "https://thirdweb.com",
|
||||
app: {
|
||||
browser: null,
|
||||
ios: null,
|
||||
android: null,
|
||||
mac: null,
|
||||
windows: null,
|
||||
linux: null,
|
||||
chrome: null,
|
||||
firefox: null,
|
||||
safari: null,
|
||||
edge: null,
|
||||
opera: null,
|
||||
},
|
||||
rdns: null,
|
||||
mobile: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
desktop: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1,4 @@
|
||||
const image =
|
||||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2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MjkuNzExNSA1My43MjhMMTcuMjgzOCA0MS42NzJDMTYuOTA1NCA0MS4zMDkzIDE2LjkwNTQgNDAuNzE0NSAxNy4yODM4IDQwLjM1MThMMjAuMDM0MiAzNy42ODI0QzIwLjQxMjUgMzcuMzE5NyAyMS4wMjM3IDM3LjMxOTcgMjEuMzg3NSAzNy42ODI0TDMwLjE3NzIgNDYuMjQyQzMwLjI2NDUgNDYuMzI5IDMwLjQyNDUgNDYuMzI5IDMwLjUxMTkgNDYuMjQyTDM5LjMwMTUgMzcuNjgyNEMzOS42Nzk5IDM3LjMxOTcgNDAuMjkxIDM3LjMxOTcgNDAuNjU0OSAzNy42ODI0TDQ5LjQ0NDUgNDYuMjQyQzQ5LjUzMTggNDYuMzI5IDQ5LjY5MTkgNDYuMzI5IDQ5Ljc3OTIgNDYuMjQyTDU4LjU2ODggMzcuNjgyNEM1OC45NzYzIDM3LjMxOTcgNTkuNTg3NSAzNy4zMTk3IDU5Ljk2NTggMzcuNjgyNFoiIGZpbGw9IndoaXRlIi8+CjxkZWZzPgo8cmFkaWFsR3JhZGllbnQgaWQ9InBhaW50MF9yYWRpYWxfMV80NiIgY3g9IjAiIGN5PSIwIiByPSIxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgZ3JhZGllbnRUcmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDI0Nzk1NSA0MC4wMDEyKSBzY2FsZSg4MCkiPgo8c3RvcCBzdG9wLWNvbG9yPSIjNUQ5REY2Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAwNkZGRiIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=";
|
||||
|
||||
export default image;
|
||||
@@ -0,0 +1,27 @@
|
||||
export const wallet = {
|
||||
id: "walletConnect",
|
||||
name: "WalletConnect",
|
||||
homepage: "https://walletconnect.com",
|
||||
app: {
|
||||
browser: null,
|
||||
ios: null,
|
||||
android: null,
|
||||
mac: null,
|
||||
windows: null,
|
||||
linux: null,
|
||||
chrome: null,
|
||||
firefox: null,
|
||||
safari: null,
|
||||
edge: null,
|
||||
opera: null,
|
||||
},
|
||||
rdns: null,
|
||||
mobile: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
desktop: {
|
||||
native: null,
|
||||
universal: null,
|
||||
},
|
||||
} as const;
|
||||
@@ -4,6 +4,7 @@ import { effect } from "../../reactive/effect.js";
|
||||
import { createStore } from "../../reactive/store.js";
|
||||
import type { Account, Wallet } from "../interfaces/wallet.js";
|
||||
import type { AsyncStorage } from "../storage/AsyncStorage.js";
|
||||
import { deleteConnectParamsFromStorage } from "../storage/walletStorage.js";
|
||||
|
||||
type WalletIdToConnectedWalletMap = Map<string, Wallet>;
|
||||
export type ConnectionStatus = "connected" | "disconnected" | "connecting";
|
||||
@@ -60,6 +61,8 @@ export function createConnectionManager(storage: AsyncStorage) {
|
||||
|
||||
const onWalletDisconnect = (wallet: Wallet) => {
|
||||
const currentMap = walletIdToConnectedWalletMap.getValue();
|
||||
deleteConnectParamsFromStorage(storage, wallet.id);
|
||||
|
||||
const newMap = new Map(currentMap);
|
||||
newMap.delete(wallet.id);
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { AsyncStorage } from "../../../wallets/storage/AsyncStorage.js";
|
||||
import type { AsyncStorage } from "./AsyncStorage.js";
|
||||
|
||||
export const asyncLocalStorage: AsyncStorage = {
|
||||
async getItem(key: string) {
|
||||
@@ -25,25 +25,55 @@ import { getDefaultAppMetadata } from "../utils/defaultDappMetadata.js";
|
||||
import type { WCSupportedWalletIds } from "../__generated__/wallet-ids.js";
|
||||
import type { DisconnectFn, SwitchChainFn } from "../types.js";
|
||||
import type { WalletEmitter } from "../wallet-emitter.js";
|
||||
import { isAndroid, isIOS, isMobile } from "../../utils/web/isMobile.js";
|
||||
import { openWindow } from "../../utils/web/openWindow.js";
|
||||
import { getWalletInfo } from "../__generated__/getWalletInfo.js";
|
||||
import { asyncLocalStorage as _asyncLocalStorage } from "../storage/asyncLocalStorage.js";
|
||||
|
||||
import {
|
||||
getSavedConnectParamsFromStorage,
|
||||
saveConnectParamsToStorage,
|
||||
} from "../storage/walletStorage.js";
|
||||
|
||||
const asyncLocalStorage =
|
||||
typeof window !== "undefined" ? _asyncLocalStorage : undefined;
|
||||
|
||||
type WCProvider = InstanceType<typeof EthereumProvider>;
|
||||
|
||||
type SavedConnectParams = {
|
||||
optionalChains?: Chain[];
|
||||
chain: Chain;
|
||||
pairingTopic?: string;
|
||||
};
|
||||
|
||||
const defaultWCProjectId = "08c4b07e3ad25f1a27c14a4e8cecb6f0";
|
||||
|
||||
const NAMESPACE = "eip155";
|
||||
const ADD_ETH_CHAIN_METHOD = "wallet_addEthereumChain";
|
||||
|
||||
// const isNewChainsStale = true;
|
||||
const isNewChainsStale = true;
|
||||
const defaultShowQrModal = true;
|
||||
|
||||
const storageKeys = {
|
||||
requestedChains: "tw.wc.requestedChains",
|
||||
lastUsedChainId: "tw.wc.lastUsedChainId",
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export async function connectWC(
|
||||
options: WCConnectOptions,
|
||||
emitter: WalletEmitter<WCSupportedWalletIds>,
|
||||
walletId: WCSupportedWalletIds | "walletConnect",
|
||||
): Promise<ReturnType<typeof onConnect>> {
|
||||
const provider = await initProvider(options);
|
||||
const provider = await initProvider(options, walletId);
|
||||
|
||||
const _isChainsState = await isChainsStale(provider, [
|
||||
provider.chainId,
|
||||
...(options?.walletConnect?.optionalChains || []).map((c) => c.id),
|
||||
]);
|
||||
|
||||
const wcOptions = options.walletConnect;
|
||||
|
||||
const targetChain = options?.chain || ethereum;
|
||||
@@ -54,26 +84,16 @@ export async function connectWC(
|
||||
client: options.client,
|
||||
});
|
||||
|
||||
const { onDisplayUri, onSessionRequestSent } = wcOptions || {};
|
||||
const { onDisplayUri } = wcOptions || {};
|
||||
|
||||
if (onDisplayUri || onSessionRequestSent) {
|
||||
if (onDisplayUri) {
|
||||
if (onDisplayUri) {
|
||||
provider.events.addListener("display_uri", onDisplayUri);
|
||||
}
|
||||
|
||||
if (onSessionRequestSent) {
|
||||
provider.signer.client.on("session_request_sent", onSessionRequestSent);
|
||||
provider.events.addListener("disconnect", () => {
|
||||
provider.signer.client.off(
|
||||
"session_request_sent",
|
||||
onSessionRequestSent,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// If there no active session, or the chain is stale, force connect.
|
||||
if (!provider.session) {
|
||||
if (!provider.session || _isChainsState) {
|
||||
await provider.connect({
|
||||
pairingTopic: wcOptions?.pairingTopic,
|
||||
chains: [Number(targetChainId)],
|
||||
@@ -81,6 +101,8 @@ export async function connectWC(
|
||||
[targetChainId.toString()]: rpc,
|
||||
},
|
||||
});
|
||||
|
||||
setRequestedChainsIds([targetChainId]);
|
||||
}
|
||||
|
||||
// If session exists and chains are authorized, enable provider for required chain
|
||||
@@ -92,6 +114,18 @@ export async function connectWC(
|
||||
|
||||
const chain = defineChain(normalizeChainId(provider.chainId));
|
||||
|
||||
if (options) {
|
||||
const savedParams: SavedConnectParams = {
|
||||
optionalChains: options.walletConnect?.optionalChains,
|
||||
chain: chain,
|
||||
pairingTopic: options.walletConnect?.pairingTopic,
|
||||
};
|
||||
|
||||
if (asyncLocalStorage) {
|
||||
saveConnectParamsToStorage(asyncLocalStorage, walletId, savedParams);
|
||||
}
|
||||
}
|
||||
|
||||
if (wcOptions?.onDisplayUri) {
|
||||
provider.events.removeListener("display_uri", wcOptions.onDisplayUri);
|
||||
}
|
||||
@@ -106,21 +140,28 @@ export async function connectWC(
|
||||
export async function autoConnectWC(
|
||||
options: WCAutoConnectOptions,
|
||||
emitter: WalletEmitter<WCSupportedWalletIds>,
|
||||
walletId: WCSupportedWalletIds | "walletConnect",
|
||||
): Promise<ReturnType<typeof onConnect>> {
|
||||
const savedConnectParams: SavedConnectParams | null = asyncLocalStorage
|
||||
? await getSavedConnectParamsFromStorage(asyncLocalStorage, walletId)
|
||||
: null;
|
||||
|
||||
const provider = await initProvider(
|
||||
options.savedConnectParams
|
||||
savedConnectParams
|
||||
? {
|
||||
chain: options.savedConnectParams.chain,
|
||||
chain: savedConnectParams.chain,
|
||||
client: options.client,
|
||||
walletConnect: {
|
||||
pairingTopic: options.savedConnectParams.pairingTopic,
|
||||
optionalChains: options.savedConnectParams.optionalChains,
|
||||
pairingTopic: savedConnectParams.pairingTopic,
|
||||
optionalChains: savedConnectParams.optionalChains,
|
||||
},
|
||||
}
|
||||
: {
|
||||
client: options.client,
|
||||
walletConnect: {},
|
||||
},
|
||||
walletId,
|
||||
true, // is auto connect
|
||||
);
|
||||
|
||||
const address = provider.accounts[0];
|
||||
@@ -153,7 +194,12 @@ export async function autoConnectWC(
|
||||
|
||||
// Connection utils -----------------------------------------------------------------------------------------------
|
||||
|
||||
async function initProvider(options: WCConnectOptions) {
|
||||
async function initProvider(
|
||||
options: WCConnectOptions,
|
||||
walletId: WCSupportedWalletIds | "walletConnect",
|
||||
isAutoConnect = false,
|
||||
) {
|
||||
const walletInfo = await getWalletInfo(walletId);
|
||||
const wcOptions = options.walletConnect;
|
||||
const { EthereumProvider, OPTIONAL_EVENTS, OPTIONAL_METHODS } = await import(
|
||||
"@walletconnect/ethereum-provider"
|
||||
@@ -194,6 +240,73 @@ async function initProvider(options: WCConnectOptions) {
|
||||
|
||||
provider.events.setMaxListeners(Infinity);
|
||||
|
||||
// disconnect the provider if chains are stale when (if not auto connecting)
|
||||
if (!isAutoConnect) {
|
||||
const chains = [
|
||||
targetChain,
|
||||
...(options?.walletConnect?.optionalChains || []),
|
||||
];
|
||||
|
||||
const isStale = await isChainsStale(
|
||||
provider,
|
||||
chains.map((c) => c.id),
|
||||
);
|
||||
|
||||
if (isStale && provider.session) {
|
||||
await provider.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (walletId !== "walletConnect") {
|
||||
function handleSessionRequest() {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMobile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const preferUniversal =
|
||||
walletInfo.mobile.universal || walletInfo.mobile.native;
|
||||
const preferNative =
|
||||
walletInfo.mobile.native || walletInfo.mobile.universal;
|
||||
|
||||
if (isAndroid()) {
|
||||
if (preferUniversal) {
|
||||
openWindow(preferUniversal);
|
||||
}
|
||||
} else if (isIOS()) {
|
||||
if (preferNative) {
|
||||
openWindow(preferNative);
|
||||
}
|
||||
} else {
|
||||
if (preferUniversal) {
|
||||
openWindow(preferUniversal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider.signer.client.on("session_request_sent", handleSessionRequest);
|
||||
provider.events.addListener("disconnect", () => {
|
||||
provider.signer.client.off("session_request_sent", handleSessionRequest);
|
||||
});
|
||||
}
|
||||
|
||||
// try switching to correct chain
|
||||
if (options?.chain && provider.chainId !== options?.chain.id) {
|
||||
try {
|
||||
await switchChainWC(provider, options.chain);
|
||||
} catch (e) {
|
||||
console.error("Failed to Switch chain to target chain");
|
||||
console.error(e);
|
||||
// throw only if not auto connecting
|
||||
if (!isAutoConnect) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
@@ -265,6 +378,8 @@ function onConnect(
|
||||
}
|
||||
|
||||
function onDisconnect() {
|
||||
setRequestedChainsIds([]);
|
||||
asyncLocalStorage?.removeItem(storageKeys.lastUsedChainId);
|
||||
disconnect();
|
||||
emitter.emit("disconnect", undefined);
|
||||
}
|
||||
@@ -280,11 +395,14 @@ function onConnect(
|
||||
function onChainChanged(newChainId: string) {
|
||||
const newChain = defineChain(normalizeChainId(newChainId));
|
||||
emitter.emit("chainChanged", newChain);
|
||||
asyncLocalStorage?.setItem(storageKeys.lastUsedChainId, String(newChainId));
|
||||
}
|
||||
|
||||
provider.on("accountsChanged", onAccountsChanged);
|
||||
provider.on("chainChanged", onChainChanged);
|
||||
provider.on("disconnect", onDisconnect);
|
||||
provider.on("session_delete", onDisconnect);
|
||||
|
||||
return [
|
||||
account,
|
||||
chain,
|
||||
@@ -335,9 +453,9 @@ async function switchChainWC(provider: WCProvider, chain: Chain) {
|
||||
},
|
||||
],
|
||||
});
|
||||
// const requestedChains = await getRequestedChainsIds(wallet);
|
||||
// requestedChains.push(chainId);
|
||||
// setRequestedChainsIds(wallet, requestedChains);
|
||||
const requestedChains = await getRequestedChainsIds();
|
||||
requestedChains.push(chainId);
|
||||
setRequestedChainsIds(requestedChains);
|
||||
}
|
||||
await provider.request({
|
||||
method: "wallet_switchEthereumChain",
|
||||
@@ -353,3 +471,53 @@ async function switchChainWC(provider: WCProvider, chain: Chain) {
|
||||
throw new SwitchChainError(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if every chain requested were already requested earlier - then they are not stale
|
||||
* @param connectToChainId
|
||||
* @internal
|
||||
*/
|
||||
async function isChainsStale(provider: WCProvider, chains: number[]) {
|
||||
const namespaceMethods = getNamespaceMethods(provider);
|
||||
|
||||
// if chain adding method is available, then chains are not stale
|
||||
if (namespaceMethods.includes(ADD_ETH_CHAIN_METHOD)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if new chains are considered stale, then return true
|
||||
if (!isNewChainsStale) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const requestedChains = await getRequestedChainsIds();
|
||||
const namespaceChains = getNamespaceChainsIds(provider);
|
||||
|
||||
// if any of the requested chains are not in the namespace chains, then they are stale
|
||||
if (
|
||||
namespaceChains.length &&
|
||||
!namespaceChains.some((id) => chains.includes(id))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if chain was requested earlier, then they are not stale
|
||||
return !chains.every((id) => requestedChains.includes(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the requested chains to the storage.
|
||||
* @internal
|
||||
*/
|
||||
function setRequestedChainsIds(chains: number[]) {
|
||||
localStorage?.setItem(storageKeys.requestedChains, JSON.stringify(chains));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last requested chains from the storage.
|
||||
* @internal
|
||||
*/
|
||||
async function getRequestedChainsIds(): Promise<number[]> {
|
||||
const data = localStorage.getItem(storageKeys.requestedChains);
|
||||
return data ? JSON.parse(data) : [];
|
||||
}
|
||||
|
||||
@@ -131,11 +131,6 @@ export type WCConnectOptions = {
|
||||
* ```
|
||||
*/
|
||||
onDisplayUri?: (uri: string) => void;
|
||||
/**
|
||||
* Callback to be called to listen to the `session_request_sent` event emitted by WalletConnect's `EthereumProvider`.
|
||||
* This can be used to
|
||||
*/
|
||||
onSessionRequestSent?: () => void;
|
||||
|
||||
/**
|
||||
* Your project’s unique identifier that can be obtained at https://cloud.walletconnect.com/
|
||||
|
||||
@@ -20,11 +20,20 @@ import type { CoinbaseSDKWalletConnectionOptions } from "./coinbase/coinbaseSDKW
|
||||
import type { ThirdwebClient } from "../client/client.js";
|
||||
|
||||
export type WalletId =
|
||||
| "walletConnect"
|
||||
| "embedded"
|
||||
| "smart"
|
||||
| WCSupportedWalletIds
|
||||
| InjectedSupportedWalletIds;
|
||||
|
||||
export type StandaloneWCConnectOptions = WCConnectOptions["walletConnect"] & {
|
||||
client: ThirdwebClient;
|
||||
/**
|
||||
* Optional chain to connect to.
|
||||
*/
|
||||
chain?: Chain;
|
||||
};
|
||||
|
||||
// connect options
|
||||
export type InjectedConnectOptions = {
|
||||
/**
|
||||
@@ -52,22 +61,25 @@ export type EmbeddedWalletCreationOptions =
|
||||
* type X = WalletConnectionOption<'io.metamask'>
|
||||
* ````
|
||||
*/
|
||||
export type WalletConnectionOption<T extends WalletId> = T extends "smart"
|
||||
? SmartWalletConnectionOptions
|
||||
: // embedded wallet
|
||||
T extends "embedded"
|
||||
? EmbeddedWalletConnectionOptions
|
||||
: // coinbase wallet (inhected + coinbaseWallet)
|
||||
T extends "com.coinbase.wallet"
|
||||
? InjectedConnectOptions | CoinbaseSDKWalletConnectionOptions
|
||||
: // injected + wc both supported
|
||||
T extends InjectedSupportedWalletIds & WCSupportedWalletIds
|
||||
? InjectedConnectOptions | WCConnectOptions
|
||||
: // injected only
|
||||
T extends InjectedSupportedWalletIds
|
||||
? InjectedConnectOptions
|
||||
: // wc only
|
||||
WCConnectOptions;
|
||||
export type WalletConnectionOption<T extends WalletId> =
|
||||
T extends "walletConnect"
|
||||
? StandaloneWCConnectOptions
|
||||
: T extends "smart"
|
||||
? SmartWalletConnectionOptions
|
||||
: // embedded wallet
|
||||
T extends "embedded"
|
||||
? EmbeddedWalletConnectionOptions
|
||||
: // coinbase wallet (inhected + coinbaseWallet)
|
||||
T extends "com.coinbase.wallet"
|
||||
? InjectedConnectOptions | CoinbaseSDKWalletConnectionOptions
|
||||
: // injected + wc both supported
|
||||
T extends InjectedSupportedWalletIds & WCSupportedWalletIds
|
||||
? InjectedConnectOptions | WCConnectOptions
|
||||
: // injected only
|
||||
T extends InjectedSupportedWalletIds
|
||||
? InjectedConnectOptions
|
||||
: // wc only
|
||||
WCConnectOptions;
|
||||
|
||||
/**
|
||||
* Generic type for getting the type of object that the `wallet.autoConnect` method takes as the first argument.
|
||||
@@ -76,21 +88,24 @@ export type WalletConnectionOption<T extends WalletId> = T extends "smart"
|
||||
* type X = WalletAutoConnectionOption<'io.metamask'>
|
||||
* ````
|
||||
*/
|
||||
export type WalletAutoConnectionOption<T extends WalletId> = T extends "smart"
|
||||
? SmartWalletConnectionOptions
|
||||
: T extends "embedded"
|
||||
? EmbeddedWalletAutoConnectOptions
|
||||
: // coinbase wallet (inhected + coinbaseWallet)
|
||||
T extends "com.coinbase.wallet"
|
||||
? InjectedConnectOptions | CoinbaseSDKWalletConnectionOptions
|
||||
: // injected + wc both supported
|
||||
T extends InjectedSupportedWalletIds & WCSupportedWalletIds
|
||||
? InjectedConnectOptions | WCAutoConnectOptions
|
||||
: // injected only
|
||||
T extends InjectedSupportedWalletIds
|
||||
? InjectedConnectOptions
|
||||
: // wc only
|
||||
WCAutoConnectOptions;
|
||||
export type WalletAutoConnectionOption<T extends WalletId> =
|
||||
T extends "walletConnect"
|
||||
? WCAutoConnectOptions
|
||||
: T extends "smart"
|
||||
? SmartWalletConnectionOptions
|
||||
: T extends "embedded"
|
||||
? EmbeddedWalletAutoConnectOptions
|
||||
: // coinbase wallet (inhected + coinbaseWallet)
|
||||
T extends "com.coinbase.wallet"
|
||||
? InjectedConnectOptions | CoinbaseSDKWalletConnectionOptions
|
||||
: // injected + wc both supported
|
||||
T extends InjectedSupportedWalletIds & WCSupportedWalletIds
|
||||
? InjectedConnectOptions | WCAutoConnectOptions
|
||||
: // injected only
|
||||
T extends InjectedSupportedWalletIds
|
||||
? InjectedConnectOptions
|
||||
: // wc only
|
||||
WCAutoConnectOptions;
|
||||
/**
|
||||
* Generic type for getting the type of object that the `createWallet` function takes as the second argument. ( the first argument being the wallet id )
|
||||
* @example
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,24 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.6.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3ef3786`](https://github.com/thirdweb-dev/js/commit/3ef378659e83341663dfaded417e33b5af29bbbc)]:
|
||||
- @thirdweb-dev/chains@0.1.85
|
||||
- @thirdweb-dev/sdk@4.0.54
|
||||
- @thirdweb-dev/wallets@2.4.30
|
||||
- @thirdweb-dev/auth@4.1.52
|
||||
|
||||
## 0.6.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6bd1b82`](https://github.com/thirdweb-dev/js/commit/6bd1b82a58505ec3af3a12ceeab51d78ee3b8bc0)]:
|
||||
- @thirdweb-dev/sdk@4.0.53
|
||||
- @thirdweb-dev/wallets@2.4.29
|
||||
- @thirdweb-dev/auth@4.1.51
|
||||
|
||||
## 0.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.6.1",
|
||||
"version": "0.6.3",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Reference in New Issue
Block a user