Skip to content

Commit

Permalink
Merge branch 'feature--role-assignments' into qa
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lima committed Oct 20, 2023
2 parents 077c190 + a4f0d30 commit 4243a03
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions abis/ERC7432.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"components": [
{
"internalType": "bytes32",
"name": "roleassignment",
"name": "role",
"type": "bytes32"
},
{
Expand Down Expand Up @@ -172,7 +172,7 @@
"components": [
{
"internalType": "bytes32",
"name": "roleassignment",
"name": "role",
"type": "bytes32"
},
{
Expand Down
4 changes: 2 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type Nft @entity {
id: ID! # tokenId + tokenAddress
address: String!
tokenAddress: String!
tokenId: BigInt!
owner: Account!
rolesHistory: [Role!] @derivedFrom(field: "nft")
roles: [Role!] @derivedFrom(field: "nft")
}

type Account @entity {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function findOrCreateAccount(id: string): Account {
export function createNft(id: string, contractAddress: string, tokenId: BigInt, owner: string): Nft {
const nft = new Nft(id)
nft.tokenId = tokenId
nft.address = contractAddress.toLowerCase()
nft.tokenAddress = contractAddress.toLowerCase()
nft.owner = owner.toLowerCase()
nft.save()
return nft
Expand Down
6 changes: 3 additions & 3 deletions tests/erc721/transfer-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ERC-721 Transfer Handler', () => {
assert.entityCount('Account', 1)

const _id = generateNftId(event.address.toHexString(), event.params.tokenId.toString())
assert.fieldEquals('Nft', _id, 'address', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenAddress', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenId', tokenId)
assert.fieldEquals('Nft', _id, 'owner', Addresses[1])
})
Expand All @@ -38,7 +38,7 @@ describe('ERC-721 Transfer Handler', () => {
assert.entityCount('Account', 2)

const _id = generateNftId(event.address.toHexString(), event.params.tokenId.toString())
assert.fieldEquals('Nft', _id, 'address', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenAddress', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenId', tokenId)
assert.fieldEquals('Nft', _id, 'owner', Addresses[2])
})
Expand All @@ -54,7 +54,7 @@ describe('ERC-721 Transfer Handler', () => {
assert.entityCount('Account', 2)

const _id = generateNftId(event.address.toHexString(), event.params.tokenId.toString())
assert.fieldEquals('Nft', _id, 'address', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenAddress', ZERO_ADDRESS)
assert.fieldEquals('Nft', _id, 'tokenId', tokenId)
assert.fieldEquals('Nft', _id, 'owner', Addresses[2])
})
Expand Down
2 changes: 1 addition & 1 deletion tests/erc7432/revoke-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('ERC-7432 RoleRevoked Handler', () => {

const nftId = generateNftId(tokenAddress, tokenId)
const nft = new Nft(nftId)
nft.address = tokenAddress
nft.tokenAddress = tokenAddress
nft.tokenId = BigInt.fromString(tokenId)
nft.owner = revoker

Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assert } from 'matchstick-as'

export function createMockNft(tokenAddress: string, tokenId: string, ownerAddress: string): Nft {
const nft = new Nft(generateNftId(tokenAddress, tokenId))
nft.address = tokenAddress
nft.tokenAddress = tokenAddress
nft.tokenId = BigInt.fromString(tokenId)

const nftOwner = createMockAccount(ownerAddress)
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function createNewRoleRevokedEvent(
const event = changetype<RoleRevoked>(newMockEvent())
event.parameters = new Array<ethereum.EventParam>()
event.parameters.push(buildEventParamBytes('_role', roleassignment))
event.parameters.push(buildEventParamAddress('_tokenAddress', nft.address))
event.parameters.push(buildEventParamAddress('_tokenAddress', nft.tokenAddress))
event.parameters.push(buildEventParamUint('_tokenId', nft.tokenId))
event.parameters.push(buildEventParamAddress('_revoker', revoker))
event.parameters.push(buildEventParamAddress('_grantee', grantee))
Expand Down

0 comments on commit 4243a03

Please sign in to comment.