Skip to content

Commit

Permalink
Fixed holey array
Browse files Browse the repository at this point in the history
  • Loading branch information
Data-Nexus committed Feb 10, 2024
1 parent 7eec947 commit d4054b0
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/utils/staticTokenDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,32 @@
import {
Address,
BigInt,
} from "@graphprotocol/graph-ts"

import { Address, BigInt } from '@graphprotocol/graph-ts'

// Initialize a Token Definition with the attributes
export class StaticTokenDefinition {
address : Address
address: Address
symbol: string
name: string
decimals: BigInt

// Initialize a Token Definition with its attributes
constructor(address: Address, symbol: string, name: string, decimals: BigInt) {
this.address = address
this.symbol = symbol
this.name = name
this.decimals = decimals
}

// Get all tokens with a static defintion
static getStaticDefinitions(): Array<StaticTokenDefinition> {
return new Array<StaticTokenDefinition>(6)
const staticDefinitions: Array<StaticTokenDefinition> = []
return staticDefinitions
}

// Helper for hardcoded tokens
static fromAddress(tokenAddress: Address) : StaticTokenDefinition | null {
static fromAddress(tokenAddress: Address): StaticTokenDefinition | null {
const staticDefinitions = this.getStaticDefinitions()
const tokenAddressHex = tokenAddress.toHexString()

// Search the definition using the address
for (let i = 0; i < staticDefinitions.length; i++) {
const def = staticDefinitions[i]
if(def.address.toHexString() == tokenAddressHex) {
if (def.address.toHexString() == tokenAddressHex) {
return def
}
}

// If not found, return null
return null
}

}
}

0 comments on commit d4054b0

Please sign in to comment.