From 12862263159e1b22a3485ee9733e495cfe7af719 Mon Sep 17 00:00:00 2001 From: Joel Nordell Date: Fri, 19 Jul 2024 12:15:15 -0500 Subject: [PATCH 1/3] [0.40.0] Update SDK v0.39.0 -> v0.40.0 Including: * Update for 0.40.0 compatibility * Implement serialization for Transfer * Rename transparent_transfer -> transfer --- Cargo.toml | 16 ++-- .../down.sql | 3 + .../up.sql | 3 + orm/src/transactions.rs | 6 +- shared/src/block.rs | 31 +++---- shared/src/block_result.rs | 12 +-- shared/src/checksums.rs | 5 +- shared/src/lib.rs | 1 + shared/src/ser.rs | 89 +++++++++++++++++++ shared/src/transaction.rs | 13 +-- swagger.yml | 6 +- webserver/src/response/transaction.rs | 6 +- 12 files changed, 141 insertions(+), 50 deletions(-) create mode 100644 orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql create mode 100644 orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql create mode 100644 shared/src/ser.rs diff --git a/Cargo.toml b/Cargo.toml index a3e05211..b65e4b52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,14 +40,14 @@ axum-extra = { version = "0.9.3", features = ["query"] } chrono = { version = "0.4.30", features = ["serde"] } async-trait = "0.1.73" anyhow = "1.0.75" -namada_core = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.39.0", default-features = false, features = ["tendermint-rpc", "std", "async-send", "download-params", "rand"] } -namada_tx = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_governance = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_ibc = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_token = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_parameters = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } -namada_proof_of_stake = { git = "https://github.com/anoma/namada", tag = "v0.39.0" } +namada_core = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.40.0", default-features = false, features = ["tendermint-rpc", "std", "async-send", "download-params", "rand"] } +namada_tx = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_governance = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_ibc = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_token = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_parameters = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } +namada_proof_of_stake = { git = "https://github.com/anoma/namada", tag = "v0.40.0" } tendermint = "0.36.0" tendermint-config = "0.36.0" tendermint-rpc = { version = "0.36.0", features = ["http-client"] } diff --git a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql new file mode 100644 index 00000000..94904d6c --- /dev/null +++ b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql @@ -0,0 +1,3 @@ +-- This file should undo anything in `up.sql` +ALTER TYPE transaction_kind RENAME value 'transfer' TO 'transparent_transfer'; + diff --git a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql new file mode 100644 index 00000000..85e2cdac --- /dev/null +++ b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql @@ -0,0 +1,3 @@ +-- Your SQL goes here +ALTER TYPE transaction_kind RENAME value 'transparent_transfer' TO 'transfer'; + diff --git a/orm/src/transactions.rs b/orm/src/transactions.rs index 0a6402e9..6cb56751 100644 --- a/orm/src/transactions.rs +++ b/orm/src/transactions.rs @@ -10,7 +10,7 @@ use crate::schema::{inner_transactions, wrapper_transactions}; #[derive(Debug, Clone, Serialize, Deserialize, diesel_derive_enum::DbEnum)] #[ExistingTypePath = "crate::schema::sql_types::TransactionKind"] pub enum TransactionKindDb { - TransparentTransfer, + Transfer, ShieldedTransfer, ShieldingTransfer, UnshieldingTransfer, @@ -30,9 +30,7 @@ pub enum TransactionKindDb { impl From for TransactionKindDb { fn from(value: TransactionKind) -> Self { match value { - TransactionKind::TransparentTransfer(_) => { - TransactionKindDb::TransparentTransfer - } + TransactionKind::Transfer(_) => TransactionKindDb::Transfer, TransactionKind::ShieldedTransfer(_) => { TransactionKindDb::ShieldedTransfer } diff --git a/shared/src/block.rs b/shared/src/block.rs index 021313b7..aa06ff23 100644 --- a/shared/src/block.rs +++ b/shared/src/block.rs @@ -283,23 +283,20 @@ impl Block { let mut balance_changes = vec![]; for tx in inners_txs { let mut balance_change = match &tx.kind { - TransactionKind::TransparentTransfer(data) => { - let transfer_data = data.clone(); - let transfer_source = - Id::from(transfer_data.source); - let transfer_target = - Id::from(transfer_data.target); - let transfer_token = Id::from(transfer_data.token); - vec![ - BalanceChange::new( - transfer_source, - transfer_token.clone(), - ), - BalanceChange::new( - transfer_target, - transfer_token, - ), - ] + TransactionKind::Transfer(data) => { + vec![&data.sources, &data.targets] + .iter() + .flat_map(|transfer_changes| { + transfer_changes.0.iter().map( + |(account, _)| { + BalanceChange::new( + Id::from(account.owner.clone()), + Id::from(account.token.clone()), + ) + }, + ) + }) + .collect() } TransactionKind::Bond(data) => { let bond_data = data.clone(); diff --git a/shared/src/block_result.rs b/shared/src/block_result.rs index 3b53fdfd..4fbf40d4 100644 --- a/shared/src/block_result.rs +++ b/shared/src/block_result.rs @@ -60,7 +60,7 @@ pub struct BatchResults { impl From> for BatchResults { fn from(value: TxResult) -> Self { Self { - batch_results: value.batch_results.0.iter().fold( + batch_results: value.batch_results.iter().fold( BTreeMap::default(), |mut acc, (tx_hash, result)| { let tx_id = Id::from(*tx_hash); @@ -73,16 +73,18 @@ impl From> for BatchResults { acc }, ), - batch_errors: value.batch_results.0.into_iter().fold( + batch_errors: value.batch_results.iter().fold( BTreeMap::default(), |mut acc, (tx_hash, result)| { - let tx_id = Id::from(tx_hash); + let tx_id = Id::from(*tx_hash); let result = if let Ok(result) = result { result .vps_result .errors - .into_iter() - .map(|(address, error)| (Id::from(address), error)) + .iter() + .map(|(address, error)| { + (Id::from(address.clone()), error.clone()) + }) .collect() } else { BTreeMap::default() diff --git a/shared/src/checksums.rs b/shared/src/checksums.rs index fe6473c1..3ea79425 100644 --- a/shared/src/checksums.rs +++ b/shared/src/checksums.rs @@ -2,8 +2,7 @@ use bimap::BiMap; use namada_sdk::tx::{ TX_BOND_WASM, TX_CHANGE_COMMISSION_WASM, TX_CHANGE_METADATA_WASM, TX_CLAIM_REWARDS_WASM, TX_INIT_PROPOSAL, TX_REDELEGATE_WASM, TX_REVEAL_PK, - TX_TRANSPARENT_TRANSFER_WASM, TX_UNBOND_WASM, TX_VOTE_PROPOSAL, - TX_WITHDRAW_WASM, + TX_TRANSFER_WASM, TX_UNBOND_WASM, TX_VOTE_PROPOSAL, TX_WITHDRAW_WASM, }; use serde::{Deserialize, Serialize}; @@ -31,7 +30,7 @@ impl Checksums { pub fn code_paths() -> Vec { vec![ TX_REVEAL_PK.to_string(), - TX_TRANSPARENT_TRANSFER_WASM.to_string(), + TX_TRANSFER_WASM.to_string(), TX_BOND_WASM.to_string(), TX_REDELEGATE_WASM.to_string(), TX_UNBOND_WASM.to_string(), diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 7b942e58..51216895 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -14,6 +14,7 @@ pub mod parameters; pub mod proposal; pub mod public_key; pub mod rewards; +pub mod ser; pub mod transaction; pub mod unbond; pub mod utils; diff --git a/shared/src/ser.rs b/shared/src/ser.rs new file mode 100644 index 00000000..119adb40 --- /dev/null +++ b/shared/src/ser.rs @@ -0,0 +1,89 @@ +use serde::{Deserialize, Serialize}; + +use std::collections::{BTreeMap, HashMap}; +use std::str::FromStr; + +use namada_core::address::Address; +use namada_core::masp::TxId; +use namada_sdk::token::{ + Account as NamadaAccount, DenominatedAmount as NamadaDenominatedAmount, + Transfer as NamadaTransfer, +}; + +#[derive(Debug, Clone)] +pub struct AccountsMap(pub BTreeMap); + +impl Serialize for AccountsMap { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.collect_seq(self.0.iter().map(|(k, v)| { + HashMap::from([ + ("owner", k.owner.encode()), + ("token", k.token.encode()), + ("amount", v.to_string_precise()), + ]) + })) + } +} + +impl<'de> Deserialize<'de> for AccountsMap { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + > as Deserialize>::deserialize( + deserializer, + ) + .map(|v| { + AccountsMap( + v.into_iter() + .map(|val| { + let owner = + val.get("owner").expect("Cannot find owner"); + let token = + val.get("token").expect("Cannot find token"); + let amount = + val.get("amount").expect("Cannot find amount"); + + ( + NamadaAccount { + owner: Address::decode(owner) + .expect("Cannot parse Address for owner"), + token: Address::decode(token) + .expect("Cannot parse Address for token"), + }, + NamadaDenominatedAmount::from_str(&amount) + .expect("Cannot parse DenominatedAmount"), + ) + }) + .collect(), + ) + }) + } +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Transfer { + /// Sources of this transfer + pub sources: AccountsMap, + /// Targets of this transfer + pub targets: AccountsMap, + /// Hash of tx section that contains the MASP transaction + pub shielded_section_hash: Option, +} + +impl From for Transfer { + fn from(transfer: NamadaTransfer) -> Self { + let sources = AccountsMap(transfer.sources); + let targets = AccountsMap(transfer.targets); + let shielded_section_hash = transfer.shielded_section_hash; + + Transfer { + sources, + targets, + shielded_section_hash, + } + } +} diff --git a/shared/src/transaction.rs b/shared/src/transaction.rs index 42c44514..54b8a159 100644 --- a/shared/src/transaction.rs +++ b/shared/src/transaction.rs @@ -5,7 +5,7 @@ use namada_governance::{InitProposalData, VoteProposalData}; use namada_sdk::borsh::BorshDeserialize; use namada_sdk::key::common::PublicKey; use namada_sdk::masp::ShieldedTransfer; -use namada_sdk::token::TransparentTransfer; +use namada_sdk::token::Transfer as NamadaTransfer; use namada_sdk::uint::Uint; use namada_tx::data::pos::{ Bond, ClaimRewards, CommissionChange, MetaDataChange, Redelegation, Unbond, @@ -19,6 +19,7 @@ use crate::block::BlockHeight; use crate::block_result::{BlockResult, TxEventStatusCode}; use crate::checksums::Checksums; use crate::id::Id; +use crate::ser::Transfer; // We wrap public key in a struct so we serialize data as object instead of // string @@ -30,7 +31,7 @@ pub struct RevealPkData { #[derive(Serialize, Debug, Clone)] #[serde(untagged)] pub enum TransactionKind { - TransparentTransfer(TransparentTransfer), + Transfer(Transfer), // TODO: remove once ShieldedTransfer can be serialized #[serde(skip)] ShieldedTransfer(ShieldedTransfer), @@ -54,10 +55,10 @@ impl TransactionKind { pub fn from(tx_kind_name: &str, data: &[u8]) -> Self { match tx_kind_name { - "tx_transparent_transfer" => TransactionKind::TransparentTransfer( - TransparentTransfer::try_from_slice(data) - .expect("Cannot deserialize TransparentTransfer"), - ), + "tx_transfer" => TransactionKind::Transfer(Transfer::from( + NamadaTransfer::try_from_slice(data) + .expect("Cannot deserialize Transfer"), + )), "tx_bond" => TransactionKind::Bond( Bond::try_from_slice(data).expect("Cannot deserialize Bond"), ), diff --git a/swagger.yml b/swagger.yml index d0e34ab0..7bf4ff9f 100644 --- a/swagger.yml +++ b/swagger.yml @@ -750,7 +750,7 @@ components: type: number txKind: type: string - enum: [transparentTransfer, shieldedTransfer, shieldingTransfer, unshieldingTransfer, bond, redelegation, unbond, withdraw, claimRewards, voteProposal, initProposal, changeMetadata, changeCommission, revealPk, unknown] + enum: [transfer, shieldedTransfer, shieldingTransfer, unshieldingTransfer, bond, redelegation, unbond, withdraw, claimRewards, voteProposal, initProposal, changeMetadata, changeCommission, revealPk, unknown] GasPriceTable: type: array items: @@ -819,7 +819,7 @@ components: type: string kind: type: string - enum: ["transparentTransfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] + enum: ["transfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] exitCode: type: string enum: [applied, rejected] @@ -842,7 +842,7 @@ components: type: string kind: type: string - enum: ["transparentTransfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] + enum: ["transfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] exitCode: type: string enum: [applied, rejected] diff --git a/webserver/src/response/transaction.rs b/webserver/src/response/transaction.rs index 16c73019..959331e6 100644 --- a/webserver/src/response/transaction.rs +++ b/webserver/src/response/transaction.rs @@ -13,7 +13,7 @@ pub enum TransactionResult { #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub enum TransactionKind { - TransparentTransfer, + Transfer, ShieldedTransfer, ShieldingTransfer, UnshieldingTransfer, @@ -88,9 +88,7 @@ impl From for TransactionResult { impl From for TransactionKind { fn from(value: TransactionKindDb) -> Self { match value { - TransactionKindDb::TransparentTransfer => { - TransactionKind::TransparentTransfer - } + TransactionKindDb::Transfer => TransactionKind::Transfer, TransactionKindDb::ShieldedTransfer => { TransactionKind::ShieldedTransfer } From 13be805c6e5842275ff575a08387c36d942240ce Mon Sep 17 00:00:00 2001 From: Joel Nordell Date: Mon, 22 Jul 2024 10:24:43 -0500 Subject: [PATCH 2/3] [0.40.0] Revert TransparentTransfer rename; name it back to TransparentTransfer --- .../down.sql | 3 --- .../up.sql | 3 --- orm/src/transactions.rs | 6 ++++-- shared/src/block.rs | 2 +- shared/src/ser.rs | 6 +++--- shared/src/transaction.rs | 16 +++++++++------- swagger.yml | 6 +++--- webserver/src/response/transaction.rs | 6 ++++-- 8 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql delete mode 100644 orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql diff --git a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql deleted file mode 100644 index 94904d6c..00000000 --- a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- This file should undo anything in `up.sql` -ALTER TYPE transaction_kind RENAME value 'transfer' TO 'transparent_transfer'; - diff --git a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql b/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql deleted file mode 100644 index 85e2cdac..00000000 --- a/orm/migrations/2024-07-19-193443_transparent_transfer_to_transfer/up.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Your SQL goes here -ALTER TYPE transaction_kind RENAME value 'transparent_transfer' TO 'transfer'; - diff --git a/orm/src/transactions.rs b/orm/src/transactions.rs index 6cb56751..0a6402e9 100644 --- a/orm/src/transactions.rs +++ b/orm/src/transactions.rs @@ -10,7 +10,7 @@ use crate::schema::{inner_transactions, wrapper_transactions}; #[derive(Debug, Clone, Serialize, Deserialize, diesel_derive_enum::DbEnum)] #[ExistingTypePath = "crate::schema::sql_types::TransactionKind"] pub enum TransactionKindDb { - Transfer, + TransparentTransfer, ShieldedTransfer, ShieldingTransfer, UnshieldingTransfer, @@ -30,7 +30,9 @@ pub enum TransactionKindDb { impl From for TransactionKindDb { fn from(value: TransactionKind) -> Self { match value { - TransactionKind::Transfer(_) => TransactionKindDb::Transfer, + TransactionKind::TransparentTransfer(_) => { + TransactionKindDb::TransparentTransfer + } TransactionKind::ShieldedTransfer(_) => { TransactionKindDb::ShieldedTransfer } diff --git a/shared/src/block.rs b/shared/src/block.rs index aa06ff23..8c428f3b 100644 --- a/shared/src/block.rs +++ b/shared/src/block.rs @@ -283,7 +283,7 @@ impl Block { let mut balance_changes = vec![]; for tx in inners_txs { let mut balance_change = match &tx.kind { - TransactionKind::Transfer(data) => { + TransactionKind::TransparentTransfer(data) => { vec![&data.sources, &data.targets] .iter() .flat_map(|transfer_changes| { diff --git a/shared/src/ser.rs b/shared/src/ser.rs index 119adb40..6fa2e5cc 100644 --- a/shared/src/ser.rs +++ b/shared/src/ser.rs @@ -65,7 +65,7 @@ impl<'de> Deserialize<'de> for AccountsMap { } #[derive(Deserialize, Serialize, Debug, Clone)] -pub struct Transfer { +pub struct TransparentTransfer { /// Sources of this transfer pub sources: AccountsMap, /// Targets of this transfer @@ -74,13 +74,13 @@ pub struct Transfer { pub shielded_section_hash: Option, } -impl From for Transfer { +impl From for TransparentTransfer { fn from(transfer: NamadaTransfer) -> Self { let sources = AccountsMap(transfer.sources); let targets = AccountsMap(transfer.targets); let shielded_section_hash = transfer.shielded_section_hash; - Transfer { + TransparentTransfer { sources, targets, shielded_section_hash, diff --git a/shared/src/transaction.rs b/shared/src/transaction.rs index 54b8a159..da09c50e 100644 --- a/shared/src/transaction.rs +++ b/shared/src/transaction.rs @@ -5,7 +5,7 @@ use namada_governance::{InitProposalData, VoteProposalData}; use namada_sdk::borsh::BorshDeserialize; use namada_sdk::key::common::PublicKey; use namada_sdk::masp::ShieldedTransfer; -use namada_sdk::token::Transfer as NamadaTransfer; +use namada_sdk::token::Transfer; use namada_sdk::uint::Uint; use namada_tx::data::pos::{ Bond, ClaimRewards, CommissionChange, MetaDataChange, Redelegation, Unbond, @@ -19,7 +19,7 @@ use crate::block::BlockHeight; use crate::block_result::{BlockResult, TxEventStatusCode}; use crate::checksums::Checksums; use crate::id::Id; -use crate::ser::Transfer; +use crate::ser::TransparentTransfer; // We wrap public key in a struct so we serialize data as object instead of // string @@ -31,7 +31,7 @@ pub struct RevealPkData { #[derive(Serialize, Debug, Clone)] #[serde(untagged)] pub enum TransactionKind { - Transfer(Transfer), + TransparentTransfer(TransparentTransfer), // TODO: remove once ShieldedTransfer can be serialized #[serde(skip)] ShieldedTransfer(ShieldedTransfer), @@ -55,10 +55,12 @@ impl TransactionKind { pub fn from(tx_kind_name: &str, data: &[u8]) -> Self { match tx_kind_name { - "tx_transfer" => TransactionKind::Transfer(Transfer::from( - NamadaTransfer::try_from_slice(data) - .expect("Cannot deserialize Transfer"), - )), + "tx_transfer" => { + TransactionKind::TransparentTransfer(TransparentTransfer::from( + Transfer::try_from_slice(data) + .expect("Cannot deserialize Transfer"), + )) + } "tx_bond" => TransactionKind::Bond( Bond::try_from_slice(data).expect("Cannot deserialize Bond"), ), diff --git a/swagger.yml b/swagger.yml index 7bf4ff9f..d0e34ab0 100644 --- a/swagger.yml +++ b/swagger.yml @@ -750,7 +750,7 @@ components: type: number txKind: type: string - enum: [transfer, shieldedTransfer, shieldingTransfer, unshieldingTransfer, bond, redelegation, unbond, withdraw, claimRewards, voteProposal, initProposal, changeMetadata, changeCommission, revealPk, unknown] + enum: [transparentTransfer, shieldedTransfer, shieldingTransfer, unshieldingTransfer, bond, redelegation, unbond, withdraw, claimRewards, voteProposal, initProposal, changeMetadata, changeCommission, revealPk, unknown] GasPriceTable: type: array items: @@ -819,7 +819,7 @@ components: type: string kind: type: string - enum: ["transfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] + enum: ["transparentTransfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] exitCode: type: string enum: [applied, rejected] @@ -842,7 +842,7 @@ components: type: string kind: type: string - enum: ["transfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] + enum: ["transparentTransfer", "shieldedTransfer", "shieldingTransfer", "unshieldingTransfer", "bond", "redelegation", "unbond", "withdraw", "claimRewards", "voteProposal", "initProposal", "changeMetadata", "changeCommission", "revealPk", "unknown"] exitCode: type: string enum: [applied, rejected] diff --git a/webserver/src/response/transaction.rs b/webserver/src/response/transaction.rs index 959331e6..16c73019 100644 --- a/webserver/src/response/transaction.rs +++ b/webserver/src/response/transaction.rs @@ -13,7 +13,7 @@ pub enum TransactionResult { #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub enum TransactionKind { - Transfer, + TransparentTransfer, ShieldedTransfer, ShieldingTransfer, UnshieldingTransfer, @@ -88,7 +88,9 @@ impl From for TransactionResult { impl From for TransactionKind { fn from(value: TransactionKindDb) -> Self { match value { - TransactionKindDb::Transfer => TransactionKind::Transfer, + TransactionKindDb::TransparentTransfer => { + TransactionKind::TransparentTransfer + } TransactionKindDb::ShieldedTransfer => { TransactionKind::ShieldedTransfer } From 45240a3a751f2ad0e38c78d68457c772114d85c3 Mon Sep 17 00:00:00 2001 From: Joel Nordell Date: Tue, 23 Jul 2024 10:23:49 -0500 Subject: [PATCH 3/3] fix clippy --- shared/src/block.rs | 16 +++++++--------- shared/src/ser.rs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/shared/src/block.rs b/shared/src/block.rs index 8c428f3b..6db3595d 100644 --- a/shared/src/block.rs +++ b/shared/src/block.rs @@ -284,17 +284,15 @@ impl Block { for tx in inners_txs { let mut balance_change = match &tx.kind { TransactionKind::TransparentTransfer(data) => { - vec![&data.sources, &data.targets] + [&data.sources, &data.targets] .iter() .flat_map(|transfer_changes| { - transfer_changes.0.iter().map( - |(account, _)| { - BalanceChange::new( - Id::from(account.owner.clone()), - Id::from(account.token.clone()), - ) - }, - ) + transfer_changes.0.keys().map(|account| { + BalanceChange::new( + Id::from(account.owner.clone()), + Id::from(account.token.clone()), + ) + }) }) .collect() } diff --git a/shared/src/ser.rs b/shared/src/ser.rs index 6fa2e5cc..7df6d77b 100644 --- a/shared/src/ser.rs +++ b/shared/src/ser.rs @@ -54,7 +54,7 @@ impl<'de> Deserialize<'de> for AccountsMap { token: Address::decode(token) .expect("Cannot parse Address for token"), }, - NamadaDenominatedAmount::from_str(&amount) + NamadaDenominatedAmount::from_str(amount) .expect("Cannot parse DenominatedAmount"), ) })