pub struct FileSigner { /* private fields */ }Expand description
A signer that loads its key from ~/.near-credentials/{network}/{account}.json.
Compatible with credentials created by near-cli and near-cli-rs.
§Example
use near_kit::FileSigner;
// Load from ~/.near-credentials/testnet/alice.testnet.json
let signer = FileSigner::new("testnet", "alice.testnet").unwrap();Implementations§
Source§impl FileSigner
impl FileSigner
Sourcepub fn new(
network: impl AsRef<str>,
account_id: impl AsRef<str>,
) -> Result<Self, Error>
pub fn new( network: impl AsRef<str>, account_id: impl AsRef<str>, ) -> Result<Self, Error>
Load credentials for an account from the standard NEAR credentials directory.
Looks for the file at ~/.near-credentials/{network}/{account_id}.json.
§Arguments
network- Network name (e.g., “testnet”, “mainnet”)account_id- The NEAR account ID
§Errors
Returns an error if:
- The home directory cannot be determined
- The credentials file doesn’t exist
- The file cannot be parsed
Sourcepub fn from_file(
path: impl AsRef<Path>,
account_id: impl AsRef<str>,
) -> Result<Self, Error>
pub fn from_file( path: impl AsRef<Path>, account_id: impl AsRef<str>, ) -> Result<Self, Error>
Load credentials from a specific file path.
§Arguments
path- Path to the credentials JSON fileaccount_id- The NEAR account ID
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 FileSigner
impl Clone for FileSigner
Source§fn clone(&self) -> FileSigner
fn clone(&self) -> FileSigner
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 FileSigner
impl Debug for FileSigner
Source§impl Signer for FileSigner
impl Signer for FileSigner
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 FileSigner
impl RefUnwindSafe for FileSigner
impl Send for FileSigner
impl Sync for FileSigner
impl Unpin for FileSigner
impl UnsafeUnpin for FileSigner
impl UnwindSafe for FileSigner
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