Skip to content

Commit d6c122e

Browse files
committed
fix: replace message with error_msg for kotlin
1 parent 2ecf988 commit d6c122e

File tree

16 files changed

+2832
-3046
lines changed

16 files changed

+2832
-3046
lines changed

crates/algokit_transact/src/address.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ impl FromStr for Address {
6565
fn from_str(s: &str) -> Result<Self, Self::Err> {
6666
if s.len() != ALGORAND_ADDRESS_LENGTH {
6767
return Err(AlgoKitTransactError::InvalidAddress {
68-
message: "Algorand address must be exactly 58 characters".into(),
68+
err_msg:"Algorand address must be exactly 58 characters".into(),
6969
});
7070
}
7171
let decoded_address = base32::decode(base32::Alphabet::Rfc4648 { padding: false }, s)
7272
.ok_or_else(|| AlgoKitTransactError::InvalidAddress {
73-
message: "Invalid base32 encoding for Algorand address".into(),
73+
err_msg:"Invalid base32 encoding for Algorand address".into(),
7474
})?;
7575

7676
// Although this is called public key (and it actually is when the account is a `KeyPairAccount`),
@@ -80,18 +80,18 @@ impl FromStr for Address {
8080
[..ALGORAND_PUBLIC_KEY_BYTE_LENGTH]
8181
.try_into()
8282
.map_err(|_| AlgoKitTransactError::InvalidAddress {
83-
message: "Could not decode address into 32-byte public key".to_string(),
83+
err_msg:"Could not decode address into 32-byte public key".to_string(),
8484
})?;
8585
let checksum: [u8; ALGORAND_CHECKSUM_BYTE_LENGTH] = decoded_address
8686
[ALGORAND_PUBLIC_KEY_BYTE_LENGTH..]
8787
.try_into()
8888
.map_err(|_| AlgoKitTransactError::InvalidAddress {
89-
message: "Could not get 4-byte checksum from decoded address".to_string(),
89+
err_msg:"Could not get 4-byte checksum from decoded address".to_string(),
9090
})?;
9191

9292
if pub_key_to_checksum(&pub_key) != checksum {
9393
return Err(AlgoKitTransactError::InvalidAddress {
94-
message: "Checksum is invalid".to_string(),
94+
err_msg:"Checksum is invalid".to_string(),
9595
});
9696
}
9797
Ok(Address(pub_key))

crates/algokit_transact/src/error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ pub enum AlgoKitTransactError {
2424
#[snafu(display("Error ocurred during msgpack decoding: {source}"))]
2525
MsgpackDecodingError { source: rmpv::decode::Error },
2626

27-
#[snafu(display("Unknown transaction type: {message}"))]
28-
UnknownTransactionType { message: String },
27+
#[snafu(display("Unknown transaction type: {err_msg}"))]
28+
UnknownTransactionType { err_msg: String },
2929

30-
#[snafu(display("{message}"))]
31-
InputError { message: String },
30+
#[snafu(display("{err_msg}"))]
31+
InputError { err_msg: String },
3232

33-
#[snafu(display("{message}"))]
34-
InvalidAddress { message: String },
33+
#[snafu(display("{err_msg}"))]
34+
InvalidAddress { err_msg: String },
3535

36-
#[snafu(display("Invalid multisig signature: {message}"))]
37-
InvalidMultisigSignature { message: String },
36+
#[snafu(display("Invalid multisig signature: {err_msg}"))]
37+
InvalidMultisigSignature { err_msg: String },
3838
}
3939

4040
impl From<rmp_serde::encode::Error> for AlgoKitTransactError {

crates/algokit_transact/src/multisig.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ impl MultisigSignature {
7878
) -> Result<Self, AlgoKitTransactError> {
7979
if version == 0 {
8080
return Err(AlgoKitTransactError::InvalidMultisigSignature {
81-
message: "Version cannot be zero".to_string(),
81+
err_msg:"Version cannot be zero".to_string(),
8282
});
8383
}
8484
if subsignatures.is_empty() {
8585
return Err(AlgoKitTransactError::InvalidMultisigSignature {
86-
message: "Subsignatures cannot be empty".to_string(),
86+
err_msg:"Subsignatures cannot be empty".to_string(),
8787
});
8888
}
8989
if threshold == 0 || threshold as usize > subsignatures.len() {
90-
return Err(AlgoKitTransactError::InvalidMultisigSignature { message: "Threshold must be greater than zero and less than or equal to the number of sub-signers".to_string() });
90+
return Err(AlgoKitTransactError::InvalidMultisigSignature { err_msg:"Threshold must be greater than zero and less than or equal to the number of sub-signers".to_string() });
9191
}
9292
Ok(Self {
9393
version,
@@ -138,7 +138,7 @@ impl MultisigSignature {
138138
}
139139
if !found {
140140
return Err(AlgoKitTransactError::InvalidMultisigSignature {
141-
message: "Address not found in multisig signature".to_string(),
141+
err_msg:"Address not found in multisig signature".to_string(),
142142
});
143143
}
144144

@@ -161,17 +161,17 @@ impl MultisigSignature {
161161
pub fn merge(&self, other: &Self) -> Result<Self, AlgoKitTransactError> {
162162
if self.version != other.version {
163163
return Err(AlgoKitTransactError::InvalidMultisigSignature {
164-
message: "Cannot merge multisig signatures with different versions".to_string(),
164+
err_msg:"Cannot merge multisig signatures with different versions".to_string(),
165165
});
166166
}
167167
if self.threshold != other.threshold {
168168
return Err(AlgoKitTransactError::InvalidMultisigSignature {
169-
message: "Cannot merge multisig signatures with different thresholds".to_string(),
169+
err_msg:"Cannot merge multisig signatures with different thresholds".to_string(),
170170
});
171171
}
172172
if self.participants() != other.participants() {
173173
return Err(AlgoKitTransactError::InvalidMultisigSignature {
174-
message: "Cannot merge multisig signatures with different participants".to_string(),
174+
err_msg:"Cannot merge multisig signatures with different participants".to_string(),
175175
});
176176
}
177177

crates/algokit_transact/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait AlgorandMsgpack: Serialize + for<'de> Deserialize<'de> {
6363
fn decode(bytes: &[u8]) -> Result<Self, AlgoKitTransactError> {
6464
if bytes.is_empty() {
6565
return Err(AlgoKitTransactError::InputError {
66-
message: "attempted to decode 0 bytes".to_string(),
66+
err_msg:"attempted to decode 0 bytes".to_string(),
6767
});
6868
}
6969

crates/algokit_transact/src/transactions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Transaction {
115115
if let Some(max_fee) = request.max_fee {
116116
if calculated_fee > max_fee {
117117
return Err(AlgoKitTransactError::InputError {
118-
message: format!(
118+
err_msg:format!(
119119
"Transaction fee {} µALGO is greater than max fee {} µALGO",
120120
calculated_fee, max_fee
121121
),
@@ -207,7 +207,7 @@ impl AlgorandMsgpack for SignedTransaction {
207207
Ok(stxn)
208208
}
209209
_ => Err(AlgoKitTransactError::InputError {
210-
message: format!(
210+
err_msg:format!(
211211
"expected signed transaction to be a map, but got a: {:#?}",
212212
value.type_id()
213213
),

crates/algokit_transact/src/transactions/payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mod tests {
150150
let msg = format!("{}", err);
151151
assert!(
152152
msg == "Transaction fee 2470 µALGO is greater than max fee 1000 µALGO",
153-
"Unexpected error message: {}",
153+
"Unexpected error err_msg:{}",
154154
msg
155155
);
156156
}

crates/algokit_transact/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ pub fn hash(bytes: &Vec<u8>) -> Byte32 {
106106
pub fn compute_group(txs: &[Transaction]) -> Result<Byte32, AlgoKitTransactError> {
107107
if txs.is_empty() {
108108
return Err(AlgoKitTransactError::InputError {
109-
message: String::from("Transaction group size cannot be 0"),
109+
err_msg:String::from("Transaction group size cannot be 0"),
110110
});
111111
}
112112

113113
if txs.len() > MAX_TX_GROUP_SIZE {
114114
return Err(AlgoKitTransactError::InputError {
115-
message: format!(
115+
err_msg:format!(
116116
"Transaction group size exceeds the max limit of {}",
117117
MAX_TX_GROUP_SIZE
118118
),
@@ -124,7 +124,7 @@ pub fn compute_group(txs: &[Transaction]) -> Result<Byte32, AlgoKitTransactError
124124
.map(|tx| {
125125
if tx.header().group.is_some() {
126126
return Err(AlgoKitTransactError::InputError {
127-
message: "Transactions must not already be grouped".to_string(),
127+
err_msg:"Transactions must not already be grouped".to_string(),
128128
});
129129
}
130130
tx.id_raw()

crates/algokit_transact_ffi/src/lib.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ use snafu::Snafu;
2323
#[derive(Debug, Snafu)]
2424
#[cfg_attr(feature = "ffi_uniffi", derive(uniffi::Error))]
2525
pub enum AlgoKitTransactError {
26-
#[snafu(display("EncodingError: {message}"))]
27-
EncodingError { message: String },
28-
#[snafu(display("DecodingError: {message}"))]
29-
DecodingError { message: String },
30-
#[snafu(display("{message}"))]
31-
InputError { message: String },
32-
#[snafu(display("MsgPackError: {message}"))]
33-
MsgPackError { message: String },
26+
#[snafu(display("EncodingError: {error_msg}"))]
27+
EncodingError { error_msg: String },
28+
#[snafu(display("DecodingError: {error_msg}"))]
29+
DecodingError { error_msg: String },
30+
#[snafu(display("{error_msg}"))]
31+
InputError { error_msg: String },
32+
#[snafu(display("MsgPackError: {error_msg}"))]
33+
MsgPackError { error_msg: String },
3434
}
3535

3636
// Convert errors from the Rust crate into the FFI-specific errors
@@ -39,40 +39,40 @@ impl From<algokit_transact::AlgoKitTransactError> for AlgoKitTransactError {
3939
match e {
4040
algokit_transact::AlgoKitTransactError::DecodingError { .. } => {
4141
AlgoKitTransactError::DecodingError {
42-
message: e.to_string(),
42+
error_msg: e.to_string(),
4343
}
4444
}
4545
algokit_transact::AlgoKitTransactError::EncodingError { .. } => {
4646
AlgoKitTransactError::EncodingError {
47-
message: e.to_string(),
47+
error_msg: e.to_string(),
4848
}
4949
}
5050
algokit_transact::AlgoKitTransactError::MsgpackDecodingError { .. } => {
5151
AlgoKitTransactError::DecodingError {
52-
message: e.to_string(),
52+
error_msg: e.to_string(),
5353
}
5454
}
5555
algokit_transact::AlgoKitTransactError::MsgpackEncodingError { .. } => {
5656
AlgoKitTransactError::EncodingError {
57-
message: e.to_string(),
57+
error_msg: e.to_string(),
5858
}
5959
}
6060
algokit_transact::AlgoKitTransactError::UnknownTransactionType { .. } => {
6161
AlgoKitTransactError::DecodingError {
62-
message: e.to_string(),
62+
error_msg: e.to_string(),
6363
}
6464
}
65-
algokit_transact::AlgoKitTransactError::InputError { message } => {
66-
AlgoKitTransactError::InputError { message }
65+
algokit_transact::AlgoKitTransactError::InputError { err_msg: message } => {
66+
AlgoKitTransactError::InputError { error_msg: message }
6767
}
6868
algokit_transact::AlgoKitTransactError::InvalidAddress { .. } => {
6969
AlgoKitTransactError::DecodingError {
70-
message: e.to_string(),
70+
error_msg: e.to_string(),
7171
}
7272
}
7373
algokit_transact::AlgoKitTransactError::InvalidMultisigSignature { .. } => {
7474
AlgoKitTransactError::DecodingError {
75-
message: e.to_string(),
75+
error_msg: e.to_string(),
7676
}
7777
}
7878
}
@@ -118,7 +118,7 @@ impl TryFrom<KeyPairAccount> for algokit_transact::KeyPairAccount {
118118
let pub_key: [u8; ALGORAND_PUBLIC_KEY_BYTE_LENGTH] =
119119
vec_to_array(&value.pub_key, "public key").map_err(|e| {
120120
AlgoKitTransactError::DecodingError {
121-
message: format!("Error while decoding a public key: {}", e),
121+
error_msg: format!("Error while decoding a public key: {}", e),
122122
}
123123
})?;
124124

@@ -212,7 +212,7 @@ impl TryFrom<Transaction> for algokit_transact::Transaction {
212212
> 1
213213
{
214214
return Err(Self::Error::DecodingError {
215-
message: "Multiple transaction type specific fields set".to_string(),
215+
error_msg: "Multiple transaction type specific fields set".to_string(),
216216
});
217217
}
218218

@@ -393,7 +393,7 @@ impl TryFrom<SignedTransaction> for algokit_transact::SignedTransaction {
393393
.map(|sig| vec_to_array(&sig, "signature"))
394394
.transpose()
395395
.map_err(|e| AlgoKitTransactError::DecodingError {
396-
message: format!(
396+
error_msg: format!(
397397
"Error while decoding the signature in a signed transaction: {}",
398398
e
399399
),
@@ -417,7 +417,7 @@ fn vec_to_array<const N: usize>(
417417
buf.to_vec()
418418
.try_into()
419419
.map_err(|_| AlgoKitTransactError::DecodingError {
420-
message: format!(
420+
error_msg: format!(
421421
"Expected {} {} bytes but got {} bytes",
422422
context,
423423
N,
@@ -544,7 +544,7 @@ pub fn estimate_transaction_size(transaction: Transaction) -> Result<u64, AlgoKi
544544
.estimate_size()?
545545
.try_into()
546546
.map_err(|_| AlgoKitTransactError::EncodingError {
547-
message: "Failed to convert size to u64".to_string(),
547+
error_msg: "Failed to convert size to u64".to_string(),
548548
})
549549
}
550550

@@ -553,7 +553,7 @@ pub fn address_from_public_key(public_key: &[u8]) -> Result<String, AlgoKitTrans
553553
Ok(
554554
algokit_transact::KeyPairAccount::from_pubkey(public_key.try_into().map_err(|_| {
555555
AlgoKitTransactError::EncodingError {
556-
message: format!(
556+
error_msg: format!(
557557
"public key should be {} bytes",
558558
ALGORAND_PUBLIC_KEY_BYTE_LENGTH
559559
),

crates/algokit_transact_ffi/src/multisig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl TryFrom<MultisigSubsignature> for algokit_transact::MultisigSubsignature {
7070
.map(|sig| vec_to_array(&sig, "signature"))
7171
.transpose()
7272
.map_err(|e| AlgoKitTransactError::DecodingError {
73-
message: format!("Error while decoding a subsignature: {}", e),
73+
error_msg:format!("Error while decoding a subsignature: {}", e),
7474
})?,
7575
})
7676
}
@@ -143,7 +143,7 @@ pub fn apply_multisig_subsignature(
143143
subsignature
144144
.try_into()
145145
.map_err(|_| AlgoKitTransactError::EncodingError {
146-
message: format!(
146+
error_msg:format!(
147147
"signature should be {} bytes",
148148
ALGORAND_SIGNATURE_BYTE_LENGTH
149149
),

crates/algokit_transact_ffi/src/transactions/app_call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl TryFrom<Transaction> for algokit_transact::AppCallTransactionFields {
9999
fn try_from(tx: Transaction) -> Result<Self, Self::Error> {
100100
if tx.transaction_type != TransactionType::AppCall || tx.app_call.is_none() {
101101
return Err(Self::Error::DecodingError {
102-
message: "AppCall call data missing".to_string(),
102+
error_msg:"AppCall call data missing".to_string(),
103103
});
104104
}
105105

@@ -135,7 +135,7 @@ impl TryFrom<Transaction> for algokit_transact::AppCallTransactionFields {
135135
transaction_fields
136136
.validate()
137137
.map_err(|errors| AlgoKitTransactError::DecodingError {
138-
message: format!("App call validation failed: {}", errors.join("\n")),
138+
error_msg:format!("App call validation failed: {}", errors.join("\n")),
139139
})?;
140140

141141
Ok(transaction_fields)

0 commit comments

Comments
 (0)