-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* format, lint and test scripts. * format * logger test * use cache in CI
- Loading branch information
1 parent
8010130
commit 95050e2
Showing
22 changed files
with
1,066 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Lint & Test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-lint-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run CI | ||
run: pnpm run ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "all", | ||
"printWidth": 80, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "all", | ||
"printWidth": 80, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
{ | ||
"name": "@across-toolkit/sdk", | ||
"version": "0.0.0", | ||
"main": "./dist/index.js", | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"types": "./dist/index.d.mts", | ||
"description": "The official SDK for integrating Across bridge into your dapp.", | ||
"keywords": [ | ||
"bridge", | ||
"sdk", | ||
"crypto", | ||
"blockchain" | ||
], | ||
"homepage": "https://github.com/across-protocol/toolkit", | ||
"bugs": { | ||
"url": "https://github.com/across-protocol/toolkit/issues" | ||
}, | ||
"author": "Across Protocol <[email protected]> (https://across.to)", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/across-protocol/toolkit.git" | ||
}, | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"files": [ | ||
|
@@ -13,20 +29,28 @@ | |
"node": ">=18.0.0" | ||
}, | ||
"scripts": { | ||
"build": "tsup src/index.ts --format esm,cjs --dts", | ||
"dev": "tsup src/index.ts --format esm,cjs --watch --dts", | ||
"build": "tsup src/index.ts --format esm --dts", | ||
"dev": "tsup src/index.ts --format esm --watch --dts", | ||
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"", | ||
"format": "prettier --write .", | ||
"check-format": "prettier --check .", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", | ||
"type-check": "tsc --noEmit" | ||
"type-check": "tsc", | ||
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm", | ||
"test": "vitest run", | ||
"ci": "pnpm run build && pnpm run check-exports pnpm npm run lint && pnpm run test" | ||
}, | ||
"devDependencies": { | ||
"@across-toolkit/eslint-config": "workspace:*", | ||
"@across-toolkit/typescript-config": "workspace:*", | ||
"@arethetypeswrong/cli": "^0.15.4", | ||
"@types/node": "^20", | ||
"eslint": "^8.57.0", | ||
"prettier": "^3.2.5", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.3.3", | ||
"viem": "^2.20.1" | ||
"viem": "^2.20.1", | ||
"vitest": "^2.0.5" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { expect, test } from "vitest"; | ||
|
||
function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
test("adds 1 + 2 to equal 3", () => { | ||
expect(sum(1, 2)).toBe(3); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { expect, test, vi } from "vitest"; | ||
import { AcrossClient } from "../../src/client"; | ||
|
||
const client = AcrossClient.create({ | ||
useTestnet: true, | ||
integratorId: "TEST_ID", | ||
logLevel: "WARN", | ||
}); | ||
|
||
const consoleErrorSpy = vi.spyOn(console, "error"); | ||
const consoleWarnSpy = vi.spyOn(console, "warn"); | ||
const consoleDebugSpy = vi.spyOn(console, "debug"); | ||
|
||
test("Lower log level not logged", () => { | ||
client.log.error("Should not be logged"); | ||
|
||
expect(consoleErrorSpy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
test("Equal log level is logged", () => { | ||
client.log.warn("Should be logged"); | ||
|
||
expect(consoleWarnSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
test("Higher log level is logged", () => { | ||
client.log.debug("Should be logged"); | ||
|
||
expect(consoleDebugSpy).toHaveBeenCalled(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entryPoints: ["src/index.ts"], | ||
format: ["esm"], | ||
dts: true, | ||
outDir: "dist", | ||
clean: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.