Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General fixes and cleaning #184

Merged
merged 8 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintrc.json

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
cache: npm

- name: Install dependencies
run: npm install
run: npm ci

- name: Build packages
run: npm run build

- name: Run lint
run: npm run lint
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

- name: Run tests
run: npm run test
env:
Expand Down
62 changes: 62 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { fixupConfigRules } from "@eslint/compat";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["**/node_modules/", "**/dist/", "**/docs/"],
}, ...fixupConfigRules(compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:import/recommended",
)), {
settings: {
"import/resolver": {
node: {
paths: ["packages/**"],
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
},
},

"import/ignore": ["./node_modules", "./dist"],
},

rules: {
"@typescript-eslint/no-explicit-any": "off",

"import/order": ["error", {
"newlines-between": "always",
groups: [["builtin", "external"], ["internal"]],

pathGroups: [{
pattern: "react",
group: "external",
position: "before",
}, {
pattern: "@/**",
group: "internal",
position: "before",
}],

alphabetize: {
order: "asc",
caseInsensitive: true,
},
}],
},
}, {
files: ["examples/**/*.{ts,tsx}"],
rules: {
"import/no-unresolved": "off",
},
}];
13 changes: 6 additions & 7 deletions examples/stake-on-me/cli.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { logo, separator } from './src/logo'
import { askChoices, getNodeList, getRandomNode, keypress } from './src/helpers'
import { GetAccountFromLedger } from '../../src/accounts/providers/Ledger/ethereum'
import { ItemType } from '../../src/messages/types'
import * as post from '../../src/messages/post'
import { logo, separator } from './src/logo'
import { AuthenticatedAlephHttpClient } from '../../packages/client/src'
import { GetAccountFromLedger } from '../../packages/ethereum-ledger/src'
import { ItemType } from '../../packages/message/src/types'

const main = async () => {
console.log(logo)
Expand Down Expand Up @@ -46,9 +46,8 @@ const main = async () => {
console.log(separator)
console.log('Sending a stake message on selected Node. Please check your Ledger to sign the message.')

const stakeMessage = await post.Publish({
account,
APIServer: 'https://api2.aleph.im',
const client = new AuthenticatedAlephHttpClient(account)
const stakeMessage = await client.createPost({
channel: 'FOUNDATION',
storageEngine: ItemType.inline,
postType: 'corechan-operation',
Expand Down
14 changes: 8 additions & 6 deletions examples/stake-on-me/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as readline from 'readline'
import { stdin as input, stdout as output } from 'process'
import * as aggregate from '../../../src/messages/aggregate'
import * as readline from 'readline'

import { AlephHttpClient } from '../../../packages/client/src'

type NodeListResponse = {
corechannel: {
Expand All @@ -9,10 +10,11 @@ type NodeListResponse = {
}

export const getNodeList = async () => {
const list: NodeListResponse = await aggregate.Get({
address: '0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10',
keys: ['corechannel'],
})
const client = new AlephHttpClient()
const list: NodeListResponse = await client.fetchAggregate(
'0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10',
'corechannel',
)

return list.corechannel.nodes.filter((node) => node.status === 'active' && !node.locked)
}
Expand Down
Loading
Loading