Skip to content

Commit

Permalink
Merge pull request #14 from gentlementlegen/feat/rpc-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Aug 25, 2024
2 parents 627caf3 + c8b751c commit 48e31d9
Show file tree
Hide file tree
Showing 10 changed files with 1,035 additions and 506 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/*.http", "**/*.toml", "src/types/database.ts"],
"useGitignore": true,
"language": "en",
"words": ["Nektos", "dataurl", "devpool", "outdir", "servedir", "Supabase", "SUPABASE", "typebox", "ubiquibot", "Smee"],
"words": ["Nektos", "dataurl", "devpool", "outdir", "servedir", "Supabase", "SUPABASE", "typebox", "ubiquibot", "Smee", "Rpcs"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
2 changes: 1 addition & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: KnipConfig = {
ignore: ["**/__mocks__/**", "**/__fixtures__/**", "src/types/database.ts"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@mswjs/data"],
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@mswjs/data", "ts-node"],
eslint: true,
};

Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [1.1.0](https://github.com/Meniole/command-wallet/compare/v1.0.0...v1.1.0) (2024-07-16)


### Features

* added test for wallet link ([e059e13](https://github.com/Meniole/command-wallet/commit/e059e1329da781194a4f7a928be17015d2b28962))
* parsing arguments and executing run ([70fb75e](https://github.com/Meniole/command-wallet/commit/70fb75e6e970d6439f5d9ba64ee51caa5edaf269))


### Bug Fixes

* fixed crash when user does not exist ([433a6a7](https://github.com/Meniole/command-wallet/commit/433a6a7c3f19b2722df75e7b826bc6b8e0244a1e))

## 1.0.0 (2024-07-08)


Expand Down
11 changes: 0 additions & 11 deletions jest.config.json

This file was deleted.

18 changes: 18 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Config } from "jest";
import { config } from "dotenv";

config({ path: ".dev.vars" });

const configuration: Config = {
preset: "ts-jest",
testEnvironment: "node",
roots: ["./tests"],
coveragePathIgnorePatterns: ["node_modules", "mocks"],
collectCoverage: true,
coverageReporters: ["json", "lcov", "text", "clover", "json-summary"],
reporters: ["default", "jest-junit", "jest-md-dashboard"],
coverageDirectory: "coverage",
setupFiles: ["dotenv/config"],
};

export default configuration;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"knip": "knip --config .github/knip.ts",
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "DOTENV_CONFIG_PATH=.dev.vars jest --setupFiles dotenv/config --coverage",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000",
"supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts",
"supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\""
Expand All @@ -36,6 +36,7 @@
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "0.32.33",
"@supabase/supabase-js": "2.43.5",
"@ubiquity-dao/rpc-handler": "1.3.0",
"commander": "12.1.0",
"dotenv": "16.4.5",
"ethers": "6.13.1",
Expand Down Expand Up @@ -69,6 +70,7 @@
"prettier": "3.3.2",
"supabase": "1.178.2",
"ts-jest": "29.1.5",
"ts-node": "10.9.2",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript-eslint": "7.13.1",
Expand Down
18 changes: 16 additions & 2 deletions src/handlers/query-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers } from "ethers";
import { Context } from "../types";
import { RPCHandler } from "@ubiquity-dao/rpc-handler";

function extractEnsName(text: string) {
const ensRegex = /^(?=.{3,40}$)([a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/gm;
Expand Down Expand Up @@ -73,8 +74,21 @@ function registerWalletWithVerification(context: Context, body: string, address:

export async function resolveAddress(ensName: string) {
// Gets the Ethereum address associated with an ENS (Ethereum Name Service) name
// Explicitly set provider to Ethereum mainnet
const provider = new ethers.JsonRpcProvider(`https://eth.drpc.org`);
// Explicitly set provider to Ethereum main-net
const rpc = new RPCHandler({
networkId: "1",
networkName: "ethereum-mainnet",
networkRpcs: null,
autoStorage: false,
cacheRefreshCycles: 3,
runtimeRpcs: null,
rpcTimeout: 1000,
proxySettings: { retryCount: 0, retryDelay: 1000, logTier: "verbose", logger: null, strictLogs: true },
});
const provider = await rpc.getFirstAvailableRpcProvider();
if (!provider) {
throw new Error("Failed to get a provider.");
}
return await provider.resolveName(ensName).catch((err) => {
console.trace({ err });
return null;
Expand Down
1 change: 0 additions & 1 deletion tests/__mocks__/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { http, HttpResponse } from "msw";
import { db } from "./db";

console.log("HANDLERS", process.env);
/**
* Intercepts the routes and returns a custom payload
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ describe("Wallet command tests", () => {
);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenLastCalledWith("Successfully registered wallet address", {
address: "0x0000000000000000000000000000000000000001",
address: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd",
sender: "ubiquibot",
});
});
}, 10000);
});
Loading

0 comments on commit 48e31d9

Please sign in to comment.