From ffde4c1e4ebe766f6250d7c1b5146b3600b15c3a Mon Sep 17 00:00:00 2001 From: Arno Simon Date: Wed, 19 Jun 2024 19:17:13 +0200 Subject: [PATCH] add TON whitelist and send from vesting contract --- src/api.ts | 2 +- src/services/ton.ts | 57 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/api.ts b/src/api.ts index cf869bb..c1e0e1d 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,6 +1,6 @@ import axios from "axios"; -const api = axios.create(); +const api = axios.create({}); api.interceptors.response.use( (res) => res, (err) => { diff --git a/src/services/ton.ts b/src/services/ton.ts index 9d007f5..4a39e7d 100644 --- a/src/services/ton.ts +++ b/src/services/ton.ts @@ -13,8 +13,8 @@ export class TonService extends Service { /** * Craft TON staking transaction to a single nomination pool * @param accountId id of the kiln account to use for the stake transaction - * @param walletAddress used to create the stake account and retrieve rewards in the future - * @param poolAddress vote account address of the validator that you wish to delegate to + * @param walletAddress sender of the transaction + * @param poolAddress single nomination pool address * @param amountTon how much to stake in TON */ async craftStakeSingleNominationPoolTx( @@ -35,8 +35,8 @@ export class TonService extends Service { /** * Craft TON staking transaction to a nomination pool * @param accountId id of the kiln account to use for the stake transaction - * @param walletAddress used to create the stake account and retrieve rewards in the future - * @param poolAddress vote account address of the validator that you wish to delegate to + * @param walletAddress sender of the transaction + * @param poolAddress nomination pool address * @param amountTon how much to stake in TON */ async craftStakeNominationPoolTx( @@ -56,8 +56,8 @@ export class TonService extends Service { /** * Craft TON unstake transaction from a single nomination pool - * @param walletAddress used to create the stake account and retrieve rewards in the future - * @param poolAddress vote account address of the validator that you wish to delegate to + * @param walletAddress sender of the transaction + * @param poolAddress single nomination pool address * @param amountTon how much to stake in TON */ async craftUnstakeSingleNominationPoolTx( @@ -75,8 +75,8 @@ export class TonService extends Service { /** * Craft TON unstake transaction from a nomination pool - * @param walletAddress used to create the stake account and retrieve rewards in the future - * @param poolAddress vote account address of the validator that you wish to delegate to + * @param walletAddress sender of the transaction + * @param poolAddress nomination pool address */ async craftUnstakeNominationPoolTx(walletAddress: string, poolAddress: string): Promise { const { data } = await api.post(`/v1/ton/transaction/unstake-nomination-pool`, { @@ -86,6 +86,47 @@ export class TonService extends Service { return data; } + /** + * Craft TON whitelist tx for vesting contract + * @param walletAddress sender of the transaction + * @param vestingContractAddress vesting contract address + * @param addresses addresses to whitelist + */ + async craftWhitelistVestingContractTx( + walletAddress: string, + vestingContractAddress: string, + addresses: string[], + ): Promise { + const { data } = await api.post(`/v1/ton/transaction/whitelist-vesting-contract`, { + wallet: walletAddress, + vesting_contract_address: vestingContractAddress, + addresses: addresses, + }); + return data; + } + + /** + * Craft TON send from a vesting contract tx + * @param walletAddress sender of the transaction + * @param vestingContractAddress vesting contract address + * @param destinationAddress the destination to which the TON will be sent to + * @param amountTon the amount of TON to send + */ + async craftSendFromVestingContractTx( + walletAddress: string, + vestingContractAddress: string, + destinationAddress: string, + amountTon: number, + ): Promise { + const { data } = await api.post(`/v1/ton/transaction/send-from-vesting-contract`, { + wallet: walletAddress, + vesting_contract_address: vestingContractAddress, + destination_address: destinationAddress, + amount_nanoton: this.tonToNanoTon(amountTon.toString()), + }); + return data; + } + /** * Sign transaction with given integration * @param integration custody solution to sign with