diff --git a/e2e/claims.service.e2e.ts b/e2e/claims.service.e2e.ts index 75a01d01..b51a8959 100644 --- a/e2e/claims.service.e2e.ts +++ b/e2e/claims.service.e2e.ts @@ -1,5 +1,5 @@ import { IRoleDefinition, PreconditionType } from "@energyweb/iam-contracts"; -import { Methods } from "@ew-did-registry/did"; +import { Methods, Chain } from "@ew-did-registry/did"; import { addressOf } from "@ew-did-registry/did-ethr-resolver"; import { KeyTags } from "@ew-did-registry/did-resolver-interface"; import { ethers, providers, utils, Wallet } from "ethers"; @@ -25,11 +25,11 @@ const { namehash } = utils; const provider = new providers.JsonRpcProvider(rpcUrl); const staticIssuer = Wallet.createRandom().connect(provider); -const staticIssuerDID = `did:${Methods.Erc1056}:volta:${staticIssuer.address}`; +const staticIssuerDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${staticIssuer.address}`; const dynamicIssuer = Wallet.createRandom().connect(provider); -const dynamicIssuerDID = `did:${Methods.Erc1056}:volta:${dynamicIssuer.address}`; +const dynamicIssuerDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${dynamicIssuer.address}`; const rootOwner = Wallet.createRandom().connect(provider); -const rootOwnerDID = `did:${Methods.Erc1056}:volta:${rootOwner.address}`; +const rootOwnerDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${rootOwner.address}`; const roleName1 = "myrole1"; const roleName2 = "myrole2"; const roleName3 = "myrole3"; @@ -67,7 +67,7 @@ const mockGetRoleDefinition = jest.fn().mockImplementation((namespace: string) = return roles[namespace]; }); const mockGetDidDocument = jest.fn().mockImplementation((did: string) => { - return { publicKey: [{ id: `did:ethr:volta:${did}-${KeyTags.OWNER}` }] }; // all documents are created + return { publicKey: [{ id: `did:${Methods.Erc1056}:${Chain.VOLTA}:${did}-${KeyTags.OWNER}` }] }; // all documents are created }); const mockGetAssetById = jest.fn(); const mockGetClaimsBySubject = jest.fn(); @@ -212,7 +212,7 @@ describe("Enrollment claim tests", () => { mockGetAssetById.mockImplementationOnce(({ id }: { id: string }) => ({ id })); await signerService.connect(rootOwner, ProviderType.PrivateKey); const assetAddress = await assetsService.registerAsset(); - const assetDID = `did:${Methods.Erc1056}:volta:${assetAddress}`; + const assetDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${assetAddress}`; await enrolAndIssue(rootOwner, staticIssuer, { subjectDID: assetDID, claimType: `${roleName1}.${root}` }); return expect(claimsService.hasOnChainRole(assetDID, `${roleName1}.${root}`, version)).resolves.toBe(true); diff --git a/e2e/domains.service.e2e.ts b/e2e/domains.service.e2e.ts index 5241cbcc..ccc14d86 100644 --- a/e2e/domains.service.e2e.ts +++ b/e2e/domains.service.e2e.ts @@ -1,6 +1,6 @@ import { utils, Wallet } from "ethers"; import { IRoleDefinition, PreconditionType } from "@energyweb/iam-contracts"; -import { Methods } from "@ew-did-registry/did"; +import { Methods, Chain } from "@ew-did-registry/did"; import { DomainsService, initWithPrivateKeySigner, @@ -92,7 +92,7 @@ describe("Domains service", () => { issuerFields: [], issuer: { issuerType: "DID", - did: [`did:${Methods.Erc1056}:volta:${rootOwner.address}`], + did: [`did:${Methods.Erc1056}:${Chain.VOLTA}:${rootOwner.address}`], }, metadata: [], roleName, diff --git a/e2e/staking-pool.e2e.ts b/e2e/staking-pool.e2e.ts index 355afe61..921d90fd 100644 --- a/e2e/staking-pool.e2e.ts +++ b/e2e/staking-pool.e2e.ts @@ -1,4 +1,5 @@ import { KeyTags } from "@ew-did-registry/did-resolver-interface"; +import { Chain } from "@ew-did-registry/did"; import { BigNumber, providers, utils, Wallet } from "ethers"; import { chainConfigs, @@ -32,7 +33,7 @@ jest.mock("../src/modules/messaging/messaging.service", () => { const mockGetRoleDefinition = jest.fn(); const mockGetDidDocument = jest.fn().mockImplementation(({ did }: { did: string }) => { - return { publicKey: [{ id: `did:ethr:volta:${did}-${KeyTags.OWNER}` }] }; + return { publicKey: [{ id: `did:ethr:${Chain.VOLTA}:${did}-${KeyTags.OWNER}` }] }; }); const mockGetApplicationsByOrgNamespace = jest.fn(); @@ -83,7 +84,7 @@ export const setupStakingPoolFactory = async () => { value: rewards, }); - setChainConfig(chainId, { stakingPoolFactoryAddress: stakingPoolFactory.address, chainName: "volta" }); + setChainConfig(chainId, { stakingPoolFactoryAddress: stakingPoolFactory.address, chainName: Chain.VOLTA }); }; const putStake = async (pool: StakingPoolService, amount: number | BigNumber, withAmountCheck = true) => { diff --git a/e2e/staking.pool.e2e.ts b/e2e/staking.pool.e2e.ts index dab56d12..25c8fabc 100644 --- a/e2e/staking.pool.e2e.ts +++ b/e2e/staking.pool.e2e.ts @@ -1,5 +1,5 @@ import { IRoleDefinition } from "@energyweb/iam-contracts"; -import { Methods } from "@ew-did-registry/did"; +import { Methods, Chain } from "@ew-did-registry/did"; import { KeyTags } from "@ew-did-registry/did-resolver-interface"; import { BigNumber, providers, utils, Wallet } from "ethers"; @@ -28,9 +28,9 @@ const patronRole = "patronrole"; const provider = new providers.JsonRpcProvider(rpcUrl); const rootOwner = Wallet.createRandom().connect(provider); const orgOwner = Wallet.createRandom().connect(provider); -const orgOwnerDid = `did:${Methods.Erc1056}:volta:${orgOwner.address}`; +const orgOwnerDid = `did:${Methods.Erc1056}:${Chain.VOLTA}:${orgOwner.address}`; const patron = Wallet.createRandom().connect(provider); -const patronDID = `did:${Methods.Erc1056}:volta:${patron.address}`; +const patronDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${patron.address}`; MessagingService.create = (signerService: SignerService) => Promise.resolve(new MessagingService(signerService)); const mockPublish = jest.fn(); jest.mock("../src/modules/messaging/messaging.service", () => { @@ -43,7 +43,7 @@ jest.mock("../src/modules/messaging/messaging.service", () => { const mockGetRoleDefinition = jest.fn(); const mockGetDidDocument = jest.fn().mockImplementation(({ did }: { did: string }) => { - return { publicKey: [{ id: `did:ethr:volta:${did}-${KeyTags.OWNER}` }] }; + return { publicKey: [{ id: `did:${Methods.Erc1056}:${Chain.VOLTA}:${did}-${KeyTags.OWNER}` }] }; }); const mockGetApplicationsByOrgNamespace = jest.fn(); const mockRequestClaim = jest.fn(); diff --git a/e2e/staking.service.e2e.ts b/e2e/staking.service.e2e.ts index 42a93bc0..533cbaa0 100644 --- a/e2e/staking.service.e2e.ts +++ b/e2e/staking.service.e2e.ts @@ -1,6 +1,6 @@ import { providers, Wallet } from "ethers"; import { IRoleDefinition } from "@energyweb/iam-contracts"; -import { Methods } from "@ew-did-registry/did"; +import { Methods, Chain } from "@ew-did-registry/did"; import { KeyTags } from "@ew-did-registry/did-resolver-interface"; import { StakingService } from "../src/modules/staking/staking.service"; import { ProviderType } from "../src/modules/signer/signer.types"; @@ -21,9 +21,9 @@ const domain = `${orgName}.${root}`; const provider = new providers.JsonRpcProvider(rpcUrl); const rootOwner = Wallet.createRandom().connect(provider); const orgOwner = Wallet.createRandom().connect(provider); -const orgOwnerDid = `did:${Methods.Erc1056}:volta:${orgOwner.address}`; +const orgOwnerDid = `did:${Methods.Erc1056}:${Chain.VOLTA}:${orgOwner.address}`; const patron = Wallet.createRandom().connect(provider); -const patronDID = `did:${Methods.Erc1056}:volta:${patron.address}`; +const patronDID = `did:${Methods.Erc1056}:${Chain.VOLTA}:${patron.address}`; MessagingService.create = (signerService: SignerService) => Promise.resolve(new MessagingService(signerService)); const mockPublish = jest.fn(); @@ -37,7 +37,7 @@ jest.mock("../src/modules/messaging/messaging.service", () => { const mockGetRoleDefinition = jest.fn(); const mockGetDidDocument = jest.fn().mockImplementation(({ did }: { did: string }) => { - return { publicKey: [{ id: `did:ethr:volta:${did}-${KeyTags.OWNER}` }] }; + return { publicKey: [{ id: `did:${Methods.Erc1056}:${Chain.VOLTA}:${did}-${KeyTags.OWNER}` }] }; }); const mockGetApplicationsByOrgNamespace = jest.fn(); const mockRequestClaim = jest.fn(); diff --git a/e2e/utils/setup_contracts.ts b/e2e/utils/setup_contracts.ts index af307abd..a6cad27d 100644 --- a/e2e/utils/setup_contracts.ts +++ b/e2e/utils/setup_contracts.ts @@ -1,5 +1,6 @@ import { ContractFactory, Contract, providers, utils, BigNumber } from "ethers"; import { ethrReg } from "@ew-did-registry/did-ethr-resolver"; +import { Chain } from "@ew-did-registry/did"; import { DomainNotifier__factory } from "../../ethers/factories/DomainNotifier__factory"; import type { DomainNotifier } from "../../ethers/DomainNotifier"; import { RoleDefinitionResolver__factory } from "../../ethers/factories/RoleDefinitionResolver__factory"; @@ -79,7 +80,7 @@ export const setupENS = async (rootOwner: string) => { const { chainId } = await provider.getNetwork(); setChainConfig(chainId, { rpcUrl, - chainName: "volta", + chainName: Chain.VOLTA, ensRegistryAddress: ensRegistry.address, ensResolverAddress: ensResolver.address, didRegistryAddress: didRegistry.address, diff --git a/e2e/utils/staking.ts b/e2e/utils/staking.ts index 93bdf22e..4b99360a 100644 --- a/e2e/utils/staking.ts +++ b/e2e/utils/staking.ts @@ -2,6 +2,7 @@ import { BigNumber, utils } from "ethers"; import { deployer, replenish } from "./setup_contracts"; import { StakingPoolFactory__factory } from "../../ethers/factories/StakingPoolFactory__factory"; import { chainConfigs, setChainConfig } from "../../src/config/chain.config"; +import { Chain } from "@ew-did-registry/did"; const { parseEther } = utils; @@ -21,7 +22,7 @@ export async function setupStakingPoolFactory(withdrawDelay = defaultWithdrawDel ).deployed(); const rewardPoolAddress = await stakingPoolFactory.rewardPool(); await replenish(rewardPoolAddress); - setChainConfig(chainId, { stakingPoolFactoryAddress: stakingPoolFactory.address, chainName: "volta" }); + setChainConfig(chainId, { stakingPoolFactoryAddress: stakingPoolFactory.address, chainName: Chain.VOLTA }); } export const calculateReward = ( diff --git a/src/config/chain.config.ts b/src/config/chain.config.ts index f535e00a..13cad79a 100644 --- a/src/config/chain.config.ts +++ b/src/config/chain.config.ts @@ -1,4 +1,5 @@ import { VoltaAddress1056 } from "@ew-did-registry/did-ethr-resolver"; +import { Chain } from "@ew-did-registry/did"; import { VOLTA_DOMAIN_NOTIFER_ADDRESS, VOLTA_ENS_REGISTRY_ADDRESS, @@ -32,7 +33,7 @@ export type ChainId = number; */ const chainConfig: Record = { [VOLTA_CHAIN_ID]: { - chainName: "volta", + chainName: Chain.VOLTA, chainDisplayName: "Energy Web Volta Testnet", rpcUrl: "https://volta-rpc.energyweb.org", ensRegistryAddress: VOLTA_ENS_REGISTRY_ADDRESS,