Gnosis Safe如何使用Safe CLI管理,求个教程

官方Github链接:https://github.com/5afe/safe-cli
求个详细教程(教程尽量详细些),如何使用官方提供的Safe CLI管理Gnosis Safe账户,包括如何在不同network下增加、删除地址

img

你可以读一下我最近写的博客,理解原理后可以直接用任何与合约交互的工具进行操作。
https://hugo.wongssh.cf/posts/deep-in-safe-part-1/
当然,你也可以私信我,我会教你操作方法。你关注的签名账户增删在我目前还未发布的博客的第二部分,具体来说需要使用 execTransaction 函数,并在设置其中的 data 参数为使用 addOwnerWithThreshold(address owner, uint256 _threshold) 函数的 abi 编码。

代码在最下面:

Add owner
To add a new owner, first go to the Settings tab and select the Owners section.
要添加新所有者,请先转到“设置”选项卡并选择“所有者”部分。

img

On the bottom-right you see the button Add new owner. Important: you need to be connected with one of the existing owners to see this button. Clicking this button would open a new window.

img

In this window, enter the name of the new owner and paste the owners Ethereum address or ENS name.

img

Next, you'll be able to set the ne transaction threshold. In this case you can require either one or both of the owners to sign a transaction for it to be executed.

img

After reviewing again if all change parameters are correct, you can submit the change using the Submit button. Your owner wallet will ask you to confirm the owner change on the blockchain. And will afterwards take you to the transaction list where you can follow the progress of the owner change.

img

In case you already had multiple required signers for this Safe, the other owners will have to go to the transaction list and confirm by expanding the transaction details and clicking on the Confrm button.

img

测试代码:

def test_add_owner(self):
        safe_address = self.deploy_test_safe(
            owners=[self.ethereum_test_account.address]
        ).safe_address
        safe_operator = SafeOperator(safe_address, self.ethereum_node_url)
        with self.assertRaises(ExistingOwnerException):
            safe_operator.add_owner(self.ethereum_test_account.address)

        new_owner = Account.create().address
        with self.assertRaises(NotEnoughSignatures):
            safe_operator.add_owner(new_owner)

        safe_operator.accounts.add(self.ethereum_test_account)

        with self.assertRaises(SenderRequiredException):
            safe_operator.add_owner(new_owner)

        safe_operator.default_sender = self.ethereum_test_account

        safe = Safe(safe_address, self.ethereum_client)
        self.assertTrue(safe_operator.add_owner(new_owner))
        self.assertIn(self.ethereum_test_account, safe_operator.accounts)
        self.assertIn(new_owner, safe.retrieve_owners())

    def test_remove_owner(self):
        safe_address = self.deploy_test_safe(
            owners=[self.ethereum_test_account.address]
        ).safe_address
        safe_operator = SafeOperator(safe_address, self.ethereum_node_url)
        random_address = Account.create().address
        with self.assertRaises(NonExistingOwnerException):
            safe_operator.remove_owner(random_address)

        safe_operator.load_cli_owners([self.ethereum_test_account.key.hex()])
        new_owner = Account.create().address
        safe = Safe(safe_address, self.ethereum_client)
        self.assertTrue(safe_operator.add_owner(new_owner))
        self.assertIn(new_owner, safe.retrieve_owners())

        self.assertTrue(safe_operator.remove_owner(new_owner))
        self.assertNotIn(new_owner, safe_operator.accounts)
        self.assertNotIn(new_owner, safe.retrieve_owners())