Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 6.1.1 #785

Merged
merged 8 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Till Kolter <till.kolter@gmail.com>
Alexander Kahl <ak@sodosopa.io>
Nazar Duchak <omelko39@gmail.com>
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [6.1.1](https://github.com/aeternity/aepp-sdk-js/compare/6.1.0...6.1.1) (2019-11-12)


### Bug Fixes

* **ACI:** Disable bytecode check for source and code on-chain. This changes will be included in next major release ([#783](https://github.com/aeternity/aepp-sdk-js/issues/783)) ([fe6021b](https://github.com/aeternity/aepp-sdk-js/commit/fe6021b))


### Features

* **KeyStore:** Remove `argon2` package, use `libsodium` for both browser and node ([#782](https://github.com/aeternity/aepp-sdk-js/issues/782)) ([c18047e](https://github.com/aeternity/aepp-sdk-js/commit/c18047e))



# [6.1.0](https://github.com/aeternity/aepp-sdk-js/compare/6.0.2...6.1.0) (2019-11-11)


Expand Down Expand Up @@ -48,6 +62,8 @@





# [6.0.0](https://github.com/aeternity/aepp-sdk-js/compare/4.7.0...6.0.0) (2019-10-16)


Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
* [@aeternity/aepp-sdk/es/tx](api/tx.md)
* [@aeternity/aepp-sdk/es/tx/tx](api/tx/tx.md)
* [@aeternity/aepp-sdk/es/utils/crypto](api/utils/crypto.md)
* [@aeternity/aepp-sdk/es/utils/keystore](api/utils/keystore.md)
* [@aeternity/aepp-sdk/es/utils/swagger](api/utils/swagger.md)
1 change: 0 additions & 1 deletion docs/api/contract/aci.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Generate contract ACI object with predefined js methods for contract usage - can
| [options.aci] | `String` | | Contract ACI |
| [options.contractAddress] | `String` | | Contract address |
| [options.filesystem] | `Object` | | Contact source external namespaces map |
| [options.forceCodeCheck] | `Boolean` | <code>false</code> | Flag to force validation of corresponding on chain bytecode |
| [options.opt] | `Object` | | Contract options |

**Example**
Expand Down
6 changes: 5 additions & 1 deletion docs/api/utils/keystore.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ KeyStore module

**Example**
```js
import * as Crypto from '@aeternity/aepp-sdk/es/utils/keystore'
import * as Keystore from '@aeternity/aepp-sdk/es/utils/keystore'
```
**Example**
```js
const { Keystore } = require('@aeternity/aepp-sdk')
```

* [@aeternity/aepp-sdk/es/utils/keystore](#module_@aeternity/aepp-sdk/es/utils/keystore)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/node/aecontract.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ implementation directly in the SDK.


```js
Ae({ url: program.host, debug: program.debug, process }).then(ae => {
Ae({ url: program.host, debug: program.debug, compilerUrl: program.compilerUrl, process }).then(ae => {
return ae.contractCompile(code)

```
Expand Down
3 changes: 1 addition & 2 deletions es/ae/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import Rpc from '../rpc/server'
import * as R from 'ramda'
import Tx from '../tx/tx'
import Contract from './contract'
import NodePool from '../node-pool'
import GeneralizeAccount from '../contract/ga'

const contains = R.flip(R.contains)
Expand Down Expand Up @@ -131,7 +130,7 @@ async function rpcAddress ({ params, session }) {
onContract: confirm
})
*/
const Wallet = Ae.compose(Accounts, Chain, NodePool, Tx, Contract, GeneralizeAccount, Rpc, {
const Wallet = Ae.compose(Accounts, Chain, Tx, Contract, GeneralizeAccount, Rpc, {
init ({ onTx = this.onTx, onChain = this.onChain, onAccount = this.onAccount, onContract = this.onContract }, { stamp }) {
this.onTx = onTx
this.onChain = onChain
Expand Down
6 changes: 4 additions & 2 deletions es/chain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Chain = Oracle.compose({
Ae: {
methods: [
'sendTransaction', 'height', 'awaitHeight', 'poll', 'balance', 'getBalance', 'tx',
'mempool', 'topBlock', 'getTxInfo', 'txDryRun', 'getName', 'getNodeInfo', 'getAccount', 'getContractByteCode', 'getContract'
'mempool', 'topBlock', 'getTxInfo', 'txDryRun', 'getName', 'getNodeInfo', 'getAccount'
]
}
}
Expand All @@ -60,7 +60,9 @@ const Chain = Oracle.compose({
getTxInfo: required,
mempool: required,
txDryRun: required,
getAccount: required
getAccount: required,
getContractByteCode: required,
getContract: required
}
}))

Expand Down
15 changes: 1 addition & 14 deletions es/contract/aci/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { validateArguments, transform, transformDecodedData } from './transforma
import { buildContractMethods, getFunctionACI } from './helpers'
import AsyncInit from '../../utils/async-init'
import { BigNumber } from 'bignumber.js'
import { isAddressValid } from '../../utils/crypto'

/**
* Validated contract call arguments using contract ACI
Expand Down Expand Up @@ -62,7 +61,6 @@ async function prepareArgsForEncode (aci, params) {
* @param {String} [options.aci] Contract ACI
* @param {String} [options.contractAddress] Contract address
* @param {Object} [options.filesystem] Contact source external namespaces map
* @param {Boolean} [options.forceCodeCheck = false] Flag to force validation of corresponding on chain bytecode
* @param {Object} [options.opt] Contract options
* @return {ContractInstance} JS Contract API
* @example
Expand All @@ -73,7 +71,7 @@ async function prepareArgsForEncode (aci, params) {
* Also you can call contract like: await contractIns.methods.setState(123, options)
* Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is stateful or not
*/
async function getContractInstance (source, { aci, contractAddress, filesystem = {}, forceCodeCheck = false, opt } = {}) {
async function getContractInstance (source, { aci, contractAddress, filesystem = {}, opt } = {}) {
aci = aci || await this.contractGetACI(source, { filesystem })
const defaultOptions = {
skipArgsConvert: false,
Expand All @@ -100,17 +98,6 @@ async function getContractInstance (source, { aci, contractAddress, filesystem =
this.options = R.merge(this.options, opt)
}
}
// Check for valid contract address and contract code
if (contractAddress) {
if (!isAddressValid(contractAddress, 'ct')) throw new Error('Invalid contract address')
const contract = await this.getContract(contractAddress).catch(e => null)
if (!contract) throw new Error(`Contract with address ${contractAddress} not found on-chain`)
if (!forceCodeCheck) {
const onChanByteCode = (await this.getContractByteCode(contractAddress)).bytecode
instance.compiled = (await this.contractCompile(source, instance.options)).bytecode
if (instance.compile !== onChanByteCode) throw new Error('Contract source do not correspond to the contract source deploying on the chain')
}
}

/**
* Compile contract
Expand Down
43 changes: 19 additions & 24 deletions es/utils/keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import uuid from 'uuid'
import { encodeBase58Check, isBase64 } from './crypto'
import { isHex } from './string'

const _sodium = require('libsodium-wrappers-sumo')

/**
* KeyStore module
* !!!Work only in node.js!!!
Expand Down Expand Up @@ -31,30 +33,23 @@ const DERIVED_KEY_FUNCTIONS = {
}

export async function deriveKeyUsingArgon2id (password, salt, options) {
const { memlimit_kib: memoryCost, parallelism, opslimit: timeCost } = options.kdf_params
const isBrowser = !(typeof module !== 'undefined' && module.exports)

if (isBrowser) {
const _sodium = require('libsodium-wrappers-sumo')

return _sodium.ready.then(async () => {
// tslint:disable-next-line:typedef
const sodium = _sodium

const result = sodium.crypto_pwhash(
32,
password,
salt,
timeCost,
memoryCost * 1024,
sodium.crypto_pwhash_ALG_ARGON2ID13
)
return Buffer.from(result)
})
} else {
const argon2 = require('argon2')
return argon2.hash(password, { timeCost, memoryCost, parallelism, type: argon2.argon2id, raw: true, salt })
}
const { memlimit_kib: memoryCost, opslimit: timeCost } = options.kdf_params
// const isBrowser = !(typeof module !== 'undefined' && module.exports)

return _sodium.ready.then(async () => {
// tslint:disable-next-line:typedef
const sodium = _sodium

const result = sodium.crypto_pwhash(
32,
password,
salt,
timeCost,
memoryCost * 1024,
sodium.crypto_pwhash_ALG_ARGON2ID13
)
return Buffer.from(result)
})
}

// CRYPTO PART
Expand Down
Loading