-
Notifications
You must be signed in to change notification settings - Fork 4
feat: solana balances #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ export enum BalanceDALIndex { | |
|
||
const accountKey = { | ||
get: (e: Balance) => e.account, | ||
length: EntityStorage.EthereumAddressLength, | ||
length: EntityStorage.AddressLength, | ||
} | ||
|
||
const blockchainKey = { | ||
|
@@ -49,7 +49,7 @@ const mapValueFn = async (value: any) => { | |
|
||
export function createBalanceDAL(path: string): BalanceStorage { | ||
return new EntityStorage<Balance>({ | ||
name: 'erc20_balance', | ||
name: 'balance', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we are storing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The snapshot taken is stored on the snapshot dal |
||
path, | ||
key: [blockchainKey, accountKey], | ||
indexes: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { EntityStorage } from '@aleph-indexer/core' | ||
|
||
export type TokenAccountStorage = EntityStorage<TokenAccount> | ||
|
||
export type TokenAccount = { | ||
address: string | ||
owner: string | ||
} | ||
|
||
const accountKey = { | ||
get: (e: TokenAccount) => e.address, | ||
length: EntityStorage.AddressLength, | ||
} | ||
|
||
export function createTokenAccounttDAL(path: string): TokenAccountStorage { | ||
return new EntityStorage<TokenAccount>({ | ||
name: 'account_mint', | ||
path, | ||
key: [accountKey], | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be still a ERC20Balance, as we have a Solana specific implementation down below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
balance query also can return solana balances from snapshot db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now where the problem in this discussion lies.
What you can do is make
Balance
a union of two types,ERC20Balance
andSolanaBalance
:This will allow you to keep all the relevant info for Solana-related balances, while not having to deal with undefined values for ERC20Balances. This style also comes in handy later, when you might want to filter balances based on which type they are.