Skip to content

Commit 8da8c5b

Browse files
committed
v2
0 parents  commit 8da8c5b

38 files changed

+21583
-0
lines changed

.eslintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "next/core-web-vitals",
3+
"rules": {
4+
"object-curly-spacing": ["error", "always"],
5+
"indent": ["warn", 2],
6+
"semi": ["warn", "always"]
7+
}
8+
}

.github/workflows/publish.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: '16.x'
15+
registry-url: 'https://registry.npmjs.org'
16+
- run: npm install
17+
- run: npm run build
18+
- run: npm publish --access public
19+
env:
20+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/sdk.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "sdk-js"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "src/**"
9+
- "index.ts"
10+
- ".github/workflows/sdk.yml"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- "src/**"
16+
- "index.ts"
17+
- ".github/workflows/sdk.yml"
18+
19+
jobs:
20+
lint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Install modules
25+
run: npm install
26+
- name: Run ESLint
27+
run: npm run lint

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules/
3+
lib/
4+
.idea/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.idea
3+
examples/

LICENSE

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Business Source License 1.1
2+
3+
License text copyright © 2022 Kiln SAS, All Rights Reserved.
4+
"Business Source License" is a trademark of Kiln SAS.
5+
6+
Terms
7+
8+
The Licensor hereby grants you the right to copy, modify, create derivative
9+
works, redistribute, and make non-production use of the Licensed Work. The
10+
Licensor may make an Additional Use Grant, above, permitting limited
11+
production use.
12+
13+
Effective on the Change Date, or the fourth anniversary of the first publicly
14+
available distribution of a specific version of the Licensed Work under this
15+
License, whichever comes first, the Licensor hereby grants you rights under
16+
the terms of the Change License, and the rights granted in the paragraph
17+
above terminate.
18+
19+
If your use of the Licensed Work does not comply with the requirements
20+
currently in effect as described in this License, you must purchase a
21+
commercial license from the Licensor, its affiliated entities, or authorized
22+
resellers, or you must refrain from using the Licensed Work.
23+
24+
All copies of the original and modified Licensed Work, and derivative works
25+
of the Licensed Work, are subject to this License. This License applies
26+
separately for each version of the Licensed Work and the Change Date may vary
27+
for each version of the Licensed Work released by Licensor.
28+
29+
You must conspicuously display this License on each original or modified copy
30+
of the Licensed Work. If you receive the Licensed Work in original or
31+
modified form from a third party, the terms and conditions set forth in this
32+
License apply to your use of that work.
33+
34+
Any use of the Licensed Work in violation of this License will automatically
35+
terminate your rights under this License for the current and all other
36+
versions of the Licensed Work.
37+
38+
This License does not grant you any right in any trademark or logo of
39+
Licensor or its affiliates (provided that you may use a trademark or logo of
40+
Licensor as expressly required by this License).
41+
42+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
43+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
44+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
45+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
46+
TITLE.
47+
48+
Kiln hereby grants you permission to use this License’s text to license
49+
your works, and to refer to it using the trademark “Business Source License”,
50+
as long as you comply with the Covenants of Licensor below.
51+
52+
Covenants of Licensor
53+
54+
In consideration of the right to use this License’s text and the “Business
55+
Source License” name and trademark, Licensor covenants to Kiln, and to all
56+
other recipients of the licensed work to be provided by Licensor:
57+
58+
1. To specify as the Change License the GPL Version 2.0 or any later version,
59+
or a license that is compatible with GPL Version 2.0 or a later version,
60+
where “compatible” means that software provided under the Change License can
61+
be included in a program with software provided under GPL Version 2.0 or a
62+
later version. Licensor may specify additional Change Licenses without
63+
limitation.
64+
65+
2. To either: (a) specify an additional grant of rights to use that does not
66+
impose any additional restriction on the right granted in this License, as
67+
the Additional Use Grant; or (b) insert the text “None”.
68+
69+
3. To specify a Change Date.
70+
71+
4. Not to modify this License in any other way.

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
## Description
2+
3+
Kiln JS SDK makes it easy to interact with the Kiln staking platform.
4+
5+
It provides a simple way of crafting staking transactions as well getting real time and historical data about your stakes.
6+
7+
Check out the [full documentation](https://docs.kiln.fi/v1/connect/overview).
8+
9+
## Supported protocols
10+
- ADA
11+
- ATOM
12+
- DOT
13+
- ETH
14+
- MATIC
15+
- NEAR
16+
- SOL
17+
- XTZ
18+
- More protocol to come, don't hesitate to contact us ([email protected])
19+
20+
## Installation
21+
22+
You can install the JS SDK with npm:
23+
24+
```sh
25+
npm install --save @kilnfi/sdk
26+
```
27+
28+
## Setup
29+
In order to use this sdk, you will need a kiln api token.
30+
Please contact [email protected] to get one.
31+
32+
```typescript
33+
import { Kiln } from "../src/kiln";
34+
35+
const k = new Kiln({
36+
testnet: true,
37+
apiToken: 'kiln_xxx',
38+
});
39+
```
40+
41+
## Craft 32 ETH staking transaction, sign it with fireblocks and broadcast it
42+
```typescript
43+
import { Kiln } from "@kilnfi/sdk";
44+
import { Integration } from "@kilnfi/sdk/lib/types/integrations";
45+
const fs = require('fs');
46+
47+
const apiSecret = fs.readFileSync(__dirname + '/path_to_fireblocks_secret', 'utf8');
48+
49+
const k = new Kiln({
50+
testnet: true,
51+
apiToken: 'kiln_xxx',
52+
});
53+
54+
const vault: Integration = {
55+
provider: 'fireblocks',
56+
fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
57+
fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
58+
vaultId: 7 // your fireblocks vault id
59+
};
60+
61+
try {
62+
// Craft 32 ETH staking transaction
63+
const tx = await k.eth.craftStakeTx(
64+
'kiln_account_id',
65+
'withdrawal_address',
66+
32
67+
);
68+
69+
// Sign it with your fireblock vault
70+
const txSigned = await k.eth.sign(vault, tx);
71+
72+
// Broadcast it
73+
const hash = await k.eth.broadcast(txSigned);
74+
75+
} catch (err) {
76+
// handle errors
77+
}
78+
```
79+
80+
## Fetch ETH stakes and network stats
81+
```typescript
82+
try {
83+
// Get stakes by accounts
84+
const stakes = await k.eth.getAccountsRewards(['kiln-account-id']);
85+
86+
// Get stakes by wallets
87+
const stakesByWallet = await k.eth.getWalletRewards(['wallet-address']);
88+
89+
// Get stakes by validators
90+
const stakesByValidator = await k.eth.getStakesRewards(['validator-address']);
91+
92+
// Get network stats
93+
const stats = await k.eth.getNetworkStats();
94+
95+
} catch (err) {
96+
// handle errors
97+
}
98+
```
99+
100+
## License
101+
This package is open-sourced software licensed under the [BUSL-1.1 license](https://github.com/kilnfi/sdk-js/blob/main/LICENSE).
102+

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src/kiln';

0 commit comments

Comments
 (0)