jcc-solidity-utils
Version:
jcc solidity utils
1,056 lines (1,055 loc) • 470 kB
JSON
{
"contractName": "ChainList",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.4.24+commit.e67f0147\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/ChainList.sol\":\"ChainList\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/ChainList.sol\":{\"keccak256\":\"0x89f2e8957412795e5e4296a8f83b787736a043280dcf1d032170838a849e461c\",\"urls\":[\"bzzr://2787c91383da9eabe221e7058451a9e7ed6c75b44e656b0a235888701ed836e6\"]},\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x239546071316c89d3bbc9e61b2ccae270a4493bbd2f7c240052f533807d50ab7\",\"urls\":[\"bzzr://267bf48e0a30f7b671aa3c98a6b27ffe7bc64efd6533f49e54188b520baa94c5\"]}},\"version\":1}",
"bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820f82cbac49dbe027212f1999d62475398aec32aa4703bb417ef0df66421216b650029",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820f82cbac49dbe027212f1999d62475398aec32aa4703bb417ef0df66421216b650029",
"sourceMap": "91:3335:14:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24",
"deployedSourceMap": "91:3335:14:-;;;;;;;;",
"source": "pragma solidity >=0.4.24;\n\nimport \"../math/SafeMath.sol\";\n\n/**\n * @dev 区块链列表\n */\nlibrary ChainList {\n using SafeMath for uint256;\n\n // 遵循BIP44\n struct element {\n // 索引id\n uint256 idx;\n // chain id\n uint256 id;\n string symbol;\n }\n struct chainMap {\n // chain id => index\n mapping(uint256 => uint256) mapId;\n // symbol hash => index\n mapping(bytes32 => uint256) mapSymbol;\n // data array\n element[] list;\n }\n\n function exist(chainMap storage self, uint256 _id)\n internal\n view\n returns (bool)\n {\n if (self.list.length == 0) return false;\n return (self.list[self.mapId[_id]].id == _id &&\n getStringLen(self.list[self.mapId[_id]].symbol) > 0);\n }\n\n function getStringLen(string _str) internal pure returns (uint256) {\n bytes memory b = bytes(_str);\n require(b.length <= 1024, \"too large string make overflow risk\");\n return b.length;\n }\n\n function getHash(string _symbol) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(_symbol));\n }\n\n /**\n @dev 增加新定时定义,重复的ID返回失败\n */\n function insert(\n chainMap storage self,\n uint256 _id,\n string _symbol\n ) internal returns (bool) {\n if (exist(self, _id)) {\n return false;\n }\n\n element memory e =\n element({idx: self.list.length, id: _id, symbol: _symbol});\n\n self.list.push(e);\n self.mapId[_id] = e.idx;\n self.mapSymbol[getHash(_symbol)] = e.idx;\n\n return true;\n }\n\n function remove(chainMap storage self, uint256 _id) internal returns (bool) {\n if (!exist(self, _id)) {\n return false;\n }\n\n uint256 row2Del = self.mapId[_id];\n element storage keyToMove = self.list[self.list.length.sub(1)];\n self.list[row2Del] = keyToMove;\n self.mapId[keyToMove.id] = row2Del;\n self.mapSymbol[getHash(keyToMove.symbol)] = row2Del;\n self.list.length = self.list.length.sub(1);\n\n return true;\n }\n\n function count(chainMap storage self) internal view returns (uint256) {\n return self.list.length;\n }\n\n function get(chainMap storage self, uint256 index)\n internal\n view\n returns (ChainList.element)\n {\n require(index < self.list.length, \"index must small than current count\");\n return self.list[index];\n }\n\n function getById(chainMap storage self, uint256 _id)\n internal\n view\n returns (ChainList.element)\n {\n require(exist(self, _id), \"chain data must exist\");\n return self.list[self.mapId[_id]];\n }\n\n function getBySymbol(chainMap storage self, string _symbol)\n internal\n view\n returns (ChainList.element)\n {\n ChainList.element storage e = self.list[self.mapSymbol[getHash(_symbol)]];\n // 因为删除增加操作,map对应的存储未动,要校验一次\n require(exist(self, e.id), \"chain data must exist\");\n return e;\n }\n\n /**\n @dev 从指定位置返回多条(不多于count)地址记录,如果不足则空缺\n */\n function getList(\n chainMap storage self,\n uint256 from,\n uint256 _count\n ) internal view returns (ChainList.element[] memory) {\n uint256 _idx = 0;\n require(_count > 0, \"return number must bigger than 0\");\n ChainList.element[] memory res = new ChainList.element[](_count);\n\n for (uint256 i = from; i < self.list.length; i++) {\n if (_idx == _count) {\n break;\n }\n\n res[_idx] = self.list[i];\n _idx = _idx.add(1);\n }\n\n return res;\n }\n}\n",
"sourcePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/ChainList.sol",
"ast": {
"absolutePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/ChainList.sol",
"exportedSymbols": {
"ChainList": [
2746
]
},
"id": 2747,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 2328,
"literals": [
"solidity",
">=",
"0.4",
".24"
],
"nodeType": "PragmaDirective",
"src": "0:25:14"
},
{
"absolutePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/math/SafeMath.sol",
"file": "../math/SafeMath.sol",
"id": 2329,
"nodeType": "ImportDirective",
"scope": 2747,
"sourceUnit": 5658,
"src": "27:30:14",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@dev 区块链列表",
"fullyImplemented": true,
"id": 2746,
"linearizedBaseContracts": [
2746
],
"name": "ChainList",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 2332,
"libraryName": {
"contractScope": null,
"id": 2330,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5657,
"src": "119:8:14",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$5657",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "113:27:14",
"typeName": {
"id": 2331,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "132:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"canonicalName": "ChainList.element",
"id": 2339,
"members": [
{
"constant": false,
"id": 2334,
"name": "idx",
"nodeType": "VariableDeclaration",
"scope": 2339,
"src": "198:11:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 2333,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "198:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2336,
"name": "id",
"nodeType": "VariableDeclaration",
"scope": 2339,
"src": "231:10:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 2335,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "231:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2338,
"name": "symbol",
"nodeType": "VariableDeclaration",
"scope": 2339,
"src": "247:13:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_string_storage_ptr",
"typeString": "string"
},
"typeName": {
"id": 2337,
"name": "string",
"nodeType": "ElementaryTypeName",
"src": "247:6:14",
"typeDescriptions": {
"typeIdentifier": "t_string_storage_ptr",
"typeString": "string"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "element",
"nodeType": "StructDefinition",
"scope": 2746,
"src": "161:104:14",
"visibility": "public"
},
{
"canonicalName": "ChainList.chainMap",
"id": 2351,
"members": [
{
"constant": false,
"id": 2343,
"name": "mapId",
"nodeType": "VariableDeclaration",
"scope": 2351,
"src": "315:33:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_uint256_$",
"typeString": "mapping(uint256 => uint256)"
},
"typeName": {
"id": 2342,
"keyType": {
"id": 2340,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "323:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Mapping",
"src": "315:27:14",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_uint256_$",
"typeString": "mapping(uint256 => uint256)"
},
"valueType": {
"id": 2341,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "334:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2347,
"name": "mapSymbol",
"nodeType": "VariableDeclaration",
"scope": 2351,
"src": "382:37:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
},
"typeName": {
"id": 2346,
"keyType": {
"id": 2344,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "390:7:14",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "Mapping",
"src": "382:27:14",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
},
"valueType": {
"id": 2345,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "401:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2350,
"name": "list",
"nodeType": "VariableDeclaration",
"scope": 2351,
"src": "443:14:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_element_$2339_storage_$dyn_storage_ptr",
"typeString": "struct ChainList.element[]"
},
"typeName": {
"baseType": {
"contractScope": null,
"id": 2348,
"name": "element",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 2339,
"src": "443:7:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_element_$2339_storage_ptr",
"typeString": "struct ChainList.element"
}
},
"id": 2349,
"length": null,
"nodeType": "ArrayTypeName",
"src": "443:9:14",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_element_$2339_storage_$dyn_storage_ptr",
"typeString": "struct ChainList.element[]"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "chainMap",
"nodeType": "StructDefinition",
"scope": 2746,
"src": "268:194:14",
"visibility": "public"
},
{
"body": {
"id": 2393,
"nodeType": "Block",
"src": "560:162:14",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 2364,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2360,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2353,
"src": "570:4:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap storage pointer"
}
},
"id": 2361,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 2350,
"src": "570:9:14",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_element_$2339_storage_$dyn_storage",
"typeString": "struct ChainList.element storage ref[] storage ref"
}
},
"id": 2362,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "570:16:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 2363,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "590:1:14",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "570:21:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 2367,
"nodeType": "IfStatement",
"src": "566:39:14",
"trueBody": {
"expression": {
"argumentTypes": null,
"hexValue": "66616c7365",
"id": 2365,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "600:5:14",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
},
"functionReturnParameters": 2359,
"id": 2366,
"nodeType": "Return",
"src": "593:12:14"
}
},
{
"expression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"id": 2390,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 2377,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2368,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2353,
"src": "619:4:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap storage pointer"
}
},
"id": 2369,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 2350,
"src": "619:9:14",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_element_$2339_storage_$dyn_storage",
"typeString": "struct ChainList.element storage ref[] storage ref"
}
},
"id": 2374,
"indexExpression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2370,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2353,
"src": "629:4:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap storage pointer"
}
},
"id": 2371,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "mapId",
"nodeType": "MemberAccess",
"referencedDeclaration": 2343,
"src": "629:10:14",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_uint256_$",
"typeString": "mapping(uint256 => uint256)"
}
},
"id": 2373,
"indexExpression": {
"argumentTypes": null,
"id": 2372,
"name": "_id",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2355,
"src": "640:3:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "629:15:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "619:26:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_element_$2339_storage",
"typeString": "struct ChainList.element storage ref"
}
},
"id": 2375,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "id",
"nodeType": "MemberAccess",
"referencedDeclaration": 2336,
"src": "619:29:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 2376,
"name": "_id",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2355,
"src": "652:3:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "619:36:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"nodeType": "BinaryOperation",
"operator": "&&",
"rightExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 2389,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2379,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2353,
"src": "678:4:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap storage pointer"
}
},
"id": 2380,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 2350,
"src": "678:9:14",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_struct$_element_$2339_storage_$dyn_storage",
"typeString": "struct ChainList.element storage ref[] storage ref"
}
},
"id": 2385,
"indexExpression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2381,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2353,
"src": "688:4:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap storage pointer"
}
},
"id": 2382,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "mapId",
"nodeType": "MemberAccess",
"referencedDeclaration": 2343,
"src": "688:10:14",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_uint256_$",
"typeString": "mapping(uint256 => uint256)"
}
},
"id": 2384,
"indexExpression": {
"argumentTypes": null,
"id": 2383,
"name": "_id",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2355,
"src": "699:3:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "688:15:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "678:26:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_element_$2339_storage",
"typeString": "struct ChainList.element storage ref"
}
},
"id": 2386,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "symbol",
"nodeType": "MemberAccess",
"referencedDeclaration": 2338,
"src": "678:33:14",
"typeDescriptions": {
"typeIdentifier": "t_string_storage",
"typeString": "string storage ref"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_string_storage",
"typeString": "string storage ref"
}
],
"id": 2378,
"name": "getStringLen",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2419,
"src": "665:12:14",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_string_memory_ptr_$returns$_t_uint256_$",
"typeString": "function (string memory) pure returns (uint256)"
}
},
"id": 2387,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "665:47:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 2388,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "715:1:14",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "665:51:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"src": "619:97:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
}
],
"id": 2391,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "618:99:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"functionReturnParameters": 2359,
"id": 2392,
"nodeType": "Return",
"src": "611:106:14"
}
]
},
"documentation": null,
"id": 2394,
"implemented": true,
"isConstructor": false,
"isDeclaredConst": true,
"modifiers": [],
"name": "exist",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 2356,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2353,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 2394,
"src": "481:21:14",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap"
},
"typeName": {
"contractScope": null,
"id": 2352,
"name": "chainMap",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 2351,
"src": "481:8:14",
"typeDescriptions": {
"typeIdentifier": "t_struct$_chainMap_$2351_storage_ptr",
"typeString": "struct ChainList.chainMap"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 2355,
"name": "_id",
"nodeType": "VariableDeclaration",
"scope": 2394,
"src": "504:11:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 2354,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "504:7:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "480:36:14"
},
"payable": false,
"returnParameters": {
"id": 2359,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 2358,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 2394,
"src": "552:4:14",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 2357,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "552:4:14",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "551:6:14"
},
"scope": 2746,
"src": "466:256:14",
"stateMutability": "view",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 2418,
"nodeType": "Block",
"src": "793:130:14",
"statements": [
{
"assignments": [
2402
],
"declarations": [
{
"constant": false,
"id": 2402,
"name": "b",
"nodeType": "VariableDeclaration",
"scope": 2419,
"src": "799:14:14",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 2401,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "799:5:14",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 2406,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 2404,
"name": "_str",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2396,
"src": "822:4:14",
"typeDescriptions": {
"typeIdentifier": "t_string_memory_ptr",
"typeString": "string memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_string_memory_ptr",
"typeString": "string memory"
}
],
"id": 2403,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "816:5:14",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_bytes_storage_ptr_$",
"typeString": "type(bytes storage pointer)"
},
"typeName": "bytes"
},
"id": 2405,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "816:11:14",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory",
"typeString": "bytes memory"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "799:28:14"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 2411,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 2408,
"name": "b",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2402,
"src": "841:1:14",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes memory"
}
},
"id": 2409,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "841:8:14",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<=",