Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 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
6 changes: 4 additions & 2 deletions .github/workflows/common-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ jobs:
uses: ./.github/actions/yarn-install
- name: Build dependencies
shell: bash
run: yarn workspace @selfxyz/common build
run: |
set -euo pipefail
yarn workspace @selfxyz/common build
- name: Yarn types
shell: bash
run: yarn types
run: CI=true yarn types

test-common:
runs-on: ubuntu-latest
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/sdk-core-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: SDK Core CI

on:
push:
paths:
- "sdk/core/**"
- ".github/workflows/sdk-core-ci.yml"
pull_request:
paths:
- "sdk/core/**"
- ".github/workflows/sdk-core-ci.yml"

jobs:
# Build dependencies once and cache for other jobs
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/yarn-install

- name: Build dependencies
shell: bash
run: |
yarn workspace @selfxyz/common build
yarn workspace @selfxyz/contracts build
cd sdk/core && yarn generate-typechain
yarn workspace @selfxyz/core build

- name: Cache build artifacts
uses: actions/cache/save@v4
with:
path: |
common/dist
contracts/artifacts
contracts/cache
sdk/core/dist
sdk/core/.tsbuildinfo
sdk/core/node_modules/.cache
common/node_modules/.cache
sdk/core/src/typechain-types
key: sdk-core-build-${{ github.sha }}

# Quality checks job
quality-checks:
runs-on: ubuntu-latest
needs: build
defaults:
run:
working-directory: ./sdk/core
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/yarn-install

- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
common/dist
contracts/artifacts
contracts/cache
sdk/core/dist
sdk/core/.tsbuildinfo
sdk/core/node_modules/.cache
common/node_modules/.cache
sdk/core/src/typechain-types
key: sdk-core-build-${{ github.sha }}
fail-on-cache-miss: true

- name: Generate typechain types (if needed)
run: yarn generate-typechain

- name: Copy ABI files
run: yarn copy-abi

- name: Lint
run: yarn lint

- name: Type check
run: yarn types

- name: Test build output
run: |
echo "Testing ESM import..."
node -e "import('@selfxyz/core').then(m => console.log('✅ ESM import successful')).catch(e => console.error('❌ ESM import failed:', e.message))"

echo "Testing CJS require..."
node -e "try { const m = require('@selfxyz/core'); console.log('✅ CJS require successful'); } catch(e) { console.error('❌ CJS require failed:', e.message); }"

- name: Verify exports
run: |
echo "Verifying package exports..."
node -e "
const pkg = require('./package.json');
console.log('Package exports:', JSON.stringify(pkg.exports, null, 2));
console.log('Main:', pkg.main);
console.log('Module:', pkg.module);
console.log('Types:', pkg.types);
"
14 changes: 10 additions & 4 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import "solidity-coverage";
import "hardhat-gas-reporter";
import "hardhat-contract-sizer";

// Support PRIVATE_KEYS (comma-separated) or fallback to PRIVATE_KEY, trim & filter out empty strings
const accountsEnv = process.env.PRIVATE_KEYS
? process.env.PRIVATE_KEYS.split(',').map(k => k.trim()).filter(Boolean)
: (process.env.PRIVATE_KEY?.trim() ? [process.env.PRIVATE_KEY.trim()] : []);
const accounts = accountsEnv.length ? accountsEnv : undefined;

const config: HardhatUserConfig = {
solidity: {
version: "0.8.28",
Expand Down Expand Up @@ -44,22 +50,22 @@ const config: HardhatUserConfig = {
mainnet: {
chainId: 1,
url: process.env.MAINNET_RPC_URL || "https://eth.llamarpc.com",
accounts: [process.env.PRIVATE_KEY as string],
...(accounts && { accounts }),
},
sepolia: {
chainId: 11155111,
url: process.env.SEPOLIA_RPC_URL || "https://eth-sepolia.public.blastapi.io",
accounts: [process.env.PRIVATE_KEY as string],
...(accounts && { accounts }),
},
celo: {
chainId: 42220,
url: process.env.CELO_RPC_URL || "https://forno.celo.org",
accounts: [process.env.PRIVATE_KEY as string],
...(accounts && { accounts }),
},
alfajores: {
chainId: 44787,
url: process.env.CELO_ALFAJORES_RPC_URL || "https://alfajores-forno.celo-testnet.org",
accounts: [process.env.PRIVATE_KEY as string],
...(accounts && { accounts }),
},
},
etherscan: {
Expand Down
88 changes: 88 additions & 0 deletions sdk/core/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
module.exports = {
root: true,
env: {
node: true,
es6: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: { jsx: false },
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
plugins: ['simple-import-sort', 'import', 'sort-exports'],
ignorePatterns: [
'node_modules/',
'dist/',
'*.js.map',
'*.d.ts',
'typechain-types/',
'src/abi/',
'scripts/',
],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
rules: {
'import/order': 'off',
'no-duplicate-imports': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [['^node:'], ['^node:.*/'], ['^[a-zA-Z]'], ['^@selfxyz/'], ['^[./]']],
},
],
'sort-exports/sort-exports': [
'error',
{ sortDir: 'asc', ignoreCase: false, sortExportKindFirst: 'type' },
],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'ExportAllDeclaration',
message: 'export * is forbidden. Use selective exports for better tree shaking.',
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
},
overrides: [
{
files: ['*.cjs'],
env: {
node: true,
commonjs: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'script',
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'no-undef': 'off',
},
},
],
};
1 change: 0 additions & 1 deletion sdk/core/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
Expand Down
Loading
Loading