* sdk version update * point sdk to a newer commit * Update iframe message handler * ConfirmTransactionModal tweaks to support params * handle sendTransactionsWithParams, display safeTxGas in app tx modal * new sdk version * yarn lock update * install libudev in travis * update sdk version * Estimating safeTxGas for Safe Apps Txs WIP * safetxgas estimation warning wip * gas estimation in confirm transaction modal * yarn lock update * update sdk version * add handler for rpc calls * use send method * update sdk version * dep bump * wip * update sdk * remove unused interface and console.log * remove async, tweak check for send func Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm> Co-authored-by: nicolas <nicosampler@users.noreply.github.com>
This commit is contained in:
parent
5f3a9ef1a9
commit
1c53167a9a
|
@ -163,7 +163,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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-contracts": "1.1.1-dev.2",
|
||||||
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#70e57bdd1e0fd5dfdf5768076577c1e000b5fe28",
|
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#70e57bdd1e0fd5dfdf5768076577c1e000b5fe28",
|
||||||
"@gnosis.pm/util-contracts": "2.0.6",
|
"@gnosis.pm/util-contracts": "2.0.6",
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
safeNameSelector,
|
safeNameSelector,
|
||||||
safeParamAddressFromStateSelector,
|
safeParamAddressFromStateSelector,
|
||||||
} from 'src/logic/safe/store/selectors'
|
} from 'src/logic/safe/store/selectors'
|
||||||
|
import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
|
||||||
import { SafeApp } from 'src/routes/safe/components/Apps/types.d'
|
import { SafeApp } from 'src/routes/safe/components/Apps/types.d'
|
||||||
|
|
||||||
type InterfaceMessageProps<T extends InterfaceMessageIds> = {
|
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 NETWORK_NAME = getNetworkName()
|
||||||
|
|
||||||
const useIframeMessageHandler = (
|
const useIframeMessageHandler = (
|
||||||
|
@ -75,7 +72,7 @@ const useIframeMessageHandler = (
|
||||||
messageId: SDKMessageIds,
|
messageId: SDKMessageIds,
|
||||||
messagePayload: SDKMessageToPayload[typeof messageId],
|
messagePayload: SDKMessageToPayload[typeof messageId],
|
||||||
requestId: RequestId,
|
requestId: RequestId,
|
||||||
) => {
|
): void => {
|
||||||
if (!messageId) {
|
if (!messageId) {
|
||||||
console.error('ThirdPartyApp: A message was received without message id.')
|
console.error('ThirdPartyApp: A message was received without message id.')
|
||||||
return
|
return
|
||||||
|
@ -104,6 +101,36 @@ const useIframeMessageHandler = (
|
||||||
break
|
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',
|
||||||
|
},
|
||||||
|
(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: {
|
case SDK_MESSAGES.SAFE_APP_SDK_INITIALIZED: {
|
||||||
const safeInfoMessage = {
|
const safeInfoMessage = {
|
||||||
messageId: INTERFACE_MESSAGES.ON_SAFE_INFO,
|
messageId: INTERFACE_MESSAGES.ON_SAFE_INFO,
|
||||||
|
|
Loading…
Reference in New Issue