refactor: move abis to system_init

* closes #31
This commit is contained in:
2022-12-01 13:07:22 +00:00
parent dbfe3e95c8
commit 4b180ea285
4 changed files with 12 additions and 12 deletions

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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