feat: settable approve session timeout

This commit is contained in:
Mohamed Sohail 2023-07-10 14:30:44 +08:00
parent 99cdb6d0aa
commit 07b079749a
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
4 changed files with 7 additions and 2 deletions

View File

@ -58,6 +58,7 @@ func main() {
natsConn, jsCtx := initJetStream()
custodial, err := custodial.NewCustodial(custodial.Opts{
ApprovalTimeout: ko.MustDuration("system.approve_timeout"),
CeloProvider: celoProvider,
LockProvider: lockProvider,
Logg: lo,

View File

@ -13,6 +13,7 @@ registry_address = ""
[system]
private_key = ""
public_key = ""
approve_timeout = "30m"
[postgres]
dsn = ""

View File

@ -3,6 +3,7 @@ package custodial
import (
"context"
"crypto/ecdsa"
"time"
"github.com/bsm/redislock"
"github.com/celo-org/celo-blockchain/common"
@ -19,6 +20,7 @@ import (
type (
Opts struct {
ApprovalTimeout time.Duration
CeloProvider *celoutils.Provider
LockProvider *redislock.Client
Logg logf.Logger
@ -32,6 +34,7 @@ type (
}
Custodial struct {
ApprovalTimeout time.Duration
Abis map[string]*w3.Func
CeloProvider *celoutils.Provider
LockProvider *redislock.Client
@ -69,6 +72,7 @@ func NewCustodial(o Opts) (*Custodial, error) {
}
return &Custodial{
ApprovalTimeout: o.ApprovalTimeout,
Abis: initAbis(),
CeloProvider: o.CeloProvider,
LockProvider: o.LockProvider,

View File

@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"math/big"
"time"
"github.com/bsm/redislock"
"github.com/celo-org/celo-blockchain/common/hexutil"
@ -159,7 +158,7 @@ func SignTransferAuthorizationProcessor(cu *custodial.Custodial) func(context.Co
&tasker.Task{
Payload: taskPayload,
},
asynq.ProcessIn(time.Minute*15),
asynq.ProcessIn(cu.ApprovalTimeout),
)
if err != nil {
return err