@ledgerhq/coin-evm 5.2.1 → 5.3.2
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/.oxlintrc.json +2 -12
- package/CHANGELOG.md +29 -0
- package/lib/adapters/blockOperations.d.ts +2 -2
- package/lib/adapters/blockOperations.d.ts.map +1 -1
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/logic/combine.d.ts +2 -1
- package/lib/logic/combine.d.ts.map +1 -1
- package/lib/logic/combine.js.map +1 -1
- package/lib/logic/common.d.ts +2 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/craftTransactionData.d.ts +1 -1
- package/lib/logic/craftTransactionData.d.ts.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +19 -13
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getStakes.d.ts +2 -2
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +6 -3
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +3 -0
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +4 -4
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +8 -4
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/index.d.ts +2 -2
- package/lib/network/explorer/index.d.ts.map +1 -1
- package/lib/network/explorer/index.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts +2 -2
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/none.d.ts +1 -1
- package/lib/network/explorer/none.d.ts.map +1 -1
- package/lib/network/explorer/none.js.map +1 -1
- package/lib/network/explorer/types.d.ts +1 -1
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/gasTracker/index.d.ts +2 -2
- package/lib/network/gasTracker/index.d.ts.map +1 -1
- package/lib/network/gasTracker/index.js.map +1 -1
- package/lib/network/gasTracker/ledger.d.ts +3 -3
- package/lib/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib/network/gasTracker/ledger.js.map +1 -1
- package/lib/network/gasTracker/types.d.ts +2 -2
- package/lib/network/gasTracker/types.d.ts.map +1 -1
- package/lib/network/node/ledger.d.ts +2 -2
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -3
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +1 -0
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -4
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +42 -3
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +2 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/assets.d.ts +1 -1
- package/lib/types/assets.d.ts.map +1 -1
- package/lib/types/staking.d.ts +3 -2
- package/lib/types/staking.d.ts.map +1 -1
- package/lib/types/transaction.d.ts +1 -1
- package/lib/types/transaction.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.d.ts +2 -2
- package/lib-es/adapters/blockOperations.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/logic/combine.d.ts +2 -1
- package/lib-es/logic/combine.d.ts.map +1 -1
- package/lib-es/logic/combine.js.map +1 -1
- package/lib-es/logic/common.d.ts +2 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +1 -1
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/craftTransactionData.d.ts +1 -1
- package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +19 -13
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts +2 -2
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +6 -3
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +3 -0
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +4 -4
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +8 -4
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/index.d.ts +2 -2
- package/lib-es/network/explorer/index.d.ts.map +1 -1
- package/lib-es/network/explorer/index.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts +2 -2
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/none.d.ts +1 -1
- package/lib-es/network/explorer/none.d.ts.map +1 -1
- package/lib-es/network/explorer/none.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +1 -1
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/gasTracker/index.d.ts +2 -2
- package/lib-es/network/gasTracker/index.d.ts.map +1 -1
- package/lib-es/network/gasTracker/index.js.map +1 -1
- package/lib-es/network/gasTracker/ledger.d.ts +3 -3
- package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib-es/network/gasTracker/ledger.js +1 -1
- package/lib-es/network/gasTracker/ledger.js.map +1 -1
- package/lib-es/network/gasTracker/types.d.ts +2 -2
- package/lib-es/network/gasTracker/types.d.ts.map +1 -1
- package/lib-es/network/node/ledger.d.ts +2 -2
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +1 -1
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -3
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +2 -1
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -4
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +40 -2
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +2 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/assets.d.ts +1 -1
- package/lib-es/types/assets.d.ts.map +1 -1
- package/lib-es/types/staking.d.ts +3 -2
- package/lib-es/types/staking.d.ts.map +1 -1
- package/lib-es/types/transaction.d.ts +1 -1
- package/lib-es/types/transaction.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/blockOperations.test.ts +2 -2
- package/src/adapters/blockOperations.ts +3 -2
- package/src/adapters/etherscan.test.ts +7 -7
- package/src/adapters/ledger.test.ts +2 -2
- package/src/api/getBlock.integ.test.ts +1 -1
- package/src/api/index.fantom.integ.test.ts +1 -1
- package/src/api/index.flare.integ.test.ts +1 -1
- package/src/api/index.integ.test.ts +265 -153
- package/src/api/index.linea.integ.test.ts +1 -1
- package/src/api/index.optimism.integ.test.ts +1 -1
- package/src/api/index.shape.integ.test.ts +1 -1
- package/src/api/index.ts +1 -1
- package/src/config.ts +1 -1
- package/src/fixtures/ledger.fixtures.ts +1 -1
- package/src/internalTxSources.test.ts +3 -6
- package/src/logic/combine.test.ts +2 -2
- package/src/logic/combine.ts +2 -1
- package/src/logic/common.test.ts +3 -3
- package/src/logic/common.ts +2 -7
- package/src/logic/craftTransaction.test.ts +4 -3
- package/src/logic/craftTransaction.ts +3 -2
- package/src/logic/craftTransactionData.test.ts +1 -1
- package/src/logic/craftTransactionData.ts +1 -1
- package/src/logic/estimateFees.ts +6 -3
- package/src/logic/getBalance.test.ts +1 -1
- package/src/logic/getBalance.ts +30 -24
- package/src/logic/getBlock.test.ts +8 -7
- package/src/logic/getBlock.ts +3 -2
- package/src/logic/getBlockInfo.test.ts +1 -3
- package/src/logic/getStakes.test.ts +2 -2
- package/src/logic/getStakes.ts +15 -6
- package/src/logic/internalTransactionsFetcher.test.ts +4 -6
- package/src/logic/internalTransactionsFetcher.ts +1 -1
- package/src/logic/lastBlock.test.ts +2 -1
- package/src/logic/listOperations.test.ts +75 -2
- package/src/logic/listOperations.ts +3 -0
- package/src/logic/validateIntent.test.ts +2 -1
- package/src/logic/validateIntent.ts +4 -2
- package/src/logic.ts +1 -1
- package/src/network/explorer/etherscan.test.ts +36 -1
- package/src/network/explorer/etherscan.ts +20 -14
- package/src/network/explorer/index.test.ts +1 -1
- package/src/network/explorer/index.ts +2 -2
- package/src/network/explorer/ledger.test.ts +2 -1
- package/src/network/explorer/ledger.ts +3 -2
- package/src/network/explorer/none.ts +2 -1
- package/src/network/explorer/types.ts +1 -1
- package/src/network/gasTracker/index.test.ts +1 -1
- package/src/network/gasTracker/index.ts +2 -2
- package/src/network/gasTracker/ledger.test.ts +10 -17
- package/src/network/gasTracker/ledger.ts +5 -7
- package/src/network/gasTracker/types.ts +2 -2
- package/src/network/node/index.memoization.test.ts +1 -1
- package/src/network/node/ledger.ts +6 -5
- package/src/network/node/rpc.common.ts +14 -14
- package/src/network/node/rpc.test.ts +4 -10
- package/src/network/node/types.ts +3 -3
- package/src/staking/detectOperationType.test.ts +1 -1
- package/src/staking/encoder.test.ts +1 -1
- package/src/staking/fetchers.ts +2 -1
- package/src/staking/operations/index.test.ts +1 -1
- package/src/staking/redelegations.test.ts +23 -15
- package/src/staking/rewards.test.ts +6 -2
- package/src/staking/rewardsFromReceipt.test.ts +1 -1
- package/src/staking/transactionData.test.ts +2 -2
- package/src/staking/validators/monad.test.ts +102 -1
- package/src/staking/validators/monad.ts +58 -5
- package/src/staking/validators/monadResolver.ts +2 -1
- package/src/staking/validators/somnia.ts +2 -1
- package/src/staking/validators/zero_gravity.ts +2 -1
- package/src/staking/validators.test.ts +7 -2
- package/src/types/assets.ts +1 -1
- package/src/types/staking.ts +4 -2
- package/src/types/transaction.ts +1 -1
|
@@ -6,7 +6,7 @@ import network from '@ledgerhq/live-network'
|
|
|
6
6
|
import { ethers } from 'ethers'
|
|
7
7
|
import monadAbi from '../../abis/monad.abi.json'
|
|
8
8
|
import { withApi } from '../../network/node/rpc.common'
|
|
9
|
-
import { fetchMonadStakes } from './monad'
|
|
9
|
+
import { fetchMonadStakes, extractMonadKnownValIds } from './monad'
|
|
10
10
|
import { getValidatorAddressById } from './monadResolver'
|
|
11
11
|
import { clearValidatorsCache, getValidators } from './index'
|
|
12
12
|
|
|
@@ -813,5 +813,106 @@ describe('staking/validators/monad', () => {
|
|
|
813
813
|
expect(stakes).toHaveLength(1)
|
|
814
814
|
expect(callNames(callMock).filter((name) => name === 'getDelegations')).toHaveLength(1)
|
|
815
815
|
})
|
|
816
|
+
|
|
817
|
+
it('surfaces withdrawal slots for a fully-undelegated validator via knownValIds', async () => {
|
|
818
|
+
setupRpc(
|
|
819
|
+
routeByName({
|
|
820
|
+
getDelegations: () => monadIface.encodeFunctionResult('getDelegations', [true, 0, [1n]]),
|
|
821
|
+
getDelegator: (valId) =>
|
|
822
|
+
valId === 1n
|
|
823
|
+
? encodeDelegator(100n)
|
|
824
|
+
: monadIface.encodeFunctionResult('getDelegator', [0n, 0n, 0n, 0n, 0n, 0n, 0n]),
|
|
825
|
+
getValidator: () => encodeGetValidator({ stake: 0n, commission: 0n, secpPubkey: SECP }),
|
|
826
|
+
getEpoch: () => monadIface.encodeFunctionResult('getEpoch', [5n, false]),
|
|
827
|
+
getWithdrawalRequest: (valId, withdrawId) => {
|
|
828
|
+
if (valId === 92n && withdrawId === 0)
|
|
829
|
+
return monadIface.encodeFunctionResult('getWithdrawalRequest', [500n, 0n, 10n])
|
|
830
|
+
return monadIface.encodeFunctionResult('getWithdrawalRequest', [0n, 0n, 0n])
|
|
831
|
+
},
|
|
832
|
+
})
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['92'])
|
|
836
|
+
|
|
837
|
+
const withdrawal = stakes.find((s) => s.details?.validatorId === '92')
|
|
838
|
+
expect(withdrawal).toMatchObject({
|
|
839
|
+
state: 'deactivating',
|
|
840
|
+
amount: 500n,
|
|
841
|
+
details: { validatorId: '92', withdrawId: 0 },
|
|
842
|
+
})
|
|
843
|
+
})
|
|
844
|
+
|
|
845
|
+
it('deduplicates a valId that appears in both getDelegations and knownValIds', async () => {
|
|
846
|
+
let delegatorCallCount = 0
|
|
847
|
+
setupRpc(
|
|
848
|
+
routeByName({
|
|
849
|
+
getDelegations: () => monadIface.encodeFunctionResult('getDelegations', [true, 0, [7n]]),
|
|
850
|
+
getDelegator: (valId) => {
|
|
851
|
+
if (valId === 7n) delegatorCallCount++
|
|
852
|
+
return encodeDelegator(100n)
|
|
853
|
+
},
|
|
854
|
+
getValidator: () => encodeGetValidator({ stake: 0n, commission: 0n, secpPubkey: SECP }),
|
|
855
|
+
})
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['7'])
|
|
859
|
+
|
|
860
|
+
expect(stakes).toHaveLength(1)
|
|
861
|
+
expect(delegatorCallCount).toBe(1)
|
|
862
|
+
})
|
|
863
|
+
})
|
|
864
|
+
|
|
865
|
+
describe('extractMonadKnownValIds', () => {
|
|
866
|
+
const makeOp = (type: string, contractPayload?: string) =>
|
|
867
|
+
({
|
|
868
|
+
type,
|
|
869
|
+
...(contractPayload !== undefined ? { details: { contractPayload } } : {}),
|
|
870
|
+
}) as unknown as Parameters<typeof extractMonadKnownValIds>[1][number]
|
|
871
|
+
|
|
872
|
+
it('extracts a validator id from a DELEGATE op', () => {
|
|
873
|
+
const payload = monadIface.encodeFunctionData('delegate', [42n])
|
|
874
|
+
expect(extractMonadKnownValIds('monad', [makeOp('DELEGATE', payload)])).toStrictEqual(['42'])
|
|
875
|
+
})
|
|
876
|
+
|
|
877
|
+
it('extracts a validator id from an UNDELEGATE op', () => {
|
|
878
|
+
const payload = monadIface.encodeFunctionData('undelegate', [92n, 10_000_000_000n, 0n])
|
|
879
|
+
expect(extractMonadKnownValIds('monad', [makeOp('UNDELEGATE', payload)])).toStrictEqual([
|
|
880
|
+
'92',
|
|
881
|
+
])
|
|
882
|
+
})
|
|
883
|
+
|
|
884
|
+
it('extracts a validator id from a WITHDRAW_UNBONDED op', () => {
|
|
885
|
+
const payload = monadIface.encodeFunctionData('withdraw', [7n, 3n])
|
|
886
|
+
expect(
|
|
887
|
+
extractMonadKnownValIds('monad', [makeOp('WITHDRAW_UNBONDED', payload)])
|
|
888
|
+
).toStrictEqual(['7'])
|
|
889
|
+
})
|
|
890
|
+
|
|
891
|
+
it('deduplicates repeated validator ids across multiple ops', () => {
|
|
892
|
+
const p1 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 0n])
|
|
893
|
+
const p2 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 1n])
|
|
894
|
+
const result = extractMonadKnownValIds('monad', [
|
|
895
|
+
makeOp('UNDELEGATE', p1),
|
|
896
|
+
makeOp('UNDELEGATE', p2),
|
|
897
|
+
])
|
|
898
|
+
expect(result).toStrictEqual(['92'])
|
|
899
|
+
})
|
|
900
|
+
|
|
901
|
+
it('ignores ops whose type is not a staking function', () => {
|
|
902
|
+
const result = extractMonadKnownValIds('monad', [makeOp('OUT'), makeOp('IN')])
|
|
903
|
+
expect(result).toStrictEqual([])
|
|
904
|
+
})
|
|
905
|
+
|
|
906
|
+
it('skips ops with no contractPayload without throwing', () => {
|
|
907
|
+
const result = extractMonadKnownValIds('monad', [makeOp('UNDELEGATE')])
|
|
908
|
+
expect(result).toStrictEqual([])
|
|
909
|
+
})
|
|
910
|
+
|
|
911
|
+
it('returns an empty array for an unknown currencyId (no ABI available)', () => {
|
|
912
|
+
const payload = monadIface.encodeFunctionData('undelegate', [7n, 1n, 0n])
|
|
913
|
+
expect(
|
|
914
|
+
extractMonadKnownValIds('unknown_coin', [makeOp('UNDELEGATE', payload)])
|
|
915
|
+
).toStrictEqual([])
|
|
916
|
+
})
|
|
816
917
|
})
|
|
817
918
|
})
|
|
@@ -5,12 +5,19 @@ import type { EvmConfigInfo } from '../../config'
|
|
|
5
5
|
import type { StakingContractConfig } from '../../types/staking'
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
7
|
import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
8
|
-
import type {
|
|
9
|
-
|
|
8
|
+
import type {
|
|
9
|
+
AssetInfo,
|
|
10
|
+
MemoNotSupported,
|
|
11
|
+
Operation,
|
|
12
|
+
Stake,
|
|
13
|
+
StakeState,
|
|
14
|
+
Validator,
|
|
15
|
+
} from '@ledgerhq/coin-module-framework/api/types'
|
|
16
|
+
import type { JsonRpcProvider } from 'ethers'
|
|
10
17
|
import network from '@ledgerhq/live-network'
|
|
11
18
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
12
19
|
import { log } from '@ledgerhq/logs'
|
|
13
|
-
import { ethers
|
|
20
|
+
import { ethers } from 'ethers'
|
|
14
21
|
import { evmUnit } from '../../logic/evmUnit'
|
|
15
22
|
import { withApi } from '../../network/node/rpc.common'
|
|
16
23
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
@@ -369,11 +376,47 @@ const fetchStakeForValId = async (
|
|
|
369
376
|
return stakes
|
|
370
377
|
}
|
|
371
378
|
|
|
379
|
+
export const extractMonadKnownValIds = (
|
|
380
|
+
currencyId: string,
|
|
381
|
+
ops: Array<Operation<MemoNotSupported>>
|
|
382
|
+
): string[] => {
|
|
383
|
+
const fnNames: Record<string, string> = {
|
|
384
|
+
DELEGATE: 'delegate',
|
|
385
|
+
UNDELEGATE: 'undelegate',
|
|
386
|
+
WITHDRAW_UNBONDED: 'withdraw',
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const abi = getStakingABI(currencyId)
|
|
390
|
+
if (!abi) return []
|
|
391
|
+
|
|
392
|
+
const iface = new ethers.Interface(abi as ethers.InterfaceAbi)
|
|
393
|
+
const valIds = new Set<string>()
|
|
394
|
+
|
|
395
|
+
for (const op of ops) {
|
|
396
|
+
const fnName = fnNames[op.type]
|
|
397
|
+
if (!fnName) continue
|
|
398
|
+
const payload = op.details?.contractPayload
|
|
399
|
+
if (!payload || typeof payload !== 'string') continue
|
|
400
|
+
try {
|
|
401
|
+
const d = iface.decodeFunctionData(fnName, payload)
|
|
402
|
+
if (typeof d[0] === 'bigint') valIds.add(d[0].toString())
|
|
403
|
+
} catch (err) {
|
|
404
|
+
log('coin-evm/staking', 'extractMonadKnownValIds: failed to decode payload', {
|
|
405
|
+
type: op.type,
|
|
406
|
+
error: err instanceof Error ? err.message : String(err),
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return [...valIds]
|
|
412
|
+
}
|
|
413
|
+
|
|
372
414
|
export const fetchMonadStakes = async (
|
|
373
415
|
evmConfig: EvmConfigInfo,
|
|
374
416
|
address: string,
|
|
375
417
|
_config: StakingContractConfig,
|
|
376
|
-
currencyId: string
|
|
418
|
+
currencyId: string,
|
|
419
|
+
knownValIds?: string[]
|
|
377
420
|
): Promise<Stake[]> => {
|
|
378
421
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
379
422
|
if (!ctx) return []
|
|
@@ -384,7 +427,17 @@ export const fetchMonadStakes = async (
|
|
|
384
427
|
currencyId,
|
|
385
428
|
async (provider) => {
|
|
386
429
|
const iface = new ethers.Interface(ctx.abi)
|
|
387
|
-
const
|
|
430
|
+
const fromDelegations = await fetchDelegatedValIds(
|
|
431
|
+
provider,
|
|
432
|
+
iface,
|
|
433
|
+
ctx.contractAddress,
|
|
434
|
+
address
|
|
435
|
+
)
|
|
436
|
+
const valIdSet = new Set(fromDelegations)
|
|
437
|
+
for (const id of knownValIds ?? []) {
|
|
438
|
+
if (/^\d+$/.test(id)) valIdSet.add(BigInt(id))
|
|
439
|
+
}
|
|
440
|
+
const valIds = [...valIdSet]
|
|
388
441
|
if (valIds.length === 0) return []
|
|
389
442
|
|
|
390
443
|
const currentEpoch = await callGetEpoch(provider, iface, ctx.contractAddress)
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import type { JsonRpcProvider } from 'ethers'
|
|
5
6
|
import { log } from '@ledgerhq/logs'
|
|
6
|
-
import { ethers
|
|
7
|
+
import { ethers } from 'ethers'
|
|
7
8
|
import { withApi } from '../../network/node/rpc.common'
|
|
8
9
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
9
10
|
import { getStakingABI } from '../abis'
|
|
@@ -6,10 +6,11 @@ import type { StakingContractConfig } from '../../types/staking'
|
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
7
|
import type { Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
8
8
|
import type { AssetInfo, Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
|
|
9
|
+
import type { JsonRpcProvider } from 'ethers'
|
|
9
10
|
import network from '@ledgerhq/live-network'
|
|
10
11
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
11
12
|
import { log } from '@ledgerhq/logs'
|
|
12
|
-
import { ethers
|
|
13
|
+
import { ethers } from 'ethers'
|
|
13
14
|
import { evmUnit } from '../../logic/evmUnit'
|
|
14
15
|
import { withApi } from '../../network/node/rpc.common'
|
|
15
16
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
@@ -6,9 +6,10 @@ import type { StakingContractConfig } from '../../types/staking'
|
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
7
|
import type { Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
8
8
|
import type { AssetInfo, Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
|
|
9
|
+
import type { JsonRpcProvider } from 'ethers'
|
|
9
10
|
import network from '@ledgerhq/live-network'
|
|
10
11
|
import { log } from '@ledgerhq/logs'
|
|
11
|
-
import { ethers
|
|
12
|
+
import { ethers } from 'ethers'
|
|
12
13
|
import { evmUnit } from '../../logic/evmUnit'
|
|
13
14
|
import { withApi } from '../../network/node/rpc.common'
|
|
14
15
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
4
5
|
import network from '@ledgerhq/live-network'
|
|
5
6
|
import {
|
|
6
7
|
clearValidatorsCache,
|
|
@@ -22,9 +23,13 @@ jest.mock('@ledgerhq/live-network', () => ({
|
|
|
22
23
|
|
|
23
24
|
const mockedNetwork = jest.mocked(network)
|
|
24
25
|
|
|
25
|
-
const mockConfig = {
|
|
26
|
+
const mockConfig: EvmConfigInfo = {
|
|
27
|
+
status: { type: 'active' },
|
|
28
|
+
chainId: 1,
|
|
29
|
+
name: 'Test EVM',
|
|
26
30
|
node: { type: 'external', uri: 'https://sei-evm.coin.ledger.com' },
|
|
27
|
-
|
|
31
|
+
explorer: { type: 'none' },
|
|
32
|
+
}
|
|
28
33
|
|
|
29
34
|
const cosmosValidatorsPayload = {
|
|
30
35
|
status: 200,
|
package/src/types/assets.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
4
|
+
import type { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
5
|
|
|
6
6
|
export function isNative(asset: AssetInfo): asset is { type: 'native' } {
|
|
7
7
|
return asset.type === 'native'
|
package/src/types/staking.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
-
import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
|
+
import type { MemoNotSupported, Operation, Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import type BigNumber from 'bignumber.js'
|
|
7
7
|
|
|
8
8
|
export type EvmStakingOperationType =
|
|
@@ -223,7 +223,8 @@ export type StakingFetcher = (
|
|
|
223
223
|
evmConfig: EvmConfigInfo,
|
|
224
224
|
address: string,
|
|
225
225
|
config: StakingContractConfig,
|
|
226
|
-
currencyId: string
|
|
226
|
+
currencyId: string,
|
|
227
|
+
knownValIds?: string[]
|
|
227
228
|
) => Promise<Stake[]>
|
|
228
229
|
|
|
229
230
|
/**
|
|
@@ -231,6 +232,7 @@ export type StakingFetcher = (
|
|
|
231
232
|
*/
|
|
232
233
|
export type StakingStrategy = {
|
|
233
234
|
fetcher: StakingFetcher
|
|
235
|
+
extractKnownValIds?: (currencyId: string, ops: Array<Operation<MemoNotSupported>>) => string[]
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
/**
|
package/src/types/transaction.ts
CHANGED