Skip to content

Commit

Permalink
Add UnpackAbi and KnownParamType support for MsgAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWad3r committed Sep 27, 2023
1 parent c7e3bdc commit 30e6351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion nekoton-abi/src/known_param_type.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;

use ton_abi::{Param, ParamType};
use ton_block::{MsgAddrStd, MsgAddressInt};
use ton_block::{MsgAddrStd, MsgAddress, MsgAddressInt};
use ton_types::{BuilderData, Cell};

use super::{MaybeRef, StandaloneToken};
Expand Down Expand Up @@ -120,6 +120,12 @@ impl KnownParamType for MsgAddressInt {
}
}

impl KnownParamType for MsgAddress {
fn param_type() -> ParamType {
ParamType::Address
}
}

impl KnownParamType for MsgAddrStd {
fn param_type() -> ParamType {
ParamType::Address
Expand Down
11 changes: 10 additions & 1 deletion nekoton-abi/src/token_unpacker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use num_bigint::{BigInt, BigUint};
use num_traits::ToPrimitive;
use ton_abi::{Token, TokenValue};
use ton_block::{MsgAddrStd, MsgAddressInt};
use ton_block::{MsgAddrStd, MsgAddress, MsgAddressInt};
use ton_types::Cell;

use super::{MaybeRef, StandaloneToken};
Expand Down Expand Up @@ -219,6 +219,15 @@ impl UnpackAbi<MsgAddressInt> for TokenValue {
}
}

impl UnpackAbi<MsgAddress> for TokenValue {
fn unpack(self) -> UnpackerResult<MsgAddress> {
match self {
TokenValue::Address(address) => Ok(address),
_ => Err(UnpackerError::InvalidAbi),
}
}
}

impl UnpackAbi<MsgAddrStd> for TokenValue {
fn unpack(self) -> UnpackerResult<MsgAddrStd> {
match self {
Expand Down

0 comments on commit 30e6351

Please sign in to comment.