Created
March 4, 2020 11:58
-
-
Save jimmychu0807/4fe3f8643c3474d42239e2ac823cd0c7 to your computer and use it in GitHub Desktop.
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 創建 api | |
// const api = await ...; | |
api.query.system.events(events => { | |
events.forEach(record => { | |
// 遍歷所有事件記錄 | |
const { event, phase } = record; | |
const types = event.typeDef; | |
// 過濾掉我們不關注的事件 | |
const eventName = `${event.section}:${ | |
event.method | |
}:: (phase=${phase.toString()})`; | |
if (filter.includes(eventName)) return; | |
// 從這裡開始,對我們關注的事件作進一步的處理 | |
// ... | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment