-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathextension.ts
More file actions
140 lines (122 loc) · 4.02 KB
/
extension.ts
File metadata and controls
140 lines (122 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { ethers } from "ethers";
import * as vscode from "vscode";
import { InputBoxOptions, window, commands } from "vscode";
import { GanacheAddressType } from "./types";
import {
callContractMethod,
deployContract,
displayBalance,
setTransactionGas,
updateSelectedNetwork,
} from "./utils/networks";
import { logger } from "./lib";
import {
createKeyPair,
deleteKeyPair,
selectAccount,
importKeyPair,
exportKeyPair,
} from "./utils/wallet";
import {
createERC4337TokenPaymaster,
createERC4337VerifyPaymaster,
createERC4907Contract,
parseBatchCompiledJSON,
parseCompiledJSONPayload,
selectContract,
} from "./utils";
// eslint-disable-next-line import/prefer-default-export
export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
// Create new account with password
commands.registerCommand("ethcode.account.create", async () => {
try {
const pwdInpOpt: InputBoxOptions = {
ignoreFocusOut: true,
password: true,
placeHolder: "Password",
};
const password = await window.showInputBox(pwdInpOpt);
createKeyPair(context, context.extensionPath, password || "");
} catch (error) {
logger.error(error);
}
}),
// Delete selected account with password
commands.registerCommand("ethcode.account.delete", async () => {
deleteKeyPair(context);
}),
// Deploy ContractcallContractMethod
commands.registerCommand("ethcode.contract.deploy", async () => {
deployContract(context);
}),
// select ethereum networks
commands.registerCommand("ethcode.network.select", () => {
updateSelectedNetwork(context);
}),
// create ERC4907 contract
commands.registerCommand("ethcode.rental.create", () => {
createERC4907Contract(context);
}),
//create ERC4337 VerifyPaymaster contracts
commands.registerCommand("ethcode.verifypaymaster.create", () => {
createERC4337VerifyPaymaster(context);
}),
//create ERC4337 TokenPaymaster contracts
commands.registerCommand("ethcode.tokenpaymaster.create", () => {
createERC4337TokenPaymaster(context);
}),
// Select Ethereum Account
commands.registerCommand("ethcode.account.select", () => {
selectAccount(context);
}),
// Get account balance
commands.registerCommand("ethcode.account.balance", async () => {
displayBalance(context);
}),
// Set gas strategy
commands.registerCommand("ethcode.transaction.gas.set", async () => {
setTransactionGas(context);
}),
// Load combined JSON output
commands.registerCommand("ethcode.compiled-json.load", () => {
const editorContent = window.activeTextEditor
? window.activeTextEditor.document.getText()
: undefined;
parseCompiledJSONPayload(context, editorContent);
}),
// Load all combined JSON output
commands.registerCommand("ethcode.compiled-json.load.all", async () => {
parseBatchCompiledJSON(context);
}),
// Select a compiled json from the list
commands.registerCommand("ethcode.compiled-json.select", () => {
selectContract(context);
}),
// Call contract method
commands.registerCommand("ethcode.contract.call", async () => {
callContractMethod(context);
}),
//Export Account
commands.registerCommand("ethcode.account.export", async () => {
exportKeyPair(context);
}),
//Import Key pair
commands.registerCommand("ethcode.account.import", async () => {
importKeyPair(context);
}),
// Set custom gas estimate
// commands.registerCommand('ethcode.transaction.gas.set', async () => {
// const gasInp: InputBoxOptions = {
// ignoreFocusOut: false,
// placeHolder: 'Enter custom gas',
// };
// const gas = await window.showInputBox(gasInp);
// context.workspaceState.update('gasEstimate', gas);
// }),
// Activate
commands.registerCommand("ethcode.activate", async () => {
logger.success("Welcome to Ethcode!");
})
);
}