|
@@ -1,5 +1,7 @@
|
|
|
import { EventRecord} from '@polkadot/types/interfaces'
|
|
|
import { getWorker, getMember, getMint, getEvents, getBlockHash } from '../lib/api';
|
|
|
+import { getOpening } from './api_extension';
|
|
|
+
|
|
|
import { wgEvents, workingGroups, joystreamBlue } from '../config'
|
|
|
import Discord from 'discord.js';
|
|
|
import { ApiPromise } from '@polkadot/api';
|
|
@@ -22,20 +24,61 @@ export const processBlock = async (api: ApiPromise, client: Discord.Client, bloc
|
|
|
if(method === 'MintCapacityChanged') {
|
|
|
const mintId = (data[0] as u32).toNumber()
|
|
|
const minted = (data[1] as u32).toNumber()
|
|
|
- const mint = await getMint(api, undefined, mintId)
|
|
|
+ const mint = (await getMint(api, hash, mintId)).capacity
|
|
|
|
|
|
const exampleEmbed = new Discord.MessageEmbed()
|
|
|
.setColor(joystreamBlue)
|
|
|
.setTitle(`💰 💵 💸 💴 💶 ${formatBalance(minted, {withUnit: 'JOY'})} minted to the Treasury 💰 💵 💸 💴 💶 `)
|
|
|
.addFields(
|
|
|
- { name: 'Balance', value: mint.capacity + "", inline: true },
|
|
|
+ { name: 'Balance', value: formatBalance(mint, {withUnit: 'JOY'}), inline: true },
|
|
|
+ { name: 'Block', value: blockNumber + "", inline: true },
|
|
|
+ { name: 'Tx', value: value.hash.toString(), inline: true },
|
|
|
+ )
|
|
|
+ .setTimestamp();
|
|
|
+ channel.send({ embeds: [exampleEmbed] });
|
|
|
+ } else if (method === 'OpeningAdded') {
|
|
|
+ const openingId = (data[0] as u32).toNumber()
|
|
|
+ const opening = (await getOpening(api, hash, openingId)).human_readable_text.toJSON()
|
|
|
+ const exampleEmbed = new Discord.MessageEmbed()
|
|
|
+ .setColor(joystreamBlue)
|
|
|
+ .setTitle(`Apply for new Opening!`)
|
|
|
+ .setDescription(opening)
|
|
|
+ .addFields(
|
|
|
+ // { name: 'Opening', value: , inline: true },
|
|
|
{ name: 'Block', value: blockNumber + "", inline: true },
|
|
|
{ name: 'Tx', value: value.hash.toString(), inline: true },
|
|
|
)
|
|
|
.setTimestamp();
|
|
|
channel.send({ embeds: [exampleEmbed] });
|
|
|
- }
|
|
|
- } else {
|
|
|
+ } else if (method === 'OpeningFilled') {
|
|
|
+ const openingId = (data[0] as u32).toNumber()
|
|
|
+ const opening = (await getOpening(api, hash, openingId)).human_readable_text.toJSON()
|
|
|
+ console.log(opening);
|
|
|
+ const exampleEmbed = new Discord.MessageEmbed()
|
|
|
+ .setColor(joystreamBlue)
|
|
|
+ .setTitle(`XXXX was hired as ${JSON.parse(opening).job.title} 🎉 🥳 👏🏻`)
|
|
|
+ .setDescription(opening)
|
|
|
+ .addFields(
|
|
|
+ { name: 'Block', value: blockNumber + "", inline: true },
|
|
|
+ { name: 'Tx', value: value.hash.toString(), inline: true },
|
|
|
+ )
|
|
|
+ .setTimestamp();
|
|
|
+ channel.send({ embeds: [exampleEmbed] });
|
|
|
+ } else if (method === 'WorkerRewardAmountUpdated') {
|
|
|
+ const workerId = (data[0] as u32).toNumber()
|
|
|
+ const worker = (await getWorker(api, section, hash, workerId))
|
|
|
+ const member = (await getMember(api, worker.member_id))
|
|
|
+ const exampleEmbed = new Discord.MessageEmbed()
|
|
|
+ .setColor(joystreamBlue)
|
|
|
+ .setTitle(`💰💰💰 Salary of ${member.handle} updated`)
|
|
|
+ .addFields(
|
|
|
+ { name: 'Block', value: blockNumber + "", inline: true },
|
|
|
+ { name: 'Tx', value: value.hash.toString(), inline: true },
|
|
|
+ )
|
|
|
+ .setTimestamp();
|
|
|
+ channel.send({ embeds: [exampleEmbed] });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
console.log(`Channel not configured for ${section}`);
|
|
|
}
|
|
|
}
|