@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.
- package/README.md +7 -7
- package/dist/config/config.d.ts +6 -1
- package/dist/config/config.js +23 -12
- package/dist/config/config.js.map +1 -1
- package/dist/utils/getChainId.js +7 -2
- package/dist/utils/getChainId.js.map +1 -1
- package/dist/utils/getWeb3Provider.d.ts +10 -2
- package/dist/utils/getWeb3Provider.js +12 -7
- package/dist/utils/getWeb3Provider.js.map +1 -1
- package/dist/utils/resolveDappAddressFromCompass.d.ts +2 -2
- package/dist/utils/resolveDappAddressFromCompass.js +1 -1
- package/dist/utils/resolveDappAddressFromCompass.js.map +1 -1
- package/dist/utils/validators.d.ts +0 -2
- package/dist/utils/validators.js +0 -4
- package/dist/utils/validators.js.map +1 -1
- package/dist/web3mail/IExecWeb3mail.d.ts +2 -2
- package/dist/web3mail/IExecWeb3mail.js +13 -14
- package/dist/web3mail/IExecWeb3mail.js.map +1 -1
- package/dist/web3mail/fetchMyContacts.d.ts +1 -1
- package/dist/web3mail/fetchMyContacts.js +2 -2
- package/dist/web3mail/fetchMyContacts.js.map +1 -1
- package/dist/web3mail/fetchUserContacts.d.ts +1 -1
- package/dist/web3mail/fetchUserContacts.js +20 -25
- package/dist/web3mail/fetchUserContacts.js.map +1 -1
- package/dist/web3mail/internalTypes.d.ts +2 -2
- package/dist/web3mail/prepareEmailCampaign.d.ts +1 -1
- package/dist/web3mail/prepareEmailCampaign.js +10 -10
- package/dist/web3mail/prepareEmailCampaign.js.map +1 -1
- package/dist/web3mail/sendEmail.d.ts +1 -1
- package/dist/web3mail/sendEmail.js +21 -41
- package/dist/web3mail/sendEmail.js.map +1 -1
- package/dist/web3mail/sendEmail.models.d.ts +8 -27
- package/dist/web3mail/sendEmail.models.js +5 -28
- package/dist/web3mail/sendEmail.models.js.map +1 -1
- package/dist/web3mail/sendEmailCampaign.d.ts +1 -1
- package/dist/web3mail/sendEmailCampaign.js +8 -9
- package/dist/web3mail/sendEmailCampaign.js.map +1 -1
- package/dist/web3mail/types.d.ts +8 -11
- package/package.json +4 -4
- package/src/config/config.ts +26 -14
- package/src/utils/getChainId.ts +11 -2
- package/src/utils/getWeb3Provider.ts +13 -6
- package/src/utils/resolveDappAddressFromCompass.ts +3 -3
- package/src/utils/validators.ts +0 -11
- package/src/web3mail/IExecWeb3mail.ts +20 -23
- package/src/web3mail/fetchMyContacts.ts +2 -2
- package/src/web3mail/fetchUserContacts.ts +21 -27
- package/src/web3mail/internalTypes.ts +2 -2
- package/src/web3mail/prepareEmailCampaign.ts +11 -11
- package/src/web3mail/sendEmail.models.ts +6 -68
- package/src/web3mail/sendEmail.ts +26 -58
- package/src/web3mail/sendEmailCampaign.ts +10 -11
- 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
|
-
|
|
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
|
-
|
|
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
|
|
29
|
+
const vWorkerpoolAddress = addressSchema()
|
|
30
30
|
.required()
|
|
31
|
-
.label('
|
|
32
|
-
.validateSync(
|
|
31
|
+
.label('workerpoolAddress')
|
|
32
|
+
.validateSync(workerpoolAddress);
|
|
33
33
|
|
|
34
34
|
if (
|
|
35
35
|
vCampaignRequest.workerpool !== NULL_ADDRESS &&
|
|
36
36
|
vCampaignRequest.workerpool.toLowerCase() !==
|
|
37
|
-
|
|
37
|
+
vWorkerpoolAddress.toLowerCase()
|
|
38
38
|
) {
|
|
39
39
|
throw new ValidationError(
|
|
40
|
-
"
|
|
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:
|
|
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
|
-
|
|
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
|
};
|
package/src/web3mail/types.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
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 =
|
|
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
|
-
|
|
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
|
-
*
|
|
98
|
+
* Ethereum contract address for the email sender dapp.
|
|
104
99
|
* If not provided, the default web3mail address will be used.
|
|
105
100
|
*/
|
|
106
|
-
|
|
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
|
-
|
|
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
|
|
175
|
+
* Workerpool contract address used for processing
|
|
181
176
|
*/
|
|
182
|
-
|
|
177
|
+
workerpoolAddress?: string;
|
|
183
178
|
};
|
|
184
179
|
|
|
185
180
|
export type SendEmailCampaignResponse = {
|