@saberhq/snapshots
Version:
The TypeScript SDK for the Saber Voting Escrow Snapshot system.
30 lines • 1.02 kB
JavaScript
import { __awaiter } from "tslib";
import { utils } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";
import { SNAPSHOTS_ADDRESSES } from "../../constants";
const encodeU16 = (num) => {
const buf = Buffer.alloc(2);
buf.writeUInt16LE(num);
return buf;
};
/**
* Finds the address of an EscrowHistory.
*/
export const findEscrowHistoryAddress = (escrow, era) => __awaiter(void 0, void 0, void 0, function* () {
return yield PublicKey.findProgramAddress([
utils.bytes.utf8.encode("EscrowHistory"),
escrow.toBuffer(),
encodeU16(era),
], SNAPSHOTS_ADDRESSES.Snapshots);
});
/**
* Finds the address of a LockerHistory.
*/
export const findLockerHistoryAddress = (locker, era) => __awaiter(void 0, void 0, void 0, function* () {
return yield PublicKey.findProgramAddress([
utils.bytes.utf8.encode("LockerHistory"),
locker.toBuffer(),
encodeU16(era),
], SNAPSHOTS_ADDRESSES.Snapshots);
});
//# sourceMappingURL=pda.js.map