Skip to content

Commit

Permalink
add TON whitelist and send from vesting contract (#103)
Browse files Browse the repository at this point in the history
* add TON whitelist and send from vesting contract

* nit
  • Loading branch information
nooxx authored Jun 20, 2024
1 parent 8fd62df commit 4161e18
Showing 1 changed file with 49 additions and 8 deletions.
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 4161e18

Please sign in to comment.