30 lines
928 B
TypeScript
30 lines
928 B
TypeScript
import { CheckIn } from "models/CheckIn"
|
|
import { utf8ToHex } from "utils/string.util"
|
|
|
|
export interface IScriptionCfg {
|
|
chain: number,
|
|
rpc?: string,
|
|
fromBlock: number,
|
|
filter: (event: any) => boolean,
|
|
process: (event: any) => Promise<void>,
|
|
}
|
|
|
|
const CHECKIN_DATA_STR = 'data:,{"p":"cf-20","op":"check"}'
|
|
const CHECKIN_DATA_HEX = '0x'+utf8ToHex(CHECKIN_DATA_STR)
|
|
const CHECKIN_ADDRESS = '0x50a8e60041a206acaa5f844a1104896224be6f39'
|
|
|
|
export const SCRIPTIONS_CFG: IScriptionCfg[] = [
|
|
{
|
|
chain: 421614,
|
|
// rpc: 'https://arbitrum-sepolia.infura.io/v3/25559ac58e714177b31ff48d507e7ac9',
|
|
rpc: 'https://arb-sepolia.g.alchemy.com/v2/EKR1je8ZGia332kkemNc4mtXQuFskIq3',
|
|
fromBlock: 5624211,
|
|
filter: (event: any) => {
|
|
return ( event.input === CHECKIN_DATA_HEX
|
|
&& event.to.toLowerCase() === CHECKIN_ADDRESS)
|
|
},
|
|
process: async (tx: any) => {
|
|
return CheckIn.saveEvent(tx)
|
|
}
|
|
}
|
|
] |