In your cargo project add the following
[dependencies]
warp = { git = "https://github.com/Satellite-im/Warp" }
warp-extensions = { git = "https://github.com/Satellite-im/Warp", features = ["mp_solana"] }
Here you will also need to utilize tesseract when utilizing multipass extension
// In real world application, you would want this to be loading from a file
let mut tesseract = Tesseract::default();
tesseract.unlock(b"this is my totally secured password that should nnever be embedded in code").unwrap();
// Use development network.
let mut account = SolanaAccount::with_devnet(&tesseract);
account.create_identity(Some("NewAcctName"), None).unwrap();
Note: If a username is not defined, one will automatically be generated
account.create_identity(None, None).unwrap();
After the function successfully executes, there will be two encrypted fields within tesseract called mnemonic
and privkey
.
If these fields exist and contained valid information related to a registered account, this will not be required and would
return an error.
let ident = account.get_own_identity().unwrap();
let ident = account.get_identity(Identifier::public_key(PublicKey::from_bytes(....))).unwrap()
At this time, fetching by username is only available to find accounts that are cached that were previously looked up via public key.
let privkey = account.decrypt_private_key(None).unwrap();
This returns an array of bytes that is related for your private key. You would need to import them into the proper keypair to utilize them directly.
Note: Many of the functions for handling friends would error if you attempt to add or manage yourself within your account
This overview will assume that our friend public key is 68vtRPQcsV7ruWXa6Z8Enrb6TsXhbRzMywgCnEVyk7Va
. This public key would get decoded using bs58 (or any base58 decoder) into an array of bytes by doing let pubkey = bs58::decode("68vtRPQcsV7ruWXa6Z8Enrb6TsXhbRzMywgCnEVyk7Va").into_vec().map(PublicKey::from_vec).unwrap()
You can send a friend request with anybody who has an solana account.
account.send_request(pubkey).unwrap();
You can accept a friend request sent to you.
account.accept_request(pubkey).unwrap();
You would be able to deny a friend request. Note that once it is denied, the account would need to send another if you wish for them to be friends.
account.deny_request(pubkey).unwrap();
account.close_request(pubkey).unwrap();
This would allow you to view all incoming request that are pending acceptance or denial.
account.list_incoming_request(pubkey).unwrap();
This would allow you to view all outgoing request you have sent that have yet to be accepted or denied.
account.list_outgoing_request(pubkey).unwrap();
You would be able to view all incoming and outgoing request regardless of their status.
account.list_all_request(pubkey).unwrap();
You would be able to remove a friend from your friend list.
account.remove_friend(pubkey).unwrap();
You would be able to block a friend from your friend list. Note: This functionality is not implemented but currently a placeholder
account.block_friend(pubkey).unwrap();
This will list all your friends, returning their Identity
.
account.list_friends().unwrap()
You would be able to check to determine if you are friends with somebody. Will return true if you are friends and false if you are not.
account.has_friend(pubkey)