mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
removed old stuff
This commit is contained in:
parent
b145fef282
commit
a43db07334
@ -1,37 +0,0 @@
|
|||||||
import KeeperBase from './keeper/keeper-base'
|
|
||||||
|
|
||||||
export default class Account extends KeeperBase {
|
|
||||||
constructor(web3Helper, token) {
|
|
||||||
super(web3Helper)
|
|
||||||
this.token = token
|
|
||||||
return (async () => {
|
|
||||||
return this
|
|
||||||
})()
|
|
||||||
}
|
|
||||||
|
|
||||||
async list() {
|
|
||||||
return Promise.all((await this.helper.getAccounts()).map(async (account) => {
|
|
||||||
// await ocean.market.requestTokens(account, 1000)
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: account,
|
|
||||||
balance: {
|
|
||||||
ocn: await this.token.getTokenBalance(account),
|
|
||||||
eth: await this.token.getEthBalance(account)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
currentAccount() {
|
|
||||||
return this.helper.getCurrentAccount()
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenBalance() {
|
|
||||||
return this.token.getTokenBalance()
|
|
||||||
}
|
|
||||||
|
|
||||||
ethBalance() {
|
|
||||||
return this.token.getEthBalance()
|
|
||||||
}
|
|
||||||
}
|
|
52
src/order.js
52
src/order.js
@ -1,52 +0,0 @@
|
|||||||
import KeeperBase from './keeper/keeper-base'
|
|
||||||
|
|
||||||
export default class Order extends KeeperBase {
|
|
||||||
constructor(web3Helper, market, token, auth) {
|
|
||||||
super(web3Helper)
|
|
||||||
this.market = market
|
|
||||||
this.token = token
|
|
||||||
this.auth = auth
|
|
||||||
return (async () => {
|
|
||||||
return this
|
|
||||||
})()
|
|
||||||
}
|
|
||||||
|
|
||||||
buyService(serviceDID, publisherId, price, timeout, senderAddress, initialRequestEventHandler,
|
|
||||||
accessCommittedEventHandler, tokenPublishedEventHandler) {
|
|
||||||
// Allow market contract to transfer funds on the consumer's behalf
|
|
||||||
const { token, market, auth } = this
|
|
||||||
token.contract.approve(market.address, price, { from: senderAddress, gas: 2000000 })
|
|
||||||
// Submit the access request
|
|
||||||
auth.contract.initiateAccessRequest(
|
|
||||||
serviceDID, publisherId, timeout, { from: senderAddress, gas: 1000000 }
|
|
||||||
)
|
|
||||||
|
|
||||||
const resourceFilter = { _resourceId: serviceDID, _consumer: senderAddress }
|
|
||||||
const initRequestEvent = auth.contract.AccessConsentRequested(resourceFilter)
|
|
||||||
let order = {}
|
|
||||||
this._listenOnce(
|
|
||||||
initRequestEvent,
|
|
||||||
'AccessConsentRequested',
|
|
||||||
(result, error) => {
|
|
||||||
order = initialRequestEventHandler(result, error)
|
|
||||||
const requestIdFilter = { _id: order.id }
|
|
||||||
const accessCommittedEvent = auth.contract.AccessRequestCommitted(requestIdFilter)
|
|
||||||
const tokenPublishedEvent = auth.contract.EncryptedTokenPublished(requestIdFilter)
|
|
||||||
this._listenOnce(
|
|
||||||
accessCommittedEvent,
|
|
||||||
'AccessRequestCommitted',
|
|
||||||
(result, error) => {
|
|
||||||
accessCommittedEventHandler(result, order, error)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
this._listenOnce(
|
|
||||||
tokenPublishedEvent,
|
|
||||||
'EncryptedTokenPublished',
|
|
||||||
(result, error) => {
|
|
||||||
tokenPublishedEventHandler(result, order, error)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
return order
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
import KeeperBase from './keeper/keeper-base'
|
|
||||||
import MetaData from './metadata'
|
|
||||||
|
|
||||||
export default class Service extends KeeperBase {
|
|
||||||
constructor(web3Helper, market) {
|
|
||||||
super(web3Helper)
|
|
||||||
this.market = market
|
|
||||||
return (async () => {
|
|
||||||
return this
|
|
||||||
})()
|
|
||||||
}
|
|
||||||
|
|
||||||
serviceMetadata(assetDID) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
serviceTribe() {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
createDDO(did, metadata) {
|
|
||||||
return {
|
|
||||||
'@context': 'https://w3id.org/did/v1',
|
|
||||||
id: did,
|
|
||||||
publicKey: [],
|
|
||||||
authentication: [],
|
|
||||||
service: [],
|
|
||||||
metadata: metadata
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resolveDID(did) {
|
|
||||||
const providerURL = this.market.resolveDID(did)
|
|
||||||
const metadataGuy = new MetaData(providerURL)
|
|
||||||
return metadataGuy.getAssetDDO(did)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user