# Migration to 11.0.0

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

## Changes to `decodeEvents` method

* Removed `decodeEvents` from contract ACI methods ([a84d781](https://github.com/aeternity/aepp-sdk-js/commit/a84d781ab08473b7af8e6c16491492cb166d6155)).

rewrite

```js
cInstance.methods.emitEvents.decodeEvents(log);
```

to

```js
cInstance.decodeEvents(log);
```

* Removed raw fields from the `decodeEvents` response ([45bae5f](https://github.com/aeternity/aepp-sdk-js/commit/45bae5f8f0b21d374966a761512ba91bb747c47a)) use processed fields for the same.
* Renamed decoded events response field `decoded` to `args`

old response

```js
// events emitted by contract calls are automatically decoded
const tx = await contractInstance.methods.emitEvents(1337, 'this message is not indexed');
console.log(tx.decodedEvents);

/*
[
  {
    address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh',
    data: 'cb_dGhpcyBtZXNzYWdlIGlzIG5vdCBpbmRleGVkdWmUpw==',
    topics: [
      '101640830366340000167918459210098337687948756568954742276612796897811614700269',
      '39519965516565108473327470053407124751867067078530473195651550649472681599133'
    ],
    name: 'AnotherEvent',
    decoded: [
      'fUq2NesPXcYZ1CcqBcGC3StpdnQw3iVxMA3YSeCNAwfN4myQk',
      'this message is not indexed'
    ]
  },
  {
    address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh',
    data: 'cb_Xfbg4g==',
    topics: [
      '59505622142252318624300825714684802559980671551955787864303522023309554554980',
      1337
    ],
    name: 'FirstEvent',
    decoded: [ '1337' ]
  }
]
*/
```

new response

```js
// events emitted by contract calls are automatically decoded
const tx = await contractInstance.methods.emitEvents(1337, 'this message is not indexed');
console.log(tx.decodedEvents);

/*
[
  {
    name: 'AnotherEvent',
    args: [
      'fUq2NesPXcYZ1CcqBcGC3StpdnQw3iVxMA3YSeCNAwfN4myQk',
      'this message is not indexed'
    ],
    contract: {
      name: 'EventEmitter',
      address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh'
    }
  },
  {
    name: 'FirstEvent',
    args: [1337n],
    contract: {
      name: 'EventEmitter',
      address: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh'
    }
  }
]
*/
```

## Removed `allowUnsynced` option of `poll` method ([6baa15d](https://github.com/aeternity/aepp-sdk-js/pull/1376/commits/6baa15d3202510ea3d1e31c4a48928de92804a9e))

## Transaction `poll` method now checks if Tx is in the node pool ([690db5b](https://github.com/aeternity/aepp-sdk-js/pull/1375/commits/690db5bd2919958edcadca79fd75b5ad96b77c62))

## The default polling interval of `5000` is replaced by a method which calculates the default interval using expected mine rate and micro block cycle ([d9c6cf9](https://github.com/aeternity/aepp-sdk-js/pull/1369/commits/d9c6cf9aae59515f9e9a032e58b45840c6801b50))

## Following contract instance methods are dropped([#1368](https://github.com/aeternity/aepp-sdk-js/pull/1368))

* `topBlock`
  * use `aeSdk.api.getTopHeader()` instead
* `contractCall`
  * replace `await aeSdk.contractCall(identityContract, contractId, 'getArg', [42])`
  * with `(await aeSdk.getContractInstance({ source, contractAddress: contractId })).methods.getArg(42)`
* `contractCompile`
  * replace `await aeSdk.contractCompile(CONTRACT_SOURCE)`
  * with `(await aeSdk.getContractInstance({ source: CONTRACT_SOURCE })).compile()`
* `contractDeploy`
  * replace `await aeSdk.contractDeploy(bytecode, identityContract)`
  * with `(await aeSdk.getContractInstance({ bytecode, source: identityContract })).deploy()`
* `contractCallStatic`
  * replace `await aeSdk.contractCallStatic(identityContract, null, 'init', [], { bytecode })`
  * with `await contract.deploy([], { callStatic: true })`
* Removed property `createdAt` from `contract.deploy` method response
* `call/callStatic`
  * removed `call` and `callStatic` methods from deploy response

rewrite

```js
deployed = await contract.deploy([], { onAccount });
await deployed.call('getArg', [42]);
await deployed.callStatic('getArg', [42]);
```

to

```js
await contract.deploy();
await contract.methods.getArg(42, { callStatic: false });
await contract.methods.getArg(42, { callStatic: true });
```

## The default `gas` of 25000 limit has been dropped. Instead, SDK attempts to estimate the gas using dry-run feature ([#1367](https://github.com/aeternity/aepp-sdk-js/pull/1367))

See documentation on [transaction-options.md](https://docs.aeternity.com/developer-documentation/aepp-sdk-js/transaction-options#how-to-estimate-gas) for detailed explanation.

## Removed Wrappers around `CompilerApi` ([#1363](https://github.com/aeternity/aepp-sdk-js/pull/1363))

* Removed `getBytecodeCompilerVersion` method.
* Removed `encodeCall` method from `contractCompile` response.
* Removed `getCompilerVersion` method, use `aeSdk. sdk.compilerVersion` instead.
* Removed `contractDecodeCallDataByCodeAPI` method.
* Removed `contractDecodeCallResultAPI` method.
* Removed `getFateAssembler` method.
* Removed `compileContractAPI` method.

rewrite

```js
const code = await aeSdk.compileContractAPI(identityContract);
const callData = await aeSdk.contractEncodeCallDataAPI(identityContract, 'init', []);
const result = await initiatorCh.createContract({
  code,
  callData,
  deposit: 1000,
  vmVersion: 5,
  abiVersion: 3,
  amount,
  gas,
  gasPrice,
});
```

to

```js
contract = await aeSdk.getContractInstance({ source: contractSource });
await contract.compile();
const result = await aeSdk.createContract({
  code: contract.bytecode,
  callData: contract.calldata.encode('Identity', 'init', []),
  deposit: 1000,
  vmVersion: 5,
  abiVersion: 3,
  amount,
  gas,
  gasPrice,
});

//or
bytecode = (await aeSdk.compilerApi.compileContract({ code: contractSource })).bytecode;
```

* Removed `contractEncodeCallDataAPI`:

rewrite

```js
await aeSdk.contractEncodeCallDataAPI(contractSource, 'getArg', ['42']);
```

to

```js
contract = await aeSdkInitiator.getContractInstance({ source: contractSource });
await contract.compile();
contract.calldata.encode('Identity', 'getArg', [42]);
```

* Removed `contractGetACI`:

rewrite

```js
const aci = await aeSdk.contractGetACI(contractSource);
```

to

```js
const aci = await aeSdk.compilerApi.generateACI({ code: contractSource });
```

* Removed `validateByteCodeAPI`:

rewrite

```js
aeSdk.validateByteCodeAPI(bytecode, identityContract);
```

to

```js
await aeSdk.compilerApi.validateByteCode({ bytecode, source: identityContract });
```

## Native build of claim tx now accepts unencoded `name` instead of encoded name ([eea92be](https://github.com/aeternity/aepp-sdk-js/pull/1414/commits/eea92be7432cfc56e781c2234379c8f2c3398e3e))

rewrite

```js
const name = 'test123test.chain';
const nameHash = `nm_${encodeBase58Check(Buffer.from(name))}`;
const params = { accountId: senderId, nonce, name: nameHash, nameSalt: _salt, nameFee };
const txFromAPI = await aeSdk.nameClaimTx(params);
```

to

```js
const name = 'test123test.chain';
const params = { accountId: senderId, nonce, name, nameSalt: _salt, nameFee };
const txFromAPI = await aeSdk.nameClaimTx(params);
```

## Removed `forceValidation` flag from `aepp-rpc` and `wallet-rpc` stamps. ([9f958c3](https://github.com/aeternity/aepp-sdk-js/pull/1415/commits/9f958c3549228c990b4c6074b88ed5b45284bf55))

## Renamed `hd-wallet` methods ([f6243ad](https://github.com/aeternity/aepp-sdk-js/commit/f6243adea2017b5e20c079d51a8e0a469ed9792c))

* Renamed `generateSaveHDWallet` to `generateSaveHDWalletFromSeed`
* Renamed `getHdWalletAccountFromMnemonic` to `getHdWalletAccountFromSeed`
