0.15.1 • Published 2 years ago

@iqprotocol/in-memory-storage v0.15.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

In-Memory Storage

This package is part of IQ Protocol JS SDK.

:exclamation: 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.

:warning: 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); 
0.15.1

2 years ago

0.15.0

2 years ago

0.12.0

2 years ago

0.13.0

2 years ago

0.13.1

2 years ago

0.11.0

3 years ago

0.10.2

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago