@iexec/web3mail 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -7
  2. package/dist/config/config.d.ts +6 -1
  3. package/dist/config/config.js +23 -12
  4. package/dist/config/config.js.map +1 -1
  5. package/dist/utils/getChainId.js +7 -2
  6. package/dist/utils/getChainId.js.map +1 -1
  7. package/dist/utils/getWeb3Provider.d.ts +10 -2
  8. package/dist/utils/getWeb3Provider.js +12 -7
  9. package/dist/utils/getWeb3Provider.js.map +1 -1
  10. package/dist/utils/resolveDappAddressFromCompass.d.ts +2 -2
  11. package/dist/utils/resolveDappAddressFromCompass.js +1 -1
  12. package/dist/utils/resolveDappAddressFromCompass.js.map +1 -1
  13. package/dist/utils/validators.d.ts +0 -2
  14. package/dist/utils/validators.js +0 -4
  15. package/dist/utils/validators.js.map +1 -1
  16. package/dist/web3mail/IExecWeb3mail.d.ts +2 -2
  17. package/dist/web3mail/IExecWeb3mail.js +13 -14
  18. package/dist/web3mail/IExecWeb3mail.js.map +1 -1
  19. package/dist/web3mail/fetchMyContacts.d.ts +1 -1
  20. package/dist/web3mail/fetchMyContacts.js +2 -2
  21. package/dist/web3mail/fetchMyContacts.js.map +1 -1
  22. package/dist/web3mail/fetchUserContacts.d.ts +1 -1
  23. package/dist/web3mail/fetchUserContacts.js +20 -25
  24. package/dist/web3mail/fetchUserContacts.js.map +1 -1
  25. package/dist/web3mail/internalTypes.d.ts +2 -2
  26. package/dist/web3mail/prepareEmailCampaign.d.ts +1 -1
  27. package/dist/web3mail/prepareEmailCampaign.js +10 -10
  28. package/dist/web3mail/prepareEmailCampaign.js.map +1 -1
  29. package/dist/web3mail/sendEmail.d.ts +1 -1
  30. package/dist/web3mail/sendEmail.js +21 -41
  31. package/dist/web3mail/sendEmail.js.map +1 -1
  32. package/dist/web3mail/sendEmail.models.d.ts +8 -27
  33. package/dist/web3mail/sendEmail.models.js +5 -28
  34. package/dist/web3mail/sendEmail.models.js.map +1 -1
  35. package/dist/web3mail/sendEmailCampaign.d.ts +1 -1
  36. package/dist/web3mail/sendEmailCampaign.js +8 -9
  37. package/dist/web3mail/sendEmailCampaign.js.map +1 -1
  38. package/dist/web3mail/types.d.ts +8 -11
  39. package/package.json +4 -4
  40. package/src/config/config.ts +26 -14
  41. package/src/utils/getChainId.ts +11 -2
  42. package/src/utils/getWeb3Provider.ts +13 -6
  43. package/src/utils/resolveDappAddressFromCompass.ts +3 -3
  44. package/src/utils/validators.ts +0 -11
  45. package/src/web3mail/IExecWeb3mail.ts +20 -23
  46. package/src/web3mail/fetchMyContacts.ts +2 -2
  47. package/src/web3mail/fetchUserContacts.ts +21 -27
  48. package/src/web3mail/internalTypes.ts +2 -2
  49. package/src/web3mail/prepareEmailCampaign.ts +11 -11
  50. package/src/web3mail/sendEmail.models.ts +6 -68
  51. package/src/web3mail/sendEmail.ts +26 -58
  52. package/src/web3mail/sendEmailCampaign.ts +10 -11
  53. package/src/web3mail/types.ts +8 -13
@@ -2,7 +2,7 @@ import { NULL_ADDRESS } from 'iexec/utils';
2
2
  import { ValidationError } from 'yup';
3
3
  import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
4
4
  import {
5
- addressOrEnsSchema,
5
+ addressSchema,
6
6
  campaignRequestSchema,
7
7
  throwIfMissing,
8
8
  } from '../utils/validators.js';
@@ -17,7 +17,7 @@ export type SendEmailCampaign = typeof sendEmailCampaign;
17
17
 
18
18
  export const sendEmailCampaign = async ({
19
19
  dataProtector = throwIfMissing(),
20
- workerpoolAddressOrEns = throwIfMissing(),
20
+ workerpoolAddress = throwIfMissing(),
21
21
  campaignRequest,
22
22
  }: DataProtectorConsumer &
23
23
  SendEmailCampaignParams): Promise<SendEmailCampaignResponse> => {
@@ -26,18 +26,18 @@ export const sendEmailCampaign = async ({
26
26
  .label('campaignRequest')
27
27
  .validateSync(campaignRequest) as CampaignRequest;
28
28
 
29
- const vWorkerpoolAddressOrEns = addressOrEnsSchema()
29
+ const vWorkerpoolAddress = addressSchema()
30
30
  .required()
31
- .label('workerpoolAddressOrEns')
32
- .validateSync(workerpoolAddressOrEns);
31
+ .label('workerpoolAddress')
32
+ .validateSync(workerpoolAddress);
33
33
 
34
34
  if (
35
35
  vCampaignRequest.workerpool !== NULL_ADDRESS &&
36
36
  vCampaignRequest.workerpool.toLowerCase() !==
37
- vWorkerpoolAddressOrEns.toLowerCase()
37
+ vWorkerpoolAddress.toLowerCase()
38
38
  ) {
39
39
  throw new ValidationError(
40
- "workerpoolAddressOrEns doesn't match campaignRequest workerpool"
40
+ "workerpoolAddress doesn't match campaignRequest workerpool"
41
41
  );
42
42
  }
43
43
 
@@ -45,7 +45,7 @@ export const sendEmailCampaign = async ({
45
45
  // Process the prepared bulk request
46
46
  const processBulkRequestResponse = await dataProtector.processBulkRequest({
47
47
  bulkRequest: vCampaignRequest,
48
- workerpool: vWorkerpoolAddressOrEns,
48
+ workerpool: vWorkerpoolAddress,
49
49
  waitForResult: false,
50
50
  });
51
51
 
@@ -57,13 +57,12 @@ export const sendEmailCampaign = async ({
57
57
  }
58
58
 
59
59
  // Handle protocol errors - this will throw if it's an ApiCallError
60
- // handleIfProtocolError transforms ApiCallError into a WorkflowError with isProtocolError=true
61
- handleIfProtocolError(error);
60
+ handleIfProtocolError(error as Error);
62
61
 
63
62
  // For all other errors
64
63
  throw new WorkflowError({
65
64
  message: 'Failed to sendEmailCampaign',
66
- errorCause: error,
65
+ errorCause: error as Error,
67
66
  });
68
67
  }
69
68
  };
@@ -1,12 +1,8 @@
1
- import { EnhancedWallet } from 'iexec';
1
+ import type { AbstractSigner } from 'ethers';
2
2
  import { IExecConfigOptions } from 'iexec/IExecConfig';
3
3
  import type { BulkRequest } from '@iexec/dataprotector';
4
4
 
5
- export type Web3SignerProvider = EnhancedWallet;
6
-
7
- export type ENS = string;
8
-
9
- export type AddressOrENS = Address | ENS;
5
+ export type Web3SignerProvider = AbstractSigner;
10
6
 
11
7
  export type Address = string;
12
8
 
@@ -59,11 +55,10 @@ export type SendEmailParams = {
59
55
  contentType?: string;
60
56
  senderName?: string;
61
57
  label?: string;
62
- workerpoolAddressOrEns?: AddressOrENS;
58
+ workerpoolAddress?: Address;
63
59
  dataMaxPrice?: number;
64
60
  appMaxPrice?: number;
65
61
  workerpoolMaxPrice?: number;
66
- useVoucher?: boolean;
67
62
  };
68
63
 
69
64
  export type FetchMyContactsParams = {
@@ -100,10 +95,10 @@ export type SendEmailResponse = {
100
95
  */
101
96
  export type Web3MailConfigOptions = {
102
97
  /**
103
- * The Ethereum contract address or ENS (Ethereum Name Service) for the email sender dapp.
98
+ * Ethereum contract address for the email sender dapp.
104
99
  * If not provided, the default web3mail address will be used.
105
100
  */
106
- dappAddressOrENS?: AddressOrENS;
101
+ dappAddress?: Address;
107
102
 
108
103
  /**
109
104
  * The Ethereum contract address for the whitelist.
@@ -156,7 +151,7 @@ export type PrepareEmailCampaignParams = {
156
151
  emailContent: string;
157
152
  contentType?: string;
158
153
  label?: string;
159
- workerpoolAddressOrEns?: AddressOrENS;
154
+ workerpoolAddress?: Address;
160
155
  dataMaxPrice?: number;
161
156
  appMaxPrice?: number;
162
157
  workerpoolMaxPrice?: number;
@@ -177,9 +172,9 @@ export type SendEmailCampaignParams = {
177
172
  */
178
173
  campaignRequest: CampaignRequest;
179
174
  /**
180
- * Workerpool address or ENS to use for processing
175
+ * Workerpool contract address used for processing
181
176
  */
182
- workerpoolAddressOrEns?: AddressOrENS;
177
+ workerpoolAddress?: string;
183
178
  };
184
179
 
185
180
  export type SendEmailCampaignResponse = {