mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-04 15:55:23 +00:00
Merge 6ed21ea3fb
into 2fa73957a9
This commit is contained in:
commit
0830a6d458
22
app/app.go
22
app/app.go
@ -111,6 +111,7 @@ import (
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
dasignersprecompile "github.com/0glabs/0g-chain/precompiles/dasigners"
|
||||
stakingprecompile "github.com/0glabs/0g-chain/precompiles/staking"
|
||||
wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/bep3"
|
||||
bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
@ -140,6 +141,9 @@ import (
|
||||
validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting"
|
||||
validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest"
|
||||
validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types"
|
||||
wrappeda0gibase "github.com/0glabs/0g-chain/x/wrapped-a0gi-base"
|
||||
wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
wrappeda0gibasetypes "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
@ -187,6 +191,7 @@ var (
|
||||
dasigners.AppModuleBasic{},
|
||||
consensus.AppModuleBasic{},
|
||||
ibcwasm.AppModuleBasic{},
|
||||
wrappeda0gibase.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -205,6 +210,7 @@ var (
|
||||
bep3types.ModuleName: {authtypes.Burner, authtypes.Minter},
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
precisebanktypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for reserve account to back fractional amounts
|
||||
wrappeda0gibasetypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
||||
}
|
||||
)
|
||||
|
||||
@ -275,6 +281,7 @@ type App struct {
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
consensusParamsKeeper consensusparamkeeper.Keeper
|
||||
precisebankKeeper precisebankkeeper.Keeper
|
||||
wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper
|
||||
|
||||
// make scoped keepers public for test purposes
|
||||
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
||||
@ -327,6 +334,7 @@ func NewApp(
|
||||
vestingtypes.StoreKey,
|
||||
consensusparamtypes.StoreKey, crisistypes.StoreKey, precisebanktypes.StoreKey,
|
||||
ibcwasmtypes.StoreKey,
|
||||
wrappeda0gibasetypes.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||
@ -496,11 +504,10 @@ func NewApp(
|
||||
app.accountKeeper,
|
||||
)
|
||||
|
||||
// dasigners keeper
|
||||
app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr)
|
||||
// precopmiles
|
||||
precompiles := make(map[common.Address]vm.PrecompiledContract)
|
||||
// dasigners
|
||||
app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr)
|
||||
daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("initialize dasigners precompile failed: %v", err))
|
||||
@ -512,6 +519,13 @@ func NewApp(
|
||||
panic(fmt.Sprintf("initialize staking precompile failed: %v", err))
|
||||
}
|
||||
precompiles[stakingPrecompile.Address()] = stakingPrecompile
|
||||
// wrapped wrapped a0gi base
|
||||
app.wrappeda0gibaseKeeper = wrappeda0gibasekeeper.NewKeeper(keys[wrappeda0gibasetypes.StoreKey], appCodec, app.precisebankKeeper, govAuthAddrStr)
|
||||
wrappeda0gibasePrecompile, err := wrappeda0gibaseprecompile.NewWrappedA0giBasePrecompile(app.wrappeda0gibaseKeeper)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("initialize wrapped a0gi base precompile failed: %v", err))
|
||||
}
|
||||
precompiles[wrappeda0gibasePrecompile.Address()] = wrappeda0gibasePrecompile
|
||||
|
||||
app.evmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
|
||||
@ -695,6 +709,7 @@ func NewApp(
|
||||
council.NewAppModule(app.CouncilKeeper),
|
||||
ibcwasm.NewAppModule(app.ibcWasmClientKeeper),
|
||||
dasigners.NewAppModule(app.dasignersKeeper, *app.stakingKeeper),
|
||||
wrappeda0gibase.NewAppModule(app.wrappeda0gibaseKeeper),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -742,6 +757,7 @@ func NewApp(
|
||||
precisebanktypes.ModuleName,
|
||||
ibcwasmtypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
wrappeda0gibasetypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -779,6 +795,7 @@ func NewApp(
|
||||
precisebanktypes.ModuleName,
|
||||
ibcwasmtypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
wrappeda0gibasetypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
|
||||
@ -815,6 +832,7 @@ func NewApp(
|
||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||
ibcwasmtypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
wrappeda0gibasetypes.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.crisisKeeper)
|
||||
|
@ -49,6 +49,7 @@ import (
|
||||
issuancekeeper "github.com/0glabs/0g-chain/x/issuance/keeper"
|
||||
precisebankkeeper "github.com/0glabs/0g-chain/x/precisebank/keeper"
|
||||
pricefeedkeeper "github.com/0glabs/0g-chain/x/pricefeed/keeper"
|
||||
wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -118,6 +119,9 @@ func (tApp TestApp) GetEvmKeeper() *evmkeeper.Keeper { return tAp
|
||||
func (tApp TestApp) GetFeeMarketKeeper() feemarketkeeper.Keeper { return tApp.feeMarketKeeper }
|
||||
func (tApp TestApp) GetDASignersKeeper() dasignerskeeper.Keeper { return tApp.dasignersKeeper }
|
||||
func (tApp TestApp) GetPrecisebankKeeper() precisebankkeeper.Keeper { return tApp.precisebankKeeper }
|
||||
func (tApp TestApp) GetWrappedA0GIBaseKeeper() wrappeda0gibasekeeper.Keeper {
|
||||
return tApp.wrappeda0gibaseKeeper
|
||||
}
|
||||
|
||||
func (tApp TestApp) GetKVStoreKey(key string) *storetypes.KVStoreKey {
|
||||
return tApp.keys[key]
|
||||
|
55
precompiles/interfaces/contracts/IWrappedA0GIBase.sol
Normal file
55
precompiles/interfaces/contracts/IWrappedA0GIBase.sol
Normal file
@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
struct Supply {
|
||||
uint256 cap;
|
||||
uint256 total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title WrappedA0GIBase is a precompile for wrapped a0gi(wA0GI), it enables wA0GI mint/burn native 0g token directly.
|
||||
*/
|
||||
interface IWrappedA0GIBase {
|
||||
/**
|
||||
* @dev set the wA0GI address.
|
||||
* It is designed to be called by governance module only so it's not implemented at EVM precompile side.
|
||||
* @param addr address of wA0GI
|
||||
*/
|
||||
// function setWA0GI(address addr) external;
|
||||
|
||||
/**
|
||||
* @dev get the wA0GI address.
|
||||
*/
|
||||
function getWA0GI() external view returns (address);
|
||||
|
||||
/**
|
||||
* @dev set the cap for a minter.
|
||||
* It is designed to be called by governance module only so it's not implemented at EVM precompile side.
|
||||
* @param minter minter address
|
||||
* @param cap mint cap
|
||||
*/
|
||||
// function setMinterCap(address minter, uint256 cap) external;
|
||||
|
||||
/**
|
||||
* @dev get the mint supply of given address
|
||||
* @param minter minter address
|
||||
*/
|
||||
function minterSupply(address minter) external view returns (Supply memory);
|
||||
|
||||
/**
|
||||
* @dev mint a0gi to this precompile, add corresponding amount to minter's mint supply.
|
||||
* If sender's final mint supply exceeds its mint cap, the transaction will revert.
|
||||
* Can only be called by WA0GI.
|
||||
* @param minter minter address
|
||||
* @param amount amount to mint
|
||||
*/
|
||||
function mint(address minter, uint256 amount) external;
|
||||
|
||||
/**
|
||||
* @dev burn given amount of a0gi on behalf of minter, reduce corresponding amount from sender's mint supply.
|
||||
* Can only be called by WA0GI.
|
||||
* @param minter minter address
|
||||
* @param amount amount to burn
|
||||
*/
|
||||
function burn(address minter, uint256 amount) external;
|
||||
}
|
82
precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json
Normal file
82
precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json
Normal file
@ -0,0 +1,82 @@
|
||||
[
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "minter",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "burn",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "getWA0GI",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "minter",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "minter",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "minterSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "cap",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "total",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct Supply",
|
||||
"name": "",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
284
precompiles/wrapped-a0gi-base/contract.go
Normal file
284
precompiles/wrapped-a0gi-base/contract.go
Normal file
@ -0,0 +1,284 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var (
|
||||
_ = errors.New
|
||||
_ = big.NewInt
|
||||
_ = strings.NewReader
|
||||
_ = ethereum.NotFound
|
||||
_ = bind.Bind
|
||||
_ = common.Big1
|
||||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// Wrappeda0gibaseMetaData contains all meta data concerning the Wrappeda0gibase contract.
|
||||
var Wrappeda0gibaseMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseABI is the input ABI used to generate the binding from.
|
||||
// Deprecated: Use Wrappeda0gibaseMetaData.ABI instead.
|
||||
var Wrappeda0gibaseABI = Wrappeda0gibaseMetaData.ABI
|
||||
|
||||
// Wrappeda0gibase is an auto generated Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibase struct {
|
||||
Wrappeda0gibaseCaller // Read-only binding to the contract
|
||||
Wrappeda0gibaseTransactor // Write-only binding to the contract
|
||||
Wrappeda0gibaseFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibaseCaller struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibaseTransactor struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type Wrappeda0gibaseFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseSession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type Wrappeda0gibaseSession struct {
|
||||
Contract *Wrappeda0gibase // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type Wrappeda0gibaseCallerSession struct {
|
||||
Contract *Wrappeda0gibaseCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type Wrappeda0gibaseTransactorSession struct {
|
||||
Contract *Wrappeda0gibaseTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibaseRaw struct {
|
||||
Contract *Wrappeda0gibase // Generic contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibaseCallerRaw struct {
|
||||
Contract *Wrappeda0gibaseCaller // Generic read-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// Wrappeda0gibaseTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type Wrappeda0gibaseTransactorRaw struct {
|
||||
Contract *Wrappeda0gibaseTransactor // Generic write-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// NewWrappeda0gibase creates a new instance of Wrappeda0gibase, bound to a specific deployed contract.
|
||||
func NewWrappeda0gibase(address common.Address, backend bind.ContractBackend) (*Wrappeda0gibase, error) {
|
||||
contract, err := bindWrappeda0gibase(address, backend, backend, backend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Wrappeda0gibase{Wrappeda0gibaseCaller: Wrappeda0gibaseCaller{contract: contract}, Wrappeda0gibaseTransactor: Wrappeda0gibaseTransactor{contract: contract}, Wrappeda0gibaseFilterer: Wrappeda0gibaseFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// NewWrappeda0gibaseCaller creates a new read-only instance of Wrappeda0gibase, bound to a specific deployed contract.
|
||||
func NewWrappeda0gibaseCaller(address common.Address, caller bind.ContractCaller) (*Wrappeda0gibaseCaller, error) {
|
||||
contract, err := bindWrappeda0gibase(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Wrappeda0gibaseCaller{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewWrappeda0gibaseTransactor creates a new write-only instance of Wrappeda0gibase, bound to a specific deployed contract.
|
||||
func NewWrappeda0gibaseTransactor(address common.Address, transactor bind.ContractTransactor) (*Wrappeda0gibaseTransactor, error) {
|
||||
contract, err := bindWrappeda0gibase(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Wrappeda0gibaseTransactor{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewWrappeda0gibaseFilterer creates a new log filterer instance of Wrappeda0gibase, bound to a specific deployed contract.
|
||||
func NewWrappeda0gibaseFilterer(address common.Address, filterer bind.ContractFilterer) (*Wrappeda0gibaseFilterer, error) {
|
||||
contract, err := bindWrappeda0gibase(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Wrappeda0gibaseFilterer{contract: contract}, nil
|
||||
}
|
||||
|
||||
// bindWrappeda0gibase binds a generic wrapper to an already deployed contract.
|
||||
func bindWrappeda0gibase(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(Wrappeda0gibaseABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _Wrappeda0gibase.Contract.Wrappeda0gibaseCaller.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Wrappeda0gibaseTransactor.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Wrappeda0gibaseTransactor.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _Wrappeda0gibase.Contract.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a.
|
||||
//
|
||||
// Solidity: function getWA0GI() view returns(address)
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseCaller) GetWA0GI(opts *bind.CallOpts) (common.Address, error) {
|
||||
var out []interface{}
|
||||
err := _Wrappeda0gibase.contract.Call(opts, &out, "getWA0GI")
|
||||
|
||||
if err != nil {
|
||||
return *new(common.Address), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a.
|
||||
//
|
||||
// Solidity: function getWA0GI() view returns(address)
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseSession) GetWA0GI() (common.Address, error) {
|
||||
return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.CallOpts)
|
||||
}
|
||||
|
||||
// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a.
|
||||
//
|
||||
// Solidity: function getWA0GI() view returns(address)
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseCallerSession) GetWA0GI() (common.Address, error) {
|
||||
return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.CallOpts)
|
||||
}
|
||||
|
||||
// MinterSupply is a free data retrieval call binding the contract method 0x95609212.
|
||||
//
|
||||
// Solidity: function minterSupply(address minter) view returns((uint256,uint256))
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseCaller) MinterSupply(opts *bind.CallOpts, minter common.Address) (Supply, error) {
|
||||
var out []interface{}
|
||||
err := _Wrappeda0gibase.contract.Call(opts, &out, "minterSupply", minter)
|
||||
|
||||
if err != nil {
|
||||
return *new(Supply), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(Supply)).(*Supply)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// MinterSupply is a free data retrieval call binding the contract method 0x95609212.
|
||||
//
|
||||
// Solidity: function minterSupply(address minter) view returns((uint256,uint256))
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseSession) MinterSupply(minter common.Address) (Supply, error) {
|
||||
return _Wrappeda0gibase.Contract.MinterSupply(&_Wrappeda0gibase.CallOpts, minter)
|
||||
}
|
||||
|
||||
// MinterSupply is a free data retrieval call binding the contract method 0x95609212.
|
||||
//
|
||||
// Solidity: function minterSupply(address minter) view returns((uint256,uint256))
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseCallerSession) MinterSupply(minter common.Address) (Supply, error) {
|
||||
return _Wrappeda0gibase.Contract.MinterSupply(&_Wrappeda0gibase.CallOpts, minter)
|
||||
}
|
||||
|
||||
// Burn is a paid mutator transaction binding the contract method 0x9dc29fac.
|
||||
//
|
||||
// Solidity: function burn(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Burn(opts *bind.TransactOpts, minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.contract.Transact(opts, "burn", minter, amount)
|
||||
}
|
||||
|
||||
// Burn is a paid mutator transaction binding the contract method 0x9dc29fac.
|
||||
//
|
||||
// Solidity: function burn(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseSession) Burn(minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount)
|
||||
}
|
||||
|
||||
// Burn is a paid mutator transaction binding the contract method 0x9dc29fac.
|
||||
//
|
||||
// Solidity: function burn(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Burn(minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount)
|
||||
}
|
||||
|
||||
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
|
||||
//
|
||||
// Solidity: function mint(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Mint(opts *bind.TransactOpts, minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.contract.Transact(opts, "mint", minter, amount)
|
||||
}
|
||||
|
||||
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
|
||||
//
|
||||
// Solidity: function mint(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseSession) Mint(minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, amount)
|
||||
}
|
||||
|
||||
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
|
||||
//
|
||||
// Solidity: function mint(address minter, uint256 amount) returns()
|
||||
func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Mint(minter common.Address, amount *big.Int) (*types.Transaction, error) {
|
||||
return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, amount)
|
||||
}
|
5
precompiles/wrapped-a0gi-base/errors.go
Normal file
5
precompiles/wrapped-a0gi-base/errors.go
Normal file
@ -0,0 +1,5 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
const (
|
||||
ErrSenderNotWA0GI = "sender is not WA0GI"
|
||||
)
|
38
precompiles/wrapped-a0gi-base/query.go
Normal file
38
precompiles/wrapped-a0gi-base/query.go
Normal file
@ -0,0 +1,38 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
func (w *WrappedA0giBasePrecompile) GetW0GI(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewGetW0GIRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := w.wrappeda0gibaseKeeper.GetWA0GI(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(common.BytesToAddress(response.Address))
|
||||
}
|
||||
|
||||
func (w *WrappedA0giBasePrecompile) MinterSupply(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewMinterSupplyRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := w.wrappeda0gibaseKeeper.MinterSupply(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
supply := Supply{
|
||||
Cap: new(big.Int).SetBytes(response.Cap),
|
||||
Total: new(big.Int).SetBytes(response.Supply),
|
||||
}
|
||||
return method.Outputs.Pack(supply)
|
||||
}
|
147
precompiles/wrapped-a0gi-base/query_test.go
Normal file
147
precompiles/wrapped-a0gi-base/query_test.go
Normal file
@ -0,0 +1,147 @@
|
||||
package wrappeda0gibase_test
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
func (s *WrappedA0giBaseTestSuite) TestGetW0GI() {
|
||||
method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionGetWA0GI
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
malleate func() []byte
|
||||
postCheck func(bz []byte)
|
||||
gas uint64
|
||||
expErr bool
|
||||
errContains string
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func(data []byte) {
|
||||
out, err := s.abi.Methods[method].Outputs.Unpack(data)
|
||||
s.Require().NoError(err, "failed to unpack output")
|
||||
wa0gi := out[0].(common.Address)
|
||||
s.Require().Equal(wa0gi, common.HexToAddress(types.DEFAULT_WRAPPED_A0GI))
|
||||
// fmt.Println(wa0gi)
|
||||
},
|
||||
100000,
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
bz, err := s.runTx(tc.malleate(), s.signerOne, 10000000)
|
||||
|
||||
if tc.expErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errContains)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
s.Require().NotNil(bz)
|
||||
tc.postCheck(bz)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *WrappedA0giBaseTestSuite) TestMinterSupply() {
|
||||
method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionMinterSupply
|
||||
govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
malleate func() []byte
|
||||
postCheck func(bz []byte)
|
||||
gas uint64
|
||||
expErr bool
|
||||
errContains string
|
||||
}{
|
||||
{
|
||||
"non-empty",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerOne.Addr,
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func(data []byte) {
|
||||
out, err := s.abi.Methods[method].Outputs.Unpack(data)
|
||||
s.Require().NoError(err, "failed to unpack output")
|
||||
wa0gi := out[0].(wrappeda0gibaseprecompile.Supply)
|
||||
s.Require().Equal(wa0gi.Cap, big.NewInt(8e18))
|
||||
s.Require().Equal(wa0gi.Total, big.NewInt(1e18))
|
||||
// fmt.Println(wa0gi)
|
||||
},
|
||||
100000,
|
||||
false,
|
||||
"",
|
||||
}, {
|
||||
"empty",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerTwo.Addr,
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func(data []byte) {
|
||||
out, err := s.abi.Methods[method].Outputs.Unpack(data)
|
||||
s.Require().NoError(err, "failed to unpack output")
|
||||
supply := out[0].(wrappeda0gibaseprecompile.Supply)
|
||||
s.Require().Equal(supply.Cap.Bytes(), big.NewInt(0).Bytes())
|
||||
s.Require().Equal(supply.Total.Bytes(), big.NewInt(0).Bytes())
|
||||
// fmt.Println(wa0gi)
|
||||
},
|
||||
100000,
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: s.signerOne.Addr.Bytes(),
|
||||
Cap: big.NewInt(8e18).Bytes(),
|
||||
})
|
||||
|
||||
s.wa0gibasekeeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{
|
||||
Minter: s.signerOne.Addr.Bytes(),
|
||||
Amount: big.NewInt(1e18).Bytes(),
|
||||
})
|
||||
|
||||
bz, err := s.runTx(tc.malleate(), s.signerOne, 10000000)
|
||||
|
||||
if tc.expErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errContains)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
s.Require().NotNil(bz)
|
||||
tc.postCheck(bz)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
62
precompiles/wrapped-a0gi-base/tx.go
Normal file
62
precompiles/wrapped-a0gi-base/tx.go
Normal file
@ -0,0 +1,62 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
func (w *WrappedA0giBasePrecompile) Mint(
|
||||
ctx sdk.Context,
|
||||
evm *vm.EVM,
|
||||
stateDB *statedb.StateDB,
|
||||
contract *vm.Contract,
|
||||
method *abi.Method,
|
||||
args []interface{},
|
||||
) ([]byte, error) {
|
||||
msg, err := NewMsgMint(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// validation
|
||||
wa0gi := common.BytesToAddress(w.wrappeda0gibaseKeeper.GetWA0GIAddress(ctx))
|
||||
if contract.CallerAddress != wa0gi {
|
||||
return nil, errors.New(ErrSenderNotWA0GI)
|
||||
}
|
||||
// execute
|
||||
_, err = w.wrappeda0gibaseKeeper.Mint(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
||||
|
||||
func (w *WrappedA0giBasePrecompile) Burn(
|
||||
ctx sdk.Context,
|
||||
evm *vm.EVM,
|
||||
stateDB *statedb.StateDB,
|
||||
contract *vm.Contract,
|
||||
method *abi.Method,
|
||||
args []interface{},
|
||||
) ([]byte, error) {
|
||||
msg, err := NewMsgBurn(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// validation
|
||||
wa0gi := common.BytesToAddress(w.wrappeda0gibaseKeeper.GetWA0GIAddress(ctx))
|
||||
if contract.CallerAddress != wa0gi {
|
||||
return nil, errors.New(ErrSenderNotWA0GI)
|
||||
}
|
||||
// execute
|
||||
_, err = w.wrappeda0gibaseKeeper.Burn(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
218
precompiles/wrapped-a0gi-base/tx_test.go
Normal file
218
precompiles/wrapped-a0gi-base/tx_test.go
Normal file
@ -0,0 +1,218 @@
|
||||
package wrappeda0gibase_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (s *WrappedA0giBaseTestSuite) TestMint() {
|
||||
method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionMint
|
||||
govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
malleate func() []byte
|
||||
postCheck func()
|
||||
gas uint64
|
||||
expErr bool
|
||||
errContains string
|
||||
isSignerOne bool
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerOne.Addr,
|
||||
big.NewInt(1e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {
|
||||
supply, err := s.wa0gibasekeeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{
|
||||
Address: s.signerOne.Addr.Bytes(),
|
||||
})
|
||||
s.Assert().NoError(err)
|
||||
s.Require().Equal(supply.Cap, big.NewInt(8e18).Bytes())
|
||||
s.Require().Equal(supply.Supply, big.NewInt(1e18).Bytes())
|
||||
// fmt.Println(wa0gi)
|
||||
},
|
||||
100000,
|
||||
false,
|
||||
"",
|
||||
true,
|
||||
}, {
|
||||
"fail",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerOne.Addr,
|
||||
big.NewInt(9e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {},
|
||||
100000,
|
||||
true,
|
||||
"insufficient mint cap",
|
||||
true,
|
||||
}, {
|
||||
"invalid sender",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerTwo.Addr,
|
||||
big.NewInt(9e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {},
|
||||
100000,
|
||||
true,
|
||||
"sender is not WA0GI",
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
fmt.Println(s.signerOne.Addr)
|
||||
s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr)
|
||||
s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: s.signerOne.Addr.Bytes(),
|
||||
Cap: big.NewInt(8e18).Bytes(),
|
||||
})
|
||||
|
||||
var err error
|
||||
if tc.isSignerOne {
|
||||
_, err = s.runTx(tc.malleate(), s.signerOne, 10000000)
|
||||
} else {
|
||||
_, err = s.runTx(tc.malleate(), s.signerTwo, 10000000)
|
||||
}
|
||||
|
||||
if tc.expErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errContains)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
tc.postCheck()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *WrappedA0giBaseTestSuite) TestBurn() {
|
||||
method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionBurn
|
||||
govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
malleate func() []byte
|
||||
postCheck func()
|
||||
gas uint64
|
||||
expErr bool
|
||||
errContains string
|
||||
isSignerOne bool
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerOne.Addr,
|
||||
big.NewInt(1e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {
|
||||
supply, err := s.wa0gibasekeeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{
|
||||
Address: s.signerOne.Addr.Bytes(),
|
||||
})
|
||||
s.Assert().NoError(err)
|
||||
s.Require().Equal(supply.Cap, big.NewInt(8e18).Bytes())
|
||||
s.Require().Equal(supply.Supply, big.NewInt(3e18).Bytes())
|
||||
// fmt.Println(wa0gi)
|
||||
},
|
||||
100000,
|
||||
false,
|
||||
"",
|
||||
true,
|
||||
}, {
|
||||
"fail",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerOne.Addr,
|
||||
big.NewInt(9e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {},
|
||||
100000,
|
||||
true,
|
||||
"insufficient mint supply",
|
||||
true,
|
||||
}, {
|
||||
"invalid sender",
|
||||
func() []byte {
|
||||
input, err := s.abi.Pack(
|
||||
method,
|
||||
s.signerTwo.Addr,
|
||||
big.NewInt(9e18),
|
||||
)
|
||||
s.Assert().NoError(err)
|
||||
return input
|
||||
},
|
||||
func() {},
|
||||
100000,
|
||||
true,
|
||||
"sender is not WA0GI",
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
fmt.Println(s.signerOne.Addr)
|
||||
s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr)
|
||||
s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: s.signerOne.Addr.Bytes(),
|
||||
Cap: big.NewInt(8e18).Bytes(),
|
||||
})
|
||||
s.wa0gibasekeeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{
|
||||
Minter: s.signerOne.Addr.Bytes(),
|
||||
Amount: big.NewInt(4e18).Bytes(),
|
||||
})
|
||||
|
||||
var err error
|
||||
if tc.isSignerOne {
|
||||
_, err = s.runTx(tc.malleate(), s.signerOne, 10000000)
|
||||
} else {
|
||||
_, err = s.runTx(tc.malleate(), s.signerTwo, 10000000)
|
||||
}
|
||||
|
||||
if tc.expErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errContains)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
tc.postCheck()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
51
precompiles/wrapped-a0gi-base/types.go
Normal file
51
precompiles/wrapped-a0gi-base/types.go
Normal file
@ -0,0 +1,51 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
precompiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
type Supply = struct {
|
||||
Cap *big.Int "json:\"cap\""
|
||||
Total *big.Int "json:\"total\""
|
||||
}
|
||||
|
||||
func NewGetW0GIRequest(args []interface{}) (*types.GetWA0GIRequest, error) {
|
||||
if len(args) != 0 {
|
||||
return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 0, len(args))
|
||||
}
|
||||
return &types.GetWA0GIRequest{}, nil
|
||||
}
|
||||
|
||||
func NewMinterSupplyRequest(args []interface{}) (*types.MinterSupplyRequest, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
return &types.MinterSupplyRequest{
|
||||
Address: args[0].(common.Address).Bytes(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgMint(args []interface{}) (*types.MsgMint, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
return &types.MsgMint{
|
||||
Minter: args[0].(common.Address).Bytes(),
|
||||
Amount: args[1].(*big.Int).Bytes(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgBurn(args []interface{}) (*types.MsgBurn, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
return &types.MsgBurn{
|
||||
Minter: args[0].(common.Address).Bytes(),
|
||||
Amount: args[1].(*big.Int).Bytes(),
|
||||
}, nil
|
||||
}
|
106
precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go
Normal file
106
precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go
Normal file
@ -0,0 +1,106 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
precompiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
const (
|
||||
PrecompileAddress = "0x0000000000000000000000000000000000001002"
|
||||
|
||||
// txs
|
||||
WrappedA0GIBaseFunctionMint = "mint"
|
||||
WrappedA0GIBaseFunctionBurn = "burn"
|
||||
// queries
|
||||
WrappedA0GIBaseFunctionGetWA0GI = "getWA0GI"
|
||||
WrappedA0GIBaseFunctionMinterSupply = "minterSupply"
|
||||
)
|
||||
|
||||
var _ vm.PrecompiledContract = &WrappedA0giBasePrecompile{}
|
||||
var _ precompiles_common.PrecompileCommon = &WrappedA0giBasePrecompile{}
|
||||
|
||||
type WrappedA0giBasePrecompile struct {
|
||||
abi abi.ABI
|
||||
wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper
|
||||
}
|
||||
|
||||
// Abi implements common.PrecompileCommon.
|
||||
func (w *WrappedA0giBasePrecompile) Abi() *abi.ABI {
|
||||
return &w.abi
|
||||
}
|
||||
|
||||
// IsTx implements common.PrecompileCommon.
|
||||
func (w *WrappedA0giBasePrecompile) IsTx(method string) bool {
|
||||
switch method {
|
||||
case WrappedA0GIBaseFunctionMint,
|
||||
WrappedA0GIBaseFunctionBurn:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// KVGasConfig implements common.PrecompileCommon.
|
||||
func (w *WrappedA0giBasePrecompile) KVGasConfig() storetypes.GasConfig {
|
||||
return storetypes.KVGasConfig()
|
||||
}
|
||||
|
||||
// Address implements vm.PrecompiledContract.
|
||||
func (w *WrappedA0giBasePrecompile) Address() common.Address {
|
||||
return common.HexToAddress(PrecompileAddress)
|
||||
}
|
||||
|
||||
// RequiredGas implements vm.PrecompiledContract.
|
||||
func (w *WrappedA0giBasePrecompile) RequiredGas(input []byte) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func NewWrappedA0giBasePrecompile(wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper) (*WrappedA0giBasePrecompile, error) {
|
||||
abi, err := abi.JSON(strings.NewReader(Wrappeda0gibaseABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &WrappedA0giBasePrecompile{
|
||||
abi: abi,
|
||||
wrappeda0gibaseKeeper: wrappeda0gibaseKeeper,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Run implements vm.PrecompiledContract.
|
||||
func (w *WrappedA0giBasePrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) {
|
||||
ctx, stateDB, method, initialGas, args, err := precompiles_common.InitializePrecompileCall(w, evm, contract, readonly)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var bz []byte
|
||||
switch method.Name {
|
||||
// queries
|
||||
case WrappedA0GIBaseFunctionGetWA0GI:
|
||||
bz, err = w.GetW0GI(ctx, evm, method, args)
|
||||
case WrappedA0GIBaseFunctionMinterSupply:
|
||||
bz, err = w.MinterSupply(ctx, evm, method, args)
|
||||
// txs
|
||||
case WrappedA0GIBaseFunctionMint:
|
||||
bz, err = w.Mint(ctx, evm, stateDB, contract, method, args)
|
||||
case WrappedA0GIBaseFunctionBurn:
|
||||
bz, err = w.Burn(ctx, evm, stateDB, contract, method, args)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cost := ctx.GasMeter().GasConsumed() - initialGas
|
||||
|
||||
if !contract.UseGas(cost) {
|
||||
return nil, vm.ErrOutOfGas
|
||||
}
|
||||
return bz, nil
|
||||
}
|
80
precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go
Normal file
80
precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go
Normal file
@ -0,0 +1,80 @@
|
||||
package wrappeda0gibase_test
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/precompiles/testutil"
|
||||
wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base"
|
||||
wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type WrappedA0giBaseTestSuite struct {
|
||||
testutil.PrecompileTestSuite
|
||||
|
||||
abi abi.ABI
|
||||
addr common.Address
|
||||
wa0gibasekeeper wrappeda0gibasekeeper.Keeper
|
||||
wa0gibase *wrappeda0gibaseprecompile.WrappedA0giBasePrecompile
|
||||
signerOne *testutil.TestSigner
|
||||
signerTwo *testutil.TestSigner
|
||||
}
|
||||
|
||||
func (suite *WrappedA0giBaseTestSuite) SetupTest() {
|
||||
suite.PrecompileTestSuite.SetupTest()
|
||||
|
||||
suite.wa0gibasekeeper = suite.App.GetWrappedA0GIBaseKeeper()
|
||||
|
||||
suite.addr = common.HexToAddress(wrappeda0gibaseprecompile.PrecompileAddress)
|
||||
|
||||
precompiles := suite.EvmKeeper.GetPrecompiles()
|
||||
precompile, ok := precompiles[suite.addr]
|
||||
suite.Assert().EqualValues(ok, true)
|
||||
|
||||
suite.wa0gibase = precompile.(*wrappeda0gibaseprecompile.WrappedA0giBasePrecompile)
|
||||
|
||||
suite.signerOne = suite.GenSigner()
|
||||
suite.signerTwo = suite.GenSigner()
|
||||
|
||||
abi, err := abi.JSON(strings.NewReader(wrappeda0gibaseprecompile.Wrappeda0gibaseABI))
|
||||
suite.Assert().NoError(err)
|
||||
suite.abi = abi
|
||||
}
|
||||
|
||||
func (suite *WrappedA0giBaseTestSuite) runTx(input []byte, signer *testutil.TestSigner, gas uint64) ([]byte, error) {
|
||||
contract := vm.NewPrecompile(vm.AccountRef(signer.Addr), vm.AccountRef(suite.addr), big.NewInt(0), gas)
|
||||
contract.Input = input
|
||||
|
||||
msgEthereumTx := evmtypes.NewTx(suite.EvmKeeper.ChainID(), 0, &suite.addr, big.NewInt(0), gas, big.NewInt(0), big.NewInt(0), big.NewInt(0), input, nil)
|
||||
msgEthereumTx.From = signer.HexAddr
|
||||
err := msgEthereumTx.Sign(suite.EthSigner, signer.Signer)
|
||||
suite.Assert().NoError(err, "failed to sign Ethereum message")
|
||||
|
||||
proposerAddress := suite.Ctx.BlockHeader().ProposerAddress
|
||||
cfg, err := suite.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.EvmKeeper.ChainID())
|
||||
suite.Assert().NoError(err, "failed to instantiate EVM config")
|
||||
|
||||
msg, err := msgEthereumTx.AsMessage(suite.EthSigner, big.NewInt(0))
|
||||
suite.Assert().NoError(err, "failed to instantiate Ethereum message")
|
||||
|
||||
evm := suite.EvmKeeper.NewEVM(suite.Ctx, msg, cfg, nil, suite.Statedb)
|
||||
precompiles := suite.EvmKeeper.GetPrecompiles()
|
||||
evm.WithPrecompiles(precompiles, []common.Address{suite.addr})
|
||||
|
||||
bz, err := suite.wa0gibase.Run(evm, contract, false)
|
||||
if err == nil {
|
||||
evm.StateDB.(*statedb.StateDB).Commit()
|
||||
}
|
||||
return bz, err
|
||||
}
|
||||
|
||||
func TestWrappedA0giBaseTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(WrappedA0giBaseTestSuite))
|
||||
}
|
@ -25,5 +25,5 @@ message Quorum {
|
||||
}
|
||||
|
||||
message Quorums {
|
||||
repeated Quorum quorums = 1;
|
||||
repeated Quorum quorums = 1;
|
||||
}
|
||||
|
15
proto/zgc/wrappeda0gibase/genesis.proto
Normal file
15
proto/zgc/wrappeda0gibase/genesis.proto
Normal file
@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
package zgc.wrappeda0gibase;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types";
|
||||
|
||||
// GenesisState defines the wrapped a0gi base module's genesis state.
|
||||
message GenesisState {
|
||||
// address of wrapped a0gi contract
|
||||
bytes wrapped_a0gi_address = 1;
|
||||
}
|
36
proto/zgc/wrappeda0gibase/query.proto
Normal file
36
proto/zgc/wrappeda0gibase/query.proto
Normal file
@ -0,0 +1,36 @@
|
||||
syntax = "proto3";
|
||||
package zgc.wrappeda0gibase;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Query defines the gRPC querier service for the wrapped a0gi base module
|
||||
service Query {
|
||||
rpc GetWA0GI(GetWA0GIRequest) returns (GetWA0GIResponse) {
|
||||
option (google.api.http).get = "/0g/wrapped-a0gi-base/get-wa0gi";
|
||||
}
|
||||
rpc MinterSupply(MinterSupplyRequest) returns (MinterSupplyResponse) {
|
||||
option (google.api.http).get = "/0g/wrapped-a0gi-base/minter-supply";
|
||||
}
|
||||
}
|
||||
|
||||
message GetWA0GIRequest {}
|
||||
|
||||
message GetWA0GIResponse {
|
||||
bytes address = 1;
|
||||
}
|
||||
|
||||
message MinterSupplyRequest {
|
||||
bytes address = 1;
|
||||
}
|
||||
|
||||
message MinterSupplyResponse {
|
||||
bytes cap = 1; // big endian
|
||||
bytes supply = 2; // big endian
|
||||
}
|
46
proto/zgc/wrappeda0gibase/tx.proto
Normal file
46
proto/zgc/wrappeda0gibase/tx.proto
Normal file
@ -0,0 +1,46 @@
|
||||
syntax = "proto3";
|
||||
package zgc.wrappeda0gibase;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Msg defines the wrapped a0gi base Msg service
|
||||
service Msg {
|
||||
rpc SetWA0GI(MsgSetWA0GI) returns (MsgSetWA0GIResponse);
|
||||
rpc SetMinterCap(MsgSetMintCap) returns (MsgSetMintCapResponse);
|
||||
rpc Mint(MsgMint) returns (MsgMintResponse);
|
||||
rpc Burn(MsgBurn) returns (MsgBurnResponse);
|
||||
}
|
||||
|
||||
message MsgSetWA0GI {
|
||||
string authority = 1;
|
||||
bytes address = 2;
|
||||
}
|
||||
|
||||
message MsgSetWA0GIResponse {}
|
||||
|
||||
message MsgSetMintCap {
|
||||
string authority = 1;
|
||||
bytes minter = 2;
|
||||
bytes cap = 3; // big endian
|
||||
}
|
||||
|
||||
message MsgSetMintCapResponse {}
|
||||
|
||||
message MsgMint {
|
||||
bytes minter = 1;
|
||||
bytes amount = 2; // big endian
|
||||
}
|
||||
|
||||
message MsgMintResponse {}
|
||||
|
||||
message MsgBurn {
|
||||
bytes minter = 1;
|
||||
bytes amount = 2; // big endian
|
||||
}
|
||||
|
||||
message MsgBurnResponse {}
|
@ -17,8 +17,8 @@ message BaseAccount {
|
||||
option (gogoproto.equal) = false;
|
||||
option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI";
|
||||
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"];
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"];
|
||||
uint64 account_number = 3;
|
||||
uint64 sequence = 4;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ message Metadata {
|
||||
string description = 1;
|
||||
// denom_units represents the list of DenomUnit's for a given coin
|
||||
repeated DenomUnit denom_units = 2;
|
||||
// base represents the evm denom (should be the DenomUnit with exponent = 0).
|
||||
// base represents the base denom (should be the DenomUnit with exponent = 0).
|
||||
string base = 3;
|
||||
// display indicates the suggested denom that should be
|
||||
// displayed in clients.
|
||||
|
@ -20,15 +20,15 @@ message StoreKVPair {
|
||||
// BlockMetadata contains all the abci event data of a block
|
||||
// the file streamer dump them into files together with the state changes.
|
||||
message BlockMetadata {
|
||||
// DeliverTx encapulate deliver tx request and response.
|
||||
message DeliverTx {
|
||||
tendermint.abci.RequestDeliverTx request = 1;
|
||||
tendermint.abci.ResponseDeliverTx response = 2;
|
||||
}
|
||||
tendermint.abci.RequestBeginBlock request_begin_block = 1;
|
||||
tendermint.abci.ResponseBeginBlock response_begin_block = 2;
|
||||
repeated DeliverTx deliver_txs = 3;
|
||||
tendermint.abci.RequestEndBlock request_end_block = 4;
|
||||
tendermint.abci.ResponseEndBlock response_end_block = 5;
|
||||
tendermint.abci.ResponseCommit response_commit = 6;
|
||||
// DeliverTx encapulate deliver tx request and response.
|
||||
message DeliverTx {
|
||||
tendermint.abci.RequestDeliverTx request = 1;
|
||||
tendermint.abci.ResponseDeliverTx response = 2;
|
||||
}
|
||||
tendermint.abci.RequestBeginBlock request_begin_block = 1;
|
||||
tendermint.abci.ResponseBeginBlock response_begin_block = 2;
|
||||
repeated DeliverTx deliver_txs = 3;
|
||||
tendermint.abci.RequestEndBlock request_end_block = 4;
|
||||
tendermint.abci.ResponseEndBlock response_end_block = 5;
|
||||
tendermint.abci.ResponseCommit response_commit = 6;
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ message MsgCommunityPoolSpend {
|
||||
option (amino.name) = "cosmos-sdk/distr/MsgCommunityPoolSpend";
|
||||
|
||||
// authority is the address that controls the module (defaults to x/gov unless overwritten).
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string recipient = 2;
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string recipient = 2;
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(amino.dont_omitempty) = true,
|
||||
|
@ -18,14 +18,14 @@ message Equivocation {
|
||||
option (gogoproto.equal) = false;
|
||||
|
||||
// height is the equivocation height.
|
||||
int64 height = 1;
|
||||
int64 height = 1;
|
||||
|
||||
// time is the equivocation time.
|
||||
google.protobuf.Timestamp time = 2
|
||||
google.protobuf.Timestamp time = 2
|
||||
[(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdtime) = true];
|
||||
|
||||
// power is the equivocation validator power.
|
||||
int64 power = 3;
|
||||
int64 power = 3;
|
||||
|
||||
// consensus_address is the equivocation validator consensus address.
|
||||
string consensus_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
@ -29,7 +29,7 @@ message MsgSubmitEvidence {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// submitter is the signer account address of evidence.
|
||||
string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// evidence defines the evidence of misbehavior.
|
||||
google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "cosmos.evidence.v1beta1.Evidence"];
|
||||
|
30
third_party/proto/cosmos/gov/v1/gov.proto
vendored
30
third_party/proto/cosmos/gov/v1/gov.proto
vendored
@ -32,17 +32,17 @@ message WeightedVoteOption {
|
||||
VoteOption option = 1;
|
||||
|
||||
// weight is the vote weight associated with the vote option.
|
||||
string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
|
||||
string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
|
||||
}
|
||||
|
||||
// Deposit defines an amount deposited by an account address to an active
|
||||
// proposal.
|
||||
message Deposit {
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1;
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// depositor defines the deposit addresses from the proposals.
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// amount to be deposited by depositor.
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
@ -51,33 +51,33 @@ message Deposit {
|
||||
// Proposal defines the core field members of a governance proposal.
|
||||
message Proposal {
|
||||
// id defines the unique id of the proposal.
|
||||
uint64 id = 1;
|
||||
uint64 id = 1;
|
||||
|
||||
// messages are the arbitrary messages to be executed if the proposal passes.
|
||||
repeated google.protobuf.Any messages = 2;
|
||||
|
||||
// status defines the proposal status.
|
||||
ProposalStatus status = 3;
|
||||
ProposalStatus status = 3;
|
||||
|
||||
// final_tally_result is the final tally result of the proposal. When
|
||||
// querying a proposal via gRPC, this field is not populated until the
|
||||
// proposal's voting period has ended.
|
||||
TallyResult final_tally_result = 4;
|
||||
TallyResult final_tally_result = 4;
|
||||
|
||||
// submit_time is the time of proposal submission.
|
||||
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
|
||||
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
|
||||
|
||||
// deposit_end_time is the end time for deposition.
|
||||
google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true];
|
||||
google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true];
|
||||
|
||||
// total_deposit is the total deposit on the proposal.
|
||||
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
||||
// voting_start_time is the starting time to vote on a proposal.
|
||||
google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true];
|
||||
google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true];
|
||||
|
||||
// voting_end_time is the end time of voting on a proposal.
|
||||
google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true];
|
||||
google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true];
|
||||
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
string metadata = 10;
|
||||
@ -122,11 +122,11 @@ enum ProposalStatus {
|
||||
// TallyResult defines a standard tally for a governance proposal.
|
||||
message TallyResult {
|
||||
// yes_count is the number of yes votes on a proposal.
|
||||
string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
// abstain_count is the number of abstain votes on a proposal.
|
||||
string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
// no_count is the number of no votes on a proposal.
|
||||
string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
// no_with_veto_count is the number of no with veto votes on a proposal.
|
||||
string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"];
|
||||
}
|
||||
@ -138,7 +138,7 @@ message Vote {
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// voter is the voter address of the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
reserved 3;
|
||||
|
||||
|
24
third_party/proto/cosmos/gov/v1/tx.proto
vendored
24
third_party/proto/cosmos/gov/v1/tx.proto
vendored
@ -46,13 +46,13 @@ message MsgSubmitProposal {
|
||||
option (amino.name) = "cosmos-sdk/v1/MsgSubmitProposal";
|
||||
|
||||
// messages are the arbitrary messages to be executed if proposal passes.
|
||||
repeated google.protobuf.Any messages = 1;
|
||||
repeated google.protobuf.Any messages = 1;
|
||||
|
||||
// initial_deposit is the deposit value that must be paid at proposal submission.
|
||||
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
||||
// proposer is the account address of the proposer.
|
||||
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
string metadata = 4;
|
||||
@ -95,16 +95,16 @@ message MsgVote {
|
||||
option (amino.name) = "cosmos-sdk/v1/MsgVote";
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
|
||||
// voter is the voter address for the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// option defines the vote option.
|
||||
VoteOption option = 3;
|
||||
VoteOption option = 3;
|
||||
|
||||
// metadata is any arbitrary metadata attached to the Vote.
|
||||
string metadata = 4;
|
||||
string metadata = 4;
|
||||
}
|
||||
|
||||
// MsgVoteResponse defines the Msg/Vote response type.
|
||||
@ -116,16 +116,16 @@ message MsgVoteWeighted {
|
||||
option (amino.name) = "cosmos-sdk/v1/MsgVoteWeighted";
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
|
||||
// voter is the voter address for the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// options defines the weighted vote options.
|
||||
repeated WeightedVoteOption options = 3;
|
||||
repeated WeightedVoteOption options = 3;
|
||||
|
||||
// metadata is any arbitrary metadata attached to the VoteWeighted.
|
||||
string metadata = 4;
|
||||
string metadata = 4;
|
||||
}
|
||||
|
||||
// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.
|
||||
@ -137,10 +137,10 @@ message MsgDeposit {
|
||||
option (amino.name) = "cosmos-sdk/v1/MsgDeposit";
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
|
||||
// depositor defines the deposit addresses from the proposals.
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// amount to be deposited by depositor.
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
18
third_party/proto/cosmos/gov/v1beta1/gov.proto
vendored
18
third_party/proto/cosmos/gov/v1beta1/gov.proto
vendored
@ -39,7 +39,7 @@ message WeightedVoteOption {
|
||||
VoteOption option = 1;
|
||||
|
||||
// weight is the vote weight associated with the vote option.
|
||||
string weight = 2 [
|
||||
string weight = 2 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
@ -55,7 +55,7 @@ message TextProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
// title of the proposal.
|
||||
string title = 1;
|
||||
string title = 1;
|
||||
|
||||
// description associated with the proposal.
|
||||
string description = 2;
|
||||
@ -68,10 +68,10 @@ message Deposit {
|
||||
option (gogoproto.equal) = false;
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1;
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// depositor defines the deposit addresses from the proposals.
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// amount to be deposited by depositor.
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [
|
||||
@ -86,20 +86,20 @@ message Proposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1;
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// content is the proposal's content.
|
||||
google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"];
|
||||
// status defines the proposal status.
|
||||
ProposalStatus status = 3;
|
||||
ProposalStatus status = 3;
|
||||
|
||||
// final_tally_result is the final tally result of the proposal. When
|
||||
// querying a proposal via gRPC, this field is not populated until the
|
||||
// proposal's voting period has ended.
|
||||
TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
||||
// submit_time is the time of proposal submission.
|
||||
google.protobuf.Timestamp submit_time = 5
|
||||
google.protobuf.Timestamp submit_time = 5
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
||||
// deposit_end_time is the end time for deposition.
|
||||
@ -188,7 +188,7 @@ message Vote {
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true];
|
||||
|
||||
// voter is the voter address of the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
// Deprecated: Prefer to use `options` instead. This field is set in queries
|
||||
// if and only if `len(options) == 1` and that option has weight 1. In all
|
||||
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
|
||||
|
16
third_party/proto/cosmos/gov/v1beta1/tx.proto
vendored
16
third_party/proto/cosmos/gov/v1beta1/tx.proto
vendored
@ -71,13 +71,13 @@ message MsgVote {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1;
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// voter is the voter address for the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// option defines the vote option.
|
||||
VoteOption option = 3;
|
||||
VoteOption option = 3;
|
||||
}
|
||||
|
||||
// MsgVoteResponse defines the Msg/Vote response type.
|
||||
@ -96,13 +96,13 @@ message MsgVoteWeighted {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
|
||||
// voter is the voter address for the proposal.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// options defines the weighted vote options.
|
||||
repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
}
|
||||
|
||||
// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.
|
||||
@ -121,10 +121,10 @@ message MsgDeposit {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// proposal_id defines the unique id of the proposal.
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
|
||||
|
||||
// depositor defines the deposit addresses from the proposals.
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// amount to be deposited by depositor.
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [
|
||||
|
27
third_party/proto/cosmos/mint/v1beta1/mint.proto
vendored
27
third_party/proto/cosmos/mint/v1beta1/mint.proto
vendored
@ -55,5 +55,30 @@ message Params {
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// expected blocks per year
|
||||
uint64 blocks_per_year = 6;
|
||||
uint64 blocks_per_year = 6;
|
||||
string max_staked_ratio = 7 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
string apy_at_max_staked_ratio = 8 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
string min_staked_ratio = 9 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
string apy_at_min_staked_ratio = 10 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
string decay_rate = 11 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
@ -234,18 +234,18 @@ message Tip {
|
||||
string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
}
|
||||
|
||||
// AuxSignerData is the intermediary format that an gas signer (e.g. a
|
||||
// AuxSignerData is the intermediary format that an auxiliary signer (e.g. a
|
||||
// tipper) builds and sends to the fee payer (who will build and broadcast the
|
||||
// actual tx). AuxSignerData is not a valid tx in itself, and will be rejected
|
||||
// by the node if sent directly as-is.
|
||||
//
|
||||
// Since: cosmos-sdk 0.46
|
||||
message AuxSignerData {
|
||||
// address is the bech32-encoded address of the gas signer. If using
|
||||
// address is the bech32-encoded address of the auxiliary signer. If using
|
||||
// AuxSignerData across different chains, the bech32 prefix of the target
|
||||
// chain (where the final transaction is broadcasted) should be used.
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
// sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the gas signer
|
||||
// sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer
|
||||
// signs. Note: we use the same sign doc even if we're signing with
|
||||
// LEGACY_AMINO_JSON.
|
||||
SignDocDirectAux sign_doc = 2;
|
||||
|
@ -56,13 +56,13 @@ message SoftwareUpgradeProposal {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// title of the proposal
|
||||
string title = 1;
|
||||
string title = 1;
|
||||
|
||||
// description of the proposal
|
||||
string description = 2;
|
||||
|
||||
// plan of the proposal
|
||||
Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
}
|
||||
|
||||
// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software
|
||||
@ -77,7 +77,7 @@ message CancelSoftwareUpgradeProposal {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// title of the proposal
|
||||
string title = 1;
|
||||
string title = 1;
|
||||
|
||||
// description of the proposal
|
||||
string description = 2;
|
||||
|
@ -86,8 +86,8 @@ message MsgCreatePeriodicVestingAccount {
|
||||
|
||||
option (gogoproto.equal) = false;
|
||||
|
||||
string from_address = 1;
|
||||
string to_address = 2;
|
||||
string from_address = 1;
|
||||
string to_address = 2;
|
||||
// start of vesting as unix time (in seconds).
|
||||
int64 start_time = 3;
|
||||
repeated Period vesting_periods = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
|
@ -44,7 +44,7 @@ message ContinuousVestingAccount {
|
||||
|
||||
BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
|
||||
// Vesting start time, as unix timestamp (in seconds).
|
||||
int64 start_time = 2;
|
||||
int64 start_time = 2;
|
||||
}
|
||||
|
||||
// DelayedVestingAccount implements the VestingAccount interface. It vests all
|
||||
|
19
third_party/proto/ethermint/evm/v1/evm.proto
vendored
19
third_party/proto/ethermint/evm/v1/evm.proto
vendored
@ -18,17 +18,12 @@ message Params {
|
||||
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
|
||||
// chain_config defines the EVM chain configuration parameters
|
||||
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
|
||||
// eip712_allowed_msgs contains list of allowed eip712 msgs and their types
|
||||
// list of allowed eip712 msgs and their types
|
||||
repeated EIP712AllowedMsg eip712_allowed_msgs = 6
|
||||
[(gogoproto.customname) = "EIP712AllowedMsgs", (gogoproto.nullable) = false];
|
||||
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
|
||||
// signed) transactions can be executed on the state machine.
|
||||
bool allow_unprotected_txs = 7;
|
||||
// enabled_precompiles contains list of hex-encoded evm addresses of enabled precompiled contracts.
|
||||
// Precompile must be registered before it can be enabled.
|
||||
// enabled_precompiles should be sorted in ascending order and unique.
|
||||
// sorting and uniqueness are checked against bytes representation of addresses
|
||||
repeated string enabled_precompiles = 8;
|
||||
}
|
||||
|
||||
// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
|
||||
@ -251,20 +246,20 @@ message TraceConfig {
|
||||
|
||||
// EIP712AllowedMsg stores an allowed legacy msg and its eip712 type.
|
||||
message EIP712AllowedMsg {
|
||||
// msg_type_url is a msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend"
|
||||
// msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend"
|
||||
string msg_type_url = 1;
|
||||
|
||||
// msg_value_type_name is a name of the eip712 value type. ie "MsgValueSend"
|
||||
// name of the eip712 value type. ie "MsgValueSend"
|
||||
string msg_value_type_name = 2;
|
||||
|
||||
// value_types is a list of msg value types
|
||||
// types of the msg value
|
||||
repeated EIP712MsgAttrType value_types = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
// nested_types is a list of msg value nested types
|
||||
// nested types of the msg value
|
||||
repeated EIP712NestedMsgType nested_types = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// EIP712NestedMsgType is the eip712 type of a single message.
|
||||
// EIP712MsgType is the eip712 type of a single message.
|
||||
message EIP712NestedMsgType {
|
||||
// name of the nested type. ie "Fee", "Coin"
|
||||
string name = 1;
|
||||
@ -275,8 +270,6 @@ message EIP712NestedMsgType {
|
||||
|
||||
// EIP712MsgAttrType is the eip712 type of a single message attribute.
|
||||
message EIP712MsgAttrType {
|
||||
// name
|
||||
string name = 1;
|
||||
// type
|
||||
string type = 2;
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
// DenomTrace contains the evm denomination for ICS20 fungible tokens and the
|
||||
// DenomTrace contains the base denomination for ICS20 fungible tokens and the
|
||||
// source tracing information path.
|
||||
message DenomTrace {
|
||||
// path defines the chain of port/channel identifiers used for tracing the
|
||||
// source of the fungible token.
|
||||
string path = 1;
|
||||
// evm denomination of the relayed fungible token.
|
||||
// base denomination of the relayed fungible token.
|
||||
string base_denom = 2;
|
||||
}
|
||||
|
||||
|
68
third_party/proto/tendermint/abci/types.proto
vendored
68
third_party/proto/tendermint/abci/types.proto
vendored
@ -103,8 +103,8 @@ message RequestListSnapshots {}
|
||||
|
||||
// offers a snapshot to the application
|
||||
message RequestOfferSnapshot {
|
||||
Snapshot snapshot = 1; // snapshot offered by peers
|
||||
bytes app_hash = 2; // light client-verified app hash for snapshot height
|
||||
Snapshot snapshot = 1; // snapshot offered by peers
|
||||
bytes app_hash = 2; // light client-verified app hash for snapshot height
|
||||
}
|
||||
|
||||
// loads a snapshot chunk
|
||||
@ -205,8 +205,8 @@ message ResponseInitChain {
|
||||
message ResponseQuery {
|
||||
uint32 code = 1;
|
||||
// bytes data = 2; // use "value" instead.
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
int64 index = 5;
|
||||
bytes key = 6;
|
||||
bytes value = 7;
|
||||
@ -223,15 +223,15 @@ message ResponseBeginBlock {
|
||||
message ResponseCheckTx {
|
||||
uint32 code = 1;
|
||||
bytes data = 2;
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
int64 gas_wanted = 5 [json_name = "gas_wanted"];
|
||||
int64 gas_used = 6 [json_name = "gas_used"];
|
||||
repeated Event events = 7
|
||||
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
|
||||
string codespace = 8;
|
||||
string sender = 9;
|
||||
int64 priority = 10;
|
||||
string codespace = 8;
|
||||
string sender = 9;
|
||||
int64 priority = 10;
|
||||
|
||||
// mempool_error is set by CometBFT.
|
||||
// ABCI applictions creating a ResponseCheckTX should not set mempool_error.
|
||||
@ -241,8 +241,8 @@ message ResponseCheckTx {
|
||||
message ResponseDeliverTx {
|
||||
uint32 code = 1;
|
||||
bytes data = 2;
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
string log = 3; // nondeterministic
|
||||
string info = 4; // nondeterministic
|
||||
int64 gas_wanted = 5 [json_name = "gas_wanted"];
|
||||
int64 gas_used = 6 [json_name = "gas_used"];
|
||||
repeated Event events = 7 [
|
||||
@ -273,12 +273,12 @@ message ResponseOfferSnapshot {
|
||||
Result result = 1;
|
||||
|
||||
enum Result {
|
||||
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
|
||||
ACCEPT = 1; // Snapshot accepted, apply chunks
|
||||
ABORT = 2; // Abort all snapshot restoration
|
||||
REJECT = 3; // Reject this specific snapshot, try others
|
||||
REJECT_FORMAT = 4; // Reject all snapshots of this format, try others
|
||||
REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others
|
||||
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
|
||||
ACCEPT = 1; // Snapshot accepted, apply chunks
|
||||
ABORT = 2; // Abort all snapshot restoration
|
||||
REJECT = 3; // Reject this specific snapshot, try others
|
||||
REJECT_FORMAT = 4; // Reject all snapshots of this format, try others
|
||||
REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,16 +288,16 @@ message ResponseLoadSnapshotChunk {
|
||||
|
||||
message ResponseApplySnapshotChunk {
|
||||
Result result = 1;
|
||||
repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply
|
||||
repeated string reject_senders = 3; // Chunk senders to reject and ban
|
||||
repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply
|
||||
repeated string reject_senders = 3; // Chunk senders to reject and ban
|
||||
|
||||
enum Result {
|
||||
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
|
||||
ACCEPT = 1; // Chunk successfully accepted
|
||||
ABORT = 2; // Abort all snapshot restoration
|
||||
RETRY = 3; // Retry chunk (combine with refetch and reject)
|
||||
RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject)
|
||||
REJECT_SNAPSHOT = 5; // Reject this snapshot, try others
|
||||
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
|
||||
ACCEPT = 1; // Chunk successfully accepted
|
||||
ABORT = 2; // Abort all snapshot restoration
|
||||
RETRY = 3; // Retry chunk (combine with refetch and reject)
|
||||
RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject)
|
||||
REJECT_SNAPSHOT = 5; // Reject this snapshot, try others
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ message Event {
|
||||
message EventAttribute {
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
bool index = 3; // nondeterministic
|
||||
bool index = 3; // nondeterministic
|
||||
}
|
||||
|
||||
// TxResult contains results of executing the transaction.
|
||||
@ -364,9 +364,9 @@ message TxResult {
|
||||
|
||||
// Validator
|
||||
message Validator {
|
||||
bytes address = 1; // The first 20 bytes of SHA256(public key)
|
||||
bytes address = 1; // The first 20 bytes of SHA256(public key)
|
||||
// PubKey pub_key = 2 [(gogoproto.nullable)=false];
|
||||
int64 power = 3; // The voting power
|
||||
int64 power = 3; // The voting power
|
||||
}
|
||||
|
||||
// ValidatorUpdate
|
||||
@ -384,7 +384,7 @@ message VoteInfo {
|
||||
message ExtendedVoteInfo {
|
||||
Validator validator = 1 [(gogoproto.nullable) = false];
|
||||
bool signed_last_block = 2;
|
||||
bytes vote_extension = 3; // Reserved for future use
|
||||
bytes vote_extension = 3; // Reserved for future use
|
||||
}
|
||||
|
||||
enum MisbehaviorType {
|
||||
@ -412,11 +412,11 @@ message Misbehavior {
|
||||
// State Sync Types
|
||||
|
||||
message Snapshot {
|
||||
uint64 height = 1; // The height at which the snapshot was taken
|
||||
uint32 format = 2; // The application-specific snapshot format
|
||||
uint32 chunks = 3; // Number of chunks in the snapshot
|
||||
bytes hash = 4; // Arbitrary snapshot hash, equal only if identical
|
||||
bytes metadata = 5; // Arbitrary application metadata
|
||||
uint64 height = 1; // The height at which the snapshot was taken
|
||||
uint32 format = 2; // The application-specific snapshot format
|
||||
uint32 chunks = 3; // Number of chunks in the snapshot
|
||||
bytes hash = 4; // Arbitrary snapshot hash, equal only if identical
|
||||
bytes metadata = 5; // Arbitrary application metadata
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
@ -30,7 +30,7 @@ message LightClientAttackEvidence {
|
||||
int64 common_height = 2;
|
||||
repeated tendermint.types.Validator byzantine_validators = 3;
|
||||
int64 total_voting_power = 4;
|
||||
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
}
|
||||
|
||||
message EvidenceList {
|
||||
|
@ -26,7 +26,7 @@ message BlockParams {
|
||||
// Note: must be greater or equal to -1
|
||||
int64 max_gas = 2;
|
||||
|
||||
reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792
|
||||
reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792
|
||||
}
|
||||
|
||||
// EvidenceParams determine how we handle evidence of malfeasance.
|
||||
|
28
third_party/proto/tendermint/types/types.proto
vendored
28
third_party/proto/tendermint/types/types.proto
vendored
@ -66,19 +66,19 @@ message Header {
|
||||
BlockID last_block_id = 5 [(gogoproto.nullable) = false];
|
||||
|
||||
// hashes of block data
|
||||
bytes last_commit_hash = 6; // commit from validators from the last block
|
||||
bytes data_hash = 7; // transactions
|
||||
bytes last_commit_hash = 6; // commit from validators from the last block
|
||||
bytes data_hash = 7; // transactions
|
||||
|
||||
// hashes from the app output from the prev block
|
||||
bytes validators_hash = 8; // validators for the current block
|
||||
bytes next_validators_hash = 9; // validators for the next block
|
||||
bytes consensus_hash = 10; // consensus params for current block
|
||||
bytes app_hash = 11; // state after txs from the previous block
|
||||
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
|
||||
bytes validators_hash = 8; // validators for the current block
|
||||
bytes next_validators_hash = 9; // validators for the next block
|
||||
bytes consensus_hash = 10; // consensus params for current block
|
||||
bytes app_hash = 11; // state after txs from the previous block
|
||||
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
|
||||
|
||||
// consensus info
|
||||
bytes evidence_hash = 13; // evidence included in the block
|
||||
bytes proposer_address = 14; // original proposer of the block
|
||||
bytes evidence_hash = 13; // evidence included in the block
|
||||
bytes proposer_address = 14; // original proposer of the block
|
||||
}
|
||||
|
||||
// Data contains the set of transactions included in the block
|
||||
@ -99,9 +99,9 @@ message Vote {
|
||||
[(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil.
|
||||
google.protobuf.Timestamp timestamp = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes validator_address = 6;
|
||||
int32 validator_index = 7;
|
||||
bytes signature = 8;
|
||||
bytes validator_address = 6;
|
||||
int32 validator_index = 7;
|
||||
bytes signature = 8;
|
||||
}
|
||||
|
||||
// Commit contains the evidence that a block was committed by a set of validators.
|
||||
@ -118,7 +118,7 @@ message CommitSig {
|
||||
bytes validator_address = 2;
|
||||
google.protobuf.Timestamp timestamp = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes signature = 4;
|
||||
bytes signature = 4;
|
||||
}
|
||||
|
||||
message Proposal {
|
||||
@ -129,7 +129,7 @@ message Proposal {
|
||||
BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false];
|
||||
google.protobuf.Timestamp timestamp = 6
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes signature = 7;
|
||||
bytes signature = 7;
|
||||
}
|
||||
|
||||
message SignedHeader {
|
||||
|
23
x/wrapped-a0gi-base/cli/query.go
Normal file
23
x/wrapped-a0gi-base/cli/query.go
Normal file
@ -0,0 +1,23 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for the inflation module.
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Querying commands for the wrapped a0gi base module",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand()
|
||||
|
||||
return cmd
|
||||
}
|
22
x/wrapped-a0gi-base/cli/tx.go
Normal file
22
x/wrapped-a0gi-base/cli/tx.go
Normal file
@ -0,0 +1,22 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetTxCmd returns the transaction commands for this module
|
||||
func GetTxCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
cmd.AddCommand()
|
||||
return cmd
|
||||
}
|
25
x/wrapped-a0gi-base/genesis.go
Normal file
25
x/wrapped-a0gi-base/genesis.go
Normal file
@ -0,0 +1,25 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the store state from a genesis state.
|
||||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) {
|
||||
if err := gs.Validate(); err != nil {
|
||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
||||
}
|
||||
keeper.SetWA0GIAddress(ctx, common.BytesToAddress(gs.WrappedA0GiAddress))
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
|
||||
return &types.GenesisState{
|
||||
WrappedA0GiAddress: keeper.GetWA0GIAddress(ctx),
|
||||
}
|
||||
}
|
67
x/wrapped-a0gi-base/genesis_test.go
Normal file
67
x/wrapped-a0gi-base/genesis_test.go
Normal file
@ -0,0 +1,67 @@
|
||||
package wrappeda0gibase_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
wrappeda0gibase "github.com/0glabs/0g-chain/x/wrapped-a0gi-base"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
)
|
||||
|
||||
type GenesisTestSuite struct {
|
||||
testutil.Suite
|
||||
}
|
||||
|
||||
func (suite *GenesisTestSuite) TestInitGenesis() {
|
||||
// Most genesis validation tests are located in the types directory. The 'invalid' test cases are
|
||||
// randomly selected subset of those tests.
|
||||
testCases := []struct {
|
||||
name string
|
||||
genState *types.GenesisState
|
||||
expectPass bool
|
||||
}{
|
||||
{
|
||||
name: "default genesis",
|
||||
genState: types.DefaultGenesisState(),
|
||||
expectPass: true,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
suite.Run(tc.name, func() {
|
||||
// Setup (note: suite.SetupTest is not run before every suite.Run)
|
||||
suite.App = app.NewTestApp()
|
||||
suite.Keeper = suite.App.GetWrappedA0GIBaseKeeper()
|
||||
suite.Ctx = suite.App.NewContext(true, tmproto.Header{})
|
||||
|
||||
// Run
|
||||
var exportedGenState *types.GenesisState
|
||||
run := func() {
|
||||
wrappeda0gibase.InitGenesis(suite.Ctx, suite.Keeper, *tc.genState)
|
||||
exportedGenState = wrappeda0gibase.ExportGenesis(suite.Ctx, suite.Keeper)
|
||||
}
|
||||
if tc.expectPass {
|
||||
suite.Require().NotPanics(run)
|
||||
} else {
|
||||
suite.Require().Panics(run)
|
||||
}
|
||||
|
||||
// Check
|
||||
if tc.expectPass {
|
||||
expectedJson, err := suite.App.AppCodec().MarshalJSON(tc.genState)
|
||||
suite.Require().NoError(err)
|
||||
actualJson, err := suite.App.AppCodec().MarshalJSON(exportedGenState)
|
||||
suite.Require().NoError(err)
|
||||
suite.Equal(expectedJson, actualJson)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenesisTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(GenesisTestSuite))
|
||||
}
|
8
x/wrapped-a0gi-base/keeper/abci.go
Normal file
8
x/wrapped-a0gi-base/keeper/abci.go
Normal file
@ -0,0 +1,8 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {}
|
37
x/wrapped-a0gi-base/keeper/grpc_query.go
Normal file
37
x/wrapped-a0gi-base/keeper/grpc_query.go
Normal file
@ -0,0 +1,37 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
||||
|
||||
// MinterSupply implements types.QueryServer.
|
||||
func (k Keeper) MinterSupply(c context.Context, request *types.MinterSupplyRequest) (*types.MinterSupplyResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
account := common.BytesToAddress(request.Address)
|
||||
cap, err := k.getMinterCap(ctx, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
supply, err := k.getMinterSupply(ctx, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MinterSupplyResponse{
|
||||
Cap: cap.Bytes(),
|
||||
Supply: supply.Bytes(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetWA0GI implements types.QueryServer.
|
||||
func (k Keeper) GetWA0GI(c context.Context, request *types.GetWA0GIRequest) (*types.GetWA0GIResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
return &types.GetWA0GIResponse{
|
||||
Address: k.GetWA0GIAddress(ctx),
|
||||
}, nil
|
||||
}
|
71
x/wrapped-a0gi-base/keeper/keeper.go
Normal file
71
x/wrapped-a0gi-base/keeper/keeper.go
Normal file
@ -0,0 +1,71 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
precisebankkeeper "github.com/0glabs/0g-chain/x/precisebank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
type Keeper struct {
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
pbkeeper precisebankkeeper.Keeper
|
||||
authority string // the address capable of changing signers params. Should be the gov module account
|
||||
}
|
||||
|
||||
// NewKeeper creates a new wrapped a0gi base keeper instance
|
||||
func NewKeeper(
|
||||
storeKey storetypes.StoreKey,
|
||||
cdc codec.BinaryCodec,
|
||||
pbkeeper precisebankkeeper.Keeper,
|
||||
authority string,
|
||||
) Keeper {
|
||||
return Keeper{
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
pbkeeper: pbkeeper,
|
||||
authority: authority,
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) SetWA0GIAddress(ctx sdk.Context, addr common.Address) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(types.WA0GIKey, addr.Bytes())
|
||||
}
|
||||
|
||||
func (k Keeper) GetWA0GIAddress(ctx sdk.Context) []byte {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.WA0GIKey)
|
||||
return bz
|
||||
}
|
||||
|
||||
func (k Keeper) setMinterCap(ctx sdk.Context, account common.Address, cap *big.Int) error {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterCapKeyPrefix)
|
||||
store.Set(account.Bytes(), cap.Bytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMinterCap(ctx sdk.Context, account common.Address) (*big.Int, error) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterCapKeyPrefix)
|
||||
bz := store.Get(account.Bytes())
|
||||
return new(big.Int).SetBytes(bz), nil
|
||||
}
|
||||
|
||||
func (k Keeper) setMinterSupply(ctx sdk.Context, account common.Address, supply *big.Int) error {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterSupplyKeyPrefix)
|
||||
store.Set(account.Bytes(), supply.Bytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMinterSupply(ctx sdk.Context, account common.Address) (*big.Int, error) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterSupplyKeyPrefix)
|
||||
bz := store.Get(account.Bytes())
|
||||
return new(big.Int).SetBytes(bz), nil
|
||||
}
|
40
x/wrapped-a0gi-base/keeper/keeper_test.go
Normal file
40
x/wrapped-a0gi-base/keeper/keeper_test.go
Normal file
@ -0,0 +1,40 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
testutil.Suite
|
||||
}
|
||||
|
||||
func (s *KeeperTestSuite) TestSetWA0GIAddress() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
wa0gi common.Address
|
||||
}{
|
||||
{
|
||||
name: "zero address",
|
||||
wa0gi: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
s.Keeper.SetWA0GIAddress(s.Ctx, tc.wa0gi)
|
||||
response, err := s.Keeper.GetWA0GI(s.Ctx, &types.GetWA0GIRequest{})
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(common.BytesToAddress(response.Address), tc.wa0gi)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeeperSuite(t *testing.T) {
|
||||
suite.Run(t, new(KeeperTestSuite))
|
||||
}
|
96
x/wrapped-a0gi-base/keeper/msg_server.go
Normal file
96
x/wrapped-a0gi-base/keeper/msg_server.go
Normal file
@ -0,0 +1,96 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = &Keeper{}
|
||||
|
||||
// Burn implements types.MsgServer.
|
||||
func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
minter := common.BytesToAddress(msg.Minter)
|
||||
supply, err := k.getMinterSupply(ctx, minter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
amount := new(big.Int).SetBytes(msg.Amount)
|
||||
// check & update mint supply
|
||||
supply.Sub(supply, amount)
|
||||
if supply.Cmp(big.NewInt(0)) < 0 {
|
||||
return nil, types.ErrInsufficientMintSupply
|
||||
}
|
||||
// burn
|
||||
c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount))
|
||||
if err = k.pbkeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = k.setMinterSupply(ctx, minter, supply); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgBurnResponse{}, nil
|
||||
}
|
||||
|
||||
// Mint implements types.MsgServer.
|
||||
func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
minter := common.BytesToAddress(msg.Minter)
|
||||
cap, err := k.getMinterCap(ctx, minter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
supply, err := k.getMinterSupply(ctx, minter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
amount := new(big.Int).SetBytes(msg.Amount)
|
||||
// check & update mint supply
|
||||
supply.Add(supply, amount)
|
||||
if supply.Cmp(cap) > 0 {
|
||||
return nil, types.ErrInsufficientMintCap
|
||||
}
|
||||
// mint
|
||||
c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount))
|
||||
if err = k.pbkeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = k.setMinterSupply(ctx, minter, supply); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgMintResponse{}, nil
|
||||
}
|
||||
|
||||
// SetMinterCap implements types.MsgServer.
|
||||
func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMintCap) (*types.MsgSetMintCapResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
minter := common.BytesToAddress(msg.Minter)
|
||||
// validate authority
|
||||
if k.authority != msg.Authority {
|
||||
return nil, errorsmod.Wrapf(gov.ErrInvalidSigner, "expected %s got %s", k.authority, msg.Authority)
|
||||
}
|
||||
// update minter cap
|
||||
if err := k.setMinterCap(ctx, minter, new(big.Int).SetBytes(msg.Cap)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgSetMintCapResponse{}, nil
|
||||
}
|
||||
|
||||
// SetWA0GI implements types.MsgServer.
|
||||
func (k Keeper) SetWA0GI(goCtx context.Context, msg *types.MsgSetWA0GI) (*types.MsgSetWA0GIResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
// validate authority
|
||||
if k.authority != msg.Authority {
|
||||
return nil, errorsmod.Wrapf(gov.ErrInvalidSigner, "expected %s got %s", k.authority, msg.Authority)
|
||||
}
|
||||
// save new address
|
||||
k.SetWA0GIAddress(ctx, common.BytesToAddress(msg.Address))
|
||||
return &types.MsgSetWA0GIResponse{}, nil
|
||||
}
|
284
x/wrapped-a0gi-base/keeper/msg_server_test.go
Normal file
284
x/wrapped-a0gi-base/keeper/msg_server_test.go
Normal file
@ -0,0 +1,284 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type MsgServerTestSuite struct {
|
||||
testutil.Suite
|
||||
}
|
||||
|
||||
func (s *MsgServerTestSuite) TestSetWA0GI() {
|
||||
govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
testCases := []struct {
|
||||
name string
|
||||
req *types.MsgSetWA0GI
|
||||
expectErr bool
|
||||
errMsg string
|
||||
}{
|
||||
{
|
||||
name: "invalid signer",
|
||||
req: &types.MsgSetWA0GI{
|
||||
Authority: s.Addresses[0].String(),
|
||||
Address: common.HexToAddress("0x0000000000000000000000000000000000000001").Bytes(),
|
||||
},
|
||||
expectErr: true,
|
||||
errMsg: "expected gov account as only signer for proposal message",
|
||||
},
|
||||
{
|
||||
name: "success",
|
||||
req: &types.MsgSetWA0GI{
|
||||
Authority: govAccAddr,
|
||||
Address: common.HexToAddress("0x0000000000000000000000000000000000000001").Bytes(),
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
_, err := s.Keeper.SetWA0GI(sdk.WrapSDKContext(s.Ctx), tc.req)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errMsg)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
response, err := s.Keeper.GetWA0GI(s.Ctx, &types.GetWA0GIRequest{})
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(response.Address, tc.req.Address)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MsgServerTestSuite) TestSetMinterCap() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
caps []struct {
|
||||
account common.Address
|
||||
cap *big.Int
|
||||
}
|
||||
}{
|
||||
{
|
||||
name: "success",
|
||||
caps: []struct {
|
||||
account common.Address
|
||||
cap *big.Int
|
||||
}{
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||
cap: big.NewInt(100000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000001"),
|
||||
cap: big.NewInt(200000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000002"),
|
||||
cap: big.NewInt(300000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000003"),
|
||||
cap: big.NewInt(400000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000002"),
|
||||
cap: big.NewInt(500000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000001"),
|
||||
cap: big.NewInt(600000),
|
||||
},
|
||||
{
|
||||
account: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||
cap: big.NewInt(700000),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
s.Run("invalid authority", func() {
|
||||
s.SetupTest()
|
||||
_, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: s.Addresses[0].String(),
|
||||
Minter: common.HexToAddress("0x0000000000000000000000000000000000000000").Bytes(),
|
||||
Cap: big.NewInt(600000).Bytes(),
|
||||
})
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), "expected gov account as only signer for proposal message")
|
||||
})
|
||||
govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
s.SetupTest()
|
||||
|
||||
c := make(map[common.Address]*big.Int)
|
||||
for _, cap := range tc.caps {
|
||||
_, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: cap.account.Bytes(),
|
||||
Cap: cap.cap.Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{
|
||||
Address: cap.account.Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(new(big.Int).SetBytes(response.Cap), cap.cap)
|
||||
c[cap.account] = cap.cap
|
||||
}
|
||||
for account, cap := range c {
|
||||
response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{
|
||||
Address: account.Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(new(big.Int).SetBytes(response.Cap), cap)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type MintBurn struct {
|
||||
IsMint bool
|
||||
Minter common.Address
|
||||
Amount *big.Int
|
||||
Success bool
|
||||
}
|
||||
|
||||
func (s *MsgServerTestSuite) TestSetMintBurn() {
|
||||
precisebankKeeper := s.App.GetPrecisebankKeeper()
|
||||
accountKeeper := s.App.GetAccountKeeper()
|
||||
moduleAcc := accountKeeper.GetModuleAccount(s.Ctx, types.ModuleName).GetAddress()
|
||||
govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String()
|
||||
|
||||
minter1 := common.HexToAddress("0x0000000000000000000000000000000000000001")
|
||||
minter2 := common.HexToAddress("0x0000000000000000000000000000000000000002")
|
||||
|
||||
// set mint cap of minter 1 to 8 a0gi
|
||||
_, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: minter1.Bytes(),
|
||||
Cap: big.NewInt(8e18).Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
// set mint cap of minter 2 to 5 a0gi
|
||||
_, err = s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{
|
||||
Authority: govAccAddr,
|
||||
Minter: minter2.Bytes(),
|
||||
Cap: big.NewInt(5e18).Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
testCases := []MintBurn{
|
||||
// #0, failed burn
|
||||
{
|
||||
IsMint: false,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(1e18),
|
||||
Success: false,
|
||||
},
|
||||
// #1, mint 5 a0gi by minter 1
|
||||
{
|
||||
IsMint: true,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(5e18),
|
||||
Success: true,
|
||||
},
|
||||
// #2, burn 0.5 a0gi by minter 1
|
||||
{
|
||||
IsMint: false,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(5e17),
|
||||
Success: true,
|
||||
},
|
||||
// #3, mint 0.7 a0gi by minter 2
|
||||
{
|
||||
IsMint: true,
|
||||
Minter: minter2,
|
||||
Amount: big.NewInt(7e17),
|
||||
Success: true,
|
||||
},
|
||||
// #4, mint 2 a0gi by minter 2
|
||||
{
|
||||
IsMint: true,
|
||||
Minter: minter2,
|
||||
Amount: big.NewInt(2e18),
|
||||
Success: true,
|
||||
},
|
||||
// #5, burn 0.3 a0gi by minter 2
|
||||
{
|
||||
IsMint: false,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(3e17),
|
||||
Success: true,
|
||||
},
|
||||
// #6, failed to mint 4 a0gi by minter 1
|
||||
{
|
||||
IsMint: true,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(4e18),
|
||||
Success: false,
|
||||
},
|
||||
// #7, mint 3.5 a0gi by minter 1
|
||||
{
|
||||
IsMint: true,
|
||||
Minter: minter1,
|
||||
Amount: big.NewInt(3e18 + 5e17),
|
||||
Success: true,
|
||||
},
|
||||
}
|
||||
minted := big.NewInt(0)
|
||||
supplied := make(map[common.Address]*big.Int)
|
||||
for id, c := range testCases {
|
||||
fmt.Println(id)
|
||||
if c.IsMint {
|
||||
_, err = s.Keeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{
|
||||
Minter: c.Minter.Bytes(),
|
||||
Amount: c.Amount.Bytes(),
|
||||
})
|
||||
} else {
|
||||
_, err = s.Keeper.Burn(sdk.WrapSDKContext(s.Ctx), &types.MsgBurn{
|
||||
Minter: c.Minter.Bytes(),
|
||||
Amount: c.Amount.Bytes(),
|
||||
})
|
||||
}
|
||||
if c.Success {
|
||||
if c.IsMint {
|
||||
minted.Add(minted, c.Amount)
|
||||
if amt, ok := supplied[c.Minter]; ok {
|
||||
amt.Add(amt, c.Amount)
|
||||
} else {
|
||||
supplied[c.Minter] = new(big.Int).Set(c.Amount)
|
||||
}
|
||||
} else {
|
||||
minted.Sub(minted, c.Amount)
|
||||
if amt, ok := supplied[c.Minter]; ok {
|
||||
amt.Sub(amt, c.Amount)
|
||||
} else {
|
||||
supplied[c.Minter] = new(big.Int).Set(c.Amount)
|
||||
}
|
||||
}
|
||||
s.Require().NoError(err)
|
||||
response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{
|
||||
Address: c.Minter.Bytes(),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(supplied[c.Minter].Bytes(), response.Supply)
|
||||
} else {
|
||||
s.Require().Error(err)
|
||||
}
|
||||
coins := precisebankKeeper.GetBalance(s.Ctx, moduleAcc, precisebanktypes.ExtendedCoinDenom)
|
||||
s.Require().Equal(coins.Amount.BigInt(), minted)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMsgServerSuite(t *testing.T) {
|
||||
suite.Run(t, new(MsgServerTestSuite))
|
||||
}
|
168
x/wrapped-a0gi-base/module.go
Normal file
168
x/wrapped-a0gi-base/module.go
Normal file
@ -0,0 +1,168 @@
|
||||
package wrappeda0gibase
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/cli"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// consensusVersion defines the current x/council module consensus version.
|
||||
const consensusVersion = 1
|
||||
|
||||
// type check to ensure the interface is properly implemented
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// app module Basics object
|
||||
type AppModuleBasic struct{}
|
||||
|
||||
// Name returns the inflation module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec.
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
||||
|
||||
// ConsensusVersion returns the consensus state-breaking version for the module.
|
||||
func (AppModuleBasic) ConsensusVersion() uint64 {
|
||||
return consensusVersion
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers interfaces and implementations of the incentives
|
||||
// module.
|
||||
func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(interfaceRegistry)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the incentives
|
||||
// module.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the inflation module.
|
||||
func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
|
||||
var genesisState types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
|
||||
return genesisState.Validate()
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST
|
||||
// endpoints
|
||||
func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module.
|
||||
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) {
|
||||
if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the inflation module.
|
||||
func (AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.GetTxCmd()
|
||||
}
|
||||
|
||||
// GetQueryCmd returns no root query command for the inflation module.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
||||
// AppModule implements an application module for the inflation module.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper keeper.Keeper
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule Object
|
||||
func NewAppModule(
|
||||
k keeper.Keeper,
|
||||
) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{},
|
||||
keeper: k,
|
||||
}
|
||||
}
|
||||
|
||||
// Name returns the inflation module's name.
|
||||
func (AppModule) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// QuerierRoute returns wrapped a0gi base module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return types.QuerierRoute }
|
||||
|
||||
// RegisterInvariants registers the inflation module invariants.
|
||||
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
||||
|
||||
// RegisterServices registers a gRPC query service to respond to the
|
||||
// module-specific gRPC queries.
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
|
||||
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
||||
am.keeper.BeginBlock(ctx, req)
|
||||
}
|
||||
|
||||
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
|
||||
// am.keeper.EndBlock(ctx, req)
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the inflation module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState types.GenesisState
|
||||
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
InitGenesis(ctx, am.keeper, genesisState)
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the inflation
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
||||
// AppModuleSimulation functions
|
||||
|
||||
// GenerateGenesisState creates a randomized GenState of the inflation module.
|
||||
func (am AppModule) GenerateGenesisState(_ *module.SimulationState) {
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder registers a decoder for inflation module's types.
|
||||
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {
|
||||
}
|
||||
|
||||
// WeightedOperations doesn't return any inflation module operation.
|
||||
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
|
||||
return []simtypes.WeightedOperation{}
|
||||
}
|
66
x/wrapped-a0gi-base/testutil/suite.go
Normal file
66
x/wrapped-a0gi-base/testutil/suite.go
Normal file
@ -0,0 +1,66 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper"
|
||||
"github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"
|
||||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/evmos/ethermint/crypto/ethsecp256k1"
|
||||
)
|
||||
|
||||
// Suite implements a test suite for the module integration tests
|
||||
type Suite struct {
|
||||
suite.Suite
|
||||
|
||||
Keeper keeper.Keeper
|
||||
StakingKeeper *stakingkeeper.Keeper
|
||||
GovKeeper govkeeper.Keeper
|
||||
App app.TestApp
|
||||
Ctx sdk.Context
|
||||
QueryClient types.QueryClient
|
||||
Addresses []sdk.AccAddress
|
||||
}
|
||||
|
||||
// SetupTest instantiates a new app, keepers, and sets suite state
|
||||
func (suite *Suite) SetupTest() {
|
||||
chaincfg.SetSDKConfig()
|
||||
suite.App = app.NewTestApp()
|
||||
suite.App.InitializeFromGenesisStates()
|
||||
suite.Keeper = suite.App.GetWrappedA0GIBaseKeeper()
|
||||
suite.GovKeeper = suite.App.GetGovKeeper()
|
||||
suite.StakingKeeper = suite.App.GetStakingKeeper()
|
||||
|
||||
// make block header
|
||||
privkey, _ := ethsecp256k1.GenerateKey()
|
||||
consAddress := sdk.ConsAddress(privkey.PubKey().Address())
|
||||
key, err := privkey.ToECDSA()
|
||||
suite.Assert().NoError(err)
|
||||
hexAddr := strings.ToLower(crypto.PubkeyToAddress(key.PublicKey).Hex()[2:])
|
||||
valAddr, err := sdk.ValAddressFromHex(hexAddr)
|
||||
suite.Assert().NoError(err)
|
||||
suite.Ctx = suite.App.NewContext(true, tmproto.Header{Height: 1, ChainID: app.TestChainId, ProposerAddress: consAddress})
|
||||
newValidator, err := stakingtypes.NewValidator(valAddr, privkey.PubKey(), stakingtypes.Description{})
|
||||
suite.Assert().NoError(err)
|
||||
err = suite.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, newValidator)
|
||||
suite.Assert().NoError(err)
|
||||
suite.StakingKeeper.SetValidator(suite.Ctx, newValidator)
|
||||
|
||||
_, accAddresses := app.GeneratePrivKeyAddressPairs(10)
|
||||
suite.Addresses = accAddresses
|
||||
|
||||
// Set query client
|
||||
queryHelper := suite.App.NewQueryServerTestHelper(suite.Ctx)
|
||||
queryHandler := suite.Keeper
|
||||
types.RegisterQueryServer(queryHelper, queryHandler)
|
||||
suite.QueryClient = types.NewQueryClient(queryHelper)
|
||||
}
|
25
x/wrapped-a0gi-base/testutil/types.go
Normal file
25
x/wrapped-a0gi-base/testutil/types.go
Normal file
@ -0,0 +1,25 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Avoid cluttering test cases with long function names
|
||||
func I(in int64) sdkmath.Int { return sdkmath.NewInt(in) }
|
||||
func D(str string) sdk.Dec { return sdk.MustNewDecFromStr(str) }
|
||||
func C(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
||||
func Cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|
||||
|
||||
func AssertProtoMessageJSON(t *testing.T, cdc codec.Codec, expected proto.Message, actual proto.Message) {
|
||||
expectedJson, err := cdc.MarshalJSON(expected)
|
||||
assert.NoError(t, err)
|
||||
actualJson, err := cdc.MarshalJSON(actual)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, string(expectedJson), string(actualJson))
|
||||
}
|
45
x/wrapped-a0gi-base/types/codec.go
Normal file
45
x/wrapped-a0gi-base/types/codec.go
Normal file
@ -0,0 +1,45 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
// ModuleCdc references the global evm module codec. Note, the codec should
|
||||
// ONLY be used in certain instances of tests and for JSON encoding.
|
||||
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
|
||||
|
||||
// AminoCdc is a amino codec created to support amino JSON compatible msgs.
|
||||
AminoCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
const (
|
||||
// Amino names
|
||||
)
|
||||
|
||||
// NOTE: This is required for the GetSignBytes function
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
amino.Seal()
|
||||
}
|
||||
|
||||
// RegisterInterfaces register implementations
|
||||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*sdk.Msg)(nil),
|
||||
&MsgSetWA0GI{},
|
||||
&MsgSetMintCap{},
|
||||
&MsgMint{},
|
||||
&MsgBurn{},
|
||||
)
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec required for EIP-712
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
}
|
9
x/wrapped-a0gi-base/types/errors.go
Normal file
9
x/wrapped-a0gi-base/types/errors.go
Normal file
@ -0,0 +1,9 @@
|
||||
package types
|
||||
|
||||
import errorsmod "cosmossdk.io/errors"
|
||||
|
||||
var (
|
||||
ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden")
|
||||
ErrInsufficientMintCap = errorsmod.Register(ModuleName, 2, "insufficient mint cap")
|
||||
ErrInsufficientMintSupply = errorsmod.Register(ModuleName, 3, "insufficient mint supply")
|
||||
)
|
33
x/wrapped-a0gi-base/types/genesis.go
Normal file
33
x/wrapped-a0gi-base/types/genesis.go
Normal file
File diff suppressed because one or more lines are too long
328
x/wrapped-a0gi-base/types/genesis.pb.go
Normal file
328
x/wrapped-a0gi-base/types/genesis.pb.go
Normal file
@ -0,0 +1,328 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: zgc/wrappeda0gibase/genesis.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the wrapped a0gi base module's genesis state.
|
||||
type GenesisState struct {
|
||||
// address of wrapped a0gi contract
|
||||
WrappedA0GiAddress []byte `protobuf:"bytes,1,opt,name=wrapped_a0gi_address,json=wrappedA0giAddress,proto3" json:"wrapped_a0gi_address,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
|
||||
func (*GenesisState) ProtoMessage() {}
|
||||
func (*GenesisState) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_7e056019f61fd820, []int{0}
|
||||
}
|
||||
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *GenesisState) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GenesisState.Merge(m, src)
|
||||
}
|
||||
func (m *GenesisState) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GenesisState) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GenesisState.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
|
||||
|
||||
func (m *GenesisState) GetWrappedA0GiAddress() []byte {
|
||||
if m != nil {
|
||||
return m.WrappedA0GiAddress
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GenesisState)(nil), "zgc.wrappeda0gibase.GenesisState")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("zgc/wrappeda0gibase/genesis.proto", fileDescriptor_7e056019f61fd820) }
|
||||
|
||||
var fileDescriptor_7e056019f61fd820 = []byte{
|
||||
// 246 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbd, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x80, 0xe3, 0x85, 0x21, 0xea, 0x14, 0x3a, 0xd0, 0x0e, 0xe6, 0x67, 0x62, 0x49, 0x6c, 0x09,
|
||||
0x1e, 0x80, 0xb2, 0xb0, 0x31, 0xc0, 0xc6, 0x12, 0xd9, 0x8e, 0xb9, 0x5a, 0x6a, 0x72, 0x56, 0xce,
|
||||
0x15, 0xb4, 0x4f, 0xc1, 0x63, 0x31, 0x76, 0x64, 0x44, 0xc9, 0x8b, 0xa0, 0xc4, 0x61, 0xc9, 0xe6,
|
||||
0xbb, 0xef, 0x93, 0xfc, 0xe9, 0xd2, 0xeb, 0x23, 0x18, 0xf1, 0xd1, 0x2a, 0xef, 0x6d, 0xa5, 0x24,
|
||||
0x38, 0xad, 0xc8, 0x0a, 0xb0, 0x8d, 0x25, 0x47, 0x85, 0x6f, 0x31, 0x60, 0x76, 0x7e, 0x04, 0x53,
|
||||
0xcc, 0x94, 0xf5, 0xca, 0x20, 0xd5, 0x48, 0xe5, 0xa8, 0x88, 0x38, 0x44, 0x7f, 0xbd, 0x04, 0x04,
|
||||
0x8c, 0xfb, 0xe1, 0x35, 0x6d, 0x57, 0x80, 0x08, 0x3b, 0x2b, 0xc6, 0x49, 0xef, 0xdf, 0x85, 0x6a,
|
||||
0x0e, 0x13, 0xba, 0x9c, 0xa3, 0xe0, 0x6a, 0x4b, 0x41, 0xd5, 0x3e, 0x0a, 0x37, 0x0f, 0xe9, 0xe2,
|
||||
0x29, 0x26, 0xbd, 0x06, 0x15, 0x6c, 0x26, 0xd3, 0xe5, 0xd4, 0x53, 0x0e, 0x41, 0xa5, 0xaa, 0xaa,
|
||||
0xd6, 0x12, 0x5d, 0xb0, 0x2b, 0x76, 0xbb, 0x78, 0xc9, 0x26, 0xb6, 0x91, 0xe0, 0x36, 0x91, 0x3c,
|
||||
0x3e, 0x7f, 0x77, 0x9c, 0x9d, 0x3a, 0xce, 0x7e, 0x3b, 0xce, 0xbe, 0x7a, 0x9e, 0x9c, 0x7a, 0x9e,
|
||||
0xfc, 0xf4, 0x3c, 0x79, 0xbb, 0x07, 0x17, 0xb6, 0x7b, 0x5d, 0x18, 0xac, 0x85, 0x84, 0x9d, 0xd2,
|
||||
0x24, 0x24, 0xe4, 0x66, 0xab, 0x5c, 0x23, 0x3e, 0xff, 0x2f, 0x93, 0x0f, 0xdf, 0xe4, 0xe3, 0x6d,
|
||||
0xc2, 0xc1, 0x5b, 0xd2, 0x67, 0x63, 0xd8, 0xdd, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xec, 0x50,
|
||||
0x04, 0x4c, 0x3f, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.WrappedA0GiAddress) > 0 {
|
||||
i -= len(m.WrappedA0GiAddress)
|
||||
copy(dAtA[i:], m.WrappedA0GiAddress)
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.WrappedA0GiAddress)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovGenesis(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *GenesisState) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.WrappedA0GiAddress)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovGenesis(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozGenesis(x uint64) (n int) {
|
||||
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field WrappedA0GiAddress", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.WrappedA0GiAddress = append(m.WrappedA0GiAddress[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.WrappedA0GiAddress == nil {
|
||||
m.WrappedA0GiAddress = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipGenesis(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipGenesis(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupGenesis
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
27
x/wrapped-a0gi-base/types/keys.go
Normal file
27
x/wrapped-a0gi-base/types/keys.go
Normal file
@ -0,0 +1,27 @@
|
||||
package types
|
||||
|
||||
import "encoding/hex"
|
||||
|
||||
const (
|
||||
// ModuleName The name that will be used throughout the module
|
||||
ModuleName = "wrapped-a0gi-base"
|
||||
|
||||
// StoreKey Top level store key where all module items will be stored
|
||||
StoreKey = ModuleName
|
||||
|
||||
// QuerierRoute Top level query string
|
||||
QuerierRoute = ModuleName
|
||||
)
|
||||
|
||||
var (
|
||||
// prefix
|
||||
MinterCapKeyPrefix = []byte{0x00}
|
||||
MinterSupplyKeyPrefix = []byte{0x01}
|
||||
|
||||
// keys
|
||||
WA0GIKey = []byte{0x00}
|
||||
)
|
||||
|
||||
func GetMinterKeyFromAccount(account string) ([]byte, error) {
|
||||
return hex.DecodeString(account)
|
||||
}
|
70
x/wrapped-a0gi-base/types/msg.go
Normal file
70
x/wrapped-a0gi-base/types/msg.go
Normal file
@ -0,0 +1,70 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMintCap{}, &MsgMint{}, &MsgBurn{}
|
||||
|
||||
func (msg *MsgSetWA0GI) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
func (msg *MsgSetWA0GI) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
|
||||
return errorsmod.Wrap(err, "authority")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg MsgSetWA0GI) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
func (msg *MsgSetMintCap) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
func (msg *MsgSetMintCap) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
|
||||
return errorsmod.Wrap(err, "authority")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg MsgSetMintCap) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
func (msg *MsgMint) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{}
|
||||
}
|
||||
|
||||
func (msg *MsgMint) ValidateBasic() error {
|
||||
// forbid mint from cosmos tx
|
||||
// it can only be called by wrapped a0gi from EVM
|
||||
return ErrTxForbidden
|
||||
}
|
||||
|
||||
func (msg MsgMint) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
func (msg *MsgBurn) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{}
|
||||
}
|
||||
|
||||
func (msg *MsgBurn) ValidateBasic() error {
|
||||
// forbid burn from cosmos tx
|
||||
// it can only be called by wrapped a0gi from EVM
|
||||
return ErrTxForbidden
|
||||
}
|
||||
|
||||
func (msg MsgBurn) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg))
|
||||
}
|
946
x/wrapped-a0gi-base/types/query.pb.go
Normal file
946
x/wrapped-a0gi-base/types/query.pb.go
Normal file
@ -0,0 +1,946 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: zgc/wrappeda0gibase/query.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
grpc1 "github.com/cosmos/gogoproto/grpc"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type GetWA0GIRequest struct {
|
||||
}
|
||||
|
||||
func (m *GetWA0GIRequest) Reset() { *m = GetWA0GIRequest{} }
|
||||
func (m *GetWA0GIRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetWA0GIRequest) ProtoMessage() {}
|
||||
func (*GetWA0GIRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_19911faa2ec12c75, []int{0}
|
||||
}
|
||||
func (m *GetWA0GIRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GetWA0GIRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GetWA0GIRequest.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *GetWA0GIRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetWA0GIRequest.Merge(m, src)
|
||||
}
|
||||
func (m *GetWA0GIRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GetWA0GIRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetWA0GIRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetWA0GIRequest proto.InternalMessageInfo
|
||||
|
||||
type GetWA0GIResponse struct {
|
||||
Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GetWA0GIResponse) Reset() { *m = GetWA0GIResponse{} }
|
||||
func (m *GetWA0GIResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetWA0GIResponse) ProtoMessage() {}
|
||||
func (*GetWA0GIResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_19911faa2ec12c75, []int{1}
|
||||
}
|
||||
func (m *GetWA0GIResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GetWA0GIResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GetWA0GIResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *GetWA0GIResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetWA0GIResponse.Merge(m, src)
|
||||
}
|
||||
func (m *GetWA0GIResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GetWA0GIResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetWA0GIResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetWA0GIResponse proto.InternalMessageInfo
|
||||
|
||||
type MinterSupplyRequest struct {
|
||||
Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MinterSupplyRequest) Reset() { *m = MinterSupplyRequest{} }
|
||||
func (m *MinterSupplyRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*MinterSupplyRequest) ProtoMessage() {}
|
||||
func (*MinterSupplyRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_19911faa2ec12c75, []int{2}
|
||||
}
|
||||
func (m *MinterSupplyRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MinterSupplyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MinterSupplyRequest.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MinterSupplyRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MinterSupplyRequest.Merge(m, src)
|
||||
}
|
||||
func (m *MinterSupplyRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MinterSupplyRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MinterSupplyRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MinterSupplyRequest proto.InternalMessageInfo
|
||||
|
||||
type MinterSupplyResponse struct {
|
||||
Cap []byte `protobuf:"bytes,1,opt,name=cap,proto3" json:"cap,omitempty"`
|
||||
Supply []byte `protobuf:"bytes,2,opt,name=supply,proto3" json:"supply,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MinterSupplyResponse) Reset() { *m = MinterSupplyResponse{} }
|
||||
func (m *MinterSupplyResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MinterSupplyResponse) ProtoMessage() {}
|
||||
func (*MinterSupplyResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_19911faa2ec12c75, []int{3}
|
||||
}
|
||||
func (m *MinterSupplyResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MinterSupplyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MinterSupplyResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MinterSupplyResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MinterSupplyResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MinterSupplyResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MinterSupplyResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MinterSupplyResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MinterSupplyResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GetWA0GIRequest)(nil), "zgc.wrappeda0gibase.GetWA0GIRequest")
|
||||
proto.RegisterType((*GetWA0GIResponse)(nil), "zgc.wrappeda0gibase.GetWA0GIResponse")
|
||||
proto.RegisterType((*MinterSupplyRequest)(nil), "zgc.wrappeda0gibase.MinterSupplyRequest")
|
||||
proto.RegisterType((*MinterSupplyResponse)(nil), "zgc.wrappeda0gibase.MinterSupplyResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("zgc/wrappeda0gibase/query.proto", fileDescriptor_19911faa2ec12c75) }
|
||||
|
||||
var fileDescriptor_19911faa2ec12c75 = []byte{
|
||||
// 410 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x6e, 0xd3, 0x30,
|
||||
0x18, 0xc7, 0x93, 0x22, 0x0a, 0xb2, 0x2a, 0x51, 0xdc, 0x0a, 0xb5, 0x11, 0x4a, 0x21, 0x50, 0x51,
|
||||
0x04, 0x89, 0x23, 0xe0, 0x01, 0x80, 0x4b, 0xc5, 0x81, 0x03, 0xe5, 0x80, 0xc4, 0x05, 0x39, 0xa9,
|
||||
0x71, 0x23, 0x35, 0xb1, 0x1b, 0x3b, 0xea, 0xda, 0xd3, 0xb4, 0x27, 0xa8, 0xb4, 0xf3, 0xde, 0xa7,
|
||||
0xc7, 0x4a, 0xbb, 0xec, 0xb8, 0xb5, 0x7b, 0x90, 0x29, 0x8e, 0xa3, 0x6d, 0x55, 0xb4, 0xed, 0xe6,
|
||||
0xff, 0xe7, 0xdf, 0xe7, 0xef, 0xef, 0xbf, 0x0d, 0x7a, 0x4b, 0x1a, 0xa2, 0x79, 0x8a, 0x39, 0x27,
|
||||
0x63, 0xec, 0xd3, 0x28, 0xc0, 0x82, 0xa0, 0x59, 0x46, 0xd2, 0x85, 0xc7, 0x53, 0x26, 0x19, 0x6c,
|
||||
0x2d, 0x69, 0xe8, 0xed, 0x01, 0x56, 0x37, 0x64, 0x22, 0x66, 0xe2, 0x9f, 0x42, 0x50, 0x21, 0x0a,
|
||||
0xde, 0x6a, 0x53, 0x46, 0x59, 0x51, 0xcf, 0x57, 0xba, 0xfa, 0x92, 0x32, 0x46, 0xa7, 0x04, 0x61,
|
||||
0x1e, 0x21, 0x9c, 0x24, 0x4c, 0x62, 0x19, 0xb1, 0xa4, 0xec, 0xe9, 0xea, 0x5d, 0xa5, 0x82, 0xec,
|
||||
0x3f, 0xc2, 0x89, 0x1e, 0x6f, 0xf5, 0xf6, 0xb7, 0x64, 0x14, 0x13, 0x21, 0x71, 0xcc, 0x0b, 0xc0,
|
||||
0x79, 0x0e, 0x9e, 0x0d, 0x89, 0xfc, 0xf3, 0xcd, 0x1f, 0xfe, 0x18, 0x91, 0x59, 0x46, 0x84, 0x74,
|
||||
0x3e, 0x82, 0xe6, 0x75, 0x49, 0x70, 0x96, 0x08, 0x02, 0x3b, 0xe0, 0x09, 0x1e, 0x8f, 0x53, 0x22,
|
||||
0x44, 0xc7, 0x7c, 0x65, 0x0e, 0x1a, 0xa3, 0x52, 0x3a, 0x08, 0xb4, 0x7e, 0x46, 0x89, 0x24, 0xe9,
|
||||
0xef, 0x8c, 0xf3, 0xe9, 0x42, 0x1f, 0x72, 0x47, 0xc3, 0x57, 0xd0, 0xbe, 0xdd, 0xa0, 0x47, 0x34,
|
||||
0xc1, 0xa3, 0x10, 0x73, 0x4d, 0xe7, 0x4b, 0xf8, 0x02, 0xd4, 0x85, 0x62, 0x3a, 0x35, 0x55, 0xd4,
|
||||
0xea, 0xd3, 0x49, 0x0d, 0x3c, 0xfe, 0x95, 0x67, 0x0c, 0x0f, 0x4d, 0xf0, 0xb4, 0xf4, 0x0a, 0xdf,
|
||||
0x7a, 0x15, 0x59, 0x7b, 0x7b, 0xb7, 0xb3, 0xfa, 0xf7, 0x50, 0x85, 0x1b, 0xe7, 0xdd, 0xd1, 0xe9,
|
||||
0xe5, 0x71, 0xed, 0x35, 0xec, 0x21, 0x9f, 0x96, 0x0f, 0xec, 0xe6, 0xb8, 0xab, 0x9e, 0x98, 0x12,
|
||||
0xe9, 0xce, 0x73, 0x09, 0x57, 0x26, 0x68, 0xdc, 0xbc, 0x0f, 0x1c, 0x54, 0x0e, 0xa8, 0xc8, 0xc8,
|
||||
0x7a, 0xff, 0x00, 0x52, 0xdb, 0xf9, 0xa0, 0xec, 0xf4, 0xe1, 0x9b, 0x6a, 0x3b, 0xb1, 0xea, 0x71,
|
||||
0x8b, 0x7c, 0xbe, 0x8f, 0xd6, 0x17, 0xb6, 0xb1, 0xde, 0xda, 0xe6, 0x66, 0x6b, 0x9b, 0xe7, 0x5b,
|
||||
0xdb, 0x5c, 0xed, 0x6c, 0x63, 0xb3, 0xb3, 0x8d, 0xb3, 0x9d, 0x6d, 0xfc, 0xfd, 0x42, 0x23, 0x39,
|
||||
0xc9, 0x02, 0x2f, 0x64, 0x31, 0xf2, 0xe9, 0x14, 0x07, 0x02, 0xf9, 0xd4, 0x0d, 0x27, 0x38, 0x4a,
|
||||
0xd0, 0x41, 0xc5, 0xd9, 0x72, 0xc1, 0x89, 0x08, 0xea, 0xea, 0xbb, 0x7c, 0xbe, 0x0a, 0x00, 0x00,
|
||||
0xff, 0xff, 0x14, 0xfb, 0x91, 0x88, 0xf1, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// QueryClient is the client API for Query service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type QueryClient interface {
|
||||
GetWA0GI(ctx context.Context, in *GetWA0GIRequest, opts ...grpc.CallOption) (*GetWA0GIResponse, error)
|
||||
MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewQueryClient(cc grpc1.ClientConn) QueryClient {
|
||||
return &queryClient{cc}
|
||||
}
|
||||
|
||||
func (c *queryClient) GetWA0GI(ctx context.Context, in *GetWA0GIRequest, opts ...grpc.CallOption) (*GetWA0GIResponse, error) {
|
||||
out := new(GetWA0GIResponse)
|
||||
err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Query/GetWA0GI", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error) {
|
||||
out := new(MinterSupplyResponse)
|
||||
err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Query/MinterSupply", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
type QueryServer interface {
|
||||
GetWA0GI(context.Context, *GetWA0GIRequest) (*GetWA0GIResponse, error)
|
||||
MinterSupply(context.Context, *MinterSupplyRequest) (*MinterSupplyResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedQueryServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedQueryServer) GetWA0GI(ctx context.Context, req *GetWA0GIRequest) (*GetWA0GIResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetWA0GI not implemented")
|
||||
}
|
||||
func (*UnimplementedQueryServer) MinterSupply(ctx context.Context, req *MinterSupplyRequest) (*MinterSupplyResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method MinterSupply not implemented")
|
||||
}
|
||||
|
||||
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
||||
s.RegisterService(&_Query_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Query_GetWA0GI_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetWA0GIRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetWA0GI(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/zgc.wrappeda0gibase.Query/GetWA0GI",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetWA0GI(ctx, req.(*GetWA0GIRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_MinterSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MinterSupplyRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).MinterSupply(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/zgc.wrappeda0gibase.Query/MinterSupply",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).MinterSupply(ctx, req.(*MinterSupplyRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Query_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "zgc.wrappeda0gibase.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetWA0GI",
|
||||
Handler: _Query_GetWA0GI_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "MinterSupply",
|
||||
Handler: _Query_MinterSupply_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "zgc/wrappeda0gibase/query.proto",
|
||||
}
|
||||
|
||||
func (m *GetWA0GIRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *GetWA0GIRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GetWA0GIRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *GetWA0GIResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *GetWA0GIResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GetWA0GIResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Address) > 0 {
|
||||
i -= len(m.Address)
|
||||
copy(dAtA[i:], m.Address)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MinterSupplyRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MinterSupplyRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MinterSupplyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Address) > 0 {
|
||||
i -= len(m.Address)
|
||||
copy(dAtA[i:], m.Address)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Address)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MinterSupplyResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MinterSupplyResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MinterSupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Supply) > 0 {
|
||||
i -= len(m.Supply)
|
||||
copy(dAtA[i:], m.Supply)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Supply)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Cap) > 0 {
|
||||
i -= len(m.Cap)
|
||||
copy(dAtA[i:], m.Cap)
|
||||
i = encodeVarintQuery(dAtA, i, uint64(len(m.Cap)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovQuery(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *GetWA0GIRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *GetWA0GIResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Address)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MinterSupplyRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Address)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MinterSupplyResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Cap)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
l = len(m.Supply)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovQuery(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozQuery(x uint64) (n int) {
|
||||
return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *GetWA0GIRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: GetWA0GIRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GetWA0GIRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *GetWA0GIResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: GetWA0GIResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GetWA0GIResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Address == nil {
|
||||
m.Address = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MinterSupplyRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MinterSupplyRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MinterSupplyRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Address == nil {
|
||||
m.Address = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MinterSupplyResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MinterSupplyResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MinterSupplyResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Cap = append(m.Cap[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Cap == nil {
|
||||
m.Cap = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Supply = append(m.Supply[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Supply == nil {
|
||||
m.Supply = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipQuery(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthQuery
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupQuery
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthQuery
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
236
x/wrapped-a0gi-base/types/query.pb.gw.go
Normal file
236
x/wrapped-a0gi-base/types/query.pb.gw.go
Normal file
@ -0,0 +1,236 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: zgc/wrappeda0gibase/query.proto
|
||||
|
||||
/*
|
||||
Package types is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
var _ = metadata.Join
|
||||
|
||||
func request_Query_GetWA0GI_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq GetWA0GIRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.GetWA0GI(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_GetWA0GI_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq GetWA0GIRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.GetWA0GI(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_MinterSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_MinterSupply_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq MinterSupplyRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MinterSupply_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.MinterSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_MinterSupply_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq MinterSupplyRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MinterSupply_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.MinterSupply(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetWA0GI_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_GetWA0GI_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetWA0GI_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_MinterSupply_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_MinterSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterQueryHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers the http handlers for service Query to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerClient registers the http handlers for service Query
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "QueryClient" to call the correct interceptors.
|
||||
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_GetWA0GI_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_GetWA0GI_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_GetWA0GI_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_MinterSupply_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_MinterSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_GetWA0GI_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"0g", "wrapped-a0gi-base", "get-wa0gi"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_MinterSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"0g", "wrapped-a0gi-base", "minter-supply"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_GetWA0GI_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_MinterSupply_0 = runtime.ForwardResponseMessage
|
||||
)
|
1719
x/wrapped-a0gi-base/types/tx.pb.go
Normal file
1719
x/wrapped-a0gi-base/types/tx.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user