@exodus/ethereum-api 7.0.14 → 7.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "7.0.14",
3
+ "version": "7.0.16",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  "@exodus/asset-lib": "^3.7.1",
18
18
  "@exodus/crypto": "^1.0.0-rc.0",
19
19
  "@exodus/currency": "^2.1.3",
20
- "@exodus/ethereum-lib": "^4.2.3",
20
+ "@exodus/ethereum-lib": "^4.2.5",
21
21
  "@exodus/ethereumjs-util": "^7.1.0-exodus.6",
22
22
  "@exodus/fetch": "^1.3.0-beta.4",
23
23
  "@exodus/simple-retry": "^0.0.6",
@@ -38,5 +38,5 @@
38
38
  "@exodus/assets-testing": "file:../../../__testing__",
39
39
  "@exodus/models": "^11.0.0"
40
40
  },
41
- "gitHead": "932d009fbd44833d111c7b73142f62e671623ab3"
41
+ "gitHead": "6fa73dbdd4ae4ff56f19a7a2854f439deaf99a13"
42
42
  }
package/src/ens/index.js CHANGED
@@ -40,7 +40,7 @@ function namehash(inputName) {
40
40
  // ENS only available on mainnet atm
41
41
  const ENS_REGISTRY_ADDRESS = ENS_REGISTRY_ADDRESSES['ethereum']
42
42
 
43
- const getResolverAddress = async (name: string, server: Object) =>
43
+ const getResolverAddress = async (name, server) =>
44
44
  server
45
45
  .ethCall({
46
46
  to: ENS_REGISTRY_ADDRESS,
@@ -48,7 +48,7 @@ const getResolverAddress = async (name: string, server: Object) =>
48
48
  })
49
49
  .then((result) => '0x' + result.slice(26))
50
50
 
51
- const resolveEnsName = async (name: string, server: Object) => {
51
+ const resolveEnsName = async (name, server) => {
52
52
  const resolverAddress = await getResolverAddress(name, server)
53
53
  const hex = await server.ethCall({
54
54
  to: resolverAddress,
@@ -57,7 +57,7 @@ const resolveEnsName = async (name: string, server: Object) => {
57
57
  return '0x' + hex.slice(26)
58
58
  }
59
59
 
60
- const resolveEnsAddress = async (address: string, server: Object) => {
60
+ const resolveEnsAddress = async (address, server) => {
61
61
  const name = `${address.slice(2)}.addr.reverse`
62
62
 
63
63
  const resolverAddress = await getResolverAddress(name, server)
@@ -0,0 +1,18 @@
1
+ import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
2
+ import { getServerByName } from '../exodus-eth-server'
3
+
4
+ const assetName = 'ethereumholesky'
5
+
6
+ // @deprecated use ./server-based-fee-monitor.js
7
+ export class EthereumHoleskyFeeMonitor extends EthereumLikeFeeMonitor {
8
+ constructor({ updateFee, interval }) {
9
+ const server = getServerByName(assetName)
10
+ const getGasPrice = (...args) => server.gasPrice(...args)
11
+ super({
12
+ updateFee,
13
+ assetName,
14
+ getGasPrice,
15
+ interval,
16
+ })
17
+ }
18
+ }
@@ -3,6 +3,7 @@ export * from './server-based-fee-monitor'
3
3
  export * from './ethereum'
4
4
  export * from './ethereumclassic'
5
5
  export * from './ethereumgoerli'
6
+ export * from './ethereumholesky'
6
7
  export * from './bsc'
7
8
  export * from './polygon'
8
9
  export * from './avalanchec'
@@ -15,14 +15,14 @@ export const DEFAULT_CONTRACT_GAS_LIMIT = 1e6
15
15
  // the gasEstimation will fail. If gasPrice is set to '0x0', the account's balance is not
16
16
  // used to estimate gas.
17
17
  export async function estimateGasLimit(
18
- asset: Object,
19
- fromAddress: string,
20
- toAddress: string,
21
- amount: Buffer | Object,
22
- data: Buffer | string,
23
- gasPrice?: string = '0x',
24
- extraPercentage?: number = EXTRA_PERCENTAGE
25
- ): Promise<number> {
18
+ asset,
19
+ fromAddress,
20
+ toAddress,
21
+ amount,
22
+ data,
23
+ gasPrice = '0x',
24
+ extraPercentage = EXTRA_PERCENTAGE
25
+ ) {
26
26
  const opts = {
27
27
  from: fromAddress,
28
28
  to: toAddress,
@@ -36,7 +36,7 @@ const getBalance = ({ asset, accountState, txLog }) => {
36
36
 
37
37
  const shouldFixBalance = isRpcBalanceAsset(asset)
38
38
 
39
- if (['ethereum', 'ethereumgoerli'].includes(asset.name)) {
39
+ if (['ethereum', 'ethereumgoerli', 'ethereumholesky'].includes(asset.name)) {
40
40
  const { balance: ethereumBalance } = getEthereumBalances({
41
41
  asset,
42
42
  liquidBalance: balance,
@@ -16,6 +16,10 @@ export class EthereumStaking {
16
16
  EVERSTAKE_ADDRESS_CONTRACT_ACCOUNTING: '0x6e95818C2Dde3d87406F5C5d0A759d9372053a94',
17
17
  EVERSTAKE_ADDRESS_CONTRACT_POOL: '0x1F28aD3B3e26192a09c1248D4092c692c32f8Ec0',
18
18
  },
19
+ ethereumholesky: {
20
+ EVERSTAKE_ADDRESS_CONTRACT_ACCOUNTING: '0x624087DD1904ab122A32878Ce9e933C7071F53B9',
21
+ EVERSTAKE_ADDRESS_CONTRACT_POOL: '0xAFA848357154a6a624686b348303EF9a13F63264',
22
+ },
19
23
  }
20
24
  static METHODS_IDS = {
21
25
  DELEGATE: '0x3a29dbae', // stake(uint256 source)
@@ -25,7 +29,7 @@ export class EthereumStaking {
25
29
  }
26
30
 
27
31
  constructor(
28
- asset, // ethereum or ethereumgoerli for testnet
32
+ asset, // ethereum or ethereumholesky for testnet
29
33
  minAmount = MIN_AMOUNT
30
34
  ) {
31
35
  this.asset = asset
@@ -9,9 +9,10 @@ export function createEthereumStakingService({
9
9
  asset,
10
10
  assetClientInterface,
11
11
  createAndBroadcastTX,
12
+ telemetryId,
12
13
  }) {
13
14
  const staking = new EthereumStaking(asset)
14
- const stakingProvider = stakingProviderClientFactory()
15
+ const stakingProvider = stakingProviderClientFactory({ telemetryId })
15
16
 
16
17
  function amountToCurrency({ asset, amount }) {
17
18
  return isNumberUnit(amount) ? amount : asset.currency.parse(amount)
@@ -5,10 +5,11 @@ const { DELEGATE, UNSTAKE, UNSTAKE_PENDING, CLAIM_UNSTAKE } = EthereumStaking.ME
5
5
  const STAKING_MANAGER_CONTRACTS = [
6
6
  EthereumStaking.addresses.ethereum.EVERSTAKE_ADDRESS_CONTRACT_POOL.toLowerCase(),
7
7
  EthereumStaking.addresses.ethereumgoerli.EVERSTAKE_ADDRESS_CONTRACT_POOL.toLowerCase(),
8
+ EthereumStaking.addresses.ethereumholesky.EVERSTAKE_ADDRESS_CONTRACT_POOL.toLowerCase(),
8
9
  ]
9
10
 
10
11
  export const isEthereumStakingTx = ({ coinName }) =>
11
- ['ethereum', 'ethereumgoerli'].includes(coinName)
12
+ ['ethereum', 'ethereumgoerli', 'ethereumholesky'].includes(coinName)
12
13
  export const isEthereumDelegate = (tx) =>
13
14
  isEthereumStakingTx(tx) &&
14
15
  STAKING_MANAGER_CONTRACTS.includes(tx.to) &&
@@ -5,10 +5,14 @@ import { MaticStakingApi } from './api'
5
5
  import { stakingProviderClientFactory } from '../staking-provider-client'
6
6
  import { isNumberUnit } from '@exodus/currency'
7
7
 
8
- export function createPolygonStakingService({ assetClientInterface, createAndBroadcastTX }) {
8
+ export function createPolygonStakingService({
9
+ assetClientInterface,
10
+ createAndBroadcastTX,
11
+ telemetryId,
12
+ }) {
9
13
  const stakingApi = new MaticStakingApi()
10
14
  const assetName = 'ethereum'
11
- const stakingProvider = stakingProviderClientFactory()
15
+ const stakingProvider = stakingProviderClientFactory({ telemetryId })
12
16
 
13
17
  async function getStakeAssets() {
14
18
  const { polygon: asset, ethereum: feeAsset } = await assetClientInterface.getAssetsForNetwork({
@@ -5,7 +5,10 @@ import ms from 'ms'
5
5
  const DEFAULT_STAKING_URL = 'https://staking.a.exodus.io'
6
6
  const HTTP_POST_TIMEOUT = ms('30s')
7
7
 
8
- export const stakingProviderClientFactory = (defaultStakingUrl = DEFAULT_STAKING_URL) => {
8
+ export const stakingProviderClientFactory = ({
9
+ defaultStakingUrl = DEFAULT_STAKING_URL,
10
+ telemetryId,
11
+ } = {}) => {
9
12
  assert(defaultStakingUrl, '"defaultStakingUrl" must be provided')
10
13
 
11
14
  let stakingUrl = new URL(defaultStakingUrl) // always should be an URL instance
@@ -20,8 +23,11 @@ export const stakingProviderClientFactory = (defaultStakingUrl = DEFAULT_STAKING
20
23
  }
21
24
 
22
25
  const stakingRequest = ({ asset, data }) => {
26
+ const headers = {}
27
+ if (telemetryId) headers.telemetryId = telemetryId
23
28
  return fetchival(stakingUrl, {
24
29
  timeout: HTTP_POST_TIMEOUT,
30
+ headers,
25
31
  })(asset)('stake').post(data)
26
32
  }
27
33
 
@@ -4,7 +4,6 @@ import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
4
4
  import { isEmpty } from 'lodash'
5
5
 
6
6
  import {
7
- type PendingTransactionsDictionary,
8
7
  getAllLogItemsByAsset,
9
8
  checkPendingTransactions,
10
9
  getDeriveTransactionsToCheck,
@@ -12,16 +11,6 @@ import {
12
11
  } from './monitor-utils'
13
12
  import { getLogItemsFromServerTx, getDeriveDataNeededForTick, filterEffects } from './clarity-utils'
14
13
 
15
- import { type Tx } from '@exodus/models'
16
-
17
- type DerivedData = {
18
- ourWalletAddress: string,
19
- currentAccountState: Object,
20
- unconfirmedTransactions: PendingTransactionsDictionary,
21
- pendingTransactionsGroupedByAddressAndNonce: PendingTransactionsDictionary,
22
- simulatedTransactions: any,
23
- }
24
-
25
14
  export class ClarityMonitor extends BaseMonitor {
26
15
  constructor({ server, config, ...args }) {
27
16
  super(args)
@@ -47,7 +36,7 @@ export class ClarityMonitor extends BaseMonitor {
47
36
  }
48
37
  }
49
38
 
50
- async deriveData({ assetName, walletAccount, tokens }: Object): DerivedData {
39
+ async deriveData({ assetName, walletAccount, tokens }) {
51
40
  const { ourWalletAddress, currentAccountState } = await this.deriveDataNeededForTick({
52
41
  assetName,
53
42
  walletAccount,
@@ -67,7 +56,7 @@ export class ClarityMonitor extends BaseMonitor {
67
56
  }
68
57
 
69
58
  // eslint-disable-next-line no-undef
70
- async checkPendingTransactions(params): { txsToRemove: { tx: Tx, assetSource: AssetSource }[] } {
59
+ async checkPendingTransactions(params) {
71
60
  const {
72
61
  pendingTransactionsToCheck,
73
62
  pendingTransactionsGroupedByAddressAndNonce,
@@ -1,10 +1,8 @@
1
- /* @flow */
2
1
  import BN from 'bn.js'
3
2
  import { getServer } from '@exodus/ethereum-api'
4
3
  import { isRpcBalanceAsset, getAssetAddresses } from '@exodus/ethereum-lib'
5
4
 
6
5
  import {
7
- type PendingTransactionsDictionary,
8
6
  checkPendingTransactions,
9
7
  getAllLogItemsByAsset,
10
8
  getLogItemsFromServerTx,
@@ -22,20 +20,8 @@ import {
22
20
 
23
21
  import { isEmpty } from 'lodash'
24
22
 
25
- import { type Tx } from '@exodus/models'
26
-
27
23
  import { BaseMonitor } from '@exodus/asset-lib'
28
24
 
29
- export type { AssetSource } from '@exodus/models/lib/types'
30
-
31
- type DerivedData = {
32
- ourWalletAddress: string,
33
- currentAccountState: Object,
34
- minimumConfirmations: number,
35
- unconfirmedTransactions: PendingTransactionsDictionary,
36
- pendingTransactionsGroupedByAddressAndNonce: PendingTransactionsDictionary,
37
- simulatedTransactions: any,
38
- }
39
25
  // The base ethereum monitor class handles listening for, fetching,
40
26
  // formatting, and populating-to-state all ETH/ETC/ERC20 transactions.
41
27
 
@@ -60,7 +46,7 @@ export class EthereumMonitor extends BaseMonitor {
60
46
  }
61
47
  }
62
48
 
63
- async deriveData({ assetSource, tokens }: Object): DerivedData {
49
+ async deriveData({ assetSource, tokens }) {
64
50
  const { asset: assetName, walletAccount } = assetSource
65
51
 
66
52
  const {
@@ -84,7 +70,7 @@ export class EthereumMonitor extends BaseMonitor {
84
70
  }
85
71
 
86
72
  // eslint-disable-next-line no-undef
87
- async checkPendingTransactions(params): { txsToRemove: { tx: Tx, assetSource: AssetSource }[] } {
73
+ async checkPendingTransactions(params) {
88
74
  const {
89
75
  pendingTransactionsToCheck,
90
76
  pendingTransactionsGroupedByAddressAndNonce,
@@ -1,7 +1,5 @@
1
- // @flow
2
1
  import getSenderNonceKey from './get-sender-nonce-key'
3
2
  import getFeeAmount from './get-fee-amount'
4
- import type { PendingTransactionsDictionary } from './types'
5
3
 
6
4
  export default function checkPendingTransactions({
7
5
  pendingTransactionsGroupedByAddressAndNonce = {},
@@ -9,13 +7,7 @@ export default function checkPendingTransactions({
9
7
  txlist,
10
8
  ourWalletAddress,
11
9
  asset,
12
- }: {
13
- pendingTransactionsGroupedByAddressAndNonce: PendingTransactionsDictionary,
14
- pendingTransactionsToCheck: PendingTransactionsDictionary,
15
- txlist: Array<Object>,
16
- ourWalletAddress: string,
17
- asset: Object,
18
- }): PendingTransactionsDictionary {
10
+ }) {
19
11
  for (const tx of txlist) {
20
12
  delete pendingTransactionsToCheck[tx.txId || tx.hash] // Found this transaction, do not mark it as dropped
21
13
 
@@ -1,4 +1,4 @@
1
- export default function getSenderNonceKey(tx, ourWalletAddress): string {
1
+ export default function getSenderNonceKey(tx, ourWalletAddress) {
2
2
  if (Array.isArray(tx.from)) {
3
3
  // Tx class. we don't define the 'from' address if our wallet was the sender.
4
4
  const from = tx.from[0] || ourWalletAddress
@@ -6,5 +6,3 @@ export { default as getHistoryFromServer } from './get-history-from-server'
6
6
  export { default as checkPendingTransactions } from './check-pending-transactions'
7
7
  export { default as getDeriveTransactionsToCheck } from './get-derive-transactions-to-check'
8
8
  export * from './exclude-unchanged-token-balances'
9
-
10
- export type { PendingTransactionsDictionary } from './types'
@@ -1,11 +0,0 @@
1
- import type { Tx } from '@exodus/models'
2
-
3
- export type PendingTransactionsDictionary =
4
- | {
5
- [string]: {
6
- tx: Tx,
7
- replaced?: boolean,
8
- assetName: string,
9
- },
10
- }
11
- | {}