@exodus/ethereum-lib 4.8.1 → 4.9.0

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-lib",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -60,5 +60,5 @@
60
60
  "@exodus/bnbmainnet-meta": "^1.0.0",
61
61
  "@exodus/elliptic": "^6.5.4-precomputed"
62
62
  },
63
- "gitHead": "220c00b21c6bf4d250aea7a40d37ceebb1716979"
63
+ "gitHead": "9322a03c6b00b6dc765356309b3e8f1e1f27df41"
64
64
  }
@@ -1,10 +1,9 @@
1
1
  import { AccountState } from '@exodus/models'
2
2
 
3
3
  import { parseLegacyBalances } from './parse-legacy-balances'
4
- import getAssetStakingData from './staking-data'
5
4
 
6
5
  // `assets` are only needed for chains that may need legacy parsing and staking support
7
- export default function createEthereumLikeAccountState({ asset, assets = {} }) {
6
+ export default function createEthereumLikeAccountState({ asset, extraData = {}, assets = {} }) {
8
7
  return class EthereumLikeAccountState extends AccountState {
9
8
  static defaults = {
10
9
  startblock: 0, // deprecated. It seems not used anymore. Remove when it's safe
@@ -12,7 +11,7 @@ export default function createEthereumLikeAccountState({ asset, assets = {} }) {
12
11
  balance: asset.currency.ZERO,
13
12
  tokenBalances: {},
14
13
  index: 0,
15
- ...getAssetStakingData({ assetName: asset.name, assets }),
14
+ ...extraData,
16
15
  }
17
16
 
18
17
  // legacy -- this should have no effect on Ethereum-like assets that do not have legacy account state
@@ -1,56 +1,13 @@
1
- const ethStakeAccountState = ({ currency }) => ({
2
- isDelegating: false,
3
- isUndelegateInProgress: false,
4
- canClaimUndelegatedBalance: false,
5
- minDelegateAmount: currency.defaultUnit(0.1),
6
- delegatedBalance: currency.ZERO,
7
- rewardsBalance: currency.ZERO,
8
- unclaimedUndelegatedBalance: currency.ZERO,
9
- totalRewardsReceived: currency.ZERO,
10
- lastStakingTxProcessed: '',
11
- })
12
-
13
- const assetStakingData = {
14
- polygon: ({ currency }) => ({
1
+ export const ethStakeAccountState = ({ currency }) => {
2
+ return {
15
3
  isDelegating: false,
16
- // Unstaking takes ~3-4 days, after that, user needs to
17
- // claim the unstaked amount (initial staked amount)
18
4
  isUndelegateInProgress: false,
19
5
  canClaimUndelegatedBalance: false,
20
- minRewardsToWithdraw: currency.defaultUnit(1),
21
- minDelegateAmount: currency.defaultUnit(1),
22
- unclaimedUndelegatedBalance: currency.ZERO,
6
+ minDelegateAmount: currency.defaultUnit(0.1),
23
7
  delegatedBalance: currency.ZERO,
24
8
  rewardsBalance: currency.ZERO,
25
- withdrawable: currency.ZERO,
26
- unbondNonce: '0',
27
- }),
28
- ethereum: ethStakeAccountState,
29
- ethereumgoerli: ethStakeAccountState,
30
- ethereumholesky: ethStakeAccountState,
31
- }
32
-
33
- const getAssetStakingData = ({ assetName, assets }) => {
34
- const stakingAssetsForAsset = {
35
- ethereum: ['ethereum', 'polygon'],
36
- ethereumgoerli: ['ethereumgoerli'],
37
- ethereumholesky: ['ethereumholesky'],
9
+ unclaimedUndelegatedBalance: currency.ZERO,
10
+ totalRewardsReceived: currency.ZERO,
11
+ lastStakingTxProcessed: '',
38
12
  }
39
-
40
- const stakingAssetsNames = stakingAssetsForAsset[assetName]
41
-
42
- if (!stakingAssetsNames) return {}
43
-
44
- const stakingData = stakingAssetsNames.reduce((allStakingData, stakeAssetName) => {
45
- const { currency } = assets[stakeAssetName]
46
- const assetStakeData = assetStakingData[stakeAssetName]({
47
- currency,
48
- })
49
- allStakingData[stakeAssetName] = assetStakeData
50
- return allStakingData
51
- }, {})
52
-
53
- return { staking: stakingData }
54
13
  }
55
-
56
- export default getAssetStakingData
package/src/index.js CHANGED
@@ -12,3 +12,4 @@ export { default as createEthereumLikeAccountState } from './account-state'
12
12
  export { default as createContract } from './create-contract'
13
13
  export * as feeData from './fee-data'
14
14
  export { default as ABI } from './abi'
15
+ export { ethStakeAccountState } from './account-state/staking-data'
@@ -81,6 +81,7 @@ export async function signMessageWithSigner({ message, signer }) {
81
81
  data: msgHash,
82
82
  ecOptions: { canonical: true },
83
83
  enc: 'raw',
84
+ signatureType: 'ecdsa',
84
85
  })
85
86
 
86
87
  return hex0xStringToBuffer(
@@ -13,8 +13,8 @@ export async function signUnsignedTxWithSigner(unsignedTx, signer) {
13
13
  const ethSigner = async (data) => {
14
14
  // temporarily support both function and object
15
15
  const sig = await (typeof signer === 'function'
16
- ? signer({ data, ecOptions: { canonical: true }, enc: 'raw' })
17
- : signer.sign({ data, ecOptions: { canonical: true }, enc: 'raw' }))
16
+ ? signer({ data, ecOptions: { canonical: true }, enc: 'raw', signatureType: 'ecdsa' })
17
+ : signer.sign({ data, ecOptions: { canonical: true }, enc: 'raw', signatureType: 'ecdsa' }))
18
18
  const signature = new Uint8Array(64)
19
19
  signature.set(sig.r.toArrayLike(Uint8Array, 'be', 32), 0)
20
20
  signature.set(sig.s.toArrayLike(Uint8Array, 'be', 32), 32)