Skip to content

Commit

Permalink
cosmos - support grantee address for restaking (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
nooxx authored Jul 11, 2024
1 parent d0fd577 commit 9840226
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kilnfi/sdk",
"version": "2.18.1",
"version": "2.19.0",
"autor": "Kiln <[email protected]> (https://kiln.fi)",
"license": "BUSL-1.1",
"description": "JavaScript sdk for Kiln API",
Expand Down
7 changes: 6 additions & 1 deletion src/services/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ export class AtomService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountAtom how many tokens to stake in ATOM
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountAtom: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/atom/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_uatom: this.atomToUatom(amountAtom.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -63,11 +66,13 @@ export class AtomService extends Service {
* Craft atom restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/atom/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/fet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ export class FetService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountFet how many tokens to stake in FET
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountFet: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/fet/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_afet: this.fetToAfet(amountFet.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -63,11 +66,13 @@ export class FetService extends Service {
* Craft fetch.ai restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/fet/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/inj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ export class InjService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountInj how many tokens to stake in INJ
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountInj: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/inj/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_inj: this.injToAinj(amountInj.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -62,11 +65,13 @@ export class InjService extends Service {
* Craft inj restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/inj/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/osmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ export class OsmoService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountOsmo how many tokens to stake in OSMO
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountOsmo: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/osmo/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_uosmo: this.osmoToUosmo(amountOsmo.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -63,11 +66,13 @@ export class OsmoService extends Service {
* Craft osmo restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/osmo/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/tia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ export class TiaService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountTia how many tokens to stake in TIA
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountTia: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/tia/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_utia: this.tiaToUtia(amountTia.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -62,11 +65,13 @@ export class TiaService extends Service {
* Craft tia restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/tia/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/zeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ export class ZetaService extends Service {
* @param validatorAddress validator address to delegate to
* @param amountZeta how many tokens to stake in ZETA
* @param restakeRewards If enabled, the rewards will be automatically restaked
* @param granteeAddress validator grantee address
*/
async craftStakeTx(
accountId: string,
pubkey: string,
validatorAddress: string,
amountZeta: number,
restakeRewards: boolean = false,
granteeAddress?: string,
): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/zeta/transaction/stake`, {
account_id: accountId,
pubkey: pubkey,
validator: validatorAddress,
amount_azeta: this.zetaToAZeta(amountZeta.toString()),
restake_rewards: restakeRewards,
grantee_address: granteeAddress,
});
return data;
}
Expand All @@ -63,11 +66,13 @@ export class ZetaService extends Service {
* Craft a Zetachain restake rewards transaction
* @param pubkey wallet pubkey, this is different from the wallet address
* @param validatorAddress validator address to which the delegation has been made
* @param granteeAddress validator grantee address
*/
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string): Promise<CosmosTx> {
async craftRestakeRewardsTx(pubkey: string, validatorAddress: string, granteeAddress: string): Promise<CosmosTx> {
const { data } = await api.post<CosmosTx>(`/v1/zeta/transaction/restake-rewards`, {
pubkey: pubkey,
validator_address: validatorAddress,
grantee_address: granteeAddress,
});
return data;
}
Expand Down

0 comments on commit 9840226

Please sign in to comment.