Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(infura): allow DID reg to take in Infura config #638

Merged
merged 6 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/api/classes/modules_did_registry.DidRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ didRegistry.getDidDocument();

### constructor

• **new DidRegistry**(`_signerService`, `_cacheClient`, `_assetsService`, `_ipfsUrl?`)
• **new DidRegistry**(`_signerService`, `_cacheClient`, `_assetsService`, `_ipfsConfig`)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `_signerService` | [`SignerService`](modules_signer.SignerService.md) | `undefined` |
| `_cacheClient` | [`CacheClient`](modules_cache_client.CacheClient.md) | `undefined` |
| `_assetsService` | [`AssetsService`](modules_assets.AssetsService.md) | `undefined` |
| `_ipfsUrl` | `string` | `'https://ipfs.infura.io:5001/api/v0/'` |
| Name | Type |
| :------ | :------ |
| `_signerService` | [`SignerService`](modules_signer.SignerService.md) |
| `_cacheClient` | [`CacheClient`](modules_cache_client.CacheClient.md) |
| `_assetsService` | [`AssetsService`](modules_assets.AssetsService.md) |
| `_ipfsConfig` | [`IpfsConfig`](../interfaces/modules_did_registry.IpfsConfig.md) |

## Accessors

Expand Down Expand Up @@ -462,7 +462,7 @@ ___

### connect

▸ `Static` **connect**(`signerService`, `cacheClient`, `assetsService`, `ipfsUrl?`): `Promise`<[`DidRegistry`](modules_did_registry.DidRegistry.md)\>
▸ `Static` **connect**(`signerService`, `cacheClient`, `assetsService`, `ipfsConfig`): `Promise`<[`DidRegistry`](modules_did_registry.DidRegistry.md)\>

#### Parameters

Expand All @@ -471,7 +471,7 @@ ___
| `signerService` | [`SignerService`](modules_signer.SignerService.md) |
| `cacheClient` | [`CacheClient`](modules_cache_client.CacheClient.md) |
| `assetsService` | [`AssetsService`](modules_assets.AssetsService.md) |
| `ipfsUrl?` | `string` |
| `ipfsConfig` | [`IpfsConfig`](../interfaces/modules_did_registry.IpfsConfig.md) |

#### Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/api/interfaces/modules_claims.IssueClaimOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ___

• `Optional` **expirationTimestamp**: `number`

Defines how long the claim is valid.
Defines how long the claim is valid (milliseconds)

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ___

• `Optional` **expirationTimestamp**: `number`

Defines how long the claim is valid.
Defines how long the claim is valid (seconds).

___

Expand Down
36 changes: 36 additions & 0 deletions docs/api/interfaces/modules_did_registry.IpfsConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Interface: IpfsConfig

[modules/did-registry](../modules/modules_did_registry.md).IpfsConfig

## Table of contents

### Properties

- [headers](modules_did_registry.IpfsConfig.md#headers)
- [host](modules_did_registry.IpfsConfig.md#host)
- [port](modules_did_registry.IpfsConfig.md#port)
- [protocol](modules_did_registry.IpfsConfig.md#protocol)

## Properties

### headers

• `Optional` **headers**: `Record`<`string`, `any`\>

___

### host

• **host**: `string`

___

### port

• `Optional` **port**: `number`

___

### protocol

• `Optional` **protocol**: `string`
28 changes: 14 additions & 14 deletions docs/api/modules/init.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/api/modules/modules_did_registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [GetDidDelegatesOptions](../interfaces/modules_did_registry.GetDidDelegatesOptions.md)
- [GetDidPublicKeysOptions](../interfaces/modules_did_registry.GetDidPublicKeysOptions.md)
- [GetServicesOptions](../interfaces/modules_did_registry.GetServicesOptions.md)
- [IpfsConfig](../interfaces/modules_did_registry.IpfsConfig.md)
- [IssuePublicClaimOptions](../interfaces/modules_did_registry.IssuePublicClaimOptions.md)
- [Profile](../interfaces/modules_did_registry.Profile.md)
- [UpdateDocumentOptions](../interfaces/modules_did_registry.UpdateDocumentOptions.md)
Expand Down
6 changes: 5 additions & 1 deletion e2e/cache-client.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { initWithPrivateKeySigner, setCacheConfig } from '../src';
import { shutDownIpfsDaemon, spawnIpfsDaemon } from './utils/setup-ipfs';

const rpcUrl = 'https://volta-rpc.energyweb.org';
const privateKey = '';
Expand All @@ -18,7 +19,9 @@ describe.skip('Cache client', () => {
);
const { connectToDidRegistry, assetsService } =
await connectToCacheServer();
const { claimsService, didRegistry } = await connectToDidRegistry();
const { claimsService, didRegistry } = await connectToDidRegistry(
await spawnIpfsDaemon()
);

const assetAddress = await assetsService.registerAsset();
const assetDid = `did:ethr:volta:${assetAddress}`;
Expand All @@ -41,5 +44,6 @@ describe.skip('Cache client', () => {
expect(s).toEqual(expect.objectContaining(metadata))
)
);
await shutDownIpfsDaemon();
}, 120000);
});
79 changes: 52 additions & 27 deletions e2e/claim-revocation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { replenish, root, rpcUrl, setupENS } from './utils/setup-contracts';
import { setLogger } from '../src/config/logger.config';
import { ConsoleLogger } from '../src/utils/logger';
import { addressOf } from '@ew-did-registry/did-ethr-resolver';
import { shutDownIpfsDaemon, spawnIpfsDaemon } from './utils/setup-ipfs';

const { id } = utils;

Expand Down Expand Up @@ -73,18 +74,22 @@ jest.mock('../src/modules/messaging/messaging.service', () => {
};
});

afterEach(async () => {
await shutDownIpfsDaemon();
});

describe('On-chain claim revocation', () => {
const rootOwner = Wallet.createRandom().connect(provider);

const initUser = async () => {
const initUser = async (ipfs) => {
const user = Wallet.createRandom().connect(provider);
await replenish(user.address);

const { signerService, messagingService, connectToCacheServer } =
await initWithPrivateKeySigner(user.privateKey, rpcUrl);
const { connectToDidRegistry, domainsService, assetsService } =
await connectToCacheServer();
const { didRegistry, claimsService } = await connectToDidRegistry();
const { didRegistry, claimsService } = await connectToDidRegistry(ipfs);

await signerService.publicKeyAndIdentityToken();

Expand Down Expand Up @@ -178,8 +183,9 @@ describe('On-chain claim revocation', () => {
});

test('revoke claim, revoke type DID, issuer is revoker', async () => {
const issuer = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -219,9 +225,10 @@ describe('On-chain claim revocation', () => {
});

test('revoke claim, revoke type DID, issuer is not revoker', async () => {
const issuer = await initUser();
const subject = await initUser();
const revoker = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const revoker = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -261,9 +268,10 @@ describe('On-chain claim revocation', () => {
});

test('throw an error when revoker is not authorized', async () => {
const issuer = await initUser();
const subject = await initUser();
const revoker = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const revoker = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -299,8 +307,9 @@ describe('On-chain claim revocation', () => {
});

test('throw an error when claim not found', async () => {
const issuer = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';

await createRole(
Expand All @@ -324,8 +333,9 @@ describe('On-chain claim revocation', () => {
});

test('revoke claim, revoke type DID, claim id', async () => {
const issuer = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -370,8 +380,9 @@ describe('On-chain claim revocation', () => {
});

test('should throw an error when claim id not found', async () => {
const issuer = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -404,8 +415,13 @@ describe('On-chain claim revocation', () => {
});

test('revoke multiple claim, revoke type DID', async () => {
const issuer = await initUser();
const subjects = [await initUser(), await initUser(), await initUser()];
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subjects = [
await initUser(ipfs),
await initUser(ipfs),
await initUser(ipfs),
];
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -474,8 +490,13 @@ describe('On-chain claim revocation', () => {
});

test('revoke multiple claim, revoke type DID, claim id', async () => {
const issuer = await initUser();
const subjects = [await initUser(), await initUser(), await initUser()];
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subjects = [
await initUser(ipfs),
await initUser(ipfs),
await initUser(ipfs),
];
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -527,8 +548,9 @@ describe('On-chain claim revocation', () => {
});

test('revocation details should match data', async () => {
const issuer = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';

const { roleDefinition } = await createRole(
Expand Down Expand Up @@ -568,7 +590,8 @@ describe('On-chain claim revocation', () => {
});

test('should result with undefined when claim was not revoked', async () => {
const issuer = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const roleName = 'test1';

await createRole(
Expand All @@ -594,9 +617,10 @@ describe('On-chain claim revocation', () => {
});

test('revoke claim, revoke type ROLE, issuer is revoker', async () => {
const issuer = await initUser();
const revoker = await initUser();
const subject = await initUser();
const ipfs = await spawnIpfsDaemon();
const issuer = await initUser(ipfs);
const revoker = await initUser(ipfs);
const subject = await initUser(ipfs);
const roleName = 'test1';
const revokerRoleName = 'test1';

Expand Down Expand Up @@ -639,7 +663,8 @@ describe('On-chain claim revocation', () => {
});

test('should throw an error when two params missing', async () => {
const revoker = await initUser();
const ipfs = await spawnIpfsDaemon();
const revoker = await initUser(ipfs);
await expect(revoker.claimsService.revokeClaim({})).rejects.toThrow();
});
});
Loading