Skip to content

Commit

Permalink
Merge pull request #100 from gnosisguild/connection-fixes
Browse files Browse the repository at this point in the history
Fix Balancer connection issues
  • Loading branch information
jfschwarz authored Apr 11, 2024
2 parents 8735c65 + d61189c commit 20ccd59
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extension/src/bridge/InjectedProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class InjectedProvider extends EventEmitter {
}
}

'isZodiac Pilot' = true
isZodiacPilot = true

// This is required for connecting to Etherscan
enable = () => {
Expand Down
31 changes: 26 additions & 5 deletions extension/src/bridge/SafeAppBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getBalances,
getSafeInfo,
getTransactionDetails,

Check warning on line 22 in extension/src/bridge/SafeAppBridge.ts

View workflow job for this annotation

GitHub Actions / tests

'getTransactionDetails' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 22 in extension/src/bridge/SafeAppBridge.ts

View workflow job for this annotation

GitHub Actions / tests

'getTransactionDetails' is defined but never used. Allowed unused vars must match /^_/u
TransactionDetails,
} from '@safe-global/safe-gateway-typescript-sdk'
import { ChainId, CHAIN_CURRENCY, CHAIN_NAME, CHAIN_PREFIX } from '../chains'
import { Connection, Eip1193Provider } from '../types'
Expand All @@ -43,6 +44,7 @@ export const SAFE_APP_WHITELIST = [
'https://testnet.snapshot.org',
'https://swap.cow.fi',
'https://www.drips.network',
'https://app.balancer.fi',
]

export default class SafeAppBridge {
Expand Down Expand Up @@ -112,7 +114,11 @@ export default class SafeAppBridge {
throw new Error('No response returned from handler')
}
} catch (e) {
console.error('Error handling message via SafeAppCommunicator', e)
console.error(
'Error handling message via SafeAppCommunicator',
msg.data,
e
)
this.postResponse(msg.source, getErrorMessage(e), msg.data.id, true)
}
}
Expand All @@ -137,10 +143,25 @@ export default class SafeAppBridge {

handlers: { [method in Methods]: MessageHandler } = {
[Methods.getTxBySafeTxHash]: ({ safeTxHash }: GetTxBySafeTxHashParams) => {
return getTransactionDetails(
CHAIN_PREFIX[this.connection.chainId],
safeTxHash
)
// mock Safe Gateway's getTransactionDetails() response
const safeAddress = getAddress(this.connection.avatarAddress)
return {
txHash: safeTxHash,
safeAddress,
txId: `multisig_${safeAddress}_${safeTxHash}`,
executedAt: new Date().getTime(),
txStatus: 'SUCCESS',
// TODO we might have to retrieve the actual transaction details from reducer state
txInfo: {
type: 'Custom',
to: {
value: '0x0000000000000000000000000000000000000000',
},
dataSize: '0',
value: '0',
isCancellation: false,
},
} as TransactionDetails
},

[Methods.getEnvironmentInfo]: () => ({
Expand Down

0 comments on commit 20ccd59

Please sign in to comment.