Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Support network option in addition to providerUrl when debugging #260

Closed
acuarica opened this issue Nov 14, 2022 · 7 comments
Closed

Support network option in addition to providerUrl when debugging #260

acuarica opened this issue Nov 14, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@acuarica
Copy link
Contributor

acuarica commented Nov 14, 2022

Currently, the extension supports the providerUrl option to allow the user to indicate a provider when launching a new debug session. This option suffices unless the user wants to specify a provider using a Web3js object[1]. Since Web3js provider objects do not have a serialized form, the extension needs a mechanism to accept a provider other than using a provider url.

Introduce a new debugger option, network, that allows the user to specify a network name declared in a Truffle config file, e.g., truffle-config.js. The network and providerUrl are options should be mutually exclusive. When both network and providerUrl options are present, the providerUrl should take precedence.

This impacts how Truffle CLI passes arguments down to the extension.trufflesuite/truffle#5684.

Moreover, this new option should be accepted from both the Debugger's launch configuration or from the Debugger's command line (#254 and #231).

Whenever this new feature is implemented, we should update the docs accordingly. This feature should be included in addition to trufflesuite/trufflesuite.com#1354.

Note that the Truffle: Debug Transaction command should not be affected by this new option. This command already handles provider selection using VS Code UI.

Examples

When the user wants to use a network declared in the Truffle config file, they can set the network field (and omit the providerUrl field altogether) as follows

Using URI handler

vscode://trufflesuite-csi.truffle-vscode/debug?txHash=0xd4290e9754d1a60cb7be5c1f6b53090fb6f047d13d325517f36aa15b6a9f46e0&network=development&workingDirectory=%2Fpath%2Fto%2Fproject&disableFetchExternal=true

Using a launch configuration

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "truffle",
            "request": "launch",
            "name": "Truffle - Debug Transaction",
            "stopOnEntry": false,
            "txHash": "0x79381a69eb828558f2728900615109eb7bdeb6d216af130142341da15cc6fecd",
            "workingDirectory": "${workspaceFolder}",
            "network": "development",
            "disableFetchExternal": true,
        }
    ]
}

[1] See provider property under the networks section for more details.

@acuarica acuarica added doc-change-required Issue indicates a change to documentation is required enhancement New feature or request labels Nov 14, 2022
@acuarica
Copy link
Contributor Author

@xhulz @kevinbluer does this make sense after our discussion? @michaeljohnbennett to loop you in.

@xhulz
Copy link
Contributor

xhulz commented Nov 15, 2022

Hi @acuarica,

Yes, sounds good! Thank you for that one :)

@xhulz
Copy link
Contributor

xhulz commented Nov 16, 2022

Hey @acuarica,

I think the providerUrl parameter is missing in the URI handler and Launch configuration.
ref: https://gist.github.com/gnidan/4579216299fac7a41c51e0e370e8ddc2

@acuarica
Copy link
Contributor Author

Hi @xhulz, not sure if understand correctly, missing where? providerUrl is currently used to accept the provider in both the launch configuration and URI handler.

@xhulz
Copy link
Contributor

xhulz commented Nov 16, 2022

Hey @acuarica, in the documentation above, but no worries. For example, here: vscode://trufflesuite-csi.truffle-vscode/debug?txHash=0xd4290e9754d1a60cb7be5c1f6b53090fb6f047d13d325517f36aa15b6a9f46e0&network=development&workingDirectory=%2Fpath%2Fto%2Fproject&disableFetchExternal=true

@acuarica
Copy link
Contributor Author

Got it, thanks for the heads up. I added some remarks in this issue's Example section that hopefully makes it clear. In summary it is missing because the network field has been specified.

@acuarica
Copy link
Contributor Author

Closing since it was implemented in #261.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants