Skip to content

Commit

Permalink
Merge branch 'feature/msg-address-unpack' into 'master'
Browse files Browse the repository at this point in the history
Add UnpackAbi and KnownParamType support for MsgAddress

See merge request network/nekoton!2
  • Loading branch information
MrWad3r committed Sep 27, 2023
2 parents c7e3bdc + 30e6351 commit dd1befc
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 dd1befc

Please sign in to comment.