From e9827396d0f3c431e76a15a4f93b52e0006f9773 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg <vandeberg@steemit.com> Date: Tue, 29 Oct 2019 16:08:04 -0700 Subject: [PATCH] Updates to SMT op serialization (#463) * Fix useTestNet Option * Bump package version * Do not set testnet in SMT test --- README.md | 7 +------ package.json | 2 +- src/api/index.js | 4 ++++ src/auth/serializer/src/types.js | 11 ++++++----- test/smt.test.js | 3 +++ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 55db293..bdc04e2 100644 --- a/README.md +++ b/README.md @@ -100,17 +100,12 @@ You need to set two Steem API options, `address_prefix` and `chain_id`. steem.api.setOptions({ address_prefix: 'TST', chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32', + useTestNet: true, }); ``` The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements. -Furthermore, you need to change asset serializations for the testnet. - -```js -Types.useTestNet = true -``` - ## Contributions Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list or on Steemit Chat channel #steemjs https://steemit.chat/channel/steemjs. diff --git a/package.json b/package.json index 0964856..15b7539 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@steemit/steem-js", - "version": "0.7.8", + "version": "0.7.9", "description": "Steem.js the JavaScript API for Steem blockchain", "main": "lib/index.js", "scripts": { diff --git a/src/api/index.js b/src/api/index.js index 54e3e4a..1a39f29 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -181,6 +181,10 @@ class Steem extends EventEmitter { this._setLogger(options); this._setTransport(options); this.transport.setOptions(options); + if( options.hasOwnProperty('useTestNet') ) + { + config.set( 'address_prefix', options.useTestNet ? 'TST' : 'STM' ) + } } setWebSocket(url) { diff --git a/src/auth/serializer/src/types.js b/src/auth/serializer/src/types.js index 448694f..629940c 100644 --- a/src/auth/serializer/src/types.js +++ b/src/auth/serializer/src/types.js @@ -10,8 +10,9 @@ const chain_types = require('./ChainTypes') import { PublicKey, Address, ecc_config } from "../../ecc" import { fromImpliedDecimal } from "./number_utils" +import Config from "../../../config.js" -const Types = { useTestNet:false } +const Types = {} module.exports = Types const HEX_DUMP = process.env.npm_config__graphene_serializer_hex_dump @@ -134,11 +135,11 @@ Types.asset = { { case "@@000000021": precision = 3 - symbol = this.useTestNet ? "TESTS" : "STEEM" + symbol = Config.get( "address_prefix" ) == "STM" ? "STEEM" : "TESTS" break case "@@000000013": precision = 3 - symbol = this.useTestNet ? "TBD" : "SBD" + symbol = Config.get( "address_prefix" ) == "STM" ? "SBD" : "TBD" break case "@@000000037": precision = 6 @@ -257,11 +258,11 @@ Types.asset_symbol = { { case "@@000000021": precision = 3 - symbol = this.useTestNet ? "TESTS" : "STEEM" + symbol = Config.get( "address_prefix" ) == "STM" ? "STEEM" : "TESTS" break case "@@000000013": precision = 3 - symbol = this.useTestNet ? "TBD" : "SBD" + symbol = Config.get( "address_prefix" ) == "STM" ? "SBD" : "TBD" break case "@@000000037": precision = 6 diff --git a/test/smt.test.js b/test/smt.test.js index adfd13e..1421f6d 100644 --- a/test/smt.test.js +++ b/test/smt.test.js @@ -11,6 +11,9 @@ describe('steem.smt:', () => { describe('smt creation ops', () => { it('signs and verifies smt_create', function(done) { + let url = steem.config.get('uri'); + steem.api.setOptions({ url: url, useAppbaseApi: true }); + let tx = { 'operations': [[ 'smt_create', { -- GitLab