2020-07-24 13:54:03 +00:00
|
|
|
package invoke
|
|
|
|
|
|
|
|
import (
|
2021-03-24 15:49:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
2020-07-24 13:54:03 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
// ChequeParams for CashOutCheque invocation.
|
|
|
|
ChequeParams struct {
|
|
|
|
ID []byte
|
|
|
|
Amount int64 // Fixed8
|
|
|
|
User util.Uint160
|
|
|
|
LockAccount util.Uint160
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Extra SysFee for contract invocations. Contracts execute inner ring
|
|
|
|
// invocations in two steps: collection and execution. At collection
|
|
|
|
// step contract waits for (2\3*n + 1) invocations, and then in execution
|
|
|
|
// stage contract actually makes changes in the contract storage. SysFee
|
|
|
|
// for invocation calculated based on testinvoke which happens at collection
|
|
|
|
// stage. Therefore client has to provide some extra SysFee to operate at
|
|
|
|
// execution stage. Otherwise invocation will fail due to gas limit.
|
2021-01-20 13:11:43 +00:00
|
|
|
extraFee = 2_0000_0000 // 2.0 Fixed8 gas
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2021-03-24 15:49:24 +00:00
|
|
|
chequeMethod = "cheque"
|
|
|
|
alphabetUpdateMethod = "alphabetUpdate"
|
2020-07-24 13:54:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CashOutCheque invokes Cheque method.
|
2021-04-29 13:39:09 +00:00
|
|
|
func CashOutCheque(cli *client.Client, con util.Uint160, fee MainFeeProvider, p *ChequeParams) error {
|
2020-07-24 13:54:03 +00:00
|
|
|
if cli == nil {
|
|
|
|
return client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:39:21 +00:00
|
|
|
return cli.NotaryInvoke(con, fee.MainChainFee(), chequeMethod,
|
2020-07-24 13:54:03 +00:00
|
|
|
p.ID,
|
|
|
|
p.User.BytesBE(),
|
|
|
|
p.Amount,
|
|
|
|
p.LockAccount.BytesBE(),
|
|
|
|
)
|
|
|
|
}
|
2021-03-24 15:49:24 +00:00
|
|
|
|
|
|
|
// AlphabetUpdate invokes alphabetUpdate method.
|
2021-04-29 13:39:09 +00:00
|
|
|
func AlphabetUpdate(cli *client.Client, con util.Uint160, fee MainFeeProvider, id []byte, list keys.PublicKeys) error {
|
2021-03-24 15:49:24 +00:00
|
|
|
if cli == nil {
|
|
|
|
return client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:39:21 +00:00
|
|
|
return cli.NotaryInvoke(con, fee.MainChainFee(), alphabetUpdateMethod, id, list)
|
2021-03-24 15:49:24 +00:00
|
|
|
}
|