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() natsConn, jsCtx := initJetStream()
custodial, err := custodial.NewCustodial(custodial.Opts{ custodial, err := custodial.NewCustodial(custodial.Opts{
ApprovalTimeout: ko.MustDuration("system.approve_timeout"),
CeloProvider: celoProvider, CeloProvider: celoProvider,
LockProvider: lockProvider, LockProvider: lockProvider,
Logg: lo, Logg: lo,

View File

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

View File

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

View File

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