Skip to content

Commit 5f48889

Browse files
committed
feat: initial composable setup
1 parent 3b7544b commit 5f48889

15 files changed

Lines changed: 575 additions & 0 deletions

File tree

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets).
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

CLAUDE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
Default to using Bun instead of Node.js.
3+
4+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
5+
- Use `bun test` instead of `jest` or `vitest`
6+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
7+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
8+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
9+
- Bun automatically loads .env, so don't use dotenv.
10+
11+
12+
## Documentation
13+
14+
Always use Context7 (`mcp__context7__resolve-library-id` + `mcp__context7__query-docs`) for library/API documentation, code generation, and setup or configuration steps without waiting for an explicit ask.
15+
16+
## Testing
17+
18+
Use `bun test` to run tests.
19+
20+
```ts#index.test.ts
21+
import { test, expect } from "bun:test";
22+
23+
test("hello world", () => {
24+
expect(1).toBe(1);
25+
});
26+
```

biome.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"includes": [
11+
"**/*.ts",
12+
"**/*.tsx",
13+
"**/*.js",
14+
"**/*.jsx",
15+
"**/*.json",
16+
"!**/node_modules",
17+
"!**/dist",
18+
"!**/.changeset"
19+
]
20+
},
21+
"formatter": {
22+
"enabled": true,
23+
"indentStyle": "space",
24+
"indentWidth": 2,
25+
"lineWidth": 100,
26+
"lineEnding": "lf"
27+
},
28+
"javascript": {
29+
"formatter": {
30+
"quoteStyle": "single",
31+
"jsxQuoteStyle": "double",
32+
"semicolons": "always",
33+
"trailingCommas": "all",
34+
"arrowParentheses": "always"
35+
}
36+
},
37+
"linter": {
38+
"enabled": true,
39+
"rules": {
40+
"recommended": true,
41+
"correctness": {
42+
"noUnusedVariables": "error",
43+
"noUnusedImports": "error"
44+
},
45+
"suspicious": {
46+
"noDebugger": "error",
47+
"noExplicitAny": "error",
48+
"noConsole": "warn",
49+
"noTsIgnore": "error"
50+
},
51+
"style": {
52+
"useConst": "error",
53+
"useTemplate": "error",
54+
"useImportType": "error",
55+
"useExportType": "error",
56+
"noNonNullAssertion": "error",
57+
"noParameterAssign": "error",
58+
"noInferrableTypes": "error",
59+
"useConsistentArrayType": "error",
60+
"useShorthandFunctionType": "error",
61+
"useConsistentTypeDefinitions": "error",
62+
"useDefaultParameterLast": "error"
63+
}
64+
}
65+
},
66+
"assist": {
67+
"enabled": true,
68+
"actions": {
69+
"source": {
70+
"organizeImports": "on"
71+
}
72+
}
73+
}
74+
}

bun.lock

Lines changed: 274 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src';

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "composable-sdk",
3+
"module": "index.ts",
4+
"type": "module",
5+
"scripts": {
6+
"lint": "biome lint --write .",
7+
"format": "biome format --write .",
8+
"check": "biome check --write .",
9+
"release": "changeset publish",
10+
"version": "changeset version"
11+
},
12+
"devDependencies": {
13+
"@biomejs/biome": "2.4.9",
14+
"@changesets/cli": "2.30.0",
15+
"@types/bun": "latest"
16+
},
17+
"peerDependencies": {
18+
"typescript": "^5",
19+
"viem": "^2.47.6"
20+
}
21+
}

src/core/contract.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { Abi } from 'abitype';
2+
import type {
3+
Address,
4+
ContractFunctionArgs,
5+
ContractFunctionName,
6+
ContractFunctionReturnType,
7+
PublicClient,
8+
} from 'viem';
9+
10+
// ---------------------------------------------------------------------------
11+
// Contract
12+
// ---------------------------------------------------------------------------
13+
14+
interface ContractInstance<TAbi extends Abi | readonly unknown[]> {
15+
readonly address: Address;
16+
readonly abi: TAbi;
17+
read<
18+
TFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,
19+
const TArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName>,
20+
>(
21+
functionName: TFunctionName,
22+
args: TArgs,
23+
): Promise<ContractFunctionReturnType<TAbi, 'pure' | 'view', TFunctionName, TArgs>>;
24+
}
25+
26+
export function contract<const TAbi extends Abi | readonly unknown[]>(
27+
publicClient: PublicClient,
28+
address: Address,
29+
abi: TAbi,
30+
): ContractInstance<TAbi> {
31+
return {
32+
address,
33+
abi,
34+
read(functionName, args) {
35+
return publicClient.readContract({ abi, address, functionName, args });
36+
},
37+
};
38+
}

src/core/encoding.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Runtime composable encoding

0 commit comments

Comments
 (0)