pub struct KeyringSigner { /* private fields */ }Expand description
Signer that loads keys from the system keyring.
Compatible with keys stored by near-cli-rs.
§Construction
Unlike FileSigner, KeyringSigner requires the public key
because keyring entries are keyed by {account_id}:{public_key}.
use near_kit::KeyringSigner;
let signer = KeyringSigner::new(
"testnet",
"alice.testnet",
"ed25519:6fWy..."
)?;Implementations§
Source§impl KeyringSigner
impl KeyringSigner
Sourcepub fn new(
network: impl AsRef<str>,
account_id: impl AsRef<str>,
public_key: impl AsRef<str>,
) -> Result<Self, Error>
pub fn new( network: impl AsRef<str>, account_id: impl AsRef<str>, public_key: impl AsRef<str>, ) -> Result<Self, Error>
Load a key from the system keyring.
§Arguments
network- Network name (e.g., “testnet”, “mainnet”)account_id- The NEAR account IDpublic_key- The public key to look up (e.g., “ed25519:…”)
§Errors
Returns an error if:
- The keyring is not available (e.g., no Secret Service on Linux)
- The key is not found in the keyring
- The stored credential has an invalid format
§Example
use near_kit::KeyringSigner;
let signer = KeyringSigner::new(
"testnet",
"alice.testnet",
"ed25519:6fWy..."
)?;Sourcepub fn public_key(&self) -> &PublicKey
pub fn public_key(&self) -> &PublicKey
Get the public key.
Sourcepub fn into_inner(self) -> InMemorySigner
pub fn into_inner(self) -> InMemorySigner
Unwrap into the underlying InMemorySigner.
Trait Implementations§
Source§impl Clone for KeyringSigner
impl Clone for KeyringSigner
Source§fn clone(&self) -> KeyringSigner
fn clone(&self) -> KeyringSigner
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyringSigner
impl Debug for KeyringSigner
Source§impl Signer for KeyringSigner
impl Signer for KeyringSigner
Source§fn account_id(&self) -> &AccountId
fn account_id(&self) -> &AccountId
The account this signer signs for.
Source§fn key(&self) -> SigningKey
fn key(&self) -> SigningKey
Get a key for signing. Read more
Auto Trait Implementations§
impl Freeze for KeyringSigner
impl RefUnwindSafe for KeyringSigner
impl Send for KeyringSigner
impl Sync for KeyringSigner
impl Unpin for KeyringSigner
impl UnsafeUnpin for KeyringSigner
impl UnwindSafe for KeyringSigner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more