# project-afael-hlw

> Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Latest version **1.5.0** (published 2023-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install project-afael-hlw
pnpm add project-afael-hlw
yarn add project-afael-hlw
bun add project-afael-hlw
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2023-02-22 |
| First published | 2023-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 62.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fcanozkan |

## Links

- npm: https://www.npmjs.com/package/project-afael-hlw
- npm.io page: https://npm.io/package/project-afael-hlw

## Dependencies (4)

- [ramda](https://npm.io/package/ramda.md) ^0.28.0
- [redis](https://npm.io/package/redis.md) ^4.6.4
- [warp-contracts](https://npm.io/package/warp-contracts.md) ^1.2.52
- [project-afael-snkrj](https://npm.io/package/project-afael-snkrj.md) ^1.1.2

## Recent versions

- 1.5.0 (latest) — 2023-02-22
- 1.4.5 — 2023-02-21
- 1.4.4 — 2023-02-21
- 1.4.3 — 2023-02-21
- 1.4.2 — 2023-02-21
- 1.4.1 — 2023-02-15
- 1.3.1 — 2023-02-15
- 1.3.0 — 2023-02-12
- 1.2.0 — 2023-02-11
- 1.1.5 — 2023-02-09
- 1.1.4 — 2023-02-09
- 1.1.3 — 2023-02-09
- 1.1.2 — 2023-02-07
- 1.1.1 — 2023-02-07
- 1.1.0 — 2023-02-07
- … 1 more at https://npm.io/package/project-afael-hlw/versions

## README

# HLW

HLW is a decentralized key-value database on Arweave network, powered by Warp-Contracts.

- [Setup](#setup)
  - [Installation](#installation)
  - [Supply Wallet](#supply-wallet)
  - [Deploy Contracts](#deploy-contracts)
- [Utils](#utils)
  - [Contracts Utils](#contract-utils)
  - [Wallet Utils](#wallet-utils)
  - [Bundlr Utils](#bundlr-utils)
- [Development](#development)
- [SDK methods](#sdk-methods)
  - [`setBucketSrc`](#setbucketsrc)
  - [`getBucketSrc`](#getbucketsrc)
  - [`putOne`](#putone)
  - [`putMany`](#putmany)
  - [`getOne`](#getone)
  - [`getMany`](#getmany)
  - [`getAll`](#getall)

# Setup

Setup has couple steps which you need to stick to them.

## Installation

Download the repo,

```shell
git clone https://github.com/firstbatchxyz/HollowDB.git
```

Install it with yarn,

```shell
cd HollowDB
yarn
```

## Supply Wallet

You need to supply arweave wallet jwk to the repo with some amount of AR in them.

Name your wallet as `wallet-main.json` and put it under the config/wallet as seen in the below.

```
/
├── config/
|   ├── contract/
|   └── wallet/
|       └── wallet-main.json
├── example
├── sdk
.
.
```

## Deploy Contracts

You need to build and deploy the parent and bucket contracts.

Run the following commands at the root of the repo,

```
yarn build
yarn deploy parent
yarn deploy bucket
```

`yarn build` command will build the contracts under /dist folder.

`yarn deploy` will deploy the contracts while saving the deploy results (contractTxId and srcTxId) under the /config/contract folder.

# Utils

Repo is packed with various utilities.

## Contract Utils

Deploy

## Wallet Utils

Read Wallet

## Bundlr Utils

Fund, Balance, Upload

# Development

See examples for getting started.

# SDK Methods

Crating a new SDK Object,

```javascript
import { SDK } from '../sdk/index.js';
import { getWallet } from '../src/util/getWallet.js';
import { getConfig } from '../src/util/getConfig.js';

const jwk = await getWallet('wallet-main.json');
const parentData = await getConfig('parent');

const db = new SDK(jwk, parentData.contractTxId);
```

Below are the sdk methods.

## `setBucketSrc`

Saves the SourceTxId of the previously deployed bucket contract in the parent contract state. Future bucket contract deployments will read this data from parent state, this improves ease of use while eliminating the chance of mixing bucket contract versions while deploying the bucket contracts.

```javascript
await db.setBucketSrc('bucket-src-tx-id');
```

You can find the srcTxId of the previously deployed bucket contract under the /config/contract/bucket.json or you can use config utility `getConfig()``

```javascript
const bucketData = await getConfig('bucket');
const myBucketSource = bucketData.srcTxId;
```

### `getBucketSrc`

Returns the Bucket srcTxId from parent contract state.

```javascript
const myBucketSource = await db.getBucketSrc();
```

### `putOne`

Puts one user into the DB.

```javascript
//HollowDB expects users in the following format
const usr = {
  fb_id: '1234567890123456789012345678901234567890123456789012345678901234',
  merkle_root: '1234567890123456789012345678901234567890123456789012345678901234',
  usr_vector: [0.123456, 0.123456, ...0.123456]
};

await db.putOne(usr);
```

### `putMany`

### `getOne`

Returns the user from the database with the given id.

```javascript
const res = await db.getOne(user.fb_id);
```

### `getMany`

### `getAll`

---
_Source: https://npm.io/package/project-afael-hlw · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
