UNPKG

@marketprotocol/marketprotocol

Version:

Decentralized Derivatives Trading Protocol For The Ethereum Blockchain

1,060 lines 43.2 kB
{ "contractName": "StringLib", "abi": [], "metadata": "{\"compiler\":{\"version\":\"0.5.2+commit.1df8f40c\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/StringLib.sol\":\"StringLib\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/StringLib.sol\":{\"keccak256\":\"0xa1d7d76809600493055bdb04692a775fde71142a921f994568beb1fdb42a92c7\",\"urls\":[\"bzzr://dcc475bb3f21803b7d5fba4157f07c5fc642ea9a976eb118bac74a1cb0b91f4f\"]}},\"version\":1}", "bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820db88c12976c4d27d9fffc3dcca18b426281b0dcd39f680215bfef2c28d164b450029", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820db88c12976c4d27d9fffc3dcca18b426281b0dcd39f680215bfef2c28d164b450029", "sourceMap": "25:404:6:-;;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": "25:404:6:-;;;;;;;;", "source": "pragma solidity 0.5.2;\n\n\nlibrary StringLib {\n\n /// @notice converts bytes32 into a string.\n /// @param bytesToConvert bytes32 array to convert\n function bytes32ToString(bytes32 bytesToConvert) internal pure returns (string memory) {\n bytes memory bytesArray = new bytes(32);\n for (uint256 i; i < 32; i++) {\n bytesArray[i] = bytesToConvert[i];\n }\n return string(bytesArray);\n }\n}", "sourcePath": "/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/StringLib.sol", "ast": { "absolutePath": "/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/StringLib.sol", "exportedSymbols": { "StringLib": [ 1530 ] }, "id": 1531, "nodeType": "SourceUnit", "nodes": [ { "id": 1491, "literals": [ "solidity", "0.5", ".2" ], "nodeType": "PragmaDirective", "src": "0:22:6" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 1530, "linearizedBaseContracts": [ 1530 ], "name": "StringLib", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 1528, "nodeType": "Block", "src": "240:187:6", "statements": [ { "assignments": [ 1499 ], "declarations": [ { "constant": false, "id": 1499, "name": "bytesArray", "nodeType": "VariableDeclaration", "scope": 1528, "src": "250:23:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 1498, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "250:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "value": null, "visibility": "internal" } ], "id": 1504, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "3332", "id": 1502, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "286:2:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" } ], "id": 1501, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "NewExpression", "src": "276:9:6", "typeDescriptions": { "typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_bytes_memory_$", "typeString": "function (uint256) pure returns (bytes memory)" }, "typeName": { "id": 1500, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "280:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } } }, "id": 1503, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "276:13:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory", "typeString": "bytes memory" } }, "nodeType": "VariableDeclarationStatement", "src": "250:39:6" }, { "body": { "id": 1522, "nodeType": "Block", "src": "328:58:6", "statements": [ { "expression": { "argumentTypes": null, "id": 1520, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 1514, "name": "bytesArray", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1499, "src": "342:10:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 1516, "indexExpression": { "argumentTypes": null, "id": 1515, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "353:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", "src": "342:13:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 1517, "name": "bytesToConvert", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1493, "src": "358:14:6", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "id": 1519, "indexExpression": { "argumentTypes": null, "id": 1518, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "373:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "358:17:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "src": "342:33:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "id": 1521, "nodeType": "ExpressionStatement", "src": "342:33:6" } ] }, "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1510, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 1508, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "315:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "hexValue": "3332", "id": 1509, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "319:2:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" }, "src": "315:6:6", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 1523, "initializationExpression": { "assignments": [ 1506 ], "declarations": [ { "constant": false, "id": 1506, "name": "i", "nodeType": "VariableDeclaration", "scope": 1523, "src": "304:9:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1505, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "304:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 1507, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "304:9:6" }, "loopExpression": { "expression": { "argumentTypes": null, "id": 1512, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "++", "prefix": false, "src": "323:3:6", "subExpression": { "argumentTypes": null, "id": 1511, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "323:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 1513, "nodeType": "ExpressionStatement", "src": "323:3:6" }, "nodeType": "ForStatement", "src": "299:87:6" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 1525, "name": "bytesArray", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1499, "src": "409:10:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } ], "id": 1524, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "402:6:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_string_storage_ptr_$", "typeString": "type(string storage pointer)" }, "typeName": "string" }, "id": 1526, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "402:18:6", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" } }, "functionReturnParameters": 1497, "id": 1527, "nodeType": "Return", "src": "395:25:6" } ] }, "documentation": "@notice converts bytes32 into a string.\n @param bytesToConvert bytes32 array to convert", "id": 1529, "implemented": true, "kind": "function", "modifiers": [], "name": "bytes32ToString", "nodeType": "FunctionDefinition", "parameters": { "id": 1494, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1493, "name": "bytesToConvert", "nodeType": "VariableDeclaration", "scope": 1529, "src": "178:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 1492, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "178:7:6", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "177:24:6" }, "returnParameters": { "id": 1497, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1496, "name": "", "nodeType": "VariableDeclaration", "scope": 1529, "src": "225:13:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, "typeName": { "id": 1495, "name": "string", "nodeType": "ElementaryTypeName", "src": "225:6:6", "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } }, "value": null, "visibility": "internal" } ], "src": "224:15:6" }, "scope": 1530, "src": "153:274:6", "stateMutability": "pure", "superFunction": null, "visibility": "internal" } ], "scope": 1531, "src": "25:404:6" } ], "src": "0:429:6" }, "legacyAST": { "absolutePath": "/home/travis/build/MARKETProtocol/MARKETProtocol/contracts/libraries/StringLib.sol", "exportedSymbols": { "StringLib": [ 1530 ] }, "id": 1531, "nodeType": "SourceUnit", "nodes": [ { "id": 1491, "literals": [ "solidity", "0.5", ".2" ], "nodeType": "PragmaDirective", "src": "0:22:6" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": null, "fullyImplemented": true, "id": 1530, "linearizedBaseContracts": [ 1530 ], "name": "StringLib", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 1528, "nodeType": "Block", "src": "240:187:6", "statements": [ { "assignments": [ 1499 ], "declarations": [ { "constant": false, "id": 1499, "name": "bytesArray", "nodeType": "VariableDeclaration", "scope": 1528, "src": "250:23:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 1498, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "250:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "value": null, "visibility": "internal" } ], "id": 1504, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "3332", "id": 1502, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "286:2:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" } ], "id": 1501, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "NewExpression", "src": "276:9:6", "typeDescriptions": { "typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_bytes_memory_$", "typeString": "function (uint256) pure returns (bytes memory)" }, "typeName": { "id": 1500, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "280:5:6", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } } }, "id": 1503, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "276:13:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory", "typeString": "bytes memory" } }, "nodeType": "VariableDeclarationStatement", "src": "250:39:6" }, { "body": { "id": 1522, "nodeType": "Block", "src": "328:58:6", "statements": [ { "expression": { "argumentTypes": null, "id": 1520, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 1514, "name": "bytesArray", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1499, "src": "342:10:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 1516, "indexExpression": { "argumentTypes": null, "id": 1515, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "353:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": true, "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", "src": "342:13:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "baseExpression": { "argumentTypes": null, "id": 1517, "name": "bytesToConvert", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1493, "src": "358:14:6", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "id": 1519, "indexExpression": { "argumentTypes": null, "id": 1518, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "373:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", "src": "358:17:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "src": "342:33:6", "typeDescriptions": { "typeIdentifier": "t_bytes1", "typeString": "bytes1" } }, "id": 1521, "nodeType": "ExpressionStatement", "src": "342:33:6" } ] }, "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1510, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 1508, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "315:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "hexValue": "3332", "id": 1509, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "319:2:6", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_32_by_1", "typeString": "int_const 32" }, "value": "32" }, "src": "315:6:6", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 1523, "initializationExpression": { "assignments": [ 1506 ], "declarations": [ { "constant": false, "id": 1506, "name": "i", "nodeType": "VariableDeclaration", "scope": 1523, "src": "304:9:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 1505, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "304:7:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 1507, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "304:9:6" }, "loopExpression": { "expression": { "argumentTypes": null, "id": 1512, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "nodeType": "UnaryOperation", "operator": "++", "prefix": false, "src": "323:3:6", "subExpression": { "argumentTypes": null, "id": 1511, "name": "i", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1506, "src": "323:1:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "id": 1513, "nodeType": "ExpressionStatement", "src": "323:3:6" }, "nodeType": "ForStatement", "src": "299:87:6" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 1525, "name": "bytesArray", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1499, "src": "409:10:6", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } ], "id": 1524, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "402:6:6", "typeDescriptions": { "typeIdentifier": "t_type$_t_string_storage_ptr_$", "typeString": "type(string storage pointer)" }, "typeName": "string" }, "id": 1526, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "402:18:6", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" } }, "functionReturnParameters": 1497, "id": 1527, "nodeType": "Return", "src": "395:25:6" } ] }, "documentation": "@notice converts bytes32 into a string.\n @param bytesToConvert bytes32 array to convert", "id": 1529, "implemented": true, "kind": "function", "modifiers": [], "name": "bytes32ToString", "nodeType": "FunctionDefinition", "parameters": { "id": 1494, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1493, "name": "bytesToConvert", "nodeType": "VariableDeclaration", "scope": 1529, "src": "178:22:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 1492, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "178:7:6", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "177:24:6" }, "returnParameters": { "id": 1497, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1496, "name": "", "nodeType": "VariableDeclaration", "scope": 1529, "src": "225:13:6", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, "typeName": { "id": 1495, "name": "string", "nodeType": "ElementaryTypeName", "src": "225:6:6", "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } }, "value": null, "visibility": "internal" } ], "src": "224:15:6" }, "scope": 1530, "src": "153:274:6", "stateMutability": "pure", "superFunction": null, "visibility": "internal" } ], "scope": 1531, "src": "25:404:6" } ], "src": "0:429:6" }, "compiler": { "name": "solc", "version": "0.5.2+commit.1df8f40c.Emscripten.clang" }, "networks": {}, "schemaVersion": "3.0.9", "updatedAt": "2019-05-28T23:53:01.589Z", "devdoc": { "methods": {} }, "userdoc": { "methods": {} } }