1
0
mirror of https://github.com/oceanprotocol/react-tutorial synced 2024-11-21 17:26:58 +01:00

keep track of registered asset so consume always works

This commit is contained in:
Matthias Kretschmann 2019-11-20 18:20:50 +01:00
parent 876afd6238
commit e639e9ed44
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

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