feat: add stake program methods; refactor instruction type handling

This commit is contained in:
Tyera Eulberg
2019-12-23 11:46:49 -07:00
committed by Michael Vines
parent fc77e55920
commit 532b28e96e
16 changed files with 602 additions and 48 deletions

View File

@ -54,6 +54,26 @@ export const rustString = (property: string = 'string') => {
return rsl;
};
/**
* Layout for an Authorized object
*/
export const authorized = (property: string = 'authorized') => {
return BufferLayout.struct(
[publicKey('staker'), publicKey('withdrawer')],
property,
);
};
/**
* Layout for a Lockup object
*/
export const lockup = (property: string = 'lockup') => {
return BufferLayout.struct(
[BufferLayout.ns64('epoch'), publicKey('custodian')],
property,
);
};
export function getAlloc(type: Object, fields: Object): number {
let alloc = 0;
type.layout.fields.forEach(item => {