Skip to content

Commit

Permalink
log for ci test debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
gobengo committed Mar 21, 2024
1 parent bcfbed7 commit 26fb50d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function loadConfigVariables() {
vars[name] = val
} else {
if (globals.DEBUG === 'true') {
console.warn(`Missing optional config variables: ${name}`)
// console.warn(`Missing optional config variables: ${name}`)
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions packages/api/src/utils/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,20 @@ export async function getContext(event, params) {
}

let w3up
if (config.W3UP_URL) {
if (
config.W3UP_URL &&
config.W3_NFTSTORAGE_PRINCIPAL &&
config.W3_NFTSTORAGE_PROOF
) {
console.warn('in getContext', {
W3UP_URL: config.W3UP_URL,
W3_NFTSTORAGE_PRINCIPAL: config.W3_NFTSTORAGE_PRINCIPAL,
W3_NFTSTORAGE_PROOF: config.W3_NFTSTORAGE_PROOF,
})
w3up = await createW3upClientFromConfig({
url: config.W3UP_URL,
principal: config.W3_NFTSTORAGE_PRINCIPAL ?? '',
proof: config.W3_NFTSTORAGE_PROOF ?? '',
principal: config.W3_NFTSTORAGE_PRINCIPAL,
proof: config.W3_NFTSTORAGE_PROOF,
})
}

Expand Down
11 changes: 9 additions & 2 deletions packages/api/src/utils/w3up.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ export async function encodeDelegationAsCid(delegation) {
* @param {string} options.proof
*/
export async function createW3upClientFromConfig(options) {
const url = new URL(options.url)
let url
try {
url = new URL(options.url)
} catch (error) {
throw new Error(`unable to parse w3up URL from "${options.url}"`, {
cause: error,
})
}
const principal = ed25519.parse(options.principal)
const connection = connect({
id: { did: () => 'did:web:web3.storage' },
Expand All @@ -130,7 +137,7 @@ export async function createW3upClientFromConfig(options) {
access: connection,
filecoin: connection,
},
receiptsEndpoint: new URL('/receipt/', options.url),
receiptsEndpoint: url && new URL('/receipt/', url.toString()),
})
await w3up.addSpace(await parseW3Proof(options.proof))
return w3up
Expand Down

0 comments on commit 26fb50d

Please sign in to comment.