Skip to content

Commit 2a0edb8

Browse files
docs: improve documentation structure and fix display issues
- Improve integrate-web3-messaging guide with bulk campaigns workflow - Fix error display and formatting issues across reference files - Update documentation structure and consistency - Refactor code examples and improve clarity
1 parent 3efbe5d commit 2a0edb8

File tree

9 files changed

+334
-549
lines changed

9 files changed

+334
-549
lines changed

src/guides/use-iapp/integrate-web3-messaging.md

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ flow is the same, except that:
1818
1. (Telegram only) Get a Chat ID from the iExec bot
1919
2. Create the Protected Data using DataProtector Toolkit
2020
3. Grant access of your Protected Data
21-
4. Send the message using the relevant SDK ( Web3Mail / Web3Telegram )
21+
4. Send the message using the relevant SDK (Web3Mail / Web3Telegram)
22+
23+
You can send messages in two modes: single messages (one recipient at a time) or
24+
bulk campaigns (same message to multiple recipients efficiently). See step 4
25+
below for details.
2226

2327
## 1. Retrieve the Telegram Chat ID (Telegram only)
2428

@@ -69,7 +73,9 @@ const protectedData = await dataProtectorCore.protectData({
6973

7074
## 3. Grant Access
7175

72-
Grant permission for a sender and/or an app to contact the user.
76+
Grant permission for a sender and/or an app to contact the user. Choose the mode
77+
based on your use case: use **Single Message** mode for individual messages, or
78+
**Bulk Campaigns** mode for sending the same message to multiple recipients.
7379

7480
::: code-group
7581

@@ -92,37 +98,20 @@ import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
9298
const web3Provider = getWeb3Provider('PRIVATE_KEY');
9399
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
94100
// ---cut---
95-
// For bulk campaigns, recipients must grant access with allowBulk: true
101+
// allowBulk: true automatically sets pricePerAccess to 0 and numberOfAccess to unlimited
96102
const grantedAccess = await dataProtectorCore.grantAccess({
97103
protectedData: '0x123abc...',
98104
authorizedApp: '0x456def...',
99105
authorizedUser: '0x789cba...',
100-
allowBulk: true, // [!code focus] Enable bulk processing
106+
allowBulk: true, // [!code focus]
101107
});
102108
```
103109

104110
:::
105111

106-
::: info
107-
108-
Setting `allowBulk: true` automatically configures `pricePerAccess` to `0` and
109-
`numberOfAccess` to `Number.MAX_SAFE_INTEGER`, enabling unlimited bulk
110-
processing at no cost per access.
111-
112-
:::
113-
114112
## 4. Send the Message
115113

116-
You can send messages in two modes:
117-
118-
- **Single Processing**: Send to one recipient using `sendEmail` or
119-
`sendTelegram`
120-
- **Bulk Processing**: Send the same message to multiple recipients efficiently
121-
using a two-step process: first call `prepareEmailCampaign` or
122-
`prepareTelegramCampaign` to prepare the campaign, then call
123-
`sendEmailCampaign` or `sendTelegramCampaign` to send it
124-
125-
### Single Message Processing
114+
### Single Messages
126115

127116
Send a message to a single recipient:
128117

@@ -156,10 +145,12 @@ const sendTelegram = await web3telegram.sendTelegram({
156145

157146
:::
158147

159-
### Bulk Message Processing
148+
### Bulk Campaigns
160149

161-
Send the same message to multiple recipients efficiently in a single
162-
transaction.
150+
Send the same message to multiple recipients efficiently. Bulk processing groups
151+
multiple protected data items (emails for Web3Mail or chat IDs for Web3Telegram)
152+
together, reducing gas fees and processing recipients in parallel across one or
153+
more transactions.
163154

164155
**To send a bulk campaign, follow these steps in order:**
165156

@@ -169,8 +160,7 @@ transaction.
169160
`prepareTelegramCampaign` (for Web3Telegram). This creates a bulk request
170161
object that groups all recipients together
171162
3. **Send the campaign** by calling `sendEmailCampaign` (for Web3Mail) or
172-
`sendTelegramCampaign` (for Web3Telegram) with the prepared bulk request.
173-
This processes all recipients in one or more efficient transactions
163+
`sendTelegramCampaign` (for Web3Telegram) with the prepared bulk request
174164

175165
::: warning Prerequisites
176166

@@ -182,60 +172,92 @@ Before using bulk processing, ensure that recipients have granted access with
182172
::: code-group
183173

184174
```ts twoslash [Web3Mail - Bulk]
185-
import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail';
175+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
176+
import { IExecWeb3mail } from '@iexec/web3mail';
186177

187178
const web3Provider = getWeb3Provider('PRIVATE_KEY');
179+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
188180
const web3mail = new IExecWeb3mail(web3Provider);
189181

190-
// Step 1: Fetch contacts with bulk access
182+
// Steps 1-2: Executed by the recipient (protected data provider)
183+
// Step 1: Create Protected Data (see section 2)
184+
const protectedData = await dataProtectorCore.protectData({
185+
data: {
186+
187+
},
188+
});
189+
190+
// Step 2: Grant access with bulk processing enabled (see section 3)
191+
const grantedAccess = await dataProtectorCore.grantAccess({
192+
protectedData: protectedData.address,
193+
authorizedApp: '0x456def...',
194+
authorizedUser: '0x789cba...',
195+
allowBulk: true,
196+
});
197+
198+
// Steps 3-5: Executed by the sender (who wants to contact recipients)
199+
// Step 3: Fetch contacts with bulk access
191200
const contacts = await web3mail.fetchMyContacts({ bulkOnly: true });
192201
const grantedAccessArray = contacts.map((contact) => contact.grantedAccess);
193202

194-
// Step 2: Prepare the campaign
203+
// Step 4: Prepare the campaign
195204
const emailCampaign = await web3mail.prepareEmailCampaign({
196205
grantedAccesses: grantedAccessArray,
197206
emailSubject: 'Hello from My Awesome App!',
198207
emailContent: 'Hello! This is a bulk email sent to all recipients.',
199208
contentType: 'text/html',
200209
});
201210

202-
// Step 3: Send the bulk campaign
211+
// Step 5: Send the bulk campaign
203212
const { tasks } = await web3mail.sendEmailCampaign({
204213
campaignRequest: emailCampaign.campaignRequest,
205214
});
206215
```
207216

208217
```ts twoslash [Web3Telegram - Bulk]
209-
import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram';
218+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
219+
import { IExecWeb3telegram } from '@iexec/web3telegram';
210220

211221
const web3Provider = getWeb3Provider('PRIVATE_KEY');
222+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
212223
const web3telegram = new IExecWeb3telegram(web3Provider);
213224

214-
// Step 1: Fetch contacts with bulk access
225+
// Steps 1-2: Executed by the recipient (protected data provider)
226+
// Step 1: Create Protected Data (see section 2)
227+
const protectedData = await dataProtectorCore.protectData({
228+
data: {
229+
telegram_chatId: '12345678',
230+
},
231+
});
232+
233+
// Step 2: Grant access with bulk processing enabled (see section 3)
234+
const grantedAccess = await dataProtectorCore.grantAccess({
235+
protectedData: protectedData.address,
236+
authorizedApp: '0x456def...',
237+
authorizedUser: '0x789cba...',
238+
allowBulk: true,
239+
});
240+
241+
// Steps 3-5: Executed by the sender (who wants to contact recipients)
242+
// Step 3: Fetch contacts with bulk access
215243
const contacts = await web3telegram.fetchMyContacts({ bulkOnly: true });
216244
const grantedAccessArray = contacts.map((contact) => contact.grantedAccess);
217245

218-
// Step 2: Prepare the campaign
246+
// Step 4: Prepare the campaign
219247
const telegramCampaign = await web3telegram.prepareTelegramCampaign({
220248
grantedAccesses: grantedAccessArray,
221249
telegramContent: 'Hello! This is a bulk message sent to all recipients.',
222250
senderName: 'My Awesome App',
223251
});
224252

225-
// Step 3: Send the bulk campaign
253+
// Step 5: Send the bulk campaign
226254
const { tasks } = await web3telegram.sendTelegramCampaign({
227255
campaignRequest: telegramCampaign.campaignRequest,
228256
});
229257
```
230258

231259
:::
232260

233-
**Benefits:**
234-
235-
- Lower costs: fewer transactions reduce gas fees
236-
- Higher performance: multiple recipients processed in parallel
237-
- Better scalability: efficiently handle hundreds or thousands of recipients
238-
239261
## Payment
240262

241263
Each message sent through Web3Mail or Web3Telegram requires payment in RLC

src/references/dataProtector/methods/getGrantedAccess.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ const listGrantedAccess = await dataProtectorCore.getGrantedAccess({
196196
**Type:** `boolean`
197197
**Default:** `false`
198198

199-
Filter to retrieve only bulk orders. When set to `true`, only granted accesses
200-
that have been created with `allowBulk: true` in
201-
[`grantAccess`](/references/dataProtector/methods/grantAccess) will be returned.
202-
This is useful when preparing bulk requests using
199+
Filter to retrieve only bulk access grants. When set to `true`, this method
200+
returns only granted accesses that were created with `allowBulk: true` when
201+
calling [`grantAccess`](/references/dataProtector/methods/grantAccess). This is
202+
useful when preparing bulk requests using
203203
[`prepareBulkRequest`](/references/dataProtector/methods/prepareBulkRequest).
204204

205205
**Usage example:**
@@ -215,20 +215,20 @@ const { grantedAccess } = await dataProtectorCore.getGrantedAccess({
215215
});
216216
```
217217

218-
## Return Value
218+
## Return value
219219

220220
```ts twoslash
221221
import { type GrantedAccessResponse } from '@iexec/dataprotector';
222222
```
223223

224224
The return value for this method has two fields: a `count` parameter indicating
225225
the number of results, and an array of `GrantedAccess` objects containing all
226-
access data. When using the optional paging parameters, the `count` will be
227-
limited by the selected `pageSize` parameter. You may use these result objects
228-
in conjunction with the [revokeOneAccess](revokeOneAccess.md) method to revoke a
226+
access data. When using the optional paging parameters, the `count` is limited
227+
by the selected `pageSize` parameter. You may use these result objects in
228+
conjunction with the [revokeOneAccess](revokeOneAccess.md) method to revoke a
229229
previously granted authorization for access.
230230

231-
### count
231+
### Count
232232

233233
**Type:** `number`
234234

@@ -238,7 +238,7 @@ smaller than the page size.
238238

239239
### grantedAccess
240240

241-
**Type:** GrantedAccess
241+
git comm**Type:** `GrantedAccess`
242242

243243
See [`GrantedAccess`](/references/dataProtector/types#grantedaccess)
244244

0 commit comments

Comments
 (0)