Skip to content

Commit

Permalink
fix: add missing receiptsEndpoint to W3UIProvider (#144)
Browse files Browse the repository at this point in the history
## 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 <[email protected]>
  • Loading branch information
BravoNatalie and alanshaw authored Nov 25, 2024
1 parent 3449961 commit eaa7e50
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-storacha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 6 additions & 2 deletions src/components/W3UIProvider.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Provider connection={serviceConnection} servicePrincipal={servicePrincipal}>
<Provider
connection={serviceConnection}
servicePrincipal={servicePrincipal}
receiptsEndpoint={receiptsURL}
>
<>{children}</>
</Provider>
)
Expand Down
6 changes: 6 additions & 0 deletions src/components/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit eaa7e50

Please sign in to comment.