Skip to content
Snippets Groups Projects
Commit df498824 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add detailed explanations

parent deba4612
No related branches found
No related tags found
No related merge requests found
// 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
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment