wallet-core icon indicating copy to clipboard operation
wallet-core copied to clipboard

[Pactus]: Support Pactus Blockchain

Open b00f opened this issue 1 year ago • 6 comments

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> && popd to generate blockchain skeleton and configure integration tests.
    • [x] Execute tools/generate-files.
    • [x] Execute pushd rust && cargo check --tests && popd to check if Rust codebase compiles successfully.
    • [x] Execute make -Cbuild -j12 tests TrezorCryptoTests to check if C++ codebase compiles successfully.
  • [x] Add relevant constants in Curve, Hasher etc., 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>/tests directory.
    • [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] 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.cpp and coin_address_derivation_test.rs, CoinAddressValidationTests.cpp, TWHRPTests.cpp, CoinAddressDerivationTests.kt, CoinAddressDerivationTests.swift.
  • [x] Upload coin icon to trustwallet/assets if necessary.

b00f avatar Oct 07 '24 05:10 b00f

@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!

b00f avatar Oct 09 '24 14:10 b00f

Hey @b00f He will review the PR next week - thank you

Milerius avatar Oct 11 '24 01:10 Milerius

@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?

b00f avatar Oct 16 '24 06:10 b00f

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

satoshiotomakan avatar Oct 17 '24 08:10 satoshiotomakan

@b00f please also fix the following assertion o iOS:

testAddress, XCTAssertEqual failed: ("95794161374b22c696dabb98e93f6ca9300b22f3b904921fbf560bb72145f4fa") is not equal to ("0x95794161374b22c696dabb98e93f6ca9300b22f3b904921fbf560bb72145f4fa")

satoshiotomakan avatar Oct 22 '24 10:10 satoshiotomakan

@satoshiotomakan it's done.

b00f avatar Oct 22 '24 12:10 b00f

@satoshiotomakan The tests in Rust are now compatible with mainnet transactions. Additionally, we have implemented the Bond Payload, which is also covered by tests.

b00f avatar Oct 29 '24 18:10 b00f

All tests have been updated with data from broadcasted transactions on the mainnet. Transactions are available here:

@satoshiotomakan please check. Thanks

b00f avatar Nov 01 '24 11:11 b00f

@satoshiotomakan There was a typo in the Android test, which has been fixed. Please re-run the tests. Apologies for the mistake.

b00f avatar Nov 05 '24 12:11 b00f

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 avatar Nov 07 '24 17:11 satoshiotomakan

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

b00f avatar Nov 08 '24 14:11 b00f