@avalabs/evm-module 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +7 -5
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +18 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/handlers/get-address/get-address.ts +26 -0
- package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.test.ts +3 -4
- package/src/handlers/get-balances/evm-balance-service/get-erc20-balances.ts +13 -17
- package/src/handlers/get-balances/evm-balance-service/get-native-token-balances.test.ts +4 -5
- package/src/handlers/get-balances/evm-balance-service/get-native-token-balances.ts +7 -10
- package/src/handlers/get-balances/get-balances.test.ts +10 -11
- package/src/handlers/get-balances/get-balances.ts +5 -3
- package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.test.ts +1 -2
- package/src/handlers/get-balances/glacier-balance-service/get-erc20-balances.ts +10 -13
- package/src/handlers/get-balances/glacier-balance-service/get-native-token-balances.test.ts +2 -3
- package/src/handlers/get-balances/glacier-balance-service/get-native-token-balances.ts +10 -9
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-erc20.test.ts +53 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-erc20.ts +3 -5
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-normal.test.ts +57 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-normal.ts +3 -4
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-tokens.ts +5 -6
- package/src/module.ts +5 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { NormalTx } from '@avalabs/etherscan-sdk';
|
|
2
2
|
import { TokenType, TransactionType, type NetworkToken, type Transaction } from '@avalabs/vm-module-types';
|
|
3
|
-
import {
|
|
4
|
-
import { BN } from 'bn.js';
|
|
3
|
+
import { TokenUnit } from '@avalabs/utils-sdk';
|
|
5
4
|
import { getExplorerAddressByNetwork } from '../../utils/get-explorer-address-by-network';
|
|
6
5
|
|
|
7
6
|
export const convertTransactionNormal = ({
|
|
@@ -20,8 +19,8 @@ export const convertTransactionNormal = ({
|
|
|
20
19
|
const isSender = tx.from.toLowerCase() === address.toLowerCase();
|
|
21
20
|
const timestamp = parseInt(tx.timeStamp) * 1000;
|
|
22
21
|
const decimals = networkToken.decimals;
|
|
23
|
-
const
|
|
24
|
-
const amountDisplayValue =
|
|
22
|
+
const amount = new TokenUnit(tx.value, networkToken.decimals, networkToken.symbol);
|
|
23
|
+
const amountDisplayValue = amount.toDisplay();
|
|
25
24
|
const txType = isSender ? TransactionType.SEND : TransactionType.RECEIVE;
|
|
26
25
|
|
|
27
26
|
const { from, to, gasPrice, gasUsed, hash } = tx;
|
package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-tokens.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { TransactionDetails } from '@avalabs/glacier-sdk';
|
|
2
|
-
import {
|
|
3
|
-
import { BN } from 'bn.js';
|
|
2
|
+
import { TokenUnit } from '@avalabs/utils-sdk';
|
|
4
3
|
import type { TxToken, NetworkToken } from '@avalabs/vm-module-types';
|
|
5
4
|
import { TokenType } from '@avalabs/vm-module-types';
|
|
6
5
|
import { resolve } from '../../utils/resolve';
|
|
@@ -16,8 +15,8 @@ export const getTokens = async (
|
|
|
16
15
|
|
|
17
16
|
if (nativeTransaction.value !== '0') {
|
|
18
17
|
const decimal = networkToken.decimals;
|
|
19
|
-
const
|
|
20
|
-
const amountDisplayValue =
|
|
18
|
+
const amount = new TokenUnit(nativeTransaction.value, networkToken.decimals, networkToken.symbol);
|
|
19
|
+
const amountDisplayValue = amount.toDisplay();
|
|
21
20
|
result.push({
|
|
22
21
|
decimal: decimal.toString(),
|
|
23
22
|
name: networkToken.name,
|
|
@@ -31,8 +30,8 @@ export const getTokens = async (
|
|
|
31
30
|
|
|
32
31
|
erc20Transfers?.forEach((erc20Transfer) => {
|
|
33
32
|
const decimals = erc20Transfer.erc20Token.decimals;
|
|
34
|
-
const
|
|
35
|
-
const amountDisplayValue =
|
|
33
|
+
const amount = new TokenUnit(erc20Transfer.value, decimals, erc20Transfer.erc20Token.symbol);
|
|
34
|
+
const amountDisplayValue = amount.toDisplay();
|
|
36
35
|
|
|
37
36
|
result.push({
|
|
38
37
|
decimal: decimals.toString(),
|
package/src/module.ts
CHANGED
|
@@ -9,6 +9,8 @@ import type {
|
|
|
9
9
|
ApprovalController,
|
|
10
10
|
GetBalancesParams,
|
|
11
11
|
GetBalancesResponse,
|
|
12
|
+
GetAddressParams,
|
|
13
|
+
GetAddressResponse,
|
|
12
14
|
} from '@avalabs/vm-module-types';
|
|
13
15
|
import { rpcErrors } from '@metamask/rpc-errors';
|
|
14
16
|
import { RpcMethod, parseManifest } from '@avalabs/vm-module-types';
|
|
@@ -22,6 +24,7 @@ import { getEnv } from './env';
|
|
|
22
24
|
import { EvmGlacierService } from './services/glacier-service/glacier-service';
|
|
23
25
|
import { ethSign } from './handlers/eth-sign/eth-sign';
|
|
24
26
|
import { forwardToRpcNode } from './handlers/forward-to-rpc-node/forward-to-rpc-node';
|
|
27
|
+
import { getAddress } from './handlers/get-address/get-address';
|
|
25
28
|
|
|
26
29
|
export class EvmModule implements Module {
|
|
27
30
|
#glacierService: EvmGlacierService;
|
|
@@ -41,8 +44,8 @@ export class EvmModule implements Module {
|
|
|
41
44
|
this.#approvalController = approvalController;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
getAddress(): Promise<
|
|
45
|
-
return
|
|
47
|
+
getAddress({ accountIndex, xpub, walletType }: GetAddressParams): Promise<GetAddressResponse> {
|
|
48
|
+
return getAddress({ accountIndex, xpub, walletType });
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
getBalances({
|