* test: allow connecting to a local ganache node by signing transactions in brower * chore: update environment variables * fix: disassocaition * chore: remove redundant code * chore: rewrite promise as async/await * fix: approval amount too low * chore: address PR comments * test: fix tets * revert changes to env file * chore: changes as per pr comments
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { ethers } from 'ethers';
|
|
import abi from '../abis/vesting_abi.json';
|
|
import { prepend0x } from '../utils';
|
|
|
|
export class TokenVesting {
|
|
public contract: ethers.Contract;
|
|
public address: string;
|
|
|
|
constructor(
|
|
address: string,
|
|
signerOrProvider: ethers.Signer | ethers.providers.Provider
|
|
) {
|
|
this.contract = new ethers.Contract(address, abi, signerOrProvider);
|
|
this.address = address;
|
|
}
|
|
|
|
stakeTokens(amount: string, vegaPublicKey: string) {
|
|
return this.contract.stake_tokens(amount, prepend0x(vegaPublicKey));
|
|
}
|
|
removeStake(amount: string, vegaPublicKey: string) {
|
|
return this.contract.remove_stake(amount, prepend0x(vegaPublicKey));
|
|
}
|
|
stakeBalance(address: string, vegaPublicKey: string) {
|
|
return this.contract.stake_balance(address, prepend0x(vegaPublicKey));
|
|
}
|
|
totalStaked() {
|
|
return this.contract.total_staked();
|
|
}
|
|
userStats(address: string) {
|
|
return this.contract.user_stats(address);
|
|
}
|
|
getTrancheBalance(address: string, trancheId: number) {
|
|
return this.contract.get_tranche_balance(address, trancheId);
|
|
}
|
|
getVestedForTranche(address: string, trancheId: number) {
|
|
return this.contract.get_vested_for_tranche(address, trancheId);
|
|
}
|
|
userTotalAllTranches(address: string) {
|
|
return this.contract.user_total_all_tranches(address);
|
|
}
|
|
withdrawFromTranche(trancheId: number) {
|
|
return this.contract.withdraw_from_tranche(trancheId);
|
|
}
|
|
}
|