Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
901789983f | ||
|
|
ad49560331 | ||
|
|
83198b2ea4 | ||
|
|
a138681b6c | ||
|
|
3a18c6e6a8 | ||
|
|
fdd8c17813 | ||
|
|
32c2ff62f8 | ||
|
|
bef65c8b69 | ||
|
|
7afc2055b9 | ||
|
|
8e9c51ee7b |
@@ -89,7 +89,7 @@ jobs:
|
||||
- run: pnpm test
|
||||
|
||||
- name: Code Coverage
|
||||
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
|
||||
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
|
||||
with:
|
||||
directory: packages/
|
||||
flags: packages
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
|
||||
uses: github/codeql-action/init@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
|
||||
uses: github/codeql-action/autobuild@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
@@ -72,4 +72,4 @@ jobs:
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
|
||||
uses: github/codeql-action/analyze@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1
|
||||
|
||||
+12
-4
@@ -20,6 +20,7 @@ import {
|
||||
createThirdwebClient,
|
||||
Engine,
|
||||
getContract,
|
||||
NATIVE_TOKEN_ADDRESS,
|
||||
readContract,
|
||||
type ThirdwebClient,
|
||||
toUnits,
|
||||
@@ -889,11 +890,16 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
|
||||
|
||||
const sendMutation = useMutation({
|
||||
mutationFn: async (values: SendFormValues) => {
|
||||
const normalizedTokenAddress =
|
||||
values.tokenAddress?.toLowerCase() ===
|
||||
NATIVE_TOKEN_ADDRESS.toLowerCase()
|
||||
? undefined
|
||||
: values.tokenAddress;
|
||||
let decimals = 18;
|
||||
if (values.tokenAddress) {
|
||||
if (normalizedTokenAddress) {
|
||||
const decimalsRpc = await readContract({
|
||||
contract: getContract({
|
||||
address: values.tokenAddress,
|
||||
address: normalizedTokenAddress,
|
||||
chain: selectedChain,
|
||||
client,
|
||||
}),
|
||||
@@ -914,7 +920,9 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
|
||||
teamId,
|
||||
walletAddress,
|
||||
secretKey: secretKeyValue,
|
||||
...(values.tokenAddress ? { tokenAddress: values.tokenAddress } : {}),
|
||||
...(normalizedTokenAddress
|
||||
? { tokenAddress: normalizedTokenAddress }
|
||||
: {}),
|
||||
...(vaultAccessTokenValue
|
||||
? { vaultAccessToken: vaultAccessTokenValue }
|
||||
: {}),
|
||||
@@ -956,7 +964,7 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit((values) => {
|
||||
void sendMutation.mutateAsync(values);
|
||||
sendMutation.mutate(values);
|
||||
})}
|
||||
>
|
||||
<div className="space-y-4 px-4 pb-8 lg:px-6">
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
# wagmi-inapp
|
||||
|
||||
## 0.0.56
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`83198b2`](https://github.com/thirdweb-dev/js/commit/83198b2ea4dd29b1debb7db2dc2eabba57e9c4d7), [`ad49560`](https://github.com/thirdweb-dev/js/commit/ad4956033107c52ecdf4cd9f5b2bff87867f3bec)]:
|
||||
- thirdweb@5.119.4
|
||||
- @thirdweb-dev/wagmi-adapter@0.2.211
|
||||
|
||||
## 0.0.55
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3a18c6e`](https://github.com/thirdweb-dev/js/commit/3a18c6e6a8c12cecaf684fff2dfc5a73c77c40c9)]:
|
||||
- thirdweb@5.119.3
|
||||
- @thirdweb-dev/wagmi-adapter@0.2.210
|
||||
|
||||
## 0.0.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`32c2ff6`](https://github.com/thirdweb-dev/js/commit/32c2ff62f8a2ca8da82c1e8d9bb73def95ec41db)]:
|
||||
- thirdweb@5.119.2
|
||||
- @thirdweb-dev/wagmi-adapter@0.2.209
|
||||
|
||||
## 0.0.53
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wagmi-inapp",
|
||||
"private": true,
|
||||
"version": "0.0.53",
|
||||
"version": "0.0.56",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# @thirdweb-dev/nebula
|
||||
|
||||
## 0.2.114
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`83198b2`](https://github.com/thirdweb-dev/js/commit/83198b2ea4dd29b1debb7db2dc2eabba57e9c4d7), [`ad49560`](https://github.com/thirdweb-dev/js/commit/ad4956033107c52ecdf4cd9f5b2bff87867f3bec)]:
|
||||
- thirdweb@5.119.4
|
||||
|
||||
## 0.2.113
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`3a18c6e`](https://github.com/thirdweb-dev/js/commit/3a18c6e6a8c12cecaf684fff2dfc5a73c77c40c9)]:
|
||||
- thirdweb@5.119.3
|
||||
|
||||
## 0.2.112
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`32c2ff6`](https://github.com/thirdweb-dev/js/commit/32c2ff62f8a2ca8da82c1e8d9bb73def95ec41db)]:
|
||||
- thirdweb@5.119.2
|
||||
|
||||
## 0.2.111
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -57,5 +57,5 @@
|
||||
"type": "module",
|
||||
"types": "./dist/types/exports/thirdweb.d.ts",
|
||||
"typings": "./dist/types/exports/thirdweb.d.ts",
|
||||
"version": "0.2.111"
|
||||
"version": "0.2.114"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.119.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#8733](https://github.com/thirdweb-dev/js/pull/8733) [`83198b2`](https://github.com/thirdweb-dev/js/commit/83198b2ea4dd29b1debb7db2dc2eabba57e9c4d7) Thanks [@Dhaiwat10](https://github.com/Dhaiwat10)! - Updates the hardcoded ENS Universal Resolver address from 0xce01f8eee7E479C928F8919abD53E553a36CeF67 (old) to 0xeeeeeeee14d718c2b47d9923deab1335e144eeee (new)
|
||||
|
||||
- [#8735](https://github.com/thirdweb-dev/js/pull/8735) [`ad49560`](https://github.com/thirdweb-dev/js/commit/ad4956033107c52ecdf4cd9f5b2bff87867f3bec) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - ENS: add coinType param to reverse resolver
|
||||
|
||||
## 5.119.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#8726](https://github.com/thirdweb-dev/js/pull/8726) [`3a18c6e`](https://github.com/thirdweb-dev/js/commit/3a18c6e6a8c12cecaf684fff2dfc5a73c77c40c9) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [CLI] fix stylus abi exports
|
||||
|
||||
## 5.119.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#8724](https://github.com/thirdweb-dev/js/pull/8724) [`32c2ff6`](https://github.com/thirdweb-dev/js/commit/32c2ff62f8a2ca8da82c1e8d9bb73def95ec41db) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [CLI] create-stylus fixes
|
||||
|
||||
## 5.119.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -431,5 +431,5 @@
|
||||
}
|
||||
},
|
||||
"typings": "./dist/types/exports/thirdweb.d.ts",
|
||||
"version": "5.119.1"
|
||||
"version": "5.119.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { parseAbiItem } from "abitype";
|
||||
import open from "open";
|
||||
import ora, { type Ora } from "ora";
|
||||
import prompts from "prompts";
|
||||
@@ -16,12 +17,6 @@ export async function publishStylus(secretKey?: string) {
|
||||
|
||||
checkPrerequisites(spinner, "cargo", ["--version"], "Rust (cargo)");
|
||||
checkPrerequisites(spinner, "rustc", ["--version"], "Rust compiler (rustc)");
|
||||
checkPrerequisites(
|
||||
spinner,
|
||||
"solc",
|
||||
["--version"],
|
||||
"Solidity compiler (solc)",
|
||||
);
|
||||
|
||||
const uri = await buildStylus(spinner, secretKey);
|
||||
|
||||
@@ -35,12 +30,6 @@ export async function deployStylus(secretKey?: string) {
|
||||
|
||||
checkPrerequisites(spinner, "cargo", ["--version"], "Rust (cargo)");
|
||||
checkPrerequisites(spinner, "rustc", ["--version"], "Rust compiler (rustc)");
|
||||
checkPrerequisites(
|
||||
spinner,
|
||||
"solc",
|
||||
["--version"],
|
||||
"Solidity compiler (solc)",
|
||||
);
|
||||
|
||||
const uri = await buildStylus(spinner, secretKey);
|
||||
|
||||
@@ -99,9 +88,9 @@ async function buildStylus(spinner: Ora, secretKey?: string) {
|
||||
}
|
||||
spinner.succeed("Initcode generated.");
|
||||
|
||||
// Step 3: Run stylus command to generate abi
|
||||
// Step 3: Run stylus command to generate abi (plain Solidity, no solc needed)
|
||||
spinner.start("Generating ABI...");
|
||||
const abiResult = spawnSync("cargo", ["stylus", "export-abi", "--json"], {
|
||||
const abiResult = spawnSync("cargo", ["stylus", "export-abi"], {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (abiResult.status !== 0) {
|
||||
@@ -109,15 +98,21 @@ async function buildStylus(spinner: Ora, secretKey?: string) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const abiContent = abiResult.stdout.trim();
|
||||
if (!abiContent) {
|
||||
const solidityOutput = abiResult.stdout.trim();
|
||||
if (!solidityOutput) {
|
||||
spinner.fail("Failed to generate ABI.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const interfaces = parseSolidityInterfaces(solidityOutput);
|
||||
if (interfaces.length === 0) {
|
||||
spinner.fail("No interfaces found in ABI output.");
|
||||
process.exit(1);
|
||||
}
|
||||
spinner.succeed("ABI generated.");
|
||||
|
||||
// Step 3.5: detect the constructor
|
||||
spinner.start("Detecting constructor…");
|
||||
spinner.start("Detecting constructor\u2026");
|
||||
const constructorResult = spawnSync("cargo", ["stylus", "constructor"], {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
@@ -127,23 +122,16 @@ async function buildStylus(spinner: Ora, secretKey?: string) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const constructorSigRaw = constructorResult.stdout.trim(); // e.g. "constructor(address owner)"
|
||||
const constructorSigRaw = constructorResult.stdout.trim();
|
||||
spinner.succeed(`Constructor found: ${constructorSigRaw || "none"}`);
|
||||
|
||||
// Step 4: Process the output
|
||||
const parts = abiContent.split(/======= <stdin>:/g).filter(Boolean);
|
||||
const contractNames = extractContractNamesFromExportAbi(abiContent);
|
||||
let selectedIndex = 0;
|
||||
|
||||
let selectedContractName: string | undefined;
|
||||
let selectedAbiContent: string | undefined;
|
||||
|
||||
if (contractNames.length === 1) {
|
||||
selectedContractName = contractNames[0]?.replace(/^I/, "");
|
||||
selectedAbiContent = parts[0];
|
||||
} else {
|
||||
if (interfaces.length > 1) {
|
||||
const response = await prompts({
|
||||
choices: contractNames.map((name, idx) => ({
|
||||
title: name,
|
||||
choices: interfaces.map((iface, idx) => ({
|
||||
title: iface.name,
|
||||
value: idx,
|
||||
})),
|
||||
message: "Select entrypoint:",
|
||||
@@ -151,46 +139,31 @@ async function buildStylus(spinner: Ora, secretKey?: string) {
|
||||
type: "select",
|
||||
});
|
||||
|
||||
const selectedIndex = response.contract;
|
||||
|
||||
if (typeof selectedIndex !== "number") {
|
||||
if (typeof response.contract !== "number") {
|
||||
spinner.fail("No contract selected.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
selectedContractName = contractNames[selectedIndex]?.replace(/^I/, "");
|
||||
selectedAbiContent = parts[selectedIndex];
|
||||
selectedIndex = response.contract;
|
||||
}
|
||||
|
||||
if (!selectedAbiContent) {
|
||||
throw new Error("Entrypoint not found");
|
||||
}
|
||||
|
||||
if (!selectedContractName) {
|
||||
spinner.fail("Error: Could not determine contract name from ABI output.");
|
||||
const selectedInterface = interfaces[selectedIndex];
|
||||
if (!selectedInterface) {
|
||||
spinner.fail("No interface found.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let cleanedAbi = "";
|
||||
try {
|
||||
const jsonMatch = selectedAbiContent.match(/\[.*\]/s);
|
||||
if (jsonMatch) {
|
||||
cleanedAbi = jsonMatch[0];
|
||||
} else {
|
||||
throw new Error("No valid JSON ABI found in the file.");
|
||||
}
|
||||
} catch (error) {
|
||||
spinner.fail("Error: ABI file contains invalid format.");
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <>
|
||||
const abiArray: any[] = JSON.parse(cleanedAbi);
|
||||
const selectedContractName = selectedInterface.name.replace(/^I/, "");
|
||||
// biome-ignore lint/suspicious/noExplicitAny: ABI is untyped JSON from parseAbiItem
|
||||
const abiArray: any[] = selectedInterface.abi;
|
||||
|
||||
const constructorAbi = constructorSigToAbi(constructorSigRaw);
|
||||
if (constructorAbi && !abiArray.some((e) => e.type === "constructor")) {
|
||||
abiArray.unshift(constructorAbi); // put it at the top for readability
|
||||
if (
|
||||
constructorAbi &&
|
||||
// biome-ignore lint/suspicious/noExplicitAny: ABI entries have varying shapes
|
||||
!abiArray.some((e: any) => e.type === "constructor")
|
||||
) {
|
||||
abiArray.unshift(constructorAbi);
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
@@ -256,10 +229,94 @@ async function buildStylus(spinner: Ora, secretKey?: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function extractContractNamesFromExportAbi(abiRawOutput: string): string[] {
|
||||
return [...abiRawOutput.matchAll(/<stdin>:(I?[A-Za-z0-9_]+)/g)]
|
||||
.map((m) => m[1])
|
||||
.filter((name): name is string => typeof name === "string");
|
||||
// biome-ignore lint/suspicious/noExplicitAny: ABI items from parseAbiItem are untyped
|
||||
type AbiEntry = any;
|
||||
type ParsedInterface = { name: string; abi: AbiEntry[] };
|
||||
|
||||
function parseSolidityInterfaces(source: string): ParsedInterface[] {
|
||||
const results: ParsedInterface[] = [];
|
||||
|
||||
const ifaceRegex = /interface\s+(I?[A-Za-z0-9_]+)\s*\{([\s\S]*?)\n\}/g;
|
||||
for (
|
||||
let ifaceMatch = ifaceRegex.exec(source);
|
||||
ifaceMatch !== null;
|
||||
ifaceMatch = ifaceRegex.exec(source)
|
||||
) {
|
||||
const name = ifaceMatch[1] ?? "";
|
||||
const body = ifaceMatch[2] ?? "";
|
||||
const abi: AbiEntry[] = [];
|
||||
|
||||
// Build struct lookup: name -> tuple type string
|
||||
const structs = new Map<string, string>();
|
||||
const structRegex = /struct\s+(\w+)\s*\{([^}]*)\}/g;
|
||||
for (
|
||||
let structMatch = structRegex.exec(body);
|
||||
structMatch !== null;
|
||||
structMatch = structRegex.exec(body)
|
||||
) {
|
||||
const fields = (structMatch[2] ?? "")
|
||||
.split(";")
|
||||
.map((f) => f.trim())
|
||||
.filter(Boolean)
|
||||
.map((f) => f.split(/\s+/)[0] ?? "");
|
||||
structs.set(structMatch[1] ?? "", `(${fields.join(",")})`);
|
||||
}
|
||||
|
||||
// Resolve struct references in a type string (iterative for nested structs)
|
||||
const resolveStructs = (sig: string): string => {
|
||||
let resolved = sig;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let changed = false;
|
||||
for (const [sName, sTuple] of structs) {
|
||||
const re = new RegExp(`\\b${sName}\\b(\\[\\])?`, "g");
|
||||
const next = resolved.replace(
|
||||
re,
|
||||
(_, arr) => `${sTuple}${arr ?? ""}`,
|
||||
);
|
||||
if (next !== resolved) {
|
||||
resolved = next;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (!changed) break;
|
||||
}
|
||||
return resolved;
|
||||
};
|
||||
|
||||
// Extract each statement (function/error/event) delimited by ;
|
||||
const statements = body
|
||||
.split(";")
|
||||
.map((s) => s.replace(/\n/g, " ").trim())
|
||||
.filter(
|
||||
(s) =>
|
||||
s.startsWith("function ") ||
|
||||
s.startsWith("error ") ||
|
||||
s.startsWith("event "),
|
||||
);
|
||||
|
||||
for (const stmt of statements) {
|
||||
// Strip Solidity qualifiers that abitype doesn't expect
|
||||
let cleaned = stmt
|
||||
.replace(/\b(external|public|internal|private)\b/g, "")
|
||||
.replace(/\b(memory|calldata|storage)\b/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
// Resolve struct type names to tuple types
|
||||
cleaned = resolveStructs(cleaned);
|
||||
|
||||
try {
|
||||
const parsed = parseAbiItem(cleaned);
|
||||
abi.push(parsed);
|
||||
} catch {
|
||||
// Skip unparseable items
|
||||
}
|
||||
}
|
||||
|
||||
results.push({ abi, name });
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function getUrl(hash: string, command: string) {
|
||||
|
||||
@@ -8,12 +8,6 @@ export async function createStylusProject() {
|
||||
|
||||
checkPrerequisites(spinner, "cargo", ["--version"], "Rust (cargo)");
|
||||
checkPrerequisites(spinner, "rustc", ["--version"], "Rust compiler (rustc)");
|
||||
checkPrerequisites(
|
||||
spinner,
|
||||
"solc",
|
||||
["--version"],
|
||||
"Solidity compiler (solc)",
|
||||
);
|
||||
|
||||
// Step 1: Ensure cargo is installed
|
||||
const cargoCheck = spawnSync("cargo", ["--version"]);
|
||||
@@ -24,7 +18,7 @@ export async function createStylusProject() {
|
||||
|
||||
// Step 2: Install stylus etc.
|
||||
spinner.start("Installing Stylus...");
|
||||
const install = spawnSync("cargo", ["install", "--force", "cargo-stylus"], {
|
||||
const install = spawnSync("cargo", ["install", "cargo-stylus"], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
if (install.status !== 0) {
|
||||
@@ -33,7 +27,7 @@ export async function createStylusProject() {
|
||||
}
|
||||
spinner.succeed("Stylus installed.");
|
||||
|
||||
spawnSync("rustup", ["default", "1.87"], {
|
||||
spawnSync("rustup", ["default", "stable"], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
spawnSync("rustup", ["target", "add", "wasm32-unknown-unknown"], {
|
||||
|
||||
+14
-6
@@ -14,14 +14,22 @@ export type ReverseParams = {
|
||||
type: "bytes";
|
||||
name: "reverseName";
|
||||
}>;
|
||||
coinType: AbiParameterToPrimitiveType<{
|
||||
type: "uint256";
|
||||
name: "coinType";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0xec11c823" as const;
|
||||
export const FN_SELECTOR = "0x5d78a217" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "reverseName",
|
||||
type: "bytes",
|
||||
},
|
||||
{
|
||||
name: "coinType",
|
||||
type: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
@@ -33,9 +41,6 @@ const FN_OUTPUTS = [
|
||||
{
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
type: "address",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
@@ -70,7 +75,10 @@ export function isReverseSupported(availableSelectors: string[]) {
|
||||
* ```
|
||||
*/
|
||||
export function encodeReverseParams(options: ReverseParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.reverseName]);
|
||||
return encodeAbiParameters(FN_INPUTS, [
|
||||
options.reverseName,
|
||||
options.coinType,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +136,6 @@ export async function reverse(options: BaseTransactionOptions<ReverseParams>) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.reverseName],
|
||||
params: [options.reverseName, options.coinType],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const UNIVERSAL_RESOLVER_ADDRESS =
|
||||
"0xce01f8eee7E479C928F8919abD53E553a36CeF67";
|
||||
"0xeeeeeeee14d718c2b47d9923deab1335e144eeee";
|
||||
export const BASENAME_RESOLVER_ADDRESS =
|
||||
"0xC6d566A56A1aFf6508b41f6c90ff131615583BCD";
|
||||
export const BASE_SEPOLIA_BASENAME_RESOLVER_ADDRESS =
|
||||
|
||||
@@ -3,8 +3,6 @@ import { ethereum } from "../../chains/chain-definitions/ethereum.js";
|
||||
import type { Chain } from "../../chains/types.js";
|
||||
import type { ThirdwebClient } from "../../client/client.js";
|
||||
import { getContract } from "../../contract/contract.js";
|
||||
import { toHex } from "../../utils/encoding/hex.js";
|
||||
import { packetToBytes } from "../../utils/ens/packetToBytes.js";
|
||||
import { withCache } from "../../utils/promise/withCache.js";
|
||||
import { reverse } from "./__generated__/UniversalResolver/read/reverse.js";
|
||||
import { UNIVERSAL_RESOLVER_ADDRESS } from "./constants.js";
|
||||
@@ -33,7 +31,9 @@ export type ResolveNameOptions = {
|
||||
* @extension ENS
|
||||
* @returns A promise that resolves to the Ethereum address.
|
||||
*/
|
||||
export async function resolveName(options: ResolveNameOptions) {
|
||||
export async function resolveName(
|
||||
options: ResolveNameOptions,
|
||||
): Promise<string | null> {
|
||||
const { client, address, resolverAddress, resolverChain } = options;
|
||||
|
||||
return withCache(
|
||||
@@ -44,25 +44,28 @@ export async function resolveName(options: ResolveNameOptions) {
|
||||
client,
|
||||
});
|
||||
|
||||
const reverseName = toHex(
|
||||
packetToBytes(`${address.toLowerCase().substring(2)}.addr.reverse`),
|
||||
);
|
||||
|
||||
const [name, resolvedAddress] = await reverse({
|
||||
const [name] = await reverse({
|
||||
contract,
|
||||
reverseName,
|
||||
reverseName: address as `0x${string}`,
|
||||
coinType: 60n,
|
||||
}).catch((e) => {
|
||||
if ("data" in e && e.data === "0x7199966d") {
|
||||
return [null, address] as const;
|
||||
// Re-throw verification errors so callers can detect data integrity issues
|
||||
if (
|
||||
typeof e === "object" &&
|
||||
e !== null &&
|
||||
"data" in e &&
|
||||
typeof e.data === "string"
|
||||
) {
|
||||
// ReverseAddressMismatch(string,bytes) = 0xef9c03ce
|
||||
if (e.data.startsWith("0xef9c03ce")) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
// Swallow expected "no resolver" / "no name" errors
|
||||
return [null] as const;
|
||||
});
|
||||
|
||||
if (address.toLowerCase() !== resolvedAddress.toLowerCase()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
return name || null;
|
||||
},
|
||||
{
|
||||
cacheKey: `ens:name:${resolverChain?.id || 1}:${address}`,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/wagmi-adapter
|
||||
|
||||
## 0.2.211
|
||||
|
||||
## 0.2.210
|
||||
|
||||
## 0.2.209
|
||||
|
||||
## 0.2.208
|
||||
|
||||
## 0.2.207
|
||||
|
||||
@@ -56,5 +56,5 @@
|
||||
"type": "module",
|
||||
"types": "./dist/types/exports/thirdweb.d.ts",
|
||||
"typings": "./dist/types/exports/thirdweb.d.ts",
|
||||
"version": "0.2.208"
|
||||
"version": "0.2.211"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user