Skip to content

Commit

Permalink
ON-453: fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
juo-dev committed Aug 23, 2023
1 parent 828711f commit 0fa287b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ generated/

#tests
tests/.latest.json
tests/.bin/

#subgrahp
#subgraph
subgraph.yaml
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# roles-subgraph
# Orium NFT Roles Subgraph

A set of subgraphs (one for each network) for Orium Network dapps
[![Discord](https://img.shields.io/discord/1009147970832322632?label=discord&logo=discord&logoColor=white)](https://discord.gg/NaNTgPK5rx)
[![Twitter Follow](https://img.shields.io/twitter/follow/oriumnetwork?label=Follow&style=social)](https://twitter.com/OriumNetwork)

Orium NFT Roles Subgraph is a subgraph for the Orium Roles Register Contracts.

## Get Started

```shell
npm ci
npm run test-goerli
```

## Generate Schema (goerli)

To generate schema for a subgraph in a different network, **goerli** just change the network parameter to the preference.

**goerli**

```shell
cp subgraph-goerli.yaml subgraph.yaml && graph codegen subgraph.yaml
```

## Build (mumbai/polygon)

To build a subgraph in a different network, **goerli**, just change the network parameter to the preference.

**goerli**

```shell
cp graph build subgraph.yaml
```

## Deploy subgraph (mumbai/polygon)

To deploy contract in a different network, **goerli** or **goerli**, just change the network parameter to the preference.

**goerli**

```shell
graph deploy --node https://api.thegraph.com/deploy/ orium-network/nft-roles-goerli
```
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "roles-subgraph",
"version": "1.0.0",
"author": "orium.network",
"license": "MIT",
"author": "@OriumNetwork",
"license": "CC0-1.0",
"description": "A set of subgraphs (one for each network) for Orium Network dapps",
"main": "index.js",
"directories": {
"test": "tests"
},
"scripts": {
"graph-auth": "graph auth --product hosted-service",
"codegen-goerli": "cp subgraph-goerli.yaml subgraph.yaml && graph codegen subgraph-goerli.yaml",
"build-goerli": "graph build subgraph-goerli.yaml",
"codegen-goerli": "cp subgraph-goerli.yaml subgraph.yaml && graph codegen subgraph.yaml",
"build-goerli": "graph build subgraph.yaml",
"deploy-goerli": "graph deploy --node https://api.thegraph.com/deploy/ orium-network/nft-roles-goerli",
"test-goerli": "cp subgraph-goerli.yaml subgraph.yaml && graph test goerli",
"lint": "npx eslint src/",
Expand Down
1 change: 0 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ import { BigInt } from '@graphprotocol/graph-ts'
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export const ONE_ETHER = BigInt.fromString('1000000000000000000')
export const ONE_HUNDRED_ETHER = BigInt.fromString('100000000000000000000')
export const MAX_EXPIRATION_DATE = BigInt.fromString('9999999999')
Binary file removed tests/.bin/goerli/chronos/traveler.wasm
Binary file not shown.
7 changes: 2 additions & 5 deletions tests/goerli/chronos/traveler.handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ import { assert, describe, test, newMockEvent, beforeEach, afterEach, clearStore
import { handleTravelerTransfer } from '../../../src/chronos/traveler/handler'
import { generateId } from '../../../src/utils/helper'
import { createNewTransferEvent } from '../../mocks/events'
import { createMockNft } from '../../mocks/entities'
import { ZERO_ADDRESS } from '../../../src/utils/constants'

const tokenId = '123'
const address1 = '0x1111111111111111111111111111111111111111'
const address2 = '0x2222222222222222222222222222222222222222'

describe('When entities no exists', () => {
beforeEach(() => {
createMockNft(tokenId)
})

afterEach(() => {
clearStore()
})
Expand All @@ -22,6 +17,8 @@ describe('When entities no exists', () => {
const event = createNewTransferEvent(address1, address2, tokenId, ZERO_ADDRESS)
const _id = generateId(event.params.tokenId.toString(), event.address.toHexString())

assert.entityCount('Nft', 0)

handleTravelerTransfer(event)

assert.fieldEquals('Nft', _id, 'address', ZERO_ADDRESS)
Expand Down
3 changes: 2 additions & 1 deletion tests/mocks/entities.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { BigInt } from '@graphprotocol/graph-ts'
import { Nft } from '../../generated/schema'
import { ZERO_ADDRESS } from '../../src/utils/constants'
import { generateId } from '../../src/utils/helper'

function createMockNft(tokenId: string): Nft {
const nft = new Nft('1')
const nft = new Nft(generateId(tokenId, ZERO_ADDRESS))
nft.address = ZERO_ADDRESS
nft.tokenId = BigInt.fromString(tokenId)
nft.currentOwner = ZERO_ADDRESS
Expand Down

0 comments on commit 0fa287b

Please sign in to comment.