Migration to 10.0.0
This guide describes all breaking changes introduced with v10.0.0
.
pollForQueryResponse
returns response as string (#1285)
- replace
oldResult.decode
withnew Buffer(newResult)
. - replace
oldResult.response
withTxBuilderHelper.encode(new Buffer(newResult), 'or')
.
removed skipArgsConvert
option of contract call and deployment (6d4a599)
Convert arguments in intermediate Sophia representation to JavaScript types. For example:
contract.methods.listFn('[1, 2]', { skipArgsConvert: false });
rewrite to
contract.methods.listFn([1, 2]);
removed skipTransformDecoded
option of contract call and deployment (bb49239)
Decoding to JavaScript types is enforced, please use it instead.
ak_ addresses are not accepted as hashes, bytes, and signatures anymore (cbaac62)
Encode addresses as an ak_
-prefixed string instead.
removed contractEncodeCall
(a4b303f)
Use contractEncodeCallDataAPI
instead.
removed contractDecodeData
(5df2285)
Use contractDecodeCallResultAPI
instead.
removed setOptions
on contract instance (b88e767)
Pass them through getContractInstance
options instead.
contractCallStatic
, contractCall
, contractDeploy
are deprecated now (c4ec019)
Use getContractInstance
instead. Also, these methods will accept JavaScript-type variables instead of
Sophia-encoded. For example:
sdk.contractCallStatic(source, address, methodName, ['42']);
should be replaced with
sdk.contractCallStatic(source, address, methodName, [42]);
dropped compatibility with [email protected] (f9cef12)
Use compiler 6.0.0 and above.
invert and rename forceCodeCheck
option to validateBytecode
in getContractInstance
(72122fa)
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)
Use node.consensusProtocolVersion
instead.
switched to @aeternity/aepp-calldata package (#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 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)
For example:
sdk.getContractInstance(contractSource, { contractAddress: '...' });
rewrite to
sdk.getContractInstance({ source: contractSource, contractAddress: '...' });
Contract instance can be generated by ACI and bytecode:
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)
For example, replace
sdk.getContractInstance({ source, opt: { ttl: 1 } });
with
sdk.getContractInstance({ source, ttl: 1 });
drop compatibility with es5 (#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
node_modules
folder except for this package in babe-loader
rule. In @vue/cli
you can use
transpileDependencies option.
removed primitives for encryption/decryption by keypairs (#1183)
Use third-party cryptographic packages instead of Crypto.encryptData
, Crypto.decryptData
methods.
aensUpdate
accepts pointers as object (f6b8999)
For example, replace
sdk.aensUpdate('test.chain', ['ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk']);
with
sdk.aensUpdate('test.chain', {
account_pubkey: 'ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk',
});
Additionally, getDefaultPointerKey
(was named classify
before) helper function can be used
import { getDefaultPointerKey } from '@aeternity/aepp-sdk';
const address = 'ak_2519mBsgjJEVEFoRgno1ryDsn3BEaCZGRbXPEjThWYLX9MTpmk';
sdk.aensUpdate('test.chain', { [getDefaultPointerKey(address)]: address });