Skip to content

Commit

Permalink
feat: Add join_identity_as_key (#11)
Browse files Browse the repository at this point in the history
Description
To accept a request to be added as secondary to an existing and verified
account on polymesh the secondary account needs to submit the extrinsic
join_identity_as_key.

Implementation Details:
- Add identity pallet
- Add function join_identity_as_key to identity pallet
- Add `IDENTITY_PALLET_IDX` to `SubstrateNetwork` trait, default = 7
- Add `IDENTITY_JOIN_AS_KEY` to `SubstrateNetwork` trait, default = 5
  • Loading branch information
aidan46-crypto authored Aug 21, 2023
1 parent fb0f816 commit e1cd764
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub trait SubstrateNetwork: Clone + Copy + 'static {
const PROXY_REMOVE_PROXIES: u8 = 3;
type ProxyDelegateType: Encode + Decode + Clone + FromStr<Err = &'static str>;
type ProxyTypeType: Encode + Decode + Clone + FromStr<Err = &'static str>;

// Identity Pallet
const IDENTITY_PALLET_IDX: u8 = 7;
const IDENTITY_JOIN_AS_KEY: u8 = 5;
}

#[derive(Debug, Copy, Clone)]
Expand Down
1 change: 1 addition & 0 deletions src/pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::rpc::RpcClient;
use crate::{Era, GenericExtra, SignedPayload, UncheckedExtrinsic};

pub mod balances;
pub mod identity;
pub mod proxy;
pub mod staking;
pub mod storage;
Expand Down
18 changes: 18 additions & 0 deletions src/pallets/identity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::client::{Api, Result, Signer};
use crate::network::SubstrateNetwork;
use crate::pallets::CallIndex;
use crate::rpc::RpcClient;
use crate::UncheckedExtrinsic;

pub type ComposedJoinIdentity = (CallIndex, u64);

impl<S: Signer, Client: RpcClient, N: SubstrateNetwork> Api<'_, S, Client, N> {
pub fn join_identity_as_key(
&self,
auth_id: u64,
nonce: Option<u32>,
) -> Result<UncheckedExtrinsic<ComposedJoinIdentity>> {
let call = ([N::IDENTITY_PALLET_IDX, N::IDENTITY_JOIN_AS_KEY], auth_id);
self._create_xt(call, nonce)
}
}

0 comments on commit e1cd764

Please sign in to comment.