// SPDX-FileCopyrightText: © 2024 LEDGER SAS // SPDX-License-Identifier: Apache-2.0 import type { AssetInfo, Memo, MemoNotSupported, SendTransactionIntent, StakingOperation, StakingTransactionIntent, TxData, TxDataNotSupported, } from '../api/index' export * from './capabilities' type SendPartialBase = { type: string } & Partial< Omit, 'intentType' | 'type'> > export function createSendTransactionIntentMockData< MemoType extends Memo = MemoNotSupported, TxDataType extends TxData = TxDataNotSupported, >( partial: SendPartialBase & { memo?: MemoType; data?: TxDataType } ): SendTransactionIntent export function createSendTransactionIntentMockData( partial: SendPartialBase ): SendTransactionIntent { const base: SendTransactionIntent = { intentType: 'transaction', type: partial.type, sender: partial.sender ?? 'sender-address', recipient: partial.recipient ?? 'recipient-address', amount: partial.amount ?? 0n, asset: partial.asset ?? { type: 'native' }, } return Object.assign({}, base, partial) } type StakingPartialBase = { type: string; mode: StakingOperation } & Partial< Omit< StakingTransactionIntent, 'intentType' | 'type' | 'mode' > > export function createStakingTransactionIntentMockData< MemoType extends Memo = MemoNotSupported, TxDataType extends TxData = TxDataNotSupported, >( partial: StakingPartialBase & { memo?: MemoType; data?: TxDataType } ): StakingTransactionIntent export function createStakingTransactionIntentMockData( partial: StakingPartialBase ): StakingTransactionIntent { const base: StakingTransactionIntent = { intentType: 'staking', type: partial.type, mode: partial.mode, sender: partial.sender ?? 'sender-address', recipient: partial.recipient ?? 'recipient-address', amount: partial.amount ?? 0n, asset: partial.asset ?? { type: 'native' }, valAddress: partial.valAddress ?? 'validator-address', } return Object.assign({}, base, partial) } export function createAssetInfoMockData( partial: { type: string } & Partial> ): AssetInfo { const asset: AssetInfo = { ...partial } return asset }