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

[Solana]: Support specifying fee payer for an encoded transaction #4156

Merged
merged 6 commits into from
Dec 16, 2024

Conversation

10gic
Copy link
Contributor

@10gic 10gic commented Dec 9, 2024

Description

Fix issue #4114

How to test

Run Rust, C++, iOS, Android tests

Types of changes

Checklist

  • Create pull request as draft initially, unless its complete.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • If there is a related Issue, mention it in the description.

If you're adding a new blockchain

  • I have read the guidelines for adding a new blockchain.

satoshiotomakan
satoshiotomakan previously approved these changes Dec 9, 2024
Copy link
Collaborator

@satoshiotomakan satoshiotomakan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Only one note - tw_solana_transaction_add_fee_payer won't be available to be called from Kotlin, Swift, JS bindings unless we bridge it through include/TWSolanaTransaction.h

@satoshiotomakan
Copy link
Collaborator

Do you have a chance to make a bridge similar to

TWString *_Nullable TWSolanaTransactionGetComputeUnitPrice(TWString *_Nonnull encodedTx) {
auto& encodedTxRef = *reinterpret_cast<const std::string*>(encodedTx);
Rust::TWStringWrapper encodedTxStr = encodedTxRef;
Rust::TWStringWrapper maybePrice = Rust::tw_solana_transaction_get_compute_unit_price(encodedTxStr.get());
if (!maybePrice) {
return nullptr;
}
auto priceStr = maybePrice.toStringOrDefault();
return TWStringCreateWithUTF8Bytes(priceStr.c_str());
}

@10gic
Copy link
Contributor Author

10gic commented Dec 9, 2024

Do you have a chance to make a bridge similar to

TWString *_Nullable TWSolanaTransactionGetComputeUnitPrice(TWString *_Nonnull encodedTx) {
auto& encodedTxRef = *reinterpret_cast<const std::string*>(encodedTx);
Rust::TWStringWrapper encodedTxStr = encodedTxRef;
Rust::TWStringWrapper maybePrice = Rust::tw_solana_transaction_get_compute_unit_price(encodedTxStr.get());
if (!maybePrice) {
return nullptr;
}
auto priceStr = maybePrice.toStringOrDefault();
return TWStringCreateWithUTF8Bytes(priceStr.c_str());
}

Currently, I haven’t added a getter function for the fee payer. The fee payer is simply the first account in a Solana transaction, and we can easily retrieve it since we already support the Solana transaction decoder.

@10gic
Copy link
Contributor Author

10gic commented Dec 9, 2024

Looks good! Only one note - tw_solana_transaction_add_fee_payer won't be available to be called from Kotlin, Swift, JS bindings unless we bridge it through include/TWSolanaTransaction.h

Thanks for the reminder; I will add it later.

@satoshiotomakan
Copy link
Collaborator

Currently, I haven’t added a getter function for the fee payer. The fee payer is simply the first account in a Solana transaction, and we can easily retrieve it since we already support the Solana transaction decoder.

No I mean we need to have a C++ -> Rust bridge, so it can be used not only from C++ or Rust, but also from Kotlin, Swift etc

@10gic
Copy link
Contributor Author

10gic commented Dec 11, 2024

Hi @satoshiotomakan, I tried for a while but couldn’t run the kotlin/swift test cases locally. Could you please help trigger the CI test cases?

Copy link
Collaborator

@satoshiotomakan satoshiotomakan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @10gic, let's run it

@satoshiotomakan
Copy link
Collaborator

@10gic there is a mistake in an iOS test

@10gic 10gic force-pushed the solana-support-fee-payer branch from fa6ea48 to 88b60a3 Compare December 11, 2024 11:40
@10gic
Copy link
Contributor Author

10gic commented Dec 11, 2024

@10gic there is a mistake in an iOS test

I have tried to fix it.

@satoshiotomakan satoshiotomakan merged commit b37b780 into trustwallet:master Dec 16, 2024
12 checks passed
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.

2 participants