-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
9 changed files
with
280 additions
and
178 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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::sync::Arc; | ||
|
||
use shared_crypto::intent::{Intent, IntentMessage}; | ||
use sui_types::base_types::SuiAddress; | ||
use sui_types::crypto::{Signature, SuiKeyPair}; | ||
use sui_types::signature::GenericSignature; | ||
use sui_types::transaction::TransactionData; | ||
|
||
use super::TxSignerTrait; | ||
|
||
pub struct InMemoryTxSigner { | ||
keypair: SuiKeyPair, | ||
} | ||
|
||
impl InMemoryTxSigner { | ||
pub fn new(keypair: SuiKeyPair) -> Arc<Self> { | ||
Arc::new(Self { keypair }) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl TxSignerTrait for InMemoryTxSigner { | ||
async fn sign_transaction( | ||
&self, | ||
tx_data: &TransactionData, | ||
) -> anyhow::Result<GenericSignature> { | ||
let intent_msg = IntentMessage::new(Intent::sui_transaction(), tx_data); | ||
let sponsor_sig = Signature::new_secure(&intent_msg, &self.keypair).into(); | ||
Ok(sponsor_sig) | ||
} | ||
|
||
fn sui_address(&self) -> SuiAddress { | ||
(&self.keypair.public()).into() | ||
} | ||
} |
Oops, something went wrong.