Skip to content

Commit 22cdfcf

Browse files
committed
helper for building payloads
1 parent b5aee3b commit 22cdfcf

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/helpers/buildSamplePayloads.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Id } from "@xyo-network/id-payload-plugin"
2+
import { PayloadBuilder } from "@xyo-network/payload-builder"
3+
import { HashPayload } from "@xyo-network/xl1-protocol"
4+
5+
export const buildSamplePayloads = async () => {
6+
// Data to store off-chain
7+
const offChainPayloads: Id[] = [0, 1].map(index => ({
8+
schema: 'network.xyo.id',
9+
salt: `Hello from Sample ${index} - ${new Date().toISOString()}`,
10+
}))
11+
12+
// build a hash payload with the hash of the off-chain payload
13+
const hashPayloads: HashPayload[] = await Promise.all([0, 1].map(async index => ({
14+
schema: 'network.xyo.hash',
15+
hash: await PayloadBuilder.hash(offChainPayloads[index]),
16+
})))
17+
return { offChainPayloads, hashPayloads }
18+
}

src/helpers/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from './getXyoGateway.ts'
1+
export * from './getXyoGateway.ts'
2+
export * from './buildSamplePayloads.ts'

0 commit comments

Comments
 (0)