github.com/Blockdaemon/celo-blockchain@v0.0.0-20200129231733-e667f6b08419/contract_comm/gold_token/gold_token.go (about) 1 package gold_token 2 3 import ( 4 "math/big" 5 "strings" 6 7 "github.com/ethereum/go-ethereum/accounts/abi" 8 "github.com/ethereum/go-ethereum/common" 9 "github.com/ethereum/go-ethereum/contract_comm" 10 "github.com/ethereum/go-ethereum/core/types" 11 "github.com/ethereum/go-ethereum/core/vm" 12 "github.com/ethereum/go-ethereum/params" 13 ) 14 15 const ( 16 // This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/GoldToken.json 17 increaseSupplyABI = `[{ 18 "constant": false, 19 "inputs": [ 20 { 21 "name": "amount", 22 "type": "uint256" 23 } 24 ], 25 "name": "increaseSupply", 26 "outputs": [], 27 "payable": false, 28 "stateMutability": "nonpayable", 29 "type": "function" 30 }]` 31 32 // This is taken from celo-monorepo/packages/protocol/build/<env>/contracts/GoldToken.json 33 totalSupplyABI = `[{ 34 "constant": true, 35 "inputs": [], 36 "name": "totalSupply", 37 "outputs": [ 38 { 39 "name": "", 40 "type": "uint256" 41 } 42 ], 43 "payable": false, 44 "stateMutability": "view", 45 "type": "function" 46 }]` 47 ) 48 49 var ( 50 increaseSupplyFuncABI, _ = abi.JSON(strings.NewReader(increaseSupplyABI)) 51 totalSupplyFuncABI, _ = abi.JSON(strings.NewReader(totalSupplyABI)) 52 ) 53 54 func GetTotalSupply(header *types.Header, state vm.StateDB) (*big.Int, error) { 55 var totalSupply *big.Int 56 _, err := contract_comm.MakeStaticCall( 57 params.GoldTokenRegistryId, 58 totalSupplyFuncABI, 59 "totalSupply", 60 []interface{}{}, 61 &totalSupply, 62 params.MaxGasForTotalSupply, 63 header, 64 state, 65 ) 66 return totalSupply, err 67 } 68 69 func IncreaseSupply(header *types.Header, state vm.StateDB, value *big.Int) error { 70 _, err := contract_comm.MakeCall( 71 params.GoldTokenRegistryId, 72 increaseSupplyFuncABI, 73 "increaseSupply", 74 []interface{}{value}, 75 nil, 76 params.MaxGasForIncreaseSupply, 77 common.Big0, 78 header, 79 state, 80 false, 81 ) 82 return err 83 }