GithubHelp home page GithubHelp logo

Comments (24)

ya7ya avatar ya7ya commented on August 23, 2024 1

hey @bent0b0x , this is pretty weird since this code has nothing to do with ipfs 😏 . I'll investigate deeper. Thanks for the heads up.

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

Yeah, sorry about the lack of documentation, I'll try to update it. Work in progress. Also there are many things that are simply not working yet. Here's some pointers:

  • Need ethereum address for fetching data of video: if it's true, it is a bug.

  • There should be no need in the client code to instantiate ParatiiEth directly. The way to use it would be to have one single paratii = new Paratii(..) instance in the app, and access the paratiiEth instance as the eth attribute on your object, i.e. as paratii.eth

  • The situation is complex, and the API and docs should hide this complexitity but does not do so very well yet. But the pattern for getting information about a video once you have the videoId would be:

    let paratii = new Paratii({provider: ...})
    paratii.core.videos.get(videoId)

Actually, I am thinking of removing this core invocation as well, so it can just become: paratii.videos.get().

  • To give you an idea of the inner workings:
    paratii.eth.videos.get(videoId) : query the blockcahin for information about the video. (this info is partial, because some info is stored in ipfs)
    paratii.db.videos.get(videoId) (not working yet): get video info from the database index, a service that we provide, that makes the info we have stored about videos on the blockahin and in ipfs indexed and searchable
    paratii.core.videos.get(videoId): get info about hte video, you don't care where it comes from. At the moment, this will get data from blockahin and ipfs, in a next iteration it should just call paratii.db.videos.get.

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

I will change the title of this issue because I think you do not, in fact, need an eth address to fetch data about a video. However, I cannot get it working still (I am running testrpc locally)

Right now I am using code like this:

const paratii = new Paratii({
  provider: "http://localhost:8545"
});

paratii.core.vids
  .create({
    id: "0x90f8bf6a479",
    owner: "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1"
  })
  .then(() => {
    paratii.core.vids
      .get("0x90f8bf6a479")
      .then(res => {
        console.log(res);
      })
      .catch(e => {
        console.log("e: ", e);
      });
  });

which results in an error:
image

Also to note, if I try to include a property of ipfsHash in the create() call, I get this error:

image

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

@bent0b0x: ok, probably a bug. The fact that you cannot pass ain ipfsHash explicitly is correct. Can you push a branch with this bug, so we save time on trying to reproduce?

@ya7ya : The calls from core may touch on the ipfs code - the idea is that parati.eth does the blockcahin stuff, paratii.ipfs the ipfs things, paratii.db the database stuff, and paratii.core (which is what ben is using here) ties everything together and can (and does) call ipfs under the hood.

from paratii-js.

ya7ya avatar ya7ya commented on August 23, 2024

@bent0b0x @jellegerbrandy I figured out the problem, the this.config in getIPFSInstance changes based on the scope of the function that calls it. so Cannot read property 'closed' of null is because the repo was null. i'm gonna push the fixes now to the ipfs branch

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

In any case, @bent0b0x , here is the corresponding test (which works and seems verys imilar to your code) for reference: https://github.com/Paratii-Video/paratii-lib/blob/master/test/paratii.core.vids.js#L19

from paratii-js.

ya7ya avatar ya7ya commented on August 23, 2024

Error fixed in this commit f84578d

@bent0b0x Let me know if you're still having issues with this.

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

Thanks @ya7ya, that cleared up that issue! However, now I see this:

image

from paratii-js.

ya7ya avatar ya7ya commented on August 23, 2024

@bent0b0x oh, i see, I'll push a fix now 👍

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

If you check out the branch 16-player you can test this out, load up localhost:8080 and the app will try to run the lib code (via VideoActions.js).

Of course you'll need to yarn link to paratii-lib

from paratii-js.

ya7ya avatar ya7ya commented on August 23, 2024

@bent0b0x fixed in 7778f67

Let me know if something else pops up 😄 👍

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

@ya7ya

image

It looks like calling paratii core indirectly calls paratii eth, which leads to problem given how I'm instantiating Paratii. Thoughts?

from paratii-js.

ya7ya avatar ya7ya commented on August 23, 2024

cc @jellegerbrandy ☝️

@bent0b0x you sure testrpc is up and running ? we probably need to deploy a test registry i think

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

Yes it is running

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

@jellegerbrandy I tried your suggestion of calling paratii.eth.deployContracts(), but I get the following error:

image

This is how Paratii was inited:

const paratii = new Paratii({
  provider: 'http://localhost:8545'
})

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

Yes.
So you need an ethereofum account to write stuff to the blockchain (such as deploying contracts). That means you need to provide an address as well as a way of signing messages with that address (either a private key or a wallet loaded from localStorage):

This can be either specified on start up

   Paratii({ address: 0x12345, privateKey: 'xxxx })

Or with the setAccount function indicated in the error message:

   paratii.setAccount({ address: '0x2332', privateKey: 'dsfaskfd'})

Where to get that key? It needs to be of an account that has some ether available to pay for the transactions. We are now setting this up #31, should be done today, and then we use the same config for testig in the portal.

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

@jellegerbrandy the private key for this test account, is this something we don't mind publishing in our code? And either way this will need to run in the browser so it will be discoverable, yes?

I'm still unclear on what we are doing for production. What does this address represent? Is it paratii's address so that we can communicate w/ the blockchain for the user? Because users will not be required to have an account to read info about a video, for example.

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

Okay, I think I am very close to having this working (at least for a POC) in the portal. I am able to instantiate paratii-lib, deploy the contracts, and then create a video like so:

lib.core.vids
      .create({
        id,
        price: 0,
        owner: '0xa99dBd162ad5E1601E8d8B20703e5A3bA5c00Be7'
      })

Then I can fetch it with a .get().

Now, I would like to test actually .get()-ing a video that is streamable via ipfs (because in the example above I am creating a dummy video). My first thought was to take the ipfsHash from a video that we are already using in paratii player and add that in to my .create() call, but I get errors saying that ipfsHash is not an allowed property.

Anyways, I feel like I might be going down the wrong route anyway. Thoughts on how to do this?

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

This is exactly the way it is supposed to be used.

The core.vids.create() does not take the ipfsHash, because I thought that the typical case would be that it would take a 'file' argument and create the hash itself. I created an issue on the paratii-lib repo to add this: #39

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

@jellegerbrandy I think passing in file does, indeed, make the most sense. I was trying to pass in ipfsHash for testing purposes, so I'm not sure that #39 will be necessary. Do we anticipate file being of type File?

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

here some more responses to your questions, @bent0b0x

  • The address (and private key) used when initializating Paratii represent the users's ethereum address
  • Each client instance always has an associated ethereum address. Even when we do what we called "anonymous navigation" - if we do not know which user we have (i.e. there is no cookie), we simply generate a new address.
  • We don't mind publishing the test private key, because it is an account used for testing purposes only. It is just "some" account.
  • About the ipfshash arg: I think it is still useful in any case to be able to set the hash directory. (Typically, this will be the hash of the transcoded files - i.e. it may take a long time to go from file to ipfshash, because we need to do all the transcoding). So I'll leave #39 open.
  • The "file" argument should probably be of type "filestream". #44
  • And it is not yet working (core.vids.create() ignored the file argument: #46)

from paratii-js.

bent0b0x avatar bent0b0x commented on August 23, 2024

Thanks! I have a couple of questions remaining:

  • Regarding list item 2: what part of our stack is taking care of this? Will we have to replicate this functionality (that I'm assuming existed) in paratii-video and port it to paratii-portal? And then store this data in paratii-portal's application state?
  • Regarding list item 3: If our tests are reliant on this test account having some amount of ETH/PTI, is there an api in paratii-lib to set the amount of ETH/PTI associated w/ an account? Otherwise we will end up coding tests w/o knowing the exact balance of our account

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

Regarding your first question: who/what is taking care of each client already having an ethereum address. So, yes, in paratii-player it was already working like that, the tests are here: https://github.com/Paratii-Video/paratii-portal/blob/dev/test/functional-tests/profile.spec.js

In paratii-lib, this stuff is handled by various functions in paratii.eth.wallet that are used for createing and serializing account info; the paratii-portal code will have to glue this together and call the right things at the right moment: how that should be done is encoded in the profile.spec.js. (more or less, that is)

Regarding the question: how is the test account gonna get some PTI and ETH to work with? I think we can use the same mechanism as in paratii-lib (where we are also setting up a test account and giving it some money). @geckoslair coded that, I have not looked into the details.

from paratii-js.

jellegerbrandy avatar jellegerbrandy commented on August 23, 2024

closing this as I do not see anything actionable anymore... feel free to reopen of create a new issues if things were left unresolved

from paratii-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.