-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'starcoinorg:master' into master
- Loading branch information
Showing
516 changed files
with
1,876 additions
and
30,708 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,77 @@ | ||
use crate::AccountInfo; | ||
use anyhow::Result; | ||
use starcoin_types::account_address::AccountAddress; | ||
use starcoin_types::account_config::token_code::TokenCode; | ||
use starcoin_types::sign_message::{SignedMessage, SigningMessage}; | ||
use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction}; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub enum AccountProviderStrategy { | ||
RPC, | ||
Local, | ||
} | ||
|
||
impl Default for AccountProviderStrategy { | ||
fn default() -> Self { | ||
AccountProviderStrategy::RPC | ||
} | ||
} | ||
pub trait AccountProvider { | ||
fn create_account(&self, password: String) -> Result<AccountInfo>; | ||
|
||
fn get_default_account(&self) -> Result<Option<AccountInfo>>; | ||
fn set_default_account(&self, address: AccountAddress) -> Result<AccountInfo>; | ||
fn get_accounts(&self) -> Result<Vec<AccountInfo>>; | ||
|
||
fn get_account(&self, address: AccountAddress) -> Result<Option<AccountInfo>>; | ||
|
||
/// Signs the hash of data with given address. | ||
fn sign_message( | ||
&self, | ||
address: AccountAddress, | ||
message: SigningMessage, | ||
) -> Result<SignedMessage>; | ||
|
||
fn sign_txn( | ||
&self, | ||
raw_txn: RawUserTransaction, | ||
signer_address: AccountAddress, | ||
) -> Result<SignedUserTransaction>; | ||
fn unlock_account( | ||
&self, | ||
address: AccountAddress, | ||
password: String, | ||
duration: std::time::Duration, | ||
) -> Result<AccountInfo>; | ||
fn lock_account(&self, address: AccountAddress) -> Result<AccountInfo>; | ||
fn import_account( | ||
&self, | ||
address: AccountAddress, | ||
private_key: Vec<u8>, | ||
password: String, | ||
) -> Result<AccountInfo>; | ||
|
||
fn import_readonly_account( | ||
&self, | ||
address: AccountAddress, | ||
public_key: Vec<u8>, | ||
) -> Result<AccountInfo>; | ||
|
||
/// Return the private key as bytes for `address` | ||
fn export_account(&self, address: AccountAddress, password: String) -> Result<Vec<u8>>; | ||
|
||
fn accepted_tokens(&self, address: AccountAddress) -> Result<Vec<TokenCode>>; | ||
|
||
/// change account password, user need to unlock account first. | ||
fn change_account_password( | ||
&self, | ||
address: AccountAddress, | ||
new_password: String, | ||
) -> Result<AccountInfo>; | ||
|
||
fn remove_account( | ||
&self, | ||
address: AccountAddress, | ||
password: Option<String>, | ||
) -> Result<AccountInfo>; | ||
} |
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,14 @@ | ||
[package] | ||
name = "starcoin-account-provider" | ||
version = "1.10.0-rc.2" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0.41" | ||
starcoin-account = { path = "../" } | ||
starcoin-account-api = { path = "../api", features = ["mock"] } | ||
starcoin-types = { path = "../../types" } | ||
starcoin-rpc-client = { path = "../../rpc/client" } | ||
starcoin-config = { path = "../../config" } |
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,4 @@ | ||
mod local_provider; | ||
mod provider; | ||
mod rpc_provider; | ||
pub use provider::ProviderFactory; |
Oops, something went wrong.