Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk-core v12 #263

Merged
merged 91 commits into from
Apr 7, 2023
Merged

sdk-core v12 #263

merged 91 commits into from
Apr 7, 2023

Conversation

schimih
Copy link
Contributor

@schimih schimih commented Feb 20, 2023

sdk-core v12 is now released 🎉

See the updated cookbook. Also, see the migration notes.

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 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).

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);

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

  • 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.

Pull Requests

New Contributors

maximechbt and others added 30 commits July 12, 2022 19:58
fix: Update type of abiRegistry types
@andreibancioiu andreibancioiu self-assigned this Apr 4, 2023
@andreibancioiu andreibancioiu changed the title Feat/erdjs v12 sdk-core v12 Apr 5, 2023
andreibancioiu
andreibancioiu previously approved these changes Apr 5, 2023
andreibancioiu
andreibancioiu previously approved these changes Apr 5, 2023
bogdan-rosianu
bogdan-rosianu previously approved these changes Apr 5, 2023
@andreibancioiu andreibancioiu dismissed stale reviews from bogdan-rosianu and themself via 9ecfabe April 6, 2023 13:57
@andreibancioiu andreibancioiu self-requested a review April 6, 2023 13:57
andreibancioiu
andreibancioiu previously approved these changes Apr 6, 2023
bogdan-rosianu
bogdan-rosianu previously approved these changes Apr 6, 2023
andreibancioiu and others added 4 commits April 6, 2023 20:48
…ed). Kept AbiRegistry, which is sufficient. Breaking change.
Breaking change / simplification: remove "SmartContractAbi"; "AbiRegistry" is sufficient
@andreibancioiu andreibancioiu dismissed stale reviews from bogdan-rosianu and themself via 516cf36 April 7, 2023 08:32
@andreibancioiu andreibancioiu merged commit bb59728 into main Apr 7, 2023
@andreibancioiu andreibancioiu deleted the feat/erdjs-v12 branch September 25, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants