-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5681b70
Showing
19 changed files
with
1,954 additions
and
0 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,21 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.sol] | ||
indent_size = 4 | ||
|
||
[*.nr] | ||
indent_size = 4 | ||
|
||
[*.rs] | ||
indent_size = 4 |
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,28 @@ | ||
name: Lint Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
node-version: [20] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run lint test | ||
run: pnpm test |
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,20 @@ | ||
.DS_Store | ||
node_modules | ||
build | ||
dist | ||
.vercel | ||
package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
|
||
.vscode/settings.json | ||
|
||
codegenCache.json | ||
|
||
artifacts | ||
cache | ||
|
||
**/target/*.bak |
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,18 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
dist | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
|
||
target/ | ||
|
||
# Ignore files for PNPM, NPM and YARN | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock |
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,21 @@ | ||
# Contributing | ||
|
||
## Requirements | ||
|
||
- Node.js: recommended to use [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) | ||
- pnpm: `npm install -g pnpm` | ||
|
||
### Project structure | ||
|
||
- `apps/` - Applications | ||
- `packages/` - Packages | ||
|
||
### Common scripts | ||
|
||
Scripts follow the same pattern in all `apps/` and `packages/`: | ||
|
||
- `pnpm dev` - Start in development mode | ||
- `pnpm build` - Build for production | ||
- `pnpm test:lint` - Type-check and lint code | ||
- `pnpm test` - Run tests and `pnpm test:lint` | ||
- `pnpm compile` - If available, compile contracts |
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 @@ | ||
# Shield Labs Monorepo | ||
|
||
Utils and other packages for Shield Labs projects. | ||
|
||
## Contributing | ||
|
||
[Contributing guide](./CONTRIBUTING.md) |
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,14 @@ | ||
{ | ||
"name": "@repo/monorepo", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"test": "pnpm _chore && pnpm -r --parallel test", | ||
"release": "pnpm changeset version && git add . && git commit -m\"chore: release\" && pnpm changeset publish && git push && git push --tags", | ||
"_chore": "pnpm i" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.27.10", | ||
"typescript": "^5.6.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 @@ | ||
dist |
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 @@ | ||
# @shield-labs/utils | ||
|
||
## 0.1.0 | ||
|
||
### Minor Changes | ||
|
||
- e349915: fix: actually build js |
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,38 @@ | ||
{ | ||
"name": "@shield-labs/utils", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"main": "src/index.ts", | ||
"module": "src/index.ts", | ||
"publishConfig": { | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"dev": "pnpm _chore && tsc -w", | ||
"build": "pnpm _chore && rm -rf dist && tsc", | ||
"test": "pnpm test:lint && pnpm test:unit", | ||
"test:unit": "pnpm _chore && vitest run", | ||
"test:lint": "tsc --noEmit --emitDeclarationOnly false && prettier --check .", | ||
"test:lint:fix": "pnpm _chore && prettier --write . && eslint . --fix", | ||
"prepublishOnly": "pnpm test && pnpm build", | ||
"_chore": "pnpm i" | ||
}, | ||
"dependencies": { | ||
"ms": "^2.1.3", | ||
"ts-essentials": "^9.4.1", | ||
"ufo": "^1.5.4" | ||
}, | ||
"devDependencies": { | ||
"@types/ms": "^0.7.34", | ||
"prettier": "^3.2.5", | ||
"typescript": "^5.5.2", | ||
"vitest": "^2.1.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 @@ | ||
export * as utils from "./utils.js"; |
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,10 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { utils } from "./index.js"; | ||
|
||
describe(utils.arrayPadEnd, () => { | ||
test("pads array", () => { | ||
expect(utils.arrayPadEnd([1, 2, 3], 5, 0)).toEqual([1, 2, 3, 0, 0]); | ||
expect(utils.arrayPadEnd([1, 2, 3], 5, 1)).toEqual([1, 2, 3, 1, 1]); | ||
expect(utils.arrayPadEnd([1, 2, 3], 5, 2)).toEqual([1, 2, 3, 2, 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import ms from "ms"; | ||
import { assert } from "ts-essentials"; | ||
|
||
export { joinURL as joinUrl } from "ufo"; | ||
|
||
export function sleep(duration: number | string) { | ||
const durationMs = typeof duration === "number" ? duration : ms(duration); | ||
return new Promise<void>((resolve) => setTimeout(resolve, durationMs)); | ||
} | ||
|
||
export function iife<T>(fn: () => T): T { | ||
return fn(); | ||
} | ||
|
||
export function arrayPadEnd<T>( | ||
array: T[], | ||
targetLength: number, | ||
padValue: T, | ||
): T[] { | ||
assert(array.length <= targetLength, "arrayPadEnd: array too long"); | ||
const newArray = array.slice(); | ||
while (newArray.length < targetLength) { | ||
newArray.push(padValue); | ||
} | ||
return newArray; | ||
} | ||
|
||
export function shortAddress(address: string) { | ||
return `${address.slice(0, 6)}...${address.slice(-4)}`; | ||
} | ||
|
||
export function assertConnected(account: unknown): asserts account { | ||
assert(account, "account is not connected"); | ||
} | ||
|
||
export function lazyValue<T>(value: () => T): () => T { | ||
let initialized = false; | ||
let result: T; | ||
return () => { | ||
if (!initialized) { | ||
initialized = true; | ||
result = value(); | ||
} | ||
return result; | ||
}; | ||
} | ||
|
||
export function isAddressEqual(a: string, b: string) { | ||
return a.toLowerCase() === b.toLowerCase(); | ||
} | ||
|
||
/** | ||
* Prefer this over `value.toString()` because it's typesafe(you can't accidentally call .toString() on another type when refactoring) | ||
*/ | ||
export function bigIntToString(value: bigint) { | ||
return value.toString(); | ||
} | ||
|
||
export function errorToString(error: any) { | ||
return String(error?.message || error); | ||
} | ||
|
||
export function removePrefixOrThrow(str: string, prefix: string) { | ||
if (!str.startsWith(prefix)) { | ||
throw new Error(`string does not start with "${prefix}"`); | ||
} | ||
|
||
return str.slice(prefix.length); | ||
} |
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,6 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
} | ||
} |
Oops, something went wrong.