-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement init actor (todo state) * Implement init actor state and fix missing init store in state tree * Switch error type * Swap errors
- Loading branch information
1 parent
5d82917
commit 7c8fb8c
Showing
14 changed files
with
294 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2020 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use cid::{multihash::Identity, Cid, Codec, Version}; | ||
|
||
lazy_static! { | ||
pub static ref SYSTEM_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/system"); | ||
pub static ref INIT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/init"); | ||
pub static ref CRON_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/cron"); | ||
pub static ref ACCOUNT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/account"); | ||
pub static ref POWER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/storagepower"); | ||
pub static ref MINER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/storageminer"); | ||
pub static ref MARKET_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/storagemarket"); | ||
pub static ref PAYCH_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/paymentchannel"); | ||
pub static ref MULTISIG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/multisig"); | ||
pub static ref REWARD_ACTOR_CODE_ID: Cid = make_builtin(b"fil/1/reward"); | ||
|
||
// Set of actor code types that can represent external signing parties. | ||
pub static ref CALLER_TYPES_SIGNABLE: [Cid; 2] = | ||
[ACCOUNT_ACTOR_CODE_ID.clone(), MULTISIG_ACTOR_CODE_ID.clone()]; | ||
} | ||
|
||
fn make_builtin(bz: &[u8]) -> Cid { | ||
Cid::new(Codec::Raw, Version::V1, Identity::digest(bz)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2020 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use address::Address; | ||
use cid::Cid; | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
use vm::Serialized; | ||
|
||
/// Constructor parameters | ||
pub struct ConstructorParams { | ||
pub network_name: String, | ||
} | ||
|
||
impl Serialize for ConstructorParams { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
[&self.network_name].serialize(serializer) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for ConstructorParams { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let [network_name]: [String; 1] = Deserialize::deserialize(deserializer)?; | ||
Ok(Self { network_name }) | ||
} | ||
} | ||
|
||
/// Exec Params | ||
pub struct ExecParams { | ||
pub code_cid: Cid, | ||
pub constructor_params: Serialized, | ||
} | ||
|
||
impl Serialize for ExecParams { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
(&self.code_cid, &self.constructor_params).serialize(serializer) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for ExecParams { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let (code_cid, constructor_params) = Deserialize::deserialize(deserializer)?; | ||
Ok(Self { | ||
code_cid, | ||
constructor_params, | ||
}) | ||
} | ||
} | ||
|
||
/// Exec Return value | ||
pub struct ExecReturn { | ||
/// ID based address for created actor | ||
pub id_address: Address, | ||
/// Reorg safe address for actor | ||
pub robust_address: Address, | ||
} | ||
|
||
impl Serialize for ExecReturn { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
(&self.id_address, &self.robust_address).serialize(serializer) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for ExecReturn { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let (id_address, robust_address) = Deserialize::deserialize(deserializer)?; | ||
Ok(Self { | ||
id_address, | ||
robust_address, | ||
}) | ||
} | ||
} |
Oops, something went wrong.