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 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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

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

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: npm

- name: Install dependencies
run: npm install

- name: Run build
run: npm run build
run: npm run build
7 changes: 5 additions & 2 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: npm

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

- name: Build packages
run: npm run build

- name: Create Doc
run: npm run doc
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
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
run: npm run lint
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]

steps:
- name: Checkout repository
Expand All @@ -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
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ Written in Typescript it is meant as a drop in replacement for the [aleph-js lib
npm install aleph-sdk-ts
```

- An API reference [on the repository github pages](https://aleph-im.github.io/aleph-sdk-ts/index.html)
- For guides and use-cases check the [Aleph TS SDK Gitbook](https://aleph-im.gitbook.io/ts-sdk/)
- Some examples are available in the `/examples` directory.
- An API reference [on the repository github pages](https://aleph-im.github.io/aleph-sdk-ts/index.html)
- For guides and use-cases check the [Aleph TS SDK Gitbook](https://aleph-im.gitbook.io/ts-sdk/)
- Some examples are available in the `/examples` directory.

## Supported chains

This is the list of currently supported Account types. For each of them you can:

- Retrieve an account from a private key or mnemonic (or generate one on the fly).
- Sign and send messages on the Aleph Network
- Some allow you to retrieve an account from a **browser based** wallet (ex: Metamask), or from a **Ledger** wallet.
- Retrieve an account from a private key or mnemonic (or generate one on the fly).
- Sign and send messages on the Aleph Network
- Some allow you to retrieve an account from a **browser based** wallet (ex: Metamask), or from a **Ledger** wallet.

[Previous versions](https://npmjs.com/package/aleph-sdk-ts) of the Typescript SDK allowed you to **encrypt** messages.
This has been

| Chain | Encryption | Browser Wallet | Ledger |
|----------------------|------------|--------------------| ------------------ |
| -------------------- | ---------- | ------------------ | ------------------ |
| Avalanche | :x: | :heavy_check_mark: | :x: |
| Base | :x: | :heavy_check_mark: | :x: |
| Cosmos | :x: | :heavy_check_mark: | :x: |
| Ethereum | :x: | :heavy_check_mark: | :heavy_check_mark: |
| NULS2 | :x: | :x: | :x: |
Expand Down Expand Up @@ -64,6 +64,7 @@ This SDK is tested and works, with the following Node.js versions:
| v16.x | :heavy_check_mark: **Full working support** |
| v18.x | :heavy_multiplication_x: Some feature may not work (see notes) |
| v20.x | :heavy_check_mark: **Full working support** |
| v22.x | :heavy_check_mark: **Full working support** |

\* Due to changes in OpenSSL in Node v18, some chains helper may not work. If you encounter bugs using Node v18, you might want to consider using the `--openssl-legacy-provider` feature flag while running your project.

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