Skip to content

Commit

Permalink
Merge branch 'feat/npm-package' into feat/encode-decode-permits
Browse files Browse the repository at this point in the history
# Conflicts:
#	knip.ts
#	src/utils/helpers.ts
#	tests/generate-erc721-permit.test.ts
  • Loading branch information
gentlementlegen committed Apr 8, 2024
2 parents 4defbd7 + 1585826 commit 0ed4694
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 851 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"libsodium",
"Libsodium",
"ciphertext",
"tweetnacl"
"tweetnacl",
"typeguards"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
node-version: "20.10.0"

- name: Install dependencies
run: yarn i --immutable --immutable-cache --check-cache
run: yarn install --immutable --immutable-cache --check-cache

- name: Generate Permit
run: npx tsx ./src/index.ts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Run Jest testing suite
on:
workflow_dispatch:
pull_request_target:
pull_request:
types: [opened, synchronize]

env:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Knip-reporter

on:
workflow_run:
workflows: ["Knip"]
types:
- completed

jobs:
knip-reporter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: yarn install

- uses: actions/download-artifact@v4
with:
name: knip-results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Read pr number
id: pr-number
uses: juliangruber/read-file-action@v1
with:
path: ./pr-number.txt
trim: true

- name: Report knip results to pull request
if: ${{ github.event.workflow_run.conclusion != 'success' }}
uses: gitcoindev/knip-reporter@main
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
json_input: true
json_input_file_name: knip-results.json
pull_request_number: ${{ steps.pr-number.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 13 additions & 9 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Knip
on:
pull_request:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
Expand All @@ -20,11 +18,17 @@ jobs:
- name: Install toolchain
run: yarn install

- name: Report knip results to pull request
uses: Codex-/knip-reporter@v2
- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt

- name: Run Knip
run: yarn knip || yarn -s knip --reporter json > knip-results.json

- name: Upload knip result
if: failure()
uses: actions/upload-artifact@v4
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
name: knip-results
path: |
knip-results.json
pr-number.txt
8 changes: 4 additions & 4 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
with:
release-type: node
package-name: @ubiquibot/permit-generation
package-name: "@ubiquibot/permit-generation"
default-branch: main
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
registry-url: https://registry.npmjs.org/
Expand Down
11 changes: 8 additions & 3 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/index.ts"],
entry: ["src/main.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts", "src/adapters/supabase/types/database.ts"],
ignore: [],
ignoreBinaries: ["publish", "src/adapters/supabase/types/database.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: [],
ignoreDependencies: ["ts-node"],
jest: {
config: ["jest.config.ts"],
entry: ["tests/*.ts"],
},
};

export default config;
18 changes: 4 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,32 @@
"@actions/github": "^6.0.0",
"@octokit/rest": "^20.0.2",
"@octokit/webhooks": "^13.1.0",
"@octokit/webhooks-types": "^7.3.1",
"@sinclair/typebox": "^0.32.5",
"@supabase/supabase-js": "2.42.0",
"@uniswap/permit2-sdk": "^1.2.0",
"blake2b": "^2.1.4",
"decimal.js": "^10.4.3",
"dotenv": "^16.4.4",
"ethers": "6.11.1",
"libsodium-wrappers": "^0.7.13",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1"
"libsodium-wrappers": "^0.7.13"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240117.0",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@cspell/dict-node": "^4.0.3",
"@cspell/dict-software-terms": "^3.3.18",
"@cspell/dict-typescript": "^3.1.2",
"@octokit/types": "^12.6.0",
"@jest/globals": "29.7.0",
"@jest/types": "29.6.3",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-yaml": "4.1.2",
"@types/jest": "29.5.12",
"@types/libsodium-wrappers": "^0.7.8",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"cspell": "^8.4.0",
"esbuild": "^0.20.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-sonarjs": "^0.24.0",
"husky": "^9.0.11",
"jest": "29.7.0",
Expand All @@ -79,8 +70,7 @@
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"wrangler": "^3.23.0"
"typescript": "^5.3.3"
},
"lint-staged": {
"*.ts": [
Expand Down
4 changes: 4 additions & 0 deletions src/adapters/supabase/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ export type Database = {

type PublicSchema = Database[Extract<keyof Database, "public">];

/** @public */
export type Tables<
PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"]) | { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
Expand All @@ -936,6 +937,7 @@ export type Tables<
: never
: never;

/** @public */
export type TablesInsert<
PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never,
Expand All @@ -953,6 +955,7 @@ export type TablesInsert<
: never
: never;

/** @public */
export type TablesUpdate<
PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never,
Expand All @@ -970,6 +973,7 @@ export type TablesUpdate<
: never
: never;

/** @public */
export type Enums<
PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] | { schema: keyof Database },
EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] : never = never,
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/generate-erc721-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export async function generateErc721PermitSignature(
}

if (!_nftContractAddress) {
const errorMesage = "NFT contract address is not defined";
_logger.error(errorMesage);
throw new Error(errorMesage);
const errorMessage = "NFT contract address is not defined";
_logger.error(errorMessage);
throw new Error(errorMessage);
}

let provider;
Expand Down
9 changes: 0 additions & 9 deletions src/types/github.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/types/webhook-events.ts

This file was deleted.

79 changes: 0 additions & 79 deletions src/utils/helpers.ts

This file was deleted.

1 change: 1 addition & 0 deletions tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context } from "../src/types/context";
import { jest } from "@jest/globals";

export const NFT_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000003";
export const SPENDER = 123;
Expand Down
3 changes: 2 additions & 1 deletion tests/generate-erc20-permit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { generateErc20PermitSignature } from "../src/handlers/generate-erc20-permit";
import { Context } from "../src/types/context";
import { SPENDER, mockContext } from "./constants";
import { describe, expect, it, beforeEach, jest } from "@jest/globals";

describe("generateErc20PermitSignature", () => {
let context: Context;
Expand All @@ -25,7 +26,7 @@ describe("generateErc20PermitSignature", () => {
eq: jest.fn().mockReturnValue({
select: jest.fn().mockReturnValue({
eq: jest.fn().mockReturnValue({
single: jest.fn().mockResolvedValue({ id: 123 }),
single: jest.fn().mockReturnValue({ id: 123 }),
}),
}),
}),
Expand Down
Loading

0 comments on commit 0ed4694

Please sign in to comment.