|
1 | 1 | import type { ChangeEvent } from 'react'
|
2 | 2 |
|
3 | 3 | import React, { useState } from 'react'
|
4 |
| -import { Space, useW3 } from '@w3ui/react' |
| 4 | +import { ContentServeService, Space, useW3 } from '@w3ui/react' |
5 | 5 | import Loader from '../components/Loader'
|
6 |
| -import { DID, DIDKey } from '@ucanto/interface' |
| 6 | +import { ConnectionView, DID, DIDKey } from '@ucanto/interface' |
7 | 7 | import { DidIcon } from './DidIcon'
|
8 | 8 | import Link from 'next/link'
|
9 | 9 | import { FolderPlusIcon, InformationCircleIcon } from '@heroicons/react/24/outline'
|
10 | 10 | import Tooltip from './Tooltip'
|
11 | 11 | import { H3 } from './Text'
|
| 12 | +import * as UcantoClient from '@ucanto/client' |
| 13 | +import { HTTP } from '@ucanto/transport' |
| 14 | +import * as CAR from '@ucanto/transport/car' |
12 | 15 |
|
13 | 16 | export function SpaceCreatorCreating(): JSX.Element {
|
14 | 17 | return (
|
@@ -52,7 +55,21 @@ export function SpaceCreatorForm({
|
52 | 55 |
|
53 | 56 | setSubmitted(true)
|
54 | 57 | try {
|
55 |
| - const space = await client.createSpace(name) |
| 58 | + |
| 59 | + const gatewayId = (process.env.NEXT_PUBLIC_W3UP_GATEWAY_ID || 'did:web:w3s.link') as DID<'web'> |
| 60 | + const gatewayUrl = process.env.NEXT_PUBLIC_W3UP_GATEWAY_HOST || 'https://freeway.dag.haus' as string |
| 61 | + |
| 62 | + const storachaGateway = UcantoClient.connect({ |
| 63 | + id: { |
| 64 | + did: () => gatewayId |
| 65 | + }, |
| 66 | + codec: CAR.outbound, |
| 67 | + channel: HTTP.open({ url: new URL(gatewayUrl) }), |
| 68 | + }) as ConnectionView<ContentServeService> |
| 69 | + |
| 70 | + const space = await client.createSpace(name, { |
| 71 | + authorizeGatewayServices: [storachaGateway] |
| 72 | + }) |
56 | 73 |
|
57 | 74 | const provider = (process.env.NEXT_PUBLIC_W3UP_PROVIDER || 'did:web:web3.storage') as DID<'web'>
|
58 | 75 | const result = await account.provision(space.did(), { provider })
|
|
0 commit comments