Skip to content

Commit

Permalink
add TON whitelist and send from vesting contract
Browse files Browse the repository at this point in the history
  • Loading branch information
nooxx committed Jun 19, 2024
1 parent 62dd194 commit ffde4c1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

const api = axios.create();
const api = axios.create({});
api.interceptors.response.use(
(res) => res,
(err) => {
Expand Down
57 changes: 49 additions & 8 deletions src/services/ton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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<TonTx> {
const { data } = await api.post<TonTx>(`/v1/ton/transaction/unstake-nomination-pool`, {
Expand All @@ -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<TonTx> {
const { data } = await api.post<TonTx>(`/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<TonTx> {
const { data } = await api.post<TonTx>(`/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
Expand Down

0 comments on commit ffde4c1

Please sign in to comment.