6.0.0 • Published 5 years ago

@windingtree/off-chain-adapter-in-memory v6.0.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
5 years ago

Winding Tree Off Chain Data Adapter - In memory

Greenkeeper badge

Very simple in-memory key-value storage that can be used in Winding Tree wt-js-libs.

Installation

npm install @windingtree/off-chain-adapter-in-memory
# or
git clone https://github.com/windingtree/off-chain-adapter-in-memory
nvm install
npm install

Usage

import { WtJsLibs } from '@windingtree/wt-js-libs';
import InMemoryAdapter from '@windingtree/off-chain-adapter-in-memory';

const libs = WtJsLibs.createInstance({
  onChainDataOptions: {
    provider: 'http://localhost:8545',
  },
  offChainDataOptions: {
    adapters: {
      'in-memory': {
        options: {
          // some: options
        }
        create: (options) => {
          return new InMemoryAdapter(options);
        },
      },
    },
  },
});
const index = await libs.getWTIndex('hotels', '0x...');
const hotel = await index.getHotel('0x...');
// Accessing off-chain data - url is actually stored on chain
const hotelDescriptionUrl = await (await hotel.dataIndex).ref;
// This data is fetched from some off-chain storage
const hotelDescription = await (await hotel.dataIndex).contents.description;
const hotelName = await hotelDescription.contents.name;
6.0.0

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.0.0

6 years ago

3.1.1

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago