diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..13480d7 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,21 @@ +/** @type { import("eslint").Linter.Config } */ +module.exports = { + root: true, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier' + ], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + parserOptions: { + sourceType: 'module', + ecmaVersion: 2020, + extraFileExtensions: ['.svelte'] + }, + env: { + browser: true, + es2017: true, + node: true + } +}; diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3cd44e..1aeec9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,18 +20,15 @@ jobs: - name: Install Bun run: | curl -fsSL https://bun.sh/install | bash - echo 'export BUN_INSTALL="$HOME/.bun"' >> $GITHUB_ENV - echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> $GITHUB_ENV - source $GITHUB_ENV - name: Verify Bun installation - run: bun --version + run: ~/.bun/bin/bun --version - name: Install dependencies - run: bun install + run: ~/.bun/bin/bun install - name: Run checks - run: bun run make check + run: make check - name: Run tests - run: bun run make test + run: ~/.bun/bin/bun run test diff --git a/bun.lockb b/bun.lockb index f67bd4c..733c0d3 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 8b988d0..e0d0455 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,28 @@ { - "name": "lighthouse", - "module": "src/index.ts", - "type": "module", - "scripts": { - "start": "bun src/index.ts", - "build": "bun build src/index.ts --compile --outfile dist/lighthouse", - "dev": "bun --hot src/index.ts" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "overrides": { - "@wharfkit/antelope": "^1.0.7" - }, - "dependencies": { - "@wharfkit/antelope": "^1.0.7", - "@wharfkit/common": "^1.2.2", - "bun-types": "latest", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0" - }, - "devDependencies": { - "@types/bun": "^1.0.8" - } + "name": "lighthouse", + "module": "src/index.ts", + "type": "module", + "scripts": { + "start": "bun src/index.ts", + "build": "bun build src/index.ts --compile --outfile dist/lighthouse", + "dev": "bun --hot src/index.ts" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "overrides": { + "@wharfkit/antelope": "^1.0.7" + }, + "dependencies": { + "@typescript-eslint/eslint-plugin": "^7.14.1", + "@wharfkit/antelope": "^1.0.7", + "@wharfkit/common": "^1.2.2", + "bun-types": "latest" + }, + "devDependencies": { + "@types/bun": "^1.0.8", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "svelte-eslint-parser": "^0.39.2" + } } diff --git a/src/chains.ts b/src/chains.ts index 7cb54ca..8ecaddc 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -1,10 +1,4 @@ -import { ChainDefinition, Chains } from "@wharfkit/common"; - -export type Chain = ChainDefinition | { - id: string; - name: string; - url: string; -}; +import { Chains } from "@wharfkit/common"; const AYETU_MAINNET = { id: "9b06067cf9f0a293e854cbdbcf4bc0292bbf1137dd01d3d9300f403706444504", diff --git a/src/index.ts b/src/index.ts index 779fbc1..7b039be 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import { serve } from "bun"; -import { APIClient, PublicKey } from "@wharfkit/antelope"; -import { MAINNET_CHAINS, TESTNET_CHAINS, type Chain } from "./chains"; +import { API, APIClient, PublicKey } from "@wharfkit/antelope"; +import { MAINNET_CHAINS, TESTNET_CHAINS } from "./chains"; +import type { Chain } from "./types"; export const accountLookup = async (req: Request) => { const url = new URL(req.url); @@ -42,8 +43,8 @@ export const lookupNetwork = async (publicKey: PublicKey, chain: Chain, apiClien const networkRequest = async (publicKey: PublicKey, chain: Chain, apiClient?: APIClient) => { const client = apiClient || new APIClient(chain); - const response = await client.v1.chain.get_accounts_by_authorizers({ keys: [publicKey] }); - return response.accounts.map((account: any) => ({ + const response: API.v1.AccountsByAuthorizers = await client.v1.chain.get_accounts_by_authorizers({ keys: [publicKey] }); + return response.accounts.map(account => ({ actor: account.account_name, permission: account.permission_name, })); diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..73786f0 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,7 @@ +import type { ChainDefinition } from "@wharfkit/common"; + +export type Chain = ChainDefinition | { + id: string; + name: string; + url: string; +};