Comments (24)
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.
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 theeth
attribute on your object, i.e. asparatii.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 callparatii.db.videos.get
.
from paratii-js.
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);
});
});
Also to note, if I try to include a property of ipfsHash
in the create()
call, I get this error:
from paratii-js.
@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.
@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.
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.
Error fixed in this commit f84578d
@bent0b0x Let me know if you're still having issues with this.
from paratii-js.
Thanks @ya7ya, that cleared up that issue! However, now I see this:
from paratii-js.
@bent0b0x oh, i see, I'll push a fix now 👍
from paratii-js.
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.
Let me know if something else pops up 😄 👍
from paratii-js.
It looks like calling paratii core indirectly calls paratii eth, which leads to problem given how I'm instantiating Paratii
. Thoughts?
from paratii-js.
cc @jellegerbrandy ☝️
@bent0b0x you sure testrpc
is up and running ? we probably need to deploy a test registry i think
from paratii-js.
Yes it is running
from paratii-js.
@jellegerbrandy I tried your suggestion of calling paratii.eth.deployContracts()
, but I get the following error:
This is how Paratii
was inited:
const paratii = new Paratii({
provider: 'http://localhost:8545'
})
from paratii-js.
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.
@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.
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.
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.
@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.
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
toipfshash
, 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.
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 toparatii-portal
? And then store this data inparatii-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.
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.
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)
- implement image resize API
- Tests fails in general because TXs stay in pending status on parity waiting for manual confirmation HOT 2
- maxlistenersexceededwarning
- Critical dependency: the request of a dependency is an expression
- documentation is not automatically updated
- commitVote shoudl return the secret hash HOT 1
- User creation needs to throw explicit error if username is not unique HOT 1
- we need a method to get the `totalStaked` PTI of a user HOT 1
- migrate TCR to use the new contract instead of the placeholder HOT 1
- upgrade docs with new TCR functionality
- vids.get should return the TCR status
- paratii.eth.transfer should throw error when you have insufficient funds HOT 3
- paratii.eth.tcr.isWhitelisted stay false HOT 2
- BN error on staging after login HOT 2
- Ben's issue with the transfer function HOT 4
- paratii.eth.tcr.getTotalStaked return a value too high
- IPFS error: QuotaExceededError HOT 5
- getTotalStaked is not very scalable HOT 1
- create a "cancel upload" function HOT 2
- paratii.eth.tcr.challengeExists throws Error: Listing with videoId DpHbf0chiRwa doesn't exist HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paratii-js.