-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WalletConnect/BNB]: Add
WalletConnectSigner
optional module
- Loading branch information
1 parent
beb19be
commit 183db68
Showing
18 changed files
with
124 additions
and
0 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 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
pub mod json_signer; | ||
pub mod message_signer; | ||
pub mod plan_builder; | ||
pub mod wallet_connect_signer; |
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,28 @@ | ||
// Copyright © 2017-2023 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
use crate::coin_context::CoinContext; | ||
use tw_proto::{DummyMessage, MessageRead, MessageWrite, NoMessage}; | ||
|
||
pub trait WalletConnectSigner { | ||
type SigningInput<'a>: MessageRead<'a>; | ||
type SigningOutput: MessageWrite; | ||
|
||
/// Signs a transaction in WalletConnect format. | ||
fn sign(&self, coin: &dyn CoinContext, input: Self::SigningInput<'_>) -> Self::SigningOutput; | ||
} | ||
|
||
/// `NoWalletConnectSigner` can't be created since there are no enum variants. | ||
pub enum NoWalletConnectSigner {} | ||
|
||
impl WalletConnectSigner for NoWalletConnectSigner { | ||
type SigningInput<'a> = DummyMessage; | ||
type SigningOutput = NoMessage; | ||
|
||
fn sign(&self, _coin: &dyn CoinContext, _input: Self::SigningInput<'_>) -> Self::SigningOutput { | ||
panic!("`NoWalletConnectSigner` should never be constructed and used") | ||
} | ||
} |
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,35 @@ | ||
syntax = "proto3"; | ||
|
||
package TW.WalletConnect.Proto; | ||
option java_package = "wallet.core.jni.proto"; | ||
|
||
import "Common.proto"; | ||
|
||
// The transaction protocol may differ from version to version. | ||
enum Protocol { | ||
V2 = 0; | ||
} | ||
|
||
message SigningInput { | ||
// A signing method like "cosmos_signAmino" or "eth_signTransaction". | ||
string method = 1; | ||
|
||
// Wallet's private key. | ||
bytes private_key = 2; | ||
|
||
// Transaction payload to sign. | ||
// Basically, a JSON object. | ||
string payload = 3; | ||
} | ||
|
||
message SigningOutput { | ||
// A signing result in string representation. | ||
// It can be a serialized signed transaction in Base64, hex etc, or a JSON object. | ||
string result = 1; | ||
|
||
// OK (=0) or other codes in case of error | ||
Common.Proto.SigningError error = 2; | ||
|
||
// error description in case of error | ||
string error_message = 3; | ||
} |