@arcsign/hardhat-plugin 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * ArcSign Provider
3
+ *
4
+ * Manages connection to ArcSign Dashboard and creates signers.
5
+ */
6
+ import { Provider } from "ethers";
7
+ import { ArcSignClient } from "./ArcSignClient";
8
+ import { ArcSignSigner } from "./ArcSignSigner";
9
+ export declare class ArcSignProvider {
10
+ private client;
11
+ private accounts;
12
+ constructor(wsUrl?: string);
13
+ /**
14
+ * Connect to ArcSign Dashboard
15
+ */
16
+ connect(): Promise<void>;
17
+ /**
18
+ * Disconnect from ArcSign Dashboard
19
+ */
20
+ disconnect(): void;
21
+ /**
22
+ * Check if connected
23
+ */
24
+ isConnected(): Promise<boolean>;
25
+ /**
26
+ * Get available accounts
27
+ */
28
+ getAccounts(): Promise<string[]>;
29
+ /**
30
+ * Get signers for all accounts
31
+ */
32
+ getSigners(provider: Provider): Promise<ArcSignSigner[]>;
33
+ /**
34
+ * Get a signer for a specific address
35
+ */
36
+ getSigner(address: string, provider: Provider): Promise<ArcSignSigner>;
37
+ /**
38
+ * Get the underlying client
39
+ */
40
+ getClient(): ArcSignClient;
41
+ /**
42
+ * Get developer session status
43
+ */
44
+ getSession(): Promise<{
45
+ active: boolean;
46
+ session?: {
47
+ enabled: boolean;
48
+ expires_at: number;
49
+ trusted_networks: string[];
50
+ sign_count: number;
51
+ };
52
+ remaining_ms?: number;
53
+ message?: string;
54
+ }>;
55
+ /**
56
+ * Create a developer session for auto-signing testnets
57
+ */
58
+ createSession(params: {
59
+ walletId: string;
60
+ durationMinutes?: number;
61
+ trustedNetworks?: string[];
62
+ maxGasLimit?: string;
63
+ }): Promise<{
64
+ status: string;
65
+ session: {
66
+ enabled: boolean;
67
+ created_at: number;
68
+ expires_at: number;
69
+ trusted_networks: string[];
70
+ sign_count: number;
71
+ };
72
+ }>;
73
+ /**
74
+ * End the current developer session
75
+ */
76
+ endSession(): Promise<{
77
+ status: string;
78
+ sign_count?: number;
79
+ message?: string;
80
+ }>;
81
+ }
82
+ //# sourceMappingURL=ArcSignProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcSignProvider.d.ts","sourceRoot":"","sources":["../src/ArcSignProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,KAAK,GAAE,MAA8B;IAIjD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAarC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQtC;;OAEG;IACG,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAgB9D;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;IAkB5E;;OAEG;IACH,SAAS,IAAI,aAAa;IAI1B;;OAEG;IACG,UAAU;;;;;;;;;;;IAIhB;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE;QAC1B,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;;;;;;;;;;IASD;;OAEG;IACG,UAAU;;;;;CAGjB"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /**
3
+ * ArcSign Provider
4
+ *
5
+ * Manages connection to ArcSign Dashboard and creates signers.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ArcSignProvider = void 0;
9
+ const ArcSignClient_1 = require("./ArcSignClient");
10
+ const ArcSignSigner_1 = require("./ArcSignSigner");
11
+ class ArcSignProvider {
12
+ constructor(wsUrl = "ws://127.0.0.1:9527") {
13
+ this.accounts = [];
14
+ this.client = new ArcSignClient_1.ArcSignClient(wsUrl);
15
+ }
16
+ /**
17
+ * Connect to ArcSign Dashboard
18
+ */
19
+ async connect() {
20
+ await this.client.connect();
21
+ // Verify connection with ping
22
+ const pingResult = await this.client.ping();
23
+ console.log(`[ArcSign] ✓ Connected to ${pingResult.wallet} v${pingResult.version}`);
24
+ // Get available accounts
25
+ const accountsResult = await this.client.getAccounts();
26
+ this.accounts = accountsResult.accounts;
27
+ if (this.accounts.length === 0) {
28
+ console.warn("[ArcSign] ⚠️ No accounts available. Please unlock a wallet in ArcSign Dashboard.");
29
+ }
30
+ else {
31
+ console.log(`[ArcSign] Available accounts:`);
32
+ this.accounts.forEach((addr, i) => {
33
+ console.log(`[ArcSign] [${i}] ${addr}`);
34
+ });
35
+ }
36
+ }
37
+ /**
38
+ * Disconnect from ArcSign Dashboard
39
+ */
40
+ disconnect() {
41
+ this.client.disconnect();
42
+ }
43
+ /**
44
+ * Check if connected
45
+ */
46
+ async isConnected() {
47
+ if (!this.client.isConnected()) {
48
+ return false;
49
+ }
50
+ try {
51
+ await this.client.ping();
52
+ return true;
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ }
58
+ /**
59
+ * Get available accounts
60
+ */
61
+ async getAccounts() {
62
+ if (this.accounts.length === 0) {
63
+ const result = await this.client.getAccounts();
64
+ this.accounts = result.accounts;
65
+ }
66
+ return this.accounts;
67
+ }
68
+ /**
69
+ * Get signers for all accounts
70
+ */
71
+ async getSigners(provider) {
72
+ const accounts = await this.getAccounts();
73
+ if (accounts.length === 0) {
74
+ throw new Error("No accounts available from ArcSign. " +
75
+ "Please make sure:\n" +
76
+ " 1. ArcSign Dashboard is running\n" +
77
+ " 2. A wallet is unlocked\n" +
78
+ " 3. The wallet has at least one address");
79
+ }
80
+ return accounts.map((address) => new ArcSignSigner_1.ArcSignSigner(address, this.client, provider));
81
+ }
82
+ /**
83
+ * Get a signer for a specific address
84
+ */
85
+ async getSigner(address, provider) {
86
+ const accounts = await this.getAccounts();
87
+ const normalizedAddress = address.toLowerCase();
88
+ const matchedAddress = accounts.find((a) => a.toLowerCase() === normalizedAddress);
89
+ if (!matchedAddress) {
90
+ throw new Error(`Address ${address} is not available in ArcSign. ` +
91
+ `Available addresses: ${accounts.join(", ")}`);
92
+ }
93
+ return new ArcSignSigner_1.ArcSignSigner(matchedAddress, this.client, provider);
94
+ }
95
+ /**
96
+ * Get the underlying client
97
+ */
98
+ getClient() {
99
+ return this.client;
100
+ }
101
+ /**
102
+ * Get developer session status
103
+ */
104
+ async getSession() {
105
+ return this.client.getDevSession();
106
+ }
107
+ /**
108
+ * Create a developer session for auto-signing testnets
109
+ */
110
+ async createSession(params) {
111
+ return this.client.createDevSession({
112
+ wallet_id: params.walletId,
113
+ duration_minutes: params.durationMinutes,
114
+ trusted_networks: params.trustedNetworks,
115
+ max_gas_limit: params.maxGasLimit,
116
+ });
117
+ }
118
+ /**
119
+ * End the current developer session
120
+ */
121
+ async endSession() {
122
+ return this.client.endDevSession();
123
+ }
124
+ }
125
+ exports.ArcSignProvider = ArcSignProvider;
126
+ //# sourceMappingURL=ArcSignProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcSignProvider.js","sourceRoot":"","sources":["../src/ArcSignProvider.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,mDAAgD;AAChD,mDAAgD;AAEhD,MAAa,eAAe;IAI1B,YAAY,QAAgB,qBAAqB;QAFzC,aAAQ,GAAa,EAAE,CAAC;QAG9B,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CAAC,EAAE,CAC9C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,6BAAa,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,MAKnB;QACC,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;YAClC,SAAS,EAAE,MAAM,CAAC,QAAQ;YAC1B,gBAAgB,EAAE,MAAM,CAAC,eAAe;YACxC,gBAAgB,EAAE,MAAM,CAAC,eAAe;YACxC,aAAa,EAAE,MAAM,CAAC,WAAW;SAClC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;CACF;AA/ID,0CA+IC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * ArcSign Signer
3
+ *
4
+ * Implements ethers.js Signer interface using ArcSign wallet.
5
+ */
6
+ import { AbstractSigner, Provider, TransactionRequest, TransactionResponse, TypedDataDomain, TypedDataField } from "ethers";
7
+ import { ArcSignClient } from "./ArcSignClient";
8
+ export declare class ArcSignSigner extends AbstractSigner {
9
+ private client;
10
+ private _address;
11
+ readonly address: string;
12
+ constructor(address: string, client: ArcSignClient, provider?: Provider | null);
13
+ /**
14
+ * Get current script context (detected at call time)
15
+ */
16
+ private getCurrentScriptContext;
17
+ /**
18
+ * Detect script context from stack trace
19
+ * Note: Should be called at signing time to capture the actual script
20
+ */
21
+ private detectScriptContext;
22
+ /**
23
+ * Connect this signer to a provider
24
+ */
25
+ connect(provider: Provider | null): ArcSignSigner;
26
+ /**
27
+ * Get the address
28
+ */
29
+ getAddress(): Promise<string>;
30
+ /**
31
+ * Sign a message (EIP-191)
32
+ */
33
+ signMessage(message: string | Uint8Array): Promise<string>;
34
+ /**
35
+ * Sign typed data (EIP-712)
36
+ */
37
+ signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
38
+ /**
39
+ * Sign a transaction
40
+ */
41
+ signTransaction(tx: TransactionRequest): Promise<string>;
42
+ /**
43
+ * Send a transaction
44
+ */
45
+ sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
46
+ /**
47
+ * Format address for display
48
+ */
49
+ private formatAddress;
50
+ /**
51
+ * Convert base64 encoded string to hex with 0x prefix
52
+ * ArcSign returns signed transactions in base64, but RPC expects hex
53
+ */
54
+ private base64ToHex;
55
+ }
56
+ //# sourceMappingURL=ArcSignSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcSignSigner.d.ts","sourceRoot":"","sources":["../src/ArcSignSigner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5H,OAAO,EAAE,aAAa,EAAc,MAAM,iBAAiB,CAAC;AAG5D,qBAAa,aAAc,SAAQ,cAAc;IAC/C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAS;IAGzB,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAE,QAAQ,GAAG,IAAW;IAOpF;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAI/B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA2C3B;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,aAAa;IAIjD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBhE;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,EACvC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;IA4BlB;;OAEG;IACG,eAAe,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IA6C9D;;OAEG;IACG,eAAe,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgB3E;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;;OAGG;IACH,OAAO,CAAC,WAAW;CAMpB"}
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /**
3
+ * ArcSign Signer
4
+ *
5
+ * Implements ethers.js Signer interface using ArcSign wallet.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ArcSignSigner = void 0;
12
+ const ethers_1 = require("ethers");
13
+ const path_1 = __importDefault(require("path"));
14
+ class ArcSignSigner extends ethers_1.AbstractSigner {
15
+ constructor(address, client, provider = null) {
16
+ super(provider);
17
+ this.client = client;
18
+ this._address = address;
19
+ this.address = address;
20
+ }
21
+ /**
22
+ * Get current script context (detected at call time)
23
+ */
24
+ getCurrentScriptContext() {
25
+ return this.detectScriptContext();
26
+ }
27
+ /**
28
+ * Detect script context from stack trace
29
+ * Note: Should be called at signing time to capture the actual script
30
+ */
31
+ detectScriptContext() {
32
+ const stack = new Error().stack || "";
33
+ const lines = stack.split("\n");
34
+ // Debug: log stack trace to help troubleshoot
35
+ console.log("[ArcSign] Stack trace for script detection:");
36
+ lines.slice(0, 10).forEach(line => console.log(" ", line));
37
+ // Look for scripts/ directory or common deploy patterns in stack
38
+ for (const line of lines) {
39
+ // Match both formats: "at func (path:line:col)" and "at path:line:col"
40
+ const match = line.match(/(?:at\s+(?:[\w.<>]+\s+)?)?(?:\()?([^()]+\.(ts|js)):\d+:\d+/);
41
+ if (match) {
42
+ const filePath = match[1];
43
+ // Skip node_modules and internal files
44
+ if (filePath.includes("node_modules"))
45
+ continue;
46
+ // Check for common script patterns
47
+ if (filePath.includes("scripts/") ||
48
+ filePath.includes("deploy") ||
49
+ filePath.includes("hardhat") ||
50
+ filePath.endsWith(".ts") ||
51
+ filePath.endsWith(".js")) {
52
+ const scriptName = path_1.default.basename(filePath);
53
+ // Skip if it's our own files
54
+ if (scriptName.includes("ArcSign"))
55
+ continue;
56
+ console.log("[ArcSign] Detected script:", scriptName);
57
+ return {
58
+ script_name: scriptName,
59
+ project_path: path_1.default.dirname(filePath),
60
+ is_dev_wallet: true,
61
+ };
62
+ }
63
+ }
64
+ }
65
+ console.log("[ArcSign] Could not detect script name from stack trace");
66
+ return {
67
+ is_dev_wallet: true,
68
+ };
69
+ }
70
+ /**
71
+ * Connect this signer to a provider
72
+ */
73
+ connect(provider) {
74
+ return new ArcSignSigner(this._address, this.client, provider);
75
+ }
76
+ /**
77
+ * Get the address
78
+ */
79
+ async getAddress() {
80
+ return this._address;
81
+ }
82
+ /**
83
+ * Sign a message (EIP-191)
84
+ */
85
+ async signMessage(message) {
86
+ const messageStr = typeof message === "string"
87
+ ? message
88
+ : "0x" + Buffer.from(message).toString("hex");
89
+ console.log(`[ArcSign] Signing message with ${this.formatAddress(this._address)}...`);
90
+ console.log(`[ArcSign] ⏳ Waiting for approval in ArcSign Dashboard...`);
91
+ const result = await this.client.personalSign(this._address, messageStr, {
92
+ ...this.getCurrentScriptContext(),
93
+ description: "Sign Message",
94
+ });
95
+ console.log(`[ArcSign] ✓ Message signed`);
96
+ return result.signature;
97
+ }
98
+ /**
99
+ * Sign typed data (EIP-712)
100
+ */
101
+ async signTypedData(domain, types, value) {
102
+ const typedData = {
103
+ types: {
104
+ EIP712Domain: [
105
+ { name: "name", type: "string" },
106
+ { name: "version", type: "string" },
107
+ { name: "chainId", type: "uint256" },
108
+ { name: "verifyingContract", type: "address" },
109
+ ],
110
+ ...types,
111
+ },
112
+ primaryType: Object.keys(types)[0],
113
+ domain,
114
+ message: value,
115
+ };
116
+ console.log(`[ArcSign] Signing typed data with ${this.formatAddress(this._address)}...`);
117
+ console.log(`[ArcSign] ⏳ Waiting for approval in ArcSign Dashboard...`);
118
+ const result = await this.client.signTypedData(this._address, typedData, {
119
+ ...this.getCurrentScriptContext(),
120
+ description: "Sign Typed Data",
121
+ });
122
+ console.log(`[ArcSign] ✓ Typed data signed`);
123
+ return result.signature;
124
+ }
125
+ /**
126
+ * Sign a transaction
127
+ */
128
+ async signTransaction(tx) {
129
+ if (!this.provider) {
130
+ throw new Error("Provider not set");
131
+ }
132
+ // Resolve addresses and estimate gas if needed
133
+ const resolvedTx = await this.populateTransaction(tx);
134
+ console.log(`[ArcSign] Signing transaction...`);
135
+ console.log(`[ArcSign] From: ${this.formatAddress(this._address)}`);
136
+ console.log(`[ArcSign] To: ${resolvedTx.to ? this.formatAddress(resolvedTx.to.toString()) : "(Contract Deploy)"}`);
137
+ console.log(`[ArcSign] Value: ${resolvedTx.value || "0"}`);
138
+ console.log(`[ArcSign] ⏳ Waiting for approval in ArcSign Dashboard...`);
139
+ const network = await this.provider.getNetwork();
140
+ const result = await this.client.devSignTransaction({
141
+ from: this._address,
142
+ to: resolvedTx.to?.toString() || "",
143
+ data: resolvedTx.data?.toString() || "0x",
144
+ value: resolvedTx.value?.toString(),
145
+ gas: resolvedTx.gasLimit?.toString(),
146
+ gasPrice: resolvedTx.gasPrice?.toString(),
147
+ maxFeePerGas: resolvedTx.maxFeePerGas?.toString(),
148
+ maxPriorityFeePerGas: resolvedTx.maxPriorityFeePerGas?.toString(),
149
+ chainId: Number(network.chainId),
150
+ nonce: resolvedTx.nonce !== undefined ? Number(resolvedTx.nonce) : undefined,
151
+ context: {
152
+ ...this.getCurrentScriptContext(),
153
+ description: resolvedTx.to ? "Contract Call" : "Deploy Contract",
154
+ },
155
+ });
156
+ if (!result.signed_tx) {
157
+ throw new Error("No signed transaction returned");
158
+ }
159
+ console.log(`[ArcSign] ✓ Transaction signed`);
160
+ // The signed_tx from ArcSign is base64 encoded - convert to hex with 0x prefix
161
+ // RPC nodes expect hex format for eth_sendRawTransaction
162
+ const signedTxHex = this.base64ToHex(result.signed_tx);
163
+ return signedTxHex;
164
+ }
165
+ /**
166
+ * Send a transaction
167
+ */
168
+ async sendTransaction(tx) {
169
+ if (!this.provider) {
170
+ throw new Error("Provider not set");
171
+ }
172
+ // Sign the transaction
173
+ const signedTx = await this.signTransaction(tx);
174
+ // Broadcast it
175
+ console.log(`[ArcSign] Broadcasting transaction...`);
176
+ const response = await this.provider.broadcastTransaction(signedTx);
177
+ console.log(`[ArcSign] ✓ Transaction submitted: ${response.hash}`);
178
+ return response;
179
+ }
180
+ /**
181
+ * Format address for display
182
+ */
183
+ formatAddress(address) {
184
+ if (address.length >= 10) {
185
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
186
+ }
187
+ return address;
188
+ }
189
+ /**
190
+ * Convert base64 encoded string to hex with 0x prefix
191
+ * ArcSign returns signed transactions in base64, but RPC expects hex
192
+ */
193
+ base64ToHex(base64) {
194
+ // Decode base64 to bytes
195
+ const bytes = Buffer.from(base64, "base64");
196
+ // Convert to hex with 0x prefix
197
+ return "0x" + bytes.toString("hex");
198
+ }
199
+ }
200
+ exports.ArcSignSigner = ArcSignSigner;
201
+ //# sourceMappingURL=ArcSignSigner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcSignSigner.js","sourceRoot":"","sources":["../src/ArcSignSigner.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,mCAA4H;AAE5H,gDAAwB;AAExB,MA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AAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,OAAe;QACnC,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACzB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;OAGG;IACK,WAAW,CAAC,MAAc;QAChC,yBAAyB;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5C,gCAAgC;QAChC,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF;AAhOD,sCAgOC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @arcsign/hardhat-plugin
3
+ *
4
+ * Hardhat plugin for secure transaction signing with ArcSign wallet.
5
+ * Eliminates the need for private keys in .env files.
6
+ *
7
+ * Usage in hardhat.config.ts:
8
+ *
9
+ * ```typescript
10
+ * import "@arcsign/hardhat-plugin";
11
+ *
12
+ * export default {
13
+ * networks: {
14
+ * mainnet: {
15
+ * url: process.env.RPC_URL,
16
+ * accounts: [], // Empty - ArcSign provides signers
17
+ * arcsign: true, // Enable ArcSign for this network
18
+ * },
19
+ * },
20
+ * };
21
+ * ```
22
+ */
23
+ import { ArcSignProvider } from "./ArcSignProvider";
24
+ import { ArcSignClient } from "./ArcSignClient";
25
+ declare module "hardhat/types/runtime" {
26
+ interface HardhatRuntimeEnvironment {
27
+ arcsign: {
28
+ provider: ArcSignProvider;
29
+ client: ArcSignClient;
30
+ isConnected: () => Promise<boolean>;
31
+ getAccounts: () => Promise<string[]>;
32
+ getExplorerApiKey: (explorer: string) => Promise<string | null>;
33
+ };
34
+ }
35
+ }
36
+ declare module "hardhat/types/config" {
37
+ interface HardhatConfig {
38
+ etherscan?: {
39
+ apiKey?: string | Record<string, string>;
40
+ customChains?: unknown[];
41
+ };
42
+ }
43
+ }
44
+ export { ArcSignProvider } from "./ArcSignProvider";
45
+ export { ArcSignSigner } from "./ArcSignSigner";
46
+ export { ArcSignClient } from "./ArcSignClient";
47
+ export { getExplorerForChainId, isTestnet, getChainIdForNetwork } from "./utils";
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAShD,OAAO,QAAQ,uBAAuB,CAAC;IACrC,UAAU,yBAAyB;QACjC,OAAO,EAAE;YACP,QAAQ,EAAE,eAAe,CAAC;YAC1B,MAAM,EAAE,aAAa,CAAC;YACtB,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;YACpC,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACrC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;SACjE,CAAC;KACH;CACF;AAGD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,aAAa;QACrB,SAAS,CAAC,EAAE;YACV,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACzC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;SAC1B,CAAC;KACH;CACF;AAgKD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}