1import type { Signer } from 'ethers' 5const allowedDestsRegistry = new Map<string, Set<string>>() 7export const registerEthSendAllowlist = (senderAddr: string, allowedDests: string[]) => { 8 const key = senderAddr.toLowerCase() 9 const existing = allowedDestsRegistry.get(key) || new Set() 10 for (const dest of allowedDests) existing.add(dest.toLowerCase()) 11 allowedDestsRegistry.set(key, existing) 14export const safeSendEth = async ({signer, destAddr, value}: {signer: Signer, destAddr: string, value: bigint}) => { 15 const senderAddr = await signer.getAddress() 16 const allowed = allowedDestsRegistry.get(senderAddr.toLowerCase()) 18 throwIf(() => !allowed.has(destAddr.toLowerCase()), {senderAddr, destAddr, allowedDests: [...allowed]}) 19 return signer.sendTransaction({to: destAddr, value})