Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type AccountBalancesUpdatedEventPayload = {
[assetId: string]: {
amount: string;
unit: string;
metadata?: Record<string, Json>;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add metadata into snap balance update event payload type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want type enforced payloads?

E.g. a typed descriminated union?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we can enforce a schema for runtime validation & parsing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think in future
some snap may still using SNAP path to sync data, those data will not able to predict

adding validation may also adding a complexity on how snap ship data to controller

and it require bump up to controller when the data sharp change..., so i will suggest leave it as this (should align with keyring API)

};
};
};
Expand Down Expand Up @@ -292,6 +293,7 @@ export class SnapDataSource extends AbstractDataSource<
accountAssets ??= {};
accountAssets[assetId as Caip19AssetId] = {
amount: balance.amount,
...(balance.metadata ? { metadata: balance.metadata } : {}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when persist balance data via event, we persist metadata together if any

type AssetBalance already ready to store metadata

};
}
}
Expand Down Expand Up @@ -483,7 +485,7 @@ export class SnapDataSource extends AbstractDataSource<
}

// Step 2: Get balances for those specific assets
const balances: Record<CaipAssetType, Balance> =
const balances: Record<CaipAssetType, Balance & { metadata?: Json }> =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mock keyring type

await client.getAccountBalances(
accountId,
accountAssets as CaipAssetType[],
Expand All @@ -497,6 +499,7 @@ export class SnapDataSource extends AbstractDataSource<
if (accountBalances) {
(accountBalances as Record<string, unknown>)[assetId] = {
amount: balance.amount,
...(balance.metadata ? { metadata: balance.metadata } : {}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when persist balance data via keyring API get balance, we persist metadata together if any

};
}
}
Expand Down
Loading