Skip to content

Latest commit

 

History

History
165 lines (103 loc) · 4.22 KB

solana.md

File metadata and controls

165 lines (103 loc) · 4.22 KB

Solana MultiPass Extension Overview

Importing extension into cargo project

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"] }

Starting Extension

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);

Creating a new account

With a username

    account.create_identity(Some("NewAcctName"), None).unwrap();

Without a username

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.

Fetching Account

Your own

    let ident = account.get_own_identity().unwrap();

By Public Key

    let ident = account.get_identity(Identifier::public_key(PublicKey::from_bytes(....))).unwrap()

By Username

At this time, fetching by username is only available to find accounts that are cached that were previously looked up via public key.

Getting private 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.

Sending/Receiving Friend Request and Managing Friends List

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()

Sending a Friend Request

You can send a friend request with anybody who has an solana account.

    account.send_request(pubkey).unwrap();

Accept a Friend Request

You can accept a friend request sent to you.

    account.accept_request(pubkey).unwrap();

Deny a Friend Request

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();

Close a Friend Request

    account.close_request(pubkey).unwrap();

List Incoming Request

This would allow you to view all incoming request that are pending acceptance or denial.

    account.list_incoming_request(pubkey).unwrap();    

List Outgoing Request

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();

List All Request

You would be able to view all incoming and outgoing request regardless of their status.

    account.list_all_request(pubkey).unwrap();

Remove Friend

You would be able to remove a friend from your friend list.

    account.remove_friend(pubkey).unwrap();

Block Friend

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();

List Current Friends

This will list all your friends, returning their Identity.

    account.list_friends().unwrap()

Check Friendship Status

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)