style: fix eslint errors for subgraph (#218)
* style: fix eslint errors. * fix: remove yarn-error.log from serverless dir.
This commit is contained in:
parent
c4ced2ff93
commit
aa98d91c7a
|
|
@ -1,110 +1,100 @@
|
||||||
import {
|
import { Bytes, log } from '@graphprotocol/graph-ts';
|
||||||
Address,
|
|
||||||
Bytes,
|
|
||||||
log,
|
|
||||||
store,
|
|
||||||
ethereum,
|
|
||||||
BigInt,
|
|
||||||
} from '@graphprotocol/graph-ts';
|
|
||||||
|
|
||||||
// Event Imports [based on the yaml config]
|
// Event Imports [based on the yaml config]
|
||||||
import {
|
import {
|
||||||
TokenRoleChanged as TokenRoleChangedEvent,
|
TokenRoleChanged as TokenRoleChangedEvent,
|
||||||
CollectionRoleChanged as CollectionRoleChangedEvent,
|
CollectionRoleChanged as CollectionRoleChangedEvent,
|
||||||
} from '../generated/FleekNFA/FleekNFA';
|
} from '../generated/FleekNFA/FleekNFA';
|
||||||
|
|
||||||
// Entity Imports [based on the schema]
|
// Entity Imports [based on the schema]
|
||||||
import {
|
import { Owner, Token } from '../generated/schema';
|
||||||
Owner,
|
|
||||||
Token,
|
|
||||||
} from '../generated/schema';
|
|
||||||
|
|
||||||
enum CollectionRoles {
|
enum CollectionRoles {
|
||||||
Owner,
|
Owner,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TokenRoles {
|
enum TokenRoles {
|
||||||
Controller,
|
Controller,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleCollectionRoleChanged(
|
export function handleCollectionRoleChanged(
|
||||||
event: CollectionRoleChangedEvent
|
event: CollectionRoleChangedEvent
|
||||||
): void {
|
): void {
|
||||||
let toAddress = event.params.toAddress;
|
const toAddress = event.params.toAddress;
|
||||||
let byAddress = event.params.byAddress;
|
const byAddress = event.params.byAddress;
|
||||||
let role = event.params.role;
|
const role = event.params.role;
|
||||||
let status = event.params.status;
|
const status = event.params.status;
|
||||||
|
|
||||||
if (role === CollectionRoles.Owner) {
|
if (role === CollectionRoles.Owner) {
|
||||||
// Owner role
|
// Owner role
|
||||||
if (status) {
|
if (status) {
|
||||||
// granted
|
// granted
|
||||||
let owner = Owner.load(toAddress);
|
let owner = Owner.load(toAddress);
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
owner = new Owner(toAddress);
|
owner = new Owner(toAddress);
|
||||||
}
|
}
|
||||||
owner.collection = true;
|
owner.collection = true;
|
||||||
owner.save();
|
owner.save();
|
||||||
} else {
|
|
||||||
// revoked
|
|
||||||
let owner = Owner.load(toAddress);
|
|
||||||
if (!owner) {
|
|
||||||
log.error(
|
|
||||||
'Owner entity not found. Role: {}, byAddress: {}, toAddress: {}',
|
|
||||||
[role.toString(), byAddress.toHexString(), toAddress.toHexString()]
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
owner.collection = false;
|
|
||||||
owner.save();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.error('Role not supported. Role: {}, byAddress: {}, toAddress: {}', [
|
// revoked
|
||||||
role.toString(),
|
const owner = Owner.load(toAddress);
|
||||||
byAddress.toHexString(),
|
if (!owner) {
|
||||||
toAddress.toHexString(),
|
log.error(
|
||||||
]);
|
'Owner entity not found. Role: {}, byAddress: {}, toAddress: {}',
|
||||||
|
[role.toString(), byAddress.toHexString(), toAddress.toHexString()]
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
owner.collection = false;
|
||||||
|
owner.save();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.error('Role not supported. Role: {}, byAddress: {}, toAddress: {}', [
|
||||||
|
role.toString(),
|
||||||
|
byAddress.toHexString(),
|
||||||
|
toAddress.toHexString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleTokenRoleChanged(event: TokenRoleChangedEvent): void {
|
export function handleTokenRoleChanged(event: TokenRoleChangedEvent): void {
|
||||||
let tokenId = event.params.tokenId;
|
const tokenId = event.params.tokenId;
|
||||||
let toAddress = event.params.toAddress;
|
const toAddress = event.params.toAddress;
|
||||||
let byAddress = event.params.byAddress;
|
const byAddress = event.params.byAddress;
|
||||||
let role = event.params.role;
|
const role = event.params.role;
|
||||||
let status = event.params.status;
|
const status = event.params.status;
|
||||||
|
|
||||||
// load token
|
// load token
|
||||||
let token = Token.load(Bytes.fromByteArray(Bytes.fromBigInt(tokenId)));
|
const token = Token.load(Bytes.fromByteArray(Bytes.fromBigInt(tokenId)));
|
||||||
if (!token) {
|
if (!token) {
|
||||||
log.error('Token not found. TokenId: {}', [tokenId.toString()]);
|
log.error('Token not found. TokenId: {}', [tokenId.toString()]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role === TokenRoles.Controller) {
|
||||||
|
// Controller role
|
||||||
|
// get the list of controllers.
|
||||||
|
let token_controllers = token.controllers;
|
||||||
|
if (!token_controllers) {
|
||||||
|
token_controllers = [];
|
||||||
}
|
}
|
||||||
|
if (status) {
|
||||||
if (role === TokenRoles.Controller) {
|
// granted
|
||||||
// Controller role
|
token_controllers.push(toAddress);
|
||||||
// get the list of controllers.
|
|
||||||
let token_controllers = token.controllers;
|
|
||||||
if (!token_controllers) {
|
|
||||||
token_controllers = [];
|
|
||||||
}
|
|
||||||
if (status) {
|
|
||||||
// granted
|
|
||||||
token_controllers.push(toAddress);
|
|
||||||
} else {
|
|
||||||
// revoked
|
|
||||||
// remove address from the controllers list
|
|
||||||
const index = token_controllers.indexOf(event.params.toAddress, 0);
|
|
||||||
if (index > -1) {
|
|
||||||
token_controllers.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
token.controllers = token_controllers;
|
|
||||||
} else {
|
} else {
|
||||||
log.error('Role not supported. Role: {}, byAddress: {}, toAddress: {}', [
|
// revoked
|
||||||
role.toString(),
|
// remove address from the controllers list
|
||||||
byAddress.toHexString(),
|
const index = token_controllers.indexOf(event.params.toAddress, 0);
|
||||||
toAddress.toHexString(),
|
if (index > -1) {
|
||||||
]);
|
token_controllers.splice(index, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
token.controllers = token_controllers;
|
||||||
|
} else {
|
||||||
|
log.error('Role not supported. Role: {}, byAddress: {}, toAddress: {}', [
|
||||||
|
role.toString(),
|
||||||
|
byAddress.toHexString(),
|
||||||
|
toAddress.toHexString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import { Bytes, log, BigInt } from '@graphprotocol/graph-ts';
|
||||||
Address,
|
|
||||||
Bytes,
|
|
||||||
log,
|
|
||||||
store,
|
|
||||||
ethereum,
|
|
||||||
BigInt,
|
|
||||||
} from '@graphprotocol/graph-ts';
|
|
||||||
|
|
||||||
// Event Imports [based on the yaml config]
|
// Event Imports [based on the yaml config]
|
||||||
import {
|
import {
|
||||||
|
|
@ -27,7 +20,7 @@ import { AccessPoint, Owner } from '../generated/schema';
|
||||||
*/
|
*/
|
||||||
export function handleNewAccessPoint(event: NewAccessPointEvent): void {
|
export function handleNewAccessPoint(event: NewAccessPointEvent): void {
|
||||||
// Create an AccessPoint entity
|
// Create an AccessPoint entity
|
||||||
let accessPointEntity = new AccessPoint(event.params.apName);
|
const accessPointEntity = new AccessPoint(event.params.apName);
|
||||||
accessPointEntity.score = BigInt.fromU32(0);
|
accessPointEntity.score = BigInt.fromU32(0);
|
||||||
accessPointEntity.contentVerified = false;
|
accessPointEntity.contentVerified = false;
|
||||||
accessPointEntity.nameVerified = false;
|
accessPointEntity.nameVerified = false;
|
||||||
|
|
@ -59,8 +52,8 @@ export function handleChangeAccessPointCreationStatus(
|
||||||
event: ChangeAccessPointCreationStatusEvent
|
event: ChangeAccessPointCreationStatusEvent
|
||||||
): void {
|
): void {
|
||||||
// Load the AccessPoint entity
|
// Load the AccessPoint entity
|
||||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
const accessPointEntity = AccessPoint.load(event.params.apName);
|
||||||
let status = event.params.status;
|
const status = event.params.status;
|
||||||
|
|
||||||
if (accessPointEntity) {
|
if (accessPointEntity) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
|
@ -101,7 +94,7 @@ export function handleChangeAccessPointScore(
|
||||||
event: ChangeAccessPointCreationScoreEvent
|
event: ChangeAccessPointCreationScoreEvent
|
||||||
): void {
|
): void {
|
||||||
// Load the AccessPoint entity
|
// Load the AccessPoint entity
|
||||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
const accessPointEntity = AccessPoint.load(event.params.apName);
|
||||||
|
|
||||||
if (accessPointEntity) {
|
if (accessPointEntity) {
|
||||||
accessPointEntity.score = event.params.score;
|
accessPointEntity.score = event.params.score;
|
||||||
|
|
@ -122,7 +115,7 @@ export function handleChangeAccessPointNameVerify(
|
||||||
event: ChangeAccessPointNameVerifyEvent
|
event: ChangeAccessPointNameVerifyEvent
|
||||||
): void {
|
): void {
|
||||||
// Load the AccessPoint entity
|
// Load the AccessPoint entity
|
||||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
const accessPointEntity = AccessPoint.load(event.params.apName);
|
||||||
|
|
||||||
if (accessPointEntity) {
|
if (accessPointEntity) {
|
||||||
accessPointEntity.nameVerified = event.params.verified;
|
accessPointEntity.nameVerified = event.params.verified;
|
||||||
|
|
@ -143,7 +136,7 @@ export function handleChangeAccessPointContentVerify(
|
||||||
event: ChangeAccessPointContentVerifyEvent
|
event: ChangeAccessPointContentVerifyEvent
|
||||||
): void {
|
): void {
|
||||||
// Load the AccessPoint entity
|
// Load the AccessPoint entity
|
||||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
const accessPointEntity = AccessPoint.load(event.params.apName);
|
||||||
|
|
||||||
if (accessPointEntity) {
|
if (accessPointEntity) {
|
||||||
accessPointEntity.contentVerified = event.params.verified;
|
accessPointEntity.contentVerified = event.params.verified;
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,38 @@
|
||||||
// Event Imports [based on the yaml config]
|
// Event Imports [based on the yaml config]
|
||||||
import {
|
import {
|
||||||
Approval as ApprovalEvent,
|
Approval as ApprovalEvent,
|
||||||
ApprovalForAll as ApprovalForAllEvent,
|
ApprovalForAll as ApprovalForAllEvent,
|
||||||
} from '../generated/FleekNFA/FleekNFA';
|
} from '../generated/FleekNFA/FleekNFA';
|
||||||
|
|
||||||
// Entity Imports [based on the schema]
|
// Entity Imports [based on the schema]
|
||||||
import {
|
import { Approval, ApprovalForAll } from '../generated/schema';
|
||||||
Approval,
|
|
||||||
ApprovalForAll,
|
|
||||||
} from '../generated/schema';
|
|
||||||
|
|
||||||
export function handleApproval(event: ApprovalEvent): void {
|
export function handleApproval(event: ApprovalEvent): void {
|
||||||
let entity = new Approval(
|
const entity = new Approval(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.owner = event.params.owner;
|
entity.owner = event.params.owner;
|
||||||
entity.approved = event.params.approved;
|
entity.approved = event.params.approved;
|
||||||
entity.tokenId = event.params.tokenId;
|
entity.tokenId = event.params.tokenId;
|
||||||
|
|
||||||
entity.blockNumber = event.block.number;
|
entity.blockNumber = event.block.number;
|
||||||
entity.blockTimestamp = event.block.timestamp;
|
entity.blockTimestamp = event.block.timestamp;
|
||||||
entity.transactionHash = event.transaction.hash;
|
entity.transactionHash = event.transaction.hash;
|
||||||
|
|
||||||
entity.save();
|
entity.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleApprovalForAll(event: ApprovalForAllEvent): void {
|
export function handleApprovalForAll(event: ApprovalForAllEvent): void {
|
||||||
let entity = new ApprovalForAll(
|
const entity = new ApprovalForAll(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
entity.owner = event.params.owner;
|
entity.owner = event.params.owner;
|
||||||
entity.operator = event.params.operator;
|
entity.operator = event.params.operator;
|
||||||
entity.approved = event.params.approved;
|
entity.approved = event.params.approved;
|
||||||
|
|
||||||
entity.blockNumber = event.block.number;
|
entity.blockNumber = event.block.number;
|
||||||
entity.blockTimestamp = event.block.timestamp;
|
entity.blockTimestamp = event.block.timestamp;
|
||||||
entity.transactionHash = event.transaction.hash;
|
entity.transactionHash = event.transaction.hash;
|
||||||
|
|
||||||
entity.save();
|
entity.save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,22 @@
|
||||||
import {
|
import { log, ethereum } from '@graphprotocol/graph-ts';
|
||||||
log,
|
|
||||||
ethereum,
|
|
||||||
} from '@graphprotocol/graph-ts';
|
|
||||||
|
|
||||||
// Event Imports [based on the yaml config]
|
// Event Imports [based on the yaml config]
|
||||||
import {
|
import { Initialized as InitializedEvent } from '../generated/FleekNFA/FleekNFA';
|
||||||
Initialized as InitializedEvent,
|
|
||||||
} from '../generated/FleekNFA/FleekNFA';
|
|
||||||
|
|
||||||
// Entity Imports [based on the schema]
|
// Entity Imports [based on the schema]
|
||||||
import {
|
import { Owner } from '../generated/schema';
|
||||||
Owner,
|
|
||||||
} from '../generated/schema';
|
|
||||||
export function handleInitialized(event: InitializedEvent): void {
|
export function handleInitialized(event: InitializedEvent): void {
|
||||||
// This is the contract creation transaction.
|
// This is the contract creation transaction.
|
||||||
log.warning('This is the contract creation transaction.', []);
|
log.warning('This is the contract creation transaction.', []);
|
||||||
if (event.receipt) {
|
if (event.receipt) {
|
||||||
let receipt = event.receipt as ethereum.TransactionReceipt;
|
const receipt = event.receipt as ethereum.TransactionReceipt;
|
||||||
log.warning('Contract address is: {}', [
|
log.warning('Contract address is: {}', [
|
||||||
receipt.contractAddress.toHexString(),
|
receipt.contractAddress.toHexString(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// add owner
|
// add owner
|
||||||
let owner = new Owner(event.transaction.from);
|
const owner = new Owner(event.transaction.from);
|
||||||
owner.collection = true;
|
owner.collection = true;
|
||||||
owner.save();
|
owner.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
export * from './access-control';
|
export * from './access-control';
|
||||||
export * from './access-point';
|
export * from './access-point';
|
||||||
export * from './approval';
|
export * from './approval';
|
||||||
export * from './contract';
|
export * from './contract';
|
||||||
export * from './metadata-update';
|
export * from './metadata-update';
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export function handleMetadataUpdateWithStringValue(
|
||||||
* setTokenDescription
|
* setTokenDescription
|
||||||
* setTokenLogo
|
* setTokenLogo
|
||||||
* */
|
* */
|
||||||
let entity = new MetadataUpdate(
|
const entity = new MetadataUpdate(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ export function handleMetadataUpdateWithStringValue(
|
||||||
entity.save();
|
entity.save();
|
||||||
|
|
||||||
// UPDATE TOKEN
|
// UPDATE TOKEN
|
||||||
let token = Token.load(
|
const token = Token.load(
|
||||||
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ export function handleMetadataUpdateWithDoubleStringValue(
|
||||||
/**
|
/**
|
||||||
* setTokenBuild
|
* setTokenBuild
|
||||||
*/
|
*/
|
||||||
let entity = new MetadataUpdate(
|
const entity = new MetadataUpdate(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ export function handleMetadataUpdateWithDoubleStringValue(
|
||||||
entity.save();
|
entity.save();
|
||||||
|
|
||||||
// UPDATE TOKEN
|
// UPDATE TOKEN
|
||||||
let token = Token.load(
|
const token = Token.load(
|
||||||
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ export function handleMetadataUpdateWithIntValue(
|
||||||
/**
|
/**
|
||||||
* setTokenColor
|
* setTokenColor
|
||||||
*/
|
*/
|
||||||
let entity = new MetadataUpdate(
|
const entity = new MetadataUpdate(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ export function handleMetadataUpdateWithIntValue(
|
||||||
|
|
||||||
entity.save();
|
entity.save();
|
||||||
|
|
||||||
let token = Token.load(
|
const token = Token.load(
|
||||||
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -138,7 +138,7 @@ export function handleMetadataUpdateWithBooleanValue(
|
||||||
/**
|
/**
|
||||||
* accessPointAutoApproval
|
* accessPointAutoApproval
|
||||||
*/
|
*/
|
||||||
let entity = new MetadataUpdate(
|
const entity = new MetadataUpdate(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ export function handleMetadataUpdateWithBooleanValue(
|
||||||
|
|
||||||
entity.save();
|
entity.save();
|
||||||
|
|
||||||
let token = Token.load(
|
const token = Token.load(
|
||||||
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,25 @@ import { Bytes, log } from '@graphprotocol/graph-ts';
|
||||||
import { NewMint as NewMintEvent } from '../generated/FleekNFA/FleekNFA';
|
import { NewMint as NewMintEvent } from '../generated/FleekNFA/FleekNFA';
|
||||||
|
|
||||||
// Entity Imports [based on the schema]
|
// Entity Imports [based on the schema]
|
||||||
import {
|
import { Owner, NewMint, Token } from '../generated/schema';
|
||||||
Owner,
|
|
||||||
GitRepository as GitRepositoryEntity,
|
|
||||||
NewMint,
|
|
||||||
Token,
|
|
||||||
} from '../generated/schema';
|
|
||||||
|
|
||||||
export function handleNewMint(event: NewMintEvent): void {
|
export function handleNewMint(event: NewMintEvent): void {
|
||||||
let newMintEntity = new NewMint(
|
const newMintEntity = new NewMint(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
let name = event.params.name;
|
const name = event.params.name;
|
||||||
let description = event.params.description;
|
const description = event.params.description;
|
||||||
let externalURL = event.params.externalURL;
|
const externalURL = event.params.externalURL;
|
||||||
let ENS = event.params.ENS;
|
const ENS = event.params.ENS;
|
||||||
let gitRepository = event.params.gitRepository;
|
const gitRepository = event.params.gitRepository;
|
||||||
let commitHash = event.params.commitHash;
|
const commitHash = event.params.commitHash;
|
||||||
let logo = event.params.logo;
|
const logo = event.params.logo;
|
||||||
let color = event.params.color;
|
const color = event.params.color;
|
||||||
let accessPointAutoApproval = event.params.accessPointAutoApproval;
|
const accessPointAutoApproval = event.params.accessPointAutoApproval;
|
||||||
let tokenId = event.params.tokenId;
|
const tokenId = event.params.tokenId;
|
||||||
let ownerAddress = event.params.owner;
|
const ownerAddress = event.params.owner;
|
||||||
let verifierAddress = event.params.verifier;
|
const verifierAddress = event.params.verifier;
|
||||||
|
|
||||||
newMintEntity.tokenId = tokenId;
|
newMintEntity.tokenId = tokenId;
|
||||||
newMintEntity.name = name;
|
newMintEntity.name = name;
|
||||||
|
|
@ -51,7 +46,7 @@ export function handleNewMint(event: NewMintEvent): void {
|
||||||
// Create Token, Owner, and Controller entities
|
// Create Token, Owner, and Controller entities
|
||||||
|
|
||||||
let owner = Owner.load(ownerAddress);
|
let owner = Owner.load(ownerAddress);
|
||||||
let token = new Token(Bytes.fromByteArray(Bytes.fromBigInt(tokenId)));
|
const token = new Token(Bytes.fromByteArray(Bytes.fromBigInt(tokenId)));
|
||||||
|
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
// Create a new owner entity
|
// Create a new owner entity
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { Transfer as TransferEvent } from '../generated/FleekNFA/FleekNFA';
|
||||||
import { Owner, Token, Transfer } from '../generated/schema';
|
import { Owner, Token, Transfer } from '../generated/schema';
|
||||||
|
|
||||||
export function handleTransfer(event: TransferEvent): void {
|
export function handleTransfer(event: TransferEvent): void {
|
||||||
let transfer = new Transfer(
|
const transfer = new Transfer(
|
||||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ export function handleTransfer(event: TransferEvent): void {
|
||||||
|
|
||||||
let token: Token | null;
|
let token: Token | null;
|
||||||
|
|
||||||
let owner_address = event.params.to;
|
const owner_address = event.params.to;
|
||||||
let owner = Owner.load(owner_address);
|
let owner = Owner.load(owner_address);
|
||||||
|
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,12 @@ import {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
afterAll,
|
afterAll,
|
||||||
} from 'matchstick-as/assembly/index';
|
} from 'matchstick-as/assembly/index';
|
||||||
import { BigInt, Bytes } from '@graphprotocol/graph-ts';
|
import { BigInt } from '@graphprotocol/graph-ts';
|
||||||
import {
|
import {
|
||||||
createNewAccessPointEvent,
|
createNewAccessPointEvent,
|
||||||
createNewChangeAccessPointCreationStatus,
|
createNewChangeAccessPointCreationStatus,
|
||||||
handleChangeAccessPointCreationStatusList,
|
handleChangeAccessPointCreationStatusList,
|
||||||
handleNewAccessPoints,
|
handleNewAccessPoints,
|
||||||
makeEventId,
|
|
||||||
USER_ONE,
|
USER_ONE,
|
||||||
USER_TWO,
|
USER_TWO,
|
||||||
} from '../helpers/utils';
|
} from '../helpers/utils';
|
||||||
|
|
@ -24,7 +23,7 @@ import {
|
||||||
describe('Change Access Point Creation Status tests', () => {
|
describe('Change Access Point Creation Status tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
// New Access Points
|
// New Access Points
|
||||||
let newAccessPoints: NewAccessPoint[] = [];
|
const newAccessPoints: NewAccessPoint[] = [];
|
||||||
|
|
||||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||||
newAccessPoints.push(
|
newAccessPoints.push(
|
||||||
|
|
@ -54,7 +53,7 @@ describe('Change Access Point Creation Status tests', () => {
|
||||||
|
|
||||||
test('Check the `creationStatus` field of each access point entity after changing it', () => {
|
test('Check the `creationStatus` field of each access point entity after changing it', () => {
|
||||||
// New Access Points
|
// New Access Points
|
||||||
let changeAccessPointCreationStatusList: ChangeAccessPointCreationStatus[] =
|
const changeAccessPointCreationStatusList: ChangeAccessPointCreationStatus[] =
|
||||||
[];
|
[];
|
||||||
|
|
||||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||||
|
|
@ -23,7 +23,7 @@ import {
|
||||||
describe('Change Access Point Name Verify tests', () => {
|
describe('Change Access Point Name Verify tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
// New Access Points
|
// New Access Points
|
||||||
let newAccessPoints: NewAccessPoint[] = [];
|
const newAccessPoints: NewAccessPoint[] = [];
|
||||||
|
|
||||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||||
newAccessPoints.push(
|
newAccessPoints.push(
|
||||||
|
|
@ -53,7 +53,7 @@ describe('Change Access Point Name Verify tests', () => {
|
||||||
|
|
||||||
test('Check the `nameVerified` field of each access point entity after changing it', () => {
|
test('Check the `nameVerified` field of each access point entity after changing it', () => {
|
||||||
// New Access Point Name Verified fields
|
// New Access Point Name Verified fields
|
||||||
let changeAccessPointNameVerifies: ChangeAccessPointNameVerify[] = [];
|
const changeAccessPointNameVerifies: ChangeAccessPointNameVerify[] = [];
|
||||||
|
|
||||||
changeAccessPointNameVerifies.push(
|
changeAccessPointNameVerifies.push(
|
||||||
createNewChangeAccessPointNameVerify(
|
createNewChangeAccessPointNameVerify(
|
||||||
|
|
@ -27,11 +27,11 @@ export function createApprovalEvent(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
owner: Address,
|
owner: Address,
|
||||||
approved: Address,
|
approved: Address,
|
||||||
tokenId: BigInt
|
tokenId: bigint
|
||||||
): ApprovalEvent {
|
): ApprovalEvent {
|
||||||
let approvalEvent = changetype<ApprovalEvent>(newMockEvent());
|
const approvalEvent = changetype<ApprovalEvent>(newMockEvent());
|
||||||
|
|
||||||
approvalEvent.parameters = new Array();
|
approvalEvent.parameters = [];
|
||||||
|
|
||||||
approvalEvent.parameters.push(
|
approvalEvent.parameters.push(
|
||||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
||||||
|
|
@ -58,9 +58,9 @@ export function createApprovalForAllEvent(
|
||||||
operator: Address,
|
operator: Address,
|
||||||
approved: boolean
|
approved: boolean
|
||||||
): ApprovalForAllEvent {
|
): ApprovalForAllEvent {
|
||||||
let approvalForAllEvent = changetype<ApprovalForAllEvent>(newMockEvent());
|
const approvalForAllEvent = changetype<ApprovalForAllEvent>(newMockEvent());
|
||||||
|
|
||||||
approvalForAllEvent.parameters = new Array();
|
approvalForAllEvent.parameters = [];
|
||||||
|
|
||||||
approvalForAllEvent.parameters.push(
|
approvalForAllEvent.parameters.push(
|
||||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
||||||
|
|
@ -82,11 +82,11 @@ export function createTransferEvent(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
from: Address,
|
from: Address,
|
||||||
to: Address,
|
to: Address,
|
||||||
tokenId: BigInt
|
tokenId: bigint
|
||||||
): TransferEvent {
|
): TransferEvent {
|
||||||
let transferEvent = changetype<TransferEvent>(newMockEvent());
|
const transferEvent = changetype<TransferEvent>(newMockEvent());
|
||||||
|
|
||||||
transferEvent.parameters = new Array();
|
transferEvent.parameters = [];
|
||||||
|
|
||||||
transferEvent.parameters.push(
|
transferEvent.parameters.push(
|
||||||
new ethereum.EventParam('from', ethereum.Value.fromAddress(from))
|
new ethereum.EventParam('from', ethereum.Value.fromAddress(from))
|
||||||
|
|
@ -110,11 +110,11 @@ export function createTransferEvent(
|
||||||
export function createNewMintEvent(
|
export function createNewMintEvent(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
to: Address,
|
to: Address,
|
||||||
tokenId: BigInt
|
tokenId: bigint
|
||||||
): NewMintEvent {
|
): NewMintEvent {
|
||||||
let newMintEvent = changetype<NewMintEvent>(newMockEvent());
|
const newMintEvent = changetype<NewMintEvent>(newMockEvent());
|
||||||
|
|
||||||
newMintEvent.parameters = new Array();
|
newMintEvent.parameters = [];
|
||||||
|
|
||||||
newMintEvent.parameters.push(
|
newMintEvent.parameters.push(
|
||||||
new ethereum.EventParam(
|
new ethereum.EventParam(
|
||||||
|
|
@ -177,12 +177,12 @@ export function createNewMintEvent(
|
||||||
export function createNewAccessPointEvent(
|
export function createNewAccessPointEvent(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
apName: string,
|
apName: string,
|
||||||
tokenId: BigInt,
|
tokenId: bigint,
|
||||||
owner: Address
|
owner: Address
|
||||||
): NewAccessPoint {
|
): NewAccessPoint {
|
||||||
let newAccessPoint = changetype<NewAccessPoint>(newMockEvent());
|
const newAccessPoint = changetype<NewAccessPoint>(newMockEvent());
|
||||||
|
|
||||||
newAccessPoint.parameters = new Array();
|
newAccessPoint.parameters = [];
|
||||||
|
|
||||||
newAccessPoint.parameters.push(
|
newAccessPoint.parameters.push(
|
||||||
new ethereum.EventParam(
|
new ethereum.EventParam(
|
||||||
|
|
@ -211,14 +211,14 @@ export function createNewAccessPointEvent(
|
||||||
export function createNewChangeAccessPointCreationStatus(
|
export function createNewChangeAccessPointCreationStatus(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
apName: string,
|
apName: string,
|
||||||
tokenId: BigInt,
|
tokenId: bigint,
|
||||||
status: i32,
|
status: i32,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): ChangeAccessPointCreationStatus {
|
): ChangeAccessPointCreationStatus {
|
||||||
let changeAccessPointCreationStatus =
|
const changeAccessPointCreationStatus =
|
||||||
changetype<ChangeAccessPointCreationStatus>(newMockEvent());
|
changetype<ChangeAccessPointCreationStatus>(newMockEvent());
|
||||||
|
|
||||||
changeAccessPointCreationStatus.parameters = new Array();
|
changeAccessPointCreationStatus.parameters = [];
|
||||||
|
|
||||||
changeAccessPointCreationStatus.parameters.push(
|
changeAccessPointCreationStatus.parameters.push(
|
||||||
new ethereum.EventParam(
|
new ethereum.EventParam(
|
||||||
|
|
@ -254,15 +254,15 @@ export function createNewChangeAccessPointCreationStatus(
|
||||||
export function createNewChangeAccessPointNameVerify(
|
export function createNewChangeAccessPointNameVerify(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
apName: string,
|
apName: string,
|
||||||
tokenId: BigInt,
|
tokenId: bigint,
|
||||||
verified: boolean,
|
verified: boolean,
|
||||||
triggeredBy: Address
|
triggeredBy: Address
|
||||||
): ChangeAccessPointNameVerify {
|
): ChangeAccessPointNameVerify {
|
||||||
let changeAccessPointNameVerify = changetype<ChangeAccessPointNameVerify>(
|
const changeAccessPointNameVerify = changetype<ChangeAccessPointNameVerify>(
|
||||||
newMockEvent()
|
newMockEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
changeAccessPointNameVerify.parameters = new Array();
|
changeAccessPointNameVerify.parameters = [];
|
||||||
|
|
||||||
changeAccessPointNameVerify.parameters.push(
|
changeAccessPointNameVerify.parameters.push(
|
||||||
new ethereum.EventParam(
|
new ethereum.EventParam(
|
||||||
|
|
@ -297,15 +297,15 @@ export function createNewChangeAccessPointNameVerify(
|
||||||
|
|
||||||
export function createNewTokenRoleChanged(
|
export function createNewTokenRoleChanged(
|
||||||
event_count: i32,
|
event_count: i32,
|
||||||
tokenId: BigInt,
|
tokenId: bigint,
|
||||||
role: i32,
|
role: i32,
|
||||||
toAddress: Address,
|
toAddress: Address,
|
||||||
status: boolean,
|
status: boolean,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): TokenRoleChanged {
|
): TokenRoleChanged {
|
||||||
let tokenRoleChanged = changetype<TokenRoleChanged>(newMockEvent());
|
const tokenRoleChanged = changetype<TokenRoleChanged>(newMockEvent());
|
||||||
|
|
||||||
tokenRoleChanged.parameters = new Array();
|
tokenRoleChanged.parameters = [];
|
||||||
|
|
||||||
tokenRoleChanged.parameters.push(
|
tokenRoleChanged.parameters.push(
|
||||||
new ethereum.EventParam(
|
new ethereum.EventParam(
|
||||||
|
|
@ -343,9 +343,11 @@ export function createNewCollectionRoleChanged(
|
||||||
status: boolean,
|
status: boolean,
|
||||||
byAddress: Address
|
byAddress: Address
|
||||||
): CollectionRoleChanged {
|
): CollectionRoleChanged {
|
||||||
let collectionRoleChanged = changetype<CollectionRoleChanged>(newMockEvent());
|
const collectionRoleChanged = changetype<CollectionRoleChanged>(
|
||||||
|
newMockEvent()
|
||||||
|
);
|
||||||
|
|
||||||
collectionRoleChanged.parameters = new Array();
|
collectionRoleChanged.parameters = [];
|
||||||
|
|
||||||
collectionRoleChanged.parameters.push(
|
collectionRoleChanged.parameters.push(
|
||||||
new ethereum.EventParam('role', ethereum.Value.fromI32(role))
|
new ethereum.EventParam('role', ethereum.Value.fromI32(role))
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import {
|
||||||
clearStore,
|
clearStore,
|
||||||
beforeAll,
|
beforeAll,
|
||||||
afterAll,
|
afterAll,
|
||||||
logStore,
|
|
||||||
log,
|
|
||||||
} from 'matchstick-as/assembly/index';
|
} from 'matchstick-as/assembly/index';
|
||||||
import { BigInt } from '@graphprotocol/graph-ts';
|
import { BigInt } from '@graphprotocol/graph-ts';
|
||||||
import {
|
import {
|
||||||
|
|
@ -24,7 +22,7 @@ import { NewMint, Transfer } from '../../generated/FleekNFA/FleekNFA';
|
||||||
describe('Owner tests', () => {
|
describe('Owner tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
// NEW MINTS
|
// NEW MINTS
|
||||||
let newMints: NewMint[] = [];
|
const newMints: NewMint[] = [];
|
||||||
newMints.push(createNewMintEvent(0, USER_ONE, BigInt.fromI32(0)));
|
newMints.push(createNewMintEvent(0, USER_ONE, BigInt.fromI32(0)));
|
||||||
newMints.push(createNewMintEvent(1, USER_TWO, BigInt.fromI32(1)));
|
newMints.push(createNewMintEvent(1, USER_TWO, BigInt.fromI32(1)));
|
||||||
newMints.push(createNewMintEvent(2, USER_ONE, BigInt.fromI32(2)));
|
newMints.push(createNewMintEvent(2, USER_ONE, BigInt.fromI32(2)));
|
||||||
|
|
@ -32,7 +30,7 @@ describe('Owner tests', () => {
|
||||||
newMints.push(createNewMintEvent(4, USER_TWO, BigInt.fromI32(4)));
|
newMints.push(createNewMintEvent(4, USER_TWO, BigInt.fromI32(4)));
|
||||||
handleNewMints(newMints);
|
handleNewMints(newMints);
|
||||||
// TRANSFERS
|
// TRANSFERS
|
||||||
let transfers: Transfer[] = [];
|
const transfers: Transfer[] = [];
|
||||||
transfers.push(
|
transfers.push(
|
||||||
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@ import {
|
||||||
clearStore,
|
clearStore,
|
||||||
beforeAll,
|
beforeAll,
|
||||||
afterAll,
|
afterAll,
|
||||||
logStore,
|
|
||||||
log,
|
|
||||||
} from 'matchstick-as/assembly/index';
|
} from 'matchstick-as/assembly/index';
|
||||||
import { BigInt, Bytes } from '@graphprotocol/graph-ts';
|
import { BigInt } from '@graphprotocol/graph-ts';
|
||||||
import {
|
import {
|
||||||
CONTRACT,
|
CONTRACT,
|
||||||
createTransferEvent,
|
createTransferEvent,
|
||||||
|
|
@ -22,7 +20,7 @@ import { Transfer } from '../../generated/FleekNFA/FleekNFA';
|
||||||
describe('Transfer tests', () => {
|
describe('Transfer tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
// TRANSFERS
|
// TRANSFERS
|
||||||
let transfers: Transfer[] = [];
|
const transfers: Transfer[] = [];
|
||||||
transfers.push(
|
transfers.push(
|
||||||
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue