Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin transfer-funds and admin safe-transfer-funds commands #3

Merged
merged 2 commits into from Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions cb-sol-cli/cmd/admin.js
Expand Up @@ -294,6 +294,36 @@ const safeWithdrawCmd = new Command("safe-withdraw")
await safeTransactionAppoveExecute(args, 'adminWithdraw',[args.handler, args.tokenContract, args.recipient, args.amountOrId])
})

const transferFunds = new Command("transfer-funds")
.description("Transfers eth in the contract to the specified addresses")
.requiredOption('--bridge <address>', 'Bridge contract address')
.requiredOption('--addrs <value>', 'Array of addresses to transfer amounts to', splitCommaList)
.requiredOption('--amounts <value>', 'Array of amonuts to addrs')
.action(async function (args) {
await setupParentArgs(args, args.parent.parent)
const bridgeInstance = new ethers.Contract(args.bridge, constants.ContractABIs.Bridge.abi, args.wallet);
log(args, `Transfering to (${args.addrs}) the amounts ${args.amounts} of ETH in wei`)
let tx = await bridgeInstance.transferFunds(args.addrs, args.amounts)
await waitForTx(args.provider, tx.hash)
})

const safeTransferFunds = new Command("safe-transfer-funds")
.description("Transfers eth in the contract to the specified addresses")
.requiredOption('--bridge <address>', 'Bridge contract address')
.requiredOption('--addrs <value>', 'Array of addresses to transfer amounts to', splitCommaList)
.requiredOption('--amounts <value>', 'Array of amonuts to addrs')
.requiredOption('--multiSig <value>', 'Address of Multi-sig which acts as bridge admin')
.option('--approve', 'Approve transaction hash')
.option('--execute', 'Execute transaction')
.option('--approvers <value>', 'Approvers addresses', splitCommaList)
.action(async function (args) {
await safeSetupParentArgs(args, args.parent.parent)

logSafe(args, `Transfering to (${args.addrs}) the amounts ${args.amounts} of ETH in wei`)

await safeTransactionAppoveExecute(args, 'transferFunds',[args.addrs, args.amounts])
})

const adminCmd = new Command("admin")

adminCmd.addCommand(isRelayerCmd)
Expand All @@ -317,5 +347,7 @@ adminCmd.addCommand(changeFeeCmd)
adminCmd.addCommand(safeChangeFeeCmd)
adminCmd.addCommand(withdrawCmd)
adminCmd.addCommand(safeWithdrawCmd)
adminCmd.addCommand(transferFunds)
adminCmd.addCommand(safeTransferFunds)

module.exports = adminCmd
3 changes: 1 addition & 2 deletions cb-sol-cli/cmd/deploy.js
@@ -1,8 +1,7 @@
const assert = require('assert')
const ethers = require('ethers');
const {Command} = require('commander');
const constants = require('../constants');
const {setupParentArgs, safeSetupParentArgs, splitCommaList, waitForTx} = require("./utils")
const {setupParentArgs, safeSetupParentArgs, splitCommaList} = require("./utils")

const deployCmd = new Command("deploy")
.description("Deploys contracts via RPC")
Expand Down
23 changes: 22 additions & 1 deletion cb-sol-cli/docs/admin.md
Expand Up @@ -10,6 +10,7 @@
- [`withdraw`](#withdraw)
- [`add-admin`](#add-admin)
- [`remove-admin`](#remove-admin)
- [`transfer-funds`](#transfer-funds)

## `is-relayer`
Check if an address is registered as a relayer.
Expand Down Expand Up @@ -100,6 +101,15 @@ Removes an admin
--bridge <address> Bridge contract address
```

## `transfer-funds`
Transfers eth in the contract to the specified addresses

```
--bridge <address> Bridge contract address
--addrs <value> Array of addresses to transfer amounts to
--amounts <value> Array of amonuts to addrs
```

# Admin Command using Multi-sig

When the admin is a Gnosis Safe multi-sig contract all the commads should be executed using `--privateKey` of the multi-sig owner, adding the following parameters:
Expand All @@ -113,7 +123,7 @@ When the admin is a Gnosis Safe multi-sig contract all the commads should be exe
--approvers <value> Approvers addresses
```

Using not setting `--approve` or `--execute` flag will get the transaction hash and data required by the multi-sig for approving or executing such action. [`example`](#example)
Not setting `--approve` or `--execute` flag will get the transaction hash and data required by the multi-sig for approving or executing such action. [`example`](#example)

- [`safe-add-relayer`](#safe-add-relayer)
- [`safe-remove-relayer`](#safe-remove-relayer)
Expand All @@ -124,6 +134,7 @@ Using not setting `--approve` or `--execute` flag will get the transaction hash
- [`safe-withdraw`](#safe-withdraw)
- [`safe-add-admin`](#safe-add-admin)
- [`safe-remove-admin`](#safe-remove-admin)
- [`safe-remove-admin`](#safe-transfer-funds)

## `safe-add-relayer`
Adds a new relayer.
Expand Down Expand Up @@ -198,6 +209,16 @@ Removes an admin
--bridge <address> Bridge contract address
```

## `safe-transfer-funds`
Transfers eth in the contract to the specified addresses

```
--bridge <address> Bridge contract address
--addrs <value> Array of addresses to transfer amounts to
--amounts <value> Array of amonuts to addrs
```


### Example

Let say we are working in `Mainnet` `ethereum` side, the admin of BRIDGE is a MULTISIG with owners A, B and C and a threshold 2.
Expand Down