diff --git a/README.md b/README.md index 55db2937..bdc04e28 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 09648560..15b75398 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 54e3e4ae..1a39f299 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 448694f8..629940cc 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 adfd13ed..1421f6dc 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', {