diff --git a/src/clients/types/IDeployContractData.ts b/src/clients/types/IDeployContractData.ts deleted file mode 100644 index 87531f5..0000000 --- a/src/clients/types/IDeployContractData.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { IDeployData } from "./IDeployData.js"; -import type { ISendMessage } from "./ISendMessage.js"; - -/** - * The data needed to send a deploy contract message. - */ -type IDeployContractData = { - deployData: IDeployData; -} & Omit; - -export type { IDeployContractData }; diff --git a/src/clients/types/IDeployContractOption.ts b/src/clients/types/IDeployContractOption.ts deleted file mode 100644 index 97245a1..0000000 --- a/src/clients/types/IDeployContractOption.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { IMessage } from "../../index.js"; -import type { IDeployData } from "../../types/IDeployData.js"; - -/** - * The option for deploying a contract. - */ -type IDeployContractOption = IDeployData & - Pick; - -export type { IDeployContractOption }; diff --git a/src/clients/types/ISendMessage.ts b/src/clients/types/ISendMessage.ts deleted file mode 100644 index 3124c6f..0000000 --- a/src/clients/types/ISendMessage.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * The data structure for the send message request. - */ -type ISendMessage = { - to: string; - value: bigint; - from?: string; - seqno?: number; - gasLimit?: bigint; - data?: Uint8Array; -}; - -export type { ISendMessage }; diff --git a/src/contracts/Faucet/Faucet.ts b/src/contracts/Faucet/Faucet.ts index 356d0a5..8eb9c1b 100644 --- a/src/contracts/Faucet/Faucet.ts +++ b/src/contracts/Faucet/Faucet.ts @@ -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"; @@ -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, diff --git a/src/utils/assert.ts b/src/utils/assert.ts index 6f75c44..12dd7ac 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -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"; @@ -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. @@ -177,7 +124,6 @@ export { assertIsBuffer, assertIsHexString, assertIsValidPrivateKey, - assertIsValidSendMessageData, assertIsAddress, assertIsValidBlock, assertIsValidShardId, diff --git a/src/utils/receipt.ts b/src/utils/receipt.ts index 3bea611..170caac 100644 --- a/src/utils/receipt.ts +++ b/src/utils/receipt.ts @@ -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]); } } }