UNPKG

@saberhq/snapshots

Version:

The TypeScript SDK for the Saber Voting Escrow Snapshot system.

35 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findLockerHistoryAddress = exports.findEscrowHistoryAddress = void 0; const tslib_1 = require("tslib"); const anchor_1 = require("@project-serum/anchor"); const web3_js_1 = require("@solana/web3.js"); const constants_1 = require("../../constants"); const encodeU16 = (num) => { const buf = Buffer.alloc(2); buf.writeUInt16LE(num); return buf; }; /** * Finds the address of an EscrowHistory. */ const findEscrowHistoryAddress = (escrow, era) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return yield web3_js_1.PublicKey.findProgramAddress([ anchor_1.utils.bytes.utf8.encode("EscrowHistory"), escrow.toBuffer(), encodeU16(era), ], constants_1.SNAPSHOTS_ADDRESSES.Snapshots); }); exports.findEscrowHistoryAddress = findEscrowHistoryAddress; /** * Finds the address of a LockerHistory. */ const findLockerHistoryAddress = (locker, era) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return yield web3_js_1.PublicKey.findProgramAddress([ anchor_1.utils.bytes.utf8.encode("LockerHistory"), locker.toBuffer(), encodeU16(era), ], constants_1.SNAPSHOTS_ADDRESSES.Snapshots); }); exports.findLockerHistoryAddress = findLockerHistoryAddress; //# sourceMappingURL=pda.js.map