Skip to content

Commit

Permalink
Release/3.3.0 (#417)
Browse files Browse the repository at this point in the history
* Realign/3.2.1 (#412)

* chore(package): Bump version to 2.4.1

* chore(Adjust CHANGELOG):

* chore(CAHNGELOG): Fix typo

* docs(USAGE): Fix networkId in Wallet example

* fix(Http): Remove userAgent from axios

* chore(CHANGELOG): Fix typo

* docs(*): Regenrate docs

* chore(bump version in package):

* chore(CHANGELOG): Adjust changelog to conventional changelog style

* chore(Docker): Update node version tot 2.3.0

* docs(CHANGELOG): Adjust release

* feat(npm): Add script for auto-generating changelog

* chore(Node): downgrade to 2.2.0 due to failed channel test

* fix(Channel): Fix failing test on 2.3.0 node

* chore(package-lock): adjust package-lock

* chore(Channel): Revert to 2.2.0

* docs(Docs): Regenerate docs

* refactor(node): Add txHash to sendTransaction error

* chore(package): bump version to 3.1.0

* chore(Docs): Regeneratee docs and changelog

* chore(package): Add packa-lock

* chore(changelog): Adjust closes issue

* chore(package): Bump version to 3.2.0

* docs(Docs and Changelog): Regenerate docs

* docs(CHANGELOG): Adjust changelog

* docs(CHANGELOG): Adjust changelog

* chore(Jenkions): Force jenkins

* fix(NPM): Make audit of npm packages. Remove esm from deps

* chore(Release): Bump version in package, generate CHNAGELOG

* force Jenkins

* force Jenkins

* force Jenkins

* force Jenkins

* feat(Consensus): Add function to get consensus version.  (#413)

* feat(Consensus): Add function to get conmsensus version. Get vm/abi based on node protocol

* chore(node): Remove logs

* add docs for node getProtocol

* disable channel tests

* try to fix channel test

* try to fix channel test

* Make sdk compatible with node from 2.3.0 to 4.0.0

* feat(TxBuilder): INT type must be greater or equal 0 int transaction

* feat(State Channels): Make state channels compatible with aeternity v… (#415)

* feat(State Channels): Make state channels compatible with aeternity v3.0.0

* Fix lint error

* feat(Transaction Builder): Add serializations for transactions introd… (#416)

* feat(Transaction Builder): Add serializations for transactions introduced in fortuna release

* Fix lint errors

* fix(AEP exampe): Fix contract in AEPP example

* chore(package): Bump version to 3.3.0

* fix(Node): Use universalUrl istead of ES URL

* Enable channel tests
  • Loading branch information
nduchak authored and mpowaga committed May 17, 2019
1 parent 1e6a544 commit d957cc9
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
TAG=v2.5.0
TAG=master
COMPILER_TAG=v2.1.0

20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# [3.3.0](https://github.com/aeternity/aepp-sdk-js/compare/2.4.0...3.3.0) (2019-05-17)


### Bug Fixes

* **AEP exampe:** Fix contract in AEPP example ([e2fec19](https://github.com/aeternity/aepp-sdk-js/commit/e2fec19))
fix(AEP exampe): Fix contract in AEPP example

### Features

* **Consensus:** Add function to get consensus version. ([#413](https://github.com/aeternity/aepp-sdk-js/issues/413)) ([46027cd](https://github.com/aeternity/aepp-sdk-js/commit/46027cd))
* **State Channels:** Make state channels compatible with aeternity 3.0.0 ([#415](https://github.com/aeternity/aepp-sdk-js/issues/415)) ([668e7f1](https://github.com/aeternity/aepp-sdk-js/commit/668e7f1))
* **Transaction Builder:** Add serializations for transactions introd… ([#416](https://github.com/aeternity/aepp-sdk-js/issues/416)) ([fd7b8ce](https://github.com/aeternity/aepp-sdk-js/commit/fd7b8ce))


### BREAKING CHANGES

* **NODE** Change compatibility from `2.3.0` to `3.0.0`


# [3.2.1](https://github.com/aeternity/aepp-sdk-js/compare/2.4.0...3.2.1) (2019-05-16)


Expand Down
4 changes: 4 additions & 0 deletions docker/aeternity_node_mean16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ keys:

chain:
persist: true
hard_forks:
"1": 0
"2": 2
"3": 4

mining:
autostart: true
Expand Down
18 changes: 14 additions & 4 deletions es/channel/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ channelOpen.enter = (channel) => {
export async function awaitingOffChainTx (channel, message, state) {
if (message.method === 'channels.sign.update') {
const { sign } = state
const signedTx = await sign(message.params.data.tx)
const signedTx = await sign(message.params.data.tx, { updates: message.params.data.updates })
send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
return { handler: awaitingOffChainUpdate, state }
}
Expand Down Expand Up @@ -194,7 +194,11 @@ export async function awaitingTxSignRequest (channel, message, state) {
// eslint-disable-next-line no-useless-escape
const [, tag] = message.method.match(/^channels\.sign\.([^\.]+)$/) || []
if (tag) {
const signedTx = await options.get(channel).sign(tag, message.params.data.tx)
const signedTx = await options.get(channel).sign(
tag,
message.params.data.tx,
{ updates: message.params.data.updates }
)
if (signedTx) {
send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
return { handler: channelOpen }
Expand Down Expand Up @@ -256,7 +260,10 @@ export function awaitingLeave (channel, message, state) {

export async function awaitingWithdrawTx (channel, message, state) {
if (message.method === 'channels.sign.withdraw_tx') {
const signedTx = await Promise.resolve(state.sign(message.params.data.tx))
const signedTx = await Promise.resolve(state.sign(
message.params.data.tx,
{ updates: message.params.data.updates }
))
send(channel, { jsonrpc: '2.0', method: 'channels.withdraw_tx', params: { tx: signedTx } })
return { handler: awaitingWithdrawCompletion, state }
}
Expand Down Expand Up @@ -296,7 +303,10 @@ export function awaitingWithdrawCompletion (channel, message, state) {

export async function awaitingDepositTx (channel, message, state) {
if (message.method === 'channels.sign.deposit_tx') {
const signedTx = await Promise.resolve(state.sign(message.params.data.tx))
const signedTx = await Promise.resolve(state.sign(
message.params.data.tx,
{ updates: message.params.data.updates }
))
send(channel, { jsonrpc: '2.0', method: 'channels.deposit_tx', params: { tx: signedTx } })
return { handler: awaitingDepositCompletion, state }
}
Expand Down
29 changes: 27 additions & 2 deletions es/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import axios from 'axios'
import * as R from 'ramda'
import Swagger from './utils/swagger'
import semverSatisfies from './utils/semver-satisfies'
import { URL } from 'universal-url'

function resolveUrl (url, baseUrl) {
return new URL(url, baseUrl).toString()
Expand Down Expand Up @@ -63,6 +64,27 @@ const loader = ({ url, internalUrl }) => (path, definition) => {
}
}

/**
* get consensus protocol version
* @param {Array} protocols Array of protocols
* @param {Number} height Geigh
* @return {Number} version Protocol version
*/
async function getConsensusProtocolVersion (protocols = [], height) {
if (!protocols) throw new Error('Protocols must be an array')
if (!height) height = (await this.api.getCurrentKeyBlock()).height
if (height < 0) throw new Error('height must be a number >= 0')

const { version } = protocols
.reduce(
({ effectiveAtHeight, version }, p) => height >= p.effectiveAtHeight && p.effectiveAtHeight > effectiveAtHeight
? { effectiveAtHeight: p.effectiveAtHeight, version: p.version }
: { effectiveAtHeight, version },
{ effectiveAtHeight: -1, version: 0 }
)
return version
}

/**
* {@link Swagger} based Node remote API Stamp
* @function
Expand Down Expand Up @@ -95,15 +117,18 @@ const Node = stampit({
nodeNetworkId: this.nodeNetworkId,
version: this.version
}
}
},
getConsensusProtocolVersion
},
props: {
version: null,
consensusProtocolVersion: null,
nodeNetworkId: null
}
}, Swagger, {
async init ({ forceCompatibility = false }) {
const { nodeRevision: revision, genesisKeyBlockHash: genesisHash, networkId } = await this.api.getStatus()
const { nodeRevision: revision, genesisKeyBlockHash: genesisHash, networkId, protocols } = await this.api.getStatus()
this.consensusProtocolVersion = await this.getConsensusProtocolVersion(protocols)
if (
!semverSatisfies(this.version.split('-')[0], NODE_GE_VERSION, NODE_LT_VERSION) &&
!forceCompatibility
Expand Down
14 changes: 11 additions & 3 deletions es/tx/builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function validateField (value, key, type, prefix) {
// Validate type of value
switch (type) {
case FIELD_TYPES.int:
return assert(!isNaN(value) || BigNumber.isBigNumber(value), { value })
const isMinusValue = (!isNaN(value) || BigNumber.isBigNumber(value)) && BigNumber(value).lt(0)
return assert((!isNaN(value) || BigNumber.isBigNumber(value)) && BigNumber(value).gte(0), { value, isMinusValue })
case FIELD_TYPES.id:
return assert(PREFIX_ID_TAG[value.split('_')[0]] && value.split('_')[0] === prefix, { value, prefix })
case FIELD_TYPES.binary:
Expand Down Expand Up @@ -301,7 +302,10 @@ export function buildTx (params, type, { excludeKeys = [], prefix = 'tx' } = {})
if (!TX_SERIALIZATION_SCHEMA[type]) {
throw new Error('Transaction serialization not implemented for ' + type)
}
const [schema, tag] = TX_SERIALIZATION_SCHEMA[type]
if (!TX_SERIALIZATION_SCHEMA[type][VSN]) {
throw new Error('Transaction serialization not implemented for ' + type + ' version ' + VSN)
}
const [schema, tag] = TX_SERIALIZATION_SCHEMA[type][VSN]
const binary = buildRawTx({ ...params, VSN, tag }, schema, { excludeKeys }).filter(e => e !== undefined)

const rlpEncoded = rlp.encode(binary)
Expand All @@ -326,7 +330,11 @@ export function unpackTx (encodedTx, fromRlpBinary = false) {
if (!TX_DESERIALIZATION_SCHEMA[objId]) {
return { message: 'Transaction deserialization not implemented for tag ' + objId }
}
const [schema] = TX_DESERIALIZATION_SCHEMA[objId]
const vsn = readInt(binary[1])
if (!TX_DESERIALIZATION_SCHEMA[objId][vsn]) {
return { message: 'Transaction deserialization not implemented for tag ' + objId + ' version ' + vsn }
}
const [schema] = TX_DESERIALIZATION_SCHEMA[objId][vsn]

return { txType: OBJECT_ID_TX_TYPE[objId], tx: unpackRawTx(binary, schema), rlpEncoded, binary }
}
Expand Down
Loading

0 comments on commit d957cc9

Please sign in to comment.