-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
36 lines (32 loc) · 1 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let Redwood = require('@redwood.dev/client').default
async function main() {
let client = Redwood.createPeer({
httpHost: 'http://localhost:8080',
rpcEndpoint: 'http://localhost:8081',
})
// Authorize with the node over the insecure RPC connection. This gives us
// a JSON web token (JWT) that allows us to send transactions from the
// identity of the node itself, rather than a browser-based identity.
let ucan = await client.rpc.ucan()
client.setUcan(ucan)
// Create our initial state
await client.put({
stateURI: 'example.project/foo',
id: Redwood.utils.genesisTxID,
patches: [
' = ' + Redwood.utils.JSON.stringify({
'Merge-Type': {
'Content-Type': 'resolver/dumb',
'value': {}
},
'messages': [],
}),
],
})
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error)
process.exit(1)
})