Skip to content

Commit

Permalink
update yarnlock
Browse files Browse the repository at this point in the history
  • Loading branch information
iainnash committed Dec 14, 2023
1 parent a5ca784 commit 47f70db
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 45 deletions.
38 changes: 22 additions & 16 deletions packages/protocol-deployments/script/copy-deployed-contracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { writeFile, readFile } from "fs/promises";
import esMain from "es-main";
// @ts-ignore
import { glob } from "glob";

type Deploy = {
Expand All @@ -12,35 +13,40 @@ async function copyEnvironmentRunFiles() {
const latestFiles = await glob(`broadcast/**/*run-latest.json`);

const allFileContents = await Promise.all(
latestFiles.map(async (file) => {
latestFiles.map(async (file: string) => {
const fileParts = file.split("/");
const chainId = fileParts[fileParts.length - 2];
return {
chainId,
contents: JSON.parse(await readFile(file, "utf-8")) as Deploy,
};
})
}),
);

const groupedByChainId = allFileContents.reduce((acc, file) => {
const chainId = file.chainId!;
if (isNaN(Number(chainId))) return acc;
const groupedByChainId = allFileContents.reduce(
(acc: any, file: { chainId: string; contents: any }) => {
const chainId = file.chainId!;
if (isNaN(Number(chainId))) return acc;

if (!acc[chainId]) {
acc[chainId] = [];
}
acc[chainId]!.push(file.contents);
return acc;
}, {} as Record<string, Deploy[]>);
if (!acc[chainId]) {
acc[chainId] = [];
}
acc[chainId]!.push(file.contents);
return acc;
},
{} as Record<string, Deploy[]>,
);

const withLatest = Object.entries(groupedByChainId).map(
([chainId, files]) => {
const latest = files.sort((a, b) => b.timestamp! - a.timestamp!)[0];
([chainId, files]: any) => {
const latest = files.sort(
(a: any, b: any) => b.timestamp! - a.timestamp!,
)[0];
return {
chainId,
latest,
};
}
},
);

withLatest.forEach(async ({ chainId, latest }) => {
Expand All @@ -55,8 +61,8 @@ async function copyEnvironmentRunFiles() {
commit: latest!.commit,
},
null,
2
)
2,
),
);
});
}
Expand Down
53 changes: 30 additions & 23 deletions packages/protocol-deployments/script/signDeploymentTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createAccount } from "@turnkey/viem";
import { TurnkeyClient } from "@turnkey/http";
import { Address, encodeFunctionData, parseAbi, LocalAccount, Hex } from "viem";
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
// @ts-ignore
import { glob } from "glob";
import * as path from "path";
import * as dotenv from "dotenv";
Expand Down Expand Up @@ -39,11 +40,11 @@ async function signAndSaveSignatures({
}) {
const configFolder = path.resolve(
__dirname,
`../deterministicConfig/${proxyName}/`
`../deterministicConfig/${proxyName}/`,
);
const configFile = path.join(configFolder, "params.json");
const deterministicDeployConfig = JSON.parse(
await readFile(configFile, "utf-8")
await readFile(configFile, "utf-8"),
);

const deploymentConfig: DeterministicDeploymentConfig = {
Expand All @@ -66,19 +67,22 @@ async function signAndSaveSignatures({
deterministicDeploymentConfig: deploymentConfig,
}),
};
})
}),
);

// aggregate above to object of key value pair indexed by chain id as number:
const byChainId = signedConfigs.reduce((acc, { chainId, signature }) => {
acc[chainId] = signature;
return acc;
}, {} as { [key: number]: string });
const byChainId = signedConfigs.reduce(
(acc, { chainId, signature }) => {
acc[chainId] = signature;
return acc;
},
{} as { [key: number]: string },
);

// write as json to ../deterministicConfig/factoryDeploySignatures.json:
await writeFile(
path.join(configFolder, "signatures.json"),
JSON.stringify(byChainId, null, 2)
JSON.stringify(byChainId, null, 2),
);
}

Expand All @@ -96,11 +100,11 @@ async function signAndSaveUpgradeGate({
}) {
const configFolder = path.resolve(
__dirname,
`../deterministicConfig/${proxyName}/`
`../deterministicConfig/${proxyName}/`,
);
const configFile = path.join(configFolder, "params.json");
const deterministicDeployConfig = JSON.parse(
await readFile(configFile, "utf-8")
await readFile(configFile, "utf-8"),
);

const deploymentConfig: GenericDeploymentConfiguration = {
Expand Down Expand Up @@ -135,25 +139,28 @@ async function signAndSaveUpgradeGate({
initCall,
}),
};
})
}),
);

// aggregate above to object of key value pair indexed by chain id as number:
const byChainId = signedConfigs.reduce((acc, { chainId, signature }) => {
acc[chainId] = signature;
return acc;
}, {} as { [key: number]: string });
const byChainId = signedConfigs.reduce(
(acc, { chainId, signature }) => {
acc[chainId] = signature;
return acc;
},
{} as { [key: number]: string },
);

// write as json to ../deterministicConfig/factoryDeploySignatures.json:
await writeFile(
path.join(configFolder, "signatures.json"),
JSON.stringify(byChainId, null, 2)
JSON.stringify(byChainId, null, 2),
);
}

const getChainConfigs = async () => {
const chainConfigsFiles = await glob(
path.resolve(__dirname, "../chainConfigs/*.json")
path.resolve(__dirname, "../chainConfigs/*.json"),
);

const chainConfigs = await Promise.all(
Expand All @@ -167,15 +174,15 @@ const getChainConfigs = async () => {
chainId,
owner: fileContents["FACTORY_OWNER"]! as Address,
};
})
}),
);

return chainConfigs;
};

const getFactoryImplConfigs = async () => {
const addresseFiles = await glob(
path.resolve(__dirname, "../addresses/*.json")
path.resolve(__dirname, "../addresses/*.json"),
);

const chainConfigs = await Promise.all(
Expand All @@ -195,15 +202,15 @@ const getFactoryImplConfigs = async () => {
implementationAddress: fileContents["FACTORY_IMPL"] as Address,
owner: chainConfig["FACTORY_OWNER"] as Address,
};
})
}),
);

return chainConfigs;
};

const getPreminterImplConfigs = async () => {
const addresseFiles = await glob(
path.resolve(__dirname, "../addresses/*.json")
path.resolve(__dirname, "../addresses/*.json"),
);

const chainConfigs = await Promise.all(
Expand All @@ -223,7 +230,7 @@ const getPreminterImplConfigs = async () => {
implementationAddress: fileContents["PREMINTER_IMPL"] as Address,
owner: chainConfig["FACTORY_OWNER"] as Address,
};
})
}),
);

return chainConfigs.filter((x) => x.implementationAddress !== undefined);
Expand All @@ -240,7 +247,7 @@ async function main() {
new ApiKeyStamper({
apiPublicKey: process.env.TURNKEY_API_PUBLIC_KEY!,
apiPrivateKey: process.env.TURNKEY_API_PRIVATE_KEY!,
})
}),
);

// Create the Viem custom account
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-deployments/wagmi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getAddresses = () => {

for (const addressesFile of addressesFiles) {
const jsonAddress = JSON.parse(
readFileSync(`./addresses/${addressesFile}`, "utf-8")
readFileSync(`./addresses/${addressesFile}`, "utf-8"),
) as {
FIXED_PRICE_SALE_STRATEGY: Address;
MERKLE_MINT_SALE_STRATEGY: Address;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3237,16 +3237,16 @@ [email protected]:
semver "^7.3.8"
solidity-comments-extractor "^0.0.7"

[email protected], prettier@^2.7.1, prettier@^2.8.1:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

[email protected]:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==

prettier@^2.7.1, prettier@^2.8.1:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

pretty-format@^29.5.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
Expand Down

0 comments on commit 47f70db

Please sign in to comment.