Skip to content

Commit

Permalink
Merge pull request #42 from ostdotcom/develop
Browse files Browse the repository at this point in the history
Support for new API route - base-tokens
  • Loading branch information
kedarchandrayan authored Jun 3, 2019
2 parents ebb1b94 + c988bd1 commit c8bb5f8
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[OST JAVA SDK v2.1.0](https://github.com/ostdotcom/ost-sdk-java/tree/v2.1.0)
---

* Added base tokens module to V2 API's

[OST Javascript SDK v2.0.0](https://github.com/ostdotcom/ost-sdk-js/tree/v2.0.0)
---

* OST API V2 interaction layer implementation.
* Removed API V0 and V1 support.
* [README.md](README.md) has API V2 usage instructions


[OST Javascript SDK v1.1.0](https://github.com/ostdotcom/ost-sdk-js/tree/v1.1.0)
---

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 OST.com Ltd.
Copyright (c) 2019 OST.com Inc.

MIT License

Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
[![Build Status](https://travis-ci.org/ostdotcom/ost-sdk-js.svg?branch=develop)](https://travis-ci.org/ostdotcom/ost-sdk-js)


The official [OST](https://dev.ost.com/) JavaScript SDK.
[OST](https://dev.ost.com/) Platform SDK for JavaScript.

## Introduction

OST is a complete technology solution enabling mainstream businesses
to easily launch blockchain-based economies without
requiring blockchain development.

At the core of OST is the concept of OST-powered Brand Tokens (BTs).
BTs are white-label cryptocurrency tokens with utility representations
Brand Tokens (BTs) are white-label cryptocurrency tokens with utility representations
running on highly-scalable Ethereum-based side blockchains,
backed by OST tokens staked on Ethereum mainnet. Within a business’s
backed by value token (such as OST, USDC) staked on Ethereum mainnet. Within a business’s
token economy, BTs can only be transferred to whitelisted user addresses.
This ensures that they stay within the token economy.

Expand Down Expand Up @@ -56,8 +55,7 @@ Initialize the SDK object:

```node.js
// the latest valid API endpoint is "https://api.ost.com/mainnet/v2/"
const ostObj = new OSTSDK({apiKey: <api_key>, apiSecret: <api_secret>, apiEndpoint: <api_endpoint>,
config: {timeout: <timeout>});
const ostObj = new OSTSDK({apiKey: <api_key>, apiSecret: <api_secret>, apiEndpoint: <api_endpoint>,config: {timeout: <timeout>}});
```


Expand Down Expand Up @@ -240,7 +238,7 @@ rulesService.getList({}).then(function(res) { console.log(JSON.stringify(res));

#### Price Points Module

To know the OST price point in USD and when it was last updated,
To know the value token (such as OST, USDC) price point in pay currency and when it was last updated,
use services provided by the Price Points module.

```node.js
Expand Down Expand Up @@ -297,10 +295,10 @@ let transferTo = "0xa31e988eebc89d0bc3e4a9a5463545ea534593e4",
transferAmount = '1',
tokenHolderSender = "0xa9632350057c2226c5a10418b1c3bc9acdf7e2ee",
payCurrencyCode = "USD",
ostToUsd = "23757000000000000" // get price-point response
intendedPricePoint = "23757000000000000" // get price-point response
raw_calldata = JSON.stringify({
method: "pay",
parameters: [tokenHolderSender, [transferTo],[transferAmount], payCurrencyCode, ostToUsd]
parameters: [tokenHolderSender, [transferTo],[transferAmount], payCurrencyCode, intendedPricePoint]
});
meta_property = {
"name": "transaction_name" , //like, download
Expand Down Expand Up @@ -423,3 +421,18 @@ Get Chain Detail:
chainsService.get({chain_id: 2000}).then(function(res) { console.log(JSON.stringify(res)); }).catch(function(err) { console.log(JSON.stringify(err)); });
```

### Base Tokens Module

To get information about the value tokens (such as OST, USDC) available on the OST Platform interface, use services
provided by the Base Tokens module. You can use this service to obtain the base token details
on OST Platform interface.

```node.js
const baseTokensService = ostObj.services.base_tokens;
```

Get Token Detail:

```node.js
baseTokensService.get({}).then(function(res) { console.log(JSON.stringify(res)); }).catch(function(err) { console.log(JSON.stringify(err)); });
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.1.0
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "@ostdotcom/ost-sdk-js",
"version": "2.0.0",
"description": "The official OST JavaScript SDK",
"version": "2.1.0",
"description": "OST Platform SDK for JavaScript.",
"main": "index.js",
"scripts": {
"start": "index.js"
},
"keywords": [
"OST",
"Javascript",
"JavaScript",
"Node.js",
"SDK",
"SimpleToken",
"OpenST"
],
"homepage": "https://ost.com",
"author": "OST.COM LTD.",
"author": "OST.com Inc.",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
47 changes: 47 additions & 0 deletions services/base_tokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";

/**
* Base Tokens Service
*
* @module /services/base_tokens
*/

// Hide request object
var _requestObj = null;

/**
* Base tokens service constructor.
*
* @constructor
*/
const baseTokens = function (requestObj) {
const oThis = this;

// Assign request object
_requestObj = requestObj;

// Define the url prefix
oThis.urlPrefix = '/base-tokens';

return oThis;
};

baseTokens.prototype = {

/**
* Get base tokens details.
*
* @param {object} params
*
* @public
*/
get: function (params) {
const oThis = this;
params = params || {};

return _requestObj.get(oThis.urlPrefix, params);
}

};

module.exports = baseTokens;
4 changes: 3 additions & 1 deletion services/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const rootPrefix = ".."
, recoveryOwnersKlass = require(rootPrefix + '/services/recovery_owners')
, rulesKlass = require(rootPrefix + '/services/rules')
, transactionsKlass = require(rootPrefix + '/services/transactions')

, baseTokensKlass = require(rootPrefix + '/services/base_tokens')
;

// hide request object
Expand Down Expand Up @@ -48,6 +48,7 @@ const manifest = function (params) {
oThis.recovery_owners = new recoveryOwnersKlass(_requestObj);
oThis.rules = new rulesKlass(_requestObj);
oThis.transactions = new transactionsKlass(_requestObj);
oThis.base_tokens = new baseTokensKlass(_requestObj);

return oThis;
};
Expand Down Expand Up @@ -76,6 +77,7 @@ manifest.prototype = {

transactions: null,

base_tokens: null
};

module.exports = manifest;
11 changes: 11 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const rootPrefix = "..",
recoveryOwnersService = ostObj.services.recovery_owners,
rulesService = ostObj.services.rules,
transactionsService = ostObj.services.transactions,
baseTokensService = ostObj.services.base_tokens,


userId = process.env.OST_KIT_USER_ID,
Expand Down Expand Up @@ -307,6 +308,15 @@ function testSignature() {
});
}

function getBaseTokensDetails() {

it("test get base token details ", async function () {
let res = await baseTokensService.get({}).catch(function (err) {
assert.fail('get base token details testcase is failed');
});
assert.equal(res.success, true);
});
}

async function generateRandomAddrs() {
let buffer = await require('crypto').randomBytes(20);
Expand All @@ -315,6 +325,7 @@ async function generateRandomAddrs() {


function testcases() {
getBaseTokensDetails();
createUser();
userList();
getChain();
Expand Down

0 comments on commit c8bb5f8

Please sign in to comment.