-
Notifications
You must be signed in to change notification settings - Fork 17
/
auth.go
36 lines (31 loc) · 1008 Bytes
/
auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package keeper
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/datachainlab/cross/x/core/auth/types"
"github.com/datachainlab/cross/x/core/initiator/types"
crosstypes "github.com/datachainlab/cross/x/core/types"
)
var _ authtypes.TxManager = (*Keeper)(nil)
// IsActive implements TxManager interface
func (a Keeper) IsActive(ctx sdk.Context, txID crosstypes.TxID) (bool, error) {
// TODO add timeout support to initiator?
_, found := a.getTxState(ctx, txID)
if !found {
return false, nil
}
return true, nil
}
// OnPostAuth implements TxManager interface
func (a Keeper) OnPostAuth(ctx sdk.Context, txID crosstypes.TxID) error {
txState, found := a.getTxState(ctx, txID)
if !found {
return fmt.Errorf("txState '%x' not found", txID)
}
if txState.IsVerified() {
return fmt.Errorf("txState '%x' is already verified", txID)
}
txState.Status = types.INITIATE_TX_STATUS_VERIFIED
a.setTxState(ctx, txID, *txState)
return a.runTx(ctx, txID, &txState.Msg)
}