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

Release/sdk v1.0.4 #154

Merged
merged 10 commits into from
Aug 8, 2024
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [1.0.4] (2024-08-08)

### Added

- support for ethers `AbstractProvider` and `AbstractSigner` in constructor

### Changed

- update `kubo-rpc-client` from v3 to v4
- update `iexec` and `ethers` dependencies

## [1.0.3]

### Changed
Expand Down
1,219 changes: 837 additions & 382 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iexec/web3mail",
"version": "1.0.3",
"version": "1.0.4",
"description": "This product enables users to confidentially store data–such as mail address, documents, personal information ...",
"main": "./dist/index.js",
"type": "module",
Expand Down Expand Up @@ -45,10 +45,10 @@
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/random": "^5.7.0",
"buffer": "^6.0.3",
"ethers": "^6.8.1",
"ethers": "^6.13.2",
"graphql-request": "^6.1.0",
"iexec": "^8.9.1",
"kubo-rpc-client": "^3.0.1",
"iexec": "^8.10.0",
"kubo-rpc-client": "^4.1.1",
"yup": "^1.1.1"
},
"devDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions src/web3mail/IExecWeb3mail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Eip1193Provider } from 'ethers';
import { AbstractProvider, AbstractSigner, Eip1193Provider } from 'ethers';
import { IExec } from 'iexec';
import { fetchUserContacts } from './fetchUserContacts.js';
import { fetchMyContacts } from './fetchMyContacts.js';
Expand Down Expand Up @@ -39,7 +39,12 @@ export class IExecWeb3mail {
private graphQLClient: GraphQLClient;

constructor(
ethProvider?: Eip1193Provider | Web3SignerProvider | string,
ethProvider?:
| Eip1193Provider
| AbstractProvider
| AbstractSigner
| Web3SignerProvider
| string,
options?: Web3MailConfigOptions
) {
try {
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/fetchMyContacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getTestConfig,
getTestWeb3SignerProvider,
getTestIExecOption,
waitSubgraphIndexing,
} from '../test-utils.js';
import IExec from 'iexec/IExec';

Expand All @@ -31,6 +32,7 @@ describe('web3mail.fetchMyContacts()', () => {
data: { email: '[email protected]' },
name: 'test do not use',
});
await waitSubgraphIndexing();
}, 2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME);

it(
Expand Down Expand Up @@ -119,6 +121,7 @@ describe('web3mail.fetchMyContacts()', () => {
data: { notemail: 'not email' },
name: 'test do not use',
});
await waitSubgraphIndexing();

await dataProtector.grantAccess({
authorizedApp: WEB3_MAIL_DAPP_ADDRESS,
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/fetchUserContacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
MAX_EXPECTED_BLOCKTIME,
MAX_EXPECTED_WEB2_SERVICES_TIME,
getTestConfig,
waitSubgraphIndexing,
} from '../test-utils.js';

describe('web3mail.fetchMyContacts()', () => {
Expand All @@ -33,6 +34,7 @@ describe('web3mail.fetchMyContacts()', () => {
data: { email: '[email protected]' },
name: 'test do not use',
});
await waitSubgraphIndexing();
}, 4 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME);

it(
Expand Down
11 changes: 6 additions & 5 deletions tests/e2e/sendEmail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getTestConfig,
getTestIExecOption,
getTestWeb3SignerProvider,
sleep,
waitSubgraphIndexing,
} from '../test-utils.js';
import { IExec } from 'iexec';

Expand Down Expand Up @@ -83,10 +83,8 @@ describe('web3mail.sendEmail()', () => {
data: { foo: 'bar' },
name: 'test do not use',
});

await waitSubgraphIndexing();
web3mail = new IExecWeb3mail(...getTestConfig(consumerWallet.privateKey));
// avoid race condition with subgraph indexation
await sleep(5_000);
}, 4 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME + 5_000);

it(
Expand All @@ -112,6 +110,8 @@ describe('web3mail.sendEmail()', () => {
data: { email: '[email protected]' },
name: 'test do not use',
});
await waitSubgraphIndexing();

//grant access to whitelist
await dataProtector.grantAccess({
authorizedApp: WHITELIST_SMART_CONTRACT_ADDRESS, //whitelist address
Expand Down Expand Up @@ -176,13 +176,14 @@ describe('web3mail.sendEmail()', () => {
data: { email: '[email protected]' },
name: 'test do not use',
});
await waitSubgraphIndexing();

const params = {
emailSubject: 'e2e mail object for test',
emailContent: 'e2e mail content for test',
protectedData: protectedData.address,
workerpoolAddressOrEns: workerpoolAddress,
};
await sleep(5_000);
await expect(web3mail.sendEmail(params)).rejects.toThrow(
new WorkflowError({
message: 'Failed to sendEmail',
Expand Down
2 changes: 2 additions & 0 deletions tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { randomInt } from 'crypto';

export const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms));

export const waitSubgraphIndexing = () => sleep(5_000);

export const getRequiredFieldMessage = (field: string = 'this') =>
`${field} is a required field`;

Expand Down