From c91c88c50f674ecb48ba043caf105b8e7fc4af4a Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:15:14 +0100 Subject: [PATCH] ci: formatting --- .cspell.json | 5 +++-- .github/workflows/knip.yml | 2 +- .github/workflows/publish-package.yml | 2 +- CHANGELOG.md | 26 +++++++++++----------- README.md | 2 ++ rollup.config.mjs | 31 +++------------------------ src/adapters/supabase/helpers/user.ts | 1 - src/handlers/generate-erc20-permit.ts | 7 +++++- src/utils/get-fastest-provider.ts | 12 +++++------ tsconfig.json | 2 +- 10 files changed, 35 insertions(+), 55 deletions(-) diff --git a/.cspell.json b/.cspell.json index 05b52fe..23383aa 100644 --- a/.cspell.json +++ b/.cspell.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", "version": "0.2", - "ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "supabase"], + "ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "supabase", "bun.lockb"], "useGitignore": true, "language": "en", "words": ["dataurl", "devpool", "outdir", "servedir", "typebox"], @@ -31,6 +31,7 @@ "ciphertext", "tweetnacl", "typeguards", - "Numberish" + "Numberish", + "Rpcs" ] } diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index 8e20626..90f47e5 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -31,4 +31,4 @@ jobs: name: knip-results path: | knip-results.json - pr-number.txt \ No newline at end of file + pr-number.txt diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 2443ca4..0e1051f 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20.10.0' + node-version: "20.10.0" registry-url: https://registry.npmjs.org/ - run: | yarn install --immutable --immutable-cache --check-cache diff --git a/CHANGELOG.md b/CHANGELOG.md index ece848c..93d3b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,25 +2,23 @@ ## 1.3.1 (2024-06-20) - ### ⚠ BREAKING CHANGES -* bundle splitting ([#13](https://github.com/ubiquibot/permit-generation/issues/13)) +- bundle splitting ([#13](https://github.com/ubiquibot/permit-generation/issues/13)) ### Features -* add custom reward token to permit ([16b08bc](https://github.com/ubiquibot/permit-generation/commit/16b08bc2ea6cadaba5f1446c832ec85d609bedab)) -* bundle splitting ([#13](https://github.com/ubiquibot/permit-generation/issues/13)) ([38eb308](https://github.com/ubiquibot/permit-generation/commit/38eb30843665724ca6521f19b72e572d0f59c1c2)) -* encode decode permits ([#10](https://github.com/ubiquibot/permit-generation/issues/10)) ([5673641](https://github.com/ubiquibot/permit-generation/commit/567364137dd48bfa7adf1c5c8a9b55e48d470181)) -* package generation and publish ([f743a24](https://github.com/ubiquibot/permit-generation/commit/f743a242bfe4487e4309647690228d98342bad74)) -* permit module ([b3b95d1](https://github.com/ubiquibot/permit-generation/commit/b3b95d1a8e9081ee4d33b8408ddf194b961ae090)) -* permits ([3b928a1](https://github.com/ubiquibot/permit-generation/commit/3b928a1c0544d8c117133cf80c4a3bcc58697345)) -* return data to kernel ([de23301](https://github.com/ubiquibot/permit-generation/commit/de2330129fe709292e4598f81cb1461ac43c0df6)) -* rollup for package bundling ([628cb59](https://github.com/ubiquibot/permit-generation/commit/628cb59da66c16f1ea8d76c95caaa25426486641)) - +- add custom reward token to permit ([16b08bc](https://github.com/ubiquibot/permit-generation/commit/16b08bc2ea6cadaba5f1446c832ec85d609bedab)) +- bundle splitting ([#13](https://github.com/ubiquibot/permit-generation/issues/13)) ([38eb308](https://github.com/ubiquibot/permit-generation/commit/38eb30843665724ca6521f19b72e572d0f59c1c2)) +- encode decode permits ([#10](https://github.com/ubiquibot/permit-generation/issues/10)) ([5673641](https://github.com/ubiquibot/permit-generation/commit/567364137dd48bfa7adf1c5c8a9b55e48d470181)) +- package generation and publish ([f743a24](https://github.com/ubiquibot/permit-generation/commit/f743a242bfe4487e4309647690228d98342bad74)) +- permit module ([b3b95d1](https://github.com/ubiquibot/permit-generation/commit/b3b95d1a8e9081ee4d33b8408ddf194b961ae090)) +- permits ([3b928a1](https://github.com/ubiquibot/permit-generation/commit/3b928a1c0544d8c117133cf80c4a3bcc58697345)) +- return data to kernel ([de23301](https://github.com/ubiquibot/permit-generation/commit/de2330129fe709292e4598f81cb1461ac43c0df6)) +- rollup for package bundling ([628cb59](https://github.com/ubiquibot/permit-generation/commit/628cb59da66c16f1ea8d76c95caaa25426486641)) ### Bug Fixes -* fixed compilation and erc20 tests ([63c3823](https://github.com/ubiquibot/permit-generation/commit/63c3823ae49cbda768dfd01d58d25e926101d7e9)) -* fixed erc721 tests and errors ([414f29f](https://github.com/ubiquibot/permit-generation/commit/414f29fe852f7a5360eef1344d1e5d7b0da0dda5)) -* this makes no sense ([881f006](https://github.com/ubiquibot/permit-generation/commit/881f006ca7f8dc64ba9fdeb7f02b3da8f0d68476)) +- fixed compilation and erc20 tests ([63c3823](https://github.com/ubiquibot/permit-generation/commit/63c3823ae49cbda768dfd01d58d25e926101d7e9)) +- fixed erc721 tests and errors ([414f29f](https://github.com/ubiquibot/permit-generation/commit/414f29fe852f7a5360eef1344d1e5d7b0da0dda5)) +- this makes no sense ([881f006](https://github.com/ubiquibot/permit-generation/commit/881f006ca7f8dc64ba9fdeb7f02b3da8f0d68476)) diff --git a/README.md b/README.md index fe1f336..4b55f78 100644 --- a/README.md +++ b/README.md @@ -47,5 +47,7 @@ General remarks: Return value should just be an array of generated permits. A separate module can convert them into URLs for pay.ubq.fi. [^1^]: I put a lot of thought into this and unless the plugins can hack X25519 encryption I think its fine for them to attempt brute forcing etc. In exchange its simpler infrastructure vs only accepting requests from the kernel (which seems more secure, but for V1 perhaps unnecessary.) + [^2^]: We pass in the username for enhanced developer experience for plugin development. I believe it will be much easier to use GitHub usernames and let the system do the lookup. + [^3^]: Mixed feelings on this lookup because it does not self encapsulate this module well. We already have an optional database write for the permit record, but this plugin WILL break if there is a database issue for reading the user's registered wallet, which can make testing and development more difficult here. The alternative is to pass in the user's wallet here, but then the kernel (or another plugin) needs to look up their wallet address (this seems like the better approach.) diff --git a/rollup.config.mjs b/rollup.config.mjs index 1e47c78..9fd8b20 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -15,16 +15,7 @@ const config = [ dir: "dist/types", format: "cjs", }, - plugins: [ - del({ targets: ["dist/*"] }), - nodeResolve({ browser: true }), - commonjs(), - typescript(), - yaml(), - json(), - generateDtsBundle(), - terser(), - ], + plugins: [del({ targets: ["dist/*"] }), nodeResolve({ browser: true }), commonjs(), typescript(), yaml(), json(), generateDtsBundle(), terser()], }, { input: "src/handlers/index.ts", @@ -32,15 +23,7 @@ const config = [ dir: "dist/handlers", format: "cjs", }, - plugins: [ - nodeResolve({ browser: true }), - commonjs(), - typescript(), - yaml(), - json(), - generateDtsBundle(), - terser(), - ], + plugins: [nodeResolve({ browser: true }), commonjs(), typescript(), yaml(), json(), generateDtsBundle(), terser()], }, { input: "src/index.ts", @@ -48,15 +31,7 @@ const config = [ dir: "dist/core", format: "cjs", }, - plugins: [ - nodeResolve(), - commonjs(), - typescript(), - yaml(), - json(), - generateDtsBundle(), - terser(), - ], + plugins: [nodeResolve(), commonjs(), typescript(), yaml(), json(), generateDtsBundle(), terser()], }, ]; diff --git a/src/adapters/supabase/helpers/user.ts b/src/adapters/supabase/helpers/user.ts index 4b6523c..7c42723 100644 --- a/src/adapters/supabase/helpers/user.ts +++ b/src/adapters/supabase/helpers/user.ts @@ -53,4 +53,3 @@ export class User extends Super { console.log("Successfully deleted user", { userId }); } } - diff --git a/src/handlers/generate-erc20-permit.ts b/src/handlers/generate-erc20-permit.ts index cdfbd19..9fd496e 100644 --- a/src/handlers/generate-erc20-permit.ts +++ b/src/handlers/generate-erc20-permit.ts @@ -16,7 +16,12 @@ export interface Payload { export async function generateErc20PermitSignature(payload: Payload, username: string, amount: number, tokenAddress: string): Promise; export async function generateErc20PermitSignature(context: Context, username: string, amount: number, tokenAddress: string): Promise; -export async function generateErc20PermitSignature(contextOrPayload: Context | Payload, username: string, amount: number, tokenAddress: string): Promise { +export async function generateErc20PermitSignature( + contextOrPayload: Context | Payload, + username: string, + amount: number, + tokenAddress: string +): Promise { let _logger: Logger; const _username = username; let _walletAddress: string | null | undefined; diff --git a/src/utils/get-fastest-provider.ts b/src/utils/get-fastest-provider.ts index 65bf85f..be8f13f 100644 --- a/src/utils/get-fastest-provider.ts +++ b/src/utils/get-fastest-provider.ts @@ -1,5 +1,5 @@ // @ts-expect-error - no types -import { RPCHandler, HandlerConstructorConfig } from "@ubiquity-dao/rpc-handler" +import { RPCHandler, HandlerConstructorConfig } from "@ubiquity-dao/rpc-handler"; import { JsonRpcProvider } from "ethers"; function getHandler(networkId: number | string) { @@ -13,14 +13,14 @@ function getHandler(networkId: number | string) { networkRpcs: null, }; - return new RPCHandler(config as HandlerConstructorConfig) + return new RPCHandler(config as HandlerConstructorConfig); } export async function getFastestProvider(networkId: number | string): Promise { try { - const handler = getHandler(networkId) - return await handler.getFastestRpcProvider() + const handler = getHandler(networkId); + return await handler.getFastestRpcProvider(); } catch (e) { - throw new Error(`Failed to get fastest provider for networkId: ${networkId}`) + throw new Error(`Failed to get fastest provider for networkId: ${networkId}`); } -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 283242e..68c62d6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,7 +27,7 @@ /* Modules */ "module": "ES2022" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */, // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */