Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ repos:
hooks:
- id: gitleaks
args: ['--verbose', '--redact']

- repo: local
hooks:
- id: eslint
name: eslint (pnpm lint)
entry: node scripts/precommit-eslint-core-sdk.mjs
language: system
pass_filenames: true
files: ^packages/core-sdk/.*\.(ts|tsx|js|jsx|mjs|cjs)$
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ This section provides the instructions on how to build Story Protocol SDK from s
- Install PNPM: Execute `npm install -g pnpm`
- Install TypeScript: Run `pnpm add typescript -D`
- Install Yalc: Use `npm install -g yalc`
- Install dependencies: `pnpm install`
- Install pre-commit (to enable git hooks):
- Option A (Homebrew): `brew install pre-commit`
- Option B (pipx): `brew install pipx && pipx ensurepath && pipx install pre-commit`
- Enable git hooks: `pre-commit install`
- Verify: confirm `./.git/hooks/pre-commit` exists, or run `pre-commit --version`

#### Steps for Using Yalc for Local Testing of Core-SDK

Expand Down
1 change: 1 addition & 0 deletions packages/core-sdk/src/utils/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const simulateAndWriteContract = async ({
const txHash = await wallet.writeContract(request as WriteContractParameters);
const receipt = await rpcClient.waitForTransactionReceipt({ hash: txHash });
return { txHash, receipt };

};
21 changes: 21 additions & 0 deletions scripts/precommit-eslint-core-sdk.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { spawnSync } from 'node:child_process';

const CORE_SDK_PREFIX = 'packages/core-sdk/';

const inputFiles = process.argv.slice(2);
const coreSdkFiles = inputFiles
.filter((f) => typeof f === 'string' && f.startsWith(CORE_SDK_PREFIX))
.map((f) => f.slice(CORE_SDK_PREFIX.length));

// If nothing matched, do nothing (pre-commit may still call the hook).
if (coreSdkFiles.length === 0) {
process.exit(0);
}

const result = spawnSync(
'pnpm',
['-C', 'packages/core-sdk', 'lint', '--', ...coreSdkFiles],
{ stdio: 'inherit' },
);

process.exit(result.status ?? 1);
Loading