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!: integrate new ucanto and upload-client #119

Merged
merged 20 commits into from
Dec 2, 2022

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Nov 3, 2022

This PR makes breaking changes to core and framework components to integrate the access agent (+ucanto 0.9) and the new upload client.

resolves #127

BREAKING CHANGE: core and framework components have changed considerably.

TODO: be more explicit about changes

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 4, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 08bc15a:

Sandbox Source
@w3ui/example-react-file-upload Configuration
@w3ui/example-react-sign-up-in Configuration
@w3ui/example-react-uploads-list Configuration
@w3ui/example-solid-file-upload Configuration
@w3ui/example-solid-sign-up-in Configuration
@w3ui/example-solid-uploads-list Configuration
@w3ui/example-vue-file-upload Configuration
@w3ui/example-vue-sign-up-in Configuration
@w3ui/example-vue-uploads-list Configuration

@alanshaw alanshaw changed the title feat: integrate new ucanto feat: integrate new ucanto and refactor uploader API Nov 8, 2022
@alanshaw alanshaw changed the title feat: integrate new ucanto and refactor uploader API feat!: integrate new ucanto and refactor uploader API Nov 8, 2022
@alanshaw alanshaw marked this pull request as ready for review November 8, 2022 13:23
@alanshaw alanshaw requested a review from hugomrdias November 8, 2022 13:24
@alanshaw alanshaw changed the title feat!: integrate new ucanto and refactor uploader API feat!: integrate new ucanto and upload-client Nov 23, 2022
@alanshaw alanshaw removed the request for review from hugomrdias November 23, 2022 17:57
@yusefnapora
Copy link
Contributor

I've been working on fixing up the vanilla file upload example and keep getting a 500 error when actually doing the upload. I figured I'd sanity check by running the react upload example, but I get a 500 there also:

image

This is with a staging-service.js added to the example source:

staging-service.js
import { connect } from '@ucanto/client'
import { CAR, CBOR, HTTP } from '@ucanto/transport'
import * as DID from '@ipld/dag-ucan/did'

export const accessServiceURL = new URL('https://w3access-staging.protocol-labs.workers.dev')
export const accessServicePrincipal = DID.parse('did:key:z6MkwTYX2JHHd8bmaEuDdS1LJjrpFspirjDcQ4DvAiDP49Gm')

export const accessServiceConnection = connect({
  id: accessServicePrincipal,
  encoder: CAR,
  decoder: CBOR,
  channel: HTTP.open({
    url: accessServiceURL,
    method: 'POST'
  })
})

export const uploadServiceURL = new URL('https://staging.up.web3.storage')
export const uploadServicePrincipal = DID.parse('did:key:z6MkhcbEpJpEvNVDd3n5RurquVdqs5dPU16JDU5VZTDtFgnn')

export const uploadServiceConnection = connect({
  id: uploadServicePrincipal,
  encoder: CAR,
  decoder: CBOR,
  channel: HTTP.open({
    url: uploadServiceURL,
    method: 'POST'
  })
})

Which is hooked into the providers:

App.js snippet
import {
  accessServicePrincipal,
  accessServiceConnection,
  uploadServicePrincipal,
  uploadServiceConnection,
} from './staging-service.js'

function App () {
  return (
    <KeyringProvider servicePrincipal={accessServicePrincipal} connection={accessServiceConnection}>
      <UploaderProvider servicePrincipal={uploadServicePrincipal} connection={uploadServiceConnection}>
   /// ... etc

Also, I bumped the @web3-storage/access dep to 7.0.2, and have npm linked a bunch of things so the example projects will find the local copy of the w3ui components. Here's the npm list output inside the react file-upload example dir:

npm list for examples/react/file-upload
w3ui@0.0.0 /home/yusef/work/repos/w3ui
└─┬ @w3ui/example-react-file-upload@0.0.0 -> ./examples/react/file-upload
  ├─┬ @w3ui/react-keyring@1.0.1 -> ./packages/react-keyring
  │ ├── @ucanto/interface@3.0.1
  │ ├── @ucanto/principal@3.0.1
  │ ├─┬ @w3ui/keyring-core@1.0.2 -> ./packages/keyring-core
  │ │ └── @web3-storage/access@7.0.2
  │ ├── @web3-storage/access@7.0.2
  │ └── react@18.2.0 deduped
  ├─┬ @w3ui/react-uploader@2.1.2 -> ./packages/react-uploader
  │ ├── @w3ui/react-keyring@1.0.1 deduped -> ./packages/react-keyring
  │ ├─┬ @w3ui/uploader-core@2.0.2 -> ./packages/uploader-core
  │ │ ├── @web3-storage/upload-client@2.1.0
  │ │ └── multiformats@10.0.2 deduped
  │ ├── multiformats@10.0.2
  │ └── react@18.2.0 deduped
  ├── react-dom@18.2.0
  ├── react-scripts@5.0.1
  └── react@18.2.0

@alanshaw should this be working, or is there some other config I need?

@flea89
Copy link
Contributor

flea89 commented Dec 2, 2022

I'm having the same issue reported by @yusefnapora on a react app I created from scratch using this version of w3ui when trying to upload a file. (Auth, space, agent generations seemed to have worked just fine)

Screenshot 2022-12-02 at 10 55 06

I've used npm link to point to a local, compiled and built version of w3ui using this branch.
I also bumped @web3-storage/access dep to 7.0.2

My staging service
import { connect } from '@ucanto/client'
import { CAR, CBOR, HTTP } from '@ucanto/transport'
import * as DID from '@ipld/dag-ucan/did'

export const accessServiceURL = new URL('https://w3access-staging.protocol-labs.workers.dev')
export const accessServicePrincipal = DID.parse('did:key:z6MkwTYX2JHHd8bmaEuDdS1LJjrpFspirjDcQ4DvAiDP49Gm')

export const accessServiceConnection = connect({
id: accessServicePrincipal,
encoder: CAR,
decoder: CBOR,
channel: HTTP.open({
  url: accessServiceURL,
  method: 'POST'
})
})

export const uploadServiceURL = new URL('https://staging.up.web3.storage')
export const uploadServicePrincipal = DID.parse('did:key:z6MkhcbEpJpEvNVDd3n5RurquVdqs5dPU16JDU5VZTDtFgnn')

export const uploadServiceConnection = connect({
id: uploadServicePrincipal,
encoder: CAR,
decoder: CBOR,
channel: HTTP.open({
  url: uploadServiceURL,
  method: 'POST'
})
})

I also tried your space-manager example in this branch, and listing uploads also return a 500 Internal Server Error

@alanshaw alanshaw changed the base branch from main to next December 2, 2022 15:11
@alanshaw
Copy link
Member Author

alanshaw commented Dec 2, 2022

I'm merging this into a branch called next and we'll land additional changes/fixes there and merge to main when the new service is deployed.

@alanshaw alanshaw merged commit c824e44 into next Dec 2, 2022
@alanshaw alanshaw deleted the feat/integrate-new-ucanto branch December 2, 2022 15:14
alanshaw pushed a commit that referenced this pull request Dec 2, 2022
This just updates the vanilla sign up/in example to use the new stuff
from #119.

I've got the file upload example nearly done as well, but need to wrap
things up for the day, so I'll finish it tomorrow.

@alanshaw this PR is targeting the branch from #119, so feel free to
pull it in there if you want. Otherwise I'll retarget this one after
that one merges.

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
alanshaw pushed a commit that referenced this pull request Dec 2, 2022
This updates the markdown docs based on the changes in #119.

I _think_ I got everything, but @alanshaw should probably take a look :)

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
@alanshaw
Copy link
Member Author

alanshaw commented Dec 2, 2022

@flea89 @yusefnapora @travis it's an issue with calling the access-api (the space/info invocation). Tracking here: storacha/w3up#243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate new ucanto and upload-client
3 participants