1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

changed signature of requestTokens to match py version, adapted readme, removed getInstance()

This commit is contained in:
Sebastian Gerske 2018-09-20 14:19:27 +02:00
parent 82f7b0001c
commit a2c19d7d89
5 changed files with 24 additions and 41 deletions

View File

@ -36,20 +36,20 @@ Start by adding the package to your dependencies:
npm i @oceanprotocol/squid npm i @oceanprotocol/squid
``` ```
The package exposes `OceanAgent` and `OceanKeeper` which you can import in your code like so: The package exposes `OceanAgent` and `Ocean` which you can import in your code like so:
```js ```js
// ES6 // ES6
import { OceanAgent, OceanKeeper } from '@oceanprotocol/squid' import { OceanAgent, Ocean } from '@oceanprotocol/squid'
// ES2015 // ES2015
const { OceanAgent, OceanKeeper } = require('@oceanprotocol/squid') const { OceanAgent, Ocean } = require('@oceanprotocol/squid')
``` ```
You can then connect to a running [Keeper](https://github.com/oceanprotocol/keeper-contracts) & [Provider](https://github.com/oceanprotocol/provider) instance, e.g.: You can then connect to a running [Keeper](https://github.com/oceanprotocol/keeper-contracts) & [Provider](https://github.com/oceanprotocol/provider) instance, e.g.:
```js ```js
const oceanKeeper = new OceanKeeper('http://localhost:8545', 'development') const ocean = await new Ocean({uri: 'http://localhost:8545', network: 'development'})
const oceanAgent = new OceanAgent('http://localhost:5000/api/v1/provider') const oceanAgent = new OceanAgent('http://localhost:5000/api/v1/provider')
``` ```

View File

@ -5,14 +5,10 @@ export default class OceanAuth extends KeeperBase {
constructor(web3, network) { constructor(web3, network) {
super(web3, network) super(web3, network)
const instance = this return (async () => {
this.contract = await ContractLoader.load('OceanAuth', this._network, this._web3)
return { return this
async getInstance() { })()
instance.contract = await ContractLoader.load('OceanAuth', instance._network, instance._web3)
return instance
}
}
} }
cancelAccessRequest(orderId, senderAddress) { cancelAccessRequest(orderId, senderAddress) {

View File

@ -7,15 +7,10 @@ export default class OceanMarket extends KeeperBase {
constructor(web3, network) { constructor(web3, network) {
super(web3, network) super(web3, network)
const instance = this return (async () => {
this.contract = await ContractLoader.load('OceanMarket', this._network, this._web3)
return { return this
async getInstance() { })()
instance.contract = await ContractLoader.load('OceanMarket', instance._network, instance._web3)
return instance
}
}
} }
// call functions (costs no gas) // call functions (costs no gas)
@ -33,8 +28,8 @@ export default class OceanMarket extends KeeperBase {
} }
// Transactions with gas cost // Transactions with gas cost
requestTokens(senderAddress, numTokens) { requestTokens(amount, address) {
return this.contract.requestTokens(numTokens, { from: senderAddress }) return this.contract.requestTokens(amount, { from: address })
} }
async registerAsset(name, description, price, publisherAddress) { async registerAsset(name, description, price, publisherAddress) {

View File

@ -6,15 +6,11 @@ export default class OceanToken extends KeeperBase {
constructor(web3, network) { constructor(web3, network) {
super(web3, network) super(web3, network)
const instance = this return (async () => {
this.contract = await ContractLoader.load('OceanToken', this._network, this._web3)
return { return this
async getInstance() { })()
instance.contract = await ContractLoader.load('OceanToken', instance._network, instance._web3)
return instance
}
}
} }
getTokenBalance(accountAddress) { getTokenBalance(accountAddress) {

View File

@ -16,17 +16,13 @@ export default class Ocean {
this.helper = new Web3Helper(this._web3) this.helper = new Web3Helper(this._web3)
const instance = this return (async () => {
this.market = await new OceanMarket(this._web3, this._network)
this.auth = await new OceanAuth(this._web3, this._network)
this.token = await new OceanToken(this._web3, this._network)
return { return this
async getInstance() { })()
instance.market = await new OceanMarket(instance._web3, instance._network).getInstance()
instance.auth = await new OceanAuth(instance._web3, instance._network).getInstance()
instance.token = await new OceanToken(instance._web3, instance._network).getInstance()
return instance
}
}
} }
async getAccounts() { async getAccounts() {