Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/tron-wallet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/internal-snaps.git"
},
"source": {
"shasum": "1pO58lSrPr77UAfnWKp2vkYda0BjiXybyYrG3SFy7u0=",
"shasum": "y1eBQiM9lDqVQ6wJj1BG3qtDXB45dwC7SdKzYF5YZWo=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const emptyAccountResources: AccountResources = {
* @param options - Fields to set on the controller asset.
* @param options.id - CAIP-19 asset ID.
* @param options.chainId - Chain ID. Defaults to Mainnet.
* @param options.amount - Raw balance amount.
* @param options.amount - UI balance amount (with decimals applied).
* @param options.symbol - Asset symbol.
* @param options.decimals - Asset decimals.
* @param options.image - Asset icon URL.
Expand All @@ -69,7 +69,7 @@ function createControllerAsset(options: {
const {
id,
chainId = Network.Mainnet,
amount = '1000000',
amount = '1',
symbol = 'TRX',
decimals = 6,
image = 'https://example.com/trx.png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('mapControllerAsset', () => {
const asset = {
id: unknownAssetId,
chainId: Network.Mainnet,
balance: { amount: '1234567' },
balance: { amount: '1.234567' },
metadata: {
type: 'fungible',
symbol: 'TKN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import type { Asset } from '@metamask/assets-controller';

import { Network } from '../../../constants';
import type { AssetEntity } from '../../../entities/assets';
import { toUiAmount } from '../../../utils/conversion';
import { toRawAmount } from '../../../utils/conversion';

/**
* Maps an AssetsController asset to the Snap's {@link AssetEntity} shape.
*
* The AssetsController returns balances in the asset's human-readable unit
* (i.e. with decimals already applied, e.g. TRX rather than Sun), so the
* source amount is used directly as the UI amount and the raw amount is
* derived from it.
*
* @param accountId - Keyring account ID.
* @param asset - Asset returned by AssetsController.
* @returns Mapped asset entity.
Expand All @@ -27,8 +32,8 @@ export function mapControllerAsset(
network: asset.chainId as Network,
symbol,
decimals,
rawAmount: amount,
uiAmount: toUiAmount(amount, decimals).toString(),
rawAmount: toRawAmount(amount, decimals),
uiAmount: amount,
iconUrl,
} as AssetEntity;
}