- Registry Table of Contents
- Registry
- Initialization
- Read Functions
- Get Allo Owner
- Get Default Admin Role
- Get Native
- Get Anchor To Profile Id
- Get Profile By Anchor
- Get Profile By ID
- Get Role Admin
- Check Role Membership
- Check Membership in Profile
- Check Ownership of Profile
- Check Ownership or Membership in Profile
- Get Profile ID to Pending Owner
- Get Profile Details by ID
- Write Functions
The Registry class provides a set of functions for interacting with the Registry contract's view and write functions. This README provides examples and explanations for using these functions.
Before using the functions provided by the Registry module, you need to create an instance of the Registry class. Here's how you can create a Registry instance:
To create a new Registry instance, you need to provide the chain information. In this example, we're using the 5 chain information.
import { Registry } from "@allo-team/allo-v2-sdk/";
const registry = new Registry({ chain: 5 });
This registry instance can then be used to call various read and transactional functions provided by the Registry module. Refer to the sections above for detailed examples on how to use these functions. Remember to replace placeholder values with actual values according to your requirements.
To retrieve the Allo Owner:
const alloOwner: string = await registry.getAlloOwner();
console.log(alloOwner);
To get the Default Admin Role:
const defaultAdminRole: string = await registry.getDefaultAdminRole();
console.log(defaultAdminRole);
To obtain the Native:
const native: string = await registry.getNative();
console.log(native);
To retrieve the Profile ID associated with an Anchor:
const anchor = "your_anchor_value_here";
const profileId: string = await registry.getAnchorToProfileId(anchor);
console.log(profileId);
To fetch a Profile using an Anchor:
import { Profile } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const anchor = "your_anchor_value_here";
const profile: Profile = await registry.getProfileByAnchor(anchor);
console.log(profile);
To retrieve a Profile using its ID:
import { Profile } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileId = "your_profile_id_here";
const profile: Profile = await registry.getProfileById(profileId);
console.log(profile);
To get the admin of a specified role:
const role = "your_role_here";
const admin: string = await registry.getRoleAdmin(role);
console.log(admin);
To check if an account has a specific role:
import { HasRoleArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const hasRoleArgs: HasRoleArgs = {
role: "your_role_here",
account: "account_address_here",
};
const hasRole: boolean = await registry.hasRole(hasRoleArgs);
console.log(hasRole);
To check if an account is a member of a profile:
import { ProfileAndAddressArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileAndAddressArgs: ProfileAndAddressArgs = {
profileId: "your_profile_id_here",
account: "account_address_here",
};
const isMember: boolean = await registry.isMemberOfProfile(
profileAndAddressArgs,
);
console.log(isMember);
To check if an account is the owner of a profile:
import { ProfileAndAddressArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileAndAddressArgs: ProfileAndAddressArgs = {
profileId: "your_profile_id_here",
account: "account_address_here",
};
const isOwner: boolean = await registry.isOwnerOfProfile(profileAndAddressArgs);
console.log(isOwner);
To check if an account is either the owner or a member of a profile:
import { ProfileAndAddressArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileAndAddressArgs: ProfileAndAddressArgs = {
profileId: "your_profile_id_here",
account: "account_address_here",
};
const isOwnerOrMember: boolean = await registry.isOwnerOrMemberOfProfile(
profileAndAddressArgs,
);
console.log(isOwnerOrMember);
To get the pending owner of a profile:
const profileId = "your_profile_id_here";
const pendingOwner: string = await registry.getProfileIdToPendingOwner(
profileId,
);
console.log(pendingOwner);
To get profile details by ID:
import { Profile } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileId = "your_profile_id_here";
const profile: Profile = await registry.getProfilesById(profileId);
console.log(profile);
To create a new profile using the createProfile
function:
import { CreateProfileArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const createProfileArgs: CreateProfileArgs = {
nonce: 3,
name: "Module Test 1",
metadata: {
protocol: BigInt(1),
pointer: "bafybeia4khbew3r2mkflyn7nzlvfzcb3qpfeftz5ivpzfwn77ollj47gqi",
},
owner: "0xE7eB5D2b5b188777df902e89c54570E7Ef4F59CE",
members: [
"0x5cdb35fADB8262A3f88863254c870c2e6A848CcA",
"0xE7eB5D2b5b188777df902e89c54570E7Ef4F59CE",
],
};
const txData: TransactionData = registry.createProfile(createProfileArgs);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
account,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To accept ownership of a profile using the acceptProfileOwnership
function:
const profileId = "your_profile_id_here";
const txData: TransactionData = registry.acceptProfileOwnership(profileId);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To add members to a profile using the addMembers
function:
import { MemberArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const memberArgs: MemberArgs = {
profileId: "your_profile_id_here",
members: [
"0xMemberAddress1",
"0xMemberAddress2",
// Add more member addresses if needed
],
};
const txData: TransactionData = registry.addMembers(memberArgs);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To remove members from a profile using the removeMembers
function:
import { MemberArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const memberArgs: MemberArgs = {
profileId: "your_profile_id_here",
members: [
"0xMemberAddress1",
"0xMemberAddress2",
// Add more member addresses if needed
],
};
const txData: TransactionData = registry.removeMembers(memberArgs);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update profile metadata using the updateProfileMetadata
function:
import { ProfileMetadataArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileMetadataArgs: ProfileMetadataArgs = {
profileId: "your_profile_id_here",
metadata: {
protocol: 2,
pointer: "bafybeia4khbew3r2mkflyn7nzlvfzcb3qpfeftz5ivpzfwn77ollj47gqi",
},
};
const txData: TransactionData =
registry.updateProfileMetadata(profileMetadataArgs);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update profile name using the updateProfileName
function:
import { ProfileNameArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profileNameArgs: ProfileNameArgs = {
profileId: "your_profile_id_here",
name: "New Profile Name",
};
const txData: TransactionData = registry.updateProfileName(profileNameArgs);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update the pending owner of a profile using the updateProfilePendingOwner
function:
import { ProfileAndAddressArgs } from "@allo-team/allo-v2-sdk/dist/Registry/types";
const profilePendingOwnerArgs: ProfileAndAddressArgs = {
profileId: "your_profile_id_here",
account: "new_pending_owner_address_here",
};
const txData: TransactionData = registry.updateProfilePendingOwner(
profilePendingOwnerArgs,
);
// Client could be from ethers, viem, etc..
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);