From ef1de9c499a37575636c09f1a368b6078d859737 Mon Sep 17 00:00:00 2001 From: Francisco de Borja Aranda Castillejo Date: Mon, 18 Nov 2024 18:09:54 +0100 Subject: [PATCH] test: finish e2e through contract --- .../testdistribute/TestDistribute.abi | 91 +++++-- .../testdistribute/TestDistribute.bin | 2 +- .../testdistribute/TestDistribute.go | 247 +++++++----------- .../testdistribute/TestDistribute.json | 93 +++++-- .../testdistribute/TestDistribute.sol | 39 +-- e2e/e2etests/test_precompiles_distribute.go | 54 ++-- ...precompiles_distribute_through_contract.go | 187 +++++++++---- .../staking/method_get_rewards_test.go | 7 +- 8 files changed, 427 insertions(+), 293 deletions(-) diff --git a/e2e/contracts/testdistribute/TestDistribute.abi b/e2e/contracts/testdistribute/TestDistribute.abi index 26aa07af4e..e8f554bd92 100644 --- a/e2e/contracts/testdistribute/TestDistribute.abi +++ b/e2e/contracts/testdistribute/TestDistribute.abi @@ -1,37 +1,31 @@ [ { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" + "stateMutability": "payable", + "type": "fallback" }, { - "anonymous": false, "inputs": [ { - "indexed": true, "internalType": "address", - "name": "zrc20_distributor", + "name": "delegator", "type": "address" }, { - "indexed": true, - "internalType": "address", - "name": "zrc20_token", - "type": "address" - }, + "internalType": "string", + "name": "validator", + "type": "string" + } + ], + "name": "claimRewardsThroughContract", + "outputs": [ { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" + "internalType": "bool", + "name": "", + "type": "bool" } ], - "name": "Distributed", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" + "stateMutability": "nonpayable", + "type": "function" }, { "inputs": [ @@ -57,6 +51,61 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getDelegatorValidatorsThroughContract", + "outputs": [ + { + "internalType": "string[]", + "name": "", + "type": "string[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + } + ], + "name": "getRewardsThroughContract", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "denom", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct DecCoin[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "stateMutability": "payable", "type": "receive" diff --git a/e2e/contracts/testdistribute/TestDistribute.bin b/e2e/contracts/testdistribute/TestDistribute.bin index 5840bf96e5..c59ac56b96 100644 --- a/e2e/contracts/testdistribute/TestDistribute.bin +++ b/e2e/contracts/testdistribute/TestDistribute.bin @@ -1 +1 @@ -60a060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b503373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505060805161034d6100a06000396000606c015261034d6000f3fe6080604052600436106100225760003560e01c806350b54e841461002b57610029565b3661002957005b005b34801561003757600080fd5b50610052600480360381019061004d9190610201565b610068565b60405161005f919061025c565b60405180910390f35b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100c257600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b815260040161011d929190610295565b6020604051808303816000875af115801561013c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016091906102ea565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101988261016d565b9050919050565b6101a88161018d565b81146101b357600080fd5b50565b6000813590506101c58161019f565b92915050565b6000819050919050565b6101de816101cb565b81146101e957600080fd5b50565b6000813590506101fb816101d5565b92915050565b6000806040838503121561021857610217610168565b5b6000610226858286016101b6565b9250506020610237858286016101ec565b9150509250929050565b60008115159050919050565b61025681610241565b82525050565b6000602082019050610271600083018461024d565b92915050565b6102808161018d565b82525050565b61028f816101cb565b82525050565b60006040820190506102aa6000830185610277565b6102b76020830184610286565b9392505050565b6102c781610241565b81146102d257600080fd5b50565b6000815190506102e4816102be565b92915050565b600060208284031215610300576102ff610168565b5b600061030e848285016102d5565b9150509291505056fea26469706673582212205443ec313ecb8c2e08ca8a30687daed4c3b666f9318ae72ccbe9033479c8b8be64736f6c634300080a0033 +608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b50610e2d806100616000396000f3fe6080604052600436106100435760003560e01c80630f4865ea1461004c57806350b54e8414610089578063834b902f146100c6578063cdc5ec4a146101035761004a565b3661004a57005b005b34801561005857600080fd5b50610073600480360381019061006e919061059d565b610140565b6040516100809190610614565b60405180910390f35b34801561009557600080fd5b506100b060048036038101906100ab9190610665565b6101e9565b6040516100bd9190610614565b60405180910390f35b3480156100d257600080fd5b506100ed60048036038101906100e8919061059d565b610292565b6040516100fa919061083b565b60405180910390f35b34801561010f57600080fd5b5061012a6004803603810190610125919061085d565b61033d565b604051610137919061094c565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166354dbdc3884846040518363ffffffff1660e01b815260040161019e9291906109c7565b6020604051808303816000875af11580156101bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e19190610a23565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b8152600401610247929190610a5f565b6020604051808303816000875af1158015610266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028a9190610a23565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639342879284846040518363ffffffff1660e01b81526004016102ef9291906109c7565b600060405180830381865afa15801561030c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103359190610c69565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b6a216ae836040518263ffffffff1660e01b81526004016103989190610cb2565b600060405180830381865afa1580156103b5573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103de9190610dae565b9050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610424826103f9565b9050919050565b61043481610419565b811461043f57600080fd5b50565b6000813590506104518161042b565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6104aa82610461565b810181811067ffffffffffffffff821117156104c9576104c8610472565b5b80604052505050565b60006104dc6103e5565b90506104e882826104a1565b919050565b600067ffffffffffffffff82111561050857610507610472565b5b61051182610461565b9050602081019050919050565b82818337600083830152505050565b600061054061053b846104ed565b6104d2565b90508281526020810184848401111561055c5761055b61045c565b5b61056784828561051e565b509392505050565b600082601f83011261058457610583610457565b5b813561059484826020860161052d565b91505092915050565b600080604083850312156105b4576105b36103ef565b5b60006105c285828601610442565b925050602083013567ffffffffffffffff8111156105e3576105e26103f4565b5b6105ef8582860161056f565b9150509250929050565b60008115159050919050565b61060e816105f9565b82525050565b60006020820190506106296000830184610605565b92915050565b6000819050919050565b6106428161062f565b811461064d57600080fd5b50565b60008135905061065f81610639565b92915050565b6000806040838503121561067c5761067b6103ef565b5b600061068a85828601610442565b925050602061069b85828601610650565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561070b5780820151818401526020810190506106f0565b8381111561071a576000848401525b50505050565b600061072b826106d1565b61073581856106dc565b93506107458185602086016106ed565b61074e81610461565b840191505092915050565b6107628161062f565b82525050565b600060408301600083015184820360008601526107858282610720565b915050602083015161079a6020860182610759565b508091505092915050565b60006107b18383610768565b905092915050565b6000602082019050919050565b60006107d1826106a5565b6107db81856106b0565b9350836020820285016107ed856106c1565b8060005b85811015610829578484038952815161080a85826107a5565b9450610815836107b9565b925060208a019950506001810190506107f1565b50829750879550505050505092915050565b6000602082019050818103600083015261085581846107c6565b905092915050565b600060208284031215610873576108726103ef565b5b600061088184828501610442565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006108c28383610720565b905092915050565b6000602082019050919050565b60006108e28261088a565b6108ec8185610895565b9350836020820285016108fe856108a6565b8060005b8581101561093a578484038952815161091b85826108b6565b9450610926836108ca565b925060208a01995050600181019050610902565b50829750879550505050505092915050565b6000602082019050818103600083015261096681846108d7565b905092915050565b61097781610419565b82525050565b600082825260208201905092915050565b6000610999826106d1565b6109a3818561097d565b93506109b38185602086016106ed565b6109bc81610461565b840191505092915050565b60006040820190506109dc600083018561096e565b81810360208301526109ee818461098e565b90509392505050565b610a00816105f9565b8114610a0b57600080fd5b50565b600081519050610a1d816109f7565b92915050565b600060208284031215610a3957610a386103ef565b5b6000610a4784828501610a0e565b91505092915050565b610a598161062f565b82525050565b6000604082019050610a74600083018561096e565b610a816020830184610a50565b9392505050565b600067ffffffffffffffff821115610aa357610aa2610472565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b6000610ad6610ad1846104ed565b6104d2565b905082815260208101848484011115610af257610af161045c565b5b610afd8482856106ed565b509392505050565b600082601f830112610b1a57610b19610457565b5b8151610b2a848260208601610ac3565b91505092915050565b600081519050610b4281610639565b92915050565b600060408284031215610b5e57610b5d610ab9565b5b610b6860406104d2565b9050600082015167ffffffffffffffff811115610b8857610b87610abe565b5b610b9484828501610b05565b6000830152506020610ba884828501610b33565b60208301525092915050565b6000610bc7610bc284610a88565b6104d2565b90508083825260208201905060208402830185811115610bea57610be9610ab4565b5b835b81811015610c3157805167ffffffffffffffff811115610c0f57610c0e610457565b5b808601610c1c8982610b48565b85526020850194505050602081019050610bec565b5050509392505050565b600082601f830112610c5057610c4f610457565b5b8151610c60848260208601610bb4565b91505092915050565b600060208284031215610c7f57610c7e6103ef565b5b600082015167ffffffffffffffff811115610c9d57610c9c6103f4565b5b610ca984828501610c3b565b91505092915050565b6000602082019050610cc7600083018461096e565b92915050565b600067ffffffffffffffff821115610ce857610ce7610472565b5b602082029050602081019050919050565b6000610d0c610d0784610ccd565b6104d2565b90508083825260208201905060208402830185811115610d2f57610d2e610ab4565b5b835b81811015610d7657805167ffffffffffffffff811115610d5457610d53610457565b5b808601610d618982610b05565b85526020850194505050602081019050610d31565b5050509392505050565b600082601f830112610d9557610d94610457565b5b8151610da5848260208601610cf9565b91505092915050565b600060208284031215610dc457610dc36103ef565b5b600082015167ffffffffffffffff811115610de257610de16103f4565b5b610dee84828501610d80565b9150509291505056fea2646970667358221220d29e8c0ffd7f95c3ae2950ad56c9ec844a4f83f78ebf290ed1f2076d3fa1537864736f6c634300080a0033 diff --git a/e2e/contracts/testdistribute/TestDistribute.go b/e2e/contracts/testdistribute/TestDistribute.go index 18b4201b1a..bdbbfce8e6 100644 --- a/e2e/contracts/testdistribute/TestDistribute.go +++ b/e2e/contracts/testdistribute/TestDistribute.go @@ -29,10 +29,16 @@ var ( _ = abi.ConvertType ) +// DecCoin is an auto generated low-level Go binding around an user-defined struct. +type DecCoin struct { + Denom string + Amount *big.Int +} + // TestDistributeMetaData contains all meta data concerning the TestDistribute contract. var TestDistributeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"zrc20_distributor\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"zrc20_token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Distributed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"distributeThroughContract\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60a060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b503373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505060805161034d6100a06000396000606c015261034d6000f3fe6080604052600436106100225760003560e01c806350b54e841461002b57610029565b3661002957005b005b34801561003757600080fd5b50610052600480360381019061004d9190610201565b610068565b60405161005f919061025c565b60405180910390f35b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100c257600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b815260040161011d929190610295565b6020604051808303816000875af115801561013c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016091906102ea565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101988261016d565b9050919050565b6101a88161018d565b81146101b357600080fd5b50565b6000813590506101c58161019f565b92915050565b6000819050919050565b6101de816101cb565b81146101e957600080fd5b50565b6000813590506101fb816101d5565b92915050565b6000806040838503121561021857610217610168565b5b6000610226858286016101b6565b9250506020610237858286016101ec565b9150509250929050565b60008115159050919050565b61025681610241565b82525050565b6000602082019050610271600083018461024d565b92915050565b6102808161018d565b82525050565b61028f816101cb565b82525050565b60006040820190506102aa6000830185610277565b6102b76020830184610286565b9392505050565b6102c781610241565b81146102d257600080fd5b50565b6000815190506102e4816102be565b92915050565b600060208284031215610300576102ff610168565b5b600061030e848285016102d5565b9150509291505056fea26469706673582212205443ec313ecb8c2e08ca8a30687daed4c3b666f9318ae72ccbe9033479c8b8be64736f6c634300080a0033", + ABI: "[{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"}],\"name\":\"claimRewardsThroughContract\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"distributeThroughContract\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"getDelegatorValidatorsThroughContract\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"}],\"name\":\"getRewardsThroughContract\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structDecCoin[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b50610e2d806100616000396000f3fe6080604052600436106100435760003560e01c80630f4865ea1461004c57806350b54e8414610089578063834b902f146100c6578063cdc5ec4a146101035761004a565b3661004a57005b005b34801561005857600080fd5b50610073600480360381019061006e919061059d565b610140565b6040516100809190610614565b60405180910390f35b34801561009557600080fd5b506100b060048036038101906100ab9190610665565b6101e9565b6040516100bd9190610614565b60405180910390f35b3480156100d257600080fd5b506100ed60048036038101906100e8919061059d565b610292565b6040516100fa919061083b565b60405180910390f35b34801561010f57600080fd5b5061012a6004803603810190610125919061085d565b61033d565b604051610137919061094c565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166354dbdc3884846040518363ffffffff1660e01b815260040161019e9291906109c7565b6020604051808303816000875af11580156101bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e19190610a23565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b8152600401610247929190610a5f565b6020604051808303816000875af1158015610266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028a9190610a23565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639342879284846040518363ffffffff1660e01b81526004016102ef9291906109c7565b600060405180830381865afa15801561030c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103359190610c69565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b6a216ae836040518263ffffffff1660e01b81526004016103989190610cb2565b600060405180830381865afa1580156103b5573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103de9190610dae565b9050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610424826103f9565b9050919050565b61043481610419565b811461043f57600080fd5b50565b6000813590506104518161042b565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6104aa82610461565b810181811067ffffffffffffffff821117156104c9576104c8610472565b5b80604052505050565b60006104dc6103e5565b90506104e882826104a1565b919050565b600067ffffffffffffffff82111561050857610507610472565b5b61051182610461565b9050602081019050919050565b82818337600083830152505050565b600061054061053b846104ed565b6104d2565b90508281526020810184848401111561055c5761055b61045c565b5b61056784828561051e565b509392505050565b600082601f83011261058457610583610457565b5b813561059484826020860161052d565b91505092915050565b600080604083850312156105b4576105b36103ef565b5b60006105c285828601610442565b925050602083013567ffffffffffffffff8111156105e3576105e26103f4565b5b6105ef8582860161056f565b9150509250929050565b60008115159050919050565b61060e816105f9565b82525050565b60006020820190506106296000830184610605565b92915050565b6000819050919050565b6106428161062f565b811461064d57600080fd5b50565b60008135905061065f81610639565b92915050565b6000806040838503121561067c5761067b6103ef565b5b600061068a85828601610442565b925050602061069b85828601610650565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561070b5780820151818401526020810190506106f0565b8381111561071a576000848401525b50505050565b600061072b826106d1565b61073581856106dc565b93506107458185602086016106ed565b61074e81610461565b840191505092915050565b6107628161062f565b82525050565b600060408301600083015184820360008601526107858282610720565b915050602083015161079a6020860182610759565b508091505092915050565b60006107b18383610768565b905092915050565b6000602082019050919050565b60006107d1826106a5565b6107db81856106b0565b9350836020820285016107ed856106c1565b8060005b85811015610829578484038952815161080a85826107a5565b9450610815836107b9565b925060208a019950506001810190506107f1565b50829750879550505050505092915050565b6000602082019050818103600083015261085581846107c6565b905092915050565b600060208284031215610873576108726103ef565b5b600061088184828501610442565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006108c28383610720565b905092915050565b6000602082019050919050565b60006108e28261088a565b6108ec8185610895565b9350836020820285016108fe856108a6565b8060005b8581101561093a578484038952815161091b85826108b6565b9450610926836108ca565b925060208a01995050600181019050610902565b50829750879550505050505092915050565b6000602082019050818103600083015261096681846108d7565b905092915050565b61097781610419565b82525050565b600082825260208201905092915050565b6000610999826106d1565b6109a3818561097d565b93506109b38185602086016106ed565b6109bc81610461565b840191505092915050565b60006040820190506109dc600083018561096e565b81810360208301526109ee818461098e565b90509392505050565b610a00816105f9565b8114610a0b57600080fd5b50565b600081519050610a1d816109f7565b92915050565b600060208284031215610a3957610a386103ef565b5b6000610a4784828501610a0e565b91505092915050565b610a598161062f565b82525050565b6000604082019050610a74600083018561096e565b610a816020830184610a50565b9392505050565b600067ffffffffffffffff821115610aa357610aa2610472565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b6000610ad6610ad1846104ed565b6104d2565b905082815260208101848484011115610af257610af161045c565b5b610afd8482856106ed565b509392505050565b600082601f830112610b1a57610b19610457565b5b8151610b2a848260208601610ac3565b91505092915050565b600081519050610b4281610639565b92915050565b600060408284031215610b5e57610b5d610ab9565b5b610b6860406104d2565b9050600082015167ffffffffffffffff811115610b8857610b87610abe565b5b610b9484828501610b05565b6000830152506020610ba884828501610b33565b60208301525092915050565b6000610bc7610bc284610a88565b6104d2565b90508083825260208201905060208402830185811115610bea57610be9610ab4565b5b835b81811015610c3157805167ffffffffffffffff811115610c0f57610c0e610457565b5b808601610c1c8982610b48565b85526020850194505050602081019050610bec565b5050509392505050565b600082601f830112610c5057610c4f610457565b5b8151610c60848260208601610bb4565b91505092915050565b600060208284031215610c7f57610c7e6103ef565b5b600082015167ffffffffffffffff811115610c9d57610c9c6103f4565b5b610ca984828501610c3b565b91505092915050565b6000602082019050610cc7600083018461096e565b92915050565b600067ffffffffffffffff821115610ce857610ce7610472565b5b602082029050602081019050919050565b6000610d0c610d0784610ccd565b6104d2565b90508083825260208201905060208402830185811115610d2f57610d2e610ab4565b5b835b81811015610d7657805167ffffffffffffffff811115610d5457610d53610457565b5b808601610d618982610b05565b85526020850194505050602081019050610d31565b5050509392505050565b600082601f830112610d9557610d94610457565b5b8151610da5848260208601610cf9565b91505092915050565b600060208284031215610dc457610dc36103ef565b5b600082015167ffffffffffffffff811115610de257610de16103f4565b5b610dee84828501610d80565b9150509291505056fea2646970667358221220d29e8c0ffd7f95c3ae2950ad56c9ec844a4f83f78ebf290ed1f2076d3fa1537864736f6c634300080a0033", } // TestDistributeABI is the input ABI used to generate the binding from. @@ -202,6 +208,89 @@ func (_TestDistribute *TestDistributeTransactorRaw) Transact(opts *bind.Transact return _TestDistribute.Contract.contract.Transact(opts, method, params...) } +// GetDelegatorValidatorsThroughContract is a free data retrieval call binding the contract method 0xcdc5ec4a. +// +// Solidity: function getDelegatorValidatorsThroughContract(address delegator) view returns(string[]) +func (_TestDistribute *TestDistributeCaller) GetDelegatorValidatorsThroughContract(opts *bind.CallOpts, delegator common.Address) ([]string, error) { + var out []interface{} + err := _TestDistribute.contract.Call(opts, &out, "getDelegatorValidatorsThroughContract", delegator) + + if err != nil { + return *new([]string), err + } + + out0 := *abi.ConvertType(out[0], new([]string)).(*[]string) + + return out0, err + +} + +// GetDelegatorValidatorsThroughContract is a free data retrieval call binding the contract method 0xcdc5ec4a. +// +// Solidity: function getDelegatorValidatorsThroughContract(address delegator) view returns(string[]) +func (_TestDistribute *TestDistributeSession) GetDelegatorValidatorsThroughContract(delegator common.Address) ([]string, error) { + return _TestDistribute.Contract.GetDelegatorValidatorsThroughContract(&_TestDistribute.CallOpts, delegator) +} + +// GetDelegatorValidatorsThroughContract is a free data retrieval call binding the contract method 0xcdc5ec4a. +// +// Solidity: function getDelegatorValidatorsThroughContract(address delegator) view returns(string[]) +func (_TestDistribute *TestDistributeCallerSession) GetDelegatorValidatorsThroughContract(delegator common.Address) ([]string, error) { + return _TestDistribute.Contract.GetDelegatorValidatorsThroughContract(&_TestDistribute.CallOpts, delegator) +} + +// GetRewardsThroughContract is a free data retrieval call binding the contract method 0x834b902f. +// +// Solidity: function getRewardsThroughContract(address delegator, string validator) view returns((string,uint256)[]) +func (_TestDistribute *TestDistributeCaller) GetRewardsThroughContract(opts *bind.CallOpts, delegator common.Address, validator string) ([]DecCoin, error) { + var out []interface{} + err := _TestDistribute.contract.Call(opts, &out, "getRewardsThroughContract", delegator, validator) + + if err != nil { + return *new([]DecCoin), err + } + + out0 := *abi.ConvertType(out[0], new([]DecCoin)).(*[]DecCoin) + + return out0, err + +} + +// GetRewardsThroughContract is a free data retrieval call binding the contract method 0x834b902f. +// +// Solidity: function getRewardsThroughContract(address delegator, string validator) view returns((string,uint256)[]) +func (_TestDistribute *TestDistributeSession) GetRewardsThroughContract(delegator common.Address, validator string) ([]DecCoin, error) { + return _TestDistribute.Contract.GetRewardsThroughContract(&_TestDistribute.CallOpts, delegator, validator) +} + +// GetRewardsThroughContract is a free data retrieval call binding the contract method 0x834b902f. +// +// Solidity: function getRewardsThroughContract(address delegator, string validator) view returns((string,uint256)[]) +func (_TestDistribute *TestDistributeCallerSession) GetRewardsThroughContract(delegator common.Address, validator string) ([]DecCoin, error) { + return _TestDistribute.Contract.GetRewardsThroughContract(&_TestDistribute.CallOpts, delegator, validator) +} + +// ClaimRewardsThroughContract is a paid mutator transaction binding the contract method 0x0f4865ea. +// +// Solidity: function claimRewardsThroughContract(address delegator, string validator) returns(bool) +func (_TestDistribute *TestDistributeTransactor) ClaimRewardsThroughContract(opts *bind.TransactOpts, delegator common.Address, validator string) (*types.Transaction, error) { + return _TestDistribute.contract.Transact(opts, "claimRewardsThroughContract", delegator, validator) +} + +// ClaimRewardsThroughContract is a paid mutator transaction binding the contract method 0x0f4865ea. +// +// Solidity: function claimRewardsThroughContract(address delegator, string validator) returns(bool) +func (_TestDistribute *TestDistributeSession) ClaimRewardsThroughContract(delegator common.Address, validator string) (*types.Transaction, error) { + return _TestDistribute.Contract.ClaimRewardsThroughContract(&_TestDistribute.TransactOpts, delegator, validator) +} + +// ClaimRewardsThroughContract is a paid mutator transaction binding the contract method 0x0f4865ea. +// +// Solidity: function claimRewardsThroughContract(address delegator, string validator) returns(bool) +func (_TestDistribute *TestDistributeTransactorSession) ClaimRewardsThroughContract(delegator common.Address, validator string) (*types.Transaction, error) { + return _TestDistribute.Contract.ClaimRewardsThroughContract(&_TestDistribute.TransactOpts, delegator, validator) +} + // DistributeThroughContract is a paid mutator transaction binding the contract method 0x50b54e84. // // Solidity: function distributeThroughContract(address zrc20, uint256 amount) returns(bool) @@ -264,157 +353,3 @@ func (_TestDistribute *TestDistributeSession) Receive() (*types.Transaction, err func (_TestDistribute *TestDistributeTransactorSession) Receive() (*types.Transaction, error) { return _TestDistribute.Contract.Receive(&_TestDistribute.TransactOpts) } - -// TestDistributeDistributedIterator is returned from FilterDistributed and is used to iterate over the raw logs and unpacked data for Distributed events raised by the TestDistribute contract. -type TestDistributeDistributedIterator struct { - Event *TestDistributeDistributed // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *TestDistributeDistributedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(TestDistributeDistributed) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(TestDistributeDistributed) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *TestDistributeDistributedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *TestDistributeDistributedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// TestDistributeDistributed represents a Distributed event raised by the TestDistribute contract. -type TestDistributeDistributed struct { - Zrc20Distributor common.Address - Zrc20Token common.Address - Amount *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterDistributed is a free log retrieval operation binding the contract event 0xad4a9acf26d8bba7a8cf1a41160d59be042ee554578e256c98d2ab74cdd43542. -// -// Solidity: event Distributed(address indexed zrc20_distributor, address indexed zrc20_token, uint256 amount) -func (_TestDistribute *TestDistributeFilterer) FilterDistributed(opts *bind.FilterOpts, zrc20_distributor []common.Address, zrc20_token []common.Address) (*TestDistributeDistributedIterator, error) { - - var zrc20_distributorRule []interface{} - for _, zrc20_distributorItem := range zrc20_distributor { - zrc20_distributorRule = append(zrc20_distributorRule, zrc20_distributorItem) - } - var zrc20_tokenRule []interface{} - for _, zrc20_tokenItem := range zrc20_token { - zrc20_tokenRule = append(zrc20_tokenRule, zrc20_tokenItem) - } - - logs, sub, err := _TestDistribute.contract.FilterLogs(opts, "Distributed", zrc20_distributorRule, zrc20_tokenRule) - if err != nil { - return nil, err - } - return &TestDistributeDistributedIterator{contract: _TestDistribute.contract, event: "Distributed", logs: logs, sub: sub}, nil -} - -// WatchDistributed is a free log subscription operation binding the contract event 0xad4a9acf26d8bba7a8cf1a41160d59be042ee554578e256c98d2ab74cdd43542. -// -// Solidity: event Distributed(address indexed zrc20_distributor, address indexed zrc20_token, uint256 amount) -func (_TestDistribute *TestDistributeFilterer) WatchDistributed(opts *bind.WatchOpts, sink chan<- *TestDistributeDistributed, zrc20_distributor []common.Address, zrc20_token []common.Address) (event.Subscription, error) { - - var zrc20_distributorRule []interface{} - for _, zrc20_distributorItem := range zrc20_distributor { - zrc20_distributorRule = append(zrc20_distributorRule, zrc20_distributorItem) - } - var zrc20_tokenRule []interface{} - for _, zrc20_tokenItem := range zrc20_token { - zrc20_tokenRule = append(zrc20_tokenRule, zrc20_tokenItem) - } - - logs, sub, err := _TestDistribute.contract.WatchLogs(opts, "Distributed", zrc20_distributorRule, zrc20_tokenRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(TestDistributeDistributed) - if err := _TestDistribute.contract.UnpackLog(event, "Distributed", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseDistributed is a log parse operation binding the contract event 0xad4a9acf26d8bba7a8cf1a41160d59be042ee554578e256c98d2ab74cdd43542. -// -// Solidity: event Distributed(address indexed zrc20_distributor, address indexed zrc20_token, uint256 amount) -func (_TestDistribute *TestDistributeFilterer) ParseDistributed(log types.Log) (*TestDistributeDistributed, error) { - event := new(TestDistributeDistributed) - if err := _TestDistribute.contract.UnpackLog(event, "Distributed", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/e2e/contracts/testdistribute/TestDistribute.json b/e2e/contracts/testdistribute/TestDistribute.json index 05ee369e1c..44201da094 100644 --- a/e2e/contracts/testdistribute/TestDistribute.json +++ b/e2e/contracts/testdistribute/TestDistribute.json @@ -1,38 +1,32 @@ { "abi": [ { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" + "stateMutability": "payable", + "type": "fallback" }, { - "anonymous": false, "inputs": [ { - "indexed": true, "internalType": "address", - "name": "zrc20_distributor", + "name": "delegator", "type": "address" }, { - "indexed": true, - "internalType": "address", - "name": "zrc20_token", - "type": "address" - }, + "internalType": "string", + "name": "validator", + "type": "string" + } + ], + "name": "claimRewardsThroughContract", + "outputs": [ { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" + "internalType": "bool", + "name": "", + "type": "bool" } ], - "name": "Distributed", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" + "stateMutability": "nonpayable", + "type": "function" }, { "inputs": [ @@ -58,10 +52,65 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getDelegatorValidatorsThroughContract", + "outputs": [ + { + "internalType": "string[]", + "name": "", + "type": "string[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + } + ], + "name": "getRewardsThroughContract", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "denom", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "internalType": "struct DecCoin[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "stateMutability": "payable", "type": "receive" } ], - "bin": "60a060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b503373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505060805161034d6100a06000396000606c015261034d6000f3fe6080604052600436106100225760003560e01c806350b54e841461002b57610029565b3661002957005b005b34801561003757600080fd5b50610052600480360381019061004d9190610201565b610068565b60405161005f919061025c565b60405180910390f35b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100c257600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b815260040161011d929190610295565b6020604051808303816000875af115801561013c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016091906102ea565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101988261016d565b9050919050565b6101a88161018d565b81146101b357600080fd5b50565b6000813590506101c58161019f565b92915050565b6000819050919050565b6101de816101cb565b81146101e957600080fd5b50565b6000813590506101fb816101d5565b92915050565b6000806040838503121561021857610217610168565b5b6000610226858286016101b6565b9250506020610237858286016101ec565b9150509250929050565b60008115159050919050565b61025681610241565b82525050565b6000602082019050610271600083018461024d565b92915050565b6102808161018d565b82525050565b61028f816101cb565b82525050565b60006040820190506102aa6000830185610277565b6102b76020830184610286565b9392505050565b6102c781610241565b81146102d257600080fd5b50565b6000815190506102e4816102be565b92915050565b600060208284031215610300576102ff610168565b5b600061030e848285016102d5565b9150509291505056fea26469706673582212205443ec313ecb8c2e08ca8a30687daed4c3b666f9318ae72ccbe9033479c8b8be64736f6c634300080a0033" + "bin": "608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005157600080fd5b50610e2d806100616000396000f3fe6080604052600436106100435760003560e01c80630f4865ea1461004c57806350b54e8414610089578063834b902f146100c6578063cdc5ec4a146101035761004a565b3661004a57005b005b34801561005857600080fd5b50610073600480360381019061006e919061059d565b610140565b6040516100809190610614565b60405180910390f35b34801561009557600080fd5b506100b060048036038101906100ab9190610665565b6101e9565b6040516100bd9190610614565b60405180910390f35b3480156100d257600080fd5b506100ed60048036038101906100e8919061059d565b610292565b6040516100fa919061083b565b60405180910390f35b34801561010f57600080fd5b5061012a6004803603810190610125919061085d565b61033d565b604051610137919061094c565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166354dbdc3884846040518363ffffffff1660e01b815260040161019e9291906109c7565b6020604051808303816000875af11580156101bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e19190610a23565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fb93210884846040518363ffffffff1660e01b8152600401610247929190610a5f565b6020604051808303816000875af1158015610266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028a9190610a23565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639342879284846040518363ffffffff1660e01b81526004016102ef9291906109c7565b600060405180830381865afa15801561030c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103359190610c69565b905092915050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b6a216ae836040518263ffffffff1660e01b81526004016103989190610cb2565b600060405180830381865afa1580156103b5573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906103de9190610dae565b9050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610424826103f9565b9050919050565b61043481610419565b811461043f57600080fd5b50565b6000813590506104518161042b565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6104aa82610461565b810181811067ffffffffffffffff821117156104c9576104c8610472565b5b80604052505050565b60006104dc6103e5565b90506104e882826104a1565b919050565b600067ffffffffffffffff82111561050857610507610472565b5b61051182610461565b9050602081019050919050565b82818337600083830152505050565b600061054061053b846104ed565b6104d2565b90508281526020810184848401111561055c5761055b61045c565b5b61056784828561051e565b509392505050565b600082601f83011261058457610583610457565b5b813561059484826020860161052d565b91505092915050565b600080604083850312156105b4576105b36103ef565b5b60006105c285828601610442565b925050602083013567ffffffffffffffff8111156105e3576105e26103f4565b5b6105ef8582860161056f565b9150509250929050565b60008115159050919050565b61060e816105f9565b82525050565b60006020820190506106296000830184610605565b92915050565b6000819050919050565b6106428161062f565b811461064d57600080fd5b50565b60008135905061065f81610639565b92915050565b6000806040838503121561067c5761067b6103ef565b5b600061068a85828601610442565b925050602061069b85828601610650565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561070b5780820151818401526020810190506106f0565b8381111561071a576000848401525b50505050565b600061072b826106d1565b61073581856106dc565b93506107458185602086016106ed565b61074e81610461565b840191505092915050565b6107628161062f565b82525050565b600060408301600083015184820360008601526107858282610720565b915050602083015161079a6020860182610759565b508091505092915050565b60006107b18383610768565b905092915050565b6000602082019050919050565b60006107d1826106a5565b6107db81856106b0565b9350836020820285016107ed856106c1565b8060005b85811015610829578484038952815161080a85826107a5565b9450610815836107b9565b925060208a019950506001810190506107f1565b50829750879550505050505092915050565b6000602082019050818103600083015261085581846107c6565b905092915050565b600060208284031215610873576108726103ef565b5b600061088184828501610442565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006108c28383610720565b905092915050565b6000602082019050919050565b60006108e28261088a565b6108ec8185610895565b9350836020820285016108fe856108a6565b8060005b8581101561093a578484038952815161091b85826108b6565b9450610926836108ca565b925060208a01995050600181019050610902565b50829750879550505050505092915050565b6000602082019050818103600083015261096681846108d7565b905092915050565b61097781610419565b82525050565b600082825260208201905092915050565b6000610999826106d1565b6109a3818561097d565b93506109b38185602086016106ed565b6109bc81610461565b840191505092915050565b60006040820190506109dc600083018561096e565b81810360208301526109ee818461098e565b90509392505050565b610a00816105f9565b8114610a0b57600080fd5b50565b600081519050610a1d816109f7565b92915050565b600060208284031215610a3957610a386103ef565b5b6000610a4784828501610a0e565b91505092915050565b610a598161062f565b82525050565b6000604082019050610a74600083018561096e565b610a816020830184610a50565b9392505050565b600067ffffffffffffffff821115610aa357610aa2610472565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b6000610ad6610ad1846104ed565b6104d2565b905082815260208101848484011115610af257610af161045c565b5b610afd8482856106ed565b509392505050565b600082601f830112610b1a57610b19610457565b5b8151610b2a848260208601610ac3565b91505092915050565b600081519050610b4281610639565b92915050565b600060408284031215610b5e57610b5d610ab9565b5b610b6860406104d2565b9050600082015167ffffffffffffffff811115610b8857610b87610abe565b5b610b9484828501610b05565b6000830152506020610ba884828501610b33565b60208301525092915050565b6000610bc7610bc284610a88565b6104d2565b90508083825260208201905060208402830185811115610bea57610be9610ab4565b5b835b81811015610c3157805167ffffffffffffffff811115610c0f57610c0e610457565b5b808601610c1c8982610b48565b85526020850194505050602081019050610bec565b5050509392505050565b600082601f830112610c5057610c4f610457565b5b8151610c60848260208601610bb4565b91505092915050565b600060208284031215610c7f57610c7e6103ef565b5b600082015167ffffffffffffffff811115610c9d57610c9c6103f4565b5b610ca984828501610c3b565b91505092915050565b6000602082019050610cc7600083018461096e565b92915050565b600067ffffffffffffffff821115610ce857610ce7610472565b5b602082029050602081019050919050565b6000610d0c610d0784610ccd565b6104d2565b90508083825260208201905060208402830185811115610d2f57610d2e610ab4565b5b835b81811015610d7657805167ffffffffffffffff811115610d5457610d53610457565b5b808601610d618982610b05565b85526020850194505050602081019050610d31565b5050509392505050565b600082601f830112610d9557610d94610457565b5b8151610da5848260208601610cf9565b91505092915050565b600060208284031215610dc457610dc36103ef565b5b600082015167ffffffffffffffff811115610de257610de16103f4565b5b610dee84828501610d80565b9150509291505056fea2646970667358221220d29e8c0ffd7f95c3ae2950ad56c9ec844a4f83f78ebf290ed1f2076d3fa1537864736f6c634300080a0033" } diff --git a/e2e/contracts/testdistribute/TestDistribute.sol b/e2e/contracts/testdistribute/TestDistribute.sol index 1ca328cfbe..00b384b871 100644 --- a/e2e/contracts/testdistribute/TestDistribute.sol +++ b/e2e/contracts/testdistribute/TestDistribute.sol @@ -30,33 +30,36 @@ interface IDistribute { // @dev Call IBank contract functions contract TestDistribute { - event Distributed( - address indexed zrc20_distributor, - address indexed zrc20_token, - uint256 amount - ); - IDistribute distr = IDistribute(0x0000000000000000000000000000000000000066); - address immutable owner; - - constructor() { - owner = msg.sender; - } + fallback() external payable {} - modifier onlyOwner() { - require(msg.sender == owner); - _; - } + receive() external payable {} function distributeThroughContract( address zrc20, uint256 amount - ) external onlyOwner returns (bool) { + ) external returns (bool) { return distr.distribute(zrc20, amount); } - fallback() external payable {} + function claimRewardsThroughContract( + address delegator, + string memory validator + ) external returns (bool) { + return distr.claimRewards(delegator, validator); + } - receive() external payable {} + function getDelegatorValidatorsThroughContract( + address delegator + ) external view returns (string[] memory) { + return distr.getDelegatorValidators(delegator); + } + + function getRewardsThroughContract( + address delegator, + string memory validator + ) external view returns (DecCoin[] memory) { + return distr.getRewards(delegator, validator); + } } diff --git a/e2e/e2etests/test_precompiles_distribute.go b/e2e/e2etests/test_precompiles_distribute.go index 8626ed6062..a6450826b5 100644 --- a/e2e/e2etests/test_precompiles_distribute.go +++ b/e2e/e2etests/test_precompiles_distribute.go @@ -62,10 +62,11 @@ func TestPrecompilesDistributeAndClaim(r *runner.E2ERunner, args []string) { require.NoError(r, err) require.GreaterOrEqual(r, len(validators), 2) - // Save first validators as it will be used through the test. - validator := validators[0] - validatorAddr, err := sdk.ValAddressFromBech32(validators[0].OperatorAddress) - require.NoError(r, err) + // Save first validator bech32 address and as it will be used through the test. + validatorAddr, validatorValAddr := getValidatorAddresses(r, distrContract) + + // Reset the test after it finishes. + defer resetDistributionTest(r, distrContract, lockerAddress, previousGasLimit, staker, validatorValAddr) // Get ERC20ZRC20. txHash := r.DepositERC20WithAmountAndMessage(staker, zrc20DistrAmt, []byte{}) @@ -77,17 +78,17 @@ func TestPrecompilesDistributeAndClaim(r *runner.E2ERunner, args []string) { require.Empty(r, dv, "DelegatorValidators response should be empty") // Shares at this point should be 0. - sharesBefore, err := distrContract.GetShares(&bind.CallOpts{}, r.ZEVMAuth.From, validator.OperatorAddress) + sharesBefore, err := distrContract.GetShares(&bind.CallOpts{}, r.ZEVMAuth.From, validatorAddr) require.NoError(r, err) require.Equal(r, int64(0), sharesBefore.Int64(), "shares should be 0 when there are no delegations") // There should be no rewards. - rewards, err := distrContract.GetRewards(&bind.CallOpts{}, staker, validator.OperatorAddress) + rewards, err := distrContract.GetRewards(&bind.CallOpts{}, staker, validatorAddr) require.NoError(r, err) require.Empty(r, rewards, "rewards should be empty when there are no delegations") // Stake with spender so it's registered as a delegator. - err = stakeThroughCosmosAPI(r, validatorAddr, staker, stakeAmt) + err = stakeThroughCosmosAPI(r, validatorValAddr, staker, stakeAmt) require.NoError(r, err) // Check initial balances. @@ -158,10 +159,10 @@ func TestPrecompilesDistributeAndClaim(r *runner.E2ERunner, args []string) { // The result should include the validator address. dv, err = distrContract.GetDelegatorValidators(&bind.CallOpts{}, staker) require.NoError(r, err) - require.Contains(r, dv, validator.OperatorAddress, "DelegatorValidators response should include validator address") + require.Contains(r, dv, validatorAddr, "DelegatorValidators response should include validator address") // Get rewards and check it contains zrc20 tokens. - rewards, err = distrContract.GetRewards(&bind.CallOpts{}, staker, validator.OperatorAddress) + rewards, err = distrContract.GetRewards(&bind.CallOpts{}, staker, validatorAddr) require.NoError(r, err) require.GreaterOrEqual(r, len(rewards), 2) found := false @@ -174,7 +175,7 @@ func TestPrecompilesDistributeAndClaim(r *runner.E2ERunner, args []string) { require.True(r, found, "rewards should include the ZRC20 token") // Claim the rewards, they'll be unlocked as ZRC20 tokens. - tx, err = distrContract.ClaimRewards(r.ZEVMAuth, staker, validator.OperatorAddress) + tx, err = distrContract.ClaimRewards(r.ZEVMAuth, staker, validatorAddr) require.NoError(r, err) receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequireTxSuccessful(r, receipt, "claim rewards should succeed") @@ -195,10 +196,8 @@ func TestPrecompilesDistributeAndClaim(r *runner.E2ERunner, args []string) { lockerFinalBalance := big.NewInt(0).Sub(zrc20DistrAmt, zrc20RewardsAmt) balanceShouldBe(r, lockerFinalBalance, checkZRC20Balance(r, lockerAddress)) - // Set the test to reset the state after it finishes. - sharesAfter, err := distrContract.GetShares(&bind.CallOpts{}, r.ZEVMAuth.From, validator.OperatorAddress) - require.NoError(r, err) - resetDistributionTest(r, lockerAddress, previousGasLimit, staker, validatorAddr, sharesAfter) + // Staker final cosmos balance should be 0. + balanceShouldBe(r, zero, checkCosmosBalance(r, sdk.AccAddress(staker.Bytes()), zrc20Denom)) } func TestPrecompilesDistributeNonZRC20(r *runner.E2ERunner, args []string) { @@ -275,12 +274,17 @@ func stakeThroughCosmosAPI( func resetDistributionTest( r *runner.E2ERunner, + distrContract *staking.IStaking, lockerAddress common.Address, previousGasLimit uint64, staker common.Address, validator sdk.ValAddress, - amount *big.Int, ) { + validatorAddr, _ := getValidatorAddresses(r, distrContract) + + amount, err := distrContract.GetShares(&bind.CallOpts{}, r.ZEVMAuth.From, validatorAddr) + require.NoError(r, err) + // Restore the gas limit. r.ZEVMAuth.GasLimit = previousGasLimit @@ -288,7 +292,7 @@ func resetDistributionTest( tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, lockerAddress, big.NewInt(0)) require.NoError(r, err) receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - utils.RequireTxSuccessful(r, receipt, "Resetting allowance failed") + utils.RequireTxSuccessful(r, receipt, "resetting allowance failed") // Reset balance to 0 for spender; this is needed when running upgrade tests where this test runs twice. balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress()) @@ -311,10 +315,26 @@ func resetDistributionTest( validator, sdk.Coin{ Denom: "azeta", - Amount: math.NewIntFromBigInt(amount), + Amount: math.NewIntFromBigInt(amount.Div(amount, big.NewInt(1e18))), }, ) _, err = r.ZetaTxServer.BroadcastTx(sdk.AccAddress(staker.Bytes()).String(), msg) require.NoError(r, err) } + +func getValidatorAddresses(r *runner.E2ERunner, distrContract *staking.IStaking) (string, sdk.ValAddress) { + // distrContract, err := staking.NewIStaking(staking.ContractAddress, r.ZEVMClient) + // require.NoError(r, err, "failed to create distribute contract caller") + + // Retrieve the list of validators. + validators, err := distrContract.GetAllValidators(&bind.CallOpts{}) + require.NoError(r, err) + require.GreaterOrEqual(r, len(validators), 2) + + // Save first validators as it will be used through the test. + validatorAddr, err := sdk.ValAddressFromBech32(validators[0].OperatorAddress) + require.NoError(r, err) + + return validators[0].OperatorAddress, validatorAddr +} diff --git a/e2e/e2etests/test_precompiles_distribute_through_contract.go b/e2e/e2etests/test_precompiles_distribute_through_contract.go index a74f24e961..aeabca1ceb 100644 --- a/e2e/e2etests/test_precompiles_distribute_through_contract.go +++ b/e2e/e2etests/test_precompiles_distribute_through_contract.go @@ -2,11 +2,13 @@ package e2etests import ( "math/big" + "strings" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/cmd/zetacored/config" "github.com/zeta-chain/node/e2e/contracts/testdistribute" "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" @@ -19,106 +21,181 @@ func TestPrecompilesDistributeAndClaimThroughContract(r *runner.E2ERunner, args require.Len(r, args, 0, "No arguments expected") var ( - spenderAddress = r.EVMAddress() - distributeContractAddress = staking.ContractAddress - lockerAddress = bank.ContractAddress + // Addresses. + staker = r.EVMAddress() + distrContractAddress = staking.ContractAddress + lockerAddress = bank.ContractAddress - zrc20Address = r.ERC20ZRC20Addr - zrc20Denom = precompiletypes.ZRC20ToCosmosDenom(zrc20Address) + // Stake amount. + stakeAmt = new(big.Int) + + // ZRC20 distribution. + zrc20Address = r.ERC20ZRC20Addr + zrc20Denom = precompiletypes.ZRC20ToCosmosDenom(zrc20Address) + zrc20DistrAmt = big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(1e6)) // carry is carried from the TestPrecompilesDistributeName test. It's applicable only to locker address. - carry = big.NewInt(6210810988040846448) - oneThousand = big.NewInt(1e3) - oneThousandOne = big.NewInt(1001) - fiveHundred = big.NewInt(500) - fiveHundredCarry = new(big.Int).Add(big.NewInt(500), carry) - fiveHundredOne = big.NewInt(501) - zero = big.NewInt(0) - - //previousGasLimit = r.ZEVMAuth.GasLimit + // This is needed because there's no easy way to retrieve that balance from the locker. + carry = big.NewInt(6210810988040846448) + zrc20DistrAmtCarry = new(big.Int).Add(zrc20DistrAmt, carry) + oneThousand = big.NewInt(1e3) + oneThousandOne = big.NewInt(1001) + fiveHundred = big.NewInt(500) + fiveHundredOne = big.NewInt(501) + zero = big.NewInt(0) + + previousGasLimit = r.ZEVMAuth.GasLimit ) - // Get ERC20ZRC20. - txHash := r.DepositERC20WithAmountAndMessage(spenderAddress, oneThousand, []byte{}) - utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + // stakeAmt has to be as big as the validator self delegation. + // This way the rewards will be distributed 50%. + _, ok := stakeAmt.SetString("1000000000000000000000", 10) + require.True(r, ok) - dstrContract, err := staking.NewIStaking(distributeContractAddress, r.ZEVMClient) + // Set new gas limit to avoid out of gas errors. + r.ZEVMAuth.GasLimit = 10_000_000 + + distrContract, err := staking.NewIStaking(distrContractAddress, r.ZEVMClient) require.NoError(r, err, "failed to create distribute contract caller") + // testDstrContract is the dApp contract that uses the staking precompile under the hood. _, tx, testDstrContract, err := testdistribute.DeployTestDistribute(r.ZEVMAuth, r.ZEVMClient) require.NoError(r, err) receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequireTxSuccessful(r, receipt, "deployment of disitributor caller contract failed") - // Set new gas limit to avoid out of gas errors. - r.ZEVMAuth.GasLimit = 10_000_000 + // Save first validator bech32 address and ValAddress as it will be used through the test. + validatorAddr, validatorValAddr := getValidatorAddresses(r, distrContract) - // Set the test to reset the state after it finishes. - //defer resetDistributionTest(r, lockerAddress, previousGasLimit) + // Reset the test after it finishes. + defer resetDistributionTest(r, distrContract, lockerAddress, previousGasLimit, staker, validatorValAddr) + + // Get ERC20ZRC20. + txHash := r.DepositERC20WithAmountAndMessage(staker, zrc20DistrAmt, []byte{}) + utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + + // There is no delegation, so the response should be empty. + dv, err := testDstrContract.GetDelegatorValidatorsThroughContract( + &bind.CallOpts{}, + staker, + ) + require.NoError(r, err) + require.Empty(r, dv, "DelegatorValidators response should be empty") + + // There should be no rewards. + rewards, err := testDstrContract.GetRewardsThroughContract(&bind.CallOpts{}, staker, validatorAddr) + require.NoError(r, err) + require.Empty(r, rewards, "rewards should be empty when there are no delegations") + + // Stake with spender so it's registered as a delegator. + err = stakeThroughCosmosAPI(r, validatorValAddr, staker, stakeAmt) + require.NoError(r, err) // Check initial balances. - balanceShouldBe(r, oneThousand, checkZRC20Balance(r, spenderAddress)) - balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) // Carries 500 from distribute e2e. + balanceShouldBe(r, zrc20DistrAmt, checkZRC20Balance(r, staker)) + balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) balanceShouldBe(r, zero, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) - receipt = distributeThroughContract(r, testDstrContract, zrc20Address, oneThousand) + tx, err = testDstrContract.DistributeThroughContract(r.ZEVMAuth, zrc20Address, oneThousand) + require.NoError(r, err) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequiredTxFailed(r, receipt, "distribute should fail when there's no allowance") // Balances shouldn't change after a failed attempt. - balanceShouldBe(r, oneThousand, checkZRC20Balance(r, spenderAddress)) - balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) // Carries 500 from distribute e2e. + balanceShouldBe(r, zrc20DistrAmt, checkZRC20Balance(r, staker)) + balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) balanceShouldBe(r, zero, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) // Allow 500. - approveAllowance(r, distributeContractAddress, fiveHundred) + approveAllowance(r, distrContractAddress, fiveHundred) - receipt = distributeThroughContract(r, testDstrContract, zrc20Address, fiveHundredOne) + tx, err = testDstrContract.DistributeThroughContract(r.ZEVMAuth, zrc20Address, fiveHundredOne) + require.NoError(r, err) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequiredTxFailed(r, receipt, "distribute should fail trying to distribute more than allowed") // Balances shouldn't change after a failed attempt. - balanceShouldBe(r, oneThousand, checkZRC20Balance(r, spenderAddress)) - balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) // Carries 500 from distribute e2e. + balanceShouldBe(r, zrc20DistrAmt, checkZRC20Balance(r, staker)) + balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) balanceShouldBe(r, zero, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) // Raise the allowance to 1000. - approveAllowance(r, distributeContractAddress, oneThousand) + approveAllowance(r, distrContractAddress, oneThousand) // Shouldn't be able to distribute more than owned balance. - receipt = distributeThroughContract(r, testDstrContract, zrc20Address, oneThousandOne) + tx, err = testDstrContract.DistributeThroughContract(r.ZEVMAuth, zrc20Address, oneThousandOne) + require.NoError(r, err) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequiredTxFailed(r, receipt, "distribute should fail trying to distribute more than owned balance") // Balances shouldn't change after a failed attempt. - balanceShouldBe(r, oneThousand, checkZRC20Balance(r, spenderAddress)) - balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) // Carries 500 from distribute e2e. + balanceShouldBe(r, zrc20DistrAmt, checkZRC20Balance(r, staker)) + balanceShouldBe(r, carry, checkZRC20Balance(r, lockerAddress)) balanceShouldBe(r, zero, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) - // Should be able to distribute 500, which is within balance and allowance. - receipt = distributeThroughContract(r, testDstrContract, zrc20Address, fiveHundred) + // Raise the allowance to max tokens. + approveAllowance(r, distrContractAddress, zrc20DistrAmt) + + // Should be able to distribute an amount which is within balance and allowance. + tx, err = testDstrContract.DistributeThroughContract(r.ZEVMAuth, zrc20Address, zrc20DistrAmt) + require.NoError(r, err) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequireTxSuccessful(r, receipt, "distribute should succeed when distributing within balance and allowance") - balanceShouldBe(r, fiveHundred, checkZRC20Balance(r, spenderAddress)) - balanceShouldBe(r, fiveHundredCarry, checkZRC20Balance(r, lockerAddress)) // Carries 500 from distribute e2e. - balanceShouldBe(r, fiveHundred, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) + balanceShouldBe(r, zero, checkZRC20Balance(r, staker)) + balanceShouldBe(r, zrc20DistrAmtCarry, checkZRC20Balance(r, lockerAddress)) + balanceShouldBe(r, zrc20DistrAmt, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) - eventDitributed, err := dstrContract.ParseDistributed(*receipt.Logs[0]) + eventDitributed, err := distrContract.ParseDistributed(*receipt.Logs[0]) require.NoError(r, err) require.Equal(r, zrc20Address, eventDitributed.Zrc20Token) - require.Equal(r, spenderAddress, eventDitributed.Zrc20Distributor) - require.Equal(r, fiveHundred.Uint64(), eventDitributed.Amount.Uint64()) + require.Equal(r, staker, eventDitributed.Zrc20Distributor) + require.Equal(r, zrc20DistrAmt.Uint64(), eventDitributed.Amount.Uint64()) // After one block the rewards should have been distributed and fee collector should have 0 ZRC20 balance. r.WaitForBlocks(1) balanceShouldBe(r, zero, checkCosmosBalance(r, r.FeeCollectorAddress, zrc20Denom)) -} -func distributeThroughContract( - r *runner.E2ERunner, - dstr *testdistribute.TestDistribute, - zrc20Address common.Address, - amount *big.Int, -) *types.Receipt { - tx, err := dstr.DistributeThroughContract(r.ZEVMAuth, zrc20Address, amount) + // DelegatorValidators returns the list of validator this delegator has delegated to. + // The result should include the validator address. + dv, err = testDstrContract.GetDelegatorValidatorsThroughContract(&bind.CallOpts{}, staker) require.NoError(r, err) - receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - return receipt + require.Contains(r, dv, validatorAddr, "DelegatorValidators response should include validator address") + + // Get rewards and check it contains zrc20 tokens. + rewards, err = testDstrContract.GetRewardsThroughContract(&bind.CallOpts{}, staker, validatorAddr) + require.NoError(r, err) + require.GreaterOrEqual(r, len(rewards), 2) + found := false + for _, coin := range rewards { + if strings.Contains(coin.Denom, config.ZRC20DenomPrefix) { + found = true + break + } + } + require.True(r, found, "rewards should include the ZRC20 token") + + tx, err = testDstrContract.ClaimRewardsThroughContract(r.ZEVMAuth, staker, validatorAddr) + require.NoError(r, err) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + utils.RequireTxSuccessful(r, receipt, "claim rewards should succeed") + + // Before claiming rewards the ZRC20 balance is 0. After claiming rewards the ZRC20 balance should be 14239697290875601808. + // Which is the amount of ZRC20 distributed, divided by two validators, and subtracted the commissions. + zrc20RewardsAmt, ok := big.NewInt(0).SetString("14239697290875601808", 10) + require.True(r, ok) + balanceShouldBe(r, zrc20RewardsAmt, checkZRC20Balance(r, staker)) + + eventClaimed, err := distrContract.ParseClaimedRewards(*receipt.Logs[0]) + require.NoError(r, err) + require.Equal(r, zrc20Address, eventClaimed.Zrc20Token) + require.Equal(r, staker, eventClaimed.ClaimAddress) + require.Equal(r, zrc20RewardsAmt.Uint64(), eventClaimed.Amount.Uint64()) + + // Locker final balance should be zrc20Distributed with carry - zrc20RewardsAmt. + lockerFinalBalance := big.NewInt(0).Sub(zrc20DistrAmtCarry, zrc20RewardsAmt) + balanceShouldBe(r, lockerFinalBalance, checkZRC20Balance(r, lockerAddress)) + + // Staker final cosmos balance should be 0. + balanceShouldBe(r, zero, checkCosmosBalance(r, sdk.AccAddress(staker.Bytes()), zrc20Denom)) } diff --git a/precompiles/staking/method_get_rewards_test.go b/precompiles/staking/method_get_rewards_test.go index e40c5a4453..961158c446 100644 --- a/precompiles/staking/method_get_rewards_test.go +++ b/precompiles/staking/method_get_rewards_test.go @@ -36,9 +36,10 @@ func Test_GetRewards(t *testing.T) { /* ASSERT */ bytes, err := s.stkContract.Run(s.mockEVM, s.mockVMContract, false) - require.Error(t, err) - require.Contains(t, err.Error(), "delegation does not exist") - require.Empty(t, bytes) + require.NoError(t, err) + res, err := getRewardsMethod.Outputs.Unpack(bytes) + require.NoError(t, err) + require.Empty(t, res[0]) }) t.Run("should return the zrc20 rewards list for a staker", func(t *testing.T) {