Skip to content

Commit

Permalink
Fix error to only take incomings into account for mutualConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
juanenrisley committed Sep 5, 2023
1 parent cfdbf35 commit 84734af
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ export default function createTrustModule(web3, contracts, utils) {
{},
);

// Select mutual connections between safe trusts and trusts of safe trusts
safe.incoming.forEach(({ userAddress, user }) => {
const checksumSafeAddress =
web3.utils.toChecksumAddress(userAddress);

if (user) {
network[checksumSafeAddress].mutualConnections.push(
...user.incoming.reduce((acc, curr) => {
const target = web3.utils.toChecksumAddress(
curr.userAddress,
);

return curr.userAddress !== userAddress && target
? [...acc, target]
: acc;
}),
);
}
});

// Add to network safes that trust us
safe.outgoing.forEach(({ limitPercentage, canSendToAddress }) => {
const checksumSafeAddress =
Expand All @@ -139,26 +159,6 @@ export default function createTrustModule(web3, contracts, utils) {
);
});

// Select mutual connections between safe trusts and trusts of safe trusts
safe.incoming.forEach(({ userAddress, user }) => {
const checksumSafeAddress =
web3.utils.toChecksumAddress(userAddress);

if (user) {
network[checksumSafeAddress].mutualConnections.push(
...user.incoming.reduce((acc, curr) => {
const target = web3.utils.toChecksumAddress(
curr.userAddress,
);

return curr.userAddress !== userAddress && target
? [...acc, target]
: acc;
}),
);
}
});

result = Object.values(network);
}

Expand Down

0 comments on commit 84734af

Please sign in to comment.