Skip to content

Commit

Permalink
Modify MonitorExample
Browse files Browse the repository at this point in the history
* input monitor params from user
  • Loading branch information
inwonkim committed Aug 29, 2023
1 parent f49bd87 commit 747e131
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions quickstart/example/html/MonitorExample.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<br />
<div>
<h3>1. monitor block</h3>
<p>
<div><label for="M01-url">URL:</label><input type="text" id="M01-url" size="60" /></div>
<div><label for="M01-addr">Addr:</label><input type="text" id="M01-addr" size="45" /></div>
<div><label for="M01-event">Event:</label><input type="text" id="M01-event" size="60" /></div>
<p>
<button id="M01-1">start monitoring</button>
<button id="M01-2">stop</button>
<p><span id="M01-3"></span></p>
Expand Down
9 changes: 7 additions & 2 deletions quickstart/example/js/MonitorExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ class MonitorExample {
}

async startMonitorBlock() {
const url = getInputValue('M01-url');
const addr = getInputValue('M01-addr');
const event = getInputValue('M01-event');
const provider: HttpProvider = new HttpProvider(url);
this.iconService = new IconService(provider);
const block = await this.iconService.getLastBlock().execute();
const height = block.height;
const spec = new BlockMonitorSpec(Converter.toBigNumber(height + 1),
[new EventFilter("ICXIssued(int,int,int,int)", "cx0000000000000000000000000000000000000000")], true);
const eventFilter = new EventFilter(event, addr);
const spec = new BlockMonitorSpec(Converter.toBigNumber(height + 1), [eventFilter], true);
const onevent = (data: BlockNotification) => {
document.getElementById("M01-3").innerHTML = JSON.stringify(data);
}
Expand Down

0 comments on commit 747e131

Please sign in to comment.