diff --git a/vidaia/assets/packages/thor_request_dart/LICENSE b/vidaia/assets/packages/thor_request_dart/LICENSE index ba75c69..49211e8 100644 --- a/vidaia/assets/packages/thor_request_dart/LICENSE +++ b/vidaia/assets/packages/thor_request_dart/LICENSE @@ -1 +1,21 @@ -TODO: Add your license here. +MIT License + +Copyright (c) 2022 SayNode Operations AG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vidaia/assets/packages/thor_request_dart/README.md b/vidaia/assets/packages/thor_request_dart/README.md index 8b55e73..94fb96e 100644 --- a/vidaia/assets/packages/thor_request_dart/README.md +++ b/vidaia/assets/packages/thor_request_dart/README.md @@ -1,39 +1,379 @@ - +- Covers most topic on contract interaction, vet transfer, vtho transfer and transaction debug. -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +- Automatically estimate gas and decode events/revert reasons for you. -## Features -TODO: List what your package can do. Maybe include images, gifs, or videos. -## Getting started +# Quick Start +```dart +import 'package:thor_request_dart/connect.dart'; + +Connect connector = Connect("https://testnet.veblocks.net") + +``` + +## API Reference + +```dart +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; +import 'package:thor_request_dart/contract.dart'; + +//Wallet +Wallet wallet = Wallet.fromPrivate(Uint8List privateKey); +Wallet wallet = Wallet.fromMnemonic(List words); +Wallet wallet = Wallet.fromKeyStore(String keyStore, String password); +Wallet wallet = Wallet.newWallet(); // Create a new random wallet + +// Contract +//must enter contract meta(solidity compiled contract) +Contract contract = Contract(String jsonString); +Contract contract = Contract.fromFile(String path); + +//Connect +Connect connector = Connect(String node_url); +Connect connector.getChainTag(); +Connect connector.getAccount(String address); +Connect connector.getBlock(String block, bool expanded);//default block is best +Connect connector.getTransaction(String tx_id); +Connect connector.getTransactionReceipt(String tx_id); +Connect connector.waitForTxReceipt(String tx_id); +Connect connector.replayTx(String tx_id); + +//Ticker +connector.ticker(); //returns the newest block block s a Stream + +//Deploy a smart contract +connector.deploy(Wallet wallet, Contract contract); + +//Call a contract function (won't spend gas) +connector.call(String caller, Contract contract, String func_name, + List funcParams, String to, + {BigInt value, + int gas = 0, // Note: value is in Wei + String? gasPayer, // Note: gas payer of the tx + String block = "best" // Target at which block + }); + +//Execute a contract fucntion (spend real gas) +connector.transact(Wallet wallet, Contract contract, String func_name, + List funcParams, String to, + {BigInt? value, // Note: value is in Wei + int expiration = 32, + int gasPriceCoef = 0, + int gas = 0, + String? dependsOn, // ID of old Tx that this tx depends on, None or string + bool force = false, // Force execute even if emulation failed + Wallet? gasPayer // fee delegation feature + ); + +// Multi clauses support (MTT) +clause1 = connector.clause(Contract contract, String func_name, List funcParams, String to, {BigInt? value}).getDevClause() +clause2 = connector.clause(Contract contract, String func_name, List funcParams, String to, {BigInt? value}).getDevClause() + +//.getDevClause returns a clause object as declared in the thor devkit + +// Call them (won't spend gas) +//Clause has to be a Clause object from the thor devkit +connector.callMulti(String caller, List clauses, {int gas = 0, String? gasPayer, String block = "best"}) + +// Or execute them +//Clause has to be a Clause object from the thor devkit +connector.transactMulti(Wallet wallet, List clauses, + {int gasPriceCoef = 0, + int gas = 0, + String? dependsOn, + int expiration = 32, + bool force = false, + Wallet? gasPayer}) +``` + +// Examples (Blockchain) +## Get Tx/Block/Account/Receipt +```dart +import 'package:thor_request_dart/connect.dart'; + +connector = Connect("https://testnet.veblocks.net") -TODO: List prerequisites and provide or point to information on how to -start using the package. +// Account +connector.getAccount('0x7567d83b7b8d80addcb281a71d54fc7b3364ffed') -## Usage +// >>> {'balance': '0x21671d16fd19254d67', 'energy': '0xf809f75231563b5f1d', 'hasCode': False} -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +// Block +connector.getBlock('0x0084f21562e046b1ae9aa70b6cd3b7bc2e8312f3961716ee3fcd58ce8bcb7392') + +// >>> {'number': 8712725, 'id': '0x0084f21562e046b1ae9aa70b6cd3b7bc2e8312f3961716ee3fcd58ce8bcb7392', 'size': 243, 'parentID': '0x0084f214dd0b96059a142b5ac33668a3bb56245bde62d72a7874dc5a842c89e7', 'timestamp': 1617158500, 'gasLimit': 281323205, 'beneficiary': '0xb4094c25f86d628fdd571afc4077f0d0196afb48', 'gasUsed': 0, 'totalScore': 33966653, 'txsRoot': '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0', 'txsFeatures': 1, 'stateRoot': '0xfe32d569f127a9a1d6f690bb83dae1c91fee31cac6596ae573ad3fa76c209670', 'receiptsRoot': '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0', 'signer': '0x39218d415dc252a50823a3f5600226823ba4716e', 'isTrunk': True, 'transactions': []} + +// Transaction +connector.getTransaction("0xda2ce6bddfb3bd32541c999e81ef56019a6314a23c90a466896aeefca33aebc1") + +# >>> {'id': '0xda2ce6bddfb3bd32541c999e81ef56019a6314a23c90a466896aeefca33aebc1', 'chainTag': 39, 'blockRef': '0x00825266c5688208', 'expiration': 18, 'clauses': [{'to': '0x0000000000000000000000000000456e65726779', 'value': '0x0', 'data': '0xa9059cbb0000000000000000000000007567d83b7b8d80addcb281a71d54fc7b3364ffed0000000000000000000000000000000000000000000000056bc75e2d63100000'}], 'gasPriceCoef': 0, 'gas': 51582, 'origin': '0xfa6e63168115a9202dcd834f6c20eabf48f18ba7', 'delegator': None, 'nonce': '0x32c31a501fcd9752', 'dependsOn': None, 'size': 190, 'meta': {'blockID': '0x0082526895631e850b6cae1ba0a05deb24b8719b6896b69437cea87ee939bf3d', 'blockNumber': 8540776, 'blockTimestamp': 1615439010}} + +// Transaction receipt +connector.getTransactionReceipt('0xda2ce6bddfb3bd32541c999e81ef56019a6314a23c90a466896aeefca33aebc1') + +// >>> {'gasUsed': 36582, 'gasPayer': '0xfa6e63168115a9202dcd834f6c20eabf48f18ba7', 'paid': '0x1fbad5f2e25570000', 'reward': '0x984d9c8dd8008000', 'reverted': False, 'meta': {'blockID': '0x0082526895631e850b6cae1ba0a05deb24b8719b6896b69437cea87ee939bf3d', 'blockNumber': 8540776, 'blockTimestamp': 1615439010, 'txID': '0xda2ce6bddfb3bd32541c999e81ef56019a6314a23c90a466896aeefca33aebc1', 'txOrigin': '0xfa6e63168115a9202dcd834f6c20eabf48f18ba7'}, 'outputs': [{'contractAddress': None, 'events': [{'address': '0x0000000000000000000000000000456e65726779', 'topics': ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x000000000000000000000000fa6e63168115a9202dcd834f6c20eabf48f18ba7', '0x0000000000000000000000007567d83b7b8d80addcb281a71d54fc7b3364ffed'], 'data': '0x0000000000000000000000000000000000000000000000056bc75e2d63100000'}], 'transfers': []}]} + +// Chain Tag +connector.getChainTag() +// >>> 39 +``` +## Debug a Failed Transaction + +This operation will yield pretty revert reason if any. + +```dart +import 'package:thor_request_dart/connect.dart'; + +connector = Connect("https://testnet.veblocks.net") +connector.replayTx("0x1d05a502db56ba46ccd258a5696b9b78cd83de6d0d67f22b297f37e710a72bb5") + +// Notice: Revert Reason is decoded for you. + +# [{ +# 'data': '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c7472616e7366657220746f20746865207a65726f206164647265737300000000', +# 'events': [], +# 'transfers': [], +# 'gasUsed': 659, +# 'reverted': True, +# 'vmError': 'evm: execution reverted', +# 'decoded': { +# 'revertReason': 'transfer to the zero address' +# } +# }] +``` +# Examples (Smart Contract) + +## Deploy a Smart Contract ```dart -const like = 'sample'; +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; +import 'package:thor_request_dart/contract.dart'; + +connector = Connect("https://testnet.veblocks.net") + +// wallet address: 0x7567d83b7b8d80addcb281a71d54fc7b3364ffed +_wallet = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) + +_contract = Contract.fromFile("/path/to/solc/compiled/smart_contract.json") + +res = connector.deploy(_wallet, _contract) +print(res) +// >>> {'id': '0xa670ae6fc053f3e63e9a944947d1e2eb9f53dc613fd305552ee00af987a6d140'} ``` -## Additional information +## Call a Function (won't spend gas, emulate only) + +```dart +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/contract.dart'; + +connector = Connect("https://testnet.veblocks.net") + +_contract_addr = '0x535b9a56c2f03a3658fc8787c44087574eb381fd' +_contract = Contract.fromFile("/path/to/solc/compiled/smart_contract.json") + +// Emulate the "balanceOf()" function +res = connector.call( + '0x....', //fill in your caller address or all zero address + _contract, + "balanceOf", + ['0x7567d83b7b8d80addcb281a71d54fc7b3364ffed'], + to: _contract_addr, +) +print(res) + +//Notice: The return value is decoded for you. +// +//{ +// 'data': '0x0000000000000000000000000000000000000000000000006124fee993bc0004', +// 'events': [], +// 'transfers': [], +// 'gasUsed': 557, +// 'reverted': False, +// 'vmError': '', +// 'decoded': { +// '0': 7000000000000000004 +// } +// } + +// Emulate the "deposit()" function +res = connector.call( + '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + _contract, + "deposit", + [], + to: _contract_addr, + value: 4 +) +print(res) + +// Notice the Event is decoded for you. + +/* + { + 'data': '0x', + 'events': [{ + 'address': '0x535b9a56c2f03a3658fc8787c44087574eb381fd', + 'topics': ['0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c', '0x0000000000000000000000007567d83b7b8d80addcb281a71d54fc7b3364ffed'], + 'data': '0x0000000000000000000000000000000000000000000000000000000000000004', + 'decoded': { + '0': '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + 'dst': '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + '1': 4, + 'wad': 4 + }, + 'name': 'Deposit' + }], + 'transfers': [{ + 'sender': '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + 'recipient': '0x535b9a56c2f03a3658fc8787c44087574eb381fd', + 'amount': '0x4' + }], + 'gasUsed': 6902, + 'reverted': False, + 'vmError': '' + } +/* +``` + +## Execute a Function (spend real gas) + +```dart +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; +import 'package:thor_request_dart/contract.dart'; + +connector = Connect("https://testnet.veblocks.net") + +// wallet address: 0x7567d83b7b8d80addcb281a71d54fc7b3364ffed +_wallet = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) +_contract_addr = '0x535b9a56c2f03a3658fc8787c44087574eb381fd' +_contract = Contract.fromFile("/path/to/solc/compiled/metadata.json") + +// Execute the "deposit()" function. (will pay gas) +// Send along 5 VET with the tx +res = connector.transact(_wallet, _contract, "deposit", [], to: _contract_addr, value: 5 * (10^18)) +print(res) + +// >>> {'id': '0x51222328b7395860cb9cc6d69d822cf31056851b5694eeccc9f243021eecd547'} +``` + +## Send VET and VTHO (or any vip180 token) +```dart +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; + +connector = Connect("https://testnet.veblocks.net") + +// wallet address: 0x7567d83b7b8d80addcb281a71d54fc7b3364ffed +_wallet = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) + +// Transfer 3 VET to 0x0000000000000000000000000000000000000000 +connector.transferVet( + _wallet, + '0x0000000000000000000000000000000000000000', + value: 3 * (10^18) +) + +// Transfer 3 VTHO to 0x0000000000000000000000000000000000000000 +connector.transferVtho( + _wallet, + '0x0000000000000000000000000000000000000000', + vthoInWei: 3 * (10^18) +) + +// Transfer 3 OCE to 0x0000000000000000000000000000000000000000 +connector.transferToken( + _wallet, + '0x0000000000000000000000000000000000000000', + tokenContractAddress: '0x0ce6661b4ba86a0ea7ca2bd86a0de87b0b860f14', // OCE smart contract + amountInWei: 3 * (10^18) +) + +// Check VET or VTHO balance of an address: 0x0000000000000000000000000000000000000000 +amount_vet = connector.getVetBalance('0x0000000000000000000000000000000000000000') +amount_vtho = connector.getVthoBalance('0x0000000000000000000000000000000000000000') +``` + +## VIP-191 Fee Delegation Feature (I) +```dart +// Sign a local transaction if you have: +// 1) Wallet to originate the transaction +// 2) Wallet to pay for the gas fee + +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; +import 'package:thor_request_dart/contract.dart'; + +connector = Connect("https://testnet.veblocks.net") + +// wallet 1: The transaction sender +_sender = Wallet.fromMnemonic(words=['...', '...', ... ]) + +// wallet 2: The transaction fee payer +_payer = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) + +// Smart contract +_contract_addr = '0x535b9a56c2f03a3658fc8787c44087574eb381fd' +_contract = Contract.fromFile("/path/to/solc/compiled/metadata.json") + +// For example, +// "The sender" execute the "deposit()" function on the smart contract, with 5 VET within the transaction +// Transaction paid by "the payer". +res = connector.transact( + _sender, + _contract, + "deposit", + [], + to: _contract_addr, + value: 5 * (10^18), + gasPayer: _payer +) +print(res) +// >>> {'id': '0x51222328b7395860cb9cc6d69d822cf31056851b5694eeccc9f243021eecd547'} +``` + + + + +## VIP-191 Fee Delegation Feature (II) + +```dart +// Quickly send VET or VTHO using fee delegation + +import 'package:thor_request_dart/connect.dart'; +import 'package:thor_request_dart/wallet.dart'; + +connector = Connect("https://testnet.veblocks.net") + +// sender wallet +_sender = Wallet.fromMnemonic(words=['...', '...', ... ]) + +// gas payer wallet +_payer = Wallet.fromPrivateKey(bytes.fromhex("dce1443bd2ef0c2631adc1c67e5c93f13dc23a41c18b536effbbdcbcdb96fb65")) + +// Transfer 3 VET from _sender to 0x0000000000000000000000000000000000000000 +connector.transferVet( + _sender, + '0x0000000000000000000000000000000000000000', + value: 3 * (10^18), + gasPayer: _payer +) -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +// Transfer 3 VTHO from _sender to 0x0000000000000000000000000000000000000000 +connector.transferVtho( + _sender, + '0x0000000000000000000000000000000000000000', + vthoInWei: 3 * (10^18), + gasPayer: _payer +) +``` \ No newline at end of file diff --git a/vidaia/assets/packages/thor_request_dart/assets/json_test/Vidar.json b/vidaia/assets/packages/thor_request_dart/assets/json_test/Vidar.json new file mode 100644 index 0000000..805026b --- /dev/null +++ b/vidaia/assets/packages/thor_request_dart/assets/json_test/Vidar.json @@ -0,0 +1,1240 @@ +{ + "contractName": "Vidar", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wallet", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.7.5+commit.eb77ed08\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wallet\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"constructor\":{\"params\":{\"wallet\":\"Address of the wallet, where tokens will be transferred to\"}},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is called. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"project:/contracts/Vidar.sol\":\"Vidar\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/Context.sol\":{\"keccak256\":\"0xe6247f7cb929a70f2eb5d08027f5148453491b052e5c2541422224dfe9114d3f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://dc17a25e6d8b8a9eed6a02c4cec558dc2e785a6a02404fbea0a672dd0b28aafa\",\"dweb:/ipfs/QmRDWKm2oJ3txKoMqcXkdtiDyvwoR5RnLJDujTKR8V4nP6\"]},\"project:/contracts/ERC20.sol\":{\"keccak256\":\"0xb36c349700afa2d355aa3373b7bc4412c8bdab6599dd69a740b119a7d0a74fa2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1577e6bd3001c72ab477b83295e1a6cd307587ee0c3840c480ffb6a34984e583\",\"dweb:/ipfs/QmU39w5WzBegTE7jrV9i9ZYTg4aUd4F99JJmAWGm1VpJTH\"]},\"project:/contracts/IERC20.sol\":{\"keccak256\":\"0xb1b439fbc95b6285b8a37a7c25bbfe77644b4706d8405709bd575a0e6d67191b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1c8fe1dd8140000fbbe4dd3899c15a20ea60d3ca1f9bff27ea21b9a2ff634e5a\",\"dweb:/ipfs/QmWgpKXT8syjcKdGtYUZjceghbSQmc9LVkzSYPxDwWrvnn\"]},\"project:/contracts/SafeMath.sol\":{\"keccak256\":\"0x315396befb4de875112837800a007cc55d2ae804e5ab912bc9af4300dde3bd19\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://520f6a196def8662eb474d9d9a55e1ffe541adbeb31287a76a8c02087c435511\",\"dweb:/ipfs/QmPiKRpR2DVNmSdF5YHjwE7qK19SnVqwkmAPhXRk1uok2m\"]},\"project:/contracts/Vidar.sol\":{\"keccak256\":\"0x9ed17745a70b42c2ced414e6a696b8c9d1a6a93ea1a3011d0815bf66539e0bbe\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7f20754706e7be03166054fac3d9f9aba1a8f08b597c1ba1ef2ce7f40367effb\",\"dweb:/ipfs/QmWBrdo3ZrjVJVKU7BzZSc4nRJKCjiYSP1dUUu1p2iEs8Z\"]},\"project:/contracts/authority.sol\":{\"keccak256\":\"0x9c349a445dfc7e02adeb6d09d5b84e4de6fbc4f8d3facba349b9334fad25b7b9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e46c28dacb21931d54f40aa69290a45dfa32eaed035de39a0976e55936d1da2e\",\"dweb:/ipfs/QmeStYGW2KeaqpbNpDvfasEAsyDesKMa1FXq9cfbsau8Hm\"]},\"project:/contracts/builtin.sol\":{\"keccak256\":\"0xb43b49a37c33f75323a2d16181192280402e91d75bc448d2a7bb590e46f3f61c\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://fa53869c7b1ff4292bc077432e7650f5dcdae84c4c7caf383a7166b98d4f854c\",\"dweb:/ipfs/QmS9MzJFs1CFuwssC9PCM6fSKVKpD2T3TUQgkN7uCfWj5N\"]},\"project:/contracts/energy.sol\":{\"keccak256\":\"0x8b439921d5283a65eb287c02ad9b7e3af8f5f6bc75454560ce4159742e970408\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://69a2f47412c24b0d7cab911a17098ddf990c80bb09cc7dca8718ca68c1776836\",\"dweb:/ipfs/QmYsko9WNLLqbFuyMLENWfYP8s6RTJfcGhTN1VDsqU8CYX\"]},\"project:/contracts/executor.sol\":{\"keccak256\":\"0x2859c8a4618f825d0545a2ed39cd7b08587f8bb7dda876b27f7b07266b5ea4e7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ec680b96fa4fcb9eff437a6f4ccc360154ac7bfe80ace77b8c1c62c884ea94c2\",\"dweb:/ipfs/QmcqSqrvzkPPtvaQGfHuA13jtBB2y8D7hgEzjc1KLw8TQU\"]},\"project:/contracts/extension.sol\":{\"keccak256\":\"0x9d5038d46026e46a6892827b56c376c629b95d0c9f5f13a592121ff172743e66\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://46e074a421a93b1589bc298e922f575d166fe28ce7918863da11c37045073a9e\",\"dweb:/ipfs/QmXTYDhUacwdM3VvdWJpwaMwhJitT5amMwSmZ4ztf1y4dE\"]},\"project:/contracts/params.sol\":{\"keccak256\":\"0xc017e4175cf0b22dddde7aae0fadd3ab63d6c8065b51ee1826b0e9b411450e73\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8a8cb7ad624e8df3ae4e0756bba59ed2e647e6a7544fe27530af2163c7182740\",\"dweb:/ipfs/QmSkxojMRV4hwdY9uSYZFucBw6WXxZmQPaygBLfvZudXrh\"]},\"project:/contracts/prototype.sol\":{\"keccak256\":\"0x83c04b917e45ced85c19da5b720ae46f7ed1d837fc93a13695af56746263909a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c2b010cb23596a62a00425e2b4ba7f2ede52709230776ba227f0954908b07b11\",\"dweb:/ipfs/QmT1MaG4EU2jvDComdo1PMx1rGuD3cDQrkJNqj2nM7SmAm\"]}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200138c3803806200138c833981810160405260208110156200003757600080fd5b81019080805190602001909291905050506012600360006101000a81548160ff021916908360ff160217905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141562000108576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f43616e206e6f74206265207a65726f206164647265737300000000000000000081525060200191505060405180910390fd5b62000125816a23e64eb6dbf115e50000006200012c60201b60201c565b5062000398565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415620001d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f45524332303a206d696e7420746f207a65726f2061646472657373000000000081525060200191505060405180910390fd5b620001e4600083836200030a60201b60201c565b62000200816002546200030f60201b620009101790919060201c565b6002819055506200025e816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546200030f60201b620009101790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b505050565b6000808284019050838110156200038e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610fe480620003a86000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610514565b60405180821515815260200191505060405180910390f35b61019d610532565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061053c565b60405180821515815260200191505060405180910390f35b61023f610632565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610649565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106fc565b6040518082815260200191505060405180910390f35b61031c610744565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610781565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061086b565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610889565b6040518082815260200191505060405180910390f35b60606040518060400160405280600781526020017f446f68726e696900000000000000000000000000000000000000000000000000815250905090565b6000610528610521610998565b84846109a0565b6001905092915050565b6000600254905090565b6000610549848484610bd1565b61062784610555610998565b610622856040518060400160405280601881526020017f45524332303a20616d6f756e74206578636565647320612e0000000000000000815250600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105d8610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6109a0565b600190509392505050565b6000600360009054906101000a900460ff16905090565b60006106f2610656610998565b846106ed8560016000610667610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461091090919063ffffffff16565b6109a0565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606040518060400160405280600381526020017f44484e0000000000000000000000000000000000000000000000000000000000815250905090565b600061086161078e610998565b8461085c856040518060400160405280601e81526020017f45524332303a2064656372656173656420612e2062656c6f77207a65726f0000815250600160006107d5610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6109a0565b6001905092915050565b600061087f610878610998565b8484610bd1565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008082840190508381101561098e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a612e2066726f6d207a65726f206164647265737300000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ae6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f45524332303a612e20746f207a65726f2061646472657373000000000000000081525060200191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a742e2066726f6d207a65726f206164647265737300000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d17576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f45524332303a742e20746f207a65726f2061646472657373000000000000000081525060200191505060405180910390fd5b610d22838383610fa9565b610daa816040518060400160405280601d81526020017f45524332303a20616d6f756e7420657863656564732062616c616e63650000008152506000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461091090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5b578082015181840152602081019050610f40565b50505050905090810190601f168015610f885780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fea26469706673582212205d15c0ad5b5ce71389e3e2bf9c165f5f6867ecde9b98e09b7f1ae317729c1f0064736f6c63430007050033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610514565b60405180821515815260200191505060405180910390f35b61019d610532565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061053c565b60405180821515815260200191505060405180910390f35b61023f610632565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610649565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106fc565b6040518082815260200191505060405180910390f35b61031c610744565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610781565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061086b565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610889565b6040518082815260200191505060405180910390f35b60606040518060400160405280600781526020017f446f68726e696900000000000000000000000000000000000000000000000000815250905090565b6000610528610521610998565b84846109a0565b6001905092915050565b6000600254905090565b6000610549848484610bd1565b61062784610555610998565b610622856040518060400160405280601881526020017f45524332303a20616d6f756e74206578636565647320612e0000000000000000815250600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105d8610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6109a0565b600190509392505050565b6000600360009054906101000a900460ff16905090565b60006106f2610656610998565b846106ed8560016000610667610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461091090919063ffffffff16565b6109a0565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606040518060400160405280600381526020017f44484e0000000000000000000000000000000000000000000000000000000000815250905090565b600061086161078e610998565b8461085c856040518060400160405280601e81526020017f45524332303a2064656372656173656420612e2062656c6f77207a65726f0000815250600160006107d5610998565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6109a0565b6001905092915050565b600061087f610878610998565b8484610bd1565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008082840190508381101561098e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a612e2066726f6d207a65726f206164647265737300000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ae6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f45524332303a612e20746f207a65726f2061646472657373000000000000000081525060200191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a742e2066726f6d207a65726f206164647265737300000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d17576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f45524332303a742e20746f207a65726f2061646472657373000000000000000081525060200191505060405180910390fd5b610d22838383610fa9565b610daa816040518060400160405280601d81526020017f45524332303a20616d6f756e7420657863656564732062616c616e63650000008152506000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee99092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461091090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5b578082015181840152602081019050610f40565b50505050905090810190601f168015610f885780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fea26469706673582212205d15c0ad5b5ce71389e3e2bf9c165f5f6867ecde9b98e09b7f1ae317729c1f0064736f6c63430007050033", + "immutableReferences": {}, + "generatedSources": [], + "deployedGeneratedSources": [], + "sourceMap": "120:258:5:-:0;;;242:133;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2080:2:1;2068:9;;:14;;;;;;;;;;;;;;;;;;304:1:5;286:20;;:6;:20;;;;278:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;340:29;346:6;354:14;340:5;;;:29;;:::i;:::-;242:133;120:258;;7894:374:1;7997:1;7978:21;;:7;:21;;;;7970:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8044:49;8073:1;8077:7;8086:6;8044:20;;;:49;;:::i;:::-;8121:24;8138:6;8121:12;;:16;;;;;;:24;;;;:::i;:::-;8106:12;:39;;;;8177:30;8200:6;8177:9;:18;8187:7;8177:18;;;;;;;;;;;;;;;;:22;;;;;;:30;;;;:::i;:::-;8156:9;:18;8166:7;8156:18;;;;;;;;;;;;;;;:51;;;;8244:7;8223:37;;8240:1;8223:37;;;8253:6;8223:37;;;;;;;;;;;;;;;;;;7894:374;;:::o;10799:92::-;;;;:::o;910:181:4:-;968:7;988:9;1004:1;1000;:5;988:17;;1029:1;1024;:6;;1016:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1082:1;1075:8;;;910:181;;;;:::o;120:258:5:-;;;;;;;", + "deployedSourceMap": "120:258:5:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2160:83:1;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4266:169;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;3235:100;;;:::i;:::-;;;;;;;;;;;;;;;;;;;4917:305;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;3087:83;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;5631:218;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;3398:119;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;2362:87;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6352:262;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;3730:175;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;3968:151;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;2160:83;2197:13;2230:5;;;;;;;;;;;;;;;;;2223:12;;2160:83;:::o;4266:169::-;4349:4;4366:39;4375:12;:10;:12::i;:::-;4389:7;4398:6;4366:8;:39::i;:::-;4423:4;4416:11;;4266:169;;;;:::o;3235:100::-;3288:7;3315:12;;3308:19;;3235:100;:::o;4917:305::-;5023:4;5040:36;5050:6;5058:9;5069:6;5040:9;:36::i;:::-;5087:105;5096:6;5104:12;:10;:12::i;:::-;5118:73;5156:6;5118:73;;;;;;;;;;;;;;;;;:11;:19;5130:6;5118:19;;;;;;;;;;;;;;;:33;5138:12;:10;:12::i;:::-;5118:33;;;;;;;;;;;;;;;;:37;;:73;;;;;:::i;:::-;5087:8;:105::i;:::-;5210:4;5203:11;;4917:305;;;;;:::o;3087:83::-;3128:5;3153:9;;;;;;;;;;;3146:16;;3087:83;:::o;5631:218::-;5719:4;5736:83;5745:12;:10;:12::i;:::-;5759:7;5768:50;5807:10;5768:11;:25;5780:12;:10;:12::i;:::-;5768:25;;;;;;;;;;;;;;;:34;5794:7;5768:34;;;;;;;;;;;;;;;;:38;;:50;;;;:::i;:::-;5736:8;:83::i;:::-;5837:4;5830:11;;5631:218;;;;:::o;3398:119::-;3464:7;3491:9;:18;3501:7;3491:18;;;;;;;;;;;;;;;;3484:25;;3398:119;;;:::o;2362:87::-;2401:13;2434:7;;;;;;;;;;;;;;;;;2427:14;;2362:87;:::o;6352:262::-;6445:4;6462:122;6471:12;:10;:12::i;:::-;6485:7;6494:89;6533:15;6494:89;;;;;;;;;;;;;;;;;:11;:25;6506:12;:10;:12::i;:::-;6494:25;;;;;;;;;;;;;;;:34;6520:7;6494:34;;;;;;;;;;;;;;;;:38;;:89;;;;;:::i;:::-;6462:8;:122::i;:::-;6602:4;6595:11;;6352:262;;;;:::o;3730:175::-;3816:4;3833:42;3843:12;:10;:12::i;:::-;3857:9;3868:6;3833:9;:42::i;:::-;3893:4;3886:11;;3730:175;;;;:::o;3968:151::-;4057:7;4084:11;:18;4096:5;4084:18;;;;;;;;;;;;;;;:27;4103:7;4084:27;;;;;;;;;;;;;;;;4077:34;;3968:151;;;;:::o;910:181:4:-;968:7;988:9;1004:1;1000;:5;988:17;;1029:1;1024;:6;;1016:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1082:1;1075:8;;;910:181;;;;:::o;611:106:0:-;664:15;699:10;692:17;;611:106;:::o;9448:326:1:-;9567:1;9550:19;;:5;:19;;;;9542:58;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9638:1;9619:21;;:7;:21;;;;9611:58;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9712:6;9682:11;:18;9694:5;9682:18;;;;;;;;;;;;;;;:27;9701:7;9682:27;;;;;;;;;;;;;;;:36;;;;9750:7;9734:32;;9743:5;9734:32;;;9759:6;9734:32;;;;;;;;;;;;;;;;;;9448:326;;;:::o;7104:508::-;7228:1;7210:20;;:6;:20;;;;7202:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7301:1;7280:23;;:9;:23;;;;7272:60;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7345:47;7366:6;7374:9;7385:6;7345:20;:47::i;:::-;7425:62;7447:6;7425:62;;;;;;;;;;;;;;;;;:9;:17;7435:6;7425:17;;;;;;;;;;;;;;;;:21;;:62;;;;;:::i;:::-;7405:9;:17;7415:6;7405:17;;;;;;;;;;;;;;;:82;;;;7521:32;7546:6;7521:9;:20;7531:9;7521:20;;;;;;;;;;;;;;;;:24;;:32;;;;:::i;:::-;7498:9;:20;7508:9;7498:20;;;;;;;;;;;;;;;:55;;;;7586:9;7569:35;;7578:6;7569:35;;;7597:6;7569:35;;;;;;;;;;;;;;;;;;7104:508;;;:::o;1813:192:4:-;1899:7;1932:1;1927;:6;;1935:12;1919:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1959:9;1975:1;1971;:5;1959:17;;1996:1;1989:8;;;1813:192;;;;;:::o;10799:92:1:-;;;;:::o", + "source": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity >=0.6.0 <0.8.0;\r\n\r\nimport \"./ERC20.sol\";\r\nimport \"./builtin.sol\";\r\n\r\ncontract Vidar is ERC20() {\r\n /**\r\n * @param wallet Address of the wallet, where tokens will be transferred to\r\n */\r\n constructor(address wallet) {\r\n require(wallet != address(0),'Can not be zero address');\r\n _mint(wallet, 43400000 ether);\r\n }\r\n}\r\n", + "sourcePath": "C:\\Github Code\\Vidaia\\Vidar deployment\\contracts\\Vidar.sol", + "ast": { + "absolutePath": "project:/contracts/Vidar.sol", + "exportedSymbols": { + "Authority": [ + 905 + ], + "Builtin": [ + 1313 + ], + "Context": [ + 22 + ], + "ERC20": [ + 515 + ], + "Energy": [ + 1408 + ], + "Executor": [ + 1460 + ], + "Extension": [ + 1534 + ], + "IERC20": [ + 593 + ], + "Params": [ + 1557 + ], + "Prototype": [ + 1708 + ], + "SafeMath": [ + 822 + ], + "Vidar": [ + 851 + ] + }, + "id": 852, + "license": "MIT", + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 824, + "literals": [ + "solidity", + ">=", + "0.6", + ".0", + "<", + "0.8", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "35:31:5" + }, + { + "absolutePath": "project:/contracts/ERC20.sol", + "file": "./ERC20.sol", + "id": 825, + "nodeType": "ImportDirective", + "scope": 852, + "sourceUnit": 516, + "src": "70:21:5", + "symbolAliases": [], + "unitAlias": "" + }, + { + "absolutePath": "project:/contracts/builtin.sol", + "file": "./builtin.sol", + "id": 826, + "nodeType": "ImportDirective", + "scope": 852, + "sourceUnit": 1314, + "src": "93:23:5", + "symbolAliases": [], + "unitAlias": "" + }, + { + "abstract": false, + "baseContracts": [ + { + "arguments": [], + "baseName": { + "id": 827, + "name": "ERC20", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 515, + "src": "138:5:5", + "typeDescriptions": { + "typeIdentifier": "t_contract$_ERC20_$515", + "typeString": "contract ERC20" + } + }, + "id": 828, + "nodeType": "InheritanceSpecifier", + "src": "138:7:5" + } + ], + "contractDependencies": [ + 22, + 515, + 593 + ], + "contractKind": "contract", + "fullyImplemented": true, + "id": 851, + "linearizedBaseContracts": [ + 851, + 515, + 593, + 22 + ], + "name": "Vidar", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 849, + "nodeType": "Block", + "src": "271:104:5", + "statements": [ + { + "expression": { + "arguments": [ + { + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 840, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "id": 835, + "name": "wallet", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 831, + "src": "286:6:5", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "arguments": [ + { + "hexValue": "30", + "id": 838, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "304:1:5", + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "id": 837, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "296:7:5", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 836, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "296:7:5", + "typeDescriptions": {} + } + }, + "id": 839, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "296:10:5", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "src": "286:20:5", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "hexValue": "43616e206e6f74206265207a65726f2061646472657373", + "id": 841, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "307:25:5", + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_a1788ce760bbb95449dd5f7fb91bc909fd0c24792a687443ec58169cbee0e1ad", + "typeString": "literal_string \"Can not be zero address\"" + }, + "value": "Can not be zero address" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_a1788ce760bbb95449dd5f7fb91bc909fd0c24792a687443ec58169cbee0e1ad", + "typeString": "literal_string \"Can not be zero address\"" + } + ], + "id": 834, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + -18, + -18 + ], + "referencedDeclaration": -18, + "src": "278:7:5", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 842, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "278:55:5", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 843, + "nodeType": "ExpressionStatement", + "src": "278:55:5" + }, + { + "expression": { + "arguments": [ + { + "id": 845, + "name": "wallet", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 831, + "src": "346:6:5", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "hexValue": "3433343030303030", + "id": 846, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "354:14:5", + "subdenomination": "ether", + "typeDescriptions": { + "typeIdentifier": "t_rational_43400000000000000000000000_by_1", + "typeString": "int_const 43400000000000000000000000" + }, + "value": "43400000" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_rational_43400000000000000000000000_by_1", + "typeString": "int_const 43400000000000000000000000" + } + ], + "id": 844, + "name": "_mint", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 391, + "src": "340:5:5", + "typeDescriptions": { + "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 847, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "340:29:5", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 848, + "nodeType": "ExpressionStatement", + "src": "340:29:5" + } + ] + }, + "documentation": { + "id": 829, + "nodeType": "StructuredDocumentation", + "src": "151:87:5", + "text": " @param wallet Address of the wallet, where tokens will be transferred to" + }, + "id": 850, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 832, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 831, + "mutability": "mutable", + "name": "wallet", + "nodeType": "VariableDeclaration", + "scope": 850, + "src": "254:14:5", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 830, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "254:7:5", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + } + ], + "src": "253:16:5" + }, + "returnParameters": { + "id": 833, + "nodeType": "ParameterList", + "parameters": [], + "src": "271:0:5" + }, + "scope": 851, + "src": "242:133:5", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 852, + "src": "120:258:5" + } + ], + "src": "35:345:5" + }, + "legacyAST": { + "attributes": { + "absolutePath": "project:/contracts/Vidar.sol", + "exportedSymbols": { + "Authority": [ + 905 + ], + "Builtin": [ + 1313 + ], + "Context": [ + 22 + ], + "ERC20": [ + 515 + ], + "Energy": [ + 1408 + ], + "Executor": [ + 1460 + ], + "Extension": [ + 1534 + ], + "IERC20": [ + 593 + ], + "Params": [ + 1557 + ], + "Prototype": [ + 1708 + ], + "SafeMath": [ + 822 + ], + "Vidar": [ + 851 + ] + }, + "license": "MIT" + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + ">=", + "0.6", + ".0", + "<", + "0.8", + ".0" + ] + }, + "id": 824, + "name": "PragmaDirective", + "src": "35:31:5" + }, + { + "attributes": { + "SourceUnit": 516, + "absolutePath": "project:/contracts/ERC20.sol", + "file": "./ERC20.sol", + "scope": 852, + "symbolAliases": [ + null + ], + "unitAlias": "" + }, + "id": 825, + "name": "ImportDirective", + "src": "70:21:5" + }, + { + "attributes": { + "SourceUnit": 1314, + "absolutePath": "project:/contracts/builtin.sol", + "file": "./builtin.sol", + "scope": 852, + "symbolAliases": [ + null + ], + "unitAlias": "" + }, + "id": 826, + "name": "ImportDirective", + "src": "93:23:5" + }, + { + "attributes": { + "abstract": false, + "contractDependencies": [ + 22, + 515, + 593 + ], + "contractKind": "contract", + "fullyImplemented": true, + "linearizedBaseContracts": [ + 851, + 515, + 593, + 22 + ], + "name": "Vidar", + "scope": 852 + }, + "children": [ + { + "attributes": { + "arguments": [ + null + ] + }, + "children": [ + { + "attributes": { + "name": "ERC20", + "referencedDeclaration": 515, + "type": "contract ERC20" + }, + "id": 827, + "name": "UserDefinedTypeName", + "src": "138:5:5" + } + ], + "id": 828, + "name": "InheritanceSpecifier", + "src": "138:7:5" + }, + { + "attributes": { + "implemented": true, + "isConstructor": true, + "kind": "constructor", + "modifiers": [ + null + ], + "name": "", + "scope": 851, + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "text": " @param wallet Address of the wallet, where tokens will be transferred to" + }, + "id": 829, + "name": "StructuredDocumentation", + "src": "151:87:5" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "mutability": "mutable", + "name": "wallet", + "scope": 850, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 830, + "name": "ElementaryTypeName", + "src": "254:7:5" + } + ], + "id": 831, + "name": "VariableDeclaration", + "src": "254:14:5" + } + ], + "id": 832, + "name": "ParameterList", + "src": "253:16:5" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 833, + "name": "ParameterList", + "src": "271:0:5" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "tryCall": false, + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_a1788ce760bbb95449dd5f7fb91bc909fd0c24792a687443ec58169cbee0e1ad", + "typeString": "literal_string \"Can not be zero address\"" + } + ], + "overloadedDeclarations": [ + -18, + -18 + ], + "referencedDeclaration": -18, + "type": "function (bool,string memory) pure", + "value": "require" + }, + "id": 834, + "name": "Identifier", + "src": "278:7:5" + }, + { + "attributes": { + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "!=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 831, + "type": "address", + "value": "wallet" + }, + "id": 835, + "name": "Identifier", + "src": "286:6:5" + }, + { + "attributes": { + "isConstant": false, + "isLValue": false, + "isPure": true, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "tryCall": false, + "type": "address payable", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)" + }, + "children": [ + { + "attributes": { + "name": "address" + }, + "id": 836, + "name": "ElementaryTypeName", + "src": "296:7:5" + } + ], + "id": 837, + "name": "ElementaryTypeNameExpression", + "src": "296:7:5" + }, + { + "attributes": { + "hexvalue": "30", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "token": "number", + "type": "int_const 0", + "value": "0" + }, + "id": 838, + "name": "Literal", + "src": "304:1:5" + } + ], + "id": 839, + "name": "FunctionCall", + "src": "296:10:5" + } + ], + "id": 840, + "name": "BinaryOperation", + "src": "286:20:5" + }, + { + "attributes": { + "hexvalue": "43616e206e6f74206265207a65726f2061646472657373", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "token": "string", + "type": "literal_string \"Can not be zero address\"", + "value": "Can not be zero address" + }, + "id": 841, + "name": "Literal", + "src": "307:25:5" + } + ], + "id": 842, + "name": "FunctionCall", + "src": "278:55:5" + } + ], + "id": 843, + "name": "ExpressionStatement", + "src": "278:55:5" + }, + { + "children": [ + { + "attributes": { + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "tryCall": false, + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_rational_43400000000000000000000000_by_1", + "typeString": "int_const 43400000000000000000000000" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 391, + "type": "function (address,uint256)", + "value": "_mint" + }, + "id": 844, + "name": "Identifier", + "src": "340:5:5" + }, + { + "attributes": { + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 831, + "type": "address", + "value": "wallet" + }, + "id": 845, + "name": "Identifier", + "src": "346:6:5" + }, + { + "attributes": { + "hexvalue": "3433343030303030", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": "ether", + "token": "number", + "type": "int_const 43400000000000000000000000", + "value": "43400000" + }, + "id": 846, + "name": "Literal", + "src": "354:14:5" + } + ], + "id": 847, + "name": "FunctionCall", + "src": "340:29:5" + } + ], + "id": 848, + "name": "ExpressionStatement", + "src": "340:29:5" + } + ], + "id": 849, + "name": "Block", + "src": "271:104:5" + } + ], + "id": 850, + "name": "FunctionDefinition", + "src": "242:133:5" + } + ], + "id": 851, + "name": "ContractDefinition", + "src": "120:258:5" + } + ], + "id": 852, + "name": "SourceUnit", + "src": "35:345:5" + }, + "compiler": { + "name": "solc", + "version": "0.7.5+commit.eb77ed08.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0x6e21867DB6572756e778883E17e7595b7f363310", + "transactionHash": "0x349673f3a62eddb7c7ec6f9f064b58b179fba07006b5fbf2dbad428b901ee272" + } + }, + "schemaVersion": "3.4.3", + "updatedAt": "2022-05-05T09:12:32.121Z", + "devdoc": { + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "See {IERC20-allowance}." + }, + "approve(address,uint256)": { + "details": "See {IERC20-approve}. Requirements: - `spender` cannot be the zero address." + }, + "balanceOf(address)": { + "details": "See {IERC20-balanceOf}." + }, + "constructor": { + "params": { + "wallet": "Address of the wallet, where tokens will be transferred to" + } + }, + "decimals()": { + "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is called. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." + }, + "decreaseAllowance(address,uint256)": { + "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." + }, + "increaseAllowance(address,uint256)": { + "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." + }, + "name()": { + "details": "Returns the name of the token." + }, + "symbol()": { + "details": "Returns the symbol of the token, usually a shorter version of the name." + }, + "totalSupply()": { + "details": "See {IERC20-totalSupply}." + }, + "transfer(address,uint256)": { + "details": "See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`." + }, + "transferFrom(address,address,uint256)": { + "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } +} \ No newline at end of file diff --git a/vidaia/assets/packages/thor_request_dart/coverage/lcov.info b/vidaia/assets/packages/thor_request_dart/coverage/lcov.info new file mode 100644 index 0000000..c23ab93 --- /dev/null +++ b/vidaia/assets/packages/thor_request_dart/coverage/lcov.info @@ -0,0 +1,582 @@ +SF:lib\clause.dart +DA:12,1 +DA:17,0 +DA:18,3 +DA:20,1 +DA:21,3 +DA:22,1 +DA:24,2 +DA:26,1 +DA:27,2 +DA:30,3 +DA:34,1 +DA:35,7 +LF:12 +LH:11 +end_of_record +SF:lib\contract.dart +DA:11,2 +DA:13,1 +DA:14,2 +DA:18,2 +DA:20,2 +DA:22,2 +DA:24,4 +DA:28,1 +DA:30,2 +DA:31,2 +DA:36,2 +DA:37,3 +DA:39,3 +DA:40,4 +DA:42,4 +DA:50,1 +DA:51,3 +DA:55,2 +DA:56,2 +DA:57,6 +DA:58,2 +DA:65,2 +DA:66,2 +DA:67,2 +DA:68,4 +DA:69,4 +DA:70,2 +DA:74,6 +DA:77,2 +DA:78,2 +DA:80,2 +DA:83,2 +DA:84,2 +DA:85,4 +DA:86,2 +DA:88,4 +DA:91,0 +DA:92,0 +DA:93,0 +DA:94,0 +DA:95,0 +DA:101,0 +DA:102,0 +DA:103,0 +DA:104,0 +DA:108,0 +LF:46 +LH:36 +end_of_record +SF:lib\codec.dart +DA:15,0 +DA:16,0 +DA:20,0 +DA:21,0 +DA:23,0 +DA:24,0 +DA:25,0 +DA:28,0 +DA:31,0 +DA:32,0 +DA:33,0 +DA:34,0 +DA:44,0 +DA:45,0 +DA:46,0 +DA:48,0 +DA:49,0 +DA:50,0 +DA:51,0 +DA:54,0 +DA:55,0 +DA:56,0 +DA:63,1 +DA:64,3 +DA:65,1 +DA:67,1 +DA:68,3 +DA:71,1 +DA:72,3 +DA:73,1 +DA:74,3 +DA:79,1 +DA:80,1 +DA:81,2 +DA:82,1 +DA:84,2 +DA:85,1 +DA:90,0 +DA:91,0 +DA:92,0 +DA:93,0 +DA:95,0 +DA:96,0 +DA:101,1 +DA:102,2 +DA:107,1 +DA:108,1 +DA:115,0 +DA:116,0 +DA:117,0 +DA:120,0 +DA:121,0 +DA:124,0 +DA:125,0 +DA:126,0 +DA:127,0 +DA:128,0 +DA:131,0 +DA:132,0 +DA:133,0 +DA:134,0 +DA:135,0 +DA:136,0 +DA:137,0 +DA:142,1 +DA:143,2 +DA:144,5 +DA:149,1 +DA:150,1 +DA:151,0 +DA:153,1 +DA:154,2 +DA:155,0 +DA:157,1 +DA:162,0 +DA:163,0 +DA:164,0 +DA:169,0 +DA:170,0 +DA:171,0 +DA:174,0 +DA:175,0 +DA:176,0 +DA:177,0 +DA:178,0 +DA:179,0 +DA:180,0 +DA:182,0 +DA:184,0 +DA:185,0 +DA:186,0 +DA:188,0 +DA:192,0 +DA:193,0 +DA:194,0 +DA:196,0 +DA:197,0 +DA:198,0 +DA:199,0 +DA:201,0 +DA:202,0 +DA:203,0 +DA:205,0 +DA:206,0 +DA:207,0 +DA:209,0 +DA:210,0 +DA:211,0 +DA:213,0 +DA:214,0 +DA:215,0 +DA:216,0 +DA:222,0 +DA:223,0 +DA:230,1 +DA:232,1 +DA:233,1 +DA:234,1 +DA:235,1 +DA:236,1 +DA:237,1 +DA:238,1 +DA:239,0 +DA:242,1 +DA:243,1 +DA:245,0 +DA:246,0 +DA:247,0 +DA:248,0 +DA:250,0 +DA:251,0 +DA:255,1 +DA:256,1 +DA:257,0 +DA:258,1 +DA:259,0 +DA:260,0 +DA:261,0 +DA:262,0 +DA:263,0 +DA:265,0 +DA:268,1 +DA:271,0 +DA:272,0 +DA:273,0 +DA:274,0 +DA:275,0 +DA:276,0 +DA:277,0 +DA:278,0 +DA:279,0 +DA:281,0 +DA:284,0 +DA:287,0 +DA:288,0 +DA:289,0 +DA:292,0 +DA:293,0 +DA:294,0 +DA:295,0 +DA:296,0 +DA:299,0 +DA:300,0 +DA:303,0 +DA:304,0 +DA:305,0 +DA:307,0 +DA:310,0 +DA:311,0 +DA:312,0 +DA:313,0 +DA:315,0 +DA:318,0 +DA:320,0 +LF:174 +LH:41 +end_of_record +SF:lib\connect.dart +DA:283,2 +DA:286,1 +DA:287,1 +DA:291,1 +DA:297,3 +DA:298,2 +DA:299,2 +DA:300,0 +DA:302,2 +DA:307,1 +DA:308,2 +DA:309,1 +DA:310,2 +DA:315,1 +DA:316,2 +DA:317,1 +DA:318,2 +DA:323,2 +DA:324,2 +DA:329,2 +DA:334,6 +DA:335,4 +DA:336,4 +DA:341,2 +DA:342,4 +DA:343,2 +DA:344,8 +DA:348,1 +DA:349,1 +DA:352,3 +DA:353,2 +DA:354,2 +DA:355,0 +DA:357,2 +DA:362,1 +DA:363,1 +DA:367,1 +DA:368,3 +DA:369,2 +DA:370,2 +DA:371,1 +DA:372,3 +DA:374,2 +DA:378,1 +DA:379,1 +DA:382,3 +DA:383,2 +DA:384,2 +DA:385,0 +DA:387,2 +DA:393,1 +DA:396,1 +DA:397,2 +DA:401,0 +DA:409,0 +DA:411,0 +DA:413,0 +DA:414,0 +DA:416,0 +DA:418,0 +DA:425,1 +DA:426,3 +DA:427,1 +DA:431,3 +DA:432,2 +DA:433,0 +DA:434,0 +DA:436,3 +DA:437,2 +DA:442,1 +DA:443,2 +DA:444,1 +DA:445,2 +DA:446,1 +DA:447,1 +DA:448,0 +DA:451,1 +DA:455,1 +DA:457,1 +DA:458,1 +DA:480,1 +DA:482,1 +DA:483,1 +DA:496,1 +DA:504,1 +DA:508,2 +DA:509,5 +DA:510,3 +DA:514,2 +DA:517,3 +DA:520,1 +DA:521,0 +DA:524,4 +DA:532,0 +DA:536,0 +DA:537,0 +DA:538,0 +DA:540,0 +DA:541,0 +DA:542,0 +DA:547,0 +DA:548,0 +DA:565,1 +DA:575,1 +DA:577,1 +DA:579,2 +DA:580,5 +DA:581,3 +DA:592,4 +DA:594,0 +DA:595,0 +DA:596,0 +DA:599,2 +DA:600,0 +DA:605,3 +DA:606,3 +DA:607,1 +DA:608,1 +DA:609,0 +DA:614,1 +DA:615,3 +DA:628,3 +DA:629,3 +DA:630,1 +DA:631,3 +DA:633,1 +DA:636,0 +DA:646,0 +DA:647,0 +DA:649,0 +DA:652,0 +DA:653,0 +DA:658,0 +DA:659,0 +DA:660,0 +DA:662,0 +DA:663,0 +DA:665,0 +DA:672,0 +DA:673,0 +DA:674,0 +DA:676,0 +DA:683,0 +DA:685,0 +DA:687,0 +DA:692,1 +DA:696,1 +DA:697,0 +DA:699,1 +DA:700,3 +DA:702,2 +DA:704,2 +DA:705,2 +DA:706,1 +DA:707,3 +DA:708,2 +DA:709,2 +DA:710,1 +DA:714,2 +DA:715,3 +DA:716,1 +DA:717,0 +DA:721,2 +DA:722,3 +DA:725,3 +DA:727,3 +DA:728,3 +DA:729,1 +DA:730,3 +DA:734,1 +DA:739,1 +DA:741,0 +DA:742,2 +DA:743,1 +DA:744,2 +DA:747,1 +DA:748,6 +DA:751,3 +DA:752,3 +DA:753,1 +DA:754,3 +DA:755,1 +DA:758,1 +DA:760,1 +DA:762,1 +DA:763,2 +DA:767,1 +DA:770,1 +DA:771,1 +DA:772,1 +DA:773,1 +DA:779,1 +DA:781,1 +DA:783,2 +DA:787,0 +DA:788,0 +LF:196 +LH:144 +end_of_record +SF:lib\utils.dart +DA:18,1 +DA:19,4 +DA:20,2 +DA:21,2 +DA:22,1 +DA:23,2 +DA:30,1 +DA:31,1 +DA:32,0 +DA:36,1 +DA:37,2 +DA:38,1 +DA:39,0 +DA:41,0 +DA:42,0 +DA:44,2 +DA:45,1 +DA:46,2 +DA:47,1 +DA:52,1 +DA:54,1 +DA:55,1 +DA:60,2 +DA:61,2 +DA:66,0 +DA:67,0 +DA:69,0 +DA:78,1 +DA:84,1 +DA:95,0 +DA:101,1 +DA:110,1 +DA:112,0 +DA:114,1 +DA:117,1 +DA:119,1 +DA:120,1 +DA:122,1 +DA:129,1 +DA:130,1 +DA:131,0 +DA:134,1 +DA:138,1 +DA:139,1 +DA:140,1 +DA:141,2 +DA:142,2 +DA:144,1 +DA:145,2 +DA:149,1 +DA:150,1 +DA:154,1 +DA:155,2 +DA:156,1 +DA:164,1 +DA:166,2 +DA:169,1 +DA:170,0 +DA:173,0 +DA:174,0 +DA:175,0 +DA:181,0 +DA:182,0 +DA:188,0 +DA:189,0 +DA:190,0 +DA:192,0 +DA:197,1 +DA:198,1 +DA:199,2 +DA:200,2 +DA:201,2 +DA:203,0 +DA:211,1 +DA:212,2 +DA:213,1 +DA:214,1 +DA:219,1 +DA:220,2 +DA:224,0 +DA:225,0 +DA:227,0 +DA:229,0 +DA:230,0 +DA:235,0 +DA:236,0 +DA:238,0 +DA:239,0 +DA:240,0 +DA:244,0 +DA:246,0 +DA:247,0 +DA:249,0 +DA:250,0 +DA:252,0 +DA:254,0 +DA:256,0 +DA:257,0 +DA:258,0 +DA:259,0 +DA:266,1 +DA:267,3 +DA:268,0 +DA:271,1 +DA:273,3 +DA:274,4 +DA:278,1 +LF:107 +LH:64 +end_of_record +SF:lib\wallet.dart +DA:17,2 +DA:18,6 +DA:19,0 +DA:22,8 +DA:23,6 +DA:24,6 +DA:29,1 +DA:30,1 +DA:31,0 +DA:34,1 +DA:35,1 +DA:40,1 +DA:41,1 +DA:42,1 +DA:47,1 +DA:48,1 +DA:49,2 +DA:52,1 +DA:53,2 +DA:54,1 +DA:59,1 +DA:60,2 +DA:62,5 +LF:23 +LH:21 +end_of_record diff --git a/vidaia/assets/packages/thor_request_dart/lib/clause.dart b/vidaia/assets/packages/thor_request_dart/lib/clause.dart index ca00952..b9d341f 100644 --- a/vidaia/assets/packages/thor_request_dart/lib/clause.dart +++ b/vidaia/assets/packages/thor_request_dart/lib/clause.dart @@ -2,14 +2,14 @@ import 'package:thor_devkit_dart/utils.dart'; import 'package:thor_request_dart/contract.dart'; import 'package:thor_devkit_dart/types/clause.dart' as dev; -class Clause { +class RClause { late Map clause; String? functionName; late BigInt value; late bool isCall; Contract? contract; - Clause(String to, + RClause(String to, {this.contract, this.functionName, List? functionParameters, @@ -19,8 +19,6 @@ class Clause { if (isCall) { var f = contract!.getFunctionByName(functionName!); - - //FIXME: can functionParameters be null? var data = f.encode(functionParameters!); clause = { diff --git a/vidaia/assets/packages/thor_request_dart/lib/codec.dart b/vidaia/assets/packages/thor_request_dart/lib/codec.dart new file mode 100644 index 0000000..97d70a8 --- /dev/null +++ b/vidaia/assets/packages/thor_request_dart/lib/codec.dart @@ -0,0 +1,321 @@ +/// +/// https://docs.soliditylang.org/en/v0.5.3/abi-spec.html +/// +/// +/// This was taken from: +/// https://github.com/nbltrust/dart-eth-abi-codec/blob/main/lib/src/codec.dart +/// + +import 'dart:typed_data'; +import 'package:convert/convert.dart'; +import 'package:thor_devkit_dart/crypto/address.dart'; +import 'package:thor_devkit_dart/utils.dart'; + + +bool isDynamicType(String typeName) { + if(typeName == 'bytes' || typeName == 'string') { + return true; + } + + var reg = RegExp(r"^([a-z\d\[\]\(\),]{1,})\[([\d]*)\]$"); + var match = reg.firstMatch(typeName); + if(match != null) { + var baseType = match.group(1); + var repeatCount = match.group(2); + if(repeatCount == "") { + return true; + } + return isDynamicType(baseType!); + } + + if(typeName.endsWith(')') && typeName.startsWith('(')) { + var subTypes = typeName.substring(1, typeName.length - 1).split(','); + for(var i = 0; i < subTypes.length; i++) { + if(isDynamicType(subTypes[i])) { + return true; + } + } + return false; + } + return false; +} + + +int sizeOfStaticType(String typeName) { + var reg = RegExp(r"^([a-z\d\[\]\(\),]{1,})\[([\d]*)\]$"); + var match = reg.firstMatch(typeName); + if(match != null) { + var baseType = match.group(1); + var repeatCount = match.group(2); + assert(repeatCount != ""); + return sizeOfStaticType(baseType!) * int.parse(repeatCount!); + } + + if(typeName.endsWith(')') && typeName.startsWith('(')) { + var subTypes = typeName.substring(1, typeName.length - 1).split(','); + return subTypes.fold(0, (previousValue, element) => previousValue + sizeOfStaticType(element)); + } + + // other static types all has capacity of 32 + return 32; +} + +Uint8List padLeft(Uint8List d, int alignBytes) { + int padLength = alignBytes - d.length % alignBytes; + if(padLength == alignBytes) + padLength = 0; + var filled = new List.filled(padLength, 0); + return Uint8List.fromList(Uint8List.fromList(filled) + d); +} + +Uint8List padRight(Uint8List d, int alignBytes) { + int padLength = alignBytes - d.length % alignBytes; + var filled = new List.filled(padLength, 0); + return Uint8List.fromList(d + Uint8List.fromList(filled)); +} + + + +Uint8List encodeUint256(BigInt v) { + var s = v.toRadixString(16); + if(s.length.isOdd) { + s = '0' + s; + } + var r = Uint8List.fromList(hex.decode(s)); + return padLeft(r, 32); +} + + + +Uint8List encodeInt256(BigInt v) { + var s = v.toRadixString(16); + if(s.length.isOdd) { + s = '0' + s; + } + var r = Uint8List.fromList(hex.decode(s)); + return padLeft(r, 32); +} + + + +Uint8List encodeInt(int v) { + return encodeUint256(BigInt.from(v)); +} + + + +Uint8List encodeBool(bool b) { + return encodeInt(b ? 1 : 0); +} + + + + + +Uint8List encodeFixedBytes(Uint8List v, int length) { + if(v.length > 32) { + throw Exception("Can not encode fixed bytes of length longer than 32"); + } + + if(v.length != length) { + throw Exception("incompatible byte length"); + } + + var pad0s = 32 - v.length; + List pads = []; + for(var i = 0; i < pad0s; i++) + pads.add(0); + return Uint8List.fromList(v + pads); +} + +Uint8List encodeBytes(Uint8List v) { + var length = encodeInt(v.length); + var pad0s = 32 - v.length % 32; + List pads = []; + for(var i = 0; i < pad0s; i++) + pads.add(0); + return Uint8List.fromList(length + v + pads); +} + + + +Uint8List encodeString(String s) { + var length = encodeInt(s.length); + return Uint8List.fromList(length + padRight(Uint8List.fromList(s.codeUnits), 32)); +} + + + +Uint8List encodeAddress(String a) { + if (!Address.isAddress(a)) { + throw Exception('Is not valid address'); + } + Uint8List encoded = hexToBytes(a); + if(encoded.length != 20) { + throw Exception("invalid address length"); + } + return padLeft(encoded, 32); +} + + + +Uint8List encodeList(List l, String type) { + var length = encodeInt(l.length); + return Uint8List.fromList(length + encodeFixedLengthList(l, type, l.length)); +} + + + +Uint8List encodeFixedLengthList(List l, String type, int length) { + if(l.length != length) { + throw Exception("incompatibal input list length for type ${type}"); + } + + if(isDynamicType(type)) { + List relocates = []; + var baseOffset = 32 * length; + List contents = []; + for(var i = 0; i < length; i++) { + relocates.addAll(encodeInt(baseOffset + contents.length)); + contents.addAll(encodeType(type, l[i])); + } + return Uint8List.fromList(relocates + contents); + } else { + List contents = []; + for(var i = 0; i < length; i++) { + contents.addAll(encodeType(type, l[i])); + } + return Uint8List.fromList(contents); + } +} + +List splitTypes(String typesStr) { + if(typesStr.length == 0) + return []; + var currentStart = 0; + List subTypes = []; + List parentheses = []; + for(var i = 0; i < typesStr.length; i++) { + var c = typesStr[i]; + switch(c) { + case '(': + case '[': + parentheses.add(c); + break; + case ')': + var pop = parentheses.removeLast(); + assert(pop == '('); + break; + case ']': + var pop = parentheses.removeLast(); + assert(pop == '['); + break; + case ',': + if(parentheses.isEmpty) { + subTypes.add(typesStr.substring(currentStart, i)); + currentStart = i + 1; + } + break; + } + } + + if(currentStart < typesStr.length) { + subTypes.add(typesStr.substring(currentStart)); + } + return subTypes; +} + + + +Uint8List encodeType(String type, dynamic data) { + switch (type) { + case 'string': + return encodeString(data); + case 'address': + return encodeAddress(data); + case 'bool': + return encodeBool(data); + case 'bytes': + return encodeBytes(data); + } + + var reg = RegExp(r"^([a-z\d\[\]\(\),]{1,})\[([\d]*)\]$"); + var match = reg.firstMatch(type); + if(match != null) { + var baseType = match.group(1); + var repeatCount = match.group(2); + if(repeatCount == "") { + return encodeList(data, baseType!); + } else { + int repeat = int.parse(repeatCount!); + return encodeFixedLengthList(data, baseType!, repeat); + } + } + + if(type.startsWith('uint')) { + if(data is BigInt) + return encodeUint256(data); + else if(data is String) { + String d = data.toLowerCase(); + if(d.startsWith('0x')) { + return encodeUint256(BigInt.parse(d.substring(2), radix: 16)); + } else if(d.contains(new RegExp(r'[a-f]'))) { + return encodeUint256(BigInt.parse(d, radix: 16)); + } else { + return encodeUint256(BigInt.parse(d)); + } + } else + return encodeInt(data); + } + + if(type.startsWith('int')) { + if(data is BigInt) + return encodeInt256(data); + else if(data is String) { + String d = data.toLowerCase(); + if(d.startsWith('0x')) { + return encodeInt256(BigInt.parse(d.substring(2), radix: 16)); + } else if(d.contains(new RegExp(r'[a-f]'))) { + return encodeInt256(BigInt.parse(d, radix: 16)); + } else { + return encodeInt256(BigInt.parse(d)); + } + } else + return encodeInt(data); + } + + if(type.startsWith('bytes')) { + var length = int.parse(type.substring(5)); + return encodeFixedBytes(data, length); + } + + if(type.startsWith('(') && type.endsWith(')')) { + var types = type.substring(1, type.length - 1); + var subtypes = splitTypes(types); + if(subtypes.length != (data as List).length) { + throw Exception("incompatibal input length and contract abi arguments for ${type}"); + } + + List headers = []; + List contents = []; + + int baseOffset = 0; + for(var i = 0; i < subtypes.length; i++) { + if(isDynamicType(subtypes[i])) + baseOffset += 32; + else + baseOffset += sizeOfStaticType(subtypes[i]); + } + + for(var i = 0; i < subtypes.length; i++) { + if(isDynamicType(subtypes[i])) { + headers.addAll(encodeInt(baseOffset + contents.length)); + contents.addAll(encodeType(subtypes[i], data[i])); + } else { + headers.addAll(encodeType(subtypes[i], data[i])); + } + } + return Uint8List.fromList(headers + contents); + } + throw Exception(''); +} \ No newline at end of file diff --git a/vidaia/assets/packages/thor_request_dart/lib/connect.dart b/vidaia/assets/packages/thor_request_dart/lib/connect.dart index e1bc95e..bb630be 100644 --- a/vidaia/assets/packages/thor_request_dart/lib/connect.dart +++ b/vidaia/assets/packages/thor_request_dart/lib/connect.dart @@ -5,13 +5,13 @@ import 'package:collection/collection.dart'; import 'package:http/http.dart' as http; import 'package:thor_devkit_dart/crypto/blake2b.dart'; import 'package:thor_devkit_dart/crypto/secp256k1.dart'; -import 'package:thor_devkit_dart/transaction.dart'; import 'package:thor_devkit_dart/utils.dart'; import 'package:thor_devkit_dart/types/clause.dart' as dev; import 'package:thor_request_dart/clause.dart'; import 'package:thor_request_dart/contract.dart'; import 'package:thor_request_dart/utils.dart'; import 'package:thor_request_dart/wallet.dart'; + const String vthoAbi = """ { "abi": [ @@ -319,7 +319,7 @@ class Connect { return balance; } - ///[block] enter block id or number, [expanded] returned block data should be expanded + ///Returns block as a Map. [block] enter block id or number, [expanded] returned block data should be expanded Future getBlock({String block = 'best', bool expanded = false}) async { var headers = { 'accept': 'application/json', @@ -333,7 +333,7 @@ class Connect { } var u = Uri.parse('$url/blocks/$block?expanded=$e'); var res = await http.get(u, headers: headers); - Map map = jsonDecode(res.body); + Map map = json.decode(res.body); return map; } @@ -344,7 +344,7 @@ class Connect { return int.parse(p.substring(p.length - 2), radix: 16); } - ///get transaction data of trnsaction with id [transactionId] + ///Get transaction data of transaction with id [transactionId] Future getTransaction(String transactionId) async { var headers = { 'accept': 'application/json', @@ -358,7 +358,7 @@ class Connect { return output; } - ///post a new transaction with raw payload [raw] + ///Post a new transaction with raw payload [raw] Future postTransaction(String raw) async { var headers = { 'accept': 'application/json', @@ -407,7 +407,6 @@ class Connect { ///stream output of best block Stream ticker() async* { - //var i = 1; Map oldBlock = await getBlock(); while (true) { Map newBlock = await getBlock(); @@ -434,7 +433,6 @@ class Connect { throw Exception("HTTP error: ${res.statusCode} ${res.reasonPhrase}, $r"); } Map allResponses = json.decode(res.body)[0]; // A list of responses - return [injectRevertReason(allResponses)]; } @@ -459,7 +457,6 @@ class Connect { return emulate(emulate_body, block: block); } -//TODO: is this really needed? remove if not ///There are two types of calls: ///1) Function call on a smart contract /// Build a clause according to the function name and params. @@ -478,10 +475,11 @@ class Connect { ///Address of the contract. ///value : int, optional ///VET sent with the clause in Wei, by default 0 - Clause clause(Contract contract, String func_name, List funcParams, String to, + RClause clause( + Contract contract, String func_name, List funcParams, String to, {BigInt? value}) { value ??= BigInt.zero; - return Clause(to, + return RClause(to, contract: contract, functionName: func_name, functionParameters: funcParams, @@ -530,36 +528,21 @@ class Connect { ///This WON'T create ANY change on blockchain. ///Only emulation happens. ///If the called functions has any return value, it will be included in "decoded" field - Future> call_multi(String caller, List clauses, + Future> callMulti(String caller, List clauses, {int gas = 0, String? gasPayer, String block = "best"}) async { bool needFeeDelegation = gasPayer != null; // Build tx body - List tempClauses = []; - for (var clause in clauses) { - tempClauses.add(json.encode(clause.clause)); - } Map b = await getBlock(); - var txBody = buildTxBody([json.encode(tempClauses)], await getChainTag(), - calc_blockRef(b["id"]), calc_nonce(), + + var tx = buildTransaction( + clauses, await getChainTag(), calc_blockRef(b["id"]), calc_nonce(), gas: gas, feeDelegation: needFeeDelegation); + var txBody = json.decode(tx.toJsonString()); // Emulate the Tx var eResponses = await emulateTx(caller, txBody, block: block, gasPayer: gasPayer); assert(eResponses.length == clauses.length); - -/* - // Try to beautify the responses - List _responses = []; - for response, clause in zip(eResponses, clauses): - // Failed response just ouput plain response - if is_emulate_failed(response): - _responses.append(response) - continue - // Success response inject beautified decoded data - _responses.append( - _beautify(response, clause.get_contract(), clause.get_func_name())) -*/ return eResponses; } @@ -574,7 +557,7 @@ class Connect { Wallet? gasPayer // fee delegation feature }) async { value ??= BigInt.zero; - Clause clause = + RClause clause = this.clause(contract, func_name, funcParams, to, value: value); var needFeeDelegation = gasPayer != null; var b = await getBlock(); @@ -586,25 +569,24 @@ class Connect { gas: gas, feeDelegation: needFeeDelegation); - List eResponses; + Future> eResponses; // Emulate the tx first. if (!needFeeDelegation) { eResponses = - await emulateTx(wallet.adressString, json.decode(txBody.toJsonString())); + emulateTx(wallet.adressString, json.decode(txBody.toJsonString())); } else { - eResponses = await emulateTx( + eResponses = emulateTx( wallet.adressString, json.decode(txBody.toJsonString()), gasPayer: gasPayer.adressString); } - if (any_emulate_failed(eResponses) && force == false) { - throw Exception("Tx will revert: $eResponses"); + if (any_emulate_failed(await eResponses) && force == false) { + throw Exception(""); } // Get gas estimation from remote node // Calculate a safe gas for user var vmGas = read_vm_gases(await eResponses).sum; - print(vmGas); var safeGas = suggest_gas_for_tx(vmGas, json.decode(txBody.toJsonString())); if (gas < safeGas) { if (gas != 0 && force == false) { @@ -614,20 +596,15 @@ class Connect { // Fill out the gas for user if (gas == 0) { - print(safeGas); txBody.gas.big = BigInt.from(safeGas); } - // Post it to the remote node - /* - var encodedRaw; - if (!needFeeDelegation) { - encodedRaw = - encodedRaw = calcTxSignedEncoded(wallet, json.decode(txBody.toJsonString())); - } else { - encodedRaw = calc_tx_signed_with_fee_delegation(wallet, gasPayer, json.decode(txBody.toJsonString())); + +//post to remote node + if (needFeeDelegation) { + txBody = calc_tx_signed_with_fee_delegation(wallet, gasPayer, txBody); } - */ + Uint8List h = blake2b256([txBody.encode()]); Uint8List sig = sign(h, wallet.priv).serialize(); txBody.signature = sig; @@ -636,20 +613,21 @@ class Connect { return postTransaction(raw); } - transactMulti(Wallet wallet, List clauses, + transactMulti(Wallet wallet, List clauses, {int gasPriceCoef = 0, int gas = 0, String? dependsOn, int expiration = 32, bool force = false, Wallet? gasPayer}) async { + assert(clauses.isNotEmpty); //Emulate transaction first List eResponses; if (gasPayer != null) { - eResponses = await call_multi(wallet.adressString, clauses, + eResponses = await callMulti(wallet.adressString, clauses, gas: gas, gasPayer: gasPayer.adressString); } else { - eResponses = await call_multi(wallet.adressString, clauses, gas: gas); + eResponses = await callMulti(wallet.adressString, clauses, gas: gas); } if (any_emulate_failed(eResponses)) { @@ -658,75 +636,90 @@ class Connect { bool needFeeDelegation = gasPayer != null; //parse clauses - List mapClauses = []; - for (var clause in clauses) { - mapClauses.add(json.encode(clause.clause)); - } + int chainTag = await getChainTag(); var b = await getBlock(); //Build body - var txBody = buildTxBody(mapClauses, chainTag, b['id'], calc_nonce(), + var tx = buildTransaction( + clauses, chainTag, calc_blockRef(b["id"]), calc_nonce(), expiration: expiration, gas: gas, gasPriceCoef: gasPriceCoef, feeDelegation: needFeeDelegation); - //GEt gas estimation for remote node - //Calculate gas safe for user + var txBody = json.decode(tx.toJsonString()); + // Get gas estimation from remote node + // Calculate a safe gas for user var vmGas = read_vm_gases(eResponses).sum; - var safeGas = suggest_gas_for_tx(vmGas, txBody); + var safeGas = suggest_gas_for_tx(vmGas, json.decode(tx.toJsonString())); if (gas < safeGas) { - if (!force) { - throw Exception('gas $gas < emulated gas $safeGas'); + if (gas != 0 && force == false) { + throw Exception("gas $gas < emulated gas $safeGas"); } } + // Fill out the gas for user + if (gas == 0) { + tx.gas.big = BigInt.from(safeGas); + } + //post to remote node - var encodedRaw; - if (!needFeeDelegation) { - encodedRaw = calcTxSignedEncoded(wallet, txBody); - } else { - encodedRaw = calc_tx_signed_with_fee_delegation(wallet, gasPayer, txBody); + if (needFeeDelegation) { + tx = calc_tx_signed_with_fee_delegation(wallet, gasPayer, txBody); } - return postTransaction(encodedRaw); + + Uint8List h = blake2b256([tx.encode()]); + Uint8List sig = sign(h, wallet.priv).serialize(); + tx.signature = sig; + String raw = '0x' + bytesToHex(tx.encode()); + + return postTransaction(raw); } ///Deploy a smart contract to blockchain - ///This is a single clause transaction. + ///This is a single clause transaction. [paramsTypes] Constructor params types, [params] Constructor params, [value] send VET in Wei with constructor call Future deploy(Wallet wallet, Contract contract, List paramsTypes, List params, BigInt value) async { //build transaction body - var dataBytes; + Uint8List dataBytes; if (paramsTypes.isEmpty) { dataBytes = contract.getBytecode(); } else { - dataBytes = contract.getBytecode() + buildParams(paramsTypes, params); + dataBytes = Uint8List.fromList( + contract.getBytecode() + buildParams(paramsTypes, params)); } var data = "0x" + bytesToHex(dataBytes); + var b = await getBlock(); - Map clause = {"to": null, "value": value, "data": data}; - var txBody = buildTxBody( - [json.encode(clause)], + Map clause = {"to": null, "value": value.toString(), "data": data}; + var txBody = buildTransaction( + [dev.Clause(null, value.toString(), data)], await getChainTag(), calc_blockRef(b["id"]), calc_nonce(), gas: 0, // We will estimate the gas later ); - // We emulate it first. - var eResponses = await emulateTx(wallet.adressString, txBody); + var eResponses = await emulateTx( + wallet.adressString, json.decode(txBody.toJsonString())); if (any_emulate_failed(eResponses)) { throw Exception("Tx will revert: $eResponses"); } // Get gas estimation from remote var vmGas = read_vm_gases(eResponses).sum; - var safeGas = suggest_gas_for_tx(vmGas, txBody); + var safeGas = suggest_gas_for_tx(vmGas, json.decode(txBody.toJsonString())); // Fill out the gas for user. - txBody["gas"] = safeGas; + txBody.gas.big = BigInt.from(safeGas); + + Uint8List h = blake2b256([txBody.encode()]); + Uint8List sig = sign(h, wallet.priv).serialize(); + txBody.signature = sig; + String raw = '0x' + bytesToHex(txBody.encode()); - var encodedRaw = calcTxSignedEncoded(wallet, txBody); - return postTransaction(encodedRaw); + //var encodedRaw = calcTxSignedEncoded(wallet, txBody); + //print(encodedRaw); + return postTransaction(raw); } ///Convenient function: do a pure VET transfer @@ -735,7 +728,7 @@ class Connect { {BigInt? value, Wallet? gasPayer}) async { value ??= BigInt.zero; var clause = dev.Clause(to, value.toRadixString(10), '0x'); - Clause(to, value: value); + RClause(to, value: value); var b = await getBlock(); //TODO: emulate gas? var gas = 21000; @@ -780,7 +773,6 @@ Map _beautify(Map response, Contract contract, String func_name) { } response["events"] = [ - //FIXME:dont think this will work in dart, fix if it doesnt for (var item in response["events"]) {inject_decoded_event(item, contract)} ]; diff --git a/vidaia/assets/packages/thor_request_dart/lib/utils.dart b/vidaia/assets/packages/thor_request_dart/lib/utils.dart index de4360e..6d70cde 100644 --- a/vidaia/assets/packages/thor_request_dart/lib/utils.dart +++ b/vidaia/assets/packages/thor_request_dart/lib/utils.dart @@ -8,9 +8,13 @@ import 'package:thor_devkit_dart/transaction.dart'; import 'package:thor_devkit_dart/types/clause.dart'; import 'package:thor_devkit_dart/types/reserved.dart'; import 'package:thor_devkit_dart/utils.dart'; +import 'package:thor_request_dart/codec.dart'; import 'package:thor_request_dart/contract.dart'; import 'package:thor_request_dart/wallet.dart'; +import 'package:rlp/rlp.dart'; + + Map injectRevertReason(Map emulateResponse) { if (emulateResponse["reverted"] == true && emulateResponse["data"] != "0x") { String encodedRevertReason = emulateResponse['data'].substring(138); @@ -32,7 +36,7 @@ Map calcEmulateTxBody(String caller, Map txBody, {String? gaspayer}) { var eClauses = []; for (var clause in txBody['clauses']) { if (clause is String) { - var c = json.decode(clause); + Map c = json.decode(clause); eClauses.add( {'to': c['to'], 'value': c['value'].toString(), 'data': c['data']}); @@ -192,7 +196,6 @@ Map inject_decoded_event(Map event_dict, Contract contract) { ///Extract vm gases from a batch of emulated executions. List read_vm_gases(List emulatedResponses) { List results = []; - print(emulatedResponses); for (var item in emulatedResponses) { if (item["gasUsed"] is int) { results.add(item["gasUsed"]); @@ -219,7 +222,6 @@ int calcGas(int vmGas, int intrinsicGas) { ///Build signed transaction from tx body Transaction calcTxSigned(Wallet wallet, Map txBody) { - print(txBody); Transaction tx = Transaction.fromJsonString(json.encode(txBody)); //var message_hash = tx.getSigningHash(null); var msgHash = blake2b256([tx.encode()]); @@ -240,8 +242,7 @@ String calcTxSignedEncoded(Wallet wallet, Map txBody) { } Transaction calc_tx_signed_with_fee_delegation( - Wallet caller, Wallet payer, Map tx_body) { - Transaction tx = Transaction.fromJsonString(json.encode(tx_body)); + Wallet caller, Wallet payer, Transaction tx) { assert(tx.isDelegated() == true); var callerHash = tx.getSigningHash(null); @@ -262,5 +263,16 @@ Transaction calc_tx_signed_with_fee_delegation( //TODO: return proper encoded data ///ABI encode params according to types Uint8List buildParams(List types, List args) { - return Uint8List.fromList([]); + if (types.length != args.length) { + throw Exception('types and args length has to be the same'); + } + + List out = []; + + for (var i = 0; i < types.length; i++) { + out.addAll(encodeType(types[i], args[i])); + } + + + return Uint8List.fromList(out); } diff --git a/vidaia/assets/packages/thor_request_dart/pubspec.yaml b/vidaia/assets/packages/thor_request_dart/pubspec.yaml index f5e4045..492e2aa 100644 --- a/vidaia/assets/packages/thor_request_dart/pubspec.yaml +++ b/vidaia/assets/packages/thor_request_dart/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: #thor devkit dependencies pointycastle: ^3.5.2 thor_devkit_dart: - path: ../thor_devkit_dart + path: C:/Users/SayNode/Documents/GitHub/thor-devkit.dart/thor_devkit_dart dev_dependencies: diff --git a/vidaia/assets/packages/thor_request_dart/test/connect_real_server_test.dart b/vidaia/assets/packages/thor_request_dart/test/connect_real_server_test.dart index 1144730..9fad38e 100644 --- a/vidaia/assets/packages/thor_request_dart/test/connect_real_server_test.dart +++ b/vidaia/assets/packages/thor_request_dart/test/connect_real_server_test.dart @@ -5,16 +5,16 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:thor_devkit_dart/crypto/blake2b.dart'; import 'package:thor_devkit_dart/crypto/secp256k1.dart'; -import 'package:thor_devkit_dart/crypto/thor_signature.dart'; import 'package:thor_devkit_dart/transaction.dart'; import 'package:thor_devkit_dart/types/clause.dart'; import 'package:thor_devkit_dart/utils.dart'; +import 'package:thor_request_dart/clause.dart'; import 'package:thor_request_dart/connect.dart'; import 'package:thor_request_dart/contract.dart'; +import 'package:thor_request_dart/utils.dart'; import 'package:thor_request_dart/wallet.dart'; void main() { - test('emulate', () async { Connect connect = Connect('https://testnet.veblocks.net'); Map b = json.decode(File("assets/json_test/tx.json").readAsStringSync()); @@ -74,21 +74,29 @@ void main() { Connect connect = Connect('https://testnet.veblocks.net'); Contract contract = Contract(contractMeta); - var a = await connect.call( + Map a = await connect.call( '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', contract, 'balanceOf', ['0x5034aa590125b64023a0262112b98d72e3c8e40e'], '0x5034aa590125b64023a0262112b98d72e3c8e40e'); - print(a); + + String matcher = + """{"data":"0x","events":[],"transfers":[],"gasUsed":0,"reverted":false,"vmError":""}"""; + + expect(json.encode(a), matcher); }); test('post transaction', () async { + Connect connect = Connect('https://testnet.veblocks.net'); List clauses = [ Clause("0x0000000000000000000000000000000000000000", "1000000000000000000", "0x"), ]; - Transaction tx = Transaction(39, "0x00634b0a00639801", "72000000", clauses, + var blo = await connect.getBlock(); + + //Blockref +1 before test + Transaction tx = Transaction(39, "0x00634b0a00639804", "72000000", clauses, "0", "21000", null, "12345678", null); Uint8List privateKey = hexToBytes( "7582be841ca040aa940fff6c05773129e135623e41acce3e0b8ba520dc1ae26a"); @@ -96,34 +104,91 @@ void main() { Uint8List sig = sign(h, privateKey).serialize(); tx.signature = sig; String raw = '0x' + bytesToHex(tx.encode()); - Connect connect = Connect('https://testnet.veblocks.net'); - // var a = await connect.postTransaction(raw); - //print(a); + + var a = await connect.postTransaction(raw); + expect(isHexString(a['id']), true); }); test('transfer VET test', () async { Connect connect = Connect('https://testnet.veblocks.net'); Wallet wallet = Wallet(hexToBytes( '7582be841ca040aa940fff6c05773129e135623e41acce3e0b8ba520dc1ae26a')); - print(await connect.transferVet( - wallet, '0x5034aa590125b64023a0262112b98d72e3c8e40e', value: BigInt.parse('37000000000000000000')),); + var a = await connect.transferVet( + wallet, '0x5034aa590125b64023a0262112b98d72e3c8e40e', + value: BigInt.parse('37000000000000000000')); + + expect(isHexString(a['id']), true); }); test('transfer VTHO test', () async { Connect connect = Connect('https://testnet.veblocks.net'); Wallet wallet = Wallet(hexToBytes( '27196338e7d0b5e7bf1be1c0327c53a244a18ef0b102976980e341500f492425')); - print(await connect.transferVtho( - wallet, '0x5034aa590125b64023a0262112b98d72e3c8e40e')); + var a = await connect.transferVtho( + wallet, '0x5034aa590125b64023a0262112b98d72e3c8e40e'); + + expect(isHexString(a['id']), true); }); + + test('recipt test', () async { + Connect connect = Connect('https://testnet.veblocks.net'); + var a = await connect.waitForTxReceipt( + '0x3c13b9db88babe6c3a74a42aec5202d6f664c9493a5a950f15ce166ac83006fe'); + + expect(a!['gasPayer'], '0x339fb3c438606519e2c75bbf531fb43a0f449a70'); + }); + test('transfer Token test', () async { Connect connect = Connect('https://testnet.veblocks.net'); Wallet wallet = Wallet(hexToBytes( '27196338e7d0b5e7bf1be1c0327c53a244a18ef0b102976980e341500f492425')); - print(await connect.transferToken( + var a = await connect.transferToken( wallet, '0x5034aa590125b64023a0262112b98d72e3c8e40e', - '0x5034aa590125b64023a0262112b98d72e3c8e40e')); + '0x5034aa590125b64023a0262112b98d72e3c8e40e'); + + expect(isHexString(a['id']), true); + }); + + test('deploy contract', () async { + Connect connect = Connect('https://testnet.veblocks.net'); + Wallet wallet = Wallet(hexToBytes( + '27196338e7d0b5e7bf1be1c0327c53a244a18ef0b102976980e341500f492425')); + + BigInt value = BigInt.from(0); + var a = await connect.deploy( + wallet, + Contract.fromFilePath('assets/json_test/Vidar.json'), + ['string', 'address'], + ['Vidar', '0x17ACC76e4685AEA9d574705163E871b83e36697f'], + BigInt.zero); + expect(isHexString(a['id']), true); }); -} + test('type encoding', () { + var a = buildParams(['uint32', 'bool'], [69, true]); + expect(bytesToHex(a), + '00000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'); + }); + + test('replay', () async { + Connect connect = Connect('https://testnet.veblocks.net'); + var a = await connect.replayTx( + '0xb133e01c7eb242a045dc56db4e898b5e45fd68c7c5ee1d0649f1c4b84220258e'); + print(a); + }); + test('transact Multiple', () async { + Connect connect = Connect('https://testnet.veblocks.net'); + Wallet wallet = Wallet(hexToBytes( + '27196338e7d0b5e7bf1be1c0327c53a244a18ef0b102976980e341500f492425')); + List clauses =[ + Clause("0x0000000000000000000000000000000000000000", + "1000000000000000000", "0x"), + ]; + var a = await connect.transactMulti(wallet, clauses); + expect(isHexString(a['id']), true); + }); + + + +}