Skip to content

Commit

Permalink
Updates to SMT op serialization (#463)
Browse files Browse the repository at this point in the history
* Fix useTestNet Option

* Bump package version

* Do not set testnet in SMT test
  • Loading branch information
Michael Vandeberg authored and jredbeard committed Oct 29, 2019
1 parent 0e8713a commit e982739
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions src/auth/serializer/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/smt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit e982739

Please sign in to comment.