keep track of registered asset so consume always works
This commit is contained in:
parent
876afd6238
commit
e639e9ed44
|
@ -14,7 +14,8 @@ if (window.web3) {
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
state = {
|
state = {
|
||||||
ocean: undefined,
|
ocean: undefined,
|
||||||
results: []
|
results: [],
|
||||||
|
ddo: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
@ -43,6 +44,8 @@ class App extends Component {
|
||||||
const ddo = await this.state.ocean.assets.create(asset, accounts[0])
|
const ddo = await this.state.ocean.assets.create(asset, accounts[0])
|
||||||
console.log('Asset successfully submitted.')
|
console.log('Asset successfully submitted.')
|
||||||
console.log(ddo)
|
console.log(ddo)
|
||||||
|
// keep track of this registered asset for consumption later on
|
||||||
|
this.setState({ ddo })
|
||||||
alert(
|
alert(
|
||||||
'Asset successfully submitted. Look into your console to see the response DDO object.'
|
'Asset successfully submitted. Look into your console to see the response DDO object.'
|
||||||
)
|
)
|
||||||
|
@ -70,8 +73,8 @@ class App extends Component {
|
||||||
try {
|
try {
|
||||||
// get all accounts
|
// get all accounts
|
||||||
const accounts = await this.state.ocean.accounts.list()
|
const accounts = await this.state.ocean.accounts.list()
|
||||||
// get first asset from search results
|
// get our registered asset
|
||||||
const consumeAsset = this.state.results[0]
|
const consumeAsset = this.state.ddo
|
||||||
// get service we want to execute
|
// get service we want to execute
|
||||||
const service = consumeAsset.findServiceByType('access')
|
const service = consumeAsset.findServiceByType('access')
|
||||||
// order service agreement
|
// order service agreement
|
||||||
|
|
Loading…
Reference in New Issue