@@ -74,11 +74,10 @@ func (d *ERC20Depositor) Deposit(ctx context.Context, req DepositReq) (types.Tra
74
74
Pending : false ,
75
75
Context : ctx ,
76
76
}
77
- // variables for the return value.
78
77
var depResult DepositResult
79
78
txApproval , approvalReceived , errApproval := Approve (ctx , lock , req , token , callOpts )
80
79
if errApproval != nil {
81
- depResult . Error = errApproval
80
+ return nil , errors . WithMessagef ( errApproval , "approving asset: %x" , req . Asset )
82
81
}
83
82
if approvalReceived {
84
83
txDeposit , err := d .DepositOnly (ctx , req )
@@ -104,16 +103,16 @@ func (d *ERC20Depositor) DepositOnly(ctx context.Context, req DepositReq) (*type
104
103
return nil , errors .WithMessagef (err , "creating transactor for asset: %x" , req .Asset )
105
104
}
106
105
107
- tx2 , err := assetholder .Deposit (opts , req .FundingID , req .Balance )
108
- return tx2 , err
106
+ tx , err := assetholder .Deposit (opts , req .FundingID , req .Balance )
107
+ return tx , err
109
108
}
110
109
111
110
// NumTX returns 2 since it does IncreaseAllowance and Deposit.
112
111
func (* ERC20Depositor ) NumTX () uint32 {
113
112
return erc20DepositorNumTx
114
113
}
115
114
116
- // Create key from account address and asset to only lock the process when hub deposits the same asset at the same time.
115
+ // Create key from account address and asset to ensure only one deposit for an asset is performed at the same time.
117
116
func lockKey (account common.Address , asset common.Address ) string {
118
117
return fmt .Sprintf ("%s-%s" , account .Hex (), asset .Hex ())
119
118
}
0 commit comments