|
@@ -2,7 +2,7 @@ import { WsProvider, ApiPromise } from "@polkadot/api";
|
|
import { types } from "@joystream/types";
|
|
import { types } from "@joystream/types";
|
|
import { Vec } from "@polkadot/types";
|
|
import { Vec } from "@polkadot/types";
|
|
import { EventRecord, Hash } from "@polkadot/types/interfaces";
|
|
import { EventRecord, Hash } from "@polkadot/types/interfaces";
|
|
-import { getBatchAction, getRemovedAction } from "./functions";
|
|
|
|
|
|
+import { getChangeAction } from "./functions";
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
async function main() {
|
|
@@ -19,32 +19,36 @@ async function main() {
|
|
const blockHash = await api.rpc.chain.getBlockHash(blockHeight) as Hash
|
|
const blockHash = await api.rpc.chain.getBlockHash(blockHeight) as Hash
|
|
const events = await api.query.system.events.at(blockHash) as Vec<EventRecord>;
|
|
const events = await api.query.system.events.at(blockHash) as Vec<EventRecord>;
|
|
const eventsArray: EventRecord[] = []
|
|
const eventsArray: EventRecord[] = []
|
|
- let index = 0
|
|
|
|
- let removIndex = 0
|
|
|
|
|
|
+ let eventIndex = 0
|
|
for (let i=0; i<events.length; i++) {
|
|
for (let i=0; i<events.length; i++) {
|
|
const section = events[i].event.section
|
|
const section = events[i].event.section
|
|
const method = events[i].event.method
|
|
const method = events[i].event.method
|
|
- if (section == "contentDirectory") {
|
|
|
|
|
|
+ if(section == 'content') {
|
|
|
|
+ console.log(`Event section=${section}, Event method=${method}`)
|
|
eventsArray.push(events[i])
|
|
eventsArray.push(events[i])
|
|
- if (method == "EntityCreated") {
|
|
|
|
- }
|
|
|
|
- if (method == "EntitySchemaSupportAdded") {
|
|
|
|
|
|
+ if (method == "VideoCreated") {
|
|
|
|
+ eventIndex+=1
|
|
|
|
+ const cdChange = await getChangeAction(api, 'createVideo', blockHeight, blockHash, eventIndex, events[i])
|
|
|
|
+ console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
}
|
|
}
|
|
- if (method == "EntityPropertyValuesUpdated") {
|
|
|
|
|
|
+ if (method == "VideoUpdated") {
|
|
|
|
+ eventIndex+=1
|
|
|
|
+ const cdChange = await getChangeAction(api, 'updateVideo', blockHeight, blockHash, eventIndex, events[i])
|
|
|
|
+ console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
}
|
|
}
|
|
- if (method == "EntityRemoved") {
|
|
|
|
- removIndex+=1
|
|
|
|
- const cdChange = await getRemovedAction(api, blockHeight, blockHash, removIndex, events[i])
|
|
|
|
|
|
+ if (method == "VideoDeleted") {
|
|
|
|
+ eventIndex+=1
|
|
|
|
+ const cdChange = await getChangeAction(api, 'deleteVideo', blockHeight, blockHash, eventIndex, events[i])
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
}
|
|
}
|
|
- if (method == "TransactionCompleted") {
|
|
|
|
- index+=1
|
|
|
|
- const cdChange = await getBatchAction(api, blockHeight, blockHash, index, eventsArray, method)
|
|
|
|
|
|
+ if (method == "ChannelCreated") {
|
|
|
|
+ eventIndex+=1
|
|
|
|
+ const cdChange = await getChangeAction(api, 'createChannel', blockHeight, blockHash, eventIndex, events[i])
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
}
|
|
}
|
|
- if (method == "TransactionFailed") {
|
|
|
|
- index+=1
|
|
|
|
- const cdChange = await getBatchAction(api, blockHeight, blockHash, index, eventsArray, method)
|
|
|
|
|
|
+ if (method == "ChannelUpdated") {
|
|
|
|
+ eventIndex+=1
|
|
|
|
+ const cdChange = await getChangeAction(api, 'updateChannel', blockHeight, blockHash, eventIndex, events[i])
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
console.log("Change",JSON.stringify(cdChange, null, 4))
|
|
}
|
|
}
|
|
}
|
|
}
|