Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: more logging #2536

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/api/src/utils/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,21 @@ export async function getContext(event, params) {
config.W3_NFTSTORAGE_ENABLE_W3UP_FOR_EMAILS,
}
let w3up
console.log('SETTING UP W3UP')
if (
config.W3UP_URL &&
config.W3UP_DID &&
config.W3_NFTSTORAGE_PRINCIPAL &&
config.W3_NFTSTORAGE_PROOF
) {
try {
console.log('CREATING W3UP WITH', config.W3_NFTSTORAGE_PROOF)
const w3upWIP = await createW3upClientFromConfig({
url: config.W3UP_URL,
did: DID.parse(config.W3UP_DID).did(),
principal: config.W3_NFTSTORAGE_PRINCIPAL,
proof: config.W3_NFTSTORAGE_PROOF,
})
console.log('CLIENT CREATED')
// @ts-expect-error todo add DID check
w3upWIP.setCurrentSpace(config.W3_NFTSTORAGE_SPACE)
w3up = w3upWIP
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/utils/w3up.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { importDAG } from '@ucanto/core/delegation'
import * as W3upClient from '@web3-storage/w3up-client'
import { connect } from '@ucanto/client'
import { CAR, HTTP } from '@ucanto/transport'
import * as DAGUCANCBOR from '@ipld/dag-ucan/codec/cbor'

/**
* @param {object} env
Expand Down Expand Up @@ -65,6 +66,9 @@ export async function readProofFromBytes(bytes) {
console.error(`Error: failed to parse proof: ${err.message}`)
throw err
}
const proof = blocks[blocks.length - 1]
console.log('DECODING PROOF', proof)
console.log('DECODED', DAGUCANCBOR.decode(proof.bytes))
try {
// @ts-expect-error Block types are slightly different but it works
return importDAG(blocks)
Expand Down
Loading