Skip to content

Commit 63d73cb

Browse files
Seulgi Kimsgkim126
authored andcommitted
Make the registrar be able to ignore the allowed script hashes
1 parent 86edd22 commit 63d73cb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

state/src/impls/shard_level.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'db> ShardLevelState<'db> {
332332
if output.shard_id != self.shard_id {
333333
continue
334334
}
335-
self.check_output_script_hash(output)?;
335+
self.check_output_script_hash(output, sender, approvers)?;
336336
self.create_asset(
337337
transaction_tracker,
338338
index,
@@ -539,14 +539,25 @@ impl<'db> ShardLevelState<'db> {
539539
Ok((asset, from_regulator))
540540
}
541541

542-
fn check_output_script_hash(&self, output: &AssetTransferOutput) -> StateResult<()> {
542+
fn check_output_script_hash(
543+
&self,
544+
output: &AssetTransferOutput,
545+
sender: &Address,
546+
approvers: &[Address],
547+
) -> StateResult<()> {
543548
let asset_scheme = {
544549
assert_eq!(self.shard_id, output.shard_id);
545550
self.asset_scheme(output.asset_type)?.ok_or_else(|| RuntimeError::AssetSchemeNotFound {
546551
asset_type: output.asset_type,
547552
shard_id: self.shard_id,
548553
})?
549554
};
555+
if let Some(registrar) = asset_scheme.registrar().as_ref() {
556+
if sender == registrar || approvers.contains(registrar) {
557+
return Ok(())
558+
}
559+
}
560+
550561
let lock_script_hash = output.lock_script_hash;
551562
if asset_scheme.is_allowed_script_hash(&lock_script_hash) {
552563
Ok(())

0 commit comments

Comments
 (0)