Skip to content

Commit

Permalink
fix linea service url
Browse files Browse the repository at this point in the history
  • Loading branch information
clemsos committed Mar 20, 2024
1 parent 209f8c0 commit 8ab2ea9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
35 changes: 22 additions & 13 deletions governance/helpers/multisig.js
Expand Up @@ -5,6 +5,14 @@ const multisigABI = require('@unlock-protocol/hardhat-helpers/dist/ABIs/multisig
const multisigOldABI = require('@unlock-protocol/hardhat-helpers/dist/ABIs/multisig.json')
const SafeApiKit = require('@safe-global/api-kit').default

// custom services URL for network not supported by Safe
const safeServiceURLs = {
324: 'https://safe-transaction-zksync.safe.global/api',
1101: 'https://safe-transaction-zkevm.safe.global/api',
534352: 'https://transaction.safe.scroll.xyz/api',
59144: 'https://transaction.safe.linea.build/api',
}

const prodSigners = [
'0x9d3ea9e9adde71141f4534dB3b9B80dF3D03Ee5f', // cc
'0x4Ce2DD8373ECe0d7baAA16E559A5817CC875b16a', // jg
Expand All @@ -29,16 +37,24 @@ const getExpectedSigners = async (chainId) => {
const logError = (name, chainId, multisig, msg) =>
console.log(`[${name} (${chainId})]: ${multisig} ${msg}`)

const getSafeService = async (chainId) => {
const txServiceUrl = safeServiceURLs[chainId] || null
console.log(`Using Safe Global service at ${txServiceUrl} - chain ${chainId}`)

const safeService = new SafeApiKit({
chainId,
txServiceUrl,
})

return safeService
}

const getMultiSigInfo = async (chainId, multisig) => {
const errors = []
const { isTestNetwork } = networks[chainId]
const expectedSigners = isTestNetwork ? devSigners : prodSigners
const provider = await getProvider(chainId)
// get Safe service
const safeService = new SafeApiKit({
chainId,
txServiceUrl: safeServiceURLs[chainId] || null,
})
const safeService = await getSafeService(chainId)

const { count } = await safeService.getPendingTransactions(multisig)
if (count) {
Expand Down Expand Up @@ -94,14 +110,6 @@ const getProvider = async (chainId) => {
return { provider, chainId }
}

// custom services URL for network not supported by Safe
const safeServiceURLs = {
324: 'https://safe-transaction-zksync.safe.global/api',
1101: 'https://safe-transaction-zkevm.safe.global/api',
534352: 'https://transaction.safe.scroll.xyz/api',
59144: 'https://transaction.safe.linea.build/api',
}

// get safeAddress directly from unlock if needed
const getSafeAddress = async (chainId) => {
const { multisig } = networks[chainId]
Expand Down Expand Up @@ -190,4 +198,5 @@ module.exports = {
getMultiSigInfo,
getExpectedSigners,
logError,
getSafeService,
}
13 changes: 3 additions & 10 deletions governance/scripts/multisig/submitTx.js
Expand Up @@ -4,16 +4,15 @@ const {
getSafeVersion,
submitTxOldMultisig,
confirmMultisigTx,
safeServiceURLs,
getSafeService,
} = require('../../helpers/multisig')
const { ADDRESS_ZERO, getNetwork } = require('@unlock-protocol/hardhat-helpers')

const { EthersAdapter } = require('@safe-global/protocol-kit')
const Safe = require('@safe-global/protocol-kit').default
const SafeApiKit = require('@safe-global/api-kit').default

async function main({ safeAddress, tx, signer }) {
const { chainId, id } = await getNetwork()
const { id: chainId } = await getNetwork()
if (!safeAddress) {
safeAddress = getSafeAddress(chainId)
}
Expand Down Expand Up @@ -41,13 +40,7 @@ async function main({ safeAddress, tx, signer }) {
})

// get Safe service URL if not default
const txServiceUrl = safeServiceURLs[id]
console.log(`Using Safe Global service at ${txServiceUrl} - chain ${id}`)

const safeService = new SafeApiKit({
chainId: id,
txServiceUrl: txServiceUrl || null,
})
const safeService = await getSafeService(chainId)

// create tx
const safeSdk = await Safe.create({ ethAdapter, safeAddress })
Expand Down

0 comments on commit 8ab2ea9

Please sign in to comment.