I have this struct and mapping inside my smart-contract:
struct attrStruct {
uint256 generation;
string faction;
}
mapping(uint256 => attrStruct) public attributes;
I want to fetch and store new version of this struct ( they get modified on-chain in normal transactions ). How can I use something like await contract.attributes(tokenId)
inside my subgraph?
Mapping.ts
export function handleTransfer(event: TransferEvent): void {
let token = Token.load(event.params.tokenId.toString())
if (!token) {
token = new Token(event.params.tokenId.toString())
// What to write here to fetch the struct?
}
}
event.block
is made available to us.