idle-moloch-subgraph/tests/raid-geld-utils.ts
2024-10-30 13:35:43 +08:00

194 lines
4.8 KiB
TypeScript

import { newMockEvent } from "matchstick-as"
import { ethereum, Address, BigInt } from "@graphprotocol/graph-ts"
import {
Approval,
OwnershipTransferred,
PlayerRegistered,
RaidPerformed,
Transfer,
UnitAdded
} from "../generated/RaidGeld/RaidGeld"
export function createApprovalEvent(
owner: Address,
spender: Address,
value: BigInt
): Approval {
let approvalEvent = changetype<Approval>(newMockEvent())
approvalEvent.parameters = new Array()
approvalEvent.parameters.push(
new ethereum.EventParam("owner", ethereum.Value.fromAddress(owner))
)
approvalEvent.parameters.push(
new ethereum.EventParam("spender", ethereum.Value.fromAddress(spender))
)
approvalEvent.parameters.push(
new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value))
)
return approvalEvent
}
export function createOwnershipTransferredEvent(
previousOwner: Address,
newOwner: Address
): OwnershipTransferred {
let ownershipTransferredEvent = changetype<OwnershipTransferred>(
newMockEvent()
)
ownershipTransferredEvent.parameters = new Array()
ownershipTransferredEvent.parameters.push(
new ethereum.EventParam(
"previousOwner",
ethereum.Value.fromAddress(previousOwner)
)
)
ownershipTransferredEvent.parameters.push(
new ethereum.EventParam("newOwner", ethereum.Value.fromAddress(newOwner))
)
return ownershipTransferredEvent
}
export function createPlayerRegisteredEvent(
player: Address,
initialGeld: BigInt
): PlayerRegistered {
let playerRegisteredEvent = changetype<PlayerRegistered>(newMockEvent())
playerRegisteredEvent.parameters = new Array()
playerRegisteredEvent.parameters.push(
new ethereum.EventParam("player", ethereum.Value.fromAddress(player))
)
playerRegisteredEvent.parameters.push(
new ethereum.EventParam(
"initialGeld",
ethereum.Value.fromUnsignedBigInt(initialGeld)
)
)
return playerRegisteredEvent
}
export function createRaidPerformedEvent(
player: Address,
totalMinted: BigInt,
geldBalance: BigInt
): RaidPerformed {
let raidPerformedEvent = changetype<RaidPerformed>(newMockEvent())
raidPerformedEvent.parameters = new Array()
raidPerformedEvent.parameters.push(
new ethereum.EventParam("player", ethereum.Value.fromAddress(player))
)
raidPerformedEvent.parameters.push(
new ethereum.EventParam(
"totalMinted",
ethereum.Value.fromUnsignedBigInt(totalMinted)
)
)
raidPerformedEvent.parameters.push(
new ethereum.EventParam(
"geldBalance",
ethereum.Value.fromUnsignedBigInt(geldBalance)
)
)
return raidPerformedEvent
}
export function createTransferEvent(
from: Address,
to: Address,
value: BigInt
): Transfer {
let transferEvent = changetype<Transfer>(newMockEvent())
transferEvent.parameters = new Array()
transferEvent.parameters.push(
new ethereum.EventParam("from", ethereum.Value.fromAddress(from))
)
transferEvent.parameters.push(
new ethereum.EventParam("to", ethereum.Value.fromAddress(to))
)
transferEvent.parameters.push(
new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value))
)
return transferEvent
}
export function createUnitAddedEvent(
player: Address,
unitType: i32,
nUnits: i32,
cost: BigInt,
geldBalance: BigInt,
molochDenierLevel: i32,
apprenticeLevel: i32,
anointedLevel: i32,
championLevel: i32
): UnitAdded {
let unitAddedEvent = changetype<UnitAdded>(newMockEvent())
unitAddedEvent.parameters = new Array()
unitAddedEvent.parameters.push(
new ethereum.EventParam("player", ethereum.Value.fromAddress(player))
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"unitType",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(unitType))
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"nUnits",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(nUnits))
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam("cost", ethereum.Value.fromUnsignedBigInt(cost))
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"geldBalance",
ethereum.Value.fromUnsignedBigInt(geldBalance)
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"molochDenierLevel",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(molochDenierLevel))
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"apprenticeLevel",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(apprenticeLevel))
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"anointedLevel",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(anointedLevel))
)
)
unitAddedEvent.parameters.push(
new ethereum.EventParam(
"championLevel",
ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(championLevel))
)
)
return unitAddedEvent
}