@iqprotocol/in-memory-storage
TypeScript icon, indicating that this package has built-in type declarations

0.15.1 • Public • Published

In-Memory Storage

This package is part of IQ Protocol JS SDK.

The package is in development and breaking changes should be expected. Use at your own risk!

The package includes very basic Account Store Interface implementation for handling account states in memory. Use this package when you want to test account state management functionality without setting up a persistent storage.

⚠️ This provider is meant for testing and does not guarantee data persistence. Do not use for production deployments!

Installation

yarn add @iqprotocol/in-memory-storage

Usage

import { InMemoryAccountStore, Account, AccountState } from '@iqprotocol/in-memory-storage';

const store = new InMemoryAccountStore(); 

const account: Account = {
  id: 'test-id',
  data: { ... },
};

await store.saveAccount(account);

const accountState: AccountState = {
  accountId: account.id,
  serviceId: 'test-service',
  energyGapHalvingPeriod: 86400,
  power: 10n,
  lockedPower: 2n,
  energyCap: 5n,
  energy: 5n,
  energyCalculatedAt: Math.floor(Date.now() / 1000),
};

await store.initAccountState(accountState); 

Readme

Keywords

none

Package Sidebar

Install

npm i @iqprotocol/in-memory-storage

Weekly Downloads

0

Version

0.15.1

License

MIT

Unpacked Size

18.3 kB

Total Files

10

Last publish

Collaborators

  • stas_iq
  • denis.narushevich.blockvis
  • timurrassolov
  • cvts
  • cheelahim
  • d_kozickis
  • zorato