Skip to content

Commit 6e515ac

Browse files
chore(aptos): Deprecate register_token in Rust (trustwallet#4491)
* chore(aptos): Deprecate `register_token` in Rust * chore(ci): Fix brew install cmake * chore(aptos): Remove `test_aptos_register_token` test * chore(ci): CMake * chore(ci): Downgrade KMP sample CI to MacOS 14 temporarily * chore(ci): Fix padding in a script
1 parent 1bbb81b commit 6e515ac

File tree

6 files changed

+11
-90
lines changed

6 files changed

+11
-90
lines changed

.github/workflows/kotlin-sample-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212

1313
jobs:
1414
build:
15-
runs-on: macos-latest-xlarge
15+
runs-on: macos-14-xlarge
1616
if: github.event.pull_request.draft == false
1717
steps:
1818
- uses: actions/checkout@v3

rust/chains/tw_aptos/src/aptos_move_packages.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,6 @@ pub fn token_transfers_claim_script(
192192
)))
193193
}
194194

195-
pub fn managed_coin_register(coin_type: TypeTag) -> TransactionPayload {
196-
TransactionPayload::EntryFunction(EntryFunction::new(
197-
ModuleId::new(
198-
AccountAddress::new([
199-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
200-
0, 0, 0, 1,
201-
]),
202-
ident_str!("managed_coin").to_owned(),
203-
),
204-
ident_str!("register").to_owned(),
205-
vec![coin_type],
206-
vec![],
207-
json!([]),
208-
))
209-
}
210-
211195
pub fn fungible_asset_transfer(
212196
metadata_address: AccountAddress,
213197
to: AccountAddress,

rust/chains/tw_aptos/src/transaction_builder.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use crate::address::from_account_error;
66
use crate::aptos_move_packages::{
77
aptos_account_create_account, aptos_account_transfer, aptos_account_transfer_coins,
8-
coin_transfer, fungible_asset_transfer, managed_coin_register,
9-
token_transfers_cancel_offer_script, token_transfers_claim_script,
10-
token_transfers_offer_script,
8+
coin_transfer, fungible_asset_transfer, token_transfers_cancel_offer_script,
9+
token_transfers_claim_script, token_transfers_offer_script,
1110
};
1211
use crate::constants::{GAS_UNIT_PRICE, MAX_GAS_AMOUNT};
1312
use crate::liquid_staking::{
@@ -124,13 +123,6 @@ impl TransactionFactory {
124123
OneOftransaction_payload::nft_message(nft_message) => {
125124
factory.nft_ops(NftOperation::try_from(nft_message)?)
126125
},
127-
OneOftransaction_payload::register_token(register_token) => {
128-
let function = register_token
129-
.function
130-
.or_tw_err(SigningErrorType::Error_invalid_params)
131-
.context("'ManagedTokensRegisterMessage::function' is not set")?;
132-
Ok(factory.register_token(convert_proto_struct_tag_to_type_tag(function)?))
133-
},
134126
OneOftransaction_payload::liquid_staking_message(msg) => {
135127
factory.liquid_staking_ops(LiquidStakingOperation::try_from(msg)?)
136128
},
@@ -200,10 +192,6 @@ impl TransactionFactory {
200192
Ok(self.payload(aptos_account_create_account(to)?))
201193
}
202194

203-
pub fn register_token(&self, coin_type: TypeTag) -> TransactionBuilder {
204-
self.payload(managed_coin_register(coin_type))
205-
}
206-
207195
pub fn nft_ops(&self, operation: NftOperation) -> SigningResult<TransactionBuilder> {
208196
match operation {
209197
NftOperation::Claim(claim) => Ok(self.payload(token_transfers_claim_script(

rust/chains/tw_aptos/tests/signer.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,6 @@ fn setup_proto_transaction<'a>(
122122
panic!("Unsupported arguments")
123123
}
124124
},
125-
"register_token" => {
126-
if let OpsDetails::RegisterToken(register_token) = ops_details.unwrap() {
127-
Proto::mod_SigningInput::OneOftransaction_payload::register_token(
128-
Proto::ManagedTokensRegisterMessage {
129-
function: Some(convert_type_tag_to_struct_tag(register_token.coin_type)),
130-
},
131-
)
132-
} else {
133-
panic!("Unsupported arguments")
134-
}
135-
},
136125
"liquid_staking_ops" => {
137126
if let OpsDetails::LiquidStakingOps(liquid_staking_ops) = ops_details.unwrap() {
138127
Proto::mod_SigningInput::OneOftransaction_payload::liquid_staking_message(
@@ -598,46 +587,6 @@ fn test_aptos_nft_claim() {
598587
}"#);
599588
}
600589

601-
// Successfully broadcasted https://explorer.aptoslabs.com/txn/0xe591252daed785641bfbbcf72a5d17864568cf32e04c0cc9129f3a13834d0e8e?network=testnet
602-
#[test]
603-
fn test_aptos_register_token() {
604-
let input = setup_proto_transaction("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", // Sender's address
605-
"5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec", // Keypair
606-
"register_token",
607-
23, // Sequence number
608-
2,
609-
2000000,
610-
3664390082,
611-
100,
612-
"",
613-
"",
614-
Some(OpsDetails::RegisterToken(RegisterToken { coin_type: TypeTag::from_str("0xe4497a32bf4a9fd5601b27661aa0b933a923191bf403bd08669ab2468d43b379::move_coin::MoveCoin").unwrap() })),
615-
);
616-
let output = Signer::sign_proto(input);
617-
test_tx_result(output,
618-
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3017000000000000000200000000000000000000000000000000000000000000000000000000000000010c6d616e616765645f636f696e0872656769737465720107e4497a32bf4a9fd5601b27661aa0b933a923191bf403bd08669ab2468d43b379096d6f76655f636f696e084d6f7665436f696e000080841e00000000006400000000000000c2276ada0000000002", // Expected raw transaction bytes
619-
"e230b49f552fb85356dbec9df13f0dc56228eb7a9c29a8af3a99f4ae95b86c72bdcaa4ff1e9beb0bd81c298b967b9d97449856ec8bc672a08e2efef345c37100", // Expected signature
620-
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3017000000000000000200000000000000000000000000000000000000000000000000000000000000010c6d616e616765645f636f696e0872656769737465720107e4497a32bf4a9fd5601b27661aa0b933a923191bf403bd08669ab2468d43b379096d6f76655f636f696e084d6f7665436f696e000080841e00000000006400000000000000c2276ada00000000020020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c40e230b49f552fb85356dbec9df13f0dc56228eb7a9c29a8af3a99f4ae95b86c72bdcaa4ff1e9beb0bd81c298b967b9d97449856ec8bc672a08e2efef345c37100", // Expected encoded transaction
621-
r#"{
622-
"expiration_timestamp_secs": "3664390082",
623-
"gas_unit_price": "100",
624-
"max_gas_amount": "2000000",
625-
"payload": {
626-
"arguments": [],
627-
"function": "0x1::managed_coin::register",
628-
"type": "entry_function_payload",
629-
"type_arguments": ["0xe4497a32bf4a9fd5601b27661aa0b933a923191bf403bd08669ab2468d43b379::move_coin::MoveCoin"]
630-
},
631-
"sender": "0x7968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30",
632-
"sequence_number": "23",
633-
"signature": {
634-
"public_key": "0xea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c",
635-
"signature": "0xe230b49f552fb85356dbec9df13f0dc56228eb7a9c29a8af3a99f4ae95b86c72bdcaa4ff1e9beb0bd81c298b967b9d97449856ec8bc672a08e2efef345c37100",
636-
"type": "ed25519_signature"
637-
}
638-
}"#);
639-
}
640-
641590
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x25dca849cb4ebacbff223139f7ad5d24c37c225d9506b8b12a925de70429e685/userTxnOverview?network=mainnet
642591
#[test]
643592
fn test_aptos_tortuga_stake() {

src/proto/Aptos.proto

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ message FungibleAssetTransferMessage {
5757
uint64 amount = 3;
5858
}
5959

60-
// Necessary fields to process a ManagedTokensRegisterMessage
61-
message ManagedTokensRegisterMessage {
62-
// token function to register, e.g BTC: 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC
63-
StructTag function = 1;
64-
}
65-
6660
// Necessary fields to process a CreateAccountMessage
6761
message CreateAccountMessage {
6862
// auth account address to create
@@ -171,7 +165,6 @@ message SigningInput {
171165
TokenTransferMessage token_transfer = 10;
172166
CreateAccountMessage create_account = 11;
173167
NftMessage nft_message = 12;
174-
ManagedTokensRegisterMessage register_token = 13;
175168
LiquidStaking liquid_staking_message = 14;
176169
TokenTransferCoinsMessage token_transfer_coins = 15;
177170
FungibleAssetTransferMessage fungible_asset_transfer = 16;

tools/install-sys-dependencies-mac

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
set -e
44

5-
brew install cmake boost ninja xcodegen xcbeautify
5+
brew install boost ninja xcodegen xcbeautify
6+
7+
if command -v cmake &> /dev/null
8+
then
9+
echo "Skip installing CMake."
10+
else
11+
brew install cmake
12+
fi
613

714
if [[ "$BOOST_ROOT" == "" ]]; then
815
echo "export BOOST_ROOT=$(brew --prefix boost)" >> ~/.zprofile

0 commit comments

Comments
 (0)