-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7eec947
commit d4054b0
Showing
1 changed file
with
8 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} | ||
} |