Skip to content

Commit

Permalink
feat: switch back to using dryRun and util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osslgtm committed Nov 25, 2022
1 parent c752b6c commit 00c5ee4
Show file tree
Hide file tree
Showing 32 changed files with 113 additions and 59 deletions.
1 change: 0 additions & 1 deletion src/commands/deploy/document-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const handler = async (args: DeployDocumentStoreCommand): Promise<string
);
return documentStore.contractAddress;
} catch (e) {
console.log(e);
error(getErrorMessage(e));
}
};
6 changes: 3 additions & 3 deletions src/commands/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type WalletOrSignerOption = Partial<PrivateKeyOption> | Partial<AwsKmsSig

export interface GasOption {
maxPriorityFeePerGasScale: number;
feeData: boolean;
dryRun: boolean;
}

export type NetworkAndWalletSignerOption = NetworkOption & (Partial<WalletOption> | Partial<PrivateKeyOption>);
Expand All @@ -66,8 +66,8 @@ export const withGasPriceOption = (yargs: Argv): Argv =>
demandOption: false,
description: "Scale for estimated priority fees (maxPriorityFeePerGasScale * estimatedPriorityFeePerGas)",
})
.option("feeData", {
alias: "fee-data",
.option("dry-run", {
alias: "dr",
type: "boolean",
default: false,
description: "Provide estimated MaxFeePerGas and PriorityFeePerGas",
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/config/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const getTokenRegistryAddress = async (encryptedWalletPath: string): Prom
maxPriorityFeePerGasScale: 1,
registryName: "Token Registry",
registrySymbol: "TR",
feeData: false,
dryRun: false,
});
const { contractAddress } = tokenRegistry;
success(`Token registry deployed, address: ${highlight(contractAddress)}`);
Expand All @@ -105,7 +105,7 @@ export const getDocumentStoreAddress = async (encryptedWalletPath: string): Prom
const documentStore = await deployDocumentStore({
encryptedWalletPath,
network: "goerli",
feeData: false,
dryRun: false,
maxPriorityFeePerGasScale: 1,
storeName: "Document Store",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const deployParams: DeployDocumentStoreCommand = {
network: "goerli",
key: "0000000000000000000000000000000000000000000000000000000000000001",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("document-store", () => {
Expand All @@ -37,7 +37,7 @@ describe("document-store", () => {
await deployDocumentStore({
storeName: "Test",
network: "goerli",
feeData: false,
dryRun: false,
maxPriorityFeePerGasScale: 1,
});

Expand All @@ -50,7 +50,7 @@ describe("document-store", () => {
storeName: "Test",
network: "goerli",
keyFile: join(__dirname, "..", "..", "..", "..", "examples", "sample-key"),
feeData: false,
dryRun: false,
maxPriorityFeePerGasScale: 1,
});

Expand Down Expand Up @@ -80,7 +80,7 @@ describe("document-store", () => {
deployDocumentStore({
storeName: "Test",
network: "goerli",
feeData: false,
dryRun: false,
maxPriorityFeePerGasScale: 1,
})
).rejects.toThrow(
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/deploy/document-store/document-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const deployDocumentStore = async ({
storeName,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: DeployDocumentStoreCommand): Promise<TransactionReceipt> => {
if (feeData) {
if (dryRun) {
await dryRunMode({
transaction: new DocumentStoreFactory().getDeployTransaction(storeName),
network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const deployParams: DeployTokenRegistryCommand = {
network: "goerli",
key: "0000000000000000000000000000000000000000000000000000000000000001",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("token-registry", () => {
Expand Down Expand Up @@ -81,7 +81,7 @@ describe("token-registry", () => {
registrySymbol: "Tst",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
})
).rejects.toThrow(
"No private key found in OA_PRIVATE_KEY, key, key-file, please supply at least one or supply an encrypted wallet path, or provide aws kms signer information"
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/deploy/token-registry/token-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const deployTokenRegistry = async ({
deployerAddress,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: DeployTokenRegistryCommand): Promise<TransactionReceipt & { contractAddress: string }> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -45,7 +45,7 @@ export const deployTokenRegistry = async ({
deployer: await wallet.getAddress(),
});

if (feeData) {
if (dryRun) {
const estimatedGas: BigNumber = await factory.estimateGas.deploy(
deployContractAddress.tokenImplementation,
initParam
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/document-store/issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const deployParams: DocumentStoreIssueCommand = {
network: "goerli",
key: "0000000000000000000000000000000000000000000000000000000000000001",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

// TODO the following test is very fragile and might break on every interface change of DocumentStoreFactory
Expand Down Expand Up @@ -53,7 +53,7 @@ describe("document-store", () => {
address: "0x1234",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
});

const passedSigner: Wallet = mockedConnect.mock.calls[0][1];
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/document-store/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const issueToDocumentStore = async ({
hash,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: DocumentStoreIssueCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
if (feeData) {
if (dryRun) {
const documentStore = await DocumentStoreFactory.connect(address, wallet);
await dryRunMode({
estimatedGas: await documentStore.estimateGas.issue(hash),
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/document-store/revoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const deployParams: DocumentStoreRevokeCommand = {
network: "goerli",
key: "0000000000000000000000000000000000000000000000000000000000000001",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

// TODO the following test is very fragile and might break on every interface change of DocumentStoreFactory
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/document-store/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const revokeToDocumentStore = async ({
hash,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: DocumentStoreRevokeCommand): Promise<{ transactionHash: string }> => {
const wallet = await getWalletOrSigner({ network, ...rest });
if (feeData) {
if (dryRun) {
const documentStore = await DocumentStoreFactory.connect(address, wallet);
await dryRunMode({
estimatedGas: await documentStore.estimateGas.revoke(hash),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const deployParams: DocumentStoreTransferOwnershipCommand = {
network: "goerli",
key: "0000000000000000000000000000000000000000000000000000000000000001",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

// TODO the following test is very fragile and might break on every interface change of DocumentStoreFactory
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/document-store/transfer-ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const transferDocumentStoreOwnershipToWallet = async ({
newOwner,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: DocumentStoreTransferOwnershipCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
if (feeData) {
if (dryRun) {
const documentStore = await DocumentStoreFactory.connect(address, wallet);
await dryRunMode({
estimatedGas: await documentStore.estimateGas.transferOwnership(newOwner),
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/title-escrow/acceptSurrendered.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const acceptSurrenderedDocumentParams: TitleEscrowSurrenderDocumentCommand = {
tokenId: "0x12345",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/acceptSurrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const acceptSurrendered = async ({
tokenId,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowSurrenderDocumentCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -25,7 +25,7 @@ export const acceptSurrendered = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await tokenRegistryInstance.estimateGas.burn(tokenId),
network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const endorseNominatedBeneficiaryParams: TitleEscrowNominateBeneficiaryCommand =
newBeneficiary: "0x1232",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const endorseNominatedBeneficiary = async ({
newBeneficiary,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowNominateBeneficiaryCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -28,7 +28,7 @@ export const endorseNominatedBeneficiary = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await titleEscrow.estimateGas.transferBeneficiary(nominatedBeneficiary),
network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const nominateBeneficiaryParams: TitleEscrowNominateBeneficiaryCommand = {
tokenRegistry: "0x1234",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/nominateBeneficiary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const nominateBeneficiary = async ({
newBeneficiary,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowNominateBeneficiaryCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -27,7 +27,7 @@ export const nominateBeneficiary = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await validateNominateBeneficiary({ beneficiaryNominee: newBeneficiary, titleEscrow });
await dryRunMode({
estimatedGas: await titleEscrow.estimateGas.nominate(newBeneficiary),
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/title-escrow/rejectSurrendered.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const rejectSurrenderedDocumentParams: TitleEscrowSurrenderDocumentCommand = {
tokenId: "0x12345",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/rejectSurrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const rejectSurrendered = async ({
tokenId,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowSurrenderDocumentCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -24,7 +24,7 @@ export const rejectSurrendered = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await tokenRegistryInstance.estimateGas.restore(tokenId),
network,
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/title-escrow/surrenderDocument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const surrenderDocumentParams: TitleEscrowSurrenderDocumentCommand = {
tokenId: "0x12345",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/surrenderDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const surrenderDocument = async ({
tokenId,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowSurrenderDocumentCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -24,7 +24,7 @@ export const surrenderDocument = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await titleEscrow.estimateGas.surrender(),
network,
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/title-escrow/transferHolder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const transferHolderParams: TitleEscrowTransferHolderCommand = {
tokenRegistry: "0x1234",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/transferHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const transferHolder = async ({
tokenId,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowTransferHolderCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -26,7 +26,7 @@ export const transferHolder = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await titleEscrow.estimateGas.transferHolder(to),
network,
Expand Down
2 changes: 1 addition & 1 deletion src/implementations/title-escrow/transferOwners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const endorseChangeOwnersParams: TitleEscrowEndorseTransferOfOwnersCommand = {
tokenRegistry: "0x1234",
network: "goerli",
maxPriorityFeePerGasScale: 1,
feeData: false,
dryRun: false,
};

describe("title-escrow", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/implementations/title-escrow/transferOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const transferOwners = async ({
newOwner,
network,
maxPriorityFeePerGasScale,
feeData,
dryRun,
...rest
}: TitleEscrowEndorseTransferOfOwnersCommand): Promise<TransactionReceipt> => {
const wallet = await getWalletOrSigner({ network, ...rest });
Expand All @@ -28,7 +28,7 @@ export const transferOwners = async ({
maxPriorityFeePerGas: scaleBigNumber(maxPriorityFeePerGas, maxPriorityFeePerGasScale),
maxFeePerGas: calculateMaxFee(maxFeePerGas, maxPriorityFeePerGas, maxPriorityFeePerGasScale),
});
if (feeData) {
if (dryRun) {
await dryRunMode({
estimatedGas: await titleEscrow.estimateGas.transferOwners(newOwner, newHolder),
network,
Expand Down
Loading

0 comments on commit 00c5ee4

Please sign in to comment.