Skip to content

Commit

Permalink
[vesting escrow fix] string to bytes (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-diamond authored Jun 13, 2024
1 parent a26e84b commit 5e1f272
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/entities/tokenTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigInt } from '@graphprotocol/graph-ts'
import { Address, BigInt } from '@graphprotocol/graph-ts'
import { TokenHolder, TokenTransfer } from '../../generated/schema'

export function createOrLoadTokenHolder(tokenSymbol: string, tokenHolderAddress: string): TokenHolder {
const id = `${tokenSymbol}-${tokenHolderAddress}`
export function createOrLoadTokenHolder(tokenSymbol: string, tokenHolderAddress: Address): TokenHolder {
const id = `${tokenSymbol}-${tokenHolderAddress.toHex()}`

let token = TokenHolder.load(id)

Expand All @@ -20,8 +20,8 @@ export function createOrLoadTokenHolder(tokenSymbol: string, tokenHolderAddress:

export function createTokenTransfer(
id: string,
from: string,
to: string,
from: Address,
to: Address,
amount: BigInt,
timestamp: BigInt,
tokenSymbol: string,
Expand Down
16 changes: 6 additions & 10 deletions src/entities/vestingEscrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@ import { log } from '@graphprotocol/graph-ts'
import { VestingEscrow } from '../../generated/schema'
import { VestingEscrowCreated } from '../../generated/VestingEscrowFactory/VestingEscrowFactory'


export function createVestingEscrow(event: VestingEscrowCreated): void {
const vestingEscrowAddress = event.params.escrow
const vestingEscrowAddressHex = vestingEscrowAddress.toHex()
const token = event.params.token.toHex()
const recipient = event.params.recipient.toHex()
const recipient = event.params.recipient

const vestingEscrow = new VestingEscrow(vestingEscrowAddressHex)

vestingEscrow.token = token
vestingEscrow.recipient = recipient
vestingEscrow.save()

log.info(
'[VestingEscrowFactory] VestingEscrowCreated address={} token={} recipient={}',
[
vestingEscrowAddressHex,
token,
recipient,
],
)
log.info('[VestingEscrowFactory] VestingEscrowCreated address={} token={} recipient={}', [
vestingEscrowAddressHex,
token,
recipient.toHex(),
])
}
4 changes: 2 additions & 2 deletions src/mappings/osToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function handleTransfer(event: Transfer): void {

createTokenTransfer(
event.transaction.hash.toHex(),
event.params.from.toHexString(),
event.params.to.toHexString(),
event.params.from,
event.params.to,
event.params.value,
event.block.timestamp,
'osETH',
Expand Down
5 changes: 2 additions & 3 deletions src/mappings/swiseToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { log } from '@graphprotocol/graph-ts'
import { Transfer } from '../../generated/Erc20Token/Erc20Token'
import { createTokenTransfer } from '../entities/tokenTransfer'


export function handleTransfer(event: Transfer): void {
createTokenTransfer(
event.transaction.hash.toHex(),
event.params.from.toHexString(),
event.params.to.toHexString(),
event.params.from,
event.params.to,
event.params.value,
event.block.timestamp,
'SWISE',
Expand Down
8 changes: 4 additions & 4 deletions src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ type TokenTransfer @entity {
tokenSymbol: String!

"The transfer sender"
from: String!
from: Bytes!

"The transfer receiver"
to: String!
to: Bytes!

"The transfer timestamp"
timestamp: BigInt!
Expand All @@ -80,7 +80,7 @@ type TokenHolder @entity {
tokenSymbol: String!

"The token holder address"
address: String!
address: Bytes!

"The total number of token transfers"
transfersCount: BigInt!
Expand Down Expand Up @@ -584,5 +584,5 @@ type VestingEscrow @entity {
token: String!

"The vesting escrow recipient"
recipient: String!
recipient: Bytes!
}

0 comments on commit 5e1f272

Please sign in to comment.