-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new wallet storage and impl #998
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,64 @@ | ||
use anyhow::Result; | ||
use futures::Stream; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use starcoin_types::account_address::AccountAddress; | ||
use starcoin_types::account_config::token_code::TokenCode; | ||
use starcoin_types::contract_event::EventWithProof; | ||
use starcoin_types::event::EventKey; | ||
use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction, TransactionPayload}; | ||
use std::time::Duration; | ||
|
||
pub trait ChainEventWatcher { | ||
fn watch_event<S>(&self, key: EventKey) -> S | ||
where | ||
S: Stream<Item = EventWithProof>; | ||
} | ||
|
||
pub trait TransactionSubmitter { | ||
fn submit_transaction(&self, txn: SignedUserTransaction) -> Result<()>; | ||
} | ||
|
||
pub trait RichWallet { | ||
fn set_default_expiration_timeout(&mut self, timeout: Duration); | ||
fn set_default_gas_price(&mut self, gas_price: u64); | ||
fn set_default_gas_token(&mut self, token: TokenCode); | ||
|
||
fn get_accepted_tokns(&self) -> Result<Vec<TokenCode>>; | ||
|
||
fn build_transaction( | ||
&self, | ||
// if not specified, use default sender. | ||
sender: Option<AccountAddress>, | ||
payload: TransactionPayload, | ||
max_gas_amount: u64, | ||
// if not specified, uses default settings. | ||
gas_unit_price: Option<u64>, | ||
gas_token_code: Option<String>, | ||
expiration_timestamp_secs: Option<u64>, | ||
) -> Result<RawUserTransaction>; | ||
|
||
fn sign_transaction( | ||
&self, | ||
raw: RawUserTransaction, | ||
address: Option<AccountAddress>, | ||
) -> Result<SignedUserTransaction>; | ||
fn submit_txn(&mut self, txn: SignedUserTransaction) -> Result<()>; | ||
fn get_next_available_seq_number(&self) -> Result<u64>; | ||
|
||
// ...other functionality of origin wallets. | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] | ||
pub struct Setting { | ||
default_expiration_timeout: u64, | ||
default_gas_price: u64, | ||
default_gas_token: TokenCode, | ||
} | ||
|
||
pub trait WalletStorageTrait { | ||
fn save_default_settings(&self, setting: Setting) -> Result<()>; | ||
|
||
fn save_accepted_token(&self, token: TokenCode) -> Result<()>; | ||
fn contain_wallet(&self, address: AccountAddress) -> Result<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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个名字是不是不太合适?但我也没想到更好的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里面的 trait 暂时没用。名字可以忽略。
目前没有抽象接口。
我是想等功能完整后,看看那些需要抽离出来。