This repository was archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 357
Feature #1480: Handle rpc calls from apps SDK #1519
Merged
mmv08
merged 32 commits into
development
from
feature/1480-handle-rpc-calls-from-apps-sdk
Oct 26, 2020
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c43ff06
sdk version update
mmv08 8ac4640
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 4042a6a
point sdk to a newer commit
mmv08 d1d4f85
Update iframe message handler
mmv08 07e1f1a
ConfirmTransactionModal tweaks to support params
mmv08 ab4ff03
handle sendTransactionsWithParams, display safeTxGas in app tx modal
mmv08 a1c909d
new sdk version
mmv08 6b6d660
yarn lock update
mmv08 8fb1f35
install libudev in travis
mmv08 0107fa7
update sdk version
mmv08 f07eda4
Estimating safeTxGas for Safe Apps Txs WIP
mmv08 7271558
safetxgas estimation warning wip
mmv08 3774d7b
gas estimation in confirm transaction modal
mmv08 63b2dd5
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 14f9427
Merge branch 'development' into feature/21-allow-specifying-safetxgas
525d914
yarn lock update
mmv08 a8d6d5c
update sdk version
mmv08 2d1975c
Merge branch 'feature/21-allow-specifying-safetxgas' of github.com:gn…
mmv08 46af578
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 574021d
add handler for rpc calls
mmv08 85ed640
use send method
mmv08 1befce7
update sdk version
mmv08 b943876
dep bump
mmv08 e9e162c
wip
mmv08 b8f90c6
update sdk
mmv08 53946fc
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
mmv08 87d6eec
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 ec2e405
Merge branch 'feature/1480-handle-rpc-calls-from-apps-sdk' of github.…
mmv08 0e518cd
remove unused interface and console.log
mmv08 cb43d86
remove async, tweak check for send func
mmv08 7b92bac
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
mmv08 2e4bcd9
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
nicosampler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { | |
| safeNameSelector, | ||
| safeParamAddressFromStateSelector, | ||
| } from 'src/logic/safe/store/selectors' | ||
| import { web3ReadOnly } from 'src/logic/wallets/getWeb3' | ||
| import { SafeApp } from 'src/routes/safe/components/Apps/types.d' | ||
|
|
||
| type InterfaceMessageProps<T extends InterfaceMessageIds> = { | ||
|
|
@@ -38,10 +39,6 @@ interface CustomMessageEvent extends MessageEvent { | |
| } | ||
| } | ||
|
|
||
| interface InterfaceMessageRequest extends InterfaceMessageProps<InterfaceMessageIds> { | ||
| requestId: number | string | ||
| } | ||
|
|
||
| const NETWORK_NAME = getNetworkName() | ||
|
|
||
| const useIframeMessageHandler = ( | ||
|
|
@@ -75,7 +72,7 @@ const useIframeMessageHandler = ( | |
| messageId: SDKMessageIds, | ||
| messagePayload: SDKMessageToPayload[typeof messageId], | ||
| requestId: RequestId, | ||
| ) => { | ||
| ): void => { | ||
| if (!messageId) { | ||
| console.error('ThirdPartyApp: A message was received without message id.') | ||
| return | ||
|
|
@@ -104,6 +101,36 @@ const useIframeMessageHandler = ( | |
| break | ||
| } | ||
|
|
||
| case SDK_MESSAGES.RPC_CALL: { | ||
| const payload = messagePayload as SDKMessageToPayload['RPC_CALL'] | ||
|
|
||
| if ( | ||
| web3ReadOnly.currentProvider !== null && | ||
| typeof web3ReadOnly.currentProvider !== 'string' && | ||
| 'send' in web3ReadOnly.currentProvider | ||
| ) { | ||
| web3ReadOnly.currentProvider?.send?.( | ||
| { | ||
| jsonrpc: '2.0', | ||
| method: payload?.call, | ||
| params: payload?.params, | ||
| id: '1', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity, why won't it generate a conflict? shouldn't we make it somehow dynamic?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| }, | ||
| (err, res) => { | ||
| if (!err) { | ||
| const rpcCallMsg = { | ||
| messageId: INTERFACE_MESSAGES.RPC_CALL_RESPONSE, | ||
| data: res, | ||
| } | ||
|
|
||
| sendMessageToIframe(rpcCallMsg, requestId) | ||
| } | ||
| }, | ||
| ) | ||
| } | ||
| break | ||
| } | ||
|
|
||
| case SDK_MESSAGES.SAFE_APP_SDK_INITIALIZED: { | ||
| const safeInfoMessage = { | ||
| messageId: INTERFACE_MESSAGES.ON_SAFE_INFO, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.