Friday, April 7, 2023
API
Protocol
WASM
Tooling

Release: mx-sdk-js-core - v12.0.1

Updated cookbook

See the updated cookbook.

Guardians are coming to Mainnet

And to this regards we've added support for guarded transactions. See the new fields transaction.guardian, transaction.guardianSignature and the function transaction.applyGuardianSignature().

Creating a guarded transaction looks as follows:


const transaction = new Transaction({
    nonce: 42
    sender: addressOfAlice,
    receiver: addressOfBob,
    value: "1000000000000000000"
    gasLimit: 100000
    chainID: "D"
    guardian: addressOfTheGuardian,
    options: TransactionOptions.withOptions({ guarded: true }),
    version: TransactionVersion.withTxOptions(),
});

...

transaction.applySignature(...);
transaction.applyGuardianSignature(...);

Passing the sender is now required

Passing the sender is now required on most transaction builders (not only on the Transaction constructor). For example, you are required to pass the caller when using smartContract.call() or the deployer when using smartContract.deploy(). When using the interactions API, make sure to call interaction.withSender(). transaction.setSender() is also supported (if needed).

Developers of wallet/wallet-like applications, please read!

For developers of wallet / wallet-like applications: sdk-core v12 supports both sdk-wallet v3 and sdk-wallet v4. Though, we recommend migrating to sdk-wallet v4. Then, signing transactions would look as follows:


const serialized: Buffer = transaction.serializeForSigning();
const signature: Buffer = await signer.sign(serialized);
transaction.applySignature(signature);

Loading ABI got easier

We've slightly simplified the loading of an ABI and feeding it to a SmartContract object. See #281. In v12, this is done as follows:


const abiRegistry = AbiRegistry.create({ ... });
const contract = new SmartContract({ address: existingAddress, abi: abiRegistry });

Breaking changes

Not one, not two, but quite a few. Here's an entire list of them:

  • transaction.getSignature() now returns a Buffer, instead of a ISignature object.
  • TransfersFactory has been renamed to TransferTransactionsFactory;
  • tokenPayment.toRationalNumber() has been renamed to toAmount() - and, actually, it became private, you cannot use (should not use) it anymore. toPrettyString() is still available, but it may be deprecated in a future release, in favor of a separate, more customizable formatter;
  • We've removed the static function TransactionOptions.withTxHashSignOptions. Use the constructor instead, and pass it the necessary flags (options);
  • We've slightly altered the constructor of TransactionWatcher;
  • The constant TRANSACTION_VERSION_TX_HASH_SIGN has been renamed to TRANSACTION_VERSION_WITH_OPTIONS;
  • We've removed SmartContractAbi and ContractInterface - they were over-engineered, designed to handle multiple sets of contract endpoints (namespaces / separate interfaces etc.). We've kept AbiRegistry, which is sufficient;
  • abiRegistry.getAllEndpoints has been renamed to getEndpoints();
  • SmartContract.setAbi() has been removed. The ABI is passed in constructor only;
  • SmartContract.getAbi() is not exposed anymore. When an ABI definition is needed (e.g. endpoint, type), it should be found in the AbiRegistry;
  • Removed ContractFunction.equals() - was already deprecated for some time.

Deprecations

  • TokenPayment has been deprecated (renamed). Use the new name: TokenTransfer, instead. ITokenPayment became ITokenTransfer, as well. The old names will be removed in the next major version.
  • Deprecated the parameter sender of interaction.withSingleESDTNFTTransfer() and interaction.withMultiESDTNFTTransfer(). Use interaction.withSender() instead.
  • Directly reading or setting the fields transaction.options, transaction.version is now deprecated. Use the get* and set* functions, instead.

Full Github Release Notes: mx-sdk-js-core - v12.0.1

We'd like to invite you joining us on Discord, where you can connect with other builders and developers, stay up-to-date on all things happening behind the scenes, and receive support from the community.

Do you need more information?

Explore projects, tokens, and integrations built on MultiversX