Skip to content

Commit

Permalink
fix test, bump ethers to ^6.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed Mar 4, 2024
1 parent 29b9509 commit e3ad4ef
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dompurify": "^3.0.5",
"dotenv": "^10.0.0",
"emoji-regex": "^10.1.0",
"ethers": "^6.10.0",
"ethers": "^6.11.1",
"express": "^4.18.1",
"google-auth-library": "^8.1.0",
"graphql": "^16.5.0",
Expand Down
5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const ETH_REGISTRY_ABI = [
'function recordExists(bytes32 node) external view returns (bool)'
];

const NAMEWRAPPER_ABI = [
'function isWrapped(bytes32 node) public view returns (bool)'
];

// response timeout: 1 min
const RESPONSE_TIMEOUT = 15 * 1000;

Expand All @@ -43,6 +47,7 @@ export {
CANVAS_FONT_PATH,
CANVAS_EMOJI_FONT_PATH,
ETH_REGISTRY_ABI,
NAMEWRAPPER_ABI,
INAMEWRAPPER,
IPFS_GATEWAY,
INFURA_API_KEY,
Expand Down
13 changes: 12 additions & 1 deletion src/controller/ensMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
ADDRESS_ETH_REGISTRY,
ETH_REGISTRY_ABI,
NAMEWRAPPER_ABI,
RESPONSE_TIMEOUT,
} from '../config';
import { checkContract } from '../service/contract';
Expand Down Expand Up @@ -96,6 +97,16 @@ export async function ensMetadata(req: Request, res: Response) {
const isRecordExist = await registry.recordExists(_namehash);
assert(isRecordExist, 'ENS name does not exist');

if (version == Version.v2) {
const contract = new Contract(
contractAddress,
NAMEWRAPPER_ABI,
provider
);
const isNameWrapped = await contract.isWrapped(_namehash);
assert(isNameWrapped, 'Name is not wrapped');
}

// When entry is not available on subgraph yet,
// return unknown name metadata with 200 status code
const { url, ...unknownMetadata } = new Metadata({
Expand All @@ -105,7 +116,7 @@ export async function ensMetadata(req: Request, res: Response) {
tokenId: '',
version: Version.v1,
// add timestamp of the request date
last_request_date
last_request_date,
});
res.status(200).json({
message: unknownMetadata,
Expand Down
4 changes: 3 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ test.before(async (t: ExecutionContext<TestContext>) => {
[
{
to: ADDRESS_NAME_WRAPPER.toLowerCase(),
data: /^0xfd0cd0.*$/,
data: '0xfd0cd0d97857c9824139b8a8c3cb04712b41558b4878c55fa9c1e5390e910ee3220c3cce',
},
'latest',
],
{
id: 2,
result:
'0x0000000000000000000000000000000000000000000000000000000000000001',
}
Expand Down Expand Up @@ -143,6 +144,7 @@ test.before(async (t: ExecutionContext<TestContext>) => {
'latest',
],
{
id: 1,
result:
'0x0000000000000000000000000000000000000000000000000000000000000001',
}
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7"
integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==

"@adraffy/[email protected]":
version "1.10.1"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069"
integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==

"@adraffy/[email protected]":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.0.tgz#223572538f6bea336750039bb43a4016dcc8182d"
Expand Down Expand Up @@ -2907,6 +2912,19 @@ ethers@^6.10.0:
tslib "2.4.0"
ws "8.5.0"

ethers@^6.11.1:
version "6.11.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.11.1.tgz#96aae00b627c2e35f9b0a4d65c7ab658259ee6af"
integrity sha512-mxTAE6wqJQAbp5QAe/+o+rXOID7Nw91OZXvgpjDa1r4fAbq2Nu314oEZSbjoRLacuCzs7kUC3clEvkCQowffGg==
dependencies:
"@adraffy/ens-normalize" "1.10.1"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
ws "8.5.0"

event-target-shim@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
Expand Down

0 comments on commit e3ad4ef

Please sign in to comment.