-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into update-spending-cap
- Loading branch information
Showing
20 changed files
with
427 additions
and
99 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
43 changes: 43 additions & 0 deletions
43
app/scripts/lib/rpc-method-middleware/handlers/desktop/enable-desktop.js
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,43 @@ | ||
import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; | ||
|
||
/** | ||
* A wrapper for `eth_accounts` that returns an empty array when permission is denied. | ||
*/ | ||
|
||
const requestEthereumAccounts = { | ||
methodNames: [MESSAGE_TYPE.ENABLE_DESKTOP], | ||
implementation: enableDesktop, | ||
hookNames: { | ||
testDesktopConnection: true, | ||
generateOtp: true, | ||
}, | ||
}; | ||
export default requestEthereumAccounts; | ||
|
||
/** | ||
* @typedef {Record<string, Function>} EthAccountsOptions | ||
* @property {Function} getAccounts - Gets the accounts for the requesting | ||
* origin. | ||
*/ | ||
|
||
/** | ||
* | ||
* @param {import('json-rpc-engine').JsonRpcRequest<unknown>} _req - The JSON-RPC request object. | ||
* @param {import('json-rpc-engine').JsonRpcResponse<true>} res - The JSON-RPC response object. | ||
* @param {Function} _next - The json-rpc-engine 'next' callback. | ||
* @param {Function} end - The json-rpc-engine 'end' callback. | ||
* @param {EthAccountsOptions} options - The RPC method hooks. | ||
*/ | ||
async function enableDesktop( | ||
_req, | ||
res, | ||
_next, | ||
end, | ||
{ testDesktopConnection, generateOtp }, | ||
) { | ||
const testResult = await testDesktopConnection(); | ||
const otp = testResult.isConnected ? await generateOtp() : undefined; | ||
|
||
res.result = { ...testResult, otp }; | ||
return end(); | ||
} |
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.