From 7a05e1c2fcc3e2fb80be4f71b46442de9181b89f Mon Sep 17 00:00:00 2001 From: Nick Gheorghita Date: Sat, 15 Aug 2020 16:01:19 -0500 Subject: [PATCH] Correct bytecodes in parse truffle artifact utils --- package.json | 2 +- src/utils/test/assets/pkgWithCompilers.json | 2 +- src/utils/truffle.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6842a25..968b486 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ethpm", - "version": "0.1.0-next.27", + "version": "0.1.0-next.28", "description": "Javascript library for EthPM (EIPs 2678 / 1319)", "main": "index.js", "types": "main.d.ts", diff --git a/src/utils/test/assets/pkgWithCompilers.json b/src/utils/test/assets/pkgWithCompilers.json index 00371a2..935ba3e 100644 --- a/src/utils/test/assets/pkgWithCompilers.json +++ b/src/utils/test/assets/pkgWithCompilers.json @@ -1 +1 @@ -{"compilers":[{"contractTypes":["ConvertLib","MetaCoin","Migrations"],"name":"solc","settings":{"optimize":true},"version":"0.5.12+commit.7709ece9.Emscripten.clang"}],"contractTypes":{"ConvertLib":{"abi":[{"constant":true,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"conversionRate","type":"uint256"}],"name":"convert","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"}],"deploymentBytecode":{"bytecode":"0x730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806396e4ee3d146038575b600080fd5b605860048036036040811015604c57600080fd5b5080359060200135606a565b60408051918252519081900360200190f35b029056fea265627a7a72315820f0fcee8250d2b07ef86c7929b068365319dfc6497933439c6e5262629763f16b64736f6c634300050c0032"},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x60a3610024600b82828239805160001a607314601757fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806396e4ee3d146038575b600080fd5b605860048036036040811015604c57600080fd5b5080359060200135606a565b60408051918252519081900360200190f35b029056fea265627a7a72315820f0fcee8250d2b07ef86c7929b068365319dfc6497933439c6e5262629763f16b64736f6c634300050c0032"},"userdoc":{"methods":{}}},"MetaCoin":{"abi":[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"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"},{"constant":false,"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sendCoin","outputs":[{"internalType":"bool","name":"sufficient","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getBalanceInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}],"deploymentBytecode":{"bytecode":"0x608060405234801561001057600080fd5b50600436106100415760003560e01c80637bd703e81461004657806390b98a111461007e578063f8b2cb4f146100be575b600080fd5b61006c6004803603602081101561005c57600080fd5b50356001600160a01b03166100e4565b60408051918252519081900360200190f35b6100aa6004803603604081101561009457600080fd5b506001600160a01b038135169060200135610178565b604080519115158252519081900360200190f35b61006c600480360360208110156100d457600080fd5b50356001600160a01b0316610204565b60007300000000000000000000000000000000000000006396e4ee3d61010984610204565b60026040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561014657600080fd5b505af415801561015a573d6000803e3d6000fd5b505050506040513d602081101561017057600080fd5b505192915050565b33600090815260208190526040812054821115610197575060006101fe565b33600081815260208181526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060015b92915050565b6001600160a01b03166000908152602081905260409020549056fea265627a7a72315820ac0a50c26b3393395603b5ac9e71dd9a8e62e402fd828f9bdc921d1f5b0d1af264736f6c634300050c0032","linkReferences":[{"length":20,"name":"ConvertLib","offsets":[466]}]},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x608060405234801561001057600080fd5b5032600090815260208190526040902061271090556102548061000000000000000000000000000000000000000000346000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80637bd703e81461004657806390b98a111461007e578063f8b2cb4f146100be575b600080fd5b61006c6004803603602081101561005c57600080fd5b50356001600160a01b03166100e4565b60408051918252519081900360200190f35b6100aa6004803603604081101561009457600080fd5b506001600160a01b038135169060200135610178565b604080519115158252519081900360200190f35b61006c600480360360208110156100d457600080fd5b50356001600160a01b0316610204565b60007300000000000000000000000000000000000000006396e4ee3d61010984610204565b60026040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561014657600080fd5b505af415801561015a573d6000803e3d6000fd5b505050506040513d602081101561017057600080fd5b505192915050565b000000000000000000000000000000000000000033600090815260208190526040812054821115610197575060006101fe565b33600081815260208181526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060015b92915050565b6001600160a01b03166000908152602081905260409020549056fea265627a7a72315820ac0a50c26b3393395603b5ac9e71dd9a8e62e402fd828f9bdc921d1f5b0d1af264736f6c634300050c0032","linkReferences":[{"length":20,"name":"OtherLib","offsets":[89]},{"length":20,"name":"ConvertLib","offsets":[610,900]}]},"userdoc":{"methods":{}}},"Migrations":{"abi":[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"last_completed_migration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"completed","type":"uint256"}],"name":"setCompleted","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"new_address","type":"address"}],"name":"upgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}],"deploymentBytecode":{"bytecode":"0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100795780638da5cb5b14610093578063fdacd576146100b7575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166100d4565b005b610081610151565b60408051918252519081900360200190f35b61009b610157565b604080516001600160a01b039092168252519081900360200190f35b610077600480360360208110156100cd57600080fd5b5035610166565b6000546001600160a01b031633141561014e576000819050806001600160a01b031663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561013457600080fd5b505af1158015610148573d6000803e3d6000fd5b50505050505b50565b60015481565b6000546001600160a01b031681565b6000546001600160a01b031633141561014e5760015556fea265627a7a7231582035e07966ef8c98072efc8102dd5eff19db0788c8fc67e54b4dc37079fa96d38464736f6c634300050c0032"},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x608060405234801561001057600080fd5b50600080546001600160a01b031916331790556101b3806100326000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100795780638da5cb5b14610093578063fdacd576146100b7575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166100d4565b005b610081610151565b60408051918252519081900360200190f35b61009b610157565b604080516001600160a01b039092168252519081900360200190f35b610077600480360360208110156100cd57600080fd5b5035610166565b6000546001600160a01b031633141561014e576000819050806001600160a01b031663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561013457600080fd5b505af1158015610148573d6000803e3d6000fd5b50505050505b50565b60015481565b6000546001600160a01b031681565b6000546001600160a01b031633141561014e5760015556fea265627a7a7231582035e07966ef8c98072efc8102dd5eff19db0788c8fc67e54b4dc37079fa96d38464736f6c634300050c0032"},"userdoc":{"methods":{}}}},"deployments":{"blockchain://4092053bae6a81988862a61247ed84cb23e102937d8ff3a2b630af839a0e19c7/block/b2b4dd2b3c184b0645644350fda85e6c54c9459b9c8c2495a3583bac90c9534f":{"ConvertLib":{"address":"0xd2D961c84035aF1B0DFADDa447Ca9B586062D452","contractType":"ConvertLib","transaction":"0x3a9c9d58c514475a1f9b7d0101ddf66dd521eaac3b3620845865bf2358d7946c"},"MetaCoin":{"address":"0x43A1E1f0E0C5568D006E42434A38851D9bc455EB","contractType":"MetaCoin","transaction":"0x62f435c351ca380ae8868aab43c5d0829891eaa12261d5b213426565495c039f"}},"blockchain://d982ee05344fd7ad71a97ce20e64ee33c8033c6dedfce14dd5c2fef09200d17b/block/8fcfdc7b53a22911bcf5b81c3fb40ccb51204f60c94c94c15b6ab0ad375ff28e":{"ConvertLib":{"address":"0xAdCe8aa6242D3ce5F7cB256504EDB62EFAAa61ca","contractType":"ConvertLib","transaction":"0xeed2fe6d36b4f84d02e9d2be4c12579c573e44435628f35ecfaaad7c563ad692"},"MetaCoin":{"address":"0x942F94De4D11A10ECB96fA5Bf3DF71FAdb333b75","contractType":"MetaCoin","transaction":"0x92bee72854f039cb36009fc041f00ab06237be3a40cf22dceb10dd9f805fc705"},"Migrations":{"address":"0xBF9Ad955317610431579d9676Cc617Ce2e999744","contractType":"Migrations","transaction":"0x2053c9e2272697fe87dcb5582f79ecb82775782aaeee6f24e4df8ec0454ef329"}}},"manifest":"ethpm/3","name":"pkg","version":"1"} +{"compilers":[{"contractTypes":["ConvertLib","MetaCoin","Migrations"],"name":"solc","settings":{"optimize":true},"version":"0.5.12+commit.7709ece9.Emscripten.clang"}],"contractTypes":{"ConvertLib":{"abi":[{"constant":true,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"conversionRate","type":"uint256"}],"name":"convert","outputs":[{"internalType":"uint256","name":"convertedAmount","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"}],"deploymentBytecode":{"bytecode":"0x60a3610024600b82828239805160001a607314601757fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806396e4ee3d146038575b600080fd5b605860048036036040811015604c57600080fd5b5080359060200135606a565b60408051918252519081900360200190f35b029056fea265627a7a72315820f0fcee8250d2b07ef86c7929b068365319dfc6497933439c6e5262629763f16b64736f6c634300050c0032"},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806396e4ee3d146038575b600080fd5b605860048036036040811015604c57600080fd5b5080359060200135606a565b60408051918252519081900360200190f35b029056fea265627a7a72315820f0fcee8250d2b07ef86c7929b068365319dfc6497933439c6e5262629763f16b64736f6c634300050c0032"},"userdoc":{"methods":{}}},"MetaCoin":{"abi":[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"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"},{"constant":false,"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sendCoin","outputs":[{"internalType":"bool","name":"sufficient","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getBalanceInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}],"deploymentBytecode":{"bytecode":"0x608060405234801561001057600080fd5b5032600090815260208190526040902061271090556102548061000000000000000000000000000000000000000000346000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80637bd703e81461004657806390b98a111461007e578063f8b2cb4f146100be575b600080fd5b61006c6004803603602081101561005c57600080fd5b50356001600160a01b03166100e4565b60408051918252519081900360200190f35b6100aa6004803603604081101561009457600080fd5b506001600160a01b038135169060200135610178565b604080519115158252519081900360200190f35b61006c600480360360208110156100d457600080fd5b50356001600160a01b0316610204565b60007300000000000000000000000000000000000000006396e4ee3d61010984610204565b60026040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561014657600080fd5b505af415801561015a573d6000803e3d6000fd5b505050506040513d602081101561017057600080fd5b505192915050565b000000000000000000000000000000000000000033600090815260208190526040812054821115610197575060006101fe565b33600081815260208181526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060015b92915050565b6001600160a01b03166000908152602081905260409020549056fea265627a7a72315820ac0a50c26b3393395603b5ac9e71dd9a8e62e402fd828f9bdc921d1f5b0d1af264736f6c634300050c0032","linkReferences":[{"length":20,"name":"OtherLib","offsets":[89]},{"length":20,"name":"ConvertLib","offsets":[610,900]}]},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x608060405234801561001057600080fd5b50600436106100415760003560e01c80637bd703e81461004657806390b98a111461007e578063f8b2cb4f146100be575b600080fd5b61006c6004803603602081101561005c57600080fd5b50356001600160a01b03166100e4565b60408051918252519081900360200190f35b6100aa6004803603604081101561009457600080fd5b506001600160a01b038135169060200135610178565b604080519115158252519081900360200190f35b61006c600480360360208110156100d457600080fd5b50356001600160a01b0316610204565b60007300000000000000000000000000000000000000006396e4ee3d61010984610204565b60026040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561014657600080fd5b505af415801561015a573d6000803e3d6000fd5b505050506040513d602081101561017057600080fd5b505192915050565b33600090815260208190526040812054821115610197575060006101fe565b33600081815260208181526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060015b92915050565b6001600160a01b03166000908152602081905260409020549056fea265627a7a72315820ac0a50c26b3393395603b5ac9e71dd9a8e62e402fd828f9bdc921d1f5b0d1af264736f6c634300050c0032","linkReferences":[{"length":20,"name":"ConvertLib","offsets":[466]}]},"userdoc":{"methods":{}}},"Migrations":{"abi":[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"last_completed_migration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"completed","type":"uint256"}],"name":"setCompleted","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"new_address","type":"address"}],"name":"upgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}],"deploymentBytecode":{"bytecode":"0x608060405234801561001057600080fd5b50600080546001600160a01b031916331790556101b3806100326000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100795780638da5cb5b14610093578063fdacd576146100b7575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166100d4565b005b610081610151565b60408051918252519081900360200190f35b61009b610157565b604080516001600160a01b039092168252519081900360200190f35b610077600480360360208110156100cd57600080fd5b5035610166565b6000546001600160a01b031633141561014e576000819050806001600160a01b031663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561013457600080fd5b505af1158015610148573d6000803e3d6000fd5b50505050505b50565b60015481565b6000546001600160a01b031681565b6000546001600160a01b031633141561014e5760015556fea265627a7a7231582035e07966ef8c98072efc8102dd5eff19db0788c8fc67e54b4dc37079fa96d38464736f6c634300050c0032"},"devdoc":{"methods":{}},"runtimeBytecode":{"bytecode":"0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100795780638da5cb5b14610093578063fdacd576146100b7575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166100d4565b005b610081610151565b60408051918252519081900360200190f35b61009b610157565b604080516001600160a01b039092168252519081900360200190f35b610077600480360360208110156100cd57600080fd5b5035610166565b6000546001600160a01b031633141561014e576000819050806001600160a01b031663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561013457600080fd5b505af1158015610148573d6000803e3d6000fd5b50505050505b50565b60015481565b6000546001600160a01b031681565b6000546001600160a01b031633141561014e5760015556fea265627a7a7231582035e07966ef8c98072efc8102dd5eff19db0788c8fc67e54b4dc37079fa96d38464736f6c634300050c0032"},"userdoc":{"methods":{}}}},"deployments":{"blockchain://4092053bae6a81988862a61247ed84cb23e102937d8ff3a2b630af839a0e19c7/block/b2b4dd2b3c184b0645644350fda85e6c54c9459b9c8c2495a3583bac90c9534f":{"ConvertLib":{"address":"0xd2D961c84035aF1B0DFADDa447Ca9B586062D452","contractType":"ConvertLib","transaction":"0x3a9c9d58c514475a1f9b7d0101ddf66dd521eaac3b3620845865bf2358d7946c"},"MetaCoin":{"address":"0x43A1E1f0E0C5568D006E42434A38851D9bc455EB","contractType":"MetaCoin","transaction":"0x62f435c351ca380ae8868aab43c5d0829891eaa12261d5b213426565495c039f"}},"blockchain://d982ee05344fd7ad71a97ce20e64ee33c8033c6dedfce14dd5c2fef09200d17b/block/8fcfdc7b53a22911bcf5b81c3fb40ccb51204f60c94c94c15b6ab0ad375ff28e":{"ConvertLib":{"address":"0xAdCe8aa6242D3ce5F7cB256504EDB62EFAAa61ca","contractType":"ConvertLib","transaction":"0xeed2fe6d36b4f84d02e9d2be4c12579c573e44435628f35ecfaaad7c563ad692"},"MetaCoin":{"address":"0x942F94De4D11A10ECB96fA5Bf3DF71FAdb333b75","contractType":"MetaCoin","transaction":"0x92bee72854f039cb36009fc041f00ab06237be3a40cf22dceb10dd9f805fc705"},"Migrations":{"address":"0xBF9Ad955317610431579d9676Cc617Ce2e999744","contractType":"Migrations","transaction":"0x2053c9e2272697fe87dcb5582f79ecb82775782aaeee6f24e4df8ec0454ef329"}}},"manifest":"ethpm/3","name":"pkg","version":"1"} \ No newline at end of file diff --git a/src/utils/truffle.ts b/src/utils/truffle.ts index 6053df3..3b100fb 100644 --- a/src/utils/truffle.ts +++ b/src/utils/truffle.ts @@ -65,8 +65,8 @@ function parseTruffleArtifactsToContractTypes(artifacts: Array) { const config = { ...(artifact.abi) && {abi: artifact.abi}, // todo: no contractName since truffle doesn't support aliasing - ...(artifact.bytecode) && {runtimeBytecode: parseBytecode(artifact.bytecode)}, - ...(artifact.deployedBytecode) && {deploymentBytecode: parseBytecode(artifact.deployedBytecode)}, + ...(artifact.deployedBytecode) && {runtimeBytecode: parseBytecode(artifact.deployedBytecode)}, + ...(artifact.bytecode) && {deploymentBytecode: parseBytecode(artifact.bytecode)}, ...(artifact.devdoc) && {devdoc: artifact.devdoc}, ...(artifact.userdoc) && {userdoc: artifact.userdoc}, }