Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dapp-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dapp-client - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

dist/client/utils.d.ts

38

dist/client/DappClient.d.ts

@@ -130,2 +130,40 @@ import { GetInfo, GetTableRow, GetTableRows, GetTableByScope, Package, Accountext, GetCurrencyStats } from "../types";

/**
* [GET /v1/chain/get_table_rows](https://developers.eos.io/eosio-nodeos/reference#get_table_rows)
*
* Returns all objects containing rows from the specified table.
*
* @param {string} code The name of the smart contract that controls the provided table
* @param {string} scope The account to which this data belongs
* @param {string} table The name of the table to query
* @param {string} lower_bound_key Key value to identify `lower_bound` object
* @param {object} [options={}] optional params
* @param {string} [options.lower_bound] Filters results to return the first element that is not less than provided value in set
* @param {string} [options.upper_bound] Filters results to return the first element that is greater than provided value in set
* @param {number} [options.limit=1500] Limit the result amount per `get_table_rows` API request
* @param {boolean} [options.show_payer=false] Show Payer
* @param {boolean} [options.json=true] JSON response
* @param {number} [options.index_position=1] Position of the index used
* @param {string} [options.key_type] Type of key specified by index_position (for example - uint64_t or name)
* @param {string} [options.table_key] Table Key
* @param {string} [options.encode_type] Encode type
* @param {number} [options.delay_ms] Delay in ms between API calls (helps prevents rate limited APIs)
* @returns {Promise<GetTableRows>} table rows
* @example
*
* const response = await rpc.get_all_table_rows("<code>", "<scope>", "<table>", "<lower_bound_key>");
* console.log(response);
*/
get_all_table_rows<T = unknown>(code: string, scope: string, table: string, lower_bound_key: string, options?: {
index_position?: number;
json?: boolean;
key_type?: string;
lower_bound?: string;
upper_bound?: string;
table_key?: string;
encode_type?: string;
show_payer?: boolean;
limit?: number;
delay_ms?: number;
}): Promise<GetTableRows<T>>;
/**
* [GET /v1/dsp/ipfsservice1/get_table_row](https://docs.liquidapps.io)

@@ -132,0 +170,0 @@ *

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {

@@ -11,2 +19,3 @@ if (mod && mod.__esModule) return mod;

const endpoints = __importStar(require("../types/endpoints"));
const utils_1 = require("../utils");
const types_1 = require("../types");

@@ -150,2 +159,77 @@ const HttpClient_1 = require("./HttpClient");

/**
* [GET /v1/chain/get_table_rows](https://developers.eos.io/eosio-nodeos/reference#get_table_rows)
*
* Returns all objects containing rows from the specified table.
*
* @param {string} code The name of the smart contract that controls the provided table
* @param {string} scope The account to which this data belongs
* @param {string} table The name of the table to query
* @param {string} lower_bound_key Key value to identify `lower_bound` object
* @param {object} [options={}] optional params
* @param {string} [options.lower_bound] Filters results to return the first element that is not less than provided value in set
* @param {string} [options.upper_bound] Filters results to return the first element that is greater than provided value in set
* @param {number} [options.limit=1500] Limit the result amount per `get_table_rows` API request
* @param {boolean} [options.show_payer=false] Show Payer
* @param {boolean} [options.json=true] JSON response
* @param {number} [options.index_position=1] Position of the index used
* @param {string} [options.key_type] Type of key specified by index_position (for example - uint64_t or name)
* @param {string} [options.table_key] Table Key
* @param {string} [options.encode_type] Encode type
* @param {number} [options.delay_ms] Delay in ms between API calls (helps prevents rate limited APIs)
* @returns {Promise<GetTableRows>} table rows
* @example
*
* const response = await rpc.get_all_table_rows("<code>", "<scope>", "<table>", "<lower_bound_key>");
* console.log(response);
*/
get_all_table_rows(code, scope, table, lower_bound_key, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
// Optional params from `get_table_rows`
const json = options.json === false ? false : true;
const index_position = options.index_position || 1;
const limit = options.limit || 1500;
const key_type = options.key_type || "";
const table_key = options.table_key || "";
const upper_bound = options.upper_bound || "";
const encode_type = options.encode_type || "";
const show_payer = options.show_payer === true ? true : false;
// Delay in ms between API calls (helps prevents rate limited APIs)
const delay_ms = options.delay_ms || 10;
// Track latest used `lower_bound` unique identifier key
let lower_bound = options.lower_bound || "";
// Data container
const rows = new Map();
while (true) {
const response = yield this.get_table_rows(code, scope, table, {
json,
index_position,
limit,
key_type,
table_key,
lower_bound,
upper_bound,
encode_type,
show_payer,
});
for (const row of response.rows) {
// Adding to Map removes duplicates entries
const key = row[lower_bound_key];
rows.set(key, row);
// Set lower bound
lower_bound = key;
}
// prevent hitting rate limits from API endpoints
yield utils_1.delay(delay_ms);
// end of table rows
if (response.more === false) {
break;
}
}
return {
more: false,
rows: Array.from(rows.values()),
};
});
}
/**
* [GET /v1/dsp/ipfsservice1/get_table_row](https://docs.liquidapps.io)

@@ -152,0 +236,0 @@ *

8

dist/client/HttpClient.js

@@ -10,12 +10,6 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const error_1 = require("../types/error");
const debug_1 = __importDefault(require("debug"));
function inferFetch(fetch) {
const debug = debug_1.default("dapp:http");
if (fetch !== undefined) {
debug("Using user provided `fetch` option.");
return fetch;

@@ -35,3 +29,2 @@ }

if (typeof window !== "undefined" && window.fetch != null) {
debug("Using `fetch` global value found on 'window' variable (Browser environment).");
return window.fetch.bind(window);

@@ -41,3 +34,2 @@ }

if (typeof global !== "undefined" && global.fetch != null) {
debug("Using `fetch` global value found on 'global' variable (Node.js environment).");
return global.fetch.bind(global);

@@ -44,0 +36,0 @@ }

@@ -0,4 +1,3 @@

export { DappClient } from "./DappClient";
export * from "./types";
export { DappClient } from "./client/DappClient";
import * as actions from "./actions/index";
export { actions };
export * from "./utils";

18

dist/index.js

@@ -5,18 +5,10 @@ "use strict";

}
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// DappClient API
var DappClient_1 = require("./DappClient");
exports.DappClient = DappClient_1.DappClient;
// TypeScript Definitions
__export(require("./types"));
// Dapp API
var DappClient_1 = require("./client/DappClient");
exports.DappClient = DappClient_1.DappClient;
// commonly used DAPP actions used to perform EOSIO actions
const actions = __importStar(require("./actions/index"));
exports.actions = actions;
// Utility methods
__export(require("./utils"));
//# sourceMappingURL=index.js.map
{
"name": "dapp-client",
"version": "0.5.0",
"version": "0.6.0",
"description": "DAPP JavaScript/TypeScript Client Library",
"license": "MIT",
"main": "dist/index.js",

@@ -20,4 +21,10 @@ "types": "dist/index.d.ts",

],
"directories": {
"example": "examples"
},
"homepage": "https://github.com/EOS-Nation/dapp-client-js",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/EOS-Nation/dapp-client-js.git"
},
"devDependencies": {

@@ -36,8 +43,3 @@ "@types/debug": "*",

},
"dependencies": {
"debug": "*"
},
"directories": {
"example": "examples"
}
"dependencies": {}
}

@@ -58,64 +58,37 @@ # DAPP JavaScript/TypeScript Client Library

- [DAPP](#dapp)
- [Examples](#examples)
- [DappClient](#dappclient)
- [Parameters](#parameters)
- [Examples](#examples-1)
- [Examples](#examples)
- [get_table_package](#get_table_package)
- [Parameters](#parameters-1)
- [Examples](#examples-2)
- [Examples](#examples-1)
- [get_table_accountext](#get_table_accountext)
- [Parameters](#parameters-2)
- [Examples](#examples-3)
- [Examples](#examples-2)
- [get_table_rows](#get_table_rows)
- [Parameters](#parameters-3)
- [Examples](#examples-3)
- [get_all_table_rows](#get_all_table_rows)
- [Parameters](#parameters-4)
- [Examples](#examples-4)
- [dsp_get_table_row](#dsp_get_table_row)
- [Parameters](#parameters-4)
- [Parameters](#parameters-5)
- [Examples](#examples-5)
- [get_table_by_scope](#get_table_by_scope)
- [Parameters](#parameters-5)
- [Parameters](#parameters-6)
- [Examples](#examples-6)
- [get_currency_balance](#get_currency_balance)
- [Parameters](#parameters-6)
- [Parameters](#parameters-7)
- [Examples](#examples-7)
- [get_currency_stats](#get_currency_stats)
- [Parameters](#parameters-7)
- [Parameters](#parameters-8)
- [Examples](#examples-8)
- [get_info](#get_info)
- [Examples](#examples-9)
- [claimrewards](#claimrewards)
- [Parameters](#parameters-8)
- [DAPP](#dapp)
- [Examples](#examples-10)
- [closeprv](#closeprv)
- [delay](#delay)
- [Parameters](#parameters-9)
- [Examples](#examples-11)
- [modifypkg](#modifypkg)
- [Parameters](#parameters-10)
- [refund](#refund)
- [Parameters](#parameters-11)
- [Examples](#examples-12)
- [regpkg](#regpkg)
- [Parameters](#parameters-12)
- [selectpkg](#selectpkg)
- [Parameters](#parameters-13)
- [stake](#stake)
- [Parameters](#parameters-14)
- [transfer](#transfer)
- [Parameters](#parameters-15)
- [unstake](#unstake)
- [Parameters](#parameters-16)
### DAPP
DAPP
#### Examples
```javascript
import { names } from "dapp-client"
names.DAPP // => "......2ke1.o4"
```
### DappClient

@@ -129,4 +102,6 @@

- `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** optional params (optional, default `{}`)
- `options.dappservices` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** dappservices code (optional, default `"dappservices"`)
- `options.ipfsservice1` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** ipfsservice1 code (optional, default `"ipfsservice1"`)
- `options.dappservices` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** DAPP Services contract (optional, default `"dappservices"`)
- `options.ipfsservice1` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** IPFS Services contract (optional, default `"ipfsservice1"`)
- `options.oracleservic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Oracle Services contract (optional, default `"oracleservic"`)
- `options.cronservices` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Cron Services contract (optional, default `"cronservices"`)
- `options.fetch` **[Fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API)** fetch (optional, default `global.fetch`)

@@ -243,2 +218,35 @@

#### get_all_table_rows
[GET /v1/chain/get_table_rows](https://developers.eos.io/eosio-nodeos/reference#get_table_rows)
Returns all objects containing rows from the specified table.
##### Parameters
- `code` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the smart contract that controls the provided table
- `scope` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The account to which this data belongs
- `table` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the table to query
- `lower_bound_key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Key value to identify `lower_bound` object
- `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** optional params (optional, default `{}`)
- `options.lower_bound` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Filters results to return the first element that is not less than provided value in set
- `options.upper_bound` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Filters results to return the first element that is greater than provided value in set
- `options.limit` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Limit the result amount per `get_table_rows` API request (optional, default `1500`)
- `options.show_payer` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Show Payer (optional, default `false`)
- `options.json` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** JSON response (optional, default `true`)
- `options.index_position` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Position of the index used (optional, default `1`)
- `options.key_type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Type of key specified by index_position (for example - uint64_t or name)
- `options.table_key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Table Key
- `options.encode_type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Encode type
- `options.delay_ms` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Delay in ms between API calls (helps prevents rate limited APIs)
##### Examples
```javascript
const response = await rpc.get_all_table_rows("<code>", "<scope>", "<table>", "<lower_bound_key>");
console.log(response);
```
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;GetTableRows>** table rows
#### dsp_get_table_row

@@ -357,129 +365,28 @@

### claimrewards
### DAPP
ACTION
DAPP
`dappservices::claimrewards`
#### Parameters
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
#### Examples
```javascript
claimrewards("<DSP Provider>");
```
import { names } from "dapp-client"
### closeprv
ACTION
`dappservices::closeprv`
#### Parameters
- `owner` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
#### Examples
```javascript
closeprv("<Account>", "ipfsservice1", "<DSP Provider>")
names.DAPP // => "......2ke1.o4"
```
### modifypkg
### delay
ACTION
Promise based timeout delay
`dappservices::modifypkg`
#### Parameters
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `package_id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `api_endpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** std::string
- `package_json_uri` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** std::string
- `ms` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Milisecond delay
### refund
ACTION
`dappservices::refund`
#### Parameters
- `to` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `symcode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** symbol_code
#### Examples
```javascript
refund("<Account>", "<DSP Provider>", "ipfsserver1", "DAPP")
await delay(100);
```
### regpkg
ACTION
`dappservices::regpkg`
#### Parameters
- `newpackage` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** package
### selectpkg
ACTION
`dappservices::selectpkg`
#### Parameters
- `owner` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `pkg` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
### stake
ACTION
`dappservices::stake`
#### Parameters
- `from` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `quantity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** asset
### transfer
ACTION
`dappservices::transfer`
#### Parameters
- `from` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `to` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `quantity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** asset
- `memo` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** string
### unstake
ACTION
`dappservices::unstake`
#### Parameters
- `to` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `provider` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `service` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name
- `quantity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** asset
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;void>**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc