From 69b0f43c165e5edf2e1df31ce3528aba293ad657 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 4 Sep 2024 10:17:54 -0300 Subject: [PATCH 1/3] fix(space-creator): check provision result before proceeding --- .env.tpl | 1 + README.md | 6 ++---- src/components/SpaceCreator.tsx | 7 ++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.env.tpl b/.env.tpl index 80607cf..eebc36d 100644 --- a/.env.tpl +++ b/.env.tpl @@ -1,6 +1,7 @@ # 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_SERVICE_DID=did:web:staging.web3.storage +NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage # set these to values from Stripe settings NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1OCeiEF6A5ufQX5vPFlWRkPm diff --git a/README.md b/README.md index 4f30b4a..89cc676 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update ### Using an alternate w3up service -By default, this app connects to https://up.web3.storage. To use an alternate service, specify -the service URL and DID in your environment variables, like: +By default, this app connects to https://up.web3.storage, and uses web:web3.storage as provider. To use an alternate service, specify the service URL and DID in your environment variables, like: ``` 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 ``` An example `.env.local` file can be found in `.env.tpl`. @@ -33,5 +33,3 @@ An example `.env.local` file can be found in `.env.tpl`. If you are using `w3infra`, the service URL will be displayed as the `UploadApiStack`'s `ApiEndpoint` output once `npm start` has successfully set up your development environment.

- - diff --git a/src/components/SpaceCreator.tsx b/src/components/SpaceCreator.tsx index 24bc9a4..f3b8170 100644 --- a/src/components/SpaceCreator.tsx +++ b/src/components/SpaceCreator.tsx @@ -52,7 +52,12 @@ export function SpaceCreatorForm ({ const space = await client.createSpace(name) const provider = (process.env.NEXT_PUBLIC_W3UP_PROVIDER || 'did:web:web3.storage') as DID<'web'> - await account.provision(space.did(), { provider }) + const result = await account.provision(space.did(), { provider }) + if (result.error) { + setSubmitted(false) + setCreated(false) + throw result.error + } // MUST do this before creating recovery, as it creates necessary authorizations await space.save() From dbfed7377ddbeb826c7d4eb49ce1f6064b322870 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 4 Sep 2024 11:15:05 -0300 Subject: [PATCH 2/3] Update README.md Co-authored-by: Alan Shaw --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89cc676..bf3e845 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update ### Using an alternate w3up service -By default, this app connects to https://up.web3.storage, and uses web:web3.storage as provider. To use an alternate service, specify the service URL and DID in your environment variables, like: +By default, this app connects to `https://up.web3.storage`, and uses `did:web:web3.storage` as provider. To use an alternate service and/or provider, specify the service URL, service DID and provider DID in your environment variables, like so: ``` NEXT_PUBLIC_W3UP_SERVICE_URL=https://your.w3up.service From a55d1aa63446c0dd28402fa117db6059868c4d86 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 4 Sep 2024 11:15:52 -0300 Subject: [PATCH 3/3] Update src/components/SpaceCreator.tsx Co-authored-by: Alan Shaw --- src/components/SpaceCreator.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SpaceCreator.tsx b/src/components/SpaceCreator.tsx index f3b8170..1e3b503 100644 --- a/src/components/SpaceCreator.tsx +++ b/src/components/SpaceCreator.tsx @@ -56,7 +56,7 @@ export function SpaceCreatorForm ({ if (result.error) { setSubmitted(false) setCreated(false) - throw result.error + throw new Error(`failed provisioning space: ${space.did()} with provider: ${provider}`, { cause: result.error }) } // MUST do this before creating recovery, as it creates necessary authorizations