Skip to content

Commit

Permalink
Merge pull request #38 from tangem/feature/IOS-6965_jetton_external_s…
Browse files Browse the repository at this point in the history
…igner_support

Add external signer support for jetton transactions
  • Loading branch information
fedorov-d authored Jun 3, 2024
2 parents ac3b3b2 + 4f5226c commit cee89fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/TheOpenNetwork/Signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Data Signer::createTransferMessage(std::shared_ptr<Wallet> wallet, const Private
}

Data Signer::createJettonTransferMessage(std::shared_ptr<Wallet> wallet, const PrivateKey& privateKey, const Proto::JettonTransfer& jettonTransfer) {
return createJettonTransferMessage(wallet, privateKey, jettonTransfer, nullptr);
}

// TANGEM
Data Signer::createJettonTransferMessage(std::shared_ptr<Wallet> wallet, const PrivateKey& privateKey, const Proto::JettonTransfer& jettonTransfer, const std::function<Data(Data)> externalSigner) {
const Proto::Transfer& transferData = jettonTransfer.transfer();

const auto payload = jettonTransferPayload(
Expand All @@ -48,6 +53,7 @@ Data Signer::createJettonTransferMessage(std::shared_ptr<Wallet> wallet, const P

const auto msg = wallet->createQueryMessage(
privateKey,
externalSigner,
Address(transferData.dest(), transferData.bounceable()),
transferData.amount(),
transferData.sequence_number(),
Expand Down Expand Up @@ -102,7 +108,7 @@ Proto::SigningOutput Signer::sign(const Proto::SigningInput& input, const Data&
case Proto::WalletVersion::WALLET_V4_R2: {
const int8_t workchainId = WorkchainType::Basechain;
auto wallet = std::make_shared<WalletV4R2>(publicKey, workchainId);
const auto& transferMessage = Signer::createJettonTransferMessage(wallet, privateKey, jettonTransfer);
const auto& transferMessage = Signer::createJettonTransferMessage(wallet, privateKey, jettonTransfer, externalSigner);
protoOutput.set_encoded(TW::Base64::encode(transferMessage));
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/TheOpenNetwork/Signer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Signer {

/// Creates a signed jetton transfer message
static Data createJettonTransferMessage(std::shared_ptr<Wallet> wallet, const PrivateKey& privateKey, const Proto::JettonTransfer& transfer);

// TANGEM
static Data createJettonTransferMessage(std::shared_ptr<Wallet> wallet, const PrivateKey& privateKey, const Proto::JettonTransfer& jettonTransfer, const std::function<Data(Data)> externalSigner);

/// Signs a Proto::SigningInput transaction
static Proto::SigningOutput sign(const Proto::SigningInput& input) noexcept;
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tangem=4.0.21-tangem5
tangem=4.0.21-tangem6

0 comments on commit cee89fd

Please sign in to comment.