Skip to content

Commit 6b09ef8

Browse files
Merge pull request #65 from jcam1/develop
Release 2025-03-04 23:57:58 +0900
2 parents e687217 + d7b0b75 commit 6b09ef8

Some content is hidden

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

77 files changed

+2394
-2205
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runs:
66
steps:
77
- uses: actions/setup-node@v4
88
with:
9-
node-version: 20
9+
node-version: 20.12.0
1010
registry-url: 'https://registry.npmjs.org'
1111
scope: '@jpyc'
1212
- name: Install dependencies

.github/workflows/check.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
outputs:
1717
root: ${{ steps.filter.outputs.root }}
1818
core: ${{ steps.filter.outputs.core }}
19-
v1: ${{ steps.filter.outputs.v1 }}
2019
steps:
2120
- uses: actions/checkout@v4
2221
- uses: dorny/paths-filter@v3
@@ -27,10 +26,10 @@ jobs:
2726
- '.github/**'
2827
- 'docs/**'
2928
- 'README.md'
29+
- 'package.json'
30+
- 'yarn.lock'
3031
core:
3132
- 'packages/core/**'
32-
v1:
33-
- 'packages/v1/**'
3433
3534
check-root:
3635
needs: detect-changes
@@ -65,21 +64,3 @@ jobs:
6564
run: yarn run format:dry-run
6665
- name: Run tests
6766
run: yarn run test
68-
69-
check-v1:
70-
needs: detect-changes
71-
if: ${{ needs.detect-changes.outputs.v1 == 'true' }}
72-
runs-on: ubuntu-latest
73-
defaults:
74-
run:
75-
working-directory: ./packages/v1
76-
timeout-minutes: 5
77-
steps:
78-
- uses: actions/checkout@v4
79-
- uses: ./.github/actions/install-dependencies
80-
- name: Compile
81-
run: yarn run compile
82-
- name: Lint
83-
run: yarn run lint:dry-run
84-
- name: Format
85-
run: yarn run format:dry-run

.github/workflows/deploy-docs.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: deploy documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- 'docs/**'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: 'pages'
18+
cancel-in-progress: false
19+
20+
jobs:
21+
format:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: 'recursive'
28+
29+
- uses: ./.github/actions/install-dependencies
30+
31+
- name: Check format
32+
run: |
33+
yarn run format:dry-run docs
34+
35+
build:
36+
needs: format
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
with:
42+
submodules: 'recursive'
43+
44+
- name: Setup Pages
45+
uses: actions/configure-pages@v5
46+
47+
- name: Upload artifact
48+
uses: actions/upload-pages-artifact@v3
49+
with:
50+
path: './docs/core/html'
51+
52+
deploy:
53+
needs: build
54+
runs-on: ubuntu-latest
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
types: [closed]
88
paths:
99
- 'packages/core/**'
10-
- 'packages/v1/**'
1110

1211
jobs:
1312
detect-changes:
@@ -17,7 +16,6 @@ jobs:
1716
pull-requests: read
1817
outputs:
1918
core: ${{ steps.filter.outputs.core }}
20-
v1: ${{ steps.filter.outputs.v1 }}
2119
steps:
2220
- uses: actions/checkout@v4
2321
- uses: dorny/paths-filter@v3
@@ -26,8 +24,6 @@ jobs:
2624
filters: |
2725
core:
2826
- 'packages/core/**'
29-
v1:
30-
- 'packages/v1/**'
3127
3228
push-git-tag:
3329
runs-on: ubuntu-latest
@@ -88,21 +84,3 @@ jobs:
8884
with:
8985
working-directory: ./packages/core
9086
node-auth-token: ${{ secrets.NPM_TOKEN }}
91-
92-
publish-v1:
93-
needs: [detect-changes, publish-release-note]
94-
if: ${{ needs.detect-changes.outputs.v1 == 'true' }}
95-
runs-on: ubuntu-latest
96-
defaults:
97-
run:
98-
working-directory: ./packages/v1
99-
timeout-minutes: 5
100-
steps:
101-
- uses: actions/checkout@v4
102-
- uses: ./.github/actions/install-dependencies
103-
- name: Build package
104-
run: yarn run compile
105-
- uses: ./.github/actions/publish-package
106-
with:
107-
working-directory: ./packages/v1
108-
node-auth-token: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ dist
119119
# TernJS port file
120120
.tern-port
121121

122-
# Stores VSCode versions used for testing VSCode extensions
122+
# VS Code
123+
.vscode
123124
.vscode-test
125+
cspell.json
124126

125127
# yarn v2
126128
.yarn/cache
@@ -131,4 +133,3 @@ dist
131133

132134
# Misc
133135
.DS_Store
134-
.vscode

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# JPYC Node SDKs
1+
# JPYC SDKs
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
44
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/jcam1/sdks/issues/new/choose)
55

6-
Monorepo for JPYC Node SDKs.
6+
Monorepo for JPYC SDKs.
77

88
## 🌈 Available SDKs
99

@@ -12,7 +12,6 @@ Please refer to `README`s of each SDK for the version specific details.
1212
| SDK | `README` |
1313
| -----: | :----------------------------------------- |
1414
| `core` | [packages/core](./packages/core/README.md) |
15-
| `v1` | [packages/v1](./packages/v1/README.md) |
1615

1716
## 🔨 Development
1817

@@ -52,17 +51,20 @@ $ yarn workspace ${workspace_name} run ${command_name}
5251

5352
### Dependencies
5453

55-
To add dependencies, run one of the following. To prevent unexpected behaviors, always pin the exact versions of the dependencies to be installed.
54+
To add dependencies, run one of the following.
5655

5756
```sh
5857
# Add dependencies to the specified workspace
59-
$ yarn workspace ${workspace_name} add -E ${dependencies}
58+
$ yarn workspace ${workspace_name} add ${dependencies}
6059

6160
# Add dev dependencies to the specified workspace
62-
$ yarn workspace ${workspace_name} add -E -D ${dependencies}
61+
$ yarn workspace ${workspace_name} add -D ${dependencies}
62+
63+
# Add dependencies to the workspaces root
64+
$ yarn add -W ${dependencies}
6365

6466
# Add dev dependencies to the workspaces root
65-
$ yarn add -E -D -W ${dependencies}
67+
$ yarn add -W -D ${dependencies}
6668
```
6769

6870
To remove dependencies, run one of the following.
@@ -113,4 +115,4 @@ Now, write code to implement the proposed features and/or to fix bugs.
113115

114116
### 5. Open a Pull Request
115117

116-
Finally, open a new PR from your branch to `develop` branch to describe what you'll have done.
118+
Finally, open a new PR from your branch to `develop` branch, and describe what you'll have done.

docs/core/README.md

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,109 @@
1-
**@jpyc/sdk-core**[**Docs**](globals.md)
1+
**@jpyc/sdk-core**
22

33
---
44

55
# JPYC Core SDK
66

7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
78
![build](https://github.com/jcam1/sdks/actions/workflows/check.yml/badge.svg)
8-
[![Node version](https://img.shields.io/node/v/@jpyc/sdk-core.svg?style=flat)](https://nodejs.org/download/)
9+
[![npm version](https://badge.fury.io/js/@jpyc%2Fsdk-core.svg)](https://badge.fury.io/js/@jpyc%2Fsdk-core)
910

10-
JPYC core SDK implements a set of constants, types and functions, commonly used across different SDK versions.
11+
JPYC core SDK implements interfaces to interact with [JPYCv2 contracts](https://github.com/jcam1/JPYCv2) on different chains. Supported chains are Ethereum, Polygon, Gnosis, Avalanche, Astar and Shiden.
12+
13+
## 💡 How to Use
14+
15+
Please follow the following steps to configure the SDK.
16+
17+
#### 1. Install Packages
18+
19+
Install packages.
20+
21+
```sh
22+
# yarn
23+
$ yarn add @jpyc/sdk-core
24+
25+
# npm
26+
$ npm i @jpyc/sdk-core
27+
```
28+
29+
#### 2. Set Environment Variables
30+
31+
Some data, such as configuration variables (e.g., chain name) or sensitive data (e.g., private key), are embedded as environment variables. You need to set the following environment variables.
32+
33+
| Variable | Description & Instructions |
34+
| --------------------: | :-------------------------------------------------------------------------------------------------------------------------------- |
35+
| `SDK_ENV` | SDK environment. Set to `local` for local environment or any other sensible string for production environment. |
36+
| `CHAIN_NAME` | Chain name. Set to one of the following\: `local`, `ethereum`, `polygon`, `gnosis`, `avalanche`, `astar` or `shiden`. |
37+
| `NETWORK_NAME` | Network name within the specified chain. Set to one of the following\: `mainnet`, `goerli`, `sepolia`, `amoy`, `chiado` or `fuji` |
38+
| `RPC_ENDPOINT` | RPC endpoint to send transactions. |
39+
| `PRIVATE_KEY` | Private key of an account. |
40+
| `LOCAL_PROXY_ADDRESS` | Proxy contract address in local environment. |
41+
42+
#### 3. Instantiate SDK
43+
44+
Initialize an SDK instance that implements abstracted interfaces to the JPYCv2 contracts.
45+
46+
```ts
47+
import {
48+
ChainName,
49+
Endpoint,
50+
IJPYC,
51+
ISdkClient,
52+
JPYC,
53+
NetworkName,
54+
SdkClient,
55+
} from '@jpyc/sdk-core';
56+
57+
// 1. Initialize an SdkClient instance
58+
const sdkClient: ISdkClient = new SdkClient({
59+
chainName: process.env.CHAIN_NAME as ChainName,
60+
networkName: process.env.NETWORK_NAME as NetworkName,
61+
rpcEndpoint: process.env.RPC_ENDPOINT as Endpoint,
62+
});
63+
64+
// 2. Generate an account from a private key
65+
export const account = sdkClient.createPrivateKeyAccount({});
66+
67+
// 3. Generate a client with the account
68+
export const client = sdkClient.createLocalClient({
69+
account: account,
70+
});
71+
72+
// 4. Initialize an SDK instance
73+
export const jpyc: IJPYC = new JPYC({
74+
client: client,
75+
});
76+
```
77+
78+
#### 4. Use SDK
79+
80+
Use the initialized SDK wherever you would like.
81+
82+
```ts
83+
import { jpyc } from './YOUR/PATH/TO/INITIALIZATION/FILE';
84+
85+
// Fetch `totalSupply` from `JPYCv2` contract
86+
const totalSupply = await jpyc.totalSupply();
87+
console.log(`totalSupply: ${totalSupply.toString()}`);
88+
```
89+
90+
## ✨ Code Examples
91+
92+
For your reference, we provide code examples in the separate [`sdk-examples` repository](https://github.com/jcam1/sdk-examples). Please follow the instructions specified in `README` files.
1193

1294
## 🤖 Available Commands
1395

1496
The following commands are available as yarn scripts for local development & testing.
1597

1698
| Command | Description |
1799
| ---------------: | :---------------------------------------------------- |
18-
| `docs` | Generate Markdown documents from TSDoc-style comments |
19-
| `compile` | Compile (transpile) TypeScript files |
100+
| `compile` | Compile (transpile) SDK |
101+
| `test` | Run unit tests (using jest) |
20102
| `lint` | Run Eslint |
21103
| `lint:dry-run` | Run Eslint without fixing |
22104
| `format` | Run Prettier |
23105
| `format:dry-run` | Run Prettier without fixing |
24-
| `test` | Run unit tests (via jest) |
106+
| `docs` | Generate Markdown documents from TSDoc-style comments |
25107

26108
## 📚 Documentation
27109

docs/core/_media/globals.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
[**@jpyc/sdk-core**](README.md)**Docs**
1+
[**@jpyc/sdk-core**](README.md)
22

33
---
44

55
# @jpyc/sdk-core
66

7+
## Classes
8+
9+
- [InvalidAddressError](classes/InvalidAddressError.md)
10+
- [InvalidChainNameError](classes/InvalidChainNameError.md)
11+
- [InvalidNetworkNameError](classes/InvalidNetworkNameError.md)
12+
- [InvalidTransactionError](classes/InvalidTransactionError.md)
13+
- [JPYC](classes/JPYC.md)
14+
- [SdkClient](classes/SdkClient.md)
15+
16+
## Interfaces
17+
18+
- [IJPYC](interfaces/IJPYC.md)
19+
- [ISdkClient](interfaces/ISdkClient.md)
20+
721
## Type Aliases
822

923
- [Address](type-aliases/Address.md)
@@ -14,6 +28,7 @@
1428

1529
## Variables
1630

31+
- [JPYC_V2_ABI](variables/JPYC_V2_ABI.md)
1732
- [LOCAL_PROXY_ADDRESS](variables/LOCAL_PROXY_ADDRESS.md)
1833
- [SUPPORTED_CHAINS](variables/SUPPORTED_CHAINS.md)
1934
- [V2_PROXY_ADDRESS](variables/V2_PROXY_ADDRESS.md)

0 commit comments

Comments
 (0)