Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions src/commands/DebuggerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {shortenHash} from '@/debugAdapter/functions';
import {TransactionProvider} from '@/debugAdapter/transaction/transactionProvider';
import {Web3Wrapper} from '@/debugAdapter/web3Wrapper';
import {getTruffleWorkspace, getPathByPlatform} from '@/helpers/workspace';
import {showInputBox, showQuickPick} from '@/helpers/userInteraction';
import {showQuickPick} from '@/helpers/userInteraction';
import {Telemetry} from '@/TelemetryClient';

export namespace DebuggerCommands {
Expand All @@ -29,28 +29,17 @@ export namespace DebuggerCommands {

// const workspaceFolder = workspace.getWorkspaceFolder(workspaceUri);

if (debugNetwork.isLocalNetwork()) {
// if local service then provide last transactions to choose
const transactionProvider = new TransactionProvider(web3, contractBuildDir);
const txHashesAsQuickPickItems = await getQuickPickItems(transactionProvider);
const transactionProvider = new TransactionProvider(web3, contractBuildDir);
const txHashesAsQuickPickItems = await getQuickPickItems(transactionProvider);

const txHashSelection = await showQuickPick(txHashesAsQuickPickItems, {
ignoreFocusOut: true,
placeHolder: 'Enter the transaction hash to debug',
});
const txHashSelection = await showQuickPick(txHashesAsQuickPickItems, {
ignoreFocusOut: true,
placeHolder: 'Enter the transaction hash to debug',
});

const txHash = txHashSelection.detail || txHashSelection.label;
const txHash = txHashSelection.detail || txHashSelection.label;

await startDebugging(txHash, workingDirectory, providerUrl);
} else {
// if remote network then require txHash
const placeHolder = 'Type the transaction hash you want to debug (0x...)';
const txHash = await showInputBox({placeHolder});

if (txHash) {
await startDebugging(txHash, workingDirectory, providerUrl);
}
}
await startDebugging(txHash, workingDirectory, providerUrl);
}
}

Expand All @@ -66,11 +55,7 @@ async function getQuickPickItems(txProvider: TransactionProvider) {
});
}

export function generateDebugAdapterConfig(
txHash: string,
workingDirectory: string,
providerUrl: string
): DebugConfiguration {
function generateDebugAdapterConfig(txHash: string, workingDirectory: string, providerUrl: string): DebugConfiguration {
return {
files: [],
name: 'Debug Transactions',
Expand Down
7 changes: 6 additions & 1 deletion src/helpers/uriHandlerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ export class UriHandlerController implements UriHandler {
try {
// Gets the command name
const command = uri.path.replace('/', '');
const searchParams = new URLSearchParams(uri.query);

// Gets the configuration arguments
const debugConfig = JSON.parse(uri.query) as TDebugInformation;
const debugConfig: TDebugInformation = {
txHash: searchParams.get('txHash')!,
workingDirectory: searchParams.get('workingDirectory')!,
providerUrl: searchParams.get('providerUrl')!,
};

// Checks what kind of command it will need to execute
switch (command) {
Expand Down
14 changes: 0 additions & 14 deletions test/commands/DebuggerCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,4 @@ describe('DebuggerCommands unit tests', () => {
assert.strictEqual(mockGetTxInfos.calledOnce, true, 'getTransactionsInfo should be called');
assert.strictEqual(createQuickPickFn.called, true, 'createQuickPic should be called');
});

it('should show inputBox when debugNetwork.isLocalNetwork() is false', async () => {
// Arrange
sinon.stub(DebugNetwork.prototype, 'isLocalNetwork').returns(false);
const showInputBoxFn = sinon.stub(userInteraction, 'showInputBox').resolves('');

// Act
await debugCommands.DebuggerCommands.startSolidityDebugger();

// Assert
assert.strictEqual(showInputBoxFn.called, true, 'showInputBox should be called');
assert.strictEqual(mockGetTxHashes.calledOnce, false, "getLastTransactionHashes shouldn't be called");
assert.strictEqual(mockGetTxInfos.calledOnce, false, "getTransactionsInfo shouldn't be called");
});
});