Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lima committed Oct 20, 2023
1 parent 3789a53 commit c10fb93
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/erc7432/role/grant-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ export function handleRoleGranted(event: RoleGranted): void {

const granteeAccount = findOrCreateAccount(event.params._grantee.toHex())
const roleAssignment = findOrCreateRoleAssignment(event, grantorAccount, granteeAccount, nft)
log.warning('[handleRoleGranted] roleAssignment: {} NFT: {} Tx: {}', [roleAssignment.id, nftId, event.transaction.hash.toHex()])
log.warning('[handleRoleGranted] roleAssignment: {} NFT: {} Tx: {}', [
roleAssignment.id,
nftId,
event.transaction.hash.toHex(),
])
}
6 changes: 5 additions & 1 deletion src/erc7432/role/revoke-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ export function handleRoleRevoked(event: RoleRevoked): void {

roleassignment.expirationDate = event.block.timestamp
roleassignment.save()
log.warning('[handleRoleRevoked] Revoked RoleAssignment: {} NFT: {} Tx: {}', [roleAssignmentId, nftId, event.transaction.hash.toHex()])
log.warning('[handleRoleRevoked] Revoked RoleAssignment: {} NFT: {} Tx: {}', [
roleAssignmentId,
nftId,
event.transaction.hash.toHex(),
])
}
10 changes: 7 additions & 3 deletions src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export function generateRoleAssignmentId(grantor: Account, grantee: Account, nft
return grantor.id + '-' + grantee.id + '-' + nft.id + '-' + roleAssignment.toHex()
}

export function findOrCreateRoleAssignment(event: RoleGranted, grantor: Account, grantee: Account, nft: Nft): RoleAssignment {
export function findOrCreateRoleAssignment(
event: RoleGranted,
grantor: Account,
grantee: Account,
nft: Nft,
): RoleAssignment {
const roleAssignmentId = generateRoleAssignmentId(grantor, grantee, nft, event.params._role)
let roleAssignment = RoleAssignment.load(roleAssignmentId)

Expand All @@ -50,10 +55,9 @@ export function findOrCreateRoleAssignment(event: RoleGranted, grantor: Account,
}

export function findOrCreateRole(nft: Nft, roleHash: Bytes): Role {

let role = Role.load(generateRoleId(nft, roleHash))

if(!role) {
if (!role) {
role = new Role(generateRoleId(nft, roleHash))
role.roleHash = roleHash
role.save()
Expand Down
8 changes: 7 additions & 1 deletion tests/helpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export function createMockAccount(ethAddress: string): Account {
return account
}

export function createMockRoleAssignment(roleHash: Bytes, grantor: string, grantee: string, nft: Nft, expirationDate: BigInt): RoleAssignment {
export function createMockRoleAssignment(
roleHash: Bytes,
grantor: string,
grantee: string,
nft: Nft,
expirationDate: BigInt,
): RoleAssignment {
const roleAssignmentId = generateRoleAssignmentId(new Account(grantor), new Account(grantee), nft, roleHash)
const newRoleAssignment = new RoleAssignment(roleAssignmentId)
newRoleAssignment.role = `${nft.id}-${roleHash.toHex()}`
Expand Down
7 changes: 6 additions & 1 deletion tests/helpers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export function createTransferEvent(from: string, to: string, tokenId: string, a
return event
}

export function createNewRoleRevokedEvent(roleassignment: Bytes, nft: Nft, revoker: string, grantee: string): RoleRevoked {
export function createNewRoleRevokedEvent(
roleassignment: Bytes,
nft: Nft,
revoker: string,
grantee: string,
): RoleRevoked {
const event = changetype<RoleRevoked>(newMockEvent())
event.parameters = new Array<ethereum.EventParam>()
event.parameters.push(buildEventParamBytes('_role', roleassignment))
Expand Down

0 comments on commit c10fb93

Please sign in to comment.