Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
snowypowers committed Apr 30, 2018
2 parents a9dfaef + 1209304 commit e7f47ef
Show file tree
Hide file tree
Showing 32 changed files with 765 additions and 983 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ build

# IDE specific
/.vscode
.idea
10 changes: 10 additions & 0 deletions docs/api-u.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ import Neon from '@cityofzion/neon-js'
Neon.u.reverseHex(hexstring)
Neon.u.num2fixed8(1)
Neon.u.ab2str(arrayBuffer)

// Conversions to hex
Neon.u.str2hexstring('normalString') // 6e6f726d616c537472696e67
Neon.u.int2hex(234) // EA
Neon.u.ab2hexstring(arrayBuffer)

// Conversion from hex
Neon.u.hexstring2str('6e6f726d616c537472696e67') // normalString
Neon.u.hex2int('EA') // 234
Neon.u.hexstring2ab(hexString)
```

The most common format is hex string. This is a string where every 2 characters represents a byte in an bytearray. `neon-js` intentionally works with hex strings because strings are easy to print and manipulate.
Expand Down
5 changes: 3 additions & 2 deletions docs/api-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ The Balance class stores the balance of the account. It is usually retrieved usi

```js
import Neon from '@cityofzion/neon-js'
// This creates a balance object but it is empty and not really useful
Neon.create.balance({net: 'TestNet', address: 'ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW'})

import {wallet, api} from '@cityofzion/neon-js'
// This form is useless as it is an empty balance.
const balance = new wallet.Balance({net: 'TestNet', address: 'ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW'})
// We get a useful balance that can be used to fill a transaction through api
const filledBalance = api.getBalanceFrom('ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW', api.neonDB)
// We get a useful balance that can be used to fill a transaction through api.neonDB
const filledBalance = api.neonDB.getBalance('MainNet','ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW')
// This contains all symbols of assets available in this balance
const symbols = filledBalance.assetSymbols
// We retrieve the unspent coins from the assets object using the symbol
Expand Down
2 changes: 1 addition & 1 deletion docs/guides-adv_multitx.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: adv_multitx
title: Advanced - Sending multiple transactions in a block
---

In this tutorial, I shall go through how can we send multiple transactions within the same block.
In this tutorial, I shall go through how we can send multiple transactions within the same block.

If you have been using the current methods `sendAsset` and `doInvoke`, you would have realised that the second transaction coming out from the same address will fail if done quickly enough. This is due to the second transaction being unaware of the first transaction and thus it tries to spend the same inputs as the first transaction has used. Therefore, this is double spending and the node rejects our second transaction.

Expand Down
2 changes: 1 addition & 1 deletion docs/guides-basic-privnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: basic_privnet
title: Basic - Using a Private Net
---

This article describes the necessary setup required in order for `neon-js` to useful on a private net.
This article describes the necessary setup required in order to use `neon-js` on a private net.

A private net is defined as a private instance of the NEO blockchain. It can be running either locally or on the cloud depending on your needs. It is useful for development work as it gives the developer all the GAS and NEO needed without having to beg and steal.

Expand Down
2 changes: 1 addition & 1 deletion docs/guides-basic_claimgas.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config = {
## Execute

```js
Neon.sendAsset(config)
Neon.claimGas(config)
.then(config => {
console.log(config.response)
})
Expand Down
6 changes: 3 additions & 3 deletions docs/guides-basic_createscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const props = {
const script = Neon.create.script(props)
```

`script` is now a hexstring that you can use in a `invokescript` RPC call or an invocationTransaction.
`script` is now a hexstring that you can use in an `invokescript` RPC call or an invocationTransaction.

```js
Neon.rpc.Query.invokeScript(script)
Expand Down Expand Up @@ -77,9 +77,9 @@ Neon.u.Fixed8.fromReverseHex('80778e06')

## Chaining scripts

Invocation transactions might be free now so we are fine with sending an transaction for every transfer but in the future, we want to aggregate them so we fully maximise the 10 free gas that we get per transaction. This is achieved by chaining scripts together.
Invocation transactions might be free now so we are fine with sending a transaction for every transfer but in the future, we want to aggregate them so we fully maximise the 10 free gas that we get per transaction. This is achieved by chaining scripts together.

`create.script` has the functionality in built for us. Let us use it to retrieve all the information about a specific token.
`create.script` has the functionality built-in for us and let's us use it to retrieve all the information about a specific token.

There are many fields that we want to know about in an NEP5 token: name, decimals, total supply, etc. Instead of performing a `invokescript` RPC call for each field, we will be combining it in a single call. The example we are using here is the testnet contract for Red Pulse.

Expand Down
2 changes: 1 addition & 1 deletion docs/guides-basic_sendasset.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ If the transaction is successful, the `txid` is attached in the response. We can

- The `sendAsset` method is found under the `api` module for named imports.
- This method only accepts one source of assets to send from. This does not support using multiple sources or multi-sig addresses.
- This supports sending assets from a smart contract by setting the `address` field to the contract's address, signing with a private key that is allowed to send from the contract and setting `sendingFromSmartContract` to true.
- This supports sending assets from a smart contract by setting the `address` field to the contract's address, signing with a private key that is allowed to send from the contract and setting `sendingFromSmartContract` to true in the configuration object.
Loading

0 comments on commit e7f47ef

Please sign in to comment.