Skip to content

Commit 58d024c

Browse files
committed
feat: Various gateway improvements & general refactorings
1 parent 89c5888 commit 58d024c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+687
-377
lines changed

Diff for: README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@ It specifically targets the [AZERO.ID](https://azero.id) registry, though, it ca
1414
| | **Testnet¹** | **Mainnet²** |
1515
| --------------------- | -------------------------------------------- | -------------------------------------------- |
1616
| **Resolver Contract** | `0x5cf63C14b82C6E1B95023d8D23e682d12761F56C` | `0x723f6C968609F62583504DD67307A4Ae4c9Fd886` |
17-
| **Gateway** | https://tzero-id-gateway.nameverse.io | https://azero-id-gateway.nameverse.io |
18-
| **ENS Domain** | `*.tzero-id.eth`, `tzero.eth` | `*.azero-id.eth` |
17+
| **Gateway** | https://gateway.tzero.id | https://gateway.azero.id |
18+
| **ENS Domains** | `<name>.tzero.id`³, `<name>.tzero-id.eth` | `<name>.azero.id`³, `<name>.azero-id.eth` |
1919

2020
<small style="opacity: 0.5;">
21-
<strong>¹ Testnet:</strong> Ethereum Sepolia & Aleph Zero Testnet<br/>
22-
<strong>² Mainnet:</strong> Ethereum Mainnet & Aleph Zero Mainnet<br/>
21+
<strong>¹</strong> Ethereum Sepolia & Aleph Zero Testnet<br/>
22+
<strong>²</strong> Ethereum Mainnet & Aleph Zero Mainnet<br/>
23+
<strong>³</strong> Regular ENS Domains imported via DNSSEC<br/>
2324
</small>
2425

2526
## Packages
2627

27-
### [Solidity Contracts](packages/contracts)
28+
### [Solidity Contracts](packages/contracts/README.md)
2829

2930
The smart contract provides a resolver stub that implement CCIP Read (EIP 3668) and ENS wildcard resolution (ENSIP 10). When queried for a name, it directs the client to query the gateway server. When called back with the gateway server response, the resolver verifies the signature was produced by an authorised signer, and returns the response to the client.
3031

31-
### [Gateway Server](packages/gateway)
32+
### [Gateway & Relayer Server](packages/server/README.md)
3233

33-
The gateway server implements CCIP Read (EIP 3668), and answers requests by looking up the names on the registry Aleph Zero. Once a record is retrieved, it is signed using a user-provided key to assert its validity, and both record and signature are returned to the caller so they can be provided to the contract that initiated the request. It's designed to be deployed as a Cloudflare worker.
34+
The server serves as both a EVM Registration Proxy (Relayer) and as a CCIP Read Resolver (Gateway) for ENS resolution.
3435

35-
### [Demo Client](packages/client)
36+
- **Gateway**: Implements CCIP Read (EIP 3668), and answers requests by looking up the names on the registry Aleph Zero. Once a record is retrieved, it is signed using a user-provided key to assert its validity, and both record and signature are returned to the caller so they can be provided to the contract that initiated the request. It's designed to be deployed as a Cloudflare worker.
37+
- **Relayer**: TODO @Nimish
38+
39+
### [Demo Client](packages/client/README.md)
3640

3741
A simple script that resolves a given domain through the ENS protocol (using the gateway server) and verifies the response with the result from the registry contracts directly on the Aleph Zero network.
3842

@@ -44,7 +48,7 @@ A simple script that resolves a given domain through the ENS protocol (using the
4448
> - Install [Bun](https://bun.sh/)
4549
> - Clone this repository
4650
47-
1. Run the gateway server ([packages/gateway/README.md](packages/gateway/README.md))
51+
1. Run the gateway server ([packages/server/README.md](packages/server/README.md))
4852
1. Use the worker url as environment variable when deploying the contracts
4953
2. Deploy the contracts ([packages/contracts/README.md](packages/contracts/README.md))
5054
1. Assign the new resolver to your ENS name

Diff for: bun.lockb

-20.5 KB
Binary file not shown.

Diff for: packages/client/index.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,32 @@ const transport = process.env.INFURA_API_KEY
3737
const viemClient = createPublicClient({ chain: evmChain, transport })
3838

3939
const evmChainName = isMainnet ? 'Ethereum Mainnet' : 'Ethereum Sepolia'
40-
const ensDomain = isMainnet ? `${domain}-id.eth` : `${domain}-id.eth`
40+
const ensDomain = isMainnet ? `${domain}.id` : `${domain}.id`
41+
// const ensDomain = isMainnet ? `${domain}-id.eth` : `${domain}-id.eth`
4142

4243
const resolver = await viemClient.getEnsResolver({
4344
name: normalize(ensDomain),
4445
})
4546
spinner.info(`[${evmChainName}] Found Resolver: ${resolver}`).start()
4647

47-
const gatewayUrl = isMainnet
48-
? `https://azero-id-gateway.nameverse.io`
49-
: `https://tzero-id-gateway.nameverse.io`
48+
const gatewayUrl = isMainnet ? `https://gateway.azero.id` : `https://gateway.tzero.id`
5049
spinner.info(`[${evmChainName}] Gateway URL: ${gatewayUrl}`)
5150

5251
spinner.start(`Fetching ENS Address on EVM via Gateway (${gatewayUrl})…`)
52+
53+
const startTime = performance.now()
5354
const evmAddress = await viemClient.getEnsAddress({
5455
name: normalize(ensDomain),
5556
coinType: 643,
56-
// universalResolverAddress: resolver,
57+
universalResolverAddress: resolver,
5758
})
59+
const endTime = performance.now()
60+
const duration = endTime - startTime
5861

5962
const evmAddressSs58 = evmAddress ? new AccountId32(evmAddress).address() : null
6063
if (evmAddress && evmAddressSs58) {
6164
spinner.success(
62-
`[${evmChainName}] Resolved address of ${ensDomain}: ${evmAddressSs58} (${evmAddress})`,
65+
`[${evmChainName}] Resolved address of ${ensDomain}: ${evmAddressSs58} (${evmAddress}) in ${duration.toFixed(0)}ms`,
6366
)
6467
} else {
6568
spinner.error(`[${evmChainName}] Couldn't resolve address of ${ensDomain}`)

Diff for: packages/client/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@scio-labs/azero-offchain-resolver-client",
3-
"version": "0.0.1",
2+
"name": "@scio-labs/azero-offchain-client",
3+
"version": "0.2.0",
44
"repository": "[email protected]:scio-labs/offchain-resolver-ts.git",
55
"author": "Scio Labs <[email protected]> (https://scio.xyz)",
66
"license": "MIT",
@@ -16,7 +16,7 @@
1616
"@types/bun": "latest",
1717
"@wagmi/cli": "^2.1.16",
1818
"dedot": "^0.6.0",
19-
"viem": "^2.21.22",
20-
"yocto-spinner": "^0.1.0"
19+
"viem": "^2.21.34",
20+
"yocto-spinner": "^0.1.1"
2121
}
2222
}

Diff for: packages/contracts/.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ REMOTE_GATEWAY=https://tzero-id-gateway.nameverse.io/
1212
# SIGNER_ADDR=TODO
1313
# NETWORK=mainnet
1414
# REMOTE_GATEWAY=https://azero-id-gateway.nameverse.io/
15+
16+
# TODO @Nimish

Diff for: packages/contracts/deploy.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ source .env
88
bun run clean
99

1010
# Deploy & Verify OffchainResolver
11-
bunx hardhat --network $NETWORK deploy --tags gateway --reset
11+
bunx hardhat --network $NETWORK deploy --tags gateway --reset
12+
13+
# Deploy & Verify RegistrationProxy
14+
bunx hardhat --network $NETWORK deploy --tags relayer --reset
15+
16+
# Verify Manually
17+
# bunx hardhat verify --network sepolia <address> --constructor-args <file>.js

Diff for: packages/contracts/deploy/20_registration_proxy.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { ethers, run } = require('hardhat')
2+
3+
module.exports = async ({ getNamedAccounts, deployments, network }) => {
4+
const { deploy } = deployments
5+
const { deployer, signer } = await getNamedAccounts()
6+
7+
// TODO @Nimish
8+
9+
// if (!network.config.gatewayurl) {
10+
// throw "gatewayurl is missing on hardhat.config.js";
11+
// }
12+
13+
// const args = [network.config.gatewayurl, [signer]];
14+
// console.log("Constructor arguments:", args);
15+
16+
// console.log("Deploying OffchainResolver…");
17+
// const { address } = await deploy("OffchainResolver", {
18+
// from: deployer,
19+
// args,
20+
// log: true,
21+
// });
22+
23+
console.log('Verifying contract…')
24+
await run('verify:verify', {
25+
address,
26+
constructorArguments: args,
27+
})
28+
}
29+
module.exports.tags = ['relayer']

Diff for: packages/contracts/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "@scio-labs/azero-offchain-resolver-contracts",
3-
"version": "0.0.1",
2+
"name": "@scio-labs/azero-offchain-contracts",
3+
"version": "0.2.0",
44
"repository": "[email protected]:scio-labs/offchain-resolver-ts.git",
55
"author": "Scio Labs <[email protected]> (https://scio.xyz)",
66
"license": "MIT",
77
"files": [
8-
"contracts/*.sol",
8+
"contracts/**/*.sol",
99
"artifacts/contracts/**/*.json"
1010
],
1111
"scripts": {

Diff for: packages/gateway/.dev.vars.example

-2
This file was deleted.

Diff for: packages/gateway/src/azero-id-resolver.ts

-157
This file was deleted.

0 commit comments

Comments
 (0)