Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f47744d
feat: install zksync-storage-proofs lib plus update/tidy-up all libs
Nov 12, 2024
5244e0a
Merge branch 'main' into aliX/ens-1
Nov 14, 2024
7312b7f
fix(GrantsTest): warping and local variables behave differently in di…
Nov 15, 2024
0c75d0f
Merge branch 'aliX/ens-1' of github.com:NodleCode/rollup into aliX/ens-1
Nov 16, 2024
0c97d9b
chore: add clave-contracts
Nov 17, 2024
390de87
feat: deploy SparseMerkleTree
Nov 17, 2024
004292e
fix var name
Nov 17, 2024
38a47c5
feat: deploy storageProofVerifier
Nov 18, 2024
4aec4e1
feat(ClickNameService): add initial draft
Nov 20, 2024
220fe45
feat(ClickNameService): allow register to move ownership of expired n…
Nov 21, 2024
ba75476
get hardhat to compile
Nov 22, 2024
620692c
deploy cns
Nov 22, 2024
1e16e1d
feat(ClickResolver): add L1 Resolver contract
Nov 25, 2024
b9e2c0d
feat: set resolver automatically on deployment of ClickResolver
Nov 25, 2024
938685c
feat: add clk-gateway api server
Nov 26, 2024
477346e
feat(clk-gateway): add expiry end point
Nov 26, 2024
a8b084f
feat: add L2 resolve api
Nov 26, 2024
487dc45
feat: add registerL2
Nov 27, 2024
0c45a3f
feat: load config from env
Nov 27, 2024
9ea1615
build: container
Nov 27, 2024
bc7f717
fix: github actions
Nov 27, 2024
78eed09
fix docker build cmd
Nov 27, 2024
cbcfbfb
fix push container
Nov 27, 2024
da95ee7
feat: add resolveL2 GET
Nov 27, 2024
767d460
feat: validate api input
Nov 28, 2024
944aec1
chore: fix spellings
Nov 28, 2024
03384e8
fix: forge test
Nov 28, 2024
f4ab097
fix spell
Nov 28, 2024
86c4004
feat: require email verified authentication only for /register
Nov 28, 2024
37c6b10
feat: add id token creator tool for testing
Dec 1, 2024
e0634a2
feat: resolveWithProofL1
Dec 2, 2024
6923cf8
feat(ClickNameService): use well defined errors
Dec 3, 2024
227f019
feat(ClickResolver): simplify resolver
Dec 4, 2024
6af46c3
feat: separate fetching proof from presenting proof to ClickResolver
Dec 4, 2024
a0a06bb
feat: use express-validator
Dec 4, 2024
4f10004
chore: remove submodule clave-contracts
Dec 4, 2024
eacc6c6
feat: add resolveL1 and decode OffchainLookup error
Dec 5, 2024
0da3d4c
fix: ClickResolver needs to return data usable by offchain gateway st…
Dec 5, 2024
a1ed236
fix domain env vars
Dec 5, 2024
801493d
--no-cache
Dec 5, 2024
739d2ba
no crash is a good crash
Dec 5, 2024
957a8a5
Google doesn't like GET with body
Dec 5, 2024
01aecd5
feat: enable full cors
Dec 9, 2024
16919ed
feat(clk-gateway): allow only one name per verified email
Dec 10, 2024
30751cb
Avoid using sol modifiers
Dec 10, 2024
dcc47c0
reuse registerWithExpiry
Dec 10, 2024
c088359
use ts-node
Dec 10, 2024
e4461a0
fix spelling
Dec 10, 2024
bc9146b
limit names to 5 characters or more
Dec 10, 2024
7c08ec1
Merge branch 'main' into aliX/ens-1
Dec 11, 2024
281e4ad
fix spelling
Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 54 additions & 45 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
{
"version": "0.2",
"language": "en",
"files": [
"**/*.{sol,ts,md}"
],
"ignorePaths": [
"node_modules",
"lib",
"out",
"cache",
"broadcast",
"artifacts-zk",
"deployments-zk",
"cache_hardhat-zk",
"zkout"
],
"ignoreWords": [
"NODL",
"Nodle",
"depin",
"contentsign",
"matterlabs",
"zksync",
"zksolc",
"Parachain",
"subql",
"codegen",
"Datasource",
"ipfs",
"keccak",
"IERC",
"Mintable",
"BOOTLOADER",
"devcontainer",
"gasleft",
"chainid",
"myfilebase",
"ethersproject",
"Numberish",
"Blockhash",
"Typechain",
"Soulbound",
"accesscontrolrole"
]
}
"version": "0.2",
"language": "en",
"files": ["**/*.{sol,ts,md}"],
"ignorePaths": [
"node_modules",
"lib",
"out",
"cache",
"broadcast",
"artifacts-zk",
"deployments-zk",
"cache_hardhat-zk",
"zkout",
"clk-gateway/src/validators.test.ts"
],
"ignoreWords": [
"NODL",
"Nodle",
"depin",
"contentsign",
"matterlabs",
"zksync",
"zksolc",
"Parachain",
"subql",
"codegen",
"Datasource",
"ipfs",
"keccak",
"IERC",
"Mintable",
"BOOTLOADER",
"devcontainer",
"gasleft",
"chainid",
"myfilebase",
"ethersproject",
"Numberish",
"Blockhash",
"Typechain",
"Soulbound",
"accesscontrolrole",
"Pubdata",
"Offchain",
"Merkle",
"inheritdoc",
"ENSIP",
"MULTICHAIN",
"CCIP",
"nameservice",
"firebaseapp",
"permissioned"
]
}
54 changes: 54 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Push Container Image

on:
workflow_dispatch:
push:
branches:
- aliX/ens-1
tags:
- v*

# Cancel pending jobs when pushing a new commit
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-push:
runs-on: ubuntu-latest-8-cores

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.PROJECT_ID }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}

- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.PROJECT_ID }}
install_components: beta

- name: Authenticate to Artifact Registry
run: |-
gcloud auth configure-docker us-west1-docker.pkg.dev

- name: Build and Tag Images
run: |-
docker build --no-cache \
-t us-west1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/service/clk-gateway:latest \
-t us-west1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/service/clk-gateway:${{ github.sha }} \
./clk-gateway

- name: Publish Images
run: |-
docker push us-west1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/service/clk-gateway:latest
docker push us-west1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/service/clk-gateway:${{ github.sha }}
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/zksync-contracts"]
path = lib/zksync-contracts
url = https://github.com/NodleCode/zksync-contracts
[submodule "lib/zksync-storage-proofs"]
path = lib/zksync-storage-proofs
url = https://github.com/getclave/zksync-storage-proofs
[submodule "lib/era-contracts"]
path = lib/era-contracts
url = https://github.com/matter-labs/era-contracts
12 changes: 10 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"solidity.packageDefaultDependenciesContractsDirectory": "./src",
"solidity.packageDefaultDependenciesDirectory": "./lib",
"solidity.formatter": "forge"
}
"solidity.formatter": "forge",
"github.copilot.chat.scopeSelection": true,
"github.copilot.chat.localeOverride": "en",
"github.copilot.chat.temporalContext.enabled": true,
"github.copilot.chat.generateTests.codeLens": true,
"github.copilot.chat.inlineChatCompletionTrigger.enabled": true,
"github.copilot.chat.inlineChatHint.enabled": true,
"github.copilot.chat.search.semanticTextResults": true,
"editor.defaultFormatter": null
}
3 changes: 3 additions & 0 deletions clk-gateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.env
13 changes: 13 additions & 0 deletions clk-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20

WORKDIR /usr/src/app

COPY . .

RUN yarn install

RUN yarn build

EXPOSE 8080

CMD ["yarn", "start"]
7 changes: 7 additions & 0 deletions clk-gateway/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: "node",
transform: {
"^.+.tsx?$": ["ts-jest",{}],
},
};
37 changes: 37 additions & 0 deletions clk-gateway/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "clk-gateway",
"version": "1.0.0",
"main": "index.js",
"license": "BSD-3-Clause",
"dependencies": {
"@types/node": "^22.9.4",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"ethers": "^6.13.4",
"express": "^4.21.1",
"express-validator": "^7.2.0",
"firebase": "^11.0.2",
"firebase-admin": "^13.0.1",
"typescript": "^5.7.2",
"zksync-ethers": "^6.15.1"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"nodemon": "^3.1.7",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2"
},
"scripts": {
"fmt": "prettier --write src/**/*.ts",
"test": "jest",
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"build": "tsc",
"serve": "yarn build && yarn start",
"createToken": "ts-node src/createToken.ts"
}
}
76 changes: 76 additions & 0 deletions clk-gateway/src/createToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* This script is a tool for test purposes that uses Firebase Admin service account to create a custom token for a user given its UID as the script input.
*
* The script performs the following steps:
* 1. Manually forces the emailVerified status for the specified user to true, avoiding the need to verify the user's email.
* 2. Uses Firebase Admin SDK to create a custom token for the user.
* 3. Uses Firebase Client SDK to sign in the user with the custom token and retrieve the ID token.
* 4. Prints the ID token, which can be used for POST requests on /registerL2 as the bearer token.
*
* Environment variables required:
* - SERVICE_ACCOUNT_KEY: The Firebase Admin service account key in JSON format.
* - FIREBASE_API_KEY: The Firebase API key.
* - FIREBASE_PROJECT_ID: The Firebase project ID.
*
* Command-line arguments:
* - userUid: The UID of the user for whom the custom token is to be created. Go to the Firebase Console to find the UID of the user.
*
* Usage:
* ```sh
* # Note 1: Do not forget to build the project before running the script
* # Note 2: Do not forget to set the environment variables before running the script
* # Note 3: There is a possibility that the first time you create a token its email remain unverified. Try to create a second token and use that in that case.
* yarn createToken <userUid>
* ```
*
* @module createToken
*/

import admin from "firebase-admin";
import { getAuth, signInWithCustomToken } from "firebase/auth";
import { initializeApp } from "firebase/app";

import dotenv from "dotenv";
dotenv.config();

const serviceAccountKey = process.env.SERVICE_ACCOUNT_KEY!;
const serviceAccount = JSON.parse(serviceAccountKey);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount as admin.ServiceAccount),
});
const firebaseClientConfig = {
apiKey: process.env.FIREBASE_API_KEY!,
authDomain: `${process.env.FIREBASE_PROJECT_ID!}.firebaseapp.com`,
};
const app = initializeApp(firebaseClientConfig);
const auth = getAuth(app);

// Get the UID from the command-line arguments
const userUid: string | undefined = process.argv[2];

if (!userUid) {
console.error("Error: Please provide a user UID as an argument.");
process.exit(1);
}

async function main(uid: string): Promise<void> {
try {
admin
.auth()
.updateUser(uid, { emailVerified: true })
.then((userRecord) => {
console.log(`Successfully updated user: ${userRecord.email}`);
})
.catch((error) => {
console.error("Error updating user:", error);
});
const customToken = await admin.auth().createCustomToken(uid);
const userCredential = await signInWithCustomToken(auth, customToken);
const idToken = await userCredential.user.getIdToken();
console.log("ID Token:", idToken);
} catch (error) {
console.error("Error generating token:", error);
}
}

main(userUid);
13 changes: 13 additions & 0 deletions clk-gateway/src/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { toLengthPrefixedBytes } from "./helpers";

describe("toLengthPrefixedBytes", () => {
test("example.click.eth", () => {
const result = toLengthPrefixedBytes("example", "click", "eth");
expect(result).toEqual(
Uint8Array.from([
7, 101, 120, 97, 109, 112, 108, 101, 5, 99, 108, 105, 99, 107, 3, 101,
116, 104,
]),
);
});
});
Loading
Loading