test: init subgraph unit tests (#117)
* test: add unit tests for the subgraph for events transfer, NewTokenName, NewTokenDescription, NewTokenExternalURL, NewTokenENS, NewTokenBuild * fix: import errors * fix: remove keyword "indexed" for strings in events. * fix: update subgraph.yaml, schema.graphql, and all generated files with the test files to match the new interface of the contract events. * fix: expose a makeEventId function to avoid repeating code for id generation and also change logIndex before handling events. Update tests to match the new changes. * chore: remove Holder. * fix: wrong import for newLogoEvent
This commit is contained in:
parent
18d3319fd7
commit
7f1aca15dd
|
|
@ -16,30 +16,25 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl {
|
||||||
using FleekStrings for FleekERC721.AccessPoint;
|
using FleekStrings for FleekERC721.AccessPoint;
|
||||||
using FleekStrings for string;
|
using FleekStrings for string;
|
||||||
|
|
||||||
event NewBuild(uint256 indexed token, string indexed commitHash, address indexed triggeredBy);
|
event NewBuild(uint256 indexed tokenId, string commitHash, address indexed triggeredBy);
|
||||||
event NewTokenName(uint256 indexed token, string indexed name, address indexed triggeredBy);
|
event NewTokenName(uint256 indexed tokenId, string name, address indexed triggeredBy);
|
||||||
event NewTokenDescription(uint256 indexed token, string indexed description, address indexed triggeredBy);
|
event NewTokenDescription(uint256 indexed tokenId, string description, address indexed triggeredBy);
|
||||||
event NewTokenLogo(uint256 indexed token, string indexed image, address indexed triggeredBy);
|
event NewTokenLogo(uint256 indexed tokenId, string logo, address indexed triggeredBy);
|
||||||
event NewTokenExternalURL(uint256 indexed token, string indexed externalURL, address indexed triggeredBy);
|
event NewTokenExternalURL(uint256 indexed tokenId, string externalURL, address indexed triggeredBy);
|
||||||
event NewTokenENS(uint256 indexed token, string indexed ENS, address indexed triggeredBy);
|
event NewTokenENS(uint256 indexed tokenId, string ENS, address indexed triggeredBy);
|
||||||
event NewTokenColor(uint256 indexed token, uint24 indexed color, address indexed triggeredBy);
|
event NewTokenColor(uint256 indexed tokenId, uint24 color, address indexed triggeredBy);
|
||||||
|
|
||||||
event NewAccessPoint(string indexed apName, uint256 indexed tokenId, address indexed owner);
|
event NewAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
|
||||||
event RemoveAccessPoint(string indexed apName, uint256 indexed tokenId, address indexed owner);
|
event RemoveAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
|
||||||
event ChangeAccessPointScore(
|
event ChangeAccessPointScore(string apName, uint256 indexed tokenId, uint256 score, address indexed triggeredBy);
|
||||||
string indexed apName,
|
|
||||||
uint256 indexed tokenId,
|
|
||||||
uint256 score,
|
|
||||||
address indexed triggeredBy
|
|
||||||
);
|
|
||||||
event ChangeAccessPointNameVerify(
|
event ChangeAccessPointNameVerify(
|
||||||
string indexed apName,
|
string apName,
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
bool indexed verified,
|
bool indexed verified,
|
||||||
address indexed triggeredBy
|
address indexed triggeredBy
|
||||||
);
|
);
|
||||||
event ChangeAccessPointContentVerify(
|
event ChangeAccessPointContentVerify(
|
||||||
string indexed apName,
|
string apName,
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
bool indexed verified,
|
bool indexed verified,
|
||||||
address indexed triggeredBy
|
address indexed triggeredBy
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,10 @@ type NewTokenExternalURL @entity(immutable: true) {
|
||||||
transactionHash: Bytes!
|
transactionHash: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewTokenImage @entity(immutable: true) {
|
type NewTokenLogo @entity(immutable: true) {
|
||||||
id: Bytes!
|
id: Bytes!
|
||||||
token: BigInt! # uint256
|
token: BigInt! # uint256
|
||||||
image: String! # string
|
logo: String! # string
|
||||||
triggeredBy: Bytes! # address
|
triggeredBy: Bytes! # address
|
||||||
blockNumber: BigInt!
|
blockNumber: BigInt!
|
||||||
blockTimestamp: BigInt!
|
blockTimestamp: BigInt!
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
NewTokenDescription as NewTokenDescriptionEvent,
|
NewTokenDescription as NewTokenDescriptionEvent,
|
||||||
NewTokenENS as NewTokenENSEvent,
|
NewTokenENS as NewTokenENSEvent,
|
||||||
NewTokenExternalURL as NewTokenExternalURLEvent,
|
NewTokenExternalURL as NewTokenExternalURLEvent,
|
||||||
NewTokenImage as NewTokenImageEvent,
|
NewTokenLogo as NewTokenLogoEvent,
|
||||||
NewTokenName as NewTokenNameEvent,
|
NewTokenName as NewTokenNameEvent,
|
||||||
TokenRoleGranted as TokenRoleGrantedEvent,
|
TokenRoleGranted as TokenRoleGrantedEvent,
|
||||||
TokenRoleRevoked as TokenRoleRevokedEvent,
|
TokenRoleRevoked as TokenRoleRevokedEvent,
|
||||||
|
|
@ -21,12 +21,11 @@ import {
|
||||||
CollectionRoleGranted,
|
CollectionRoleGranted,
|
||||||
CollectionRoleRevoked,
|
CollectionRoleRevoked,
|
||||||
Controller,
|
Controller,
|
||||||
Holder,
|
|
||||||
NewBuild,
|
NewBuild,
|
||||||
NewTokenDescription,
|
NewTokenDescription,
|
||||||
NewTokenENS,
|
NewTokenENS,
|
||||||
NewTokenExternalURL,
|
NewTokenExternalURL,
|
||||||
NewTokenImage,
|
NewTokenLogo,
|
||||||
NewTokenName,
|
NewTokenName,
|
||||||
Owner,
|
Owner,
|
||||||
Token,
|
Token,
|
||||||
|
|
@ -103,7 +102,7 @@ export function handleNewBuild(event: NewBuildEvent): void {
|
||||||
let entity = new NewBuild(
|
let entity = new NewBuild(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.commitHash = event.params.commitHash.toString();
|
entity.commitHash = event.params.commitHash.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
|
|
@ -120,7 +119,7 @@ export function handleNewTokenDescription(
|
||||||
let entity = new NewTokenDescription(
|
let entity = new NewTokenDescription(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.description = event.params.description.toString();
|
entity.description = event.params.description.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
|
|
@ -135,7 +134,7 @@ export function handleNewTokenENS(event: NewTokenENSEvent): void {
|
||||||
let entity = new NewTokenENS(
|
let entity = new NewTokenENS(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.ENS = event.params.ENS.toString();
|
entity.ENS = event.params.ENS.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
|
|
@ -152,7 +151,7 @@ export function handleNewTokenExternalURL(
|
||||||
let entity = new NewTokenExternalURL(
|
let entity = new NewTokenExternalURL(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.externalURL = event.params.externalURL.toString();
|
entity.externalURL = event.params.externalURL.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
|
|
@ -163,12 +162,12 @@ export function handleNewTokenExternalURL(
|
||||||
entity.save();
|
entity.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleNewTokenImage(event: NewTokenImageEvent): void {
|
export function handleNewTokenLogo(event: NewTokenLogoEvent): void {
|
||||||
let entity = new NewTokenImage(
|
let entity = new NewTokenLogo(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.image = event.params.image.toString();
|
entity.logo = event.params.logo.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
entity.blockNumber = event.block.number;
|
entity.blockNumber = event.block.number;
|
||||||
|
|
@ -182,7 +181,7 @@ export function handleNewTokenName(event: NewTokenNameEvent): void {
|
||||||
let entity = new NewTokenName(
|
let entity = new NewTokenName(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.token = event.params.token;
|
entity.token = event.params.tokenId;
|
||||||
entity.name = event.params.name.toString();
|
entity.name = event.params.name.toString();
|
||||||
entity.triggeredBy = event.params.triggeredBy;
|
entity.triggeredBy = event.params.triggeredBy;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ dataSources:
|
||||||
- Controller
|
- Controller
|
||||||
abis:
|
abis:
|
||||||
- name: FleekNFA
|
- name: FleekNFA
|
||||||
file: ./abis/FleekNFA.json
|
file: ../contracts/artifacts/contracts/FleekERC721.sol/FleekERC721.json
|
||||||
eventHandlers:
|
eventHandlers:
|
||||||
- event: Approval(indexed address,indexed address,indexed uint256)
|
- event: Approval(indexed address,indexed address,indexed uint256)
|
||||||
handler: handleApproval
|
handler: handleApproval
|
||||||
|
|
@ -42,17 +42,17 @@ dataSources:
|
||||||
handler: handleCollectionRoleGranted
|
handler: handleCollectionRoleGranted
|
||||||
- event: CollectionRoleRevoked(indexed uint8,indexed address,address)
|
- event: CollectionRoleRevoked(indexed uint8,indexed address,address)
|
||||||
handler: handleCollectionRoleRevoked
|
handler: handleCollectionRoleRevoked
|
||||||
- event: NewBuild(indexed uint256,indexed string,indexed address)
|
- event: NewBuild(indexed uint256,string,indexed address)
|
||||||
handler: handleNewBuild
|
handler: handleNewBuild
|
||||||
- event: NewTokenDescription(indexed uint256,indexed string,indexed address)
|
- event: NewTokenDescription(indexed uint256,string,indexed address)
|
||||||
handler: handleNewTokenDescription
|
handler: handleNewTokenDescription
|
||||||
- event: NewTokenENS(indexed uint256,indexed string,indexed address)
|
- event: NewTokenENS(indexed uint256,string,indexed address)
|
||||||
handler: handleNewTokenENS
|
handler: handleNewTokenENS
|
||||||
- event: NewTokenExternalURL(indexed uint256,indexed string,indexed address)
|
- event: NewTokenExternalURL(indexed uint256,string,indexed address)
|
||||||
handler: handleNewTokenExternalURL
|
handler: handleNewTokenExternalURL
|
||||||
- event: NewTokenImage(indexed uint256,indexed string,indexed address)
|
- event: NewTokenLogo(indexed uint256,string,indexed address)
|
||||||
handler: handleNewTokenImage
|
handler: handleNewTokenLogo
|
||||||
- event: NewTokenName(indexed uint256,indexed string,indexed address)
|
- event: NewTokenName(indexed uint256,string,indexed address)
|
||||||
handler: handleNewTokenName
|
handler: handleNewTokenName
|
||||||
- event: TokenRoleGranted(indexed uint256,indexed uint8,indexed address,address)
|
- event: TokenRoleGranted(indexed uint256,indexed uint8,indexed address,address)
|
||||||
handler: handleTokenRoleGranted
|
handler: handleTokenRoleGranted
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"version": "0.5.4",
|
||||||
|
"timestamp": 1675972891956
|
||||||
|
}
|
||||||
|
|
@ -5,60 +5,494 @@ import {
|
||||||
clearStore,
|
clearStore,
|
||||||
beforeAll,
|
beforeAll,
|
||||||
afterAll,
|
afterAll,
|
||||||
|
logStore,
|
||||||
|
log,
|
||||||
} from 'matchstick-as/assembly/index';
|
} from 'matchstick-as/assembly/index';
|
||||||
import { Address, BigInt } from '@graphprotocol/graph-ts';
|
import { BigInt, Bytes } from '@graphprotocol/graph-ts';
|
||||||
import { Approval } from '../generated/schema';
|
import '../generated/schema';
|
||||||
import { Approval as ApprovalEvent } from '../generated/FleekNFA/FleekNFA';
|
import '../generated/FleekNFA/FleekNFA';
|
||||||
import { handleApproval } from '../src/fleek-nfa';
|
import '../src/fleek-nfa';
|
||||||
import { createApprovalEvent } from './fleek-nfa-utils';
|
import './utils';
|
||||||
|
import {
|
||||||
// Tests structure (matchstick-as >=0.5.0)
|
NewBuild,
|
||||||
// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0
|
NewTokenDescription,
|
||||||
|
NewTokenENS,
|
||||||
|
NewTokenExternalURL,
|
||||||
|
NewTokenName,
|
||||||
|
Transfer,
|
||||||
|
} from '../generated/FleekNFA/FleekNFA';
|
||||||
|
import {
|
||||||
|
CONTRACT,
|
||||||
|
createNewBuildEvent,
|
||||||
|
createNewTokenDescriptionEvent,
|
||||||
|
createNewTokenENSEvent,
|
||||||
|
createNewTokenExternalURLEvent,
|
||||||
|
createNewTokenNameEvent,
|
||||||
|
createTransferEvent,
|
||||||
|
handleNewBuilds,
|
||||||
|
handleNewTokenDescriptions,
|
||||||
|
handleNewTokenENSAddresses,
|
||||||
|
handleNewTokenExternalURLs,
|
||||||
|
handleNewTokenNames,
|
||||||
|
handleTransfers,
|
||||||
|
makeEventId,
|
||||||
|
TOKEN_OWNER_ONE,
|
||||||
|
TOKEN_OWNER_TWO,
|
||||||
|
} from './utils';
|
||||||
|
|
||||||
describe('Describe entity assertions', () => {
|
describe('Describe entity assertions', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
let owner = Address.fromString(
|
// TRANSFERS
|
||||||
'0x0000000000000000000000000000000000000001'
|
let transfers: Transfer[] = [];
|
||||||
|
transfers.push(
|
||||||
|
createTransferEvent(0, CONTRACT, TOKEN_OWNER_ONE, BigInt.fromI32(0))
|
||||||
);
|
);
|
||||||
let approved = Address.fromString(
|
transfers.push(
|
||||||
'0x0000000000000000000000000000000000000001'
|
createTransferEvent(1, CONTRACT, TOKEN_OWNER_TWO, BigInt.fromI32(1))
|
||||||
);
|
);
|
||||||
let tokenId = BigInt.fromI32(234);
|
transfers.push(
|
||||||
let newApprovalEvent = createApprovalEvent(owner, approved, tokenId);
|
createTransferEvent(2, CONTRACT, TOKEN_OWNER_ONE, BigInt.fromI32(2))
|
||||||
handleApproval(newApprovalEvent);
|
);
|
||||||
|
transfers.push(
|
||||||
|
createTransferEvent(3, CONTRACT, TOKEN_OWNER_ONE, BigInt.fromI32(3))
|
||||||
|
);
|
||||||
|
transfers.push(
|
||||||
|
createTransferEvent(
|
||||||
|
4,
|
||||||
|
TOKEN_OWNER_TWO,
|
||||||
|
TOKEN_OWNER_ONE,
|
||||||
|
BigInt.fromI32(1)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
transfers.push(
|
||||||
|
createTransferEvent(5, CONTRACT, TOKEN_OWNER_TWO, BigInt.fromI32(4))
|
||||||
|
);
|
||||||
|
transfers.push(
|
||||||
|
createTransferEvent(
|
||||||
|
6,
|
||||||
|
TOKEN_OWNER_ONE,
|
||||||
|
TOKEN_OWNER_TWO,
|
||||||
|
BigInt.fromI32(0)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
handleTransfers(transfers);
|
||||||
|
|
||||||
|
// NEW TOKEN NAME EVENTS
|
||||||
|
let newTokenNames: NewTokenName[] = [];
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
0,
|
||||||
|
BigInt.fromI32(0),
|
||||||
|
'Token Zero New Name',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
1,
|
||||||
|
BigInt.fromI32(1),
|
||||||
|
'Token One New Name',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
2,
|
||||||
|
BigInt.fromI32(2),
|
||||||
|
'Token Two New Name',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
3,
|
||||||
|
BigInt.fromI32(3),
|
||||||
|
'Token Three New Name',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
4,
|
||||||
|
BigInt.fromI32(4),
|
||||||
|
'Token Four New Name',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenNames.push(
|
||||||
|
createNewTokenNameEvent(
|
||||||
|
5,
|
||||||
|
BigInt.fromI32(0),
|
||||||
|
'Token Zero New Name By New Owner',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
handleNewTokenNames(newTokenNames);
|
||||||
|
|
||||||
|
// New Token ENS Addresses
|
||||||
|
let newENSAddresses: NewTokenENS[] = [];
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
0,
|
||||||
|
BigInt.fromI32(0),
|
||||||
|
'New_Token_Zero_ENS',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
1,
|
||||||
|
BigInt.fromI32(1),
|
||||||
|
'New_Token_One_ENS',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
2,
|
||||||
|
BigInt.fromI32(2),
|
||||||
|
'New_Token_Two_ENS',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
3,
|
||||||
|
BigInt.fromI32(3),
|
||||||
|
'New_Token_Three_ENS',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
4,
|
||||||
|
BigInt.fromI32(4),
|
||||||
|
'New_Token_Four_ENS',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newENSAddresses.push(
|
||||||
|
createNewTokenENSEvent(
|
||||||
|
5,
|
||||||
|
BigInt.fromI32(5),
|
||||||
|
'New_Token_Five_ENS',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
handleNewTokenENSAddresses(newENSAddresses);
|
||||||
|
|
||||||
|
// New Token Descriptions
|
||||||
|
let newTokenDescriptions: NewTokenDescription[] = [];
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
0,
|
||||||
|
BigInt.fromI32(0),
|
||||||
|
'New Token Zero Description',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
1,
|
||||||
|
BigInt.fromI32(1),
|
||||||
|
'New Token One Description',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
2,
|
||||||
|
BigInt.fromI32(2),
|
||||||
|
'New Token Two Description',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
3,
|
||||||
|
BigInt.fromI32(3),
|
||||||
|
'New Token Three Description',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
4,
|
||||||
|
BigInt.fromI32(4),
|
||||||
|
'New Token Four Description',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenDescriptions.push(
|
||||||
|
createNewTokenDescriptionEvent(
|
||||||
|
5,
|
||||||
|
BigInt.fromI32(5),
|
||||||
|
'New Token Five Description By New Owner',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
handleNewTokenDescriptions(newTokenDescriptions);
|
||||||
|
|
||||||
|
// New Token External URLs
|
||||||
|
let newTokenExternalURLs: NewTokenExternalURL[] = [];
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
0,
|
||||||
|
BigInt.fromI32(0),
|
||||||
|
'https://0_external.url',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
1,
|
||||||
|
BigInt.fromI32(1),
|
||||||
|
'https://1_external.url',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
2,
|
||||||
|
BigInt.fromI32(2),
|
||||||
|
'https://2_external.url',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
3,
|
||||||
|
BigInt.fromI32(3),
|
||||||
|
'https://3_external.url',
|
||||||
|
TOKEN_OWNER_ONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
4,
|
||||||
|
BigInt.fromI32(4),
|
||||||
|
'https://4_external.url',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newTokenExternalURLs.push(
|
||||||
|
createNewTokenExternalURLEvent(
|
||||||
|
5,
|
||||||
|
BigInt.fromI32(5),
|
||||||
|
'https://5_external.url',
|
||||||
|
TOKEN_OWNER_TWO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
handleNewTokenExternalURLs(newTokenExternalURLs);
|
||||||
|
|
||||||
|
// New Token External URLs
|
||||||
|
let newBuilds: NewBuild[] = [];
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(0, BigInt.fromI32(0), 'hash0_0', TOKEN_OWNER_ONE)
|
||||||
|
);
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(1, BigInt.fromI32(1), 'hash1_0', TOKEN_OWNER_TWO)
|
||||||
|
);
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(2, BigInt.fromI32(2), 'hash2_0', TOKEN_OWNER_ONE)
|
||||||
|
);
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(3, BigInt.fromI32(3), 'hash3_0', TOKEN_OWNER_ONE)
|
||||||
|
);
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(4, BigInt.fromI32(4), 'hash4_0', TOKEN_OWNER_TWO)
|
||||||
|
);
|
||||||
|
newBuilds.push(
|
||||||
|
createNewBuildEvent(5, BigInt.fromI32(5), 'hash5_0', TOKEN_OWNER_TWO)
|
||||||
|
);
|
||||||
|
handleNewBuilds(newBuilds);
|
||||||
|
|
||||||
|
logStore();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
clearStore();
|
clearStore();
|
||||||
});
|
});
|
||||||
|
|
||||||
// For more test scenarios, see:
|
describe('Transfers', () => {
|
||||||
// https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test
|
test('Check the number of transfers to be valid', () => {
|
||||||
|
assert.entityCount('Transfer', 7);
|
||||||
|
});
|
||||||
|
test('Check the `from` and `to` fields of each transfer to be equal to expected values', () => {
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(0),
|
||||||
|
'to',
|
||||||
|
'0x2000000000000000000000000000000000000002'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(1),
|
||||||
|
'to',
|
||||||
|
'0x3000000000000000000000000000000000000003'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(2),
|
||||||
|
'to',
|
||||||
|
'0x2000000000000000000000000000000000000002'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(3),
|
||||||
|
'to',
|
||||||
|
'0x2000000000000000000000000000000000000002'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(4),
|
||||||
|
'to',
|
||||||
|
'0x2000000000000000000000000000000000000002'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(5),
|
||||||
|
'to',
|
||||||
|
'0x3000000000000000000000000000000000000003'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'Transfer',
|
||||||
|
makeEventId(6),
|
||||||
|
'to',
|
||||||
|
'0x3000000000000000000000000000000000000003'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('Approval created and stored', () => {
|
describe('New Token Name Events', () => {
|
||||||
assert.entityCount('Approval', 1);
|
test('Check the number of NewTokenName to be valid', () => {
|
||||||
|
assert.entityCount('NewTokenName', 6);
|
||||||
|
});
|
||||||
|
test('Check the `name` and `triggeredBy` fields of each new token name event to be equal to expected values', () => {
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(0),
|
||||||
|
'name',
|
||||||
|
'Token Zero New Name'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(1),
|
||||||
|
'name',
|
||||||
|
'Token One New Name'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(2),
|
||||||
|
'name',
|
||||||
|
'Token Two New Name'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(3),
|
||||||
|
'name',
|
||||||
|
'Token Three New Name'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(4),
|
||||||
|
'name',
|
||||||
|
'Token Four New Name'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenName',
|
||||||
|
makeEventId(5),
|
||||||
|
'name',
|
||||||
|
'Token Zero New Name By New Owner'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function
|
describe('New Token External URL Events', () => {
|
||||||
assert.fieldEquals(
|
test('Check the number of newTokenExternalURl events to be valid', () => {
|
||||||
'Approval',
|
assert.entityCount('NewTokenExternalURL', 6);
|
||||||
'0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1',
|
});
|
||||||
'owner',
|
test('Check the `description` and `triggeredBy` fields of each new token name event to be equal to expected values', () => {
|
||||||
'0x0000000000000000000000000000000000000001'
|
assert.fieldEquals(
|
||||||
);
|
'NewTokenExternalURL',
|
||||||
assert.fieldEquals(
|
makeEventId(0),
|
||||||
'Approval',
|
'externalURL',
|
||||||
'0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1',
|
'https://0_external.url'
|
||||||
'approved',
|
);
|
||||||
'0x0000000000000000000000000000000000000001'
|
assert.fieldEquals(
|
||||||
);
|
'NewTokenExternalURL',
|
||||||
assert.fieldEquals(
|
makeEventId(1),
|
||||||
'Approval',
|
'externalURL',
|
||||||
'0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1',
|
'https://1_external.url'
|
||||||
'tokenId',
|
);
|
||||||
'234'
|
assert.fieldEquals(
|
||||||
);
|
'NewTokenExternalURL',
|
||||||
|
makeEventId(2),
|
||||||
|
'externalURL',
|
||||||
|
'https://2_external.url'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenExternalURL',
|
||||||
|
makeEventId(3),
|
||||||
|
'externalURL',
|
||||||
|
'https://3_external.url'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenExternalURL',
|
||||||
|
makeEventId(4),
|
||||||
|
'externalURL',
|
||||||
|
'https://4_external.url'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenExternalURL',
|
||||||
|
makeEventId(5),
|
||||||
|
'externalURL',
|
||||||
|
'https://5_external.url'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// More assert options:
|
describe('New Token Description Events', () => {
|
||||||
// https://thegraph.com/docs/en/developer/matchstick/#asserts
|
test('Check the number of NewTokenDescription events to be valid', () => {
|
||||||
|
assert.entityCount('NewTokenDescription', 6);
|
||||||
|
});
|
||||||
|
test('Check the `description` and `triggeredBy` fields of each new token name event to be equal to expected values', () => {
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(0),
|
||||||
|
'description',
|
||||||
|
'New Token Zero Description'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(1),
|
||||||
|
'description',
|
||||||
|
'New Token One Description'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(2),
|
||||||
|
'description',
|
||||||
|
'New Token Two Description'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(3),
|
||||||
|
'description',
|
||||||
|
'New Token Three Description'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(4),
|
||||||
|
'description',
|
||||||
|
'New Token Four Description'
|
||||||
|
);
|
||||||
|
assert.fieldEquals(
|
||||||
|
'NewTokenDescription',
|
||||||
|
makeEventId(5),
|
||||||
|
'description',
|
||||||
|
'New Token Five Description By New Owner'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,43 @@
|
||||||
import { newMockEvent } from 'matchstick-as';
|
import { newMockEvent } from 'matchstick-as';
|
||||||
import { ethereum, Address, BigInt } from '@graphprotocol/graph-ts';
|
import { ethereum, Address, BigInt, Bytes } from '@graphprotocol/graph-ts';
|
||||||
import {
|
import {
|
||||||
Approval,
|
Approval as ApprovalEvent,
|
||||||
ApprovalForAll,
|
ApprovalForAll as ApprovalForAllEvent,
|
||||||
CollectionRoleGranted,
|
CollectionRoleGranted as CollectionRoleGrantedEvent,
|
||||||
CollectionRoleRevoked,
|
CollectionRoleRevoked as CollectionRoleRevokedEvent,
|
||||||
NewBuild,
|
NewBuild as NewBuildEvent,
|
||||||
NewTokenDescription,
|
NewTokenDescription as NewTokenDescriptionEvent,
|
||||||
NewTokenENS,
|
NewTokenENS as NewTokenENSEvent,
|
||||||
NewTokenExternalURL,
|
NewTokenExternalURL as NewTokenExternalURLEvent,
|
||||||
NewTokenImage,
|
NewTokenLogo as NewTokenLogoEvent,
|
||||||
NewTokenName,
|
NewTokenName as NewTokenNameEvent,
|
||||||
TokenRoleGranted,
|
TokenRoleGranted as TokenRoleGrantedEvent,
|
||||||
TokenRoleRevoked,
|
TokenRoleRevoked as TokenRoleRevokedEvent,
|
||||||
Transfer,
|
Transfer as TransferEvent,
|
||||||
} from '../generated/FleekNFA/FleekNFA';
|
} from '../generated/FleekNFA/FleekNFA';
|
||||||
|
import {
|
||||||
|
handleApproval,
|
||||||
|
handleApprovalForAll,
|
||||||
|
handleCollectionRoleGranted,
|
||||||
|
handleCollectionRoleRevoked,
|
||||||
|
handleNewBuild,
|
||||||
|
handleNewTokenDescription,
|
||||||
|
handleNewTokenENS,
|
||||||
|
handleNewTokenExternalURL,
|
||||||
|
handleNewTokenLogo,
|
||||||
|
handleNewTokenName,
|
||||||
|
handleTokenRoleGranted,
|
||||||
|
handleTokenRoleRevoked,
|
||||||
|
handleTransfer,
|
||||||
|
} from '../src/fleek-nfa';
|
||||||
|
|
||||||
export function createApprovalEvent(
|
export function createApprovalEvent(
|
||||||
|
event_count: i32,
|
||||||
owner: Address,
|
owner: Address,
|
||||||
approved: Address,
|
approved: Address,
|
||||||
tokenId: BigInt
|
tokenId: BigInt
|
||||||
): Approval {
|
): ApprovalEvent {
|
||||||
let approvalEvent = changetype<Approval>(newMockEvent());
|
let approvalEvent = changetype<ApprovalEvent>(newMockEvent());
|
||||||
|
|
||||||
approvalEvent.parameters = new Array();
|
approvalEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -38,15 +54,19 @@ export function createApprovalEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
approvalEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
approvalEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return approvalEvent;
|
return approvalEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createApprovalForAllEvent(
|
export function createApprovalForAllEvent(
|
||||||
|
event_count: i32,
|
||||||
owner: Address,
|
owner: Address,
|
||||||
operator: Address,
|
operator: Address,
|
||||||
approved: boolean
|
approved: boolean
|
||||||
): ApprovalForAll {
|
): ApprovalForAllEvent {
|
||||||
let approvalForAllEvent = changetype<ApprovalForAll>(newMockEvent());
|
let approvalForAllEvent = changetype<ApprovalForAllEvent>(newMockEvent());
|
||||||
|
|
||||||
approvalForAllEvent.parameters = new Array();
|
approvalForAllEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -60,15 +80,19 @@ export function createApprovalForAllEvent(
|
||||||
new ethereum.EventParam('approved', ethereum.Value.fromBoolean(approved))
|
new ethereum.EventParam('approved', ethereum.Value.fromBoolean(approved))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
approvalForAllEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
approvalForAllEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return approvalForAllEvent;
|
return approvalForAllEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createCollectionRoleGrantedEvent(
|
export function createCollectionRoleGrantedEvent(
|
||||||
|
event_count: i32,
|
||||||
role: i32,
|
role: i32,
|
||||||
toAddress: Address,
|
toAddress: Address,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): CollectionRoleGranted {
|
): CollectionRoleGrantedEvent {
|
||||||
let collectionRoleGrantedEvent = changetype<CollectionRoleGranted>(
|
let collectionRoleGrantedEvent = changetype<CollectionRoleGrantedEvent>(
|
||||||
newMockEvent()
|
newMockEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -87,15 +111,19 @@ export function createCollectionRoleGrantedEvent(
|
||||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
collectionRoleGrantedEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
collectionRoleGrantedEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return collectionRoleGrantedEvent;
|
return collectionRoleGrantedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createCollectionRoleRevokedEvent(
|
export function createCollectionRoleRevokedEvent(
|
||||||
|
event_count: i32,
|
||||||
role: i32,
|
role: i32,
|
||||||
toAddress: Address,
|
toAddress: Address,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): CollectionRoleRevoked {
|
): CollectionRoleRevokedEvent {
|
||||||
let collectionRoleRevokedEvent = changetype<CollectionRoleRevoked>(
|
let collectionRoleRevokedEvent = changetype<CollectionRoleRevokedEvent>(
|
||||||
newMockEvent()
|
newMockEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -114,15 +142,19 @@ export function createCollectionRoleRevokedEvent(
|
||||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
collectionRoleRevokedEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
collectionRoleRevokedEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return collectionRoleRevokedEvent;
|
return collectionRoleRevokedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewBuildEvent(
|
export function createNewBuildEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
commitHash: string,
|
commitHash: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewBuild {
|
): NewBuildEvent {
|
||||||
let newBuildEvent = changetype<NewBuild>(newMockEvent());
|
let newBuildEvent = changetype<NewBuildEvent>(newMockEvent());
|
||||||
|
|
||||||
newBuildEvent.parameters = new Array();
|
newBuildEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -139,15 +171,19 @@ export function createNewBuildEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newBuildEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newBuildEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newBuildEvent;
|
return newBuildEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewTokenDescriptionEvent(
|
export function createNewTokenDescriptionEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
description: string,
|
description: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewTokenDescription {
|
): NewTokenDescriptionEvent {
|
||||||
let newTokenDescriptionEvent = changetype<NewTokenDescription>(
|
let newTokenDescriptionEvent = changetype<NewTokenDescriptionEvent>(
|
||||||
newMockEvent()
|
newMockEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -169,15 +205,19 @@ export function createNewTokenDescriptionEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newTokenDescriptionEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newTokenDescriptionEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newTokenDescriptionEvent;
|
return newTokenDescriptionEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewTokenENSEvent(
|
export function createNewTokenENSEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
ENS: string,
|
ENS: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewTokenENS {
|
): NewTokenENSEvent {
|
||||||
let newTokenEnsEvent = changetype<NewTokenENS>(newMockEvent());
|
let newTokenEnsEvent = changetype<NewTokenENSEvent>(newMockEvent());
|
||||||
|
|
||||||
newTokenEnsEvent.parameters = new Array();
|
newTokenEnsEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -194,15 +234,19 @@ export function createNewTokenENSEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newTokenEnsEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newTokenEnsEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newTokenEnsEvent;
|
return newTokenEnsEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewTokenExternalURLEvent(
|
export function createNewTokenExternalURLEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
externalURL: string,
|
externalURL: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewTokenExternalURL {
|
): NewTokenExternalURLEvent {
|
||||||
let newTokenExternalUrlEvent = changetype<NewTokenExternalURL>(
|
let newTokenExternalUrlEvent = changetype<NewTokenExternalURLEvent>(
|
||||||
newMockEvent()
|
newMockEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -224,15 +268,19 @@ export function createNewTokenExternalURLEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newTokenExternalUrlEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newTokenExternalUrlEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newTokenExternalUrlEvent;
|
return newTokenExternalUrlEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewTokenImageEvent(
|
export function createNewTokenImageEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
image: string,
|
image: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewTokenImage {
|
): NewTokenImageEvent {
|
||||||
let newTokenImageEvent = changetype<NewTokenImage>(newMockEvent());
|
let newTokenImageEvent = changetype<NewTokenImageEvent>(newMockEvent());
|
||||||
|
|
||||||
newTokenImageEvent.parameters = new Array();
|
newTokenImageEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -249,15 +297,19 @@ export function createNewTokenImageEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newTokenImageEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newTokenImageEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newTokenImageEvent;
|
return newTokenImageEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNewTokenNameEvent(
|
export function createNewTokenNameEvent(
|
||||||
|
event_count: i32,
|
||||||
token: BigInt,
|
token: BigInt,
|
||||||
name: string,
|
name: string,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): NewTokenName {
|
): NewTokenNameEvent {
|
||||||
let newTokenNameEvent = changetype<NewTokenName>(newMockEvent());
|
let newTokenNameEvent = changetype<NewTokenNameEvent>(newMockEvent());
|
||||||
|
|
||||||
newTokenNameEvent.parameters = new Array();
|
newTokenNameEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -274,16 +326,20 @@ export function createNewTokenNameEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
newTokenNameEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
newTokenNameEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return newTokenNameEvent;
|
return newTokenNameEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTokenRoleGrantedEvent(
|
export function createTokenRoleGrantedEvent(
|
||||||
|
event_count: i32,
|
||||||
tokenId: BigInt,
|
tokenId: BigInt,
|
||||||
role: i32,
|
role: i32,
|
||||||
toAddress: Address,
|
toAddress: Address,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): TokenRoleGranted {
|
): TokenRoleGrantedEvent {
|
||||||
let tokenRoleGrantedEvent = changetype<TokenRoleGranted>(newMockEvent());
|
let tokenRoleGrantedEvent = changetype<TokenRoleGrantedEvent>(newMockEvent());
|
||||||
|
|
||||||
tokenRoleGrantedEvent.parameters = new Array();
|
tokenRoleGrantedEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -306,16 +362,20 @@ export function createTokenRoleGrantedEvent(
|
||||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
tokenRoleGrantedEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
tokenRoleGrantedEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return tokenRoleGrantedEvent;
|
return tokenRoleGrantedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTokenRoleRevokedEvent(
|
export function createTokenRoleRevokedEvent(
|
||||||
|
event_count: i32,
|
||||||
tokenId: BigInt,
|
tokenId: BigInt,
|
||||||
role: i32,
|
role: i32,
|
||||||
toAddress: Address,
|
toAddress: Address,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): TokenRoleRevoked {
|
): TokenRoleRevokedEvent {
|
||||||
let tokenRoleRevokedEvent = changetype<TokenRoleRevoked>(newMockEvent());
|
let tokenRoleRevokedEvent = changetype<TokenRoleRevokedEvent>(newMockEvent());
|
||||||
|
|
||||||
tokenRoleRevokedEvent.parameters = new Array();
|
tokenRoleRevokedEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -338,15 +398,19 @@ export function createTokenRoleRevokedEvent(
|
||||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
tokenRoleRevokedEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
tokenRoleRevokedEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return tokenRoleRevokedEvent;
|
return tokenRoleRevokedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTransferEvent(
|
export function createTransferEvent(
|
||||||
|
event_count: i32,
|
||||||
from: Address,
|
from: Address,
|
||||||
to: Address,
|
to: Address,
|
||||||
tokenId: BigInt
|
tokenId: BigInt
|
||||||
): Transfer {
|
): TransferEvent {
|
||||||
let transferEvent = changetype<Transfer>(newMockEvent());
|
let transferEvent = changetype<TransferEvent>(newMockEvent());
|
||||||
|
|
||||||
transferEvent.parameters = new Array();
|
transferEvent.parameters = new Array();
|
||||||
|
|
||||||
|
|
@ -363,5 +427,111 @@ export function createTransferEvent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
transferEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||||
|
transferEvent.logIndex = new BigInt(event_count);
|
||||||
|
|
||||||
return transferEvent;
|
return transferEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const CONTRACT: Address = Address.fromString(
|
||||||
|
'0x0000000000000000000000000000000000000000'
|
||||||
|
);
|
||||||
|
export const CONTRACT_OWNER: Address = Address.fromString(
|
||||||
|
'0x1000000000000000000000000000000000000001'
|
||||||
|
);
|
||||||
|
export const TOKEN_OWNER_ONE: Address = Address.fromString(
|
||||||
|
'0x2000000000000000000000000000000000000002'
|
||||||
|
);
|
||||||
|
export const TOKEN_OWNER_TWO: Address = Address.fromString(
|
||||||
|
'0x3000000000000000000000000000000000000003'
|
||||||
|
);
|
||||||
|
|
||||||
|
export function handleTransfers(events: TransferEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleTransfer(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewTokenNames(events: NewTokenNameEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewTokenName(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewTokenDescriptions(
|
||||||
|
events: NewTokenDescriptionEvent[]
|
||||||
|
): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewTokenDescription(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewTokenENSAddresses(events: NewTokenENSEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewTokenENS(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewTokenExternalURLs(
|
||||||
|
events: NewTokenExternalURLEvent[]
|
||||||
|
): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewTokenExternalURL(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewBuilds(events: NewBuildEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewBuild(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleNewTokenLogos(events: NewTokenLogoEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleNewTokenLogo(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleApprovals(events: ApprovalEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleApproval(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleApprovalForAlls(events: ApprovalForAllEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleApprovalForAll(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleCollectionRoleGranteds(
|
||||||
|
events: CollectionRoleGrantedEvent[]
|
||||||
|
): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleCollectionRoleGranted(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleCollectionRoleRevokeds(
|
||||||
|
events: CollectionRoleRevokedEvent[]
|
||||||
|
): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleCollectionRoleRevoked(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleTokenRoleGranteds(events: TokenRoleGrantedEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleTokenRoleGranted(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleTokenRoleRevokeds(events: TokenRoleRevokedEvent[]): void {
|
||||||
|
events.forEach((event) => {
|
||||||
|
handleTokenRoleRevoked(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function makeEventId(id: i32): string {
|
||||||
|
return Bytes.fromI32(id).toHexString() + '00000000';
|
||||||
|
}
|
||||||
|
|
@ -1445,9 +1445,9 @@ glob@^7.1.3:
|
||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
path-is-absolute "^1.0.0"
|
path-is-absolute "^1.0.0"
|
||||||
|
|
||||||
"gluegun@git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep":
|
"gluegun@https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep":
|
||||||
version "4.3.1"
|
version "4.3.1"
|
||||||
resolved "git+https://github.com/edgeandnode/gluegun.git#b34b9003d7bf556836da41b57ef36eb21570620a"
|
resolved "https://github.com/edgeandnode/gluegun#b34b9003d7bf556836da41b57ef36eb21570620a"
|
||||||
dependencies:
|
dependencies:
|
||||||
apisauce "^1.0.1"
|
apisauce "^1.0.1"
|
||||||
app-module-path "^2.2.0"
|
app-module-path "^2.2.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue