@communitiesid/resolver
v0.0.8
Published
``` npm i @communitiesid/resolver ```
Downloads
1
Readme
Communities ID Resolver
Install
npm i @communitiesid/resolver
Usage
Initialze
import CommunitiesIDResolver from '@communitiesid/resolver';
const options: CommunitiesIDResolverInput = {
goerli: {
RPCUrl: "https://goerli.blockpi.network/v1/rpc/public",
alchemyKey: "<your alchemy key for goerli network>",
generateSigner: provider => new ethers.Wallet('<your private key>', provider)
},
mumbai: {
RPCUrl: "https://polygon-mumbai.blockpi.network/v1/rpc/public",
alchemyKey: "<your alchemy key for polygon mumbai network>",
generateSigner: provider => new ethers.Wallet('<your private key>', provider)
}
}
const resolver = new CommunitiesIDResolver(options);
Input
|Name|Type|Description|required| |---|---|---|---| |goerli.RPCUrl|string|The RPC url for goerli network|true| |goerli.alchemyKey|string|The Alchemy key for goerli network|true| |goerli.generateSigner|(provider: ethers.providers.Provider) => ethers.Signer|The function to generate signer, if not set, some write method (like mint) will fail |false| |mombai.RPCUrl|string|The RPC url for mombai network|true| |mombai.alchemyKey|string|The Alchemy key for mombai network|true| |mombai.generateSigner|(provider: ethers.providers.Provider) => ethers.Signer|The function to generate signer, if not set, some write method (like mint) will fail |false|
Methods
searchCommunity
Get the community info by name
Input:
|Name|Type|Description|required| |---|---|---|---| |name|string|The name of the community|true|
Output: Promise<Community | null>
Example:
const res = await resolver.searchCommunity('did')
searchMember
Get the member info by name
Input:
|Name|Type|Description|required|
|---|---|---|---|
|name|string|The name of the member, the format should be ${member}.${community}
|true|
Output: Promise<Member | null>
Example:
const res = await resolver.searchMember('a.did')
getOwnerOfMember
Get the owner of a member
Input:
|Name|Type|Description|required|
|---|---|---|---|
|name|string|The name of the member, the format should be ${member}.${community}
|true|
Output: Promise<string | null>
Example:
const res = await resolver.getOwnerOfMember('a.did')
getPrimaryDID
Get primary did of an address
Input:
|Name|Type|Description|required| |---|---|---|---| |address|string|The address of the member|true|
Output: Promise<string | null>
Example:
const res = await resolver.getPrimaryDID('0x0000000000000000000000000000000000000000')
getAllCommunities
Get all communities in specific chain
Input:
|Name|Type|Description|required| |---|---|---|---| |chain|'goerli' | 'mumbai'|The chain that you want to get communities|true|
Output: Promise<object[]>
Example:
const res = await resolver.getAllCommunities('goerli')
getAllCommunitiesOwnedByAddress
Get all communities owned by an address in specific chain
Input:
|Name|Type|Description|required| |---|---|---|---| |address|string|The address you want to get communities|true| |chain|'goerli' | 'mumbai'|The chain that you want to get communities|true|
Output: Promise<object[]>
Example:
const res = await resolver.getAllCommunitiesOwnedByAddress('0x0000000000000000000000000000000000000000', 'goerli')
getAllMembersOwnedByAddress
Get all members owned by an address in specific chain
Input:
|Name|Type|Description|required| |---|---|---|---| |address|string|The address you want to get members|true| |chain|'goerli' | 'mumbai'|The chain that you want to get members|true|
Output: Promise<object[]>
Example:
const res = await resolver.getAllMembersOwnedByAddress('0x0000000000000000000000000000000000000000', 'goerli')
getAllCommunitiesJoinedByAddress
Get all communities joined by an address in specific chain
Input:
|Name|Type|Description|required| |---|---|---|---| |address|string|The address you want to get communities|true| |chain|'goerli' | 'mumbai'|The chain that you want to get communities|true|
Output: Promise<object[]>
Example:
const res = await resolver.getAllCommunitiesJoinedByAddress('0x0000000000000000000000000000000000000000', 'goerli')
getAllMembersOwnedByCommunity
Get all members under specific community
Input:
|Name|Type|Description|required| |---|---|---|---| |name|string|TThe name of the community, if registry and chain is provided, the name will be ignored, and the query efficiency will improve|true| |registry|string|The registry of this community|false| |chain|'goerli' | 'mumbai'|The chain this community is on|false|
Output: Promise<object[]>
Example:
const res = await resolver.getAllMembersOwnedByCommunity('did')
const res = await resolver.getAllMembersOwnedByCommunity('', '0x123', 'mumbai')
mintMember
Mint a member (This is a write method, the generateSigner function of the chain which this member on is required)
Input:
|Name|Type|Description|required| |---|---|---|---| |name|string|The name of the member|true| |address|string|The address that you want to mint this member to|true| |years|number|How many years do you want to mint|false, default 1 year|
Example:
const res = await resolver.mintMember('test.did', '0x123456')
updateMember
Update the info of specific member (This is a write method, the generateSigner function of the chain which this member on is required)
Input:
|Name|Type|Description|required| |---|---|---|---| |name|string|The name of the member|true| |data|UpdateMemberInput|The data you want to update|true|
Example:
const res = await resolver.updateMember('test.did', {
description: 'test description',
twitter: 'twi',
discord: 'dis',
telegram: 'tel',
externalUrl: 'https://google.com'
})