diff --git a/packages/namada/Cargo.lock b/packages/namada/Cargo.lock index 21ec46576d..5e7de3c007 100644 --- a/packages/namada/Cargo.lock +++ b/packages/namada/Cargo.lock @@ -84,6 +84,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + [[package]] name = "anyhow" version = "1.0.86" @@ -725,6 +731,31 @@ dependencies = [ "version_check", ] +[[package]] +name = "clap" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + [[package]] name = "clru" version = "0.5.0" @@ -3001,7 +3032,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" +source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" dependencies = [ "borsh 1.5.1", "chacha20", @@ -3045,7 +3076,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" +source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" dependencies = [ "aes", "bip0039 0.12.0", @@ -3062,7 +3093,7 @@ dependencies = [ "incrementalmerkletree", "jubjub", "lazy_static", - "masp_note_encryption 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_note_encryption 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "memuse", "nonempty", "num-traits 0.2.19 (git+https://github.com/heliaxdev/num-traits?rev=3f3657caa34b8e116fdf3f8a3519c4ac29f012fe)", @@ -3096,7 +3127,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82#4ede1c42d76d6348af8224bc8bfac4404321fe82" +source = "git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7#8d83b172698098fba393006016072bc201ed9ab7" dependencies = [ "bellman", "blake2b_simd", @@ -3107,7 +3138,7 @@ dependencies = [ "itertools 0.11.0", "jubjub", "lazy_static", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "rand_core 0.6.4", "redjubjub", "tracing", @@ -3175,18 +3206,19 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "namada" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "async-trait", "borsh 1.5.1", "borsh-ext", "clru", + "either", "ethers", "eyre", "itertools 0.12.1", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", - "masp_proofs 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", + "masp_proofs 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_account", "namada_core", "namada_ethereum_bridge", @@ -3222,8 +3254,8 @@ dependencies = [ [[package]] name = "namada_account" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "namada_core", @@ -3234,8 +3266,8 @@ dependencies = [ [[package]] name = "namada_controller" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "namada_core", "smooth-operator", @@ -3244,8 +3276,8 @@ dependencies = [ [[package]] name = "namada_core" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "bech32 0.8.1", "borsh 1.5.1", @@ -3262,7 +3294,7 @@ dependencies = [ "index-set", "indexmap 2.2.4", "k256", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_macros", "num-integer", "num-rational", @@ -3273,6 +3305,7 @@ dependencies = [ "prost-types", "rand 0.8.5", "rand_core 0.6.4", + "ripemd", "serde", "serde_json", "sha2 0.9.9", @@ -3289,8 +3322,8 @@ dependencies = [ [[package]] name = "namada_ethereum_bridge" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "ethers", @@ -3314,8 +3347,8 @@ dependencies = [ [[package]] name = "namada_events" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "namada_core", @@ -3328,8 +3361,8 @@ dependencies = [ [[package]] name = "namada_gas" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "namada_core", @@ -3341,8 +3374,8 @@ dependencies = [ [[package]] name = "namada_governance" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "itertools 0.12.1", @@ -3362,15 +3395,16 @@ dependencies = [ [[package]] name = "namada_ibc" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", + "data-encoding", "ibc", "ibc-derive", "ics23", "konst", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_core", "namada_events", "namada_governance", @@ -3384,14 +3418,15 @@ dependencies = [ "serde", "serde_json", "sha2 0.9.9", + "smooth-operator", "thiserror", "tracing", ] [[package]] name = "namada_macros" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "data-encoding", "proc-macro2", @@ -3402,8 +3437,8 @@ dependencies = [ [[package]] name = "namada_merkle_tree" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "eyre", @@ -3417,19 +3452,20 @@ dependencies = [ [[package]] name = "namada_parameters" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "namada_core", "namada_macros", "namada_storage", + "smooth-operator", "thiserror", ] [[package]] name = "namada_proof_of_stake" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "konst", @@ -3451,33 +3487,35 @@ dependencies = [ [[package]] name = "namada_replay_protection" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "namada_core", ] [[package]] name = "namada_sdk" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "async-trait", "bimap", "borsh 1.5.1", "borsh-ext", "circular-queue", + "clap", "data-encoding", "derivation-path", "duration-str", + "either", "ethbridge-bridge-contract", "ethers", "eyre", "futures", "itertools 0.12.1", "lazy_static", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", - "masp_proofs 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", + "masp_proofs 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_account", "namada_core", "namada_ethereum_bridge", @@ -3503,7 +3541,6 @@ dependencies = [ "rand 0.8.5", "rand_core 0.6.4", "regex", - "ripemd", "serde", "serde_json", "sha2 0.9.9", @@ -3522,16 +3559,20 @@ dependencies = [ [[package]] name = "namada_shielded_token" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "lazy_static", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", + "masp_proofs 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_controller", "namada_core", + "namada_gas", "namada_parameters", "namada_storage", "namada_trans_token", + "rand_core 0.6.4", "serde", "smooth-operator", "tracing", @@ -3539,8 +3580,8 @@ dependencies = [ [[package]] name = "namada_state" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "itertools 0.12.1", @@ -3561,8 +3602,8 @@ dependencies = [ [[package]] name = "namada_storage" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "itertools 0.12.1", @@ -3579,8 +3620,8 @@ dependencies = [ [[package]] name = "namada_token" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "namada_core", @@ -3594,8 +3635,8 @@ dependencies = [ [[package]] name = "namada_trans_token" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "konst", "namada_core", @@ -3605,15 +3646,16 @@ dependencies = [ [[package]] name = "namada_tx" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "ark-bls12-381", "bitflags 2.5.0", "borsh 1.5.1", "data-encoding", + "either", "konst", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_core", "namada_events", "namada_gas", @@ -3622,6 +3664,7 @@ dependencies = [ "num-traits 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "prost", "prost-types", + "rand_core 0.6.4", "serde", "serde_json", "sha2 0.9.9", @@ -3631,8 +3674,8 @@ dependencies = [ [[package]] name = "namada_tx_env" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "namada_core", "namada_events", @@ -3641,8 +3684,8 @@ dependencies = [ [[package]] name = "namada_vote_ext" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "borsh 1.5.1", "namada_core", @@ -3653,11 +3696,11 @@ dependencies = [ [[package]] name = "namada_vp_env" -version = "0.39.0" -source = "git+https://github.com/anoma/namada#5cc23b4f43b12ecfc70eeca8d04cbe15f4b11a3a" +version = "0.40.0" +source = "git+https://github.com/anoma/namada#22a4839d84b8e7ff6a909b94d50165d98434ee15" dependencies = [ "derivative", - "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=4ede1c42d76d6348af8224bc8bfac4404321fe82)", + "masp_primitives 1.0.0 (git+https://github.com/anoma/masp?rev=8d83b172698098fba393006016072bc201ed9ab7)", "namada_core", "namada_events", "namada_ibc", diff --git a/packages/namada/Cargo.toml b/packages/namada/Cargo.toml index 59620f06d0..694c5d51a4 100644 --- a/packages/namada/Cargo.toml +++ b/packages/namada/Cargo.toml @@ -12,7 +12,7 @@ hex = "0.4.3" js-sys = "0.3.64" masp_primitives = { git = "https://github.com/anoma/masp", tag = "v1.1.0" } masp_proofs = { git = "https://github.com/anoma/masp", tag = "v1.1.0", default-features = false, features = ["local-prover"] } -namada = { git = "https://github.com/anoma/namada", version = "0.39.0", default-features = false, features = ["namada-sdk"] } +namada = { git = "https://github.com/anoma/namada", version = "0.40.0", default-features = false, features = ["namada-sdk"] } tendermint = "0.34.0" #tendermint-config = "0.34.0" #tendermint-proto = "0.34.0" diff --git a/packages/namada/src/decode.rs b/packages/namada/src/decode.rs index b976215044..e02f7cd4b6 100644 --- a/packages/namada/src/decode.rs +++ b/packages/namada/src/decode.rs @@ -18,16 +18,30 @@ impl Decode { Ok(to_object! { "epochDuration" = get_epoch_duration_storage_key().to_string(), - "maxBlockDuration" = - get_max_expected_time_per_block_key().to_string(), - "vpAllowlist" = - get_tx_allowlist_storage_key().to_string(), - "maxGasForBlock" = - get_max_block_gas_key().to_string(), - "feeUnshieldingGasLimit" = - get_fee_unshielding_gas_limit_key().to_string(), + "epochsPerYear" = + get_epochs_per_year_key().to_string(), "gasCostTable" = get_gas_cost_key().to_string(), + "gasScale" = + get_gas_scale_key().to_string(), + "implicitVp" = + get_implicit_vp_key().to_string(), + "maspEpochMultipler" = + get_masp_epoch_multiplier_key().to_string(), + "maspFeePaymentGasLimi" = + get_masp_fee_payment_gas_limit_key().to_string(), + "maxBlockGas" = + get_max_block_gas_key().to_string(), + "maxProposalBytes" = + get_max_proposal_bytes_key().to_string(), + "maxTxBytes" = + get_max_tx_bytes_key().to_string(), + "nativeTokenTransferable" = + get_native_token_transferable_key().to_string(), + "txAllowlist" = + get_tx_allowlist_storage_key().to_string(), + "vpAllowlist" = + get_vp_allowlist_storage_key().to_string(), }) } diff --git a/packages/namada/src/lib.rs b/packages/namada/src/lib.rs index b64d4a3bf0..407b887902 100644 --- a/packages/namada/src/lib.rs +++ b/packages/namada/src/lib.rs @@ -63,11 +63,18 @@ pub(crate) use namada::{ EpochDuration, storage::{ get_epoch_duration_storage_key, - get_max_expected_time_per_block_key, - get_max_block_gas_key, - get_fee_unshielding_gas_limit_key, + get_epochs_per_year_key, get_gas_cost_key, + get_gas_scale_key, + get_implicit_vp_key, + get_masp_epoch_multiplier_key, + get_masp_fee_payment_gas_limit_key, + get_max_block_gas_key, + get_max_proposal_bytes_key, + get_max_tx_bytes_key, + get_native_token_transferable_key, get_tx_allowlist_storage_key, + get_vp_allowlist_storage_key, }, }, storage::KeySeg, @@ -84,13 +91,11 @@ pub(crate) use namada::{ time::Time }, token::{ + Account, Amount, MaspDigitPos, DenominatedAmount, - ShieldedTransfer, - ShieldingTransfer, - TransparentTransfer, - UnshieldingTransfer, + Transfer, }, tx::{ Tx, Header as TxHeader, diff --git a/packages/namada/src/to_js.rs b/packages/namada/src/to_js.rs index 569bb3bd7c..a6ab015eba 100644 --- a/packages/namada/src/to_js.rs +++ b/packages/namada/src/to_js.rs @@ -140,7 +140,7 @@ impl ToJS for Vec { } } -impl ToJS for BTreeSet
{ +impl ToJS for BTreeSet { fn to_js (&self) -> Result { let set = Set::new(&JsValue::UNDEFINED); for value in self.iter() { @@ -150,11 +150,11 @@ impl ToJS for BTreeSet
{ } } -impl ToJS for BTreeMap { +impl ToJS for BTreeMap { fn to_js (&self) -> Result { let object = Object::new(); for (key, value) in self.iter() { - Reflect::set(&object, &key.into(), &value.into())?; + Reflect::set(&object, &key.to_js()?, &value.to_js()?)?; } Ok(object.into()) } @@ -343,6 +343,15 @@ impl ToJS for ChainId { } } +impl ToJS for Account { + fn to_js (&self) -> Result { + Ok(to_object! { + "owner" = self.owner, + "token" = self.token, + }.into()) + } +} + impl ToJS for AccountId { fn to_js (&self) -> Result { hex::encode_upper(self.as_bytes()).to_js() diff --git a/packages/namada/src/tx/content.rs b/packages/namada/src/tx/content.rs index 2ac2cd5917..cebd5731c8 100644 --- a/packages/namada/src/tx/content.rs +++ b/packages/namada/src/tx/content.rs @@ -41,12 +41,9 @@ pub fn tx_content (tx: &Tx, result: Object) -> Result { "tx_redelegate.wasm" => redelegate(binary), "tx_resign_steward.wasm" => resign_steward(binary), "tx_reveal_pk.wasm" => reveal_pk(binary), - "tx_shield.wasm" => shielding_transfer(binary), - "tx_transfer.wasm" => shielded_transfer(binary), - "tx_transparent_transfer.wasm" => transparent_transfer(binary), + "tx_transfer.wasm" => transfer(binary), "tx_unbond.wasm" => unbond(binary), "tx_unjail_validator.wasm" => unjail_validator(binary), - "tx_unshield.wasm" => unshielding_transfer(binary), "tx_update_account.wasm" => update_account(binary), "tx_update_steward_commission.wasm" => update_steward_commission(binary), "tx_vote_proposal.wasm" => vote_proposal(binary), @@ -247,58 +244,15 @@ fn reveal_pk (binary: &[u8]) -> Result { }) } -fn shielded_transfer (binary: &[u8]) -> Result { - let inner = ShieldedTransfer::try_from_slice(&binary[..]) +fn transfer (binary: &[u8]) -> Result { + let inner = Transfer::try_from_slice(&binary[..]) .map_err(|e|Error::new(&format!("{e}")))?; - object(&[ - ("sectionHash".into(), - hex::encode_upper(inner.section_hash).into()), - ]) -} - -fn shielding_transfer (binary: &[u8]) -> Result { - let inner = ShieldingTransfer::try_from_slice(&binary[..]) - .map_err(|e|Error::new(&format!("{e}")))?; - object(&[ - ("source".into(), - inner.source.encode().into()), - ("token".into(), - inner.token.encode().into()), - ("amount".into(), - format!("{}", inner.amount).into()), - ("shieldedSectionHash".into(), - hex::encode_upper(inner.shielded_section_hash).into()), - ]) -} - -fn transparent_transfer (binary: &[u8]) -> Result { - let inner = TransparentTransfer::try_from_slice(&binary[..]) - .map_err(|e|Error::new(&format!("{e}")))?; - object(&[ - ("source".into(), - inner.source.encode().into()),// /* pub source: Address, - ("target".into(), - inner.target.encode().into()),//pub target: Address, - ("token".into(), - inner.token.encode().into()),//pub token: Address, - ("amount".into(), - format!("{}", inner.amount).into()),//pub amount: DenominatedAmount, - ]) -} - -fn unshielding_transfer (binary: &[u8]) -> Result { - let inner = UnshieldingTransfer::try_from_slice(&binary[..]) - .map_err(|e|Error::new(&format!("{e}")))?; - object(&[ - ("target".into(), - inner.target.encode().into()),//pub target: Address, - ("token".into(), - inner.token.encode().into()),//pub token: Address, - ("amount".into(), - format!("{}", inner.amount).into()),//pub amount: DenominatedAmount, - ("shieldedSectionHash".into(), - hex::encode_upper(inner.shielded_section_hash).into()), - ]) + Ok(to_object! { + "sources" = inner.sources, + "targets" = inner.targets, + "shieldedSectionHash" = inner.shielded_section_hash + .map(|hash|format!("{:?}", hash)), + }) } fn unbond (binary: &[u8]) -> Result { diff --git a/packages/namada/src/tx/section.rs b/packages/namada/src/tx/section.rs index bae12f4f40..bb8e8ccdfe 100644 --- a/packages/namada/src/tx/section.rs +++ b/packages/namada/src/tx/section.rs @@ -205,7 +205,7 @@ fn section_masp_builder (masp_builder: &MaspBuilder) -> Result { ("type".into(), "MaspBuilder".into()), ("target".into(), - hex::encode_upper(masp_builder.target.0).into()), + format!("{:?}", masp_builder.target).into()), ("asset_types".into(), { let types = Set::new(&JsValue::UNDEFINED); for asset_type in masp_builder.asset_types.iter() {