Skip to content

Commit 69b0f43

Browse files
committed
fix(space-creator): check provision result before proceeding
1 parent 5f135df commit 69b0f43

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.env.tpl

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# set these to your upload API service URL and the DID your service is using as its service DID
22
NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.web3.storage
33
NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage
4+
NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage
45

56
# set these to values from Stripe settings
67
NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1OCeiEF6A5ufQX5vPFlWRkPm

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update
2020

2121
### Using an alternate w3up service
2222

23-
By default, this app connects to https://up.web3.storage. To use an alternate service, specify
24-
the service URL and DID in your environment variables, like:
23+
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:
2524

2625
```
2726
NEXT_PUBLIC_W3UP_SERVICE_URL=https://your.w3up.service
2827
NEXT_PUBLIC_W3UP_SERVICE_DID=did:your-service-did
28+
NEXT_PUBLIC_W3UP_PROVIDER=did:your-provider-did
2929
```
3030

3131
An example `.env.local` file can be found in `.env.tpl`.
3232

3333
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.
3434

3535
<p style="text-align:center;padding-top:2rem">⁂</p>
36-
37-

src/components/SpaceCreator.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export function SpaceCreatorForm ({
5252
const space = await client.createSpace(name)
5353

5454
const provider = (process.env.NEXT_PUBLIC_W3UP_PROVIDER || 'did:web:web3.storage') as DID<'web'>
55-
await account.provision(space.did(), { provider })
55+
const result = await account.provision(space.did(), { provider })
56+
if (result.error) {
57+
setSubmitted(false)
58+
setCreated(false)
59+
throw result.error
60+
}
5661

5762
// MUST do this before creating recovery, as it creates necessary authorizations
5863
await space.save()

0 commit comments

Comments
 (0)