safe-eth-py icon indicating copy to clipboard operation
safe-eth-py copied to clipboard

Add function to insert ordered signature to SafeTx

Open moisses89 opened this issue 1 year ago • 0 comments

What is needed?

Currently some projects that uses the safe-eth-py library as safe-cli are keeping by themself the sorting of safeTx signatures each time that new signature is added to safeTx, for example:

 # Insert signature sorted
            if wallet.address not in safe_tx.signers:
                new_owners = safe_tx.signers + [wallet.address]
                new_owner_pos = sorted(new_owners, key=lambda x: int(x, 16)).index(
                    wallet.address
                )
                safe_tx.signatures = (
                    safe_tx.signatures[: 65 * new_owner_pos]
                    + signature
                    + safe_tx.signatures[65 * new_owner_pos :]
                )

I'd suggest include a function in safeTx class that lets a developer to just provide a signature or list of signatures and the function insert the new signature sorted in the safeTx.

moisses89 avatar Dec 12 '23 16:12 moisses89