Skip to content

Commit

Permalink
remove unused #100
Browse files Browse the repository at this point in the history
  • Loading branch information
KlonD90 committed Jul 18, 2024
1 parent a8891c5 commit 0391b8e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 91 deletions.
11 changes: 0 additions & 11 deletions src/clients/types/IDeployContractData.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/clients/types/IDeployContractOption.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/clients/types/ISendMessage.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/contracts/Faucet/Faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type Hex, bytesToHex, encodeFunctionData } from "viem";
import type { PublicClient } from "../../clients/PublicClient.js";
import { ExternalMessageEnvelope } from "../../encoding/externalMessage.js";
import { hexToBytes } from "../../index.js";
import type { IReceipt } from "../../types/IReceipt.js";
import { getShardIdFromAddress } from "../../utils/address.js";
import { waitTillCompleted } from "../../utils/receipt.js";
import FaucetAbi from "./Faucet.abi.json";
Expand Down Expand Up @@ -109,7 +108,7 @@ export class Faucet {
const encodedMessage = message.encode();
await this.client.sendRawMessage(bytesToHex(encodedMessage));
const hash = bytesToHex(message.hash());
const receipts: IReceipt[] = await Promise.race([
const receipts = await Promise.race([
new Promise<[]>((resolve) => setTimeout(() => resolve([]), 10000)),
waitTillCompleted(
this.client,
Expand Down
54 changes: 0 additions & 54 deletions src/utils/assert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import invariant from "tiny-invariant";
import { masterShardId } from "../clients/constants.js";
import type { IDeployData } from "../clients/types/IDeployData.js";
import type { ISendMessage } from "../clients/types/ISendMessage.js";
import { type Hex, InvalidShardIdError } from "../index.js";
import type { IPrivateKey } from "../signers/index.js";
import type { Block } from "../types/Block.js";
Expand Down Expand Up @@ -51,58 +50,6 @@ const assertIsValidPrivateKey = (
);
};

/**
* Checks if the data to send message is valid. If the message is valid, it returns nothing.
* @throws Will throw an error if the value is not a valid data to send message.
* @param sendMessage - The data to validate.
* @param message - The message to throw if the data is invalid.
*/
const assertIsValidSendMessageData = (
sendMessage: ISendMessage,
message?: string,
) => {
const { gasPrice, gasLimit, to, from, seqno, value } = sendMessage;
invariant(
typeof to === "string" && isAddress(to),
message ?? `Expected a valid 'to' address but got ${to}`,
);

invariant(
typeof value === "bigint" && value >= 0,
message ?? `Expected a valid 'value' but got ${value}`,
);

if (from !== undefined) {
invariant(
typeof from === "string" && isAddress(from),
message ?? `Expected a valid 'from' address but got ${from}`,
);
}

if (gasPrice !== undefined) {
invariant(
(typeof gasPrice === "number" || typeof gasPrice === "bigint") &&
gasPrice > 0,
message ?? `Expected a valid 'gasPrice' but got ${gasPrice}`,
);
}

if (gasLimit !== undefined) {
invariant(
(typeof gasLimit === "number" || typeof gasLimit === "bigint") &&
gasLimit > 0,
message ?? `Expected a valid 'gasLimit' but got ${gasLimit}`,
);
}

if (seqno !== undefined) {
invariant(
seqno >= 0,
message ?? `Expected a valid 'seqno' but got ${seqno}`,
);
}
};

/**
* Checks if the data to deploy contract is valid. If the data is valid, it returns nothing.
* @throws Will throw an error if the value is not a valid data to deploy contract.
Expand Down Expand Up @@ -177,7 +124,6 @@ export {
assertIsBuffer,
assertIsHexString,
assertIsValidPrivateKey,
assertIsValidSendMessageData,
assertIsAddress,
assertIsValidBlock,
assertIsValidShardId,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const waitTillCompleted = async (
receipts.push(receipt);
if (receipt.outputReceipts) {
for (const r of receipt.outputReceipts) {
hashes.push([r.shardId, r.messageHash]);
if (r !== null) hashes.push([r.shardId, r.messageHash]);
}
}
}
Expand Down

0 comments on commit 0391b8e

Please sign in to comment.