-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee9fe74
commit f1d88b4
Showing
126 changed files
with
19,360 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ pub mod v12; | |
pub mod v13; | ||
pub mod v14; | ||
pub mod v15; | ||
pub mod v16; | ||
pub mod v8; | ||
pub mod v9; |
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,20 @@ | ||
// Copyright 2019-2022 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
pub use self::state::State; | ||
use fvm_shared4::METHOD_CONSTRUCTOR; | ||
use num_derive::FromPrimitive; | ||
|
||
mod state; | ||
pub mod types; | ||
|
||
/// Account actor methods available | ||
#[derive(FromPrimitive)] | ||
#[repr(u64)] | ||
pub enum Method { | ||
Constructor = METHOD_CONSTRUCTOR, | ||
PubkeyAddress = 2, | ||
// Deprecated in v10 | ||
// AuthenticateMessage = 3, | ||
AuthenticateMessageExported = frc42_dispatch::method_hash!("AuthenticateMessage"), | ||
} |
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,11 @@ | ||
// Copyright 2019-2022 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use fvm_ipld_encoding::tuple::*; | ||
use fvm_shared4::address::Address; | ||
|
||
/// State includes the address for the actor | ||
#[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)] | ||
pub struct State { | ||
pub address: Address, | ||
} |
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,29 @@ | ||
use fvm_ipld_encoding::strict_bytes; | ||
use fvm_ipld_encoding::tuple::*; | ||
use fvm_shared4::address::Address; | ||
|
||
#[derive(Debug, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct ConstructorParams { | ||
pub address: Address, | ||
} | ||
|
||
#[derive(Debug, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct PubkeyAddressReturn { | ||
pub address: Address, | ||
} | ||
|
||
#[derive(Debug, Serialize_tuple, Deserialize_tuple)] | ||
pub struct AuthenticateMessageParams { | ||
#[serde(with = "strict_bytes")] | ||
pub signature: Vec<u8>, | ||
#[serde(with = "strict_bytes")] | ||
pub message: Vec<u8>, | ||
} | ||
|
||
#[derive(Debug, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct AuthenticateMessageReturn { | ||
pub authenticated: bool, | ||
} |
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 |
---|---|---|
|
@@ -7,5 +7,6 @@ pub mod v12; | |
pub mod v13; | ||
pub mod v14; | ||
pub mod v15; | ||
pub mod v16; | ||
pub mod v8; | ||
pub mod v9; |
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,27 @@ | ||
// Copyright 2019-2022 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use fvm_ipld_encoding::tuple::*; | ||
|
||
use fvm_shared4::METHOD_CONSTRUCTOR; | ||
use num_derive::FromPrimitive; | ||
|
||
pub use self::state::{Entry, State}; | ||
|
||
mod state; | ||
|
||
/// Cron actor methods available | ||
#[derive(FromPrimitive)] | ||
#[repr(u64)] | ||
pub enum Method { | ||
Constructor = METHOD_CONSTRUCTOR, | ||
EpochTick = 2, | ||
} | ||
|
||
/// Constructor parameters for Cron actor, contains entries | ||
/// of actors and methods to call on each epoch | ||
#[derive(Default, Debug, Serialize_tuple, Deserialize_tuple)] | ||
pub struct ConstructorParams { | ||
/// Entries is a set of actors (and corresponding methods) to call during EpochTick. | ||
pub entries: Vec<Entry>, | ||
} |
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,21 @@ | ||
// Copyright 2019-2022 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use fvm_ipld_encoding::tuple::*; | ||
use fvm_shared4::address::Address; | ||
use fvm_shared4::MethodNum; | ||
|
||
/// Cron actor state which holds entries to call during epoch tick | ||
#[derive(Default, Serialize_tuple, Deserialize_tuple, Clone, Debug)] | ||
pub struct State { | ||
/// Entries is a set of actors (and corresponding methods) to call during EpochTick. | ||
pub entries: Vec<Entry>, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, Debug, Serialize_tuple, Deserialize_tuple)] | ||
pub struct Entry { | ||
/// The actor to call (ID address) | ||
pub receiver: Address, | ||
/// The method number to call (must accept empty parameters) | ||
pub method_num: MethodNum, | ||
} |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ pub mod v12; | |
pub mod v13; | ||
pub mod v14; | ||
pub mod v15; | ||
pub mod v16; | ||
pub mod v9; |
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,63 @@ | ||
// Copyright 2019-2022 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use frc46_token::token::TOKEN_PRECISION; | ||
use fvm_shared4::bigint::BigInt; | ||
use fvm_shared4::econ::TokenAmount; | ||
use fvm_shared4::METHOD_CONSTRUCTOR; | ||
use lazy_static::lazy_static; | ||
use num_derive::FromPrimitive; | ||
|
||
pub use self::state::State; | ||
pub use self::types::*; | ||
|
||
mod state; | ||
mod types; | ||
|
||
pub const DATACAP_GRANULARITY: u64 = TOKEN_PRECISION; | ||
|
||
lazy_static! { | ||
// > 800 EiB | ||
pub static ref INFINITE_ALLOWANCE: TokenAmount = TokenAmount::from_atto( | ||
BigInt::from(TOKEN_PRECISION) | ||
* BigInt::from(1_000_000_000_000_000_000_000_i128) | ||
); | ||
} | ||
|
||
/// Datacap actor methods available | ||
#[derive(FromPrimitive)] | ||
#[repr(u64)] | ||
pub enum Method { | ||
Constructor = METHOD_CONSTRUCTOR, | ||
// Deprecated in v10 | ||
// Mint = 2, | ||
// Destroy = 3, | ||
// Name = 10, | ||
// Symbol = 11, | ||
// TotalSupply = 12, | ||
// BalanceOf = 13, | ||
// Transfer = 14, | ||
// TransferFrom = 15, | ||
// IncreaseAllowance = 16, | ||
// DecreaseAllowance = 17, | ||
// RevokeAllowance = 18, | ||
// Burn = 19, | ||
// BurnFrom = 20, | ||
// Allowance = 21, | ||
// Method numbers derived from FRC-0042 standards | ||
MintExported = frc42_dispatch::method_hash!("Mint"), | ||
DestroyExported = frc42_dispatch::method_hash!("Destroy"), | ||
NameExported = frc42_dispatch::method_hash!("Name"), | ||
SymbolExported = frc42_dispatch::method_hash!("Symbol"), | ||
GranularityExported = frc42_dispatch::method_hash!("Granularity"), | ||
TotalSupplyExported = frc42_dispatch::method_hash!("TotalSupply"), | ||
BalanceExported = frc42_dispatch::method_hash!("Balance"), | ||
TransferExported = frc42_dispatch::method_hash!("Transfer"), | ||
TransferFromExported = frc42_dispatch::method_hash!("TransferFrom"), | ||
IncreaseAllowanceExported = frc42_dispatch::method_hash!("IncreaseAllowance"), | ||
DecreaseAllowanceExported = frc42_dispatch::method_hash!("DecreaseAllowance"), | ||
RevokeAllowanceExported = frc42_dispatch::method_hash!("RevokeAllowance"), | ||
BurnExported = frc42_dispatch::method_hash!("Burn"), | ||
BurnFromExported = frc42_dispatch::method_hash!("BurnFrom"), | ||
AllowanceExported = frc42_dispatch::method_hash!("Allowance"), | ||
} |
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,37 @@ | ||
use frc46_token::token; | ||
use fvm_ipld_blockstore::Blockstore; | ||
use fvm_ipld_encoding::tuple::*; | ||
use fvm_shared4::address::Address; | ||
use fvm_shared4::econ::TokenAmount; | ||
use fvm_shared4::error::ExitCode; | ||
use fvm_shared4::ActorID; | ||
|
||
use fil_actors_shared::v16::{ActorError, AsActorError}; | ||
|
||
#[derive(Debug, Serialize_tuple, Deserialize_tuple)] | ||
pub struct State { | ||
pub governor: Address, | ||
pub token: token::state::TokenState, | ||
} | ||
|
||
impl State { | ||
pub fn new<BS: Blockstore>(store: &BS, governor: Address) -> Result<State, ActorError> { | ||
let token_state = token::state::TokenState::new(store) | ||
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to create token state")?; | ||
Ok(State { | ||
governor, | ||
token: token_state, | ||
}) | ||
} | ||
|
||
// Visible for testing | ||
pub fn balance<BS: Blockstore>( | ||
&self, | ||
bs: &BS, | ||
owner: ActorID, | ||
) -> Result<TokenAmount, ActorError> { | ||
self.token | ||
.get_balance(bs, owner) | ||
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to get balance") | ||
} | ||
} |
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,85 @@ | ||
use fvm_ipld_encoding::tuple::*; | ||
use fvm_shared4::address::Address; | ||
use fvm_shared4::econ::TokenAmount; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct ConstructorParams { | ||
pub governor: Address, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct NameReturn { | ||
pub name: String, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct SymbolReturn { | ||
pub symbol: String, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct TotalSupplyReturn { | ||
pub supply: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct BalanceParams { | ||
pub address: Address, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct BalanceReturn { | ||
pub balance: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct GetAllowanceReturn { | ||
pub allowance: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct IncreaseAllowanceReturn { | ||
pub new_allowance: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct DecreaseAllowanceReturn { | ||
pub new_allowance: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct RevokeAllowanceReturn { | ||
pub old_allowance: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
pub struct MintParams { | ||
// Recipient of the newly minted tokens. | ||
pub to: Address, | ||
// Amount of tokens to mint. | ||
pub amount: TokenAmount, | ||
// Addresses to be granted effectively-infinite operator allowance for the recipient. | ||
pub operators: Vec<Address>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
pub struct DestroyParams { | ||
pub owner: Address, | ||
pub amount: TokenAmount, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] | ||
#[serde(transparent)] | ||
pub struct GranularityReturn { | ||
pub granularity: u64, | ||
} |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod v12; | |
pub mod v13; | ||
pub mod v14; | ||
pub mod v15; | ||
pub mod v16; |
Oops, something went wrong.