From eaa7e50386635723751af1fc7cb4cf4ff5cf6abc Mon Sep 17 00:00:00 2001 From: Natalie Bravo Date: Mon, 25 Nov 2024 11:17:51 -0300 Subject: [PATCH] fix: add missing receiptsEndpoint to W3UIProvider (#144) ## Description This PR adds a `receiptsEndpoint` configuration to `W3UIProvider`. The receipts URL is currently not provided by the console to the client as an option, so this ensures the endpoint is explicitly configured. ## Motivation Uploading in staging is currently broken. The console shows an error when attempting to retrieve the receipt. The receipts endpoint being used for staging is incorrect due to a missing configuration. This causes the value to default to a hardcoded production endpoint. --------- Co-authored-by: ash --- .env.tpl | 1 + .github/workflows/deploy-storacha.yml | 2 ++ .github/workflows/deploy.yml | 2 ++ README.md | 1 + src/components/W3UIProvider.tsx | 8 ++++++-- src/components/services.ts | 6 ++++++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.env.tpl b/.env.tpl index eebc36d..ef94963 100644 --- a/.env.tpl +++ b/.env.tpl @@ -1,5 +1,6 @@ # set these to your upload API service URL and the DID your service is using as its service DID NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.web3.storage +NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://staging.up.web3.storage/receipt/ NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage diff --git a/.github/workflows/deploy-storacha.yml b/.github/workflows/deploy-storacha.yml index 7485a61..d4ae079 100644 --- a/.github/workflows/deploy-storacha.yml +++ b/.github/workflows/deploy-storacha.yml @@ -38,6 +38,7 @@ jobs: # add vars configuring console frontend to use staging w3up as backend echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage" >> .env echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.storacha.network" >> .env + echo "NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://staging.up.storacha.network/receipt/" >> .env echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage" >> .env echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1NzhdvF6A5ufQX5vKNZuRhie" >> .env echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51LO87hF6A5ufQX5viNsPTbuErzfavdrEFoBuaJJPfoIhzQXdOUdefwL70YewaXA32ZrSRbK4U4fqebC7SVtyeNcz00qmgNgueC" >> .env @@ -127,6 +128,7 @@ jobs: # add vars configuring console frontend to use staging w3up as backend echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:web3.storage" >> .env echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://up.storacha.network" >> .env + echo "NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://up.storacha.network/receipt/" >> .env echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:web3.storage" >> .env echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1OCJ1qF6A5ufQX5vM5DWg4rA" >> .env echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_51LO87hF6A5ufQX5vQTO5BHyz8y9ybJp4kg1GsBjYuqwluuwtQTkbeZzkoQweFQDlv7JaGjuIdUWAyuwXp3tmCfsM005lJK9aS8" >> .env diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cc033c5..ec2cdb2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,6 +38,7 @@ jobs: # add vars configuring console frontend to use staging w3up as backend echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage" >> .env echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.web3.storage" >> .env + echo "NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://staging.up.web3.storage/receipt/" >> .env echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage" >> .env echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1NzhdvF6A5ufQX5vKNZuRhie" >> .env echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51LO87hF6A5ufQX5viNsPTbuErzfavdrEFoBuaJJPfoIhzQXdOUdefwL70YewaXA32ZrSRbK4U4fqebC7SVtyeNcz00qmgNgueC" >> .env @@ -125,6 +126,7 @@ jobs: # add vars configuring console frontend to use staging w3up as backend echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:web3.storage" >> .env echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://up.web3.storage" >> .env + echo "NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://up.web3.storage/receipt/" >> .env echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:web3.storage" >> .env echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1OCJ1qF6A5ufQX5vM5DWg4rA" >> .env echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_51LO87hF6A5ufQX5vQTO5BHyz8y9ybJp4kg1GsBjYuqwluuwtQTkbeZzkoQweFQDlv7JaGjuIdUWAyuwXp3tmCfsM005lJK9aS8" >> .env diff --git a/README.md b/README.md index 9f12bc1..24c19f7 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ By default, this app connects to `https://up.web3.storage`, and uses `did:web:we NEXT_PUBLIC_W3UP_SERVICE_URL=https://your.w3up.service NEXT_PUBLIC_W3UP_SERVICE_DID=did:your-service-did NEXT_PUBLIC_W3UP_PROVIDER=did:your-provider-did +NEXT_PUBLIC_W3UP_RECEIPTS_URL=https://your.w3up.service/receipt/ ``` An example `.env.local` file can be found in `.env.tpl`. diff --git a/src/components/W3UIProvider.tsx b/src/components/W3UIProvider.tsx index 1807839..e2317d4 100644 --- a/src/components/W3UIProvider.tsx +++ b/src/components/W3UIProvider.tsx @@ -1,12 +1,16 @@ 'use client' import { Provider } from '@w3ui/react' -import { serviceConnection, servicePrincipal } from '@/components/services' +import { serviceConnection, servicePrincipal, receiptsURL } from '@/components/services' import { ReactNode } from 'react' export default function W3UIProvider ({ children }: { children: ReactNode }) { return ( - + <>{children} ) diff --git a/src/components/services.ts b/src/components/services.ts index 9b92d5f..93477a2 100644 --- a/src/components/services.ts +++ b/src/components/services.ts @@ -8,6 +8,12 @@ export const serviceURL = new URL( // 'https://staging.up.web3.storage' process.env.NEXT_PUBLIC_W3UP_SERVICE_URL ?? 'https://up.web3.storage' ) + +export const receiptsURL = new URL( + // 'https://staging.up.web3.storage/receipt/' + process.env.NEXT_PUBLIC_W3UP_RECEIPTS_URL ?? 'https://up.web3.storage/receipt/' +) + export const servicePrincipal = DID.parse( // 'did:web:staging.web3.storage' process.env.NEXT_PUBLIC_W3UP_SERVICE_DID ?? 'did:web:web3.storage'