Skip to content

Commit 17d0570

Browse files
authored
abi-to-sol use current solidity compiler (#22)
* abi-to-sol use current solidity compiler - fixes #21 #20 * prepare 0.2.1 * prep v0.2.1 * update acks * fix typo
1 parent d4ab0a5 commit 17d0570

File tree

7 files changed

+74
-18
lines changed

7 files changed

+74
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22
All notable changes will be documented in this file.
33

4+
## v0.2.1
5+
- fix: feed current compiler version into abi-to-sol; strip attribution and other code #20 #21
6+
- update: compiler list
7+
- update: built-in solc -> 0.8.16
8+
49
## v0.2.0
510
- new: new command to fetch & load interface declaration from etherscan.io #19
611

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,49 @@ contract MainContract {
188188
}
189189
}
190190
```
191+
192+
### Fetch Interface Declaration from Etherscan
193+
194+
![shell-fetch-interface](https://user-images.githubusercontent.com/2865694/183062446-c952b308-9fc7-49f9-8308-3eac09ca3b4a.gif)
195+
196+
197+
`.fetch interface <address> <interfaceName> [optional: chain=mainnet]`
198+
199+
```
200+
⇒ solidity-shell --fork https://mainnet.infura.io/v3/<yourApiKey>
201+
202+
🚀 Entering interactive Solidity ^0.8.16 shell (🧁:Ganache built-in). '.help' and '.exit' are your friends.
203+
»
204+
» .fetch interface 0x40cfEe8D71D67108Db46F772B7e2CD55813Bf2FB Test
205+
» interface Test {
206+
207+
... omitted ...
208+
209+
function symbol() external view returns (string memory);
210+
211+
function tokenURI(uint256 tokenId) external view returns (string memory);
212+
213+
function totalSupply() external view returns (uint256);
214+
215+
function transferFrom(
216+
address from,
217+
address to,
218+
uint256 tokenId
219+
) external;
220+
221+
function transferOwnership(address newOwner) external;
222+
223+
function withdraw() external;
224+
}
225+
226+
» Test t = Test(0x40cfEe8D71D67108Db46F772B7e2CD55813Bf2FB)
227+
» t.symbol()
228+
MGX
229+
```
191230
____
192231

193232

194233
## Acknowledgements
195234

196235
* Inspired by the great but unfortunately unmaintained [solidity-repl](https://github.com/raineorshine/solidity-repl).
236+
* Fetch interfaces from Etherscan is powered by [abi-to-sol](https://github.com/gnidan/abi-to-sol).

bin/main.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,24 @@ cheers 🙌
248248
case 'interface':
249249
const { getRemoteInterfaceFromEtherscan } = require('../src/compiler/remoteCompiler');
250250

251-
getRemoteInterfaceFromEtherscan(commandParts[2], commandParts[3], commandParts.length >= 4 ? commandParts[4] : undefined).then(interfaceSource => {
251+
getRemoteInterfaceFromEtherscan(
252+
commandParts[2],
253+
commandParts[3],
254+
commandParts.length >= 4 ? commandParts[4] : undefined,
255+
shell.settings.installedSolidityVersion
256+
).then(interfaceSource => {
252257
console.log(interfaceSource);
253258
return cb(handleRepl(interfaceSource, cb)); // recursively call
254259
}).catch(e => {
255260
console.error(e);
256261
console.log("let's try once more 🤷‍♂️")
257262
// try once more?
258-
getRemoteInterfaceFromEtherscan(commandParts[2], commandParts[3], commandParts.length >= 4 ? commandParts[4] : undefined).then(interfaceSource => {
263+
getRemoteInterfaceFromEtherscan(
264+
commandParts[2],
265+
commandParts[3],
266+
commandParts.length >= 4 ? commandParts[4] : undefined,
267+
shell.settings.installedSolidityVersion
268+
).then(interfaceSource => {
259269
console.log(interfaceSource);
260270
return cb(handleRepl(interfaceSource, cb)); // recursively call
261271
}).catch(e => {

package-lock.json

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solidity-shell",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "An interactive Solidity shell with lightweight session recording and remote compiler support",
55
"main": "src/index.js",
66
"bin": {
@@ -31,7 +31,7 @@
3131
"minimist": "^1.2.5",
3232
"readline-sync": "^1.4.10",
3333
"request": "^2.88.2",
34-
"solc": "^0.8.15",
34+
"solc": "^0.8.16",
3535
"sync-request": "^6.1.0",
3636
"vorpal": "^1.12.0",
3737
"web3": "^1.5.2"

src/compiler/autogenerated/solcVersions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
//autogenerated with # npm run updateCompilerList
88
module.exports.solcVersions = [
9+
"v0.8.16+commit.07a7930e",
910
"v0.8.15+commit.e14f2714",
1011
"v0.8.14+commit.80d49f37",
1112
"v0.8.13+commit.abaa5c0e",

src/compiler/remoteCompiler.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function getRemoteCompiler(solidityVersion) {
5757
}
5858

5959
//.import interface 0x40cfee8d71d67108db46f772b7e2cd55813bf2fb test2
60-
function getRemoteInterfaceFromEtherscan(address, name, chain) {
60+
function getRemoteInterfaceFromEtherscan(address, name, chain, solidityVersion) {
6161
return new Promise((resolve, reject) => {
6262

6363
let provider = `https://api${(!chain || chain == "mainnet") ? "" : `-${chain}`}.etherscan.io`
@@ -73,10 +73,12 @@ function getRemoteInterfaceFromEtherscan(address, name, chain) {
7373
let abi = JSON.parse(data.result);
7474
let src = generateSolidity({
7575
name: name,
76-
solidityVersion: "0.8.9",
76+
solidityVersion: solidityVersion,
7777
abi,
78-
outputSource: false
78+
outputSource: false,
79+
outputAttribution: false,
7980
});
81+
src = src.substring(src.indexOf("\n\n") + 2); // strip license/pragma
8082
return resolve(src)
8183
}
8284
})

0 commit comments

Comments
 (0)