Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use two env vars to configure service not four #562

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ jobs:
working-directory: examples/react/w3console
env:
VITE_W3UP_PROVIDER: did:web:staging.web3.storage
VITE_W3UP_ACCESS_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_ACCESS_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_UPLOAD_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_UPLOAD_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_SERVICE_BRAND_NAME: 'staging.web3.storage'
- name: Publish staging.console.web3.storage
uses: ./.github/actions/preview
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/w3console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ jobs:
run: pnpm build
working-directory: examples/react/w3console
env:
VITE_W3UP_ACCESS_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_ACCESS_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_UPLOAD_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_UPLOAD_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_SERVICE_URL: 'https://staging.up.web3.storage'
VITE_W3UP_SERVICE_DID: 'did:web:staging.web3.storage'
VITE_W3UP_SERVICE_BRAND_NAME: 'preview.web3.storage'
- name: Publish static site
uses: ./.github/actions/preview
Expand Down
8 changes: 4 additions & 4 deletions examples/react/w3console/src/components/W3API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
KeyringContextValue,
KeyringProvider
} from '@w3ui/react-keyring'
import { accessServiceConnection, accessServicePrincipal, uploadServiceConnection, uploadServicePrincipal } from './services'
import { serviceConnection, servicePrincipal } from './services'

export interface W3APIContextValue {
keyring: KeyringContextValue
Expand All @@ -32,9 +32,9 @@ export function W3APIProvider ({
uploadsListPageSize
}: W3APIProviderProps): JSX.Element {
return (
<KeyringProvider servicePrincipal={accessServicePrincipal} connection={accessServiceConnection}>
<UploaderProvider servicePrincipal={uploadServicePrincipal} connection={uploadServiceConnection}>
<UploadsListProvider servicePrincipal={uploadServicePrincipal} connection={uploadServiceConnection} size={uploadsListPageSize}>
<KeyringProvider servicePrincipal={servicePrincipal} connection={serviceConnection}>
<UploaderProvider servicePrincipal={servicePrincipal} connection={serviceConnection}>
<UploadsListProvider servicePrincipal={servicePrincipal} connection={serviceConnection} size={uploadsListPageSize}>
<>{children}</>
</UploadsListProvider>
</UploaderProvider>
Expand Down
34 changes: 8 additions & 26 deletions examples/react/w3console/src/components/services.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
import type { Service } from '@web3-storage/access/types'
import { connect } from '@ucanto/client'
import { CAR, CBOR, HTTP } from '@ucanto/transport'
import { CAR, HTTP } from '@ucanto/transport'
import * as DID from '@ipld/dag-ucan/did'


export const accessServiceURL = new URL(
export const serviceURL = new URL(
//'https://staging.up.web3.storage'
import.meta.env.VITE_W3UP_ACCESS_SERVICE_URL ?? 'https://access.web3.storage'
import.meta.env.VITE_W3UP_SERVICE_URL ?? 'https://up.web3.storage'
)
export const accessServicePrincipal = DID.parse(
export const servicePrincipal = DID.parse(
//'did:web:staging.web3.storage'
import.meta.env.VITE_W3UP_ACCESS_SERVICE_DID ?? 'did:web:web3.storage'
import.meta.env.VITE_W3UP_SERVICE_DID ?? 'did:web:web3.storage'
)

export const accessServiceConnection = connect<Service>({
id: accessServicePrincipal,
export const serviceConnection = connect<Service>({
id: servicePrincipal,
codec: CAR.outbound,
channel: HTTP.open<Record<string, any>>({
url: accessServiceURL,
method: 'POST',
}),
})

export const uploadServiceURL = new URL(
//'https://staging.up.web3.storage'
import.meta.env.VITE_W3UP_UPLOAD_SERVICE_URL ?? 'https://up.web3.storage'
)
export const uploadServicePrincipal = DID.parse(
//'did:web:staging.web3.storage'
import.meta.env.VITE_W3UP_UPLOAD_SERVICE_DID ?? 'did:web:web3.storage'
)

export const uploadServiceConnection = connect<Service>({
id: uploadServicePrincipal,
codec: CAR.outbound,
channel: HTTP.open<Record<string, any>>({
url: uploadServiceURL,
url: serviceURL,
method: 'POST',
}),
})
Expand Down
Loading