Skip to content

Commit f75aeef

Browse files
philogicaegmolki
andauthored
General fixes and cleaning (#184)
* Missing fields: features / node_hash * Fix wrong fallback logic on switch/add network * Fix examples for devtests * Fix peer deps / linting / sort imports * Fix issues and tests * fix: CI + upgrade to 20.x --------- Co-authored-by: gmolki <[email protected]>
1 parent a479268 commit f75aeef

File tree

92 files changed

+2558
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2558
-728
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18.x
23+
node-version: 20.x
2424
cache: npm
2525

2626
- name: Install dependencies
2727
run: npm install
2828

2929
- name: Run build
30-
run: npm run build
30+
run: npm run build

.github/workflows/doc.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ jobs:
1818
- name: Setup node
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: 18.x
21+
node-version: 20.x
2222
cache: npm
2323

2424
- name: Install dependencies
25-
run: npm install
25+
run: npm ci
26+
27+
- name: Build packages
28+
run: npm run build
2629

2730
- name: Create Doc
2831
run: npm run doc

.github/workflows/lint.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18.x
23+
node-version: 20.x
2424
cache: npm
2525

2626
- name: Install dependencies
27-
run: npm install
27+
run: npm ci
28+
29+
- name: Build packages
30+
run: npm run build
2831

2932
- name: Run lint
30-
run: npm run lint
33+
run: npm run lint

.github/workflows/test.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: [18, 20]
14+
node-version: [20, 22]
1515

1616
steps:
1717
- name: Checkout repository
@@ -28,6 +28,9 @@ jobs:
2828
- name: Install dependencies
2929
run: npm ci
3030

31+
- name: Build packages
32+
run: npm run build
33+
3134
- name: Run tests
3235
run: npm run test
3336
env:

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ Written in Typescript it is meant as a drop in replacement for the [aleph-js lib
1212
npm install aleph-sdk-ts
1313
```
1414

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

1919
## Supported chains
2020

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

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

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

3029
| Chain | Encryption | Browser Wallet | Ledger |
31-
|----------------------|------------|--------------------| ------------------ |
30+
| -------------------- | ---------- | ------------------ | ------------------ |
3231
| Avalanche | :x: | :heavy_check_mark: | :x: |
32+
| Base | :x: | :heavy_check_mark: | :x: |
3333
| Cosmos | :x: | :heavy_check_mark: | :x: |
3434
| Ethereum | :x: | :heavy_check_mark: | :heavy_check_mark: |
3535
| NULS2 | :x: | :x: | :x: |
@@ -64,6 +64,7 @@ This SDK is tested and works, with the following Node.js versions:
6464
| v16.x | :heavy_check_mark: **Full working support** |
6565
| v18.x | :heavy_multiplication_x: Some feature may not work (see notes) |
6666
| v20.x | :heavy_check_mark: **Full working support** |
67+
| v22.x | :heavy_check_mark: **Full working support** |
6768

6869
\* 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.
6970

eslint.config.mjs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { fixupConfigRules } from "@eslint/compat";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import js from "@eslint/js";
5+
import { FlatCompat } from "@eslint/eslintrc";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
const compat = new FlatCompat({
10+
baseDirectory: __dirname,
11+
recommendedConfig: js.configs.recommended,
12+
allConfig: js.configs.all
13+
});
14+
15+
export default [{
16+
ignores: ["**/node_modules/", "**/dist/", "**/docs/"],
17+
}, ...fixupConfigRules(compat.extends(
18+
"eslint:recommended",
19+
"plugin:@typescript-eslint/recommended",
20+
"plugin:prettier/recommended",
21+
"plugin:import/recommended",
22+
)), {
23+
settings: {
24+
"import/resolver": {
25+
node: {
26+
paths: ["packages/**"],
27+
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
28+
},
29+
},
30+
31+
"import/ignore": ["./node_modules", "./dist"],
32+
},
33+
34+
rules: {
35+
"@typescript-eslint/no-explicit-any": "off",
36+
37+
"import/order": ["error", {
38+
"newlines-between": "always",
39+
groups: [["builtin", "external"], ["internal"]],
40+
41+
pathGroups: [{
42+
pattern: "react",
43+
group: "external",
44+
position: "before",
45+
}, {
46+
pattern: "@/**",
47+
group: "internal",
48+
position: "before",
49+
}],
50+
51+
alphabetize: {
52+
order: "asc",
53+
caseInsensitive: true,
54+
},
55+
}],
56+
},
57+
}, {
58+
files: ["examples/**/*.{ts,tsx}"],
59+
rules: {
60+
"import/no-unresolved": "off",
61+
},
62+
}];

examples/stake-on-me/cli.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { logo, separator } from './src/logo'
21
import { askChoices, getNodeList, getRandomNode, keypress } from './src/helpers'
3-
import { GetAccountFromLedger } from '../../src/accounts/providers/Ledger/ethereum'
4-
import { ItemType } from '../../src/messages/types'
5-
import * as post from '../../src/messages/post'
2+
import { logo, separator } from './src/logo'
3+
import { AuthenticatedAlephHttpClient } from '../../packages/client/src'
4+
import { GetAccountFromLedger } from '../../packages/ethereum-ledger/src'
5+
import { ItemType } from '../../packages/message/src/types'
66

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

49-
const stakeMessage = await post.Publish({
50-
account,
51-
APIServer: 'https://api2.aleph.im',
49+
const client = new AuthenticatedAlephHttpClient(account)
50+
const stakeMessage = await client.createPost({
5251
channel: 'FOUNDATION',
5352
storageEngine: ItemType.inline,
5453
postType: 'corechan-operation',

examples/stake-on-me/src/helpers.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as readline from 'readline'
21
import { stdin as input, stdout as output } from 'process'
3-
import * as aggregate from '../../../src/messages/aggregate'
2+
import * as readline from 'readline'
3+
4+
import { AlephHttpClient } from '../../../packages/client/src'
45

56
type NodeListResponse = {
67
corechannel: {
@@ -9,10 +10,11 @@ type NodeListResponse = {
910
}
1011

1112
export const getNodeList = async () => {
12-
const list: NodeListResponse = await aggregate.Get({
13-
address: '0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10',
14-
keys: ['corechannel'],
15-
})
13+
const client = new AlephHttpClient()
14+
const list: NodeListResponse = await client.fetchAggregate(
15+
'0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10',
16+
'corechannel',
17+
)
1618

1719
return list.corechannel.nodes.filter((node) => node.status === 'active' && !node.locked)
1820
}

0 commit comments

Comments
 (0)