Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Polkadot implementation to Rust. (#4102)
* Add the tw_ss58_address crate * Apply suggestions from code review, refactor some utility functions * Remove unused dependency * Add PolkadotAddress * Add NetworkId constants and Hash derivation * Add SCALE encoding for integers (fixed and compact) * Fix tiny things in scale.rs * Add extrinsics * Add PolkadotPrefix * Require a pre-built NetworkId when deriving SS58Address * Format extrinsic.rs * Add address parsing and derivation in entry.rs * Rename SS58Address::from_str to SS58Address::parse * Add SubstrateNetwork to AddressPrefix enum * Rework ToScale trait to allow encoding to an existing Vec, add more implementations * Refactor Extrinsic to use in-place encoding * Add more tests for staking extrinsics * Introduce ExtrinsicEncoder helper to build encoded extrinsics * Refactor Scale encoding into tw_scale crate. * Add u128 SCALE support. * Fix: Use correct endianess. * Add struct/enum SCALE encoding macros. * Add Substrate ExtrinsicV4 encoding. * U256 to u128. * Add Substrate call encoding support. * Fix some incorrect tests. * Add more extrinsic support. * Fix Option SCALE encoding. * Add Polymesh network id. * Remove extra lifetimes. Simplify code. * More encoder refactoring. * Fix SCALE encoding test for Option type. * Update Polkadot CoinEntry impl. * Add support for custom call index. * Implement Era SCALE encoding. * cargo fmt * Move common Substrate logic in tw_substrate crate. * Improve bool SCALE code. * Refactor highly nested test code. * cargo fmt * Implment Polkadot coin address derivation test. * Add more Era tests ported from the C++ tests. * Refactor call encoder. * FIXUP * Implement signer and compiler. * Start adding tw_tests for polkadot. * Add ss58prefix support to tw_coin_registry. * implement tw_any_address_is_valid_ss58 and tw_any_address_create_ss58_with_public_key * Fix missing length prefix when encoding signed transaction. * cargo fmt * Add support for CheckMetadata transaction extension. * Refactor transaction building. * Add support for optional MultiAddress. * Finish support for optional MultiAddress. * Fix C++ test, Rust impl returns different error code. * Fix 'tip' support. * Add support for ChargeAssetTxPayment (paying tx fee with asset). * Remove unused call indices. * Add more SS58 address types. * Update Polkadot C++ tests to use TWAny* interfaces. * Use default value for block hashes. * Improve errors. * Support custom call indices in Polymesh. * Fix Polkadot CheckMetadataHash support * Support old staking.bond calls. * Support Kusama with Rust impl. Remove old C++ impl. * Fix address derivation test for Acala and Kusama * Add Rust polkadot compile/sign tests. * cargo fmt * Merge TransactionBuilder and PrepareTransaction types. * Use SubstrateCoinEntry trait to better support Substrate chains. * Add missing crates to top-level Cargo.toml. * Re-enable test. * Fix memory leaks in C++ unit tests. * Update Acala support to match C++. * Move tw_substrate to frameworks. * Improve error reporting. * Simplify Compact encoding. * Refactor some rarely used SCALE code. * Rename Encoded to RawOwned and move to tw_scale. * Use H256 in Memo and IdentityId. * Don't store KeyPair. * Remove unused error variant. * Improve errors. * Improve errors with context. * Remove TWSS58AddressType * Remove deadcode * Remove consts from tw_ss58_address crate. * Simplify impl_enum_scale macro * Document SCALE macros. * Some code cleanup and deps reorder. * Cleanup `parse_address` * Fix RewardDestination. Added missing ACCOUNT variant. * Remove assert. * Fix C++ tests and use original expected output. * Fix TODO * Revert RewardDestination::ACCOUNT change. * Add links for Polymesh encoded transactions. * Cleanup error conversion code. * Port some tests from C++ to Rust. * Finish porting C++ test to Rust. * Remove old C++ tests. Only keep one for integration. * Sort crates. * Add docs to `tw_substrate`. * More docs. * Add note about space padded Memo. * Port most address validation tests from C++. * Fix cargo clippy warnings. * Fix C++ test compile errors. * Fix implicit conversion warning. * Try fixing iOS build. --------- Co-authored-by: doom <clement.doumergue@binance.com>
- Loading branch information