counter.ts 339 B

1234567891011121314151617
  1. import * as BN from 'bn.js';
  2. export type Counter = {
  3. count: BN
  4. }
  5. export const COUNTER_ACCOUNT_SIZE = 8;
  6. export function deserializeCounterAccount(data: Buffer): Counter {
  7. if (data.byteLength !== 8) {
  8. throw Error("Need exactly 8 bytes to deserialize counter")
  9. }
  10. return {
  11. count: new BN(data, 'le')
  12. }
  13. }