Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ L1_CHAIN=sepolia
L2_CHAIN=scrollSepolia
L1_RPC_URLS=<your-rpc-url>,<your-rpc-url>
L2_RPC_URLS=<your-rpc-url>,<your-rpc-url>
ALCHEMY_API_KEY=<your-alchemy-api-key>
ALCHEMY_L1_NETWORK=ETH_SEPOLIA
ALCHEMY_L2_NETWORK=SCROLL_SEPOLIA
TRANSACTION_WAIT_TRANSACTION_TIMEOUT=30000
TRANSACTION_INCREMENT_RATE=0.3

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "intmax2-function",
"version": "1.0.15",
"version": "1.0.16",
"license": "MIT",
"description": "A collection of function for INTMAX2 blockchain",
"repository": {
Expand Down
39 changes: 7 additions & 32 deletions packages/mint-executor/src/service/process.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Alchemy,
ITX_AMOUNT_TO_LIQUIDITY,
logger,
MintedEvent,
TransferredToLiquidityEvent,
} from "@intmax2-function/shared";
import { ITX_AMOUNT_TO_LIQUIDITY, logger } from "@intmax2-function/shared";
import { hexToNumber } from "viem";
import { afterEach, beforeEach, describe, expect, it, type MockedFunction, vi } from "vitest";
import { getMintedEvent, getTransferredToLiquidityEvent } from "./event.service";
Expand All @@ -14,9 +8,6 @@ import { executeAutomaticOperations, processEvents } from "./process.service";
import { transferToLiquidity } from "./transfer.service";

vi.mock("@intmax2-function/shared", () => ({
Alchemy: {
getInstance: vi.fn(),
},
ITX_AMOUNT_TO_LIQUIDITY: 1000000n,
MINT_INTERVAL_WEEKS: 4,
TRANSFER_INTERVAL_WEEKS: 1,
Expand Down Expand Up @@ -61,12 +52,9 @@ describe("Event Processing Service", () => {
getLatestEventByType: vi.fn(),
addEvent: vi.fn(),
};

mockAlchemyInstance = {
mockEthereumClient = {
getBlock: vi.fn(),
};

(Alchemy.getInstance as any).mockReturnValue(mockAlchemyInstance);
(hexToNumber as any).mockImplementation((hex: string) => parseInt(hex, 16));
});

Expand All @@ -75,28 +63,15 @@ describe("Event Processing Service", () => {
const currentBlockNumber = 2000n;

it("should process new mint and transfer events", async () => {
const mockMintedEvent: MintedEvent = {
name: "Minted",
address: "0x1234567890123456789012345678901234567890",
const mockMintedEvent = {
blockNumber: 1500n,
blockTimestamp: "0x64a1b2c3",
blockHash: "0xblockhash123",
transactionHash: "0xabc123",
args: {
amount: 1000n,
},
};

const mockTransferEvent: TransferredToLiquidityEvent = {
name: "TransferredToLiquidity",
address: "0x1234567890123456789012345678901234567890",
const mockTransferEvent = {
blockNumber: 1600n,
blockTimestamp: "0x64a1b2c4",
blockHash: "0xblockhash456",
transactionHash: "0xdef456",
args: {
amount: 2000n,
},
};

mockMintEvent.getLatestEventByType
Expand Down Expand Up @@ -200,7 +175,7 @@ describe("Event Processing Service", () => {
.mockReturnValueOnce(true) // mint
.mockReturnValueOnce(false); // transfer
(mint as MockedFunction<any>).mockResolvedValue(mockReceipt);
mockAlchemyInstance.getBlock.mockResolvedValue(mockBlock);
mockEthereumClient.getBlock.mockResolvedValue(mockBlock);

await executeAutomaticOperations(mockEthereumClient, mockMintEvent);

Expand Down Expand Up @@ -238,7 +213,7 @@ describe("Event Processing Service", () => {
.mockReturnValueOnce(false) // mint
.mockReturnValueOnce(true); // transfer
(transferToLiquidity as MockedFunction<any>).mockResolvedValue(mockReceipt);
mockAlchemyInstance.getBlock.mockResolvedValue(mockBlock);
mockEthereumClient.getBlock.mockResolvedValue(mockBlock);

await executeAutomaticOperations(mockEthereumClient, mockMintEvent);

Expand Down Expand Up @@ -286,7 +261,7 @@ describe("Event Processing Service", () => {
.mockReturnValueOnce(true); // transfer
(mint as MockedFunction<any>).mockResolvedValue(mockMintReceipt);
(transferToLiquidity as MockedFunction<any>).mockResolvedValue(mockTransferReceipt);
mockAlchemyInstance.getBlock.mockResolvedValue(mockBlock);
mockEthereumClient.getBlock.mockResolvedValue(mockBlock);

await executeAutomaticOperations(mockEthereumClient, mockMintEvent);

Expand Down
7 changes: 4 additions & 3 deletions packages/mint-executor/src/service/process.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Alchemy,
createNetworkClient,
ITX_AMOUNT_TO_LIQUIDITY,
logger,
Expand Down Expand Up @@ -148,7 +147,8 @@ const executeMintOperation = async (
logger.info("Executing mint operation");

const receipt = await mint(l1Client);
const block = await Alchemy.getInstance("l1").getBlock(BigInt(receipt.blockNumber));
const block = await l1Client.getBlock({ blockNumber: BigInt(receipt.blockNumber) });

await mintEvent.addEvent({
type: "mint",
blockNumber: Number(receipt.blockNumber),
Expand All @@ -164,7 +164,8 @@ const executeTransferOperation = async (
logger.info("Executing transfer to liquidity operation");

const receipt = await transferToLiquidity(l1Client, BigInt(ITX_AMOUNT_TO_LIQUIDITY));
const block = await Alchemy.getInstance("l1").getBlock(BigInt(receipt.blockNumber));
const block = await l1Client.getBlock({ blockNumber: BigInt(receipt.blockNumber) });

await mintEvent.addEvent({
type: "transferToLiquidity",
blockNumber: Number(receipt.blockNumber),
Expand Down
1 change: 0 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@google-cloud/storage": "^7.17.1",
"@hono/node-server": "^1.19.4",
"abitype": "^1.1.1",
"alchemy-sdk": "^3.6.3",
"axios": "^1.12.2",
"discord.js": "^14.22.1",
"envalid": "^8.1.0",
Expand Down
45 changes: 0 additions & 45 deletions packages/shared/src/blockchain/alchemy.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/shared/src/blockchain/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./alchemy";
export * from "./calculate";
export * from "./ethersCalculate";
export * from "./ethersTransaction";
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export const config = cleanEnv(process.env, {
L2_CHAIN: l2Chain({ default: "scroll" }),
L1_RPC_URLS: rpcUrls({ default: ["https://eth-sepolia.alchemyapi.io/v2/dummy"] }),
L2_RPC_URLS: rpcUrls({ default: ["https://scroll-sepolia.alchemyapi.io/v2/dummy"] }),
ALCHEMY_API_KEY: str({ default: "dummy" }),
ALCHEMY_L1_NETWORK: str({ default: "ETH_SEPOLIA" }),
ALCHEMY_L2_NETWORK: str({ default: "SCROLL_SEPOLIA" }),
TRANSACTION_WAIT_TRANSACTION_TIMEOUT: num({ default: 30_000 }),
TRANSACTION_INCREMENT_RATE: num({
default: 0.3,
Expand Down
Loading