Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@solarpunkltd/gsoc
Advanced tools
This library facilitates to use Graffiti Several Owner Chunks (GSOC) on Ethereum Swarm.
Leveraging its features, any data can be referenced to other related data without maintaing any external registry or running service.
** WARNING! This project is in the experimental phase! **
It is intended to be an upgraded version of the predecessor Graffiti Feed based zerodash library. Missing feature is the reading part though the communication is possible by running storer node and subscribe to incoming infromation signals.
npm install @anythread/gsoc --save
The library provides InformationSignal
class that reads/writes GSOC according to the consensus and other configuration parameters.
The consensus consists of an arbitrary id
and an assert function that validates the handled records in the GSOC address space.
const id = 'SampleDapp:v1'
export interface SampleDappRecord {
/** text of the message */
text: string
/** creation time of the comment */
timestamp: number
}
function assertRecord(value: unknown): asserts value is SampleDappRecord {
if (
value !== null &&
typeof value === 'object' &&
Object.keys(value).includes('text') &&
Object.keys(value).includes('timestamp')
) {
return
}
throw new Error('The given value is not a valid personal storage record')
}
With that, the rules have been created for kademlia information signaling on any data.
Information Signal class facilitates GSOC data reading based on the passed consensus rules.
import { InformationSignal } from '@anythread/gsoc'
beeUrl = 'http://localhost:1633' // Bee API URL to connect p2p storage network
postage = '0000000000000000000000000000000000000000000000000000000000000000' // for write operations, the Postage Batch ID (64 length hex) or a Postage Stamp (226 length hex) must be set
resourceId = 'demo' // any string/content hash that represents the resource to which the Personal Storage record will be associated.
// initialize object that will read and write the GSOC according to the passed consensus/configuration
informationSignal = new InformationSignal(beeUrl, {
postage,
consensus: {
id,
assertRecord,
},
})
// it is also possible to mine the resourceId to the desired Bee node to ensure they will get the message as soon as possible on the forwarding Kademlia network
targetBeeOverlayAddress = 'b0baf37700000000000000000000000000000000000000000000000000000000'
{ resourceId } = informationSignal.mine(targetBeeOverlayAddress, 16)
// subscribe to incoming topics on the receiver node
// this will immediately invoge `onMessage` and `onError` function if the message arrives to the target neighborhood of the Kademlia network.
cancelSub = informationSignal.subscribe({onMessage: msg => console.log('my-life-event', msg), onError: console.log}, resourceId)
// write GSOC record that satisfies the message format with the `write` method.
uploadedSoc = await informationSignal.write({ text: 'Hello there!', timestamp: 1721989685349 }, resourceId)
In order to compile code run
npm run compile
You can find the resulted code under the dist
folder.
For types compilation, run
npm run compile:types
The testing needs running Bee client node for integration testing.
You should set BEE_POSTAGE
and BEE_POSTAGE_2
environment variable with valid Postage batch IDs.
In order to test on different node than http://localhost:1633
and http://localhost:11633
, set BEE_API_URL
and BEE_PEER_API_URL
environment variable, respectively.
To run test execute
npm run test
FAQs
Graffiti Several Owner Chunk implementation on Swarm network
We found that @solarpunkltd/gsoc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.