Skip to content

Commit 631bd9d

Browse files
committed
sync with main
1 parent 968955e commit 631bd9d

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

crates/yttrium/src/chain_abstraction/dart_compat_models.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ impl From<PulseMetadataCompat> for PulseMetadata {
7272
fn from(compat: PulseMetadataCompat) -> Self {
7373
let url = compat.url.and_then(|s| url::Url::parse(&s).ok());
7474
let bundle_id = compat.bundle_id.clone();
75-
let package_name = compat.package_name.clone();
75+
// let package_name = compat.package_name.clone();
7676
let sdk_version = compat.sdk_version.clone();
7777
let sdk_platform = compat.sdk_platform.clone();
7878

79-
Self { url, bundle_id, package_name, sdk_version, sdk_platform }
79+
Self { url, bundle_id, sdk_version, sdk_platform }
8080
}
8181
}
8282

@@ -113,7 +113,7 @@ impl From<CallCompat> for Call {
113113
let to = Address::from_str(&compat.to).unwrap();
114114
let value = U256::from(compat.value);
115115
// Convert hex string back to Bytes
116-
let input = Bytes::from(hex::decode(&compat.input[2..]).unwrap()); // Skip "0x" prefix
116+
let input = Bytes::from(hex::decode(&compat.input[2..]).unwrap()); // Skip "0x" prefix
117117

118118
Call { to, value, input }
119119
}
@@ -493,7 +493,7 @@ impl From<FeeEstimatedTransactionCompat> for FeeEstimatedTransaction {
493493
to: Address::from_str(&compat.to).unwrap(),
494494
value: U256::from_str(&compat.value).unwrap(),
495495
// Convert hex string back to Bytes
496-
input: Bytes::from(hex::decode(&compat.input[2..]).unwrap()), // Skip "0x" prefix
496+
input: Bytes::from(hex::decode(&compat.input[2..]).unwrap()), // Skip "0x" prefix
497497
gas_limit: U64::from_str(&compat.gas_limit).unwrap(),
498498
nonce: U64::from_str(&compat.nonce).unwrap(),
499499
max_fee_per_gas: U128::from_str(&compat.max_fee_per_gas).unwrap(),
@@ -787,17 +787,18 @@ impl From<PrepareDetailedResponseSuccessCompat>
787787
#[frb(dart_metadata=("freezed"))]
788788
pub struct PrepareResponseErrorCompat {
789789
pub error: BridgingErrorCompat,
790+
pub reason: String,
790791
}
791792

792793
impl From<PrepareResponseError> for PrepareResponseErrorCompat {
793794
fn from(original: PrepareResponseError) -> Self {
794-
Self { error: original.error.into() }
795+
Self { error: original.error.into(), reason: original.reason }
795796
}
796797
}
797798

798799
impl From<PrepareResponseErrorCompat> for PrepareResponseError {
799800
fn from(compat: PrepareResponseErrorCompat) -> Self {
800-
Self { error: compat.error.into() }
801+
Self { error: compat.error.into(), reason: compat.reason }
801802
}
802803
}
803804

@@ -893,7 +894,7 @@ pub struct TransactionCompat {
893894
pub from: String,
894895
pub to: String,
895896
pub value: String,
896-
pub input: String, // Changed from Vec<u8> to String
897+
pub input: String, // Changed from Vec<u8> to String
897898
pub gas_limit: u64,
898899
pub nonce: u64,
899900
}
@@ -907,7 +908,7 @@ impl From<Transaction> for TransactionCompat {
907908
to: original.to.to_string(),
908909
value: original.value.to_string(),
909910
// Convert Bytes to hex string
910-
input: hex::encode(original.input.0), // or format!("0x{}", hex::encode(original.input.0)) for 0x prefix
911+
input: hex::encode(original.input.0), // or format!("0x{}", hex::encode(original.input.0)) for 0x prefix
911912
gas_limit: original.gas_limit.to(),
912913
nonce: original.nonce.to(),
913914
}
@@ -927,7 +928,7 @@ impl From<TransactionCompat> for Transaction {
927928
let to = Address::from_str(&compat.to).unwrap();
928929
let value = U256::from_str(&compat.value).unwrap();
929930
// Convert hex string back to Bytes
930-
let input = Bytes::from(hex::decode(&compat.input[2..]).unwrap()); // Skip "0x" prefix
931+
let input = Bytes::from(hex::decode(&compat.input[2..]).unwrap()); // Skip "0x" prefix
931932
let gas_limit = U64::from(compat.gas_limit);
932933
let nonce = U64::from(compat.nonce);
933934

crates/yttrium/src/frb_generated.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,10 @@ impl SseDecode
591591
<crate::chain_abstraction::api::prepare::BridgingError>::sse_decode(
592592
deserializer,
593593
);
594+
let mut var_reason = <String>::sse_decode(deserializer);
594595
return crate::chain_abstraction::api::prepare::PrepareResponseError {
595596
error: var_error,
597+
reason: var_reason,
596598
};
597599
}
598600
}
@@ -1176,7 +1178,11 @@ impl flutter_rust_bridge::IntoDart
11761178
for crate::chain_abstraction::api::prepare::PrepareResponseError
11771179
{
11781180
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
1179-
[self.error.into_into_dart().into_dart()].into_dart()
1181+
[
1182+
self.error.into_into_dart().into_dart(),
1183+
self.reason.into_into_dart().into_dart(),
1184+
]
1185+
.into_dart()
11801186
}
11811187
}
11821188
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
@@ -1817,6 +1823,7 @@ impl SseEncode
18171823
<crate::chain_abstraction::api::prepare::BridgingError>::sse_encode(
18181824
self.error, serializer,
18191825
);
1826+
<String>::sse_encode(self.reason, serializer);
18201827
}
18211828
}
18221829

crates/yttrium_dart/lib/generated/chain_abstraction/api/prepare.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ enum BridgingError {
1717
/// response
1818
class PrepareResponseError {
1919
final BridgingError error;
20+
final String reason;
2021

2122
const PrepareResponseError({
2223
required this.error,
24+
required this.reason,
2325
});
2426

2527
@override
26-
int get hashCode => error.hashCode;
28+
int get hashCode => error.hashCode ^ reason.hashCode;
2729

2830
@override
2931
bool operator ==(Object other) =>
3032
identical(this, other) ||
3133
other is PrepareResponseError &&
3234
runtimeType == other.runtimeType &&
33-
error == other.error;
35+
error == other.error &&
36+
reason == other.reason;
3437
}

crates/yttrium_dart/lib/generated/frb_generated.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,11 @@ class YttriumDartApiImpl extends YttriumDartApiImplPlatform
676676
PrepareResponseError dco_decode_prepare_response_error(dynamic raw) {
677677
// Codec=Dco (DartCObject based), see doc to use other codecs
678678
final arr = raw as List<dynamic>;
679-
if (arr.length != 1)
680-
throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
679+
if (arr.length != 2)
680+
throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
681681
return PrepareResponseError(
682682
error: dco_decode_bridging_error(arr[0]),
683+
reason: dco_decode_String(arr[1]),
683684
);
684685
}
685686

@@ -1245,7 +1246,8 @@ class YttriumDartApiImpl extends YttriumDartApiImplPlatform
12451246
SseDeserializer deserializer) {
12461247
// Codec=Sse (Serialization based), see doc to use other codecs
12471248
var var_error = sse_decode_bridging_error(deserializer);
1248-
return PrepareResponseError(error: var_error);
1249+
var var_reason = sse_decode_String(deserializer);
1250+
return PrepareResponseError(error: var_error, reason: var_reason);
12491251
}
12501252

12511253
@protected
@@ -1739,6 +1741,7 @@ class YttriumDartApiImpl extends YttriumDartApiImplPlatform
17391741
PrepareResponseError self, SseSerializer serializer) {
17401742
// Codec=Sse (Serialization based), see doc to use other codecs
17411743
sse_encode_bridging_error(self.error, serializer);
1744+
sse_encode_String(self.reason, serializer);
17421745
}
17431746

17441747
@protected

0 commit comments

Comments
 (0)