Skip to content

Commit

Permalink
Updating AcceptAdmin to allow acceptance of admin promotion from any …
Browse files Browse the repository at this point in the history
…caller.
  • Loading branch information
Brandon Chatham committed Dec 17, 2024
1 parent b4aae44 commit 08d29b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/user/admin/accept.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func readAndValidateAcceptAdminConfig(
logger logging.Logger,
) (*acceptAdminConfig, error) {
accountAddress := gethcommon.HexToAddress(cliContext.String(AccountAddressFlag.Name))
callerAddress := gethcommon.HexToAddress(cliContext.String(CallerAddress.Name))
ethRpcUrl := cliContext.String(flags.ETHRpcUrlFlag.Name)
network := cliContext.String(flags.NetworkFlag.Name)
environment := cliContext.String(flags.EnvironmentFlag.Name)
Expand All @@ -98,6 +99,13 @@ func readAndValidateAcceptAdminConfig(
return nil, err
}
}
if common.IsEmptyString(callerAddress.String()) {
logger.Infof(
"Caller address not provided. Using account address (%s) as caller address",
accountAddress,
)
callerAddress = accountAddress
}

logger.Debugf(
"Env: %s, network: %s, chain ID: %s, PermissionManager address: %s",
Expand All @@ -111,6 +119,7 @@ func readAndValidateAcceptAdminConfig(
Network: network,
RPCUrl: ethRpcUrl,
AccountAddress: accountAddress,
CallerAddress: callerAddress,
PermissionManagerAddress: gethcommon.HexToAddress(permissionManagerAddress),
SignerConfig: *signerConfig,
ChainID: chainID,
Expand Down Expand Up @@ -144,7 +153,7 @@ func generateAcceptAdminWriter(
return nil, eigenSdkUtils.WrapError("failed to create new eth client", err)
}
return common.GetELWriter(
config.AccountAddress,
config.CallerAddress,
&config.SignerConfig,
ethClient,
elcontracts.Config{
Expand Down
7 changes: 7 additions & 0 deletions pkg/user/admin/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ var (
Usage: "user admin ... --admin-address \"0x...\"",
EnvVars: []string{"ADMIN_ADDRESS"},
}
CallerAddress = cli.StringFlag{
Name: "caller-address",
Aliases: []string{"ca"},
Usage: "This is the address of the caller who is calling the contract function. \n" +
"If it is not provided, the account address will be used as the caller address",
EnvVars: []string{"CALLER_ADDRESS"},
}
PendingAdminAddressFlag = cli.StringFlag{
Name: "pending-admin-address",
Aliases: []string{"paa"},
Expand Down
1 change: 1 addition & 0 deletions pkg/user/admin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type acceptAdminConfig struct {
Network string
RPCUrl string
AccountAddress gethcommon.Address
CallerAddress gethcommon.Address
PermissionManagerAddress gethcommon.Address
SignerConfig types.SignerConfig
ChainID *big.Int
Expand Down

0 comments on commit 08d29b3

Please sign in to comment.