Skip to content

Commit

Permalink
Updating appointee set & remove methods to support injecting txOpts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Chatham committed Dec 17, 2024
1 parent 7aa2a64 commit 1dd4a5c
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,62 +612,64 @@ func (w *ChainWriter) RemovePermission(
ctx context.Context,
request RemovePermissionRequest,
) (*gethtypes.Receipt, error) {
tx, err := w.NewRemovePermissionTx(request)
txOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, utils.WrapError("failed to get no-send tx opts", err)
}
tx, err := w.NewRemovePermissionTx(txOpts, request)
if err != nil {
return nil, utils.WrapError("failed to create NewRemovePermissionTx", err)
}
return w.txMgr.Send(ctx, tx, request.WaitForReceipt)
}

func (w *ChainWriter) NewRemovePermissionTx(
txOpts *bind.TransactOpts,
request RemovePermissionRequest,
) (*gethtypes.Transaction, error) {
if w.permissionController == nil {
return nil, errors.New("permission contract not provided")
}
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, utils.WrapError("failed to get no send tx opts", err)
}

return w.permissionController.RemoveAppointee(
noSendTxOpts,
txOpts,
request.AccountAddress,
request.AppointeeAddress,
request.Target,
request.Selector,
)
}

func (w *ChainWriter) SetPermission(ctx context.Context, request SetPermissionRequest) (*gethtypes.Receipt, error) {
tx, err := w.NewSetPermissionTx(request)
if err != nil {
return nil, utils.WrapError("failed to create NewSetPermissionTx", err)
}
receipt, err := w.txMgr.Send(ctx, tx, request.WaitForReceipt)
return receipt, err
}

func (w *ChainWriter) NewSetPermissionTx(request SetPermissionRequest) (*gethtypes.Transaction, error) {
func (w *ChainWriter) NewSetPermissionTx(
txOpts *bind.TransactOpts,
request SetPermissionRequest,
) (*gethtypes.Transaction, error) {
if w.permissionController == nil {
return nil, errors.New("permission contract not provided")
}
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, utils.WrapError("failed to get no send tx opts", err)
}

tx, err := w.permissionController.SetAppointee(
noSendTxOpts,
return w.permissionController.SetAppointee(
txOpts,
request.AccountAddress,
request.AppointeeAddress,
request.Target,
request.Selector,
)
}

func (w *ChainWriter) SetPermission(
ctx context.Context,
request SetPermissionRequest,
) (*gethtypes.Receipt, error) {
txOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, utils.WrapError("failed to get no-send tx opts", err)
}

tx, err := w.NewSetPermissionTx(txOpts, request)
if err != nil {
return nil, errors.New("call to permission controller failed: " + err.Error())
return nil, utils.WrapError("failed to create NewSetPermissionTx", err)
}
return tx, nil

return w.txMgr.Send(ctx, tx, request.WaitForReceipt)
}

func (w *ChainWriter) NewAcceptAdminTx(
Expand Down

0 comments on commit 1dd4a5c

Please sign in to comment.