Skip to content

Commit

Permalink
fix: add drand client globals
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Dec 13, 2022
1 parent 798f922 commit 3f5346e
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 2 deletions.
151 changes: 151 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions upload-api/functions/ucan-invocation-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import * as Sentry from '@sentry/serverless'
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
// @ts-ignore no types in client
import Client from 'drand-client'
import fetch from 'node-fetch'
import AbortController from 'abort-controller'

// Set drand globals
// @ts-ignore
global.fetch = fetch
// @ts-ignore
global.AbortController = AbortController

import { createAccessClient } from '../access.js'
import { parseUcanInvocationRequest, persistUcanInvocation } from '../ucan-invocation.js'
Expand Down Expand Up @@ -96,8 +104,6 @@ async function ucanInvocationRouter (request) {
Client.roundAt(Date.now())
])

console.log('round', round)

// Put invocation to UCAN stream
await kinesisClient.putRecord({
Data: uint8arrayFromString(JSON.stringify({
Expand Down
2 changes: 2 additions & 0 deletions upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"@web-std/fetch": "^4.1.0",
"@web3-storage/access": "^9.0.0",
"@web3-storage/capabilities": "^2.0.0",
"abort-controller": "3.0.0",
"drand-client": "^0.2.0",
"multiformats": "^10.0.2",
"node-fetch": "^3.3.0",
"p-retry": "^5.1.2",
"uint8arrays": "^4.0.2"
},
Expand Down

0 comments on commit 3f5346e

Please sign in to comment.