Skip to content

Commit

Permalink
fix: empty tx array results in failed gnosis safe http call
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Goulding <[email protected]>
  • Loading branch information
ryandgoulding committed Nov 28, 2023
1 parent baf0e15 commit ed2ada8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@layerzerolabs/ua-utils",
"version": "0.0.21",
"version": "0.0.23",
"repository": "https://github.com/LayerZero-Labs/ua-utils.git",
"license": "MIT",
"main": "dist/index.js",
Expand Down
28 changes: 16 additions & 12 deletions src/utils/crossChainHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,23 @@ export const executeGnosisTransactions = async (hre: any, network: string, gnosi
signerOrProvider: signer,
});

const safeSdk: Safe = await Safe.create({ ethAdapter, safeAddress, ...(!!contractNetworks && contractNetworks)});
const safeSdk: Safe = await Safe.create({ ethAdapter, safeAddress, ...(!!contractNetworks && { contractNetworks })});
const gnosisTransactions = transactions.map((tx) => ({ to: tx.contractAddress, data: tx.calldata!, value: "0" }));
const nonce = await safeService.getNextNonce(safeAddress);
const safeTransaction = await safeSdk.createTransaction(gnosisTransactions, { nonce });

await safeSdk.signTransaction(safeTransaction);
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
await safeService.proposeTransaction({
safeAddress,
safeTransaction,
safeTxHash,
senderAddress: signer.address,
});
if (gnosisTransactions.length > 0) {
const nonce = await safeService.getNextNonce(safeAddress);
const safeTransaction = await safeSdk.createTransaction(gnosisTransactions, { nonce });

await safeSdk.signTransaction(safeTransaction);
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
await safeService.proposeTransaction({
safeAddress,
safeTransaction,
safeTxHash,
senderAddress: signer.address,
});
} else {
console.log(`No transactions to submit for ${network}`);
}
}

export const getDeploymentAddresses = (network: string, throwIfMissing: boolean = true): any => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type SafeConfig = {
* Contract addresses for each network.
*/
type ContractNetworks = {
[chainListId: number]: {
[chainListId: string]: {
multiSendAddress: string
safeMasterCopyAddress: string
safeProxyFactoryAddress: string
Expand Down

0 comments on commit ed2ada8

Please sign in to comment.