forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from poanetwork/vb-eip-1193-final
Refactoring #2 before EIP - 1193
- Loading branch information
Showing
37 changed files
with
1,538 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { formatTxMetaForRpcResult } = require('../util') | ||
import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware' | ||
|
||
export function createPendingNonceMiddleware ({ getPendingNonce }) { | ||
return createAsyncMiddleware(async (req, res, next) => { | ||
const { method, params } = req | ||
if (method !== 'eth_getTransactionCount') { | ||
return next() | ||
} | ||
const [param, blockRef] = params | ||
if (blockRef !== 'pending') { | ||
return next() | ||
} | ||
res.result = await getPendingNonce(param) | ||
}) | ||
} | ||
|
||
export function createPendingTxMiddleware ({ getPendingTransactionByHash }) { | ||
return createAsyncMiddleware(async (req, res, next) => { | ||
const { method, params } = req | ||
if (method !== 'eth_getTransactionByHash') { | ||
return next() | ||
} | ||
const [hash] = params | ||
const txMeta = getPendingTransactionByHash(hash) | ||
if (!txMeta) { | ||
return next() | ||
} | ||
res.result = formatTxMetaForRpcResult(txMeta) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.