Skip to content

Commit

Permalink
Update xdrgen (#317)
Browse files Browse the repository at this point in the history
* Update xdrgen

* upd

* upd to use i174-2

* upd

* upd

* upd
  • Loading branch information
leighmcculloch authored Nov 3, 2023
1 parent 16f4d7c commit 2597c26
Show file tree
Hide file tree
Showing 10 changed files with 5,661 additions and 4,989 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CARGO_HACK_ARGS=--feature-powerset --exclude-features default --group-features b

CARGO_DOC_ARGS?=--open

XDRGEN_VERSION=64612a24
XDRGEN_VERSION=cbff4b31
XDRGEN_TYPES_CUSTOM_STR_IMPL=PublicKey,AccountId,MuxedAccount,MuxedAccountMed25519,SignerKey,SignerKeyEd25519SignedPayload,NodeId,ScAddress

all: build test
Expand Down
5 changes: 1 addition & 4 deletions src/bin/stellar-xdr/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ macro_rules! run_x {
)
})?;
for f in &mut files {
let mut f = stellar_xdr::$m::DepthLimitedRead::new(
f,
stellar_xdr::$m::DEFAULT_XDR_RW_DEPTH_LIMIT,
);
let mut f = stellar_xdr::$m::Limited::new(f, stellar_xdr::$m::Limits::none());
match self.input {
InputFormat::Single => {
let t = stellar_xdr::$m::Type::read_xdr_to_end(r#type, &mut f)?;
Expand Down
11 changes: 7 additions & 4 deletions src/bin/stellar-xdr/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ impl From<stellar_xdr::curr::Error> for Error {
| stellar_xdr::curr::Error::Utf8Error(_)
| stellar_xdr::curr::Error::InvalidHex
| stellar_xdr::curr::Error::Io(_)
| stellar_xdr::curr::Error::DepthLimitExceeded => Error::WriteXdrCurr(e),
| stellar_xdr::curr::Error::DepthLimitExceeded
| stellar_xdr::curr::Error::LengthLimitExceeded => Error::WriteXdrCurr(e),
stellar_xdr::curr::Error::Json(_) => Error::ReadJsonCurr(e),
}
}
Expand All @@ -53,7 +54,8 @@ impl From<stellar_xdr::next::Error> for Error {
| stellar_xdr::next::Error::Utf8Error(_)
| stellar_xdr::next::Error::InvalidHex
| stellar_xdr::next::Error::Io(_)
| stellar_xdr::next::Error::DepthLimitExceeded => Error::WriteXdrNext(e),
| stellar_xdr::next::Error::DepthLimitExceeded
| stellar_xdr::next::Error::LengthLimitExceeded => Error::WriteXdrNext(e),
stellar_xdr::next::Error::Json(_) => Error::ReadJsonNext(e),
}
}
Expand Down Expand Up @@ -117,10 +119,11 @@ macro_rules! run_x {
match self.input {
InputFormat::Json => {
let t = stellar_xdr::$m::Type::read_json(r#type, f)?;
let l = stellar_xdr::$m::Limits::none();

match self.output {
OutputFormat::Single => stdout().write_all(&t.to_xdr()?)?,
OutputFormat::SingleBase64 => println!("{}", t.to_xdr_base64()?),
OutputFormat::Single => stdout().write_all(&t.to_xdr(l)?)?,
OutputFormat::SingleBase64 => println!("{}", t.to_xdr_base64(l)?),
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/bin/stellar-xdr/guess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ impl Default for OutputFormat {
macro_rules! run_x {
($f:ident, $m:ident) => {
fn $f(&self) -> Result<(), Error> {
let mut f = stellar_xdr::$m::DepthLimitedRead::new(
let mut f = stellar_xdr::$m::Limited::new(
ResetRead::new(self.file()?),
stellar_xdr::$m::DEFAULT_XDR_RW_DEPTH_LIMIT,
stellar_xdr::$m::Limits::none(),
);
'variants: for v in stellar_xdr::$m::TypeVariant::VARIANTS {
f.inner.reset();
Expand Down
Loading

0 comments on commit 2597c26

Please sign in to comment.