Skip to content

Commit

Permalink
fixup migration
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jun 17, 2022
1 parent 265b6d5 commit 5e1419d
Showing 1 changed file with 85 additions and 85 deletions.
170 changes: 85 additions & 85 deletions docs/guides/migration/12.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This guide describes all breaking changes introduced with `v12.0.0`.

## General
### `Universal`, `RpcAepp`, `RpcWallet`, `Ae` stamps are removed
#### `Universal`, `RpcAepp`, `RpcWallet`, `Ae` stamps are removed
Use `AeSdk`, `AeSdkAepp`, `AeSdkWallet`, `AeSdbBase` accordingly.
For example, replace:
```js
Expand All @@ -15,7 +15,7 @@ import { AeSdk } from '@aeternity/aepp-sdk'
const aeSdk = new AeSdk(options)
```

### all combined exports are inlined (`require('@aeternity/aepp-sdk').generateKeyPair()`)
#### all combined exports are inlined (`require('@aeternity/aepp-sdk').generateKeyPair()`)
Import the needed utils directly instead of importing a wrapper object firstly.
For example, replace:
```js
Expand All @@ -28,15 +28,15 @@ import { generateKeyPair } from '@aeternity/aepp-sdk'
console.log(generateKeyPair())
```

### `AccountBase` and inheritors are classes now
#### `AccountBase` and inheritors are classes now
Use `new` to create an instance.

### `ChainNode`, `Contract`, `Oracle`, `Aens`, `GeneralizedAccount` stamps not exported
#### `ChainNode`, `Contract`, `Oracle`, `Aens`, `GeneralizedAccount` stamps not exported
Their methods exported instead. Outside of `AeSdkBase` context, they may accept `onAccount`,
`onNode`, `onCompiler` options.

## Node and Compiler
### `Node`, `Compiler` (previously `ContractCompilerHttp`) are classes instead of a stamps
#### `Node`, `Compiler` (previously `ContractCompilerHttp`) are classes instead of a stamps
For example, replace:
```js
import { Node } from '@aeternity/aepp-sdk'
Expand All @@ -48,60 +48,60 @@ import { Node } from '@aeternity/aepp-sdk'
const node = new Node(url, { ignoreVersion: false })
```

### `Node`, `Compiler` doesn't check version on the first request instead of init
#### `Node`, `Compiler` doesn't check version on the first request instead of init
Don't handle `new Node(...)` and `new Compiler(...)` as a `Promise`.

### `getNetworkId` returns a promise
#### `getNetworkId` returns a promise

### `getNetworkId` ignores `force` option
#### `getNetworkId` ignores `force` option
So, it would throw exception in case networkId is not provided. Use `try/catch` instead.

### `api` is removed in `Node`
#### `api` is removed in `Node`
Use `node.getBalance` instead of `node.api.getBalance.`

### static properties are removed in `Node`
#### static properties are removed in `Node`
Use `node.getStatus()` or `node.getNodeInfo()` to get values of `version`, `revision`,
`genesisHash`, `nodeNetworkId`, `consensusProtocolVersion`.

### `Node` returns BigInts for coin amount fields instead of string or number
#### `Node` returns BigInts for coin amount fields instead of string or number

### `Node` not accepts `internalUrl`
#### `Node` not accepts `internalUrl`
`Node` doesn't accepts and stores `internalUrl`, also internal endpoints are not available anymore.
If necessary, create a wrapper of internal API separately (`swagger-client` package).

### removed `mempool` method in `Node`
#### removed `mempool` method in `Node`
Create a wrapper of internal API by `genSwaggerClient` and use `getPendingTransactions` method
instead.

### `compilerVersion` is removed in `Compiler`
#### `compilerVersion` is removed in `Compiler`
Use `compilerApi.aPIVersion()` method instead.

### `setCompilerUrl` changes compiler URL in sync
#### `setCompilerUrl` changes compiler URL in sync
Don't handle `aeSdk.setCompilerUrl(...)` as a `Promise`.

### methods of `Compiler` requires `options` object according to their specification
#### methods of `Compiler` requires `options` object according to their specification

### methods of `Compiler` returns and accepts keys named in camelCase instead of snake_case
#### methods of `Compiler` returns and accepts keys named in camelCase instead of snake_case

## Transaction builder
### removed methods to generate a transaction of specific type
#### removed methods to generate a transaction of specific type
Use `aeSdk.buildTx(txType, params)` instead.

### removed ability to generate transaction on the node side
#### removed ability to generate transaction on the node side
Use `aeSdk.buildTx(txType, params)` instead.

### `nonce`, `ttl`, `gas` decoded and accepted as numbers instead of strings
#### `nonce`, `ttl`, `gas` decoded and accepted as numbers instead of strings

### `gas` renamed to `gasLimit`
#### `gas` renamed to `gasLimit`
Use `gasLimit` instead of `gas` everywhere except for transaction details returned by node.

### `unpackTx` not accepting transaction as `Buffer`, only as tx-encoded string
#### `unpackTx` not accepting transaction as `Buffer`, only as tx-encoded string
Use `unpackTx(encode(tx, 'tx'))` instead.

### `unpackTx` doesn't have `binary` field in result
#### `unpackTx` doesn't have `binary` field in result
Use `require('rlp').decode(unpackTx(tx).rlpEncoded)` instead.

### **encode:** since the prefix is evaluated by the type itself the required prefix parameter
#### **encode:** since the prefix is evaluated by the type itself the required prefix parameter
is no more accepted
Rewrite
```js
Expand All @@ -112,166 +112,166 @@ to
decode('cb_DA6sWJo=')
```

### `calculateMinFee` returns BigNumber instead of string
### Fee helpers not exported anymore (`BASE_GAS`, `GAS_PER_BYTE`, `KEY_BLOCK_INTERVAL`,
#### `calculateMinFee` returns BigNumber instead of string
#### Fee helpers not exported anymore (`BASE_GAS`, `GAS_PER_BYTE`, `KEY_BLOCK_INTERVAL`,
`TX_FEE_BASE_GAS`, `TX_FEE_OTHER_GAS`, `calculateFee`, `DEFAULT_FEE`)
Use a general `calculateMinFee` instead.

### `buildRawTx`, `calculateTtl` not exported anymore
#### `buildRawTx`, `calculateTtl` not exported anymore
Use a general `buildTx` method instead.

### `TX_TYPE` mapped to tag (number) instead of string
#### `TX_TYPE` mapped to tag (number) instead of string
Always use `TX_TYPE`. To get type name by tag use `TX_TYPE[tag]`.

### `OBJECT_ID_TX_TYPE` not exported anymore
#### `OBJECT_ID_TX_TYPE` not exported anymore
Use `TX_TYPE[tag]` instead.

### `TX_SERIALIZATION_SCHEMA` combined with `TX_DESERIALIZATION_SCHEMA`
#### `TX_SERIALIZATION_SCHEMA` combined with `TX_DESERIALIZATION_SCHEMA`
Use `TX_SCHEMA[TX_TYPE.*]` instead.

### Transaction schemas doesn't contain tag anymore
#### Transaction schemas doesn't contain tag anymore
Use `OBJECT_ID_TX_TYPE` to find tag by transaction type.

## AENS
### `computeBidFee` accepts `startFee`, `increment` as options
#### `computeBidFee` accepts `startFee`, `increment` as options

### `NAME_BID_TIMEOUTS` not exposed anymore
#### `NAME_BID_TIMEOUTS` not exposed anymore
Use `computeAuctionEndBlock` function instead.

### `computeAuctionEndBlock` accepts and returns height as number
#### `computeAuctionEndBlock` accepts and returns height as number

### removed `ensureNameValid`
#### removed `ensureNameValid`
Use a TypeScript check instead.

### `name.update`, `name.revoke` doesn't accept address in `onAccount`
#### `name.update`, `name.revoke` doesn't accept address in `onAccount`
Pass an instance of `AccountBase` to `onAccount` option instead.

## Oracle
### `extendOracleTtl` accepts oracle ttl in `oracleTtlType` and `oracleTtlValue` fields
#### `extendOracleTtl` accepts oracle ttl in `oracleTtlType` and `oracleTtlValue` fields
Use `oracleTtlType` field instead of `type`, and `oracleTtlValue` field instead of `value`.

### `decode` method of `getQueryObject` removed
#### `decode` method of `getQueryObject` removed
Use `decode` function instead.

## Contract
### `createAensDelegationSignature` first argument not an object
#### `createAensDelegationSignature` first argument not an object
`contractId` accepted as the first argument, `name` should be passed as option to the second one.

### `createOracleDelegationSignature` first argument not an object
#### `createOracleDelegationSignature` first argument not an object
`contractId` accepted as the first argument, `queryId` should be passed as option to the second one.

### call arguments in `createGeneralizedAccount` is required
#### call arguments in `createGeneralizedAccount` is required
Pass an empty array if you need no arguments.

### `filesystem` option renamed to `fileSystem`
### Contract instance doesn't accept address in `onAccount`
#### `filesystem` option renamed to `fileSystem`
#### Contract instance doesn't accept address in `onAccount`
It should be an instance of `AccountBase` instead.

## Chain
### removed `balance` method
#### removed `balance` method
Use `getBalance` instead.

### removed `tx` method
#### removed `tx` method
Use `node.getTransactionByHash/getTransactionInfoByHash` instead.

### removed `getTxInfo` method
#### removed `getTxInfo` method
Use `node.getTransactionInfoByHash` instead.

## Other
### `getAccountNonce` removed
#### `getAccountNonce` removed
Use `node.getAccountNextNonce` instead.

### `AeSdk` doesn't accept array of accounts
#### `AeSdk` doesn't accept array of accounts
Use `aeSdk.addAccount` method instead.

### `destroyInstance` method removed
#### `destroyInstance` method removed
It wasn't doing anything, just remove it's usages.

### `NodePool` is removed
#### `NodePool` is removed
Use `AeSdkBase` or `AeSdk` instead.

### `AccountMultiple` is removed
#### `AccountMultiple` is removed
Use `AeSdk` instead.

### `DENOMINATION_MAGNITUDE` not exposed anymore
#### `DENOMINATION_MAGNITUDE` not exposed anymore
It is intended for internal use only.

### The result of `unpackTx` returned instead of `TxObject`
#### The result of `unpackTx` returned instead of `TxObject`
In `txObject` option of `onSign` handler on wallet side.
In `tx` field of contract call result.

### `validateKeyObj` removed
#### `validateKeyObj` removed
Rely on TypeScript checks instead.

### `deriveKeyUsingArgon2id` removed
#### `deriveKeyUsingArgon2id` removed
Use `argon2-browser` package instead.

### removed extra implementation of `getAddressFromPriv` in keystore
#### removed extra implementation of `getAddressFromPriv` in keystore
Use `Crypto.getAddressFromPriv` instead.

### `genSwaggerClient` removed
#### `genSwaggerClient` removed
Use `swagger-client` package instead.

## Aepp Wallet communication
### BrowserRuntimeConnection, BrowserWindowMessageConnection are classes
#### BrowserRuntimeConnection, BrowserWindowMessageConnection are classes
Create instances using new.

### ContentScriptBridge, WalletDetector rewrited to plain functions
#### ContentScriptBridge, WalletDetector rewrited to plain functions
Use `connectionProxy`, `walletDetector` accordingly.

### **RpcClient:** removed `origin` property
#### **RpcClient:** removed `origin` property
Use `connection` property instead.

### **RpcClient:** `sendMessage` is a private method
#### **RpcClient:** `sendMessage` is a private method
Use `request` or `notify` instead.

### **RpcClient:** `handlers` parameter is removed
#### **RpcClient:** `handlers` parameter is removed
Provide a `methods` parameter instead of `handlers[0]`.
Provide an `onDisconnect` parameter instead of `handlers[1]`.

### **RpcClient:** doesn't contain aepp info anymore
#### **RpcClient:** doesn't contain aepp info anymore
Get aepp info in `onConnection` callback, and store somehow to use later.

### **RpcClient:** doesn't contain `networkId` anymore
#### **RpcClient:** doesn't contain `networkId` anymore
On wallet side: assume that all aepps uses the same network as the wallet connected to.
On aepp side: use `networkId` that wallet provided.
In case `networkId` is not compatible ask user to switch wallet to a compatible network.

### RPC helpers are not exposed anymore (`isInIframe`, `sendMessage`, `getHandler`, `message`,
#### RPC helpers are not exposed anymore (`isInIframe`, `sendMessage`, `getHandler`, `message`,
`responseMessage`, `sendResponseMessage`, `isValidAccounts`)
Use own implementation if needed.

## Aepp
### `connectToWallet` accepts wallet connection as the first argument
#### `connectToWallet` accepts wallet connection as the first argument
See [connect-aepp-to-wallet.md](../connect-aepp-to-wallet.md) for details.

### `disconnectWallet` runs in sync and `sendDisconnect` arg removed
#### `disconnectWallet` runs in sync and `sendDisconnect` arg removed
So, aepp would always send `closeConnection` notification.

### `sendConnectRequest` removed
#### `sendConnectRequest` removed
Use `connectToWallet` instead.

### doesn't accept `connection` anymore
#### doesn't accept `connection` anymore
Use `connectToWallet` method instead.

### removed `isConnected`, `isSubscribedAccount` methods
#### removed `isConnected`, `isSubscribedAccount` methods
Detect is aepp connected by persistence of `rpcClient` property.

### `signMessage` returns Buffer by default
#### `signMessage` returns Buffer by default
Use `returnHex` option to get the previous behaviour.

## Wallet
### `BrowserRuntimeConnection` requires `port` parameter
#### `BrowserRuntimeConnection` requires `port` parameter
Pass `require('webextension-polyfill').runtime.connect()` to it.

### requires `id`, `type` in params
#### requires `id`, `type` in params
`id` should be a unique string;
`type` should be one of `WALLET_TYPE.window`, `WALLET_TYPE.extension`.

### `getBrowserAPI` helper removed
#### `getBrowserAPI` helper removed
Use `webextension-polyfill` package instead.

### `shareWalletInfo` accepts rpc client id instead of callback
#### `shareWalletInfo` accepts rpc client id instead of callback
For example, rewrite
```
const connection = new BrowserRuntimeConnection({ port })
Expand All @@ -285,31 +285,31 @@ const rpcClientId = aeSdk.addRpcClient(connection)
aeSdk.shareWalletInfo(rpcClientId)
```

### `shareNode` argument in accept callback of `onConnection` removed
#### `shareNode` argument in accept callback of `onConnection` removed
Just deny the connection if you don't want to share the node url.

### can't handle specific set of accounts for an app
#### can't handle specific set of accounts for an app
If you need this feature, create a custom wallet implementation or fill us an issue.

### `txObject` parameter of `onSign` callback is removed
#### `txObject` parameter of `onSign` callback is removed
Use `unpackTx(tx)` on wallet side instead.

### `rpcClients` in wallet is not exposed anymore
#### `rpcClients` in wallet is not exposed anymore
This expected to be used only internally.

### `onDisconnect` callback on wallet side accepts client id instead of `RpcClient`
#### `onDisconnect` callback on wallet side accepts client id instead of `RpcClient`
Use `sdk.rpcClient[clientId]` to get the corresponding instance of RpcClient.

### wallet can't selectively notify aepps about selecting/adding account
#### wallet can't selectively notify aepps about selecting/adding account
If you need this feature, create a custom wallet implementation or fill us an issue.

### wallet can't provide metadata for accounts
#### wallet can't provide metadata for accounts
If you need this feature, create a custom wallet implementation or fill us an issue.

### removed `action.accept` in permission callbacks
#### removed `action.accept` in permission callbacks
Return the value you passed to `accept` instead.

### removed `action.deny` in permission callbacks
#### removed `action.deny` in permission callbacks
Throw instances of `RpcRejectedByUserError` instead.

### callbacks accept client id, params, and origin
#### callbacks accept client id, params, and origin

0 comments on commit 5e1419d

Please sign in to comment.