WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 471f1d0

Browse files
committed
Add burn notification to jetton parsing
1 parent 1950da0 commit 471f1d0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

nekoton-contracts/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ mod utils {
146146
(@abi_version v2_1) => { ::ton_abi::contract::ABI_VERSION_2_1 };
147147
(@abi_version v2_2) => { ::ton_abi::contract::ABI_VERSION_2_2 };
148148
(@abi_version v2_3) => { ::ton_abi::contract::ABI_VERSION_2_3 };
149+
(@abi_version v2_7) => { ::ton_abi::contract::ABI_VERSION_2_7 };
149150

150151
(@function_id $f:ident) => { $f.get_function_id() };
151152
(@function_id $f:ident $id:literal) => { $id };

src/core/jetton_wallet/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use super::{utils, ContractSubscription, InternalMessage};
1818

1919
pub const JETTON_TRANSFER_OPCODE: u32 = 0x0f8a7ea5;
2020
pub const JETTON_INTERNAL_TRANSFER_OPCODE: u32 = 0x178d4519;
21+
pub const JETTON_BURN_NOTIFICATION_OPCODE: u32 = 0x7bdd97de;
2122

2223
pub struct JettonWallet {
2324
clock: Arc<dyn Clock>,
@@ -246,6 +247,9 @@ impl JettonWallet {
246247
JettonWalletTransaction::InternalTransfer(transfer) => {
247248
balance += transfer.tokens.clone().to_bigint().trust_me();
248249
}
250+
JettonWalletTransaction::BurnNotification(transfer) => {
251+
balance -= transfer.tokens.clone().to_bigint().trust_me();
252+
}
249253
}
250254
}
251255

src/core/parsing.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use nekoton_abi::*;
1010
use nekoton_contracts::tip4_1::nft_contract;
1111
use nekoton_contracts::{old_tip3, tip3_1};
1212

13-
use crate::core::jetton_wallet::{JETTON_INTERNAL_TRANSFER_OPCODE, JETTON_TRANSFER_OPCODE};
13+
use crate::core::jetton_wallet::{
14+
JETTON_BURN_NOTIFICATION_OPCODE, JETTON_INTERNAL_TRANSFER_OPCODE, JETTON_TRANSFER_OPCODE,
15+
};
1416
use crate::core::models::*;
1517
use crate::core::ton_wallet::{MultisigType, WalletType};
1618

@@ -706,7 +708,10 @@ pub fn parse_jetton_transaction(
706708

707709
let opcode = body.get_next_u32().ok()?;
708710

709-
if opcode != JETTON_TRANSFER_OPCODE && opcode != JETTON_INTERNAL_TRANSFER_OPCODE {
711+
if opcode != JETTON_TRANSFER_OPCODE
712+
&& opcode != JETTON_INTERNAL_TRANSFER_OPCODE
713+
&& opcode != JETTON_BURN_NOTIFICATION_OPCODE
714+
{
710715
return None;
711716
}
712717

@@ -732,6 +737,12 @@ pub fn parse_jetton_transaction(
732737
tokens: amount,
733738
},
734739
)),
740+
JETTON_BURN_NOTIFICATION_OPCODE => Some(JettonWalletTransaction::BurnNotification(
741+
JettonBurnNotification {
742+
from: addr,
743+
tokens: amount,
744+
},
745+
)),
735746
_ => None,
736747
}
737748
}

src/models.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ pub enum TokenWalletTransaction {
283283
pub enum JettonWalletTransaction {
284284
Transfer(JettonOutgoingTransfer),
285285
InternalTransfer(JettonIncomingTransfer),
286+
BurnNotification(JettonBurnNotification),
286287
}
287288

288289
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -321,6 +322,14 @@ pub struct JettonIncomingTransfer {
321322
pub tokens: BigUint,
322323
}
323324

325+
#[derive(Clone, Debug, Serialize, Deserialize)]
326+
pub struct JettonBurnNotification {
327+
#[serde(with = "serde_string")]
328+
pub from: MsgAddressInt,
329+
#[serde(with = "serde_string")]
330+
pub tokens: BigUint,
331+
}
332+
324333
#[derive(Clone, Debug, Serialize, Deserialize)]
325334
pub struct JettonOutgoingTransfer {
326335
#[serde(with = "serde_string")]

0 commit comments

Comments
 (0)