Skip to content

Commit 50d1681

Browse files
prototype error handling helpers
1 parent 29fce72 commit 50d1681

File tree

6 files changed

+157
-157
lines changed

6 files changed

+157
-157
lines changed

Cargo.lock

Lines changed: 19 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ members = [
5454
## Uncomment entries below when working locally on ref-fvm and this repo simultaneously.
5555
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
5656
## (Valid once FVM modules are published to crates.io)
57-
#[patch.crates-io]
58-
#fvm_shared = { path = "../ref-fvm/shared" }
59-
#fvm_sdk = { path = "../ref-fvm/sdk" }
60-
#fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
61-
#fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
62-
#fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
63-
#fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
64-
#fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
57+
[patch.crates-io]
58+
fvm_shared = { path = "../ref-fvm/shared" }
59+
fvm_sdk = { path = "../ref-fvm/sdk" }
60+
fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
61+
fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
62+
fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
63+
fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
64+
fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
6565

6666
[profile.wasm]
6767
inherits = "release"

actors/account/src/lib.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use num_traits::FromPrimitive;
1111
use fil_actors_runtime::builtin::singletons::SYSTEM_ACTOR_ADDR;
1212
use fil_actors_runtime::cbor;
1313
use fil_actors_runtime::runtime::{ActorCode, Runtime};
14-
use fil_actors_runtime::{actor_error, ActorError};
14+
use fil_actors_runtime::{actor_error, ensure_args, ActorError};
1515

1616
pub use self::state::State;
1717

@@ -39,14 +39,12 @@ impl Actor {
3939
BS: Blockstore,
4040
RT: Runtime<BS>,
4141
{
42-
rt.validate_immediate_caller_is(std::iter::once(&*SYSTEM_ACTOR_ADDR))?;
43-
match address.protocol() {
44-
Protocol::Secp256k1 | Protocol::BLS => {}
45-
protocol => {
46-
return Err(actor_error!(ErrIllegalArgument;
47-
"address must use BLS or SECP protocol, got {}", protocol));
48-
}
49-
}
42+
rt.validate_immediate_caller_is([&*SYSTEM_ACTOR_ADDR])?;
43+
ensure_args!(
44+
matches!(address.protocol(), Protocol::Secp256k1 | Protocol::BLS),
45+
"address must use BLS or SECP protocol, got {}",
46+
address.protocol(),
47+
);
5048
rt.create(&State { address })?;
5149
Ok(())
5250
}

0 commit comments

Comments
 (0)