Support network
option in addition to providerUrl
when debugging #260
Description
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.