Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
akostylev0 committed Sep 19, 2024
1 parent d492a8d commit d4a7164
Show file tree
Hide file tree
Showing 28 changed files with 246 additions and 272 deletions.
10 changes: 5 additions & 5 deletions crates/contracts/src/jetton/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tlb::{
r#as::{Remainder, VarInt},
ser::{BitPack, BitWriter, BitWriterExt},
},
de::{CellDeserialize, CellParser, CellParserError},
de::{CellDeserialize, OrdinaryCellParser, OrdinaryCellParserError},
either::Either,
r#as::{EitherInlineOrRef, ParseFully, Ref, Same},
ser::{CellBuilder, CellBuilderError, CellSerialize},
Expand Down Expand Up @@ -67,7 +67,7 @@ where
P: CellDeserialize<'de>,
F: CellDeserialize<'de>,
{
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
// transfer#0f8a7ea5
parser.unpack::<ConstU32<JETTON_TRANSFER_TAG>>()?;
Ok(Self {
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<'de, F> CellDeserialize<'de> for ForwardPayload<F>
where
F: CellDeserialize<'de>,
{
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
if parser.bits_left() >= bits_of::<u32>()
// clone, so we don't advance original parser
&& parser.clone().unpack::<u32>()? == Self::COMMENT_PREFIX
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'de, P> CellDeserialize<'de> for JettonTransferNotification<P>
where
P: CellDeserialize<'de>,
{
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
parser.unpack::<ConstU32<JETTON_TRANSFER_NOTIFICATION_TAG>>()?;
Ok(Self {
query_id: parser.unpack()?,
Expand Down Expand Up @@ -253,7 +253,7 @@ impl<'de, P> CellDeserialize<'de> for JettonBurn<P>
where
P: CellDeserialize<'de>,
{
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
parser.unpack::<ConstU32<JETTON_BURN_TAG>>()?;
Ok(Self {
query_id: parser.unpack()?,
Expand Down
14 changes: 7 additions & 7 deletions crates/contracts/src/wallet/v4r2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use nacl::sign::PUBLIC_KEY_LENGTH;
use num_bigint::BigUint;
use tlb::{
bits::{de::BitReaderExt, ser::BitWriterExt},
de::{CellDeserialize, CellParser, CellParserError},
de::{CellDeserialize, OrdinaryCellParser, OrdinaryCellParserError},
r#as::{NoArgs, Ref},
ser::{CellBuilder, CellBuilderError, CellSerialize},
Cell, Error,
Expand Down Expand Up @@ -93,7 +93,7 @@ impl CellSerialize for WalletV4R2Data {
}

impl<'de> CellDeserialize<'de> for WalletV4R2Data {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
seqno: parser.unpack()?,
wallet_id: parser.unpack()?,
Expand Down Expand Up @@ -127,7 +127,7 @@ impl CellSerialize for WalletV4R2SignBody {
}

impl<'de> CellDeserialize<'de> for WalletV4R2SignBody {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
wallet_id: parser.unpack()?,
expire_at: parser.unpack_as::<_, UnixTimestamp>()?,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl CellSerialize for WalletV4R2Op {
}

impl<'de> CellDeserialize<'de> for WalletV4R2Op {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
Self::SEND_PREFIX => Self::Send(
iter::from_fn(|| {
Expand Down Expand Up @@ -216,7 +216,7 @@ where
IC: CellDeserialize<'de>,
ID: CellDeserialize<'de>,
{
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
plugin_workchain: parser.unpack()?,
plugin_balance: parser.unpack_as::<_, Grams>()?,
Expand Down Expand Up @@ -245,7 +245,7 @@ impl CellSerialize for WalletV4R2OpPlugin {
}

impl<'de> CellDeserialize<'de> for WalletV4R2OpPlugin {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
plugin_address: MsgAddress {
workchain_id: parser.unpack::<i8>()? as i32,
Expand Down Expand Up @@ -273,7 +273,7 @@ impl CellSerialize for WalletV4R2ExternalBody {

impl<'de> CellDeserialize<'de> for WalletV4R2ExternalBody {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
signature: parser.unpack()?,
body: parser.parse()?,
Expand Down
16 changes: 8 additions & 8 deletions crates/contracts/src/wallet/v5r1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use lazy_static::lazy_static;
use nacl::sign::PUBLIC_KEY_LENGTH;
use tlb::{
bits::{de::BitReaderExt, ser::BitWriterExt},
de::{CellDeserialize, CellParser, CellParserError},
de::{CellDeserialize, OrdinaryCellParser, OrdinaryCellParserError},
r#as::{Data, NoArgs},
ser::{CellBuilder, CellBuilderError, CellSerialize},
Cell, Error, ResultExt,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl CellSerialize for WalletV5R1Data {

impl<'de> CellDeserialize<'de> for WalletV5R1Data {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
is_signature_allowed: parser.unpack()?,
seqno: parser.unpack()?,
Expand Down Expand Up @@ -141,7 +141,7 @@ impl CellSerialize for WalletV5R1InnerRequest {
}

impl<'de> CellDeserialize<'de> for WalletV5R1InnerRequest {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
out_actions: parser
.parse_as::<_, Option<List>>()
Expand Down Expand Up @@ -200,7 +200,7 @@ impl CellSerialize for ExtendedAction {
}

impl<'de> CellDeserialize<'de> for ExtendedAction {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
Self::ADD_EXTENSION_PREFIX => Self::AddExtension(parser.unpack()?),
Self::DELETE_EXTENSION_PREFIX => Self::DeleteExtension(parser.unpack()?),
Expand Down Expand Up @@ -241,7 +241,7 @@ impl CellSerialize for WalletV5RSignBody {
}

impl<'de> CellDeserialize<'de> for WalletV5RSignBody {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
wallet_id: parser.unpack()?,
valid_until: parser.unpack_as::<_, UnixTimestamp>()?,
Expand Down Expand Up @@ -274,7 +274,7 @@ impl CellSerialize for WalletV5R1SignedRequest {
}

impl<'de> CellDeserialize<'de> for WalletV5R1SignedRequest {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
body: parser.parse()?,
signature: parser.unpack()?,
Expand Down Expand Up @@ -320,7 +320,7 @@ impl CellSerialize for WalletV5R1MsgBody {
}

impl<'de> CellDeserialize<'de> for WalletV5R1MsgBody {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
Self::INTERNAL_SIGNED_PREFIX => {
Self::InternalSigned(parser.parse().context("internal_signed")?)
Expand Down Expand Up @@ -350,7 +350,7 @@ impl CellSerialize for InternalExtensionWalletV5R1MsgBody {
}

impl<'de> CellDeserialize<'de> for InternalExtensionWalletV5R1MsgBody {
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
query_id: parser.unpack()?,
inner: parser.parse()?,
Expand Down
10 changes: 5 additions & 5 deletions crates/tlb-ton/src/action.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tlb::{
bits::{de::BitReaderExt, r#as::NBits, ser::BitWriterExt},
de::{CellDeserialize, CellParser, CellParserError},
de::{CellDeserialize, OrdinaryCellParser, OrdinaryCellParserError},
r#as::Ref,
ser::{CellBuilder, CellBuilderError, CellSerialize},
Cell, Error, ResultExt,
Expand Down Expand Up @@ -59,7 +59,7 @@ impl CellSerialize for OutAction {

impl<'de> CellDeserialize<'de> for OutAction {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
Self::SEND_MSG_PREFIX => Self::SendMsg(parser.parse().context("action_send_msg")?),
Self::SET_CODE_PREFIX => {
Expand Down Expand Up @@ -106,7 +106,7 @@ where
ID: CellDeserialize<'de>,
{
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
mode: parser.unpack()?,
message: parser.parse_as::<_, Ref>()?,
Expand All @@ -133,7 +133,7 @@ impl CellSerialize for ReserveCurrencyAction {

impl<'de> CellDeserialize<'de> for ReserveCurrencyAction {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
mode: parser.unpack()?,
currency: parser.parse()?,
Expand Down Expand Up @@ -168,7 +168,7 @@ where
R: CellDeserialize<'de>,
{
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
mode: parser.unpack_as::<_, NBits<7>>()?,
libref: parser.parse()?,
Expand Down
10 changes: 5 additions & 5 deletions crates/tlb-ton/src/bin_tree/aug.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tlb::{
bits::{de::BitReaderExt, ser::BitWriterExt},
de::{args::r#as::CellDeserializeAsWithArgs, CellParser, CellParserError},
de::{args::r#as::CellDeserializeAsWithArgs, OrdinaryCellParser, OrdinaryCellParserError},
r#as::{ParseFully, Ref},
ser::{args::r#as::CellSerializeAsWithArgs, CellBuilder, CellBuilderError},
};
Expand Down Expand Up @@ -49,9 +49,9 @@ where

#[inline]
fn parse_as_with(
parser: &mut CellParser<'de>,
parser: &mut OrdinaryCellParser<'de>,
(args, extra_args): Self::Args,
) -> Result<BinTreeAug<T, E>, CellParserError<'de>> {
) -> Result<BinTreeAug<T, E>, OrdinaryCellParserError<'de>> {
Ok(BinTreeAug {
extra: parser.parse_as_with::<_, AsE>(extra_args.clone())?,
node: parser
Expand Down Expand Up @@ -113,9 +113,9 @@ where

#[inline]
fn parse_as_with(
parser: &mut CellParser<'de>,
parser: &mut OrdinaryCellParser<'de>,
(args, extra_args): Self::Args,
) -> Result<BinTreeNode<T, E>, CellParserError<'de>> {
) -> Result<BinTreeNode<T, E>, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
false => BinTreeNode::Leaf(parser.parse_as_with::<_, AsT>(args)?),
true => BinTreeNode::Fork(
Expand Down
18 changes: 9 additions & 9 deletions crates/tlb-ton/src/bin_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::ops::Deref;

use tlb::bits::de::BitReaderExt;
use tlb::de::args::r#as::CellDeserializeAsWithArgs;
use tlb::de::{CellParser, CellParserError};
use tlb::de::{OrdinaryCellParser, OrdinaryCellParserError};
use tlb::r#as::Ref;

/// [`BinTree X`](https://docs.ton.org/develop/data-formats/tl-b-types#bintree)
Expand Down Expand Up @@ -62,9 +62,9 @@ where

#[inline]
fn parse_as_with(
parser: &mut CellParser<'de>,
parser: &mut OrdinaryCellParser<'de>,
args: Self::Args,
) -> Result<BinTree<T>, CellParserError<'de>> {
) -> Result<BinTree<T>, OrdinaryCellParserError<'de>> {
Ok(match parser.unpack()? {
// bt_leaf$0
false => BinTree::Leaf(parser.parse_as_with::<T, As>(args)?),
Expand All @@ -83,19 +83,19 @@ where

#[inline]
fn parse_as_with(
parser: &mut CellParser<'de>,
parser: &mut OrdinaryCellParser<'de>,
args: Self::Args,
) -> Result<Vec<T>, CellParserError<'de>> {
) -> Result<Vec<T>, OrdinaryCellParserError<'de>> {
let mut output = Vec::new();
let mut stack: Vec<CellParser<'de>> = Vec::new();
let mut stack: Vec<OrdinaryCellParser<'de>> = Vec::new();

#[inline]
fn parse<'de, T, As>(
parser: &mut CellParser<'de>,
stack: &mut Vec<CellParser<'de>>,
parser: &mut OrdinaryCellParser<'de>,
stack: &mut Vec<OrdinaryCellParser<'de>>,
output: &mut Vec<T>,
args: As::Args,
) -> Result<(), CellParserError<'de>>
) -> Result<(), OrdinaryCellParserError<'de>>
where
As: CellDeserializeAsWithArgs<'de, T>,
{
Expand Down
6 changes: 3 additions & 3 deletions crates/tlb-ton/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use num_bigint::BigUint;
use num_traits::One;
use tlb::{
bits::{de::BitReaderExt, r#as::VarInt, ser::BitWriterExt},
de::{CellDeserialize, CellParser, CellParserError},
de::{CellDeserialize, OrdinaryCellParser, OrdinaryCellParserError},
r#as::{Data, NoArgs},
ser::{CellBuilder, CellBuilderError, CellSerialize},
};
Expand Down Expand Up @@ -52,7 +52,7 @@ impl CellSerialize for CurrencyCollection {

impl<'de> CellDeserialize<'de> for CurrencyCollection {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self {
grams: parser.unpack_as::<_, Grams>()?,
other: parser.parse()?,
Expand All @@ -79,7 +79,7 @@ impl CellSerialize for ExtraCurrencyCollection {

impl<'de> CellDeserialize<'de> for ExtraCurrencyCollection {
#[inline]
fn parse(parser: &mut CellParser<'de>) -> Result<Self, CellParserError<'de>> {
fn parse(parser: &mut OrdinaryCellParser<'de>) -> Result<Self, OrdinaryCellParserError<'de>> {
Ok(Self(
parser.parse_as_with::<_, HashmapE<NoArgs<_, Data<VarInt<32>>>, NoArgs<_>>>((
32,
Expand Down
Loading

0 comments on commit d4a7164

Please sign in to comment.