Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mortimr committed Apr 10, 2024
1 parent e5dc7c6 commit a2d99b9
Show file tree
Hide file tree
Showing 11 changed files with 1,856 additions and 875 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"dependencies": {
"@ethersproject/hardware-wallets": "5.7.0",
"@fireblocks/fireblocks-web3-provider": "^1.2.3",
"@safe-global/api-kit": "1.3.0",
"@safe-global/protocol-kit": "1.2.0",
"@ledgerhq/hw-transport-node-hid": "^6.28.3",
"@safe-global/api-kit": "2.3.0",
"@safe-global/protocol-kit": "3.0.2",
"@slack/rtm-api": "^6.1.1",
"@slack/web-api": "^6.9.0",
"@types/node": "18.15.11",
Expand All @@ -20,7 +21,7 @@
"axios": "1.4.0",
"color": "^4.2.3",
"commander": "11.0.0",
"ethers": "5.7.2",
"ethers": "6.11.1",
"git-diff": "2.0.6",
"lokijs": "^1.5.12",
"nice-color-palettes": "^3.0.0",
Expand All @@ -43,4 +44,4 @@
"prettier": "2.8.7",
"prettier-plugin-organize-imports": "3.2.2"
}
}
}
18 changes: 2 additions & 16 deletions src/commands/addDelegate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChainId, FireblocksWeb3Provider } from '@fireblocks/fireblocks-web3-provider';
import { EthereumProvider } from '@walletconnect/ethereum-provider';
import { Command } from 'commander';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -27,7 +26,7 @@ export default function loadCommand(command: Command): void {
if (!options.ledger && !options.pk && !options.walletconnect && !options.fireblocksPrivateKeyPath) {
throw new Error(`Missing ledger or pk`);
}
const provider = new ethers.providers.JsonRpcProvider(options.rpc);
const provider = new ethers.JsonRpcProvider(options.rpc);
let signer;
if (options.walletconnect) {
const provider = await EthereumProvider.init({
Expand All @@ -46,20 +45,7 @@ export default function loadCommand(command: Command): void {
console.log(`uri: "${uri}"`);
});
await provider.connect();
signer = new ethers.providers.Web3Provider(provider).getSigner();
} else if (
options.fireblocksPrivateKeyPath &&
options.fireblocksApiKey &&
options.fireblocksVaultAccountIds
) {
signer = new ethers.providers.Web3Provider(
new FireblocksWeb3Provider({
privateKey: options.fireblocksPrivateKeyPath,
apiKey: options.fireblocksApiKey,
vaultAccountIds: options.fireblocksVaultAccountIds,
chainId: ChainId.MAINNET
})
).getSigner();
signer = provider.signer;
} else if (options.ledger) {
signer = new LedgerSigner(provider, 'hid', options.ledger);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/commands/sync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, Option } from 'commander';
import { ethers, utils } from 'ethers';
import { ethers, getAddress } from 'ethers';
import { existsSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from 'fs';
import { relative, resolve } from 'path';
import { promisify } from 'util';
Expand Down Expand Up @@ -56,15 +56,15 @@ export default function loadCommand(command: Command): void {
console.log();
const shouldUpload = options.upload;
const shouldWrite = !options.dryRun;
const provider = new ethers.providers.JsonRpcProvider(options.rpc);
const provider = new ethers.JsonRpcProvider(options.rpc);
const signers: { [key: string]: ethers.Signer } = {};
let loaded = false;
let pkIdx = 0;
for (const pk of pks) {
try {
loaded = true;
const signer = new ethers.Wallet(pk, provider);
signers[utils.getAddress(signer.address)] = signer;
signers[getAddress(signer.address)] = signer;
console.log(` loaded signer for ${await signer.address}`);
pkIdx += 1;
} catch (e) {
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function loadCommand(command: Command): void {
shouldUpload,
shouldWrite,
network: state.config.network,
network_id: chainId,
network_id: Number(chainId),
state
};

Expand Down Expand Up @@ -143,7 +143,7 @@ export default function loadCommand(command: Command): void {
writeFileSync('COMMIT_MSG', COMMIT_MSG, { encoding: 'utf8' });
if (process.env.CI === 'true') {
await exec(`echo "hasChanges=true" >> $GITHUB_OUTPUT`);
console.log('writting "hasChanged=true" ci output variable');
console.log('writing "hasChanged=true" ci output variable');
}
} else if (existsSync('COMMIT_MSG')) {
unlinkSync('COMMIT_MSG');
Expand All @@ -166,14 +166,14 @@ export default function loadCommand(command: Command): void {
}
writeFileSync('PR_COMMENT', content, { encoding: 'utf8' });
await exec(`echo "hasPrComment=true" >> $GITHUB_OUTPUT`);
console.log('writting "hasPrComment=true" ci output variable');
console.log('writing "hasPrComment=true" ci output variable');
}
}
}

if (error > 0) {
await exec(`echo "hasFailedProposals=true" >> $GITHUB_OUTPUT`);
console.log('writting "hasFailedProposals=true" ci output variable');
console.log('writing "hasFailedProposals=true" ci output variable');
}
});
}
Expand Down Expand Up @@ -257,7 +257,7 @@ ${YAML.stringify(manifest.safe_estimation, { lineWidth: 0 })}
`;
} else {
return `
# ${title}
### \`${path}\`
Expand Down
47 changes: 28 additions & 19 deletions src/docs/generatedRootReadme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { utils } from 'ethers';
import { formatEther, getAddress } from 'ethers';
import { existsSync, readFileSync } from 'fs';
import YAML from 'yaml';
import { EOA, PopulatedSafe, Proposal, SafeCDKit, Transaction } from '../types';
Expand Down Expand Up @@ -176,11 +176,11 @@ ${formatSafeTransactions(scdk, safe, txs)}
}

function getTxTitle(tx: Transaction): string {
if (utils.getAddress(tx.safe) === utils.getAddress(tx.to) && tx.data === null) {
if (getAddress(tx.safe) === getAddress(tx.to) && tx.data === null) {
if (tx.value === '0') {
return 'Transaction rejection';
}
return `Ether transfer of ${utils.formatEther(tx.value)} ETH`;
return `Ether transfer of ${formatEther(tx.value)} ETH`;
}
if (tx.dataDecoded?.method) {
return `\`\`\`solidity
Expand Down Expand Up @@ -211,10 +211,13 @@ function formatOwnerLeaderboard(scdk: SafeCDKit, safe: PopulatedSafe): string {
ownerScores[(tx.executor as string).toLowerCase()] =
(ownerScores[(tx.executor as string).toLowerCase()] || 0) + 1;
}
for (const confirmation of tx.confirmations) {
ownerSignatures[confirmation.owner.toLowerCase()] =
(ownerSignatures[confirmation.owner.toLowerCase()] || 0) + 1;
ownerScores[confirmation.owner.toLowerCase()] = (ownerScores[confirmation.owner.toLowerCase()] || 0) + 1;
if (tx.confirmations) {
for (const confirmation of tx.confirmations) {
ownerSignatures[confirmation.owner.toLowerCase()] =
(ownerSignatures[confirmation.owner.toLowerCase()] || 0) + 1;
ownerScores[confirmation.owner.toLowerCase()] =
(ownerScores[confirmation.owner.toLowerCase()] || 0) + 1;
}
}
}
const owners = Object.keys(ownerScores)
Expand Down Expand Up @@ -290,7 +293,11 @@ ${YAML.stringify(tx, { lineWidth: 0 })}
${proposal ? resolveChildProposals(scdk, proposal, 1) : ''}
</td>
</td>
${tx.isExecuted ? '' : `<td>${getConfirmationIcons(tx.confirmations.length, safe.threshold)}</td>`}
${
tx.isExecuted
? ''
: `<td>${getConfirmationIcons(tx.confirmations ? tx.confirmations.length : 0, safe.threshold)}</td>`
}
<td>${resolveConfirmations(scdk, tx)}</td>
${tx.isExecuted ? `<td>${resolveExecutor(scdk, tx)}</td>` : ''}
${tx.isExecuted ? `<td><a target="_blank" href="${getTxExplorerLink(scdk, tx)}">🔗</a></td>` : ''}
Expand Down Expand Up @@ -328,8 +335,10 @@ function resolveExecutor(scdk: SafeCDKit, tx: Transaction): string {

function resolveConfirmations(scdk: SafeCDKit, tx: Transaction): string {
let content = [];
for (const confirmation of tx.confirmations) {
content.push(getNameAndType(scdk, confirmation.owner));
if (tx.confirmations) {
for (const confirmation of tx.confirmations) {
content.push(getNameAndType(scdk, confirmation.owner));
}
}
return content.join('<br/>');
}
Expand Down Expand Up @@ -357,30 +366,30 @@ function getNameAndType(scdk: SafeCDKit, address: string): string {
namingMap = {};
for (let eoaIdx = 0; eoaIdx < scdk.state.eoas.length; ++eoaIdx) {
const loadedEOA: EOA = scdk.state.eoas[eoaIdx].entity as EOA;
namingMap[utils.getAddress(loadedEOA.address)] = `<code><a href="${getAddressExplorerLink(
namingMap[getAddress(loadedEOA.address)] = `<code><a href="${getAddressExplorerLink(
scdk,
loadedEOA.address
)}" target="_blank">eoa@${loadedEOA.name}</a></code>`;
}

for (let safeIdx = 0; safeIdx < scdk.state.safes.length; ++safeIdx) {
const safe: PopulatedSafe = scdk.state.safes[safeIdx].entity as PopulatedSafe;
namingMap[utils.getAddress(safe.address)] = `<code><a href="${getAddressExplorerLink(
namingMap[getAddress(safe.address)] = `<code><a href="${getAddressExplorerLink(
scdk,
safe.address
)}" target="_blank">safe@${safe.name}</a></code>`;
}
}

if (namingMap[utils.getAddress(address)]) {
return namingMap[utils.getAddress(address)];
if (namingMap[getAddress(address)]) {
return namingMap[getAddress(address)];
}

return `<code><a href="${getAddressExplorerLink(scdk, address)}" target="_blank">${address}</a></code>`;
}

function getAllSafeTransactions(scdk: SafeCDKit, safe: PopulatedSafe): Transaction[] {
const txIds = scdk.state.transactionBySafe[utils.getAddress(safe.address)];
const txIds = scdk.state.transactionBySafe[getAddress(safe.address)];
if (!txIds) {
return [];
}
Expand Down Expand Up @@ -412,15 +421,15 @@ function getScore(color: string): number {
const Color = require('color');

function lightAndDark(address: string): [string, string] {
const index = parseInt(utils.getAddress(address).slice(2, 8), 16);
const index = parseInt(getAddress(address).slice(2, 8), 16);
const palette = colors[index % colors.length];
let lightest = Color(palette[index % palette.length]).lightness(10);
let darkest = Color(palette[index % palette.length]);
while (Math.abs(getScore(lightest.hex()) - getScore(darkest.hex())) < 200) {
lightest = lightest.lighten(0.01);
darkest = darkest.darken(0.01);
}
if (parseInt(utils.getAddress(address).slice(8, 10), 16) % 2 == 0) {
if (parseInt(getAddress(address).slice(8, 10), 16) % 2 == 0) {
return [lightest.hex(), darkest.hex()];
}
return [darkest.hex(), lightest.hex()];
Expand Down Expand Up @@ -488,13 +497,13 @@ function generateSafeDiagram(
function getNames(scdk: SafeCDKit, address: string): string[] {
let names = [];
for (const eoa of scdk.state.eoas) {
if (utils.getAddress(eoa.entity.address) === utils.getAddress(address)) {
if (getAddress(eoa.entity.address) === getAddress(address)) {
names.push(eoa.entity.name);
}
}

for (const safeConfig of scdk.state.safes) {
if (utils.getAddress(safeConfig.entity.address) === utils.getAddress(address)) {
if (getAddress(safeConfig.entity.address) === getAddress(address)) {
names.push(safeConfig.entity.name);
}
}
Expand Down
Loading

0 comments on commit a2d99b9

Please sign in to comment.