Skip to content

Commit

Permalink
revert writel1action base type change
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrosario committed Nov 30, 2023
1 parent d9ce04d commit 4be65e3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/actions/wallet/L1/writeDepositERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export type WriteDepositERC20Parameters<
> =
& { args: DepositERC20Parameters; l1StandardBridge: RawOrContractAddress<_chainId> }
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'nonpayable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
Expand Down
20 changes: 12 additions & 8 deletions src/actions/wallet/L1/writeDepositETH.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import type { Account, Chain, Transport, WalletClient, WriteContractReturnType } from 'viem'
import { optimismPortalABI } from '@eth-optimism/contracts-ts'
import type { Account, Chain, ContractFunctionArgs, Transport, WalletClient, WriteContractReturnType } from 'viem'
import { type RawOrContractAddress, resolveAddress } from '../../../types/addresses.js'
import { type DepositETHParameters } from '../../../types/depositETH.js'
import type { L1WriteActionBaseType } from '../../../types/l1Actions.js'
import { writeDepositTransaction, type WriteDepositTransactionParameters } from './writeDepositTransaction.js'

export const ABI = optimismPortalABI
export const FUNCTION = 'depositTransaction'

export type WriteDepositETHParameters<
TChain extends Chain | undefined = Chain,
TAccount extends Account | undefined = Account | undefined,
TChainOverride extends Chain | undefined = Chain | undefined,
_chainId = TChain extends Chain ? TChain['id'] : number,
> =
& { args: DepositETHParameters; portal: RawOrContractAddress<_chainId> }
& Omit<
L1WriteActionBaseType<
TChain,
TAccount,
TChainOverride
>,
'value'
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'payable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
>

/**
Expand Down
3 changes: 3 additions & 0 deletions src/actions/wallet/L1/writeDepositTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export type WriteDepositTransactionParameters<
=
& { args: DepositTransactionParameters; portal: RawOrContractAddress<number> }
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'payable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
Expand Down
3 changes: 3 additions & 0 deletions src/actions/wallet/L1/writeFinalizeWithdrawalTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export type WriteFinalizeWithdrawalTransactionParameters<
> =
& { args: { withdrawal: FinalizeWithdrawalTransactionParameters }; portal: RawOrContractAddress<_chainId> }
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'nonpayable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
Expand Down
3 changes: 3 additions & 0 deletions src/actions/wallet/L1/writeProveWithdrawalTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export type WriteProveWithdrawalTransactionParameters<
> =
& { args: ProveWithdrawalTransactionParameters; portal: RawOrContractAddress<_chainId> }
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'nonpayable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
Expand Down
3 changes: 3 additions & 0 deletions src/actions/wallet/L1/writeSendMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export type WriteSendMessageParameters<
> =
& { args: SendMessageParameters; l1CrossDomainMessenger: RawOrContractAddress<_chainId> }
& L1WriteActionBaseType<
typeof ABI,
typeof FUNCTION,
ContractFunctionArgs<typeof ABI, 'payable', typeof FUNCTION>,
TChain,
TAccount,
TChainOverride
Expand Down
20 changes: 13 additions & 7 deletions src/types/l1Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ import type {
Chain,
ContractFunctionArgs,
ContractFunctionName,
SendTransactionParameters,
SimulateContractParameters,
WriteContractParameters,
} from 'viem'

export type L1WriteActionBaseType<
TAbi extends Abi | readonly unknown[] = Abi,
TFunctionName extends ContractFunctionName<
TAbi,
'nonpayable' | 'payable'
> = ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,
TArgs extends ContractFunctionArgs<
TAbi,
'nonpayable' | 'payable',
TFunctionName
> = ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName>,
TChain extends Chain | undefined = Chain,
TAccount extends Account | undefined = Account | undefined,
TChainOverride extends Chain | undefined = Chain | undefined,
> = Omit<
SendTransactionParameters<
TChain,
TAccount,
TChainOverride
>,
'chain'
WriteContractParameters<TAbi, TFunctionName, TArgs, TChain, TAccount, TChainOverride>,
'abi' | 'functionName' | 'args' | 'address'
>

export type L1SimulateActionBaseType<
Expand Down

0 comments on commit 4be65e3

Please sign in to comment.