Changelog (v3)
3.11.9
Fixes
- Fix balance calculation after applying transaction.
- Remove applyTx call from Balance.calculate.
- fix getVersion parsing.
- Fix typings for
buildMultiSig. - Fix ScriptBuilder's integer not emitted as two's complement.
- Lock dependencies to specific versions.
- Adjust ScriptBuilder for dnagling instructions.
3.11.0
Wallet
- Add multi-sig support through
Account.createMultiSig.
- Add multi-sig support through
Transaction
- Add multi-sig support through
Witness.buildMultiSig.
- Add multi-sig support through
3.10.1
Fixes
- Adjust default timeout for rpc calls to 30s from 5s.
3.10.0
API
getTokenBalancesto retrieve multiple token balances for a single address within a single HTTP call.setupVoteis a new method that allows you to setup your voting status for your neo.
const config = { net: "TestNet", account: new wallet.Account(privateKey), candidateKeys: [key1, key2], // Keys retrieved from a getValidators call. }; Neon.api.setupVote(config);RPC
getvalidatorscall added. This call returns the list of possible candidates as well as their current vote tally.
Wallet
verifySignatureas the counterpart togenerateSignature. This makes it possible to verify signatures of pure hexstrings.- State Transaction support is added.
Website
- Redirect static package to use unpkg. This will serve the latest browser.js that is published.
3.9.2
Fixes
- Change default return value of contract in deployContract to ff00
- Fix bug in
getRPCEndpointwhere we drop the list when finding a new best height - Fix bug in
getRPCEndpointwhere a rejected promise was ending the Promise.race - Remove neonDB tests
3.9.1
Fixes
- Added
sendingFromSmartContractfor claimGas.
3.9.0
- Added
Smart Contract
- Add Runtime.Deserialize logic. This is the deserialization logic found in the VM.
import { sc } from "@cityofzion/neon-js"; sc.deserialize("800200126d65737361676520746f206d7973656c66210204438ffc5a");Fixes
- All class constructors now accept optional parameters. This means that all classes should be easily instantiated with defaults if required.
- Update dump logic for managed methods to dump fees.
3.8.1
Fixes
- Typings update
3.8.0
Transactions
- Transactions now support attaching fees
API
- Neoscan
getTransactionHistoryis updated to use a paginated endpoint. It currently only supports a single page but it should speed up loading by a significant amount. The downside is that it will not return the full history.
- Neoscan
Fixes
getRPCEndpointis adjusted to also return RPCs that are only 1 block behind the best height. This reduces the load on a single RPC on the chance that only 1 endpoint has the best height. This should increase RPC reliability while not sacrificing too much in terms of information.
3.7.3
Fixes
- Fix scriptBuilder to ScriptParams error parsing nonce
- Use generateRandomArray in attachAttributes
- Fix timeout setting for api calls
- Correct semantic API for verify
- Typings update
3.7.0
RPC
- RPC Client now has the fields
latencyandlastSeenHeightand methodping().
import {rpc} from '@cityofzion/neon-js var client = new rpc.RPCClient(url) client.ping() .then(ms => { console.log(ms) // latency in milliseconds. Max of 2000 (default timeout for ping) console.log(client.latency) // This is an average of last 5 values retrieved using ping() console.log(client.lastSeenHeight) // This is filled whenever getBlockCount is called })- RPC Client now takes an extra argument
configwhich exposes the underlying axios instance, allowing users to customize the axios configuration.
- RPC Client now has the fields
API
- Add attribute and remark for signing empty transactions. Now if you use
doInvokefor your token transfers, it will automatically setup your transaction to be accepted by the NEO node without the need for any asset inputs. claimGasnow accepts aclaimsproperty as an override for claims. This behavior is inline withsendAssetanddoInvokeacceptingbalanceoverrides.getRPCEndpointnow ensures that the returned endpoint is callable by doing a ping check internally. It will also cache the endpoint to return next time instead of repeatedly pinging every single healthy node.
- Add attribute and remark for signing empty transactions. Now if you use
Settings
- Settings now contain
timeoutwhich setups the timeouts forpingand all rpc calls
- Settings now contain
Fixes
- Fix faulty url in networks config file
- Fix typings for strategy
- Update
neoscan.getMaxClaimAmountto useget_unclaimedendpoint
3.6.2
Fixes
wallet.decryptAsyncto properly reject all errors- fix
balancedApproachcalculation strategy to consider bigger coins when insufficient small coins - Fix typo in typings
3.6.0
Transaction
- Add calculation strategies to modify how inputs are selected. Current
available strategies are
smallestFirst,biggestFirstandbalancedApproach. Currently only available as a global setting.
import { tx, settings } from "@cityofzion/neon-js"; // Change the strategy to use the biggest valued output available. settings.defaultCalculationStrategy = tx.calculationStrategy.biggestFirst; // See all available strategies console.log(tx.calculationStrategy);3.5.0
- Add calculation strategies to modify how inputs are selected. Current
available strategies are
Wallet
- Add scripthash support.
Accountnow accepts scripthash as a constructor andisScriptHashis available as a verification method.
- Add scripthash support.
SC
- Add arguments for handling specific ContractParam transformation. The first one to do this is Fixed8 which takes a decimals argument which adjusts the number to the number of decimals given. This is useful for contracts that use decimals places other than 8.
3.4.5
Docs
- Add 2 new guides around
doInvoke
- Add 2 new guides around
Fixes
- Fix script ordering for mintTokens
- Remove
newfor Coin - Revert upgrade for bignumber.js
- Fix typings and add typings check
- Fix
ScriptBuilder._emitStringfor large strings
3.4.0
Settings
There is now global settings that control how
neon-jsworks. The first settings available arehttpsOnlyandnetworks.httpsOnlyis a boolean which will force neonDB and neoscan to return only https RPC nodes. Do note that an error will be thrown if no suitable nodes are found.networksis an object containing every network configuration available for consumption. It comes default withMainNet,TestNetandCozNet. For now, these configurations only determine the neonDB/neoscan urls used for each network but they will serve more purposes in the future.
RPC
- Network class representing a NEO network. This can be created by importing a
protocol file or just manually entering the parameters. This is the new way
which we can link
neon-jsto a private net that comes with a neoscan or neonDB setup.
- Network class representing a NEO network. This can be created by importing a
protocol file or just manually entering the parameters. This is the new way
which we can link
Smart Contract
- ScriptBuilder.toScriptParams allows you to reverse engineer a VM script back to its arguments. Due to the varied nature of the arguments, it is not possible to reverse it completely. More work has to be done on the user side to parse it in a meaningful manner.
const sb = new sb.ScriptBuilder( "00c1046e616d65675f0e5a86edd8e1f62b68d2b3f7c0a761fc5a67dc" ); const params = sb.toScriptParams(); params = [ { scriptHash: "dc675afc61a7c0f7b3d2682bf6e1d8ed865a0e5f", args: [ "6e616d65", // 'name' in hexstring [], ], useTailCall: false, }, ];Wallet
- New methods added for signing and verifying messages:
signMessage,verifyMessage
- New methods added for signing and verifying messages:
Docs
- Docs migrated to Docusaurus! This will make it easier to customize docs and also allow us to support Chinese as the alternative language.
Development
- Upgraded dependencies to use webpack v4 and the new babel exports from its monorepo.
Fixes
- Fix neonDB and neoscan
getTransactionHistory. Do note that this can be considered a breaking change for some as the return structure has changed. However, this is considered a fix as the original return structure was not intended. - new Wallet to use default scrypt params when not provided.
- Typescript typings refactored and cleaned up. Introduces the object-like interfaces which are the neon-js classes exported as plain javascript objects.
3.3.2
- Fix neonDB and neoscan
Fixes
- Update typescript typings
- Use user provided parameters when given for api core methods
- Fix ScriptBuilder to accept empty string and zero value
- neonDB to use
get_all_nodesendpoint instead ofbest_nodeendpoint - Fix neoscan
getMaxClaimAmount,getBalanceandgetClaimsfor invalid addresses
3.3.0
API
- Add support for manpulating smart contracts. This means that you can send
assets from smart contracts. This support is currently enabled only in the
core API methods
sendAssetanddoInvoke. This is currently experimental and is subject to breaking changes without notice (no minor version bump for changes to these). - Add support for
config.account. You can now use Account in place of address and private key. - Add support for
config.balance. You can use an old Balance object instead of retrieving a new one. Attaching a Balance object will cause the function to skip over the retrieval process.
- Add support for manpulating smart contracts. This means that you can send
assets from smart contracts. This support is currently enabled only in the
core API methods
Wallet
- Add
confirmto Balance object.
- Add
SC
- Add ContractParam.hash160
Util
- Add
isHexandensureHexas ways to conveniently check format of hexstrings.
- Add
Fixes
- Add more logging messages throughout.
api.signTxnow checks and converts the return value from external function to a Transaction object.- Fix regex string for
rpc.getVersion.
3.2.1
Update typescript typings
3.2.0
Wallet
- Implement encryptAsync and decryptAsync using a new scrypt library. Further work will be done to convert the existing encrypt/decrypt to use the new library.
- Claims object is now slicable, allowing users to break up the Claims object into smaller Claims.
Util
- Override more methods in Fixed8 to return Fixed8s.
- Update util functions to use Fixed8 internally.
API
- Mark
api.nep5.doTransferTokenfor deprecation.
- Mark
Sc
- createScript now accepts an array of scripts to parse and concatenate.
Docs
- Start to overhaul docs to favor examples and integrating the reference into the main docs instead of having it as a standalone section.
Others
- NPM packages updated to latest.
Fixes
- Fix scryptParams to use n,r,p
- Update default RPC endpoints to use https
- Fix Account defaults
- Fix _emitNum emitting trimmed hex numbers
3.1.0
API
- Expose the
loadBalancemethod. This method allows the use of the dynamic API switch withinneon-jsfor the external providers. - Implement the full set of APIs on neoscan. Neoscan is now complete and up to par with neonDB in terms of features.
- Expose
getXFromset of methods which follow the API config convention and is usable with the loadBalance function.
3.0.0
- Expose the
Logging
- Setup logging directed at
stdoutandstderr. Logging package is loglevel. - Defaults to silent.
- Not exposed through semantic style currently.
- All deprecation messages are set to 'warn' level.
- See logging for more details.
- Setup logging directed at
Utils
- Fixed8: A new class extending bignumber.js that replaces all value storage in neon-js
- This class is now used for all classes that involves coin values with decimal places.
- Comes with helper methods such as
toHexandfromHex.
import { u } from "@cityofzion/neon-js";
// accepts numbers or string
const num1 = new u.Fixed8(123.4567);
const num2 = u.Fixed8.fromHex("0000000005f5e100"); // 1
const num3 = num1.add(num2); // immutable
console.log(num3.toString()); // '124.4567'
Wallet
Claimsis now a ES6 class. While it does not have any spceial methods for it now, it is one of the high level objects that we will be working with inneon-js. This allows easy creation ofClaimsusing the constructor by passing in a CLaims-like javascript object.componentshave been created for the minor sub-components found inClaimsandBalance. These methods are useful for us to rapidly create components that are usable withneon-jsmethods. Refer to the wallet section for more information.- BREAKING Excess NEP2 functions are now fully deprecated. The list is
encryptWifAccount,generateENcryptedWif,encryptWIF,decryptWIF.
Transaction
- Update all methods to conform with the new Fixed8 classes. This also means
that
neon-jswill not be compatible with just normal javascript objects anymore.
- Update all methods to conform with the new Fixed8 classes. This also means
that
API
- BREAKING Update external API libraries (neonDB and neoscan) to return
BalanceandClaimsobjects. Fixed8 will be used in the new models, making arithmetic operations very different from normal javascript numbers. - A bug has been discovered in
getPrice. While it works for NEO and GAS, it will not work for any of the NEP5 tokens.getPriceshas been fixed for this bug. However, there is no easy fix forgetPriceand thus, we will move forward with deprecatinggetPricein favor ofgetPrices.
- BREAKING Update external API libraries (neonDB and neoscan) to return
Fixes
- fix getPrices by adding a limit=0 to the query.
- fix default Account.contract field not having the required shape.
- fix transaction attribute being deserialized wrongly.