mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-21 22:06:47 +01:00
parent
dbfe3e95c8
commit
4b180ea285
@ -13,6 +13,7 @@ import (
|
||||
|
||||
func initSystemContainer() *tasker.SystemContainer {
|
||||
return &tasker.SystemContainer{
|
||||
Abis: initAbis(),
|
||||
GasRefillThreshold: big.NewInt(ko.MustInt64("system.gas_refill_threshold")),
|
||||
GasRefillValue: big.NewInt(ko.MustInt64("system.gas_refill_value")),
|
||||
GiftableGasValue: big.NewInt(ko.MustInt64("system.giftable_gas_value")),
|
||||
@ -27,6 +28,13 @@ func initSystemContainer() *tasker.SystemContainer {
|
||||
}
|
||||
}
|
||||
|
||||
func initAbis() map[string]*w3.Func {
|
||||
return map[string]*w3.Func{
|
||||
"mint": w3.MustNewFunc("mint(address,uint256)", ""),
|
||||
"transfer": w3.MustNewFunc("transfer(address,uint256)", "bool"),
|
||||
}
|
||||
}
|
||||
|
||||
func initSystemKey() *ecdsa.PrivateKey {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
@ -147,12 +147,7 @@ func GiftTokenProcessor(
|
||||
return err
|
||||
}
|
||||
|
||||
abi, err := w3.NewFunc("mint(address,uint256)", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input, err := abi.EncodeArgs(publicKey, system.GiftableTokenValue)
|
||||
input, err := system.Abis["mint"].EncodeArgs(publicKey, system.GiftableTokenValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ABI encode failed %v: %w", err, asynq.SkipRetry)
|
||||
}
|
||||
|
@ -55,12 +55,7 @@ func TransferToken(
|
||||
return err
|
||||
}
|
||||
|
||||
abi, err := w3.NewFunc("transfer(address,uint256)", "bool")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input, err := abi.EncodeArgs(w3.A(p.To), parseTransferValue(p.Amount, system.TokenDecimals))
|
||||
input, err := system.Abis["transfer"].EncodeArgs(w3.A(p.To), parseTransferValue(p.Amount, system.TokenDecimals))
|
||||
if err != nil {
|
||||
return fmt.Errorf("ABI encode failed %v: %w", err, asynq.SkipRetry)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/celo-org/celo-blockchain/common"
|
||||
"github.com/grassrootseconomics/w3-celo-patch"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -15,6 +16,7 @@ type (
|
||||
)
|
||||
|
||||
type SystemContainer struct {
|
||||
Abis map[string]*w3.Func
|
||||
GasRefillThreshold *big.Int
|
||||
GasRefillValue *big.Int
|
||||
GiftableGasValue *big.Int
|
||||
|
Loading…
Reference in New Issue
Block a user