[Pactus]: Support Pactus Blockchain
Description
This PR adds support for the Pactus Blockchain in TrustWalletCore. It follows the Integration Criteria highlighted by TrustWalletCore team.
How to test
This PR includes all the necessary tests to ensure the integration is done properly. We have also compared the results with the native wallet in Pactus, which is available here and here.
This PR fixes #4056 .
Types of changes
New feature (non-breaking change which adds functionality)
Checklist
- [x] Create pull request as draft initially, unless its complete.
- [x] Add tests to cover changes as needed.
- [ ] Update documentation as needed.
- [x] If there is a related Issue, mention it in the description.
- [x] I have read the guidelines for adding a new blockchain.
Integration Checklist
- [x] Coin Definition:
- [x] Add the coin definition to
registry.json. - [x] Execute
pushd codegen-v2 && cargo run -- new-blockchain <coinid> && popdto generate blockchain skeleton and configure integration tests. - [x] Execute
tools/generate-files. - [x] Execute
pushd rust && cargo check --tests && popdto check if Rust codebase compiles successfully. - [x] Execute
make -Cbuild -j12 tests TrezorCryptoTeststo check if C++ codebase compiles successfully.
- [x] Add the coin definition to
- [x] Add relevant constants in
Curve,Hasheretc., in C++ and Rust, as necessary. - [x] Implement functionality in Rust.
- [x] Entry at
rust/chains/tw_<coinid>/src/entry.rs. - [x] Address at
rust/chains/tw_<coinid>/src/address.rs. - [x] Transaction (if necessary) at
rust/chains/tw_<coinid>/src/transaction.rs. - [x] Signer at
rust/chains/tw_<coinid>/src/signer.rs. - [x] Compiler at
rust/chains/tw_<coinid>/src/compiler.rs. - [x] Write unit tests. Put them in the
rust/chains/tw_<coinid>/testsdirectory. - [x] Write Rust integration tests. Put them in a subfolder of
rust/tw_any_coin/tests/chains/<coinid>- [x] Transaction signing tests, at least one mainnet transaction test.
- [ ] Add stake, unstake, get rewards tests if the blockchain is PoS like.
- [x] Entry at
- [x] Write C++ integration tests. Put them in a subfolder of
tests/chains/<CoinId>. - [x] Validate generated code in Android an iOS projects. Write integration tests for each.
- [x] Extend central derivation and validation tests: make sure the following tests are extended with the new coin:
CoinAddressDerivationTests.cppandcoin_address_derivation_test.rs,CoinAddressValidationTests.cpp,TWHRPTests.cpp,CoinAddressDerivationTests.kt,CoinAddressDerivationTests.swift. - [x] Upload coin icon to trustwallet/assets if necessary.
@philiparthurmoore
I hope this message finds you well!
If you have a moment, I would greatly appreciate your review of this pull request. Please let us know if there’s anything we might have missed that needs attention before we proceed with the merge.
Thank you very much for your assistance!
Hey @b00f He will review the PR next week - thank you
@satoshiotomakan Thank you for taking the time to review this PR. I believe all of your comments have been addressed. Could you please double-check and resolve those that are confirmed?
Hi @b00f, could you please fix cargo fmt warnings, fix cargo clippy in advance, make sure all Rust tests pass.
Please also take a look at these Android, Swift test examples, and change your tests accordingly:
https://github.com/trustwallet/wallet-core/blob/4b203e076d1e7c042eae573f3b084cd3e53782ae/android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestEthereumTransactionSigner.kt#L25-L46
https://github.com/trustwallet/wallet-core/blob/4b203e076d1e7c042eae573f3b084cd3e53782ae/swift/Tests/Blockchains/EthereumTests.swift#L22-L42
@b00f please also fix the following assertion o iOS:
testAddress, XCTAssertEqual failed: ("95794161374b22c696dabb98e93f6ca9300b22f3b904921fbf560bb72145f4fa") is not equal to ("0x95794161374b22c696dabb98e93f6ca9300b22f3b904921fbf560bb72145f4fa")
@satoshiotomakan it's done.
@satoshiotomakan The tests in Rust are now compatible with mainnet transactions. Additionally, we have implemented the Bond Payload, which is also covered by tests.
All tests have been updated with data from broadcasted transactions on the mainnet. Transactions are available here:
- An example of Transfer
- An example of Bond with Public Key
- An example of Bond without Public Key
@satoshiotomakan please check. Thanks
@satoshiotomakan There was a typo in the Android test, which has been fixed. Please re-run the tests. Apologies for the mistake.
Hi @b00f, if you want the Pactus Blockchain to be integrated into TrustWallet app, please submit a request to https://support.trustwallet.com/en/support/tickets/new
@SatoshiOtomakan and the Wallet-Core project team,
Thank you for this amazing project and for carefully reviewing this PR and helping us correct our mistakes. I will definitely submit the request, and we hope to see Pactus in the Trust Wallet application soon.