Skip to content

Migration to 13.0.0

This guide describes all breaking changes introduced with v13.0.0.

Wallet

onSign, onMessageSign callbacks were removed on the wallet side

Check allowance to sign on the account side instead, using aeppOrigin, aeppRpcClientId options.

Aepp

All wallet provided nodes have the same name

Specified in name option of connectToWallet.

Select option removed from connectToWallet

If you are using connectNode then the current node would always be the same as wallet provides.

Contract

ACI format used the same as returned by aesophia_cli

aesophia_http old format

{
  "encoded_aci": { contract: <1> },
  "external_encoded_aci": [<2>]
}
aesophia_cli format
[<2>, { contract: <1> }]

params argument in $deploy and $call is required

Contract methods accessible on the instance itself

Apply a patch:

-const contract = aeSdk.getContractInstance(<contract args>);
+const contract = aeSdk.getContractInstance<{ foo: (a: bigint) => bigint }>(<contract args>);
-await contract.methods.foo(<arguments>);
+await contract.foo(<arguments>);

contract.methods.<name>.get,send removed

Use callStatic option instead.

contract.bytecode,sourceCode moved to contract.$options

contract.calldata renamed to contract._calldata

Use contract._calldata (considered to be a private field) or aepp-calldata package directly.

contract.options renamed to contract.$options

contract.deployInfo removed

Use the return value of contract.$deploy instead. contract.deployInfo.address moved to contract.$options.address.

contract.decodeEvents renamed to contract.$decodeEvents

contract.call renamed to contract.$call

contract.compile renamed to contract.$compile

contract.deploy renamed to contract.$deploy

createAensDelegationSignature, createOracleDelegationSignature removed

Use createDelegationSignature instead.

use sourceCode instead of source

It is related to getContractInstance and signing using Generalized accounts. Apply a change:

-aeSdk.getContractInstance({ source: <contract source code>, ... })
+aeSdk.getContractInstance({ sourceCode: <contract source code>, ... })
-aeSdk.spend(..., { authData: { source: <contract source code>, args: [...] } })
+aeSdk.spend(..., { authData: { sourceCode: <contract source code>, args: [...] } })

getContractInstance accepts address instead of contractAddress

Apply a change:

-aeSdk.getContractInstance({ contractAddress: <contract address>, ... })
+aeSdk.getContractInstance({ address: <contract address>, ... })

getContractInstance function replaced with Contract class

Apply a patch:

-contract = await getContractInstance(<options>);
+contract = await Contract.initialize(<options>);

AeSdk.getContractInstance renamed to AeSdk.initializeContract

prepareTxParams, getVmVersion are not exported anymore

Use buildTx instead.

isGA method removed

Use (await aeSdk.getAccount(<address>)).kind === 'generalized' instead.

Transaction builder

writeInt function removed

Use toBytes util instead.

returnType of contract call result structure is a value of CallReturnType enum

Apply a patch:

-contractCall.returnType === "error"
+contractCall.returnType === CallReturnType.Error

writeId, readId functions removed

Use transaction builder instead.

readPointers, buildPointers functions removed

Use transaction builder instead.

formatSalt function removed

Use Buffer.from(<salt>.toString(16).padStart(64, '0'), 'hex') instead.

validateParams, unpackRawTx functions removed

Use transaction builder instead.

AMOUNT constant removed

If necessary, use 0 instead.

StateTrees fields decoded as objects mapping key to decoded entry instead of internals

The content of Tag.*Mtree entries decoded and moved to payload field

TX_SCHEMA, TxParamsCommon, TxSchema, TxTypeSchemas are not exported anymore

TX_TTL is not exported anymore

Use 0 instead.

Enum FIELD_TYPES is not exported anymore

Not able to build/unpack CompilerSophia entry (tag 70)

Enums PROTOCOL_VM_ABI, interface CtVersion not exported anymore

Enums VM_VERSIONS, ABI_VERSIONS, PROTOCOL_VERSIONS renamed

They are exported as VmVersion, AbiVersion, ConsensusProtocolVersion.

stateHash of Channel entry decoded as st_-prefixed string instead of hex

SpendTx payload doesn't accept arbitrary strings anymore

Provide a ba_-encoded string instead.

-payload: 'test',
+payload: encode(Buffer.from('test'), Encoding.Bytearray),

verifyTransaction doesn't accept parent tx types anymore

buildTx doesn't accept excludeKeys option anymore

Consider opening an issue, if you need this functionality.

Use version instead of VSN, vsn in unpackTx, buildTx

buildTx accepts transaction type and version in the first argument

Apply a change:

-buildTx({ ... }, Tag.SpendTx, { version: 2 })
+buildTx({ ..., tag: Tag.SpendTx, version: 2 })

AeSdk.buildTx accepts tag in options

Replace aeSdk.buildTx(Tag.SpendTx, { ... }) with aeSdk.buildTx({ ..., tag: Tag.SpendTx }).

sync buildTx accepts denomination in the first argument

-buildTx({ ... }, { denomination: AE_AMOUNT_FORMATS.AETTOS })
+buildTx({ ..., denomination: AE_AMOUNT_FORMATS.AETTOS })

unpackTx return an object of transaction parameters

Use unpackTx(...) instead of unpackTx(...).tx.

unpackTx doesn't return rlpEncoded anymore

Use decode(buildTx(unpackTx(...))) instead.

unpackTx doesn't return txType anymore

Use unpackTx(...).tag instead.

buildTx return string instead of object

Use just buildTx(...) instead of buildTx(...).tx.

buildTx doesn't return txObject anymore

Use unpackTx(buildTx(...)) instead.

buildTx doesn't return binary anymore

Use require('rlp').decode(decode(buildTx(...))) instead.

buildTx doesn't return rlpEncoded anymore

Use decode(buildTx(...)) instead.

key of MtreeValue entry decoded as a buffer instead of a hex

TxBuilder accepts and returns poi field unpacked as TreesPoi

get method of MPTree accepts and returns typed values

Apply a change:

-unpackTx(tree.get(decode('ak_97...')))
+tree.get('ak_97...')

Compiler

Compiler export renamed to CompilerHttp

removed AeSdk:compilerUrl, AeSdk:setCompilerUrl

A compiler instance needs to be passed explicitly in onCompiler option:

-import { AeSdk } from '@aeternity/aepp-sdk';
+import { AeSdk, CompilerHttp } from '@aeternity/aepp-sdk';

const aeSdk = new AeSdk({
-  compilerUrl: <compiler url>,
+  onCompiler: new CompilerHttp(<compiler url>),
});

Methods of CompilerHttp moved to api property

Apply a patch:

-compilerHttp.generateACI({ code: sourceCode });
+compilerHttp.api.generateACI({ code: sourceCode });

Dropped compatibility with aesophia_http below 7.1.1, aesophia_cli below 7.0.1

Account

createGeneralizedAccount accepts sourceCode in options

Apply a patch:

-aeSdk.createGeneralizedAccount('authorize', sourceCode, ['arg-1']);
+aeSdk.createGeneralizedAccount('authorize', ['arg-1'], { sourceCode });

createMetaTx removed

Use AccountGeneralized.signTransaction instead.

AccountRpc constructor accepts arguments one by one

Apply a change:

-new AccountRpc({ rpcClient: <rpc client>, address: <address> })
+new AccountRpc(<rpc client>, <address>)

AccountMemory requires networkId in signTransaction

AccountBase simplified

  • networkId removed
  • getNetworkId method removed
  • signTransaction, signMessage made abstract

address in AccountBase is a property

Apply a change:

-await accountMemory.address(options)
+accountMemory.address

MemoryAccount accepts only secretKey

Apply a change:

-new MemoryAccount({ keypair: { publicKey: 'ak_..', secretKey: <secret key> } })
+new MemoryAccount(<secret key>)

MemoryAccount is not compatible with GA

Apply a change:

-new MemoryAccount({ gaId: <address> })
+new AccountGeneralized(<address>)

Node

url property of Node removed

Use autorest's $host property instead.

Oracle

QUERY_FEE is not exported anymore

Use 30000 instead if necessary.

Oracles created without queryFee by default

Specify queryFee in registerOracle if needed.

AeSdk:extendOracleTtl, AeSdk:respondToQuery doesn't accept oracleId

Remove the first argument.

onQuery callback of pollForQueries, oracle.pollQueries accepts a single query

It was accepting an array before. Apply a patch:

-aeSdk.pollForQueries(oracleId, (queries) => queries.forEach(handleQuery));
+aeSdk.pollForQueries(oracleId, handleQuery);

Chain

send inlined into sendTransaction

Pass not signed transaction to sendTransaction. If you need to post signed transaction use Node:postTransaction.

AENS

height removed from the output of aensPreclaim

Use blockHeight instead:

const res = aeSdk.aensPreclaim('name.chain');
-res.height
+res.blockHeight - 1

Channel

Channel:state returns unpacked entries

Use buildTx to pack them back if needed.

All channel events emitted in snakeCase

Affected events: 'own_withdraw_locked', 'withdraw_locked', 'own_deposit_locked', 'deposit_locked', 'peer_disconnected', 'channel_reestablished'.

Channel:poi returns unpacked TreesPoi

Use just await channel.poi(...) instead of unpackTx(await channel.poi(...)).

Other

onAccount doesn't accept keypair

Apply a change:

-aeSdk.<metnod name>(..., { onAccount: <keypair> })
+aeSdk.<metnod name>(..., { onAccount: new MemoryAccount(<keypair>.secretKey) })

bigNumberToByteArray removed

Use toBytes instead.

str2buf function removed

Use Buffer.from(<data>, <encoding>) instead.

getAddressFromPriv doesn't accept private key as base64-encoded or raw string

isValidKeypair doesn't accept public key as base64-encoded string

bytesToHex function removed

Use Buffer.from(<bytes>).toString('hex') instead.

hexToBytes function removed

Use Buffer.from(<hex string>, 'hex') instead.

rename umd export to Aeternity

Subpaths imports of SDK are not allowed

SDK does versioning only for the API provided in the root export. Replace subpaths imports with imports of the package root.

-import MemoryAccount from '@aeternity/aepp-sdk/es/account/Memory.mjs';
+import { MemoryAccount } from '@aeternity/aepp-sdk';

Removed getNetworkId from AeSdkBase

Use Node.getNetworkId instead.

address a getter in AeSdkBase

Apply a change:

-await aeSdk.address()
+aeSdk.address

addAccount is a sync function

verifyMessage removed from accounts and AeSdkBase

Use verifyMessage exported in the root instead.

verify and verifyMessage accepts address instead of hex string or Uint8Array

Convert public key in Uint8Array to address using encode(pk, 'ak'). Convert public key in hex to address using encode(Buffer.from(pk, 'hex'), 'ak').

node@12 not supported

Use [email protected] or newer.

removeAccount throws an error if the account is not found

signMessage always returns Uint8Array

Use Buffer.from(signature).toString('hex') to convert it to hex.

encryptKey, decryptKey are not exported anymore

Use 'sha.js' and 'aes-js' packages directly instead.

sha256hash is not exported anymore

Use SubtleCrypto.digest or sha.js package instead.

height method removed

Use getHeight instead.

signUsingGA method removed

Use AccountGeneralized.signTransaction instead.

POINTER_KEY_BY_PREFIX removed

Use getDefaultPointerKey instead.

ID_TAG_PREFIX, PREFIX_ID_TAG, ID_TAG removed

Use transaction builder instead.

TX_TYPE removed.

Use Tag instead.

GAS_MAX removed

The maximum gas limit depends on transaction size, this value is outdated, sdk check/provides gasLimit by itself while building a transaction.

calculateMinFee removed

Use buildTx to generate a transaction, unpack it and refer to fee field.

salt, createSalt removed

Use genSalt instead.

Pointer removed

Use NamePointer from apis/node instead.