Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c43ff06
sdk version update
mmv08 Oct 5, 2020
8ac4640
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 Oct 6, 2020
4042a6a
point sdk to a newer commit
mmv08 Oct 6, 2020
d1d4f85
Update iframe message handler
mmv08 Oct 6, 2020
07e1f1a
ConfirmTransactionModal tweaks to support params
mmv08 Oct 6, 2020
ab4ff03
handle sendTransactionsWithParams, display safeTxGas in app tx modal
mmv08 Oct 7, 2020
a1c909d
new sdk version
mmv08 Oct 7, 2020
6b6d660
yarn lock update
mmv08 Oct 7, 2020
8fb1f35
install libudev in travis
mmv08 Oct 7, 2020
0107fa7
update sdk version
mmv08 Oct 8, 2020
f07eda4
Estimating safeTxGas for Safe Apps Txs WIP
mmv08 Oct 8, 2020
7271558
safetxgas estimation warning wip
mmv08 Oct 9, 2020
3774d7b
gas estimation in confirm transaction modal
mmv08 Oct 9, 2020
63b2dd5
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 Oct 9, 2020
14f9427
Merge branch 'development' into feature/21-allow-specifying-safetxgas
Oct 14, 2020
525d914
yarn lock update
mmv08 Oct 15, 2020
a8d6d5c
update sdk version
mmv08 Oct 15, 2020
2d1975c
Merge branch 'feature/21-allow-specifying-safetxgas' of github.com:gn…
mmv08 Oct 15, 2020
46af578
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 Oct 19, 2020
574021d
add handler for rpc calls
mmv08 Oct 19, 2020
85ed640
use send method
mmv08 Oct 20, 2020
1befce7
update sdk version
mmv08 Oct 20, 2020
b943876
dep bump
mmv08 Oct 21, 2020
e9e162c
wip
mmv08 Oct 21, 2020
b8f90c6
update sdk
mmv08 Oct 22, 2020
53946fc
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
mmv08 Oct 22, 2020
87d6eec
Merge branch 'development' of github.com:gnosis/safe-react into featu…
mmv08 Oct 22, 2020
ec2e405
Merge branch 'feature/1480-handle-rpc-calls-from-apps-sdk' of github.…
mmv08 Oct 22, 2020
0e518cd
remove unused interface and console.log
mmv08 Oct 22, 2020
cb43d86
remove async, tweak check for send func
mmv08 Oct 23, 2020
7b92bac
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
mmv08 Oct 23, 2020
2e4bcd9
Merge branch 'development' into feature/1480-handle-rpc-calls-from-ap…
nicosampler Oct 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
]
},
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "https://github.com/gnosis/safe-apps-sdk#a6c168b",
"@gnosis.pm/safe-apps-sdk": "https://github.com/gnosis/safe-apps-sdk.git#3f0689f",
"@gnosis.pm/safe-contracts": "1.1.1-dev.2",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#70e57bdd1e0fd5dfdf5768076577c1e000b5fe28",
"@gnosis.pm/util-contracts": "2.0.6",
Expand Down
37 changes: 32 additions & 5 deletions src/routes/safe/components/Apps/hooks/useIframeMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> = {
Expand All @@ -38,10 +39,6 @@ interface CustomMessageEvent extends MessageEvent {
}
}

interface InterfaceMessageRequest extends InterfaceMessageProps<InterfaceMessageIds> {
requestId: number | string
}

const NETWORK_NAME = getNetworkName()

const useIframeMessageHandler = (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id is required to be defined by json rpc specification, but our callback is already mapped to a request, so I don’t think it will cause any conflict. Let’s ask @rmeissner if he could confirm it

},
(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,
Expand Down
Loading