Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter Datapod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
Duniter Datapod
Commits
df498824
Commit
df498824
authored
5 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add detailed explanations
parent
deba4612
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/scripts/datapod-profile-example.ts
+13
-0
13 additions, 0 deletions
src/scripts/datapod-profile-example.ts
src/types.ts
+1
-0
1 addition, 0 deletions
src/types.ts
with
14 additions
and
0 deletions
src/scripts/datapod-profile-example.ts
+
13
−
0
View file @
df498824
// 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
...
...
This diff is collapsed.
Click to expand it.
src/types.ts
+
1
−
0
View file @
df498824
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment