Skip to content

Commit

Permalink
fix: indent space
Browse files Browse the repository at this point in the history
  • Loading branch information
vibhurajeev committed Feb 22, 2022
1 parent 06b02d8 commit 1873607
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 54 deletions.
98 changes: 49 additions & 49 deletions child/src/mappings/child-erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,67 @@ import { TransactionEntity, GlobalTransferCounter } from '../../generated/schema
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

function getGlobalTransferCounter(): GlobalTransferCounter {
// Only one entry will be kept in this entity
let id = 'global-transfer-counter'
let entity = GlobalTransferCounter.load(id)
if (entity === null) {
entity = new GlobalTransferCounter(id)
entity.current = BigInt.fromI32(0)
}
return entity as GlobalTransferCounter
// Only one entry will be kept in this entity
let id = 'global-transfer-counter'
let entity = GlobalTransferCounter.load(id)
if (entity === null) {
entity = new GlobalTransferCounter(id)
entity.current = BigInt.fromI32(0)
}
return entity as GlobalTransferCounter
}

export function handleSingleTransfer(event: TransferSingle): void {

// Try to get what's current global counter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
let updated = counter.current.plus(BigInt.fromI32(1))
// Try to get what's current global counter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
let updated = counter.current.plus(BigInt.fromI32(1))

// Updating global counter's state
counter.current = updated
counter.save()
// Updating global counter's state
counter.current = updated
counter.save()

const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false
const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false

let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
transactionEntity.to = event.params.to
transactionEntity.amount = event.params.value
transactionEntity.tokenId = event.params.id
transactionEntity.block = event.block.number
transactionEntity.timestamp = event.block.timestamp
transactionEntity.transaction = event.transaction.hash
transactionEntity.token = event.address
transactionEntity.tokenType = 'ERC1155'
transactionEntity.isPos = true
transactionEntity.save()
let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
transactionEntity.to = event.params.to
transactionEntity.amount = event.params.value
transactionEntity.tokenId = event.params.id
transactionEntity.block = event.block.number
transactionEntity.timestamp = event.block.timestamp
transactionEntity.transaction = event.transaction.hash
transactionEntity.token = event.address
transactionEntity.tokenType = 'ERC1155'
transactionEntity.isPos = true
transactionEntity.save()
}

export function handleBatchTransfer(event: TransferBatch): void {
// Try to get what's current global counter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
let updated = counter.current.plus(BigInt.fromI32(1))
// Try to get what's current global counter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
let updated = counter.current.plus(BigInt.fromI32(1))

// Updating global counter's state
counter.current = updated
counter.save()
// Updating global counter's state
counter.current = updated
counter.save()

const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false
const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false

let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))

transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
transactionEntity.to = event.params.to
transactionEntity.amounts = event.params.values
transactionEntity.tokenIds = event.params.ids
transactionEntity.timestamp = event.block.timestamp
transactionEntity.transaction = event.transaction.hash
transactionEntity.token = event.address
transactionEntity.tokenType = 'ERC1155'
transactionEntity.isPos = true
transactionEntity.save()
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
transactionEntity.to = event.params.to
transactionEntity.amounts = event.params.values
transactionEntity.tokenIds = event.params.ids
transactionEntity.timestamp = event.block.timestamp
transactionEntity.transaction = event.transaction.hash
transactionEntity.token = event.address
transactionEntity.tokenType = 'ERC1155'
transactionEntity.isPos = true
transactionEntity.save()
}
5 changes: 2 additions & 3 deletions child/src/mappings/child-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function handleLogTransfer(event: LogTransfer): void {

export function handleWithdraw(event: Withdraw): void {

// Try to get what's current globalcounter's state
// Try to get what's current globalcounter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
let updated = counter.current.plus(BigInt.fromI32(1))
Expand All @@ -60,7 +60,6 @@ export function handleWithdraw(event: Withdraw): void {
}

export function handleTransfer(event: Transfer): void {

// Try to get what's current global counter's state
// when called for very first time, it'll be `0`
let counter = getGlobalTransferCounter()
Expand All @@ -71,7 +70,7 @@ export function handleTransfer(event: Transfer): void {
counter.save()

const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false

let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
Expand Down
4 changes: 2 additions & 2 deletions child/src/mappings/child-erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function handleTransfer(event: Transfer): void {

const isWithdraw = event.params.to.toHex() === ZERO_ADDRESS || event.params.to === event.address ? true : false

let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
let transactionEntity = new TransactionEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString() + (isWithdraw ? '-withdraw' : '-transfer'))
transactionEntity.type = isWithdraw ? 'withdraw' : 'transfer'
transactionEntity.from = event.params.from
transactionEntity.to = event.params.to
transactionEntity.tokenId = event.params.tokenId
Expand Down

0 comments on commit 1873607

Please sign in to comment.