Skip to content

Commit 7eb11a6

Browse files
majectykseo
authored andcommitted
Add network_id field to AssetMintTransaction
1 parent d55691c commit 7eb11a6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

core/src/parcel.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn parcel_error_message(error: &ParcelError) -> String {
7878
AlreadyImported => "Already imported".into(),
7979
Old => "No longer valid".into(),
8080
TooCheapToReplace => "Fee too low to replace".into(),
81-
InvalidNetworkId => "Parcel of this network ID is not allowed on this chain.".into(),
81+
InvalidNetworkId => "This network ID is not allowed on this chain".into(),
8282
MetadataTooBig => "Metadata size is too big.".into(),
8383
LimitReached => "Parcel limit reached".into(),
8484
InsufficientFee {
@@ -375,12 +375,16 @@ impl UnverifiedParcel {
375375
for t in transactions {
376376
match &t {
377377
Transaction::AssetMint {
378+
network_id,
378379
metadata,
379380
..
380381
} => {
381382
if metadata.len() > params.max_metadata_size {
382383
return Err(ParcelError::MetadataTooBig)
383384
}
385+
if network_id != &self.network_id {
386+
return Err(ParcelError::InvalidNetworkId)
387+
}
384388
}
385389
Transaction::AssetTransfer {
386390
network_id,

core/src/transaction.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use super::parcel::{AssetTransferInput, AssetTransferOutput};
2929
pub enum Transaction {
3030
#[serde(rename_all = "camelCase")]
3131
AssetMint {
32+
network_id: u64,
3233
metadata: String,
3334
lock_script_hash: H256,
3435
parameters: Vec<Bytes>,
@@ -101,16 +102,17 @@ impl Decodable for Transaction {
101102
fn decode(d: &UntrustedRlp) -> Result<Self, DecoderError> {
102103
match d.val_at(0)? {
103104
ASSET_MINT_ID => {
104-
if d.item_count()? != 7 {
105+
if d.item_count()? != 8 {
105106
return Err(DecoderError::RlpIncorrectListLen)
106107
}
107108
Ok(Transaction::AssetMint {
108-
metadata: d.val_at(1)?,
109-
lock_script_hash: d.val_at(2)?,
110-
parameters: d.val_at(3)?,
111-
amount: d.val_at(4)?,
112-
registrar: d.val_at(5)?,
113-
nonce: d.val_at(6)?,
109+
network_id: d.val_at(1)?,
110+
metadata: d.val_at(2)?,
111+
lock_script_hash: d.val_at(3)?,
112+
parameters: d.val_at(4)?,
113+
amount: d.val_at(5)?,
114+
registrar: d.val_at(6)?,
115+
nonce: d.val_at(7)?,
114116
})
115117
}
116118
ASSET_TRANSFER_ID => {
@@ -134,14 +136,16 @@ impl Encodable for Transaction {
134136
fn rlp_append(&self, s: &mut RlpStream) {
135137
match self {
136138
Transaction::AssetMint {
139+
network_id,
137140
metadata,
138141
lock_script_hash,
139142
parameters,
140143
amount,
141144
registrar,
142145
nonce,
143-
} => s.begin_list(7)
146+
} => s.begin_list(8)
144147
.append(&ASSET_MINT_ID)
148+
.append(network_id)
145149
.append(metadata)
146150
.append(lock_script_hash)
147151
.append(parameters)

0 commit comments

Comments
 (0)