Skip to content

Commit e8606e7

Browse files
authored
V2 [sof-1523][sof-1515][sof-1577][sof-1534][sof-1577][sof-1595] (#58)
* wip * ada tested * atom add withdraw rewards * atom nits * DOT wip * required validator addresses in functions * dot done * eth update * matic * near updates * near get stakes functions * near get stakes functions * near reward endpoints * nit * near network stats * sol updates * tezos updates * update readme * more specific error messages * ada KILN0 pool * utils functions more readable * better comments * better comments * update amounts and stake params * test matic * remove ds store * update package version
1 parent 00609f2 commit e8606e7

36 files changed

+1107
-822
lines changed

.gitignore

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

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
## Description
22

3-
Kiln JS SDK makes it easy to interact with the Kiln platform. It provides a simple way of crafting staking transactions as well getting real time rewards data.
3+
Kiln JS SDK makes it easy to interact with the Kiln staking platform.
44

5-
Check out the full documentation [here](https://docs.kiln.fi/v1/connect/overview).
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).
68

79
## Supported protocols
8-
- ETH
9-
- SOL
10-
- ATOM
1110
- ADA
12-
- NEAR
11+
- ATOM
1312
- DOT
13+
- ETH
14+
- MATIC
15+
- NEAR
16+
- SOL
17+
- XTZ
1418
- More protocol to come, don't hesitate to contact us ([email protected])
1519

1620
## Installation
@@ -36,38 +40,38 @@ const k = new Kiln({
3640

3741
## Craft 32 ETH staking transaction, sign it with fireblocks and broadcast it
3842
```typescript
39-
import { Kiln } from "../src/kiln";
43+
import { Kiln } from "@kilnfi/sdk";
44+
import { Integration } from "@kilnfi/sdk/lib/types/integrations";
4045
const fs = require('fs');
4146

4247
const apiSecret = fs.readFileSync(__dirname + '/path_to_fireblocks_secret', 'utf8');
4348

4449
const k = new Kiln({
4550
testnet: true,
4651
apiToken: 'kiln_xxx',
47-
integrations: [
48-
{
49-
name: 'vault1',
50-
provider: 'fireblocks',
51-
fireblocksApiKey: 'fireblocks_api_key',
52-
fireblocksSecretKey: apiSecret,
53-
vaultAccountId: 'vault_account_id'
54-
}
55-
],
5652
});
5753

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+
5861
try {
5962
// Craft 32 ETH staking transaction
63+
const amountWei = k.eth.ethToWei('32');
6064
const tx = await k.eth.craftStakeTx(
6165
'kiln_account_id',
6266
'withdrawal_address',
63-
32
67+
amountWei
6468
);
6569

66-
// Sign it with fireblocks vault 'vault1'
67-
const txSigned = await k.eth.sign('vault1', tx);
70+
// Sign it with your fireblock vault
71+
const txSigned = await k.eth.sign(vault, tx);
6872

6973
// Broadcast it
70-
const receipt = await k.eth.broadcast(txSigned);
74+
const hash = await k.eth.broadcast(txSigned);
7175

7276
} catch (err) {
7377
// handle errors

examples/ada.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Kiln } from "../src/kiln";
2+
import { Integration } from "../lib/types/integrations";
23

34
const fs = require('fs');
45

@@ -8,33 +9,35 @@ const f = async () => {
89
try {
910
const k = new Kiln({
1011
testnet: true,
11-
apiToken: 'kiln_Q3VFTHU0WW85Q2Z1dXJqMUFYSmtFYnFIZElpM3dwbFE6WWhxNGlobEJEbzktMm1zUm4tdUJhUDdPZml0NTdxdTIxVEVYczZlaDVQVTlEVk9TM1B5N0J6UV9xSFJVRzJKTg',
12-
integrations: [
13-
{
14-
name: 'vault1',
15-
provider: 'fireblocks',
16-
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
17-
fireblocksSecretKey: apiSecret,
18-
vaultAccountId: '7',
19-
},
20-
],
12+
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6cS01ZkhkV3ZrZnZ5cjVZQXk1czl1M29SeXBoeEV0U01wczVpWm1zNTlXSkdjLUkyR1ZIeWpyc291a3pWbEl0MQ',
2113
});
22-
23-
const tx = await k.ada.craftStakeTx(
24-
'd3f1b917-72b1-4982-a4dd-93fce579a708',
25-
'addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5',
26-
);
27-
// const tx = await k.ada.craftWithdrawRewardsTx(
14+
15+
const vault: Integration = {
16+
provider: 'fireblocks',
17+
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
18+
fireblocksSecretKey: apiSecret,
19+
vaultId: 7
20+
};
21+
22+
console.log('crafting...');
23+
// const tx = await k.ada.craftStakeTx(
24+
// '5dcd8897-4fe7-401a-9ad8-3a15dae1fbe8',
2825
// 'addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5',
26+
// 'pool1u4x4ly6qyx9fs9k2lt7f9hpa2gftd52fee67jcmuhnt7qqae3x0'
2927
// );
30-
31-
// const tx = await k.ada.craftUnstakeTx(
28+
// const tx = await k.ada.craftWithdrawRewardsTx(
3229
// 'addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5',
3330
// );
34-
const txSigned = await k.ada.sign('vault1', tx);
31+
32+
const tx = await k.ada.craftUnstakeTx(
33+
'addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5',
34+
);
35+
console.log('signing...');
36+
const txSigned = await k.ada.sign(vault, tx);
37+
console.log('broadcasting...');
3538
const hash = await k.ada.broadcast(txSigned);
3639
console.log(hash);
37-
// const status = await k.ada.getTxStatus('aad008eec08f606f763837144d18275203406bdada7fc2a429c656c15952dd9c');
40+
// const status = await k.ada.getTxStatus('aaa64683e93514ed7e7bbafade1ab1e226706fb65233b2f2bc37cb4005e62ed1');
3841
// console.log(status);
3942

4043
// const stakes = await k.ada.getStakesByAccounts(['771254de-ac5a-4911-afdf-1d5b7e802dc9']);

examples/atom.ts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
import { Kiln } from "../src/kiln";
2+
import { Integration } from "../lib/types/integrations";
23
const fs = require('fs');
34

45
const apiSecret = fs.readFileSync(__dirname + '/fireblocks_secret.key', 'utf8');
56

67
const f = async () => {
78
const k = new Kiln({
8-
testnet: false,
9-
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6ZjF1SUw4d3R1ZDRxYUdreEwtV2sxcjdmbVFJYlhuMWFGUVduRjBkVFJscFdCaUc5bkV2WmpyTU9xb19pSjlsWg',
10-
integrations: [
11-
{
12-
name: 'vault1',
13-
provider: 'fireblocks',
14-
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
15-
fireblocksSecretKey: apiSecret,
16-
vaultAccountId: '7'
17-
}
18-
],
9+
testnet: true,
10+
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6cS01ZkhkV3ZrZnZ5cjVZQXk1czl1M29SeXBoeEV0U01wczVpWm1zNTlXSkdjLUkyR1ZIeWpyc291a3pWbEl0MQ',
1911
});
2012

13+
const vault: Integration = {
14+
provider: 'fireblocks',
15+
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
16+
fireblocksSecretKey: apiSecret,
17+
vaultId: 7
18+
};
19+
2120
try {
22-
// const tx = await k.atom.craftStakeTx(
23-
// '376acfff-e35d-4b7c-90da-c6acb8ea7197',
21+
console.log('crafting...');
22+
const tx = await k.atom.craftStakeTx(
23+
'376acfff-e35d-4b7c-90da-c6acb8ea7197',
24+
'cosmos19c9fdh488vqjclltwp68jm50ydwyh36jqeatev',
25+
'cosmosvaloper1uxlf7mvr8nep3gm7udf2u9remms2jyjqvwdul2',
26+
0.5,
27+
);
28+
// const tx = await k.atom.craftWithdrawRewardsTx(
2429
// 'cosmos19c9fdh488vqjclltwp68jm50ydwyh36jqeatev',
25-
// 0.1,
30+
// 'cosmosvaloper178h4s6at5v9cd8m9n7ew3hg7k9eh0s6wptxpcn'
2631
// );
2732
// const tx = await k.atom.craftUnstakeTx(
2833
// 'cosmos19c9fdh488vqjclltwp68jm50ydwyh36jqeatev',
29-
// 'cosmosvaloper17hskshytlrepzhas628uk00jvvppg7yfj3wpqz',
30-
// 0.1
34+
// 'cosmosvaloper178h4s6at5v9cd8m9n7ew3hg7k9eh0s6wptxpcn',
35+
// amountUatom
3136
// );
3237

33-
// const signedTx = await k.atom.sign('vault1', tx);
34-
// const hash = await k.atom.broadcast(signedTx);
35-
// console.log(hash);
36-
const tx = await k.atom.getTxStatus('D43C977E0A969B00CB79CFAC45F147C9C7DE5B6B735CFDA685EE3CFCE1DE5B33');
37-
console.log(tx);
38+
console.log('signing...');
39+
const signedTx = await k.atom.sign(vault, tx);
40+
console.log('broadcasting...');
41+
const hash = await k.atom.broadcast(signedTx);
42+
console.log(hash);
43+
// const tx = await k.atom.getTxStatus('D43C977E0A969B00CB79CFAC45F147C9C7DE5B6B735CFDA685EE3CFCE1DE5B33');
44+
// console.log(tx);
3845
} catch (err){
3946
console.log(err);
4047
}

examples/dot.ts

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Kiln } from "../src/kiln";
2+
import { Integration } from "../lib/types/integrations";
23

34
const fs = require('fs');
45

@@ -7,36 +8,40 @@ const apiSecret = fs.readFileSync(__dirname + '/fireblocks_secret.key', 'utf8');
78
const f = async () => {
89
const k = new Kiln({
910
testnet: true,
10-
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6ZjF1SUw4d3R1ZDRxYUdreEwtV2sxcjdmbVFJYlhuMWFGUVduRjBkVFJscFdCaUc5bkV2WmpyTU9xb19pSjlsWg',
11-
integrations: [
12-
{
13-
name: 'vault1',
14-
provider: 'fireblocks',
15-
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
16-
fireblocksSecretKey: apiSecret,
17-
vaultAccountId: '7',
18-
},
19-
],
11+
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6cS01ZkhkV3ZrZnZ5cjVZQXk1czl1M29SeXBoeEV0U01wczVpWm1zNTlXSkdjLUkyR1ZIeWpyc291a3pWbEl0MQ',
2012
});
2113

14+
const vault: Integration = {
15+
provider: 'fireblocks',
16+
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
17+
fireblocksSecretKey: apiSecret,
18+
vaultId: 7
19+
};
20+
2221
try {
23-
// const tx = await k.dot.craftBondTx(
24-
// '376acfff-e35d-4b7c-90da-c6acb8ea7197',
22+
console.log('crafting...');
23+
const tx = await k.dot.craftBondTx(
24+
'5dcd8897-4fe7-401a-9ad8-3a15dae1fbe8',
25+
'5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
26+
0.5,
27+
);
28+
// const tx = await k.dot.craftBondExtraTx(
2529
// '5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
26-
// 1,
30+
// amountPlanck,
2731
// );
2832
// const tx = await k.dot.craftRebondTx(
2933
// '5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
30-
// 1,
34+
// amountPlanck,
3135
// );
3236

3337
// const tx = await k.dot.craftNominateTx(
3438
// '5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
39+
// ['5GR6UNoUW3VsXTqwDuMzRpZpeA7pmH3VtZNCaSGp2RGz8p6g']
3540
// );
3641

3742
// const tx = await k.dot.craftUnbondTx(
3843
// '5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
39-
// 1,
44+
// amountPlanck,
4045
// );
4146

4247
// const tx = await k.dot.craftWithdrawUnbondedTx(
@@ -56,19 +61,20 @@ const f = async () => {
5661
// '5DK8ShqtyuVk2w4qrF9HwaBJoiZV1byQs5ARZ3df2Pt8V6Vj',
5762
// 'Staked',
5863
// );
59-
//
60-
// const signedTx = await k.dot.sign('vault1', tx);
61-
// const hash = await k.dot.broadcast(signedTx);
62-
// console.log(hash);
64+
console.log('signing...');
65+
const signedTx = await k.dot.sign(vault, tx);
66+
console.log('broadcasting...');
67+
const hash = await k.dot.broadcast(signedTx);
68+
console.log(hash);
6369

64-
const status = await k.dot.getTxStatus(
65-
{
66-
blockHash: '0x62ea99ad580e8bfa9d4c79b61b9867838d7086e8c0c8c2ae70226ea37279fc47',
67-
hash: '0x6c6654109e448117ffb021fba07d38d1b41c6927da465ddc3de7af49760f0bae'
68-
},
69-
);
70-
71-
console.log(status);
70+
// const status = await k.dot.getTxStatus(
71+
// {
72+
// blockHash: '0x62ea99ad580e8bfa9d4c79b61b9867838d7086e8c0c8c2ae70226ea37279fc47',
73+
// hash: '0x6c6654109e448117ffb021fba07d38d1b41c6927da465ddc3de7af49760f0bae'
74+
// },
75+
// );
76+
//
77+
// console.log(status);
7278
} catch (err) {
7379
console.log(err);
7480
}

examples/eth.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Kiln } from "../src/kiln";
2+
import { Integration } from "../lib/types/integrations";
23

34
const fs = require('fs');
45

@@ -7,28 +8,25 @@ const apiSecret = fs.readFileSync(__dirname + '/fireblocks_secret.key', 'utf8');
78
const f = async () => {
89
const k = new Kiln({
910
testnet: true,
10-
apiToken: 'kiln_Q3VFTHU0WW85Q2Z1dXJqMUFYSmtFYnFIZElpM3dwbFE6WWhxNGlobEJEbzktMm1zUm4tdUJhUDdPZml0NTdxdTIxVEVYczZlaDVQVTlEVk9TM1B5N0J6UV9xSFJVRzJKTg',
11-
integrations: [
12-
{
13-
name: 'vault1',
14-
provider: 'fireblocks',
15-
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
16-
fireblocksSecretKey: apiSecret,
17-
vaultAccountId: '7'
18-
}
19-
],
11+
apiToken: 'kiln_dTkxUTFRdHBMZm9vNFFycFhDSTZCdlJsbjJZang5VnY6cS01ZkhkV3ZrZnZ5cjVZQXk1czl1M29SeXBoeEV0U01wczVpWm1zNTlXSkdjLUkyR1ZIeWpyc291a3pWbEl0MQ',
2012
});
2113

14+
const vault: Integration = {
15+
provider: 'fireblocks',
16+
fireblocksApiKey: '53aee35e-04b7-9314-8f28-135a66c8af2c',
17+
fireblocksSecretKey: apiSecret,
18+
vaultId: 7
19+
};
20+
2221
try {
2322
console.log('crafting tx...');
24-
const amountWei = k.eth.ethToWei('32');
2523
const tx = await k.eth.craftStakeTx(
26-
'd3f1b917-72b1-4982-a4dd-93fce579a708',
24+
'5dcd8897-4fe7-401a-9ad8-3a15dae1fbe8',
2725
'0x9cE658155A6f05FE4aef83b7Fa8F431D5e8CcB55',
28-
amountWei,
26+
32,
2927
);
3028
console.log('signing tx...');
31-
const txSigned = await k.eth.sign('vault1', tx);
29+
const txSigned = await k.eth.sign(vault, tx);
3230
console.log('broadcasting tx...');
3331
const hash = await k.eth.broadcast(txSigned);
3432
console.log(hash);

examples/fireblocks_secret.key

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ gsOYg6FNQVXk89MoNJo3erhLE4lIxKyQoWc51JqFdBnHwMzDJ1Ebp5WVeCa1aP3b
4949
gXA5M3TviDti+zWQJbNwImR4XPK8KB2v69kPccOHTmelIRMBRGB71YHJ4g7yVjmn
5050
lY6dKDbk0kXdekgc9Su84FYLZ8KESZUIY4vpIT03W/H0U3FOx824SXF7yj0F+UQ9
5151
E7+pKsCyncT0tbZe5BUbg3BAMMlcAw==
52-
-----END PRIVATE KEY-----
52+
-----END PRIVATE KEY-----

0 commit comments

Comments
 (0)