diff --git a/src/scripts/datapod-profile-example.ts b/src/scripts/datapod-profile-example.ts index 014f8493623eb3c059cc6213b4901354c4812365..f9dd6a94c85eba59c50ab0cad09ef5bcf8dc7b71 100644 --- a/src/scripts/datapod-profile-example.ts +++ b/src/scripts/datapod-profile-example.ts @@ -1,5 +1,12 @@ // This script shows a minimal working example to publish a datapod profile +// Explaning dependencies: +// - consts: contains common kinds for index requests +// - types: contains details about index request fields +// - kubo-rpc-client: simple rpc client lib available in many langages +// - collector: contains function defining expected payload to sign +// - polkadot: contains crypto utils + import { readFileSync } from 'fs' import { CESIUM_PLUS_PROFILE_INSERT } from '../consts' import type { IndexRequest } from '../types' @@ -11,12 +18,16 @@ import { u8aToHex } from '@polkadot/util' // This public Kubo node exposes features necessary to upload data and relay to datapod network // This is a simple alternative to embedding an ipfs node when it is not possible or suited +// Bear in mind that the data sent here can be garbage collected at any moment. +// If the datapod network did not pin it, it will simply disappear. +// The datapod network currently does not have pinning strategy and pins nothing. const KUBO_RPC = 'https://rpc.datapod.gyroi.de/' const kubo: KuboRPCClient = create({ url: new URL(KUBO_RPC) }) +// main function describing the steps of datapod publication process async function main() { // 0. keyring const keyring = new Keyring({ type: 'ed25519', ss58Format: 42 }) @@ -60,6 +71,7 @@ async function main() { const enc = new TextEncoder() await kubo.pubsub.publish('ddd', enc.encode(ir_cid.toString() + '\n')) + // some logging when you run it console.log(`➡️ published ${ir_cid} on pubsub`) console.log('➡️ corresponding to the following index request') console.log(ir) @@ -69,6 +81,7 @@ async function main() { console.log('https://duniter--vue-coinduf-eu.ipns.pagu.re/#/data/' + alice.address) } +// run the main function main() // get image for demo purpose diff --git a/src/types.ts b/src/types.ts index a2acd3b6ec19a2ee82de8163c4e00afb2b5f54b7..a10d6fc45e37375a97e8103c50c25737f9e460eb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -28,6 +28,7 @@ export interface IndexRequest { /// signature of the following byte payload : /// ["dd" prefix for 'duniter datapods' | timestamp as u64 bytes | kind bytes | data bytes or 0x00] // can be null in the case where the signature is inside the data (C+ profile formats for example) + // for the moment as hexadecimal strinf prefixed by 0x sig: string | null }