diff --git a/app/app.go b/app/app.go index 0879f353..95eb8720 100644 --- a/app/app.go +++ b/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) diff --git a/app/test_common.go b/app/test_common.go index b822ddd2..b4657884 100644 --- a/app/test_common.go +++ b/app/test_common.go @@ -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] diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol new file mode 100644 index 00000000..ad7e8132 --- /dev/null +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -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; +} diff --git a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json new file mode 100644 index 00000000..67a7800b --- /dev/null +++ b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json @@ -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" + } +] diff --git a/precompiles/wrapped-a0gi-base/contract.go b/precompiles/wrapped-a0gi-base/contract.go new file mode 100644 index 00000000..3cadb588 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/contract.go @@ -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) +} diff --git a/precompiles/wrapped-a0gi-base/errors.go b/precompiles/wrapped-a0gi-base/errors.go new file mode 100644 index 00000000..4d793692 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/errors.go @@ -0,0 +1,5 @@ +package wrappeda0gibase + +const ( + ErrSenderNotWA0GI = "sender is not WA0GI" +) diff --git a/precompiles/wrapped-a0gi-base/query.go b/precompiles/wrapped-a0gi-base/query.go new file mode 100644 index 00000000..9052dbf7 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/query.go @@ -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) +} diff --git a/precompiles/wrapped-a0gi-base/query_test.go b/precompiles/wrapped-a0gi-base/query_test.go new file mode 100644 index 00000000..e987c4b4 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/query_test.go @@ -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.MsgSetMinterCap{ + 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) + } + }) + } +} diff --git a/precompiles/wrapped-a0gi-base/tx.go b/precompiles/wrapped-a0gi-base/tx.go new file mode 100644 index 00000000..74032d94 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/tx.go @@ -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() +} diff --git a/precompiles/wrapped-a0gi-base/tx_test.go b/precompiles/wrapped-a0gi-base/tx_test.go new file mode 100644 index 00000000..acf3e262 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/tx_test.go @@ -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.MsgSetMinterCap{ + 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.MsgSetMinterCap{ + 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() + } + }) + } +} diff --git a/precompiles/wrapped-a0gi-base/types.go b/precompiles/wrapped-a0gi-base/types.go new file mode 100644 index 00000000..23c6c2c0 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/types.go @@ -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 +} diff --git a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go new file mode 100644 index 00000000..ca3176dc --- /dev/null +++ b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go @@ -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 +} diff --git a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go new file mode 100644 index 00000000..62bfce4b --- /dev/null +++ b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go @@ -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)) +} diff --git a/proto/zgc/dasigners/v1/dasigners.proto b/proto/zgc/dasigners/v1/dasigners.proto index ee32ed3b..c390e5f3 100644 --- a/proto/zgc/dasigners/v1/dasigners.proto +++ b/proto/zgc/dasigners/v1/dasigners.proto @@ -25,5 +25,5 @@ message Quorum { } message Quorums { - repeated Quorum quorums = 1; + repeated Quorum quorums = 1; } diff --git a/proto/zgc/wrappeda0gibase/genesis.proto b/proto/zgc/wrappeda0gibase/genesis.proto new file mode 100644 index 00000000..3915a898 --- /dev/null +++ b/proto/zgc/wrappeda0gibase/genesis.proto @@ -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; +} diff --git a/proto/zgc/wrappeda0gibase/query.proto b/proto/zgc/wrappeda0gibase/query.proto new file mode 100644 index 00000000..a242ad39 --- /dev/null +++ b/proto/zgc/wrappeda0gibase/query.proto @@ -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 +} diff --git a/proto/zgc/wrappeda0gibase/tx.proto b/proto/zgc/wrappeda0gibase/tx.proto new file mode 100644 index 00000000..323dce06 --- /dev/null +++ b/proto/zgc/wrappeda0gibase/tx.proto @@ -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(MsgSetMinterCap) returns (MsgSetMinterCapResponse); + rpc Mint(MsgMint) returns (MsgMintResponse); + rpc Burn(MsgBurn) returns (MsgBurnResponse); +} + +message MsgSetWA0GI { + string authority = 1; + bytes address = 2; +} + +message MsgSetWA0GIResponse {} + +message MsgSetMinterCap { + string authority = 1; + bytes minter = 2; + bytes cap = 3; // big endian +} + +message MsgSetMinterCapResponse {} + +message MsgMint { + bytes minter = 1; + bytes amount = 2; // big endian +} + +message MsgMintResponse {} + +message MsgBurn { + bytes minter = 1; + bytes amount = 2; // big endian +} + +message MsgBurnResponse {} diff --git a/x/wrapped-a0gi-base/cli/query.go b/x/wrapped-a0gi-base/cli/query.go new file mode 100644 index 00000000..c693ab23 --- /dev/null +++ b/x/wrapped-a0gi-base/cli/query.go @@ -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 +} diff --git a/x/wrapped-a0gi-base/cli/tx.go b/x/wrapped-a0gi-base/cli/tx.go new file mode 100644 index 00000000..1fd09826 --- /dev/null +++ b/x/wrapped-a0gi-base/cli/tx.go @@ -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 +} diff --git a/x/wrapped-a0gi-base/genesis.go b/x/wrapped-a0gi-base/genesis.go new file mode 100644 index 00000000..56da0ad5 --- /dev/null +++ b/x/wrapped-a0gi-base/genesis.go @@ -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), + } +} diff --git a/x/wrapped-a0gi-base/genesis_test.go b/x/wrapped-a0gi-base/genesis_test.go new file mode 100644 index 00000000..831efd82 --- /dev/null +++ b/x/wrapped-a0gi-base/genesis_test.go @@ -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)) +} diff --git a/x/wrapped-a0gi-base/keeper/abci.go b/x/wrapped-a0gi-base/keeper/abci.go new file mode 100644 index 00000000..4abc1524 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/abci.go @@ -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) {} diff --git a/x/wrapped-a0gi-base/keeper/grpc_query.go b/x/wrapped-a0gi-base/keeper/grpc_query.go new file mode 100644 index 00000000..3164fb26 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/grpc_query.go @@ -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 +} diff --git a/x/wrapped-a0gi-base/keeper/keeper.go b/x/wrapped-a0gi-base/keeper/keeper.go new file mode 100644 index 00000000..13a77c67 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/keeper.go @@ -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 +} diff --git a/x/wrapped-a0gi-base/keeper/keeper_test.go b/x/wrapped-a0gi-base/keeper/keeper_test.go new file mode 100644 index 00000000..b045109f --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/keeper_test.go @@ -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)) +} diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go new file mode 100644 index 00000000..b626cab4 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -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.MsgSetMinterCap) (*types.MsgSetMinterCapResponse, 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.MsgSetMinterCapResponse{}, 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 +} diff --git a/x/wrapped-a0gi-base/keeper/msg_server_test.go b/x/wrapped-a0gi-base/keeper/msg_server_test.go new file mode 100644 index 00000000..127d73db --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/msg_server_test.go @@ -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.MsgSetMinterCap{ + 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.MsgSetMinterCap{ + 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.MsgSetMinterCap{ + 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.MsgSetMinterCap{ + 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)) +} diff --git a/x/wrapped-a0gi-base/module.go b/x/wrapped-a0gi-base/module.go new file mode 100644 index 00000000..2055f509 --- /dev/null +++ b/x/wrapped-a0gi-base/module.go @@ -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{} +} diff --git a/x/wrapped-a0gi-base/testutil/suite.go b/x/wrapped-a0gi-base/testutil/suite.go new file mode 100644 index 00000000..071d87de --- /dev/null +++ b/x/wrapped-a0gi-base/testutil/suite.go @@ -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) +} diff --git a/x/wrapped-a0gi-base/testutil/types.go b/x/wrapped-a0gi-base/testutil/types.go new file mode 100644 index 00000000..1ae3828c --- /dev/null +++ b/x/wrapped-a0gi-base/testutil/types.go @@ -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)) +} diff --git a/x/wrapped-a0gi-base/types/codec.go b/x/wrapped-a0gi-base/types/codec.go new file mode 100644 index 00000000..6fdf49af --- /dev/null +++ b/x/wrapped-a0gi-base/types/codec.go @@ -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{}, + &MsgSetMinterCap{}, + &MsgMint{}, + &MsgBurn{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec required for EIP-712 +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} diff --git a/x/wrapped-a0gi-base/types/errors.go b/x/wrapped-a0gi-base/types/errors.go new file mode 100644 index 00000000..cd8bff0d --- /dev/null +++ b/x/wrapped-a0gi-base/types/errors.go @@ -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") +) diff --git a/x/wrapped-a0gi-base/types/genesis.go b/x/wrapped-a0gi-base/types/genesis.go new file mode 100644 index 00000000..1f8510bb --- /dev/null +++ b/x/wrapped-a0gi-base/types/genesis.go @@ -0,0 +1,33 @@ +package types + +import "github.com/ethereum/go-ethereum/common" + +const ( + // This is a Wrapped A0GI contract deployed by a raw transaction: + // raw tx params: + // from: 0x873cd27b6833e6394c34a00c37b260aca5abc0b6 + // nonce: 0 + // gasPrice: 100 Gwei + // gasLimit: 1000000 + // The sender is an ephemeral account, nobody holds its private key and this is the only transaction it signed. + // This transaction is a legacy transaction without chain ID so it can be deployed at any EVM chain which supports pre-EIP155 transactions. + // raw tx: 0xf90f568085174876e800830f42408080b90f0360c0604052600c60809081526b57726170706564204130474960a01b60a0526000906200002d908262000128565b50604080518082019091526005815264574130474960d81b602082015260019062000059908262000128565b50600280546001600160a81b031916621002121790553480156200007c57600080fd5b50620001f4565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620000ae57607f821691505b602082108103620000cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200012357600081815260208120601f850160051c81016020861015620000fe5750805b601f850160051c820191505b818110156200011f578281556001016200010a565b5050505b505050565b81516001600160401b0381111562000144576200014462000083565b6200015c8162000155845462000099565b84620000d5565b602080601f8311600181146200019457600084156200017b5750858301515b600019600386901b1c1916600185901b1785556200011f565b600085815260208120601f198616915b82811015620001c557888601518255948401946001909101908401620001a4565b5085821015620001e45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610cff80620002046000396000f3fe6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb14610291578063c8dd1a26146102b1578063d0e30db0146102ee578063dd62ed3e146102f657600080fd5b806370a082311461022f57806379cc67901461025c57806395d89b411461027c5780639dc29fac1461025c57600080fd5b80632e1a7d4d116100c65780632e1a7d4d146101a3578063313ce567146101c357806340c10f19146101ef57806342966c681461020f57600080fd5b806306fdde031461010b578063095ea7b31461013657806318160ddd1461016657806323b872dd1461018357600080fd5b366101065761010461032e565b005b600080fd5b34801561011757600080fd5b50610120610389565b60405161012d9190610b1b565b60405180910390f35b34801561014257600080fd5b50610156610151366004610b6a565b610417565b604051901515815260200161012d565b34801561017257600080fd5b50475b60405190815260200161012d565b34801561018f57600080fd5b5061015661019e366004610b94565b610484565b3480156101af57600080fd5b506101046101be366004610bd0565b61068c565b3480156101cf57600080fd5b506002546101dd9060ff1681565b60405160ff909116815260200161012d565b3480156101fb57600080fd5b5061010461020a366004610b6a565b610716565b34801561021b57600080fd5b5061010461022a366004610bd0565b610879565b34801561023b57600080fd5b5061017561024a366004610be9565b60036020526000908152604090205481565b34801561026857600080fd5b50610104610277366004610b6a565b610886565b34801561028857600080fd5b50610120610894565b34801561029d57600080fd5b506101566102ac366004610b6a565b6108a1565b3480156102bd57600080fd5b506002546102d69061010090046001600160a01b031681565b6040516001600160a01b03909116815260200161012d565b61010461032e565b34801561030257600080fd5b50610175610311366004610c04565b600460209081526000928352604080842090915290825290205481565b336000908152600360205260408120805434929061034d908490610c4d565b909155505060405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a2565b6000805461039690610c60565b80601f01602080910402602001604051908101604052809291908181526020018280546103c290610c60565b801561040f5780601f106103e45761010080835404028352916020019161040f565b820191906000526020600020905b8154815290600101906020018083116103f257829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906104729086815260200190565b60405180910390a35060015b92915050565b6001600160a01b0383166000908152600360205260408120548211156104f15760405162461bcd60e51b815260206004820152601860248201527f73726320696e73756666696369656e742062616c616e6365000000000000000060448201526064015b60405180910390fd5b6001600160a01b038416331480159061052f57506001600160a01b038416600090815260046020908152604080832033845290915290205460001914155b156105d9576001600160a01b03841660009081526004602090815260408083203384529091529020548211156105a05760405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7420616c6c6f77616e636560501b60448201526064016104e8565b6001600160a01b0384166000908152600460209081526040808320338452909152812080548492906105d3908490610c9a565b90915550505b6001600160a01b03841660009081526003602052604081208054849290610601908490610c9a565b90915550506001600160a01b0383166000908152600360205260408120805484929061062e908490610c4d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161067a91815260200190565b60405180910390a35060019392505050565b33600090815260036020526040812080548392906106ab908490610c9a565b9091555050604051339082156108fc029083906000818181858888f193505050501580156106dd573d6000803e3d6000fd5b5060405181815233907f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b659060200160405180910390a250565b6002546040513360248201526044810183905260009161010090046001600160a01b03169060640160408051601f198184030181529181526020820180516001600160e01b03166340c10f1960e01b179052516107739190610cad565b6000604051808303816000865af19150503d80600081146107b0576040519150601f19603f3d011682016040523d82523d6000602084013e6107b5565b606091505b50509050806108065760405162461bcd60e51b815260206004820152601d60248201527f7772617070656420613067692062617365206d696e74206661696c656400000060448201526064016104e8565b6001600160a01b0383166000908152600360205260408120805484929061082e908490610c4d565b90915550506040518281526001600160a01b0384169033907fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8906020015b60405180910390a3505050565b61088333826108b5565b50565b61089082826108b5565b5050565b6001805461039690610c60565b60006108ae338484610484565b9392505050565b6002546040513360248201526044810183905260009161010090046001600160a01b03169060640160408051601f198184030181529181526020820180516001600160e01b0316632770a7eb60e21b179052516109129190610cad565b6000604051808303816000865af19150503d806000811461094f576040519150601f19603f3d011682016040523d82523d6000602084013e610954565b606091505b50509050806109a55760405162461bcd60e51b815260206004820152601d60248201527f7772617070656420613067692062617365206275726e206661696c656400000060448201526064016104e8565b6001600160a01b03831633148015906109e357506001600160a01b038316600090815260046020908152604080832033845290915290205460001914155b15610a8d576001600160a01b0383166000908152600460209081526040808320338452909152902054821115610a545760405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7420616c6c6f77616e636560501b60448201526064016104e8565b6001600160a01b038316600090815260046020908152604080832033845290915281208054849290610a87908490610c9a565b90915550505b6001600160a01b03831660009081526003602052604081208054849290610ab5908490610c9a565b90915550506040518281526001600160a01b0384169033907fbac40739b0d4ca32fa2d82fc91630465ba3eddd1598da6fca393b26fb63b94539060200161086c565b60005b83811015610b12578181015183820152602001610afa565b50506000910152565b6020815260008251806020840152610b3a816040850160208701610af7565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610b6557600080fd5b919050565b60008060408385031215610b7d57600080fd5b610b8683610b4e565b946020939093013593505050565b600080600060608486031215610ba957600080fd5b610bb284610b4e565b9250610bc060208501610b4e565b9150604084013590509250925092565b600060208284031215610be257600080fd5b5035919050565b600060208284031215610bfb57600080fd5b6108ae82610b4e565b60008060408385031215610c1757600080fd5b610c2083610b4e565b9150610c2e60208401610b4e565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047e5761047e610c37565b600181811c90821680610c7457607f821691505b602082108103610c9457634e487b7160e01b600052602260045260246000fd5b50919050565b8181038181111561047e5761047e610c37565b60008251610cbf818460208701610af7565b919091019291505056fea2646970667358221220e46d4016267b105c34d4679646e09d6fb451927a4dd464e4ebe1563577af02a664736f6c634300081400331ba0fbd8c503ac7ff82ea302cdc5d6a7195281eaa99017a6a363e36fba073028ba42a037a49fedf5460e3d33776233d88dfb242ddaf9bb5d4cb6688aa290ead65a93c7 + DEFAULT_WRAPPED_A0GI = "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c" +) + +// NewGenesisState returns a new genesis state object for the module. +func NewGenesisState(addr common.Address) *GenesisState { + return &GenesisState{ + WrappedA0GiAddress: addr.Bytes(), + } +} + +// DefaultGenesisState returns the default genesis state for the module. +func DefaultGenesisState() *GenesisState { + return NewGenesisState(common.HexToAddress(DEFAULT_WRAPPED_A0GI)) +} + +// Validate performs basic validation of genesis data. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/wrapped-a0gi-base/types/genesis.pb.go b/x/wrapped-a0gi-base/types/genesis.pb.go new file mode 100644 index 00000000..4d23ee39 --- /dev/null +++ b/x/wrapped-a0gi-base/types/genesis.pb.go @@ -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") +) diff --git a/x/wrapped-a0gi-base/types/keys.go b/x/wrapped-a0gi-base/types/keys.go new file mode 100644 index 00000000..47d86e2f --- /dev/null +++ b/x/wrapped-a0gi-base/types/keys.go @@ -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) +} diff --git a/x/wrapped-a0gi-base/types/msg.go b/x/wrapped-a0gi-base/types/msg.go new file mode 100644 index 00000000..437c1058 --- /dev/null +++ b/x/wrapped-a0gi-base/types/msg.go @@ -0,0 +1,70 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMinterCap{}, &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 *MsgSetMinterCap) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +func (msg *MsgSetMinterCap) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + + return nil +} + +func (msg MsgSetMinterCap) 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)) +} diff --git a/x/wrapped-a0gi-base/types/query.pb.go b/x/wrapped-a0gi-base/types/query.pb.go new file mode 100644 index 00000000..ed2753b2 --- /dev/null +++ b/x/wrapped-a0gi-base/types/query.pb.go @@ -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") +) diff --git a/x/wrapped-a0gi-base/types/query.pb.gw.go b/x/wrapped-a0gi-base/types/query.pb.gw.go new file mode 100644 index 00000000..17f15012 --- /dev/null +++ b/x/wrapped-a0gi-base/types/query.pb.gw.go @@ -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 +) diff --git a/x/wrapped-a0gi-base/types/tx.pb.go b/x/wrapped-a0gi-base/types/tx.pb.go new file mode 100644 index 00000000..87358084 --- /dev/null +++ b/x/wrapped-a0gi-base/types/tx.pb.go @@ -0,0 +1,1719 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/wrappeda0gibase/tx.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" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 MsgSetWA0GI struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MsgSetWA0GI) Reset() { *m = MsgSetWA0GI{} } +func (m *MsgSetWA0GI) String() string { return proto.CompactTextString(m) } +func (*MsgSetWA0GI) ProtoMessage() {} +func (*MsgSetWA0GI) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{0} +} +func (m *MsgSetWA0GI) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWA0GI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWA0GI.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 *MsgSetWA0GI) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWA0GI.Merge(m, src) +} +func (m *MsgSetWA0GI) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWA0GI) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWA0GI.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWA0GI proto.InternalMessageInfo + +type MsgSetWA0GIResponse struct { +} + +func (m *MsgSetWA0GIResponse) Reset() { *m = MsgSetWA0GIResponse{} } +func (m *MsgSetWA0GIResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetWA0GIResponse) ProtoMessage() {} +func (*MsgSetWA0GIResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{1} +} +func (m *MsgSetWA0GIResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWA0GIResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWA0GIResponse.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 *MsgSetWA0GIResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWA0GIResponse.Merge(m, src) +} +func (m *MsgSetWA0GIResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWA0GIResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWA0GIResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWA0GIResponse proto.InternalMessageInfo + +type MsgSetMinterCap struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Minter []byte `protobuf:"bytes,2,opt,name=minter,proto3" json:"minter,omitempty"` + Cap []byte `protobuf:"bytes,3,opt,name=cap,proto3" json:"cap,omitempty"` +} + +func (m *MsgSetMinterCap) Reset() { *m = MsgSetMinterCap{} } +func (m *MsgSetMinterCap) String() string { return proto.CompactTextString(m) } +func (*MsgSetMinterCap) ProtoMessage() {} +func (*MsgSetMinterCap) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{2} +} +func (m *MsgSetMinterCap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMinterCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMinterCap.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 *MsgSetMinterCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMinterCap.Merge(m, src) +} +func (m *MsgSetMinterCap) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMinterCap) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMinterCap.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMinterCap proto.InternalMessageInfo + +type MsgSetMinterCapResponse struct { +} + +func (m *MsgSetMinterCapResponse) Reset() { *m = MsgSetMinterCapResponse{} } +func (m *MsgSetMinterCapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetMinterCapResponse) ProtoMessage() {} +func (*MsgSetMinterCapResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{3} +} +func (m *MsgSetMinterCapResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMinterCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMinterCapResponse.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 *MsgSetMinterCapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMinterCapResponse.Merge(m, src) +} +func (m *MsgSetMinterCapResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMinterCapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMinterCapResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMinterCapResponse proto.InternalMessageInfo + +type MsgMint struct { + Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + Amount []byte `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgMint) Reset() { *m = MsgMint{} } +func (m *MsgMint) String() string { return proto.CompactTextString(m) } +func (*MsgMint) ProtoMessage() {} +func (*MsgMint) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{4} +} +func (m *MsgMint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMint.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 *MsgMint) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMint.Merge(m, src) +} +func (m *MsgMint) XXX_Size() int { + return m.Size() +} +func (m *MsgMint) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMint.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMint proto.InternalMessageInfo + +type MsgMintResponse struct { +} + +func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} } +func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintResponse) ProtoMessage() {} +func (*MsgMintResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{5} +} +func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintResponse.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 *MsgMintResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintResponse.Merge(m, src) +} +func (m *MsgMintResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo + +type MsgBurn struct { + Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + Amount []byte `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgBurn) Reset() { *m = MsgBurn{} } +func (m *MsgBurn) String() string { return proto.CompactTextString(m) } +func (*MsgBurn) ProtoMessage() {} +func (*MsgBurn) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{6} +} +func (m *MsgBurn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurn.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 *MsgBurn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurn.Merge(m, src) +} +func (m *MsgBurn) XXX_Size() int { + return m.Size() +} +func (m *MsgBurn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurn.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurn proto.InternalMessageInfo + +type MsgBurnResponse struct { +} + +func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } +func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBurnResponse) ProtoMessage() {} +func (*MsgBurnResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{7} +} +func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnResponse.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 *MsgBurnResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnResponse.Merge(m, src) +} +func (m *MsgBurnResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSetWA0GI)(nil), "zgc.wrappeda0gibase.MsgSetWA0GI") + proto.RegisterType((*MsgSetWA0GIResponse)(nil), "zgc.wrappeda0gibase.MsgSetWA0GIResponse") + proto.RegisterType((*MsgSetMinterCap)(nil), "zgc.wrappeda0gibase.MsgSetMinterCap") + proto.RegisterType((*MsgSetMinterCapResponse)(nil), "zgc.wrappeda0gibase.MsgSetMinterCapResponse") + proto.RegisterType((*MsgMint)(nil), "zgc.wrappeda0gibase.MsgMint") + proto.RegisterType((*MsgMintResponse)(nil), "zgc.wrappeda0gibase.MsgMintResponse") + proto.RegisterType((*MsgBurn)(nil), "zgc.wrappeda0gibase.MsgBurn") + proto.RegisterType((*MsgBurnResponse)(nil), "zgc.wrappeda0gibase.MsgBurnResponse") +} + +func init() { proto.RegisterFile("zgc/wrappeda0gibase/tx.proto", fileDescriptor_f80bf93a1fc022d3) } + +var fileDescriptor_f80bf93a1fc022d3 = []byte{ + // 419 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xc1, 0xae, 0xd2, 0x40, + 0x14, 0x86, 0x5b, 0x30, 0x20, 0x23, 0x89, 0x5a, 0x14, 0x4b, 0x43, 0x1a, 0xd2, 0xb0, 0x60, 0x21, + 0x9d, 0x46, 0xdd, 0xb8, 0x14, 0x63, 0x8c, 0x26, 0xdd, 0xd4, 0x44, 0xa3, 0x1b, 0x33, 0x2d, 0xe3, + 0xd0, 0x84, 0x76, 0x9a, 0xce, 0x34, 0x02, 0x4f, 0xe1, 0x63, 0xb1, 0x64, 0xa9, 0x3b, 0x2f, 0xbc, + 0xc8, 0xcd, 0x4c, 0x69, 0x6f, 0x21, 0x17, 0xb8, 0xb9, 0xbb, 0x39, 0xff, 0xf9, 0xcf, 0x77, 0x9a, + 0xbf, 0x39, 0xa0, 0xbf, 0x22, 0x01, 0xfc, 0x9d, 0xa2, 0x24, 0xc1, 0x53, 0xe4, 0x90, 0xd0, 0x47, + 0x0c, 0x43, 0xbe, 0xb0, 0x93, 0x94, 0x72, 0xaa, 0x75, 0x56, 0x24, 0xb0, 0x8f, 0xba, 0x46, 0x2f, + 0xa0, 0x2c, 0xa2, 0xec, 0xa7, 0xb4, 0xc0, 0xbc, 0xc8, 0xfd, 0xc6, 0x33, 0x42, 0x09, 0xcd, 0x75, + 0xf1, 0xda, 0xab, 0x3d, 0x42, 0x29, 0x99, 0x63, 0x28, 0x2b, 0x3f, 0xfb, 0x05, 0x51, 0xbc, 0xcc, + 0x5b, 0xd6, 0x07, 0xf0, 0xc8, 0x65, 0xe4, 0x0b, 0xe6, 0xdf, 0xde, 0x39, 0x1f, 0x3f, 0x69, 0x7d, + 0xd0, 0x42, 0x19, 0x9f, 0xd1, 0x34, 0xe4, 0x4b, 0x5d, 0x1d, 0xa8, 0xa3, 0x96, 0x77, 0x23, 0x68, + 0x3a, 0x68, 0xa2, 0xe9, 0x34, 0xc5, 0x8c, 0xe9, 0xb5, 0x81, 0x3a, 0x6a, 0x7b, 0x45, 0x69, 0x3d, + 0x07, 0x9d, 0x0a, 0xc6, 0xc3, 0x2c, 0xa1, 0x31, 0xc3, 0xd6, 0x77, 0xf0, 0x38, 0x97, 0xdd, 0x30, + 0xe6, 0x38, 0x7d, 0x8f, 0x92, 0x0b, 0x1b, 0xba, 0xa0, 0x11, 0x49, 0xeb, 0x7e, 0xc1, 0xbe, 0xd2, + 0x9e, 0x80, 0x7a, 0x80, 0x12, 0xbd, 0x2e, 0x45, 0xf1, 0xb4, 0x7a, 0xe0, 0xc5, 0x11, 0xba, 0xdc, + 0xfa, 0x16, 0x34, 0x5d, 0x46, 0x84, 0x5e, 0xe1, 0xa9, 0x07, 0xbc, 0x2e, 0x68, 0xa0, 0x88, 0x66, + 0x31, 0x2f, 0xf6, 0xe4, 0x95, 0xf5, 0x54, 0x7e, 0xb0, 0x18, 0x3d, 0xa2, 0x4d, 0xb2, 0x34, 0xbe, + 0x27, 0x4d, 0x8c, 0x16, 0xb4, 0x57, 0xff, 0x6a, 0xa0, 0xee, 0x32, 0xa2, 0x7d, 0x05, 0x0f, 0xcb, + 0xd0, 0x07, 0xf6, 0x2d, 0x7f, 0xd9, 0xae, 0xe4, 0x69, 0x8c, 0x2e, 0x39, 0x0a, 0xbe, 0xe6, 0x83, + 0xf6, 0x41, 0xdc, 0xc3, 0x33, 0x93, 0xa5, 0xcb, 0x78, 0x79, 0x17, 0x57, 0xb9, 0xe3, 0x33, 0x78, + 0x20, 0xc3, 0xed, 0x9f, 0x9a, 0x12, 0x5d, 0x63, 0x78, 0xae, 0x5b, 0x65, 0xc9, 0x68, 0x4f, 0xb2, + 0x44, 0xf7, 0x34, 0xab, 0x9a, 0xed, 0xc4, 0x5b, 0x5f, 0x99, 0xca, 0x7a, 0x6b, 0xaa, 0x9b, 0xad, + 0xa9, 0xfe, 0xdf, 0x9a, 0xea, 0x9f, 0x9d, 0xa9, 0x6c, 0x76, 0xa6, 0xf2, 0x77, 0x67, 0x2a, 0x3f, + 0xde, 0x90, 0x90, 0xcf, 0x32, 0xdf, 0x0e, 0x68, 0x04, 0x1d, 0x32, 0x47, 0x3e, 0x83, 0x0e, 0x19, + 0x07, 0x33, 0x14, 0xc6, 0x70, 0x51, 0x5c, 0xe0, 0x58, 0xc0, 0xc7, 0xf9, 0x0d, 0x2e, 0x13, 0xcc, + 0xfc, 0x86, 0x3c, 0x93, 0xd7, 0xd7, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x07, 0x50, 0x07, 0xa7, + 0x03, 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 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc.CallOption) (*MsgSetWA0GIResponse, error) + SetMinterCap(ctx context.Context, in *MsgSetMinterCap, opts ...grpc.CallOption) (*MsgSetMinterCapResponse, error) + Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) + Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc.CallOption) (*MsgSetWA0GIResponse, error) { + out := new(MsgSetWA0GIResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/SetWA0GI", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetMinterCap(ctx context.Context, in *MsgSetMinterCap, opts ...grpc.CallOption) (*MsgSetMinterCapResponse, error) { + out := new(MsgSetMinterCapResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/SetMinterCap", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) { + out := new(MsgMintResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/Mint", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) { + out := new(MsgBurnResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/Burn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + SetWA0GI(context.Context, *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) + SetMinterCap(context.Context, *MsgSetMinterCap) (*MsgSetMinterCapResponse, error) + Mint(context.Context, *MsgMint) (*MsgMintResponse, error) + Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SetWA0GI(ctx context.Context, req *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetWA0GI not implemented") +} +func (*UnimplementedMsgServer) SetMinterCap(ctx context.Context, req *MsgSetMinterCap) (*MsgSetMinterCapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetMinterCap not implemented") +} +func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMintResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Mint not implemented") +} +func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SetWA0GI_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetWA0GI) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetWA0GI(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/SetWA0GI", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetWA0GI(ctx, req.(*MsgSetWA0GI)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetMinterCap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetMinterCap) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetMinterCap(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/SetMinterCap", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetMinterCap(ctx, req.(*MsgSetMinterCap)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Mint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMint) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Mint(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/Mint", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Mint(ctx, req.(*MsgMint)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBurn) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Burn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/Burn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Burn(ctx, req.(*MsgBurn)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.wrappeda0gibase.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetWA0GI", + Handler: _Msg_SetWA0GI_Handler, + }, + { + MethodName: "SetMinterCap", + Handler: _Msg_SetMinterCap_Handler, + }, + { + MethodName: "Mint", + Handler: _Msg_Mint_Handler, + }, + { + MethodName: "Burn", + Handler: _Msg_Burn_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/wrappeda0gibase/tx.proto", +} + +func (m *MsgSetWA0GI) 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 *MsgSetWA0GI) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWA0GI) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetWA0GIResponse) 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 *MsgSetWA0GIResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWA0GIResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetMinterCap) 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 *MsgSetMinterCap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMinterCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Cap) > 0 { + i -= len(m.Cap) + copy(dAtA[i:], m.Cap) + i = encodeVarintTx(dAtA, i, uint64(len(m.Cap))) + i-- + dAtA[i] = 0x1a + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetMinterCapResponse) 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 *MsgSetMinterCapResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMinterCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMint) 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 *MsgMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintResponse) 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 *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBurn) 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 *MsgBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnResponse) 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 *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSetWA0GI) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetWA0GIResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetMinterCap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Cap) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetMinterCapResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBurn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgBurnResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSetWA0GI) 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 ErrIntOverflowTx + } + 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: MsgSetWA0GI: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWA0GI: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetWA0GIResponse) 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 ErrIntOverflowTx + } + 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: MsgSetWA0GIResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWA0GIResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetMinterCap) 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 ErrIntOverflowTx + } + 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: MsgSetMinterCap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMinterCap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cap = append(m.Cap[:0], dAtA[iNdEx:postIndex]...) + if m.Cap == nil { + m.Cap = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetMinterCapResponse) 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 ErrIntOverflowTx + } + 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: MsgSetMinterCapResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMinterCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMint) 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 ErrIntOverflowTx + } + 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: MsgMint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount[:0], dAtA[iNdEx:postIndex]...) + if m.Amount == nil { + m.Amount = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMintResponse) 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 ErrIntOverflowTx + } + 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: MsgMintResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBurn) 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 ErrIntOverflowTx + } + 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: MsgBurn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount[:0], dAtA[iNdEx:postIndex]...) + if m.Amount == nil { + m.Amount = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBurnResponse) 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 ErrIntOverflowTx + } + 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: MsgBurnResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)