# Migration to 10.0.0

This guide describes all breaking changes introduced with `v10.0.0`.

### `pollForQueryResponse` returns response as string ([#1285](https://github.com/aeternity/aepp-sdk-js/pull/1285))

* replace `oldResult.decode` with `new Buffer(newResult)`.
* replace `oldResult.response` with `TxBuilderHelper.encode(new Buffer(newResult), 'or')`.

### removed `skipArgsConvert` option of contract call and deployment ([6d4a599](https://github.com/aeternity/aepp-sdk-js/commit/6d4a59986d6833866b6828085fad96b364e5d315))

Convert arguments in intermediate Sophia representation to JavaScript types.\
For example:

```js
contract.methods.listFn('[1, 2]', { skipArgsConvert: false });
```

rewrite to

```js
contract.methods.listFn([1, 2]);
```

### removed `skipTransformDecoded` option of contract call and deployment ([bb49239](https://github.com/aeternity/aepp-sdk-js/commit/bb492396a29d673f02eee7cfec4e114c2fba2f3c))

Decoding to JavaScript types is enforced, please use it instead.

### ak\_ addresses are not accepted as hashes, bytes, and signatures anymore ([cbaac62](https://github.com/aeternity/aepp-sdk-js/commit/cbaac6263dd1729d64ef3a01c94e10687fed3b0d))

Encode addresses as an `ak_`-prefixed string instead.

### removed `contractEncodeCall` ([a4b303f](https://github.com/aeternity/aepp-sdk-js/commit/a4b303fbcc3b7cc544a2b5b3415d0f4a147b488c))

Use `contractEncodeCallDataAPI` instead.

### removed `contractDecodeData` ([5df2285](https://github.com/aeternity/aepp-sdk-js/commit/5df2285a7b5694475554e5154c544e0885bd4b33))

Use `contractDecodeCallResultAPI` instead.

### removed `setOptions` on contract instance ([b88e767](https://github.com/aeternity/aepp-sdk-js/commit/b88e767c86874f259ff7a1eb1784c368524e7167))

Pass them through `getContractInstance` options instead.

### `contractCallStatic`, `contractCall`, `contractDeploy` are deprecated now ([c4ec019](https://github.com/aeternity/aepp-sdk-js/commit/c4ec019372f5d5745378e781afb1eb6b2b5acfeb))

Use `getContractInstance` instead. Also, these methods will accept JavaScript-type variables instead of\
Sophia-encoded. For example:

```js
sdk.contractCallStatic(source, address, methodName, ['42']);
```

should be replaced with

```js
sdk.contractCallStatic(source, address, methodName, [42]);
```

### dropped compatibility with compiler\@4.1.0 ([f9cef12](https://github.com/aeternity/aepp-sdk-js/commit/f9cef12a7db4b2559519ef7f8380cc9e89630492))

Use compiler 6.0.0 and above.

### invert and rename `forceCodeCheck` option to `validateBytecode` in `getContractInstance` ([72122fa](https://github.com/aeternity/aepp-sdk-js/commit/72122facdcec9921202b210c387c19509b26e578))

Use `validateBytecode` when you need to ensure that the source code/bytecode provided to`getContractInstance` corresponds to the on-chain bytecode.

### removed `getConsensusProtocolVersion` method ([75f0447](https://github.com/aeternity/aepp-sdk-js/commit/75f044792bd2d81eca3a2abc8218e8ca5f167134))

Use `node.consensusProtocolVersion` instead.

### switched to @aeternity/aepp-calldata package ([#1313](https://github.com/aeternity/aepp-sdk-js/pull/1313))

Numbers in Sophia are not limited in size. Before they were returned from contract methods as usual\
JavaScript numbers that have limited accuracy. To fix this, we make it return instances of BigInt.

Variant types are now supported by sdk, so replace `"RelativeTTL(50)"` with `{ RelativeTTL: [50] }`.\
As an exception `Some(value)` is converted to the exact value in JavaScript and `None` is converted to `undefined`\
(Sophia's `option` type).

Contract methods will accept/return instances of JavaScript's `Map` as variables of Sophia's `map`\
type. Objects are not accepted as maps any longer.

Sophia's `hash`, `signature`, `bytes` types return values as `Uint8Array` instead of a hex-encoded\
string.

Check the [documentation](https://github.com/aeternity/aepp-calldata-js/blob/master/README.md)\
of calldata package for additional info.

Use `.decodedResult` instead of `.decode()` to get the result of method call.

Most of the errors thrown by contract iterations will be different due to doing validation using\
calldata package instead of `joi`.

### pass source in options of `sdk.getContractInstance` ([5c690d2](https://github.com/aeternity/aepp-sdk-js/commit/5c690d2d77a433c8496ab9cda6fd66e52a6b4b23))

For example:

```js
sdk.getContractInstance(contractSource, { contractAddress: '...' });
```

rewrite to

```js
sdk.getContractInstance({ source: contractSource, contractAddress: '...' });
```

Contract instance can be generated by ACI and bytecode:

```js
sdk.getContractInstance({ aci, bytecode });
```

SDK won't use hosted compiler in this case.

Also, `contract.compiled` was renamed to `contract.bytecode`.

### additional options of `getContractInstance` accepted as usual ones ([10fb7ba](https://github.com/aeternity/aepp-sdk-js/commit/10fb7bad8f61b973c1be5daec50909d251ec1f90))

For example, replace

```js
sdk.getContractInstance({ source, opt: { ttl: 1 } });
```

with

```js
sdk.getContractInstance({ source, ttl: 1 });
```

### drop compatibility with es5 ([#1331](https://github.com/aeternity/aepp-sdk-js/pull/1331))

To support old environments, you need to set up transpilation of SDK package while building your\
app. In Webpack it can be done by [excluding](https://webpack.js.org/configuration/module/#ruleexclude)`node_modules` folder except for this package in `babe-loader` rule. In `@vue/cli` you can use[transpileDependencies](https://cli.vuejs.org/config/#transpiledependencies) option.

### removed primitives for encryption/decryption by keypairs ([#1183](https://github.com/aeternity/aepp-sdk-js/pull/1183))

Use third-party cryptographic packages instead of `Crypto.encryptData`, `Crypto.decryptData`\
methods.

### `aensUpdate` accepts pointers as object ([f6b8999](https://github.com/aeternity/aepp-sdk-js/commit/f6b8999ac70d10c5455e9a45d8ad65e161d28ca4))

For example, replace

```js
sdk.aensUpdate('test.chain', ['ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk']);
```

with

```js
sdk.aensUpdate('test.chain', {
  account_pubkey: 'ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk',
});
```

Additionally, `getDefaultPointerKey` (was named `classify` before) helper function can be used

```js
import { getDefaultPointerKey } from '@aeternity/aepp-sdk';

const address = 'ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk';
sdk.aensUpdate('test.chain', { [getDefaultPointerKey(address)]: address });
```
