Files
Daniel DimitrovandGitHub a4ff1b666d chore: update store types (#6402)
* chore: update types

* fix(mobile): linting

* chore: use Chain type from @safe-global/store

* fix(utils): failing tests
2025-10-06 09:23:02 +02:00

32 lines
1.2 KiB
TypeScript

// `assert` does not work with arrow functions
import type { ConnectedWallet } from '@/hooks/wallets/useOnboard'
import type { SafeTransaction } from '@safe-global/types-kit'
import { type Chain } from '@safe-global/store/gateway/AUTO_GENERATED/chains'
import type { OnboardAPI } from '@web3-onboard/core'
import type { Eip1193Provider } from 'ethers'
import { invariant } from '@safe-global/utils/utils/helpers'
export function assertTx(safeTx: SafeTransaction | undefined): asserts safeTx {
return invariant(safeTx, 'Transaction not provided')
}
export function assertWallet(wallet: ConnectedWallet | null): asserts wallet {
return invariant(wallet, 'Wallet not connected')
}
export function assertOnboard(onboard: OnboardAPI | undefined): asserts onboard {
return invariant(onboard, 'Onboard not connected')
}
export function assertChainInfo(chainInfo: Chain | undefined): asserts chainInfo {
return invariant(chainInfo, 'No chain config available')
}
export function assertProvider(provider: Eip1193Provider | undefined | null): asserts provider {
return invariant(provider, 'Provider not found')
}
export const getKeyWithTrueValue = (obj: Record<string, boolean>) => {
return Object.entries(obj).find(([, value]) => !!value)?.[0]
}