safe-eth-py
safe-eth-py copied to clipboard
Add function to insert ordered signature to SafeTx
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
.