Counter uses dispatcher to deduct fees from account
This commit is contained in:
@@ -66,6 +66,17 @@ func (c secureContext) HasPermission(perm basecoin.Actor) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c secureContext) GetPermissions(chain, app string) (res []basecoin.Actor) {
|
||||
for _, p := range c.perms {
|
||||
if chain == p.ChainID {
|
||||
if app == "" || app == p.App {
|
||||
res = append(res, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// IsParent ensures that this is derived from the given secureClient
|
||||
func (c secureContext) IsParent(other basecoin.Context) bool {
|
||||
so, ok := other.(secureContext)
|
||||
|
||||
+9
-6
@@ -56,8 +56,9 @@ func (d *Dispatcher) CheckTx(ctx basecoin.Context, store types.KVStore, tx basec
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// TODO: callback
|
||||
return r.CheckTx(ctx, store, tx, nil)
|
||||
// TODO: check on callback
|
||||
cb := d
|
||||
return r.CheckTx(ctx, store, tx, cb)
|
||||
}
|
||||
|
||||
func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
@@ -65,8 +66,9 @@ func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store types.KVStore, tx bas
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// TODO: callback
|
||||
return r.DeliverTx(ctx, store, tx, nil)
|
||||
// TODO: check on callback
|
||||
cb := d
|
||||
return r.DeliverTx(ctx, store, tx, cb)
|
||||
}
|
||||
|
||||
func (d *Dispatcher) SetOption(l log.Logger, store types.KVStore, module, key, value string) (string, error) {
|
||||
@@ -74,8 +76,9 @@ func (d *Dispatcher) SetOption(l log.Logger, store types.KVStore, module, key, v
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// TODO: callback
|
||||
return r.SetOption(l, store, module, key, value, nil)
|
||||
// TODO: check on callback
|
||||
cb := d
|
||||
return r.SetOption(l, store, module, key, value, cb)
|
||||
}
|
||||
|
||||
func (d *Dispatcher) lookupTx(tx basecoin.Tx) (Dispatchable, error) {
|
||||
|
||||
@@ -67,6 +67,12 @@ func (_ PassOption) SetOption(l log.Logger, store types.KVStore, module, key, va
|
||||
return next.SetOption(l, store, module, key, value)
|
||||
}
|
||||
|
||||
type NopOption struct{}
|
||||
|
||||
func (_ NopOption) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Dispatchable is like middleware, except the meaning of "next" is different.
|
||||
// Whereas in the middleware, it is the next handler that we should pass the same tx into,
|
||||
// for dispatchers, it is a dispatcher, which it can use to
|
||||
|
||||
@@ -44,6 +44,17 @@ func (c mockContext) HasPermission(perm basecoin.Actor) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c mockContext) GetPermissions(chain, app string) (res []basecoin.Actor) {
|
||||
for _, p := range c.perms {
|
||||
if chain == p.ChainID {
|
||||
if app == "" || app == p.App {
|
||||
res = append(res, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// IsParent ensures that this is derived from the given secureClient
|
||||
func (c mockContext) IsParent(other basecoin.Context) bool {
|
||||
_, ok := other.(mockContext)
|
||||
|
||||
Reference in New Issue
Block a user