Skip to content

Commit 39d3625

Browse files
authored
Merge pull request #785 from aeternity/release/6.1.1
Release 6.1.1
2 parents 2edf518 + 6b0af4e commit 39d3625

File tree

12 files changed

+109
-107
lines changed

12 files changed

+109
-107
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Till Kolter <[email protected]>
22
Alexander Kahl <[email protected]>
3+
Nazar Duchak <[email protected]>

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# [6.1.1](https://github.com/aeternity/aepp-sdk-js/compare/6.1.0...6.1.1) (2019-11-12)
2+
3+
4+
### Bug Fixes
5+
6+
* **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))
7+
8+
9+
### Features
10+
11+
* **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))
12+
13+
14+
115
# [6.1.0](https://github.com/aeternity/aepp-sdk-js/compare/6.0.2...6.1.0) (2019-11-11)
216

317

@@ -48,6 +62,8 @@
4862

4963

5064

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

5369

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
* [@aeternity/aepp-sdk/es/tx](api/tx.md)
2828
* [@aeternity/aepp-sdk/es/tx/tx](api/tx/tx.md)
2929
* [@aeternity/aepp-sdk/es/utils/crypto](api/utils/crypto.md)
30+
* [@aeternity/aepp-sdk/es/utils/keystore](api/utils/keystore.md)
3031
* [@aeternity/aepp-sdk/es/utils/swagger](api/utils/swagger.md)

docs/api/contract/aci.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ Generate contract ACI object with predefined js methods for contract usage - can
7171
| [options.aci] | `String` | | Contract ACI |
7272
| [options.contractAddress] | `String` | | Contract address |
7373
| [options.filesystem] | `Object` | | Contact source external namespaces map |
74-
| [options.forceCodeCheck] | `Boolean` | <code>false</code> | Flag to force validation of corresponding on chain bytecode |
7574
| [options.opt] | `Object` | | Contract options |
7675

7776
**Example**

docs/api/utils/keystore.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ KeyStore module
66

77
**Example**
88
```js
9-
import * as Crypto from '@aeternity/aepp-sdk/es/utils/keystore'
9+
import * as Keystore from '@aeternity/aepp-sdk/es/utils/keystore'
10+
```
11+
**Example**
12+
```js
13+
const { Keystore } = require('@aeternity/aepp-sdk')
1014
```
1115

1216
* [@aeternity/aepp-sdk/es/utils/keystore](#module_@aeternity/aepp-sdk/es/utils/keystore)

docs/examples/node/aecontract.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ implementation directly in the SDK.
107107
108108
109109
```js
110-
Ae({ url: program.host, debug: program.debug, process }).then(ae => {
110+
Ae({ url: program.host, debug: program.debug, compilerUrl: program.compilerUrl, process }).then(ae => {
111111
return ae.contractCompile(code)
112112

113113
```

es/ae/wallet.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import Rpc from '../rpc/server'
3131
import * as R from 'ramda'
3232
import Tx from '../tx/tx'
3333
import Contract from './contract'
34-
import NodePool from '../node-pool'
3534
import GeneralizeAccount from '../contract/ga'
3635

3736
const contains = R.flip(R.contains)
@@ -131,7 +130,7 @@ async function rpcAddress ({ params, session }) {
131130
onContract: confirm
132131
})
133132
*/
134-
const Wallet = Ae.compose(Accounts, Chain, NodePool, Tx, Contract, GeneralizeAccount, Rpc, {
133+
const Wallet = Ae.compose(Accounts, Chain, Tx, Contract, GeneralizeAccount, Rpc, {
135134
init ({ onTx = this.onTx, onChain = this.onChain, onAccount = this.onAccount, onContract = this.onContract }, { stamp }) {
136135
this.onTx = onTx
137136
this.onChain = onChain

es/chain/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const Chain = Oracle.compose({
4343
Ae: {
4444
methods: [
4545
'sendTransaction', 'height', 'awaitHeight', 'poll', 'balance', 'getBalance', 'tx',
46-
'mempool', 'topBlock', 'getTxInfo', 'txDryRun', 'getName', 'getNodeInfo', 'getAccount', 'getContractByteCode', 'getContract'
46+
'mempool', 'topBlock', 'getTxInfo', 'txDryRun', 'getName', 'getNodeInfo', 'getAccount'
4747
]
4848
}
4949
}
@@ -60,7 +60,9 @@ const Chain = Oracle.compose({
6060
getTxInfo: required,
6161
mempool: required,
6262
txDryRun: required,
63-
getAccount: required
63+
getAccount: required,
64+
getContractByteCode: required,
65+
getContract: required
6466
}
6567
}))
6668

es/contract/aci/index.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { validateArguments, transform, transformDecodedData } from './transforma
2929
import { buildContractMethods, getFunctionACI } from './helpers'
3030
import AsyncInit from '../../utils/async-init'
3131
import { BigNumber } from 'bignumber.js'
32-
import { isAddressValid } from '../../utils/crypto'
3332

3433
/**
3534
* Validated contract call arguments using contract ACI
@@ -62,7 +61,6 @@ async function prepareArgsForEncode (aci, params) {
6261
* @param {String} [options.aci] Contract ACI
6362
* @param {String} [options.contractAddress] Contract address
6463
* @param {Object} [options.filesystem] Contact source external namespaces map
65-
* @param {Boolean} [options.forceCodeCheck = false] Flag to force validation of corresponding on chain bytecode
6664
* @param {Object} [options.opt] Contract options
6765
* @return {ContractInstance} JS Contract API
6866
* @example
@@ -73,7 +71,7 @@ async function prepareArgsForEncode (aci, params) {
7371
* Also you can call contract like: await contractIns.methods.setState(123, options)
7472
* Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is stateful or not
7573
*/
76-
async function getContractInstance (source, { aci, contractAddress, filesystem = {}, forceCodeCheck = false, opt } = {}) {
74+
async function getContractInstance (source, { aci, contractAddress, filesystem = {}, opt } = {}) {
7775
aci = aci || await this.contractGetACI(source, { filesystem })
7876
const defaultOptions = {
7977
skipArgsConvert: false,
@@ -100,17 +98,6 @@ async function getContractInstance (source, { aci, contractAddress, filesystem =
10098
this.options = R.merge(this.options, opt)
10199
}
102100
}
103-
// Check for valid contract address and contract code
104-
if (contractAddress) {
105-
if (!isAddressValid(contractAddress, 'ct')) throw new Error('Invalid contract address')
106-
const contract = await this.getContract(contractAddress).catch(e => null)
107-
if (!contract) throw new Error(`Contract with address ${contractAddress} not found on-chain`)
108-
if (!forceCodeCheck) {
109-
const onChanByteCode = (await this.getContractByteCode(contractAddress)).bytecode
110-
instance.compiled = (await this.contractCompile(source, instance.options)).bytecode
111-
if (instance.compile !== onChanByteCode) throw new Error('Contract source do not correspond to the contract source deploying on the chain')
112-
}
113-
}
114101

115102
/**
116103
* Compile contract

es/utils/keystore.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import uuid from 'uuid'
44
import { encodeBase58Check, isBase64 } from './crypto'
55
import { isHex } from './string'
66

7+
const _sodium = require('libsodium-wrappers-sumo')
8+
79
/**
810
* KeyStore module
911
* !!!Work only in node.js!!!
@@ -31,30 +33,23 @@ const DERIVED_KEY_FUNCTIONS = {
3133
}
3234

3335
export async function deriveKeyUsingArgon2id (password, salt, options) {
34-
const { memlimit_kib: memoryCost, parallelism, opslimit: timeCost } = options.kdf_params
35-
const isBrowser = !(typeof module !== 'undefined' && module.exports)
36-
37-
if (isBrowser) {
38-
const _sodium = require('libsodium-wrappers-sumo')
39-
40-
return _sodium.ready.then(async () => {
41-
// tslint:disable-next-line:typedef
42-
const sodium = _sodium
43-
44-
const result = sodium.crypto_pwhash(
45-
32,
46-
password,
47-
salt,
48-
timeCost,
49-
memoryCost * 1024,
50-
sodium.crypto_pwhash_ALG_ARGON2ID13
51-
)
52-
return Buffer.from(result)
53-
})
54-
} else {
55-
const argon2 = require('argon2')
56-
return argon2.hash(password, { timeCost, memoryCost, parallelism, type: argon2.argon2id, raw: true, salt })
57-
}
36+
const { memlimit_kib: memoryCost, opslimit: timeCost } = options.kdf_params
37+
// const isBrowser = !(typeof module !== 'undefined' && module.exports)
38+
39+
return _sodium.ready.then(async () => {
40+
// tslint:disable-next-line:typedef
41+
const sodium = _sodium
42+
43+
const result = sodium.crypto_pwhash(
44+
32,
45+
password,
46+
salt,
47+
timeCost,
48+
memoryCost * 1024,
49+
sodium.crypto_pwhash_ALG_ARGON2ID13
50+
)
51+
return Buffer.from(result)
52+
})
5853
}
5954

6055
// CRYPTO PART

0 commit comments

Comments
 (0)