UNPKG

@terminusbet/stake-vote-sdk

Version:

A simple SDK for interacting with terminusbet governance

88 lines 3.66 kB
import { struct, u64, u8, publicKey } from "@coral-xyz/borsh"; import { PublicKey } from "@solana/web3.js"; const u128 = (property) => struct([u64("low"), u64("high")], property); const toBigInt = ({ low, high }) => (BigInt(high.toString()) << 64n) + BigInt(low.toString()); export class UserStakeVoteState { discriminator; stakePoolState; owner; timeStartAt; timeEndAt; timeStakeRelease; periodUsed; periodTotal; stakeAllTotal; // u128 stakeTotal; stakeReleaseNotRecived; // u128 stakeReleaseRecived; // u128 stakeReleasePerTime; // u128 votePerTime; // u128 voteUsed; voteTotal; decimal; constructor(discriminator, stakePoolState, owner, timeStartAt, timeEndAt, timeStakeRelease, periodUsed, periodTotal, stakeAllTotal, stakeTotal, stakeReleaseNotRecived, stakeReleaseRecived, stakeReleasePerTime, votePerTime, voteUsed, voteTotal, decimal) { this.discriminator = discriminator; this.stakePoolState = stakePoolState; this.owner = owner; this.timeStartAt = timeStartAt; this.timeEndAt = timeEndAt; this.timeStakeRelease = timeStakeRelease; this.periodUsed = periodUsed; this.periodTotal = periodTotal; this.stakeAllTotal = stakeAllTotal; this.stakeTotal = stakeTotal; this.stakeReleaseNotRecived = stakeReleaseNotRecived; this.stakeReleaseRecived = stakeReleaseRecived; this.stakeReleasePerTime = stakeReleasePerTime; this.votePerTime = votePerTime; this.voteUsed = voteUsed; this.voteTotal = voteTotal; this.decimal = decimal; } static fromBuffer(buffer) { const structure = struct([ u64("discriminator"), publicKey("stakePoolState"), publicKey("owner"), u64("timeStartAt"), u64("timeEndAt"), u64("timeStakeRelease"), u64("periodUsed"), u64("periodTotal"), u128("stakeAllTotal"), u64("stakeTotal"), u128("stakeReleaseNotRecived"), u128("stakeReleaseRecived"), u128("stakeReleasePerTime"), u128("votePerTime"), u64("voteUsed"), u64("voteTotal"), u8("decimal") ]); let value = structure.decode(buffer); return new UserStakeVoteState(BigInt(value.discriminator), new PublicKey(value.stakePoolState), new PublicKey(value.owner), BigInt(value.timeStartAt), BigInt(value.timeEndAt), BigInt(value.timeStakeRelease), BigInt(value.periodUsed), BigInt(value.periodTotal), toBigInt(value.stakeAllTotal), BigInt(value.stakeTotal), toBigInt(value.stakeReleaseNotRecived), toBigInt(value.stakeReleaseRecived), toBigInt(value.stakeReleasePerTime), toBigInt(value.votePerTime), BigInt(value.voteUsed), BigInt(value.voteTotal), BigInt(value.decimal)); } } export class UserVoteState { discriminator; ballotBot; owner; voteCount; constructor(discriminator, ballotBot, owner, voteCount) { this.discriminator = discriminator; this.ballotBot = ballotBot; this.owner = owner; this.voteCount = voteCount; } static fromBuffer(buffer) { const structure = struct([ u64("discriminator"), publicKey("ballotBot"), publicKey("owner"), u64("voteCount") ]); let value = structure.decode(buffer); return new UserVoteState(BigInt(value.discriminator), new PublicKey(value.ballotBot), new PublicKey(value.owner), BigInt(value.voteCount)); } } //# sourceMappingURL=userStakeVoteState.js.map