Skip to content

Commit b03925e

Browse files
committed
added act page draft
1 parent a509a6f commit b03925e

File tree

3 files changed

+143
-4
lines changed

3 files changed

+143
-4
lines changed

docs/documentation/act.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,140 @@ This section is still being worked on. Check back soon for updates!
1616
* Show example of creating grantee list
1717
* Show example of secure upload
1818
* Show example of secure download
19+
20+
21+
## Create Grantees List
22+
23+
```js
24+
import { Bee, PublicKey, BatchId } from '@ethersphere/bee-js';
25+
26+
// Initialize Bee instance
27+
const bee = new Bee('http://localhost:1643');
28+
29+
// Grantee's public key (replace with the actual key)
30+
const grantees = [
31+
new PublicKey('027d0c4759f689ea3dd3eb79222870671c492cb99f3fade275bcbf0ea39cd0ef6e')
32+
];
33+
34+
// Your postage batch ID (replace with a valid one)
35+
const postageBatchId = new BatchId('955e22d95ca6793db4d22cb1aac1c59f64469293811bb969ac33f0c23f3b1f31');
36+
37+
// Function to create grantees list
38+
async function createGranteeList() {
39+
try {
40+
// Create the grantee list using `createGrantees`
41+
const response = await bee.createGrantees(postageBatchId, grantees);
42+
43+
// Log the response (ref and history ref)
44+
console.log('Grantee List Created Successfully:');
45+
console.log('Reference:', response.ref.toHex());
46+
console.log('History Reference:', response.historyref.toHex());
47+
} catch (error) {
48+
console.error('Error creating grantee list:', error);
49+
}
50+
}
51+
52+
// Call the function to create the grantee list
53+
createGranteeList();
54+
```
55+
56+
Example output:
57+
58+
```bash
59+
Grantee List Created Successfully:
60+
Reference: ac35c416cae0a5481e483b70a55950c0d0ed63f61ead4edc20d6fc70d065fc3792223d08752fa6ea9b6bdf66d55def4fdceb3a2f9d8672aacde209717bfbf8fd
61+
History Reference: 980969082877ba5577e01fd2bfe9941d151a1ca2a58aa8c114a97807e8e94e54
62+
```
63+
64+
## Update Grantees List
65+
66+
```js
67+
import { Bee, PublicKey, BatchId, Reference } from '@ethersphere/bee-js';
68+
69+
// Initialize Bee instance
70+
const bee = new Bee('http://localhost:1643'); // Correct port is 1643
71+
72+
// Grantee's public key to be added (replace with the actual key)
73+
const newGrantee = new PublicKey('03636056d1e08f100c5acaf14d10070102de9444c97b2e8215305ab3e97254ede6');
74+
75+
// Grantee list reference and history reference (replace with actual references from `createGrantees`)
76+
const granteeListRef = new Reference('ac35c416cae0a5481e483b70a55950c0d0ed63f61ead4edc20d6fc70d065fc3792223d08752fa6ea9b6bdf66d55def4fdceb3a2f9d8672aacde209717bfbf8fd')
77+
const granteeHistoryRef = new Reference('980969082877ba5577e01fd2bfe9941d151a1ca2a58aa8c114a97807e8e94e54')
78+
79+
// Your postage batch ID (replace with a valid one)
80+
const postageBatchId = new BatchId('955e22d95ca6793db4d22cb1aac1c59f64469293811bb969ac33f0c23f3b1f31');
81+
82+
// Function to update the grantee list by adding the new public key
83+
async function updateGranteeList() {
84+
try {
85+
// Call the patchGrantees function to add the new public key
86+
const response = await bee.patchGrantees(postageBatchId, granteeListRef, granteeHistoryRef, {
87+
add: [newGrantee], // Add the new grantee
88+
});
89+
90+
// Log the updated grantee list references
91+
console.log('Grantee List Updated Successfully:');
92+
console.log('Updated Reference:', response.ref.toHex());
93+
console.log('Updated History Reference:', response.historyref.toHex());
94+
} catch (error) {
95+
console.error('Error updating grantee list:', error.message);
96+
if (error.response) {
97+
// If there's a response object, log the full response for more details
98+
console.error('Response Status:', error.response.status);
99+
console.error('Response Body:', JSON.stringify(error.response.body, null, 2));
100+
}
101+
}
102+
}
103+
104+
// Call the function to update the grantee list
105+
updateGranteeList();
106+
```
107+
108+
Example output:
109+
110+
```bash
111+
Grantee List Updated Successfully:
112+
Updated Reference: 4cad43d435bceca6925b3ed750d415a9f78566bb2b7dac90886f9305cd8f2267818cfaf6b0cd00a593a94719ec1cbc0270c76f0c57840c1210667b7b6aa48080
113+
Updated History Reference: ffa62ebf1c0f8f9c756743add487d0e5f0c938309333e283729bdb9ad962da14
114+
```
115+
116+
## Get Grantees List
117+
118+
```js
119+
import { Bee, Reference } from '@ethersphere/bee-js';
120+
121+
// Initialize Bee instance with the correct port (1643)
122+
const bee = new Bee('http://localhost:1643');
123+
124+
// Grantee list reference (the reference returned from the `createGrantees` function)
125+
const granteeListRef = new Reference('55c3b293cd15956f4c40f2fe1b58e4fea4cf55a1c95b61a419120b39d545f9592c58ea761147122685ff940409a57047d04cb2ae914b5ecf2a0083267eded8ab');
126+
127+
// Function to get the grantee list
128+
async function getGranteeList() {
129+
try {
130+
// Call the getGrantees function with the reference
131+
const result = await bee.getGrantees(granteeListRef);
132+
133+
// Log the full response
134+
console.log('Grantee List Retrieved:');
135+
console.log('Status:', result.status);
136+
console.log('Status Text:', result.statusText);
137+
138+
// Log the grantees as an array of their string representations (compressed hex values)
139+
console.log('Grantees:', result.grantees.map(grantee => grantee.toCompressedHex()));
140+
141+
// Check if ref and historyref exist before trying to call toHex()
142+
if (result.ref && result.historyref) {
143+
console.log('Reference:', result.ref.toHex());
144+
console.log('History Reference:', result.historyref.toHex());
145+
} else {
146+
console.log('Reference or History Reference not found.');
147+
}
148+
} catch (error) {
149+
console.error('Error retrieving grantee list:', error);
150+
}
151+
}
152+
153+
// Call the function to fetch the grantee list
154+
getGranteeList();
155+
```

docs/documentation/pss.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Postal Service over Swarm
33
id: pss
44
slug: /pss
5-
sidebar_label: Postal Service over Swarm
5+
sidebar_label: PSS
66
---
77

88
Swarm supports sending encrypted messages over the network using a system called **Postal Service over Swarm** (PSS). These messages are embedded in regular Swarm traffic and routed to specific nodes based on their overlay address.

sidebars.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ module.exports = {
1414
'documentation/tracking-uploads',
1515
'documentation/pinning',
1616
'documentation/staking',
17+
'documentation/pss',
18+
'documentation/gsoc',
19+
// 'documentation/act',
1720
// 'documentation/manifests',
1821
// 'documentation/soc-and-feeds',
19-
// 'documentation/pss',
20-
// 'documentation/gsoc',
21-
// 'documentation/act',
22+
23+
2224
'documentation/utilities',
2325
],
2426
collapsed: false

0 commit comments

Comments
 (0)