Skip to content

Commit e1d274a

Browse files
committed
preliminary work for external tx support
1 parent 269bca5 commit e1d274a

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

TODO.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
- [ ] error on Library missing in bytecode
2121
- [ ] error when not finding --no-scripts as folder
2222
- [ ] continue even if evm_snapshot not present on fixture call
23+
- [ ] supports ENS name in namedAccounts (fetch ENS first, or only if ends with .eth or other domain?, require mainnet provider)

src/helpers.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,11 @@ export function addHelpers(
614614
);
615615
await setupGasPrice(unsignedTx);
616616
await setupNonce(from, unsignedTx);
617-
617+
618618
// Temporary workaround for https://github.com/ethers-io/ethers.js/issues/2078
619619
// TODO: Remove me when LedgerSigner adds proper support for 1559 txns
620620
if (hardwareWallet === 'ledger') {
621-
unsignedTx.type = 1
621+
unsignedTx.type = 1;
622622
}
623623

624624
if (unknown) {
@@ -1730,7 +1730,26 @@ Note that in this case, the contract deployment will not behave the same if depl
17301730
const registeredProtocol =
17311731
deploymentManager.addressesToProtocol[from.toLowerCase()];
17321732
if (registeredProtocol) {
1733-
if (registeredProtocol === 'ledger') {
1733+
if (registeredProtocol === 'external') {
1734+
ethersSigner = provider.getSigner(from); //new WaitingTxSigner(from, provider);
1735+
ethersSigner.sendTransaction = async (
1736+
txRequest: TransactionRequest
1737+
) => {
1738+
const response: {hash: string} = await enquirer.prompt({
1739+
type: 'input',
1740+
name: 'hash',
1741+
message: `
1742+
tx hash please
1743+
to : ${txRequest.to}
1744+
data : ${txRequest.data}
1745+
value : ${txRequest.value}
1746+
`,
1747+
});
1748+
1749+
return provider.getTransaction(response.hash);
1750+
};
1751+
hardwareWallet = 'external';
1752+
} else if (registeredProtocol === 'ledger') {
17341753
if (!LedgerSigner) {
17351754
// eslint-disable-next-line @typescript-eslint/no-unused-vars
17361755
let error: any | undefined;

src/utils.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ export async function getExtendedArtifactFromFolders(
6868
for (const folderPath of folderPaths) {
6969
const artifacts = new Artifacts(folderPath);
7070
let artifact = getOldArtifactSync(name, folderPath);
71-
if (!artifact && (await artifacts.artifactExists(name).catch(()=>false))) {
71+
if (
72+
!artifact &&
73+
(await artifacts.artifactExists(name).catch(() => false))
74+
) {
7275
const hardhatArtifact: Artifact = await artifacts.readArtifact(name);
7376
// check if name is already a fullyQualifiedName
7477
let fullyQualifiedName = name;
@@ -332,7 +335,12 @@ function transformNamedAccounts(
332335
// eslint-disable-next-line no-case-declarations
333336
const protocolSplit = spec.split('://');
334337
if (protocolSplit.length > 1) {
335-
if (protocolSplit[0].toLowerCase() === 'ledger') {
338+
if (protocolSplit[0].toLowerCase() === 'external') {
339+
address = protocolSplit[1];
340+
addressesToProtocol[address.toLowerCase()] =
341+
protocolSplit[0].toLowerCase();
342+
// knownAccountsDict[address.toLowerCase()] = true; // TODO ? this would prevent auto impersonation in fork/test
343+
} else if (protocolSplit[0].toLowerCase() === 'ledger') {
336344
address = protocolSplit[1];
337345
addressesToProtocol[address.toLowerCase()] =
338346
protocolSplit[0].toLowerCase();

0 commit comments

Comments
 (0)