From 072bcbce46c0ea8d78b657339c5984f7d63b4e10 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Fri, 29 Mar 2024 11:45:08 -0700 Subject: [PATCH] fix: more logging plus try to parse the UCAN a bit earlier in an attempt to get better stack traces --- packages/api/src/utils/context.js | 3 ++- packages/api/src/utils/w3up.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/api/src/utils/context.js b/packages/api/src/utils/context.js index fc43d18afc..c15c390efc 100644 --- a/packages/api/src/utils/context.js +++ b/packages/api/src/utils/context.js @@ -76,6 +76,7 @@ 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 && @@ -83,13 +84,13 @@ export async function getContext(event, params) { 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 diff --git a/packages/api/src/utils/w3up.js b/packages/api/src/utils/w3up.js index 8aff4a3758..9e113cc6c5 100644 --- a/packages/api/src/utils/w3up.js +++ b/packages/api/src/utils/w3up.js @@ -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 @@ -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)