genlayer-js 0.18.10 → 0.18.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/chains/index.cjs +2 -2
  2. package/dist/chains/index.js +1 -1
  3. package/dist/{chunk-PPBY3UXF.cjs → chunk-5TKVNHAO.cjs} +1118 -305
  4. package/dist/{chunk-WZNF2WK4.js → chunk-NOFMB7RP.js} +1118 -305
  5. package/dist/{index-D9ONjYgl.d.cts → index-DsN7LGHA.d.cts} +1615 -459
  6. package/dist/{index-ZDqJWXj0.d.ts → index-sw3NAvBf.d.ts} +1615 -459
  7. package/dist/index.cjs +58 -58
  8. package/dist/index.d.cts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +28 -28
  11. package/dist/types/index.d.cts +1 -1
  12. package/dist/types/index.d.ts +1 -1
  13. package/package.json +11 -1
  14. package/.eslintignore +0 -2
  15. package/.eslintrc.cjs +0 -59
  16. package/.github/pull_request_template.md +0 -43
  17. package/.github/workflows/publish.yml +0 -41
  18. package/.github/workflows/test.yml +0 -33
  19. package/.prettierignore +0 -19
  20. package/.prettierrc +0 -12
  21. package/.release-it.json +0 -64
  22. package/CHANGELOG.md +0 -304
  23. package/CLAUDE.md +0 -66
  24. package/CONTRIBUTING.md +0 -87
  25. package/renovate.json +0 -20
  26. package/src/abi/calldata/consts.ts +0 -14
  27. package/src/abi/calldata/decoder.ts +0 -86
  28. package/src/abi/calldata/encoder.ts +0 -178
  29. package/src/abi/calldata/index.ts +0 -3
  30. package/src/abi/calldata/string.ts +0 -83
  31. package/src/abi/index.ts +0 -6
  32. package/src/abi/staking.ts +0 -687
  33. package/src/abi/transactions.ts +0 -11
  34. package/src/accounts/IAccountActions.ts +0 -5
  35. package/src/accounts/account.ts +0 -9
  36. package/src/accounts/actions.ts +0 -34
  37. package/src/chains/actions.ts +0 -40
  38. package/src/chains/index.ts +0 -4
  39. package/src/chains/localnet.ts +0 -4016
  40. package/src/chains/studionet.ts +0 -4017
  41. package/src/chains/testnetAsimov.ts +0 -4013
  42. package/src/client/client.ts +0 -139
  43. package/src/config/snapID.ts +0 -4
  44. package/src/config/transactions.ts +0 -9
  45. package/src/contracts/actions.ts +0 -387
  46. package/src/global.d.ts +0 -9
  47. package/src/index.ts +0 -12
  48. package/src/staking/actions.ts +0 -691
  49. package/src/staking/index.ts +0 -2
  50. package/src/staking/utils.ts +0 -22
  51. package/src/transactions/ITransactionActions.ts +0 -15
  52. package/src/transactions/actions.ts +0 -113
  53. package/src/transactions/decoders.ts +0 -275
  54. package/src/types/accounts.ts +0 -1
  55. package/src/types/calldata.ts +0 -31
  56. package/src/types/chains.ts +0 -22
  57. package/src/types/clients.ts +0 -106
  58. package/src/types/contracts.ts +0 -32
  59. package/src/types/index.ts +0 -9
  60. package/src/types/metamaskClientResult.ts +0 -5
  61. package/src/types/network.ts +0 -1
  62. package/src/types/snapSource.ts +0 -1
  63. package/src/types/staking.ts +0 -225
  64. package/src/types/transactions.ts +0 -312
  65. package/src/utils/async.ts +0 -3
  66. package/src/utils/jsonifier.ts +0 -119
  67. package/src/wallet/actions.ts +0 -10
  68. package/src/wallet/connect.ts +0 -67
  69. package/src/wallet/metamaskClient.ts +0 -50
  70. package/tests/client.test-d.ts +0 -67
  71. package/tests/client.test.ts +0 -197
  72. package/tests/smoke.test.ts +0 -59
  73. package/tests/transactions.test.ts +0 -142
  74. package/tsconfig.json +0 -119
  75. package/tsconfig.vitest-temp.json +0 -41
  76. package/vitest.config.ts +0 -18
@@ -1,67 +0,0 @@
1
- import {localnet} from "@/chains/localnet";
2
- import {studionet} from "@/chains/studionet";
3
- import {testnetAsimov} from "@/chains/testnetAsimov";
4
- import {GenLayerClient, GenLayerChain} from "@/types";
5
- import {Network} from "@/types/network";
6
- import {SnapSource} from "@/types/snapSource";
7
- import {snapID} from "@/config/snapID";
8
-
9
- const networks = {
10
- localnet,
11
- studionet,
12
- testnetAsimov,
13
- };
14
-
15
- export const connect = async (
16
- client: GenLayerClient<GenLayerChain>,
17
- network: Network = "studionet",
18
- snapSource: SnapSource = "npm",
19
- ): Promise<void> => {
20
- if (!window.ethereum) {
21
- throw new Error("MetaMask is not installed.");
22
- }
23
- if (network === "mainnet") {
24
- throw new Error(`${network} is not available yet. Please use localnet.`);
25
- }
26
-
27
- const selectedNetwork = networks[network];
28
- if (!selectedNetwork) {
29
- throw new Error(`Network configuration for '${network}' is not available.`);
30
- }
31
-
32
- const chainIdHex = `0x${selectedNetwork.id.toString(16)}`;
33
- const chainParams = {
34
- chainId: chainIdHex,
35
- chainName: selectedNetwork.name,
36
- rpcUrls: selectedNetwork.rpcUrls.default.http,
37
- nativeCurrency: selectedNetwork.nativeCurrency,
38
- blockExplorerUrls: [selectedNetwork.blockExplorers?.default.url],
39
- };
40
-
41
- const currentChainId = await window.ethereum.request({method: "eth_chainId"});
42
- if (currentChainId !== chainIdHex) {
43
- await window.ethereum.request({
44
- method: "wallet_addEthereumChain",
45
- params: [chainParams],
46
- });
47
- await window.ethereum.request({
48
- method: "wallet_switchEthereumChain",
49
- params: [{chainId: chainIdHex}],
50
- });
51
- }
52
-
53
- const id = snapSource === "local" ? snapID.local : snapID.npm;
54
- const installedSnaps: any = await window.ethereum.request({method: "wallet_getSnaps"});
55
- const isGenLayerSnapInstalled = Object.values(installedSnaps).some((snap: any) => snap.id === id);
56
-
57
- if (!isGenLayerSnapInstalled) {
58
- await window.ethereum.request({
59
- method: "wallet_requestSnaps",
60
- params: {
61
- [id]: {},
62
- },
63
- });
64
- }
65
-
66
- client.chain = selectedNetwork;
67
- };
@@ -1,50 +0,0 @@
1
- import { snapID } from "@/config/snapID";
2
- import { SnapSource } from "@/types/snapSource";
3
- import { MetaMaskClientResult } from "@/types/metamaskClientResult";
4
-
5
- export const metamaskClient = async (snapSource: SnapSource = "npm") => {
6
- if (typeof window === "undefined" || !window.ethereum) {
7
- throw new Error("MetaMask is not installed.");
8
- }
9
-
10
- const isFlask = async (): Promise<boolean> => {
11
- try {
12
- const clientVersion = await window.ethereum?.request({
13
- method: "web3_clientVersion",
14
- });
15
-
16
- return (clientVersion as string)?.includes("flask");
17
- } catch (error) {
18
- console.error("Error detecting Flask:", error);
19
- return false;
20
- }
21
- };
22
-
23
- const installedSnaps = async (): Promise<Record<string, any>> => {
24
- try {
25
- return (await window.ethereum?.request({
26
- method: "wallet_getSnaps",
27
- })) as Record<string, any>;
28
- } catch (error) {
29
- console.error("Error getting installed snaps:", error);
30
- return {};
31
- }
32
- };
33
-
34
- const isGenLayerSnapInstalled = async (): Promise<boolean> => {
35
- const id = snapSource === "local" ? snapID.local : snapID.npm;
36
- const snaps = await installedSnaps();
37
-
38
- return Object.values(snaps).some((snap: any) => snap.id === id);
39
- };
40
-
41
- const flaskDetected = await isFlask();
42
- const snapsList = await installedSnaps();
43
- const genLayerSnapInstalled = await isGenLayerSnapInstalled();
44
-
45
- return {
46
- isFlask: flaskDetected,
47
- installedSnaps: snapsList,
48
- isGenLayerSnapInstalled: genLayerSnapInstalled,
49
- } as MetaMaskClientResult;
50
- };
@@ -1,67 +0,0 @@
1
- import {createClient} from "../src/client/client";
2
- import {localnet} from "@/chains/localnet";
3
- import {createAccount, generatePrivateKey} from "../src/accounts/account";
4
- import {TransactionHash, TransactionStatus} from "../src/types/transactions";
5
-
6
- test("type checks", () => {
7
- const client = createClient({
8
- chain: localnet,
9
- account: createAccount(generatePrivateKey()),
10
- });
11
-
12
- const exampleAddress = "0x1234567890123456789012345678901234567890";
13
-
14
- // This should fail type checking - "whatever" is not a valid filter
15
- // @ts-expect-error "whatever" is not a valid filter type
16
- void client.request({
17
- method: "sim_getTransactionsForAddress",
18
- params: [exampleAddress, "whatever"],
19
- });
20
-
21
- // This should pass type checking - "all", "to" and "from" are valid filters
22
- void client.request({
23
- method: "sim_getTransactionsForAddress",
24
- params: [exampleAddress, "all"],
25
- });
26
-
27
- void client.request({
28
- method: "sim_getTransactionsForAddress",
29
- params: [exampleAddress, "to"],
30
- });
31
-
32
- void client.request({
33
- method: "sim_getTransactionsForAddress",
34
- params: [exampleAddress, "from"],
35
- });
36
-
37
- void client.getContractSchema(exampleAddress);
38
-
39
- void client.getContractSchemaForCode("class SomeContract...");
40
-
41
- void client.waitForTransactionReceipt({
42
- hash: "0x1234567890123456789012345678901234567890123456789012345678901234" as TransactionHash,
43
- });
44
-
45
- void client.waitForTransactionReceipt({
46
- hash: "0x1234567890123456789012345678901234567890123456789012345678901234" as TransactionHash,
47
- status: TransactionStatus.FINALIZED,
48
- });
49
-
50
- void client.waitForTransactionReceipt({
51
- hash: "0x1234567890123456789012345678901234567890123456789012345678901234" as TransactionHash,
52
- status: TransactionStatus.FINALIZED,
53
- interval: 1000,
54
- });
55
-
56
- void client.waitForTransactionReceipt({
57
- hash: "0x1234567890123456789012345678901234567890123456789012345678901234" as TransactionHash,
58
- status: TransactionStatus.FINALIZED,
59
- interval: 1000,
60
- retries: 10,
61
- });
62
-
63
- // @ts-expect-error missing hash
64
- void client.waitForTransactionReceipt({
65
- status: TransactionStatus.FINALIZED,
66
- });
67
- });
@@ -1,197 +0,0 @@
1
- // tests/client.test.ts
2
- import {createClient} from "../src/client/client";
3
- import {localnet} from "@/chains/localnet";
4
- import {Address} from "../src/types/accounts";
5
- import {createAccount, generatePrivateKey} from "../src/accounts/account";
6
- import {vi} from "vitest";
7
- import {TransactionHashVariant} from "../src/types/transactions";
8
- import {zeroAddress} from "viem";
9
-
10
- // Setup fetch mock
11
- const mockFetch = vi.fn();
12
- vi.stubGlobal("fetch", mockFetch);
13
-
14
- // Store for gen_call parameters received by mockFetch
15
- let lastGenCallParams: any = null;
16
-
17
- describe("Client Creation", () => {
18
- it("should create a client for the localnet", () => {
19
- const client = createClient({chain: localnet});
20
- expect(client).toBeDefined();
21
- expect(client.chain).toBe(localnet);
22
- });
23
- });
24
-
25
- describe("Client Overrides", () => {
26
- beforeEach(() => {
27
- mockFetch.mockReset();
28
- lastGenCallParams = null; // Reset for each test
29
-
30
- mockFetch.mockImplementation(async (url, options) => {
31
- let body = {};
32
- const bodyString = typeof options?.body === "string" ? options.body : null;
33
-
34
- if (bodyString) {
35
- try {
36
- body = JSON.parse(bodyString);
37
- } catch (e) {
38
- console.error("[TESTS] mockFetch: Failed to parse bodyString:", bodyString, "Error:", e);
39
- // Return a generic error if body parsing fails
40
- return {
41
- ok: false,
42
- status: 500,
43
- json: async () => ({error: {message: "mockFetch body parse error"}}),
44
- };
45
- }
46
- }
47
-
48
- const method = (body as any).method;
49
- // console.log(`[TESTS] mockFetch called: URL=${url}, Method=${method}, Body=`, body); // Optional: keep for debugging
50
-
51
- if (method === "sim_getConsensusContract") {
52
- // console.log("[TESTS] mockFetch: Handling sim_getConsensusContract");
53
- return {
54
- ok: true,
55
- json: async () => ({
56
- result: {
57
- address: "0x0000000000000000000000000000000000000001",
58
- abi: [],
59
- },
60
- }),
61
- };
62
- } else if (method === "gen_call") {
63
- // console.log("[TESTS] mockFetch: Handling gen_call");
64
- lastGenCallParams = (body as any).params; // Store the params for gen_call
65
- return {
66
- ok: true,
67
- json: async () => ({result: "0"}),
68
- };
69
- }
70
-
71
- console.warn(`[TESTS] mockFetch: Unhandled method - URL=${url}, Method=${method}, Body=`, body);
72
- return {
73
- ok: false,
74
- status: 404, // Not Found for unhandled methods
75
- json: async () => ({error: {message: `Unexpected fetch mock call to method: ${method}`}}),
76
- };
77
- });
78
- });
79
-
80
- afterEach(() => {
81
- // Restore any spies if they weren't restored in tests
82
- vi.restoreAllMocks();
83
- });
84
-
85
- it("should default to client account if no account is provided", async () => {
86
- const account = createAccount(generatePrivateKey());
87
- const client = createClient({
88
- chain: localnet,
89
- account: account,
90
- });
91
-
92
- // const requestSpy = vi.spyOn(client, "request"); // Removed spy
93
-
94
- const contractAddress = "0x1234567890123456789012345678901234567890";
95
- await client.readContract({
96
- address: contractAddress as Address,
97
- functionName: "testFunction",
98
- args: ["arg1", "arg2"],
99
- transactionHashVariant: TransactionHashVariant.LATEST_NONFINAL,
100
- });
101
-
102
- expect(lastGenCallParams).toEqual([
103
- {
104
- type: "read",
105
- to: contractAddress,
106
- from: account.address,
107
- data: expect.any(String), // The data is complex, checking type is often sufficient
108
- transaction_hash_variant: TransactionHashVariant.LATEST_NONFINAL,
109
- },
110
- ]);
111
- });
112
-
113
- it("should override client account if account is provided", async () => {
114
- const clientInternalAccount = createAccount(generatePrivateKey()); // Renamed for clarity
115
- const client = createClient({
116
- chain: localnet,
117
- account: clientInternalAccount,
118
- });
119
-
120
- const overrideAccount = createAccount(generatePrivateKey());
121
-
122
- // const requestSpy = vi.spyOn(client, "request"); // Removed spy
123
-
124
- const contractAddress = "0x1234567890123456789012345678901234567890";
125
- await client.readContract({
126
- account: overrideAccount,
127
- address: contractAddress as Address,
128
- functionName: "testFunction",
129
- args: ["arg1", "arg2"],
130
- transactionHashVariant: TransactionHashVariant.LATEST_FINAL,
131
- });
132
-
133
- expect(lastGenCallParams).toEqual([
134
- {
135
- type: "read",
136
- to: contractAddress,
137
- from: overrideAccount.address,
138
- data: expect.any(String),
139
- transaction_hash_variant: TransactionHashVariant.LATEST_FINAL,
140
- },
141
- ]);
142
- });
143
-
144
- it("should use client account if account is an address string and no override", async () => {
145
- // Clarified title
146
- const accountAddressString = "0x65e03a3e916CF1dC92d3C8E8186a89CfAB0D2bc2";
147
- const client = createClient({
148
- chain: localnet,
149
- account: accountAddressString, // Client's account is an address string
150
- });
151
-
152
- // const requestSpy = vi.spyOn(client, "request"); // Removed spy
153
-
154
- const contractAddress = "0x1234567890123456789012345678901234567890";
155
- await client.readContract({
156
- address: contractAddress as Address,
157
- functionName: "testFunction",
158
- args: ["arg1", "arg2"],
159
- // No stateStatus, no account override in this specific call to readContract
160
- });
161
-
162
- expect(lastGenCallParams).toEqual([
163
- {
164
- type: "read",
165
- to: contractAddress,
166
- from: accountAddressString, // Expecting the address string directly
167
- data: expect.any(String),
168
- transaction_hash_variant: TransactionHashVariant.LATEST_NONFINAL,
169
- },
170
- ]);
171
- });
172
-
173
- it("should use zero address when no account is provided anywhere", async () => {
174
- const client = createClient({
175
- chain: localnet,
176
- // No account provided on client
177
- });
178
-
179
- const contractAddress = "0x1234567890123456789012345678901234567890";
180
- await client.readContract({
181
- // No account override either
182
- address: contractAddress as Address,
183
- functionName: "testFunction",
184
- args: ["arg1", "arg2"],
185
- });
186
-
187
- expect(lastGenCallParams).toEqual([
188
- {
189
- type: "read",
190
- to: contractAddress,
191
- from: zeroAddress, // Should default to zero address
192
- data: expect.any(String),
193
- transaction_hash_variant: TransactionHashVariant.LATEST_NONFINAL,
194
- },
195
- ]);
196
- });
197
- });
@@ -1,59 +0,0 @@
1
- // tests/smoke.test.ts
2
- // Basic smoke tests to verify testnet chain configuration and connectivity
3
- import {describe, it, expect} from "vitest";
4
- import {testnetAsimov} from "@/chains/testnetAsimov";
5
- import {createPublicClient, http} from "viem";
6
-
7
- describe("Testnet Asimov Chain Config", () => {
8
- it("should have valid RPC URL", () => {
9
- const rpcUrl = testnetAsimov.rpcUrls.default.http[0];
10
- expect(rpcUrl).toBe("https://zksync-os-testnet-genlayer.zksync.dev");
11
- });
12
-
13
- it("should have valid WebSocket URL", () => {
14
- const wsUrl = testnetAsimov.rpcUrls.default.webSocket?.[0];
15
- expect(wsUrl).toBe("wss://zksync-os-testnet-alpha.zksync.dev/ws");
16
- });
17
-
18
- it("should have consensus main contract address", () => {
19
- expect(testnetAsimov.consensusMainContract?.address).toBe(
20
- "0x6CAFF6769d70824745AD895663409DC70aB5B28E",
21
- );
22
- });
23
-
24
- it("should have consensus data contract address", () => {
25
- expect(testnetAsimov.consensusDataContract?.address).toBe(
26
- "0x0D9d1d74d72Fa5eB94bcf746C8FCcb312a722c9B",
27
- );
28
- });
29
-
30
- it("should have staking contract address", () => {
31
- expect(testnetAsimov.stakingContract?.address).toBe(
32
- "0x63Fa5E0bb10fb6fA98F44726C5518223F767687A",
33
- );
34
- });
35
-
36
- it("should have correct chain ID", () => {
37
- expect(testnetAsimov.id).toBe(0x107d);
38
- });
39
- });
40
-
41
- describe("Testnet Asimov RPC Connectivity", () => {
42
- it("should connect and fetch chain ID", async () => {
43
- const client = createPublicClient({
44
- chain: testnetAsimov,
45
- transport: http(testnetAsimov.rpcUrls.default.http[0]),
46
- });
47
- const chainId = await client.getChainId();
48
- expect(chainId).toBe(testnetAsimov.id);
49
- }, 15000);
50
-
51
- it("should fetch latest block number", async () => {
52
- const client = createPublicClient({
53
- chain: testnetAsimov,
54
- transport: http(testnetAsimov.rpcUrls.default.http[0]),
55
- });
56
- const blockNumber = await client.getBlockNumber();
57
- expect(blockNumber).toBeGreaterThan(0n);
58
- }, 15000);
59
- });
@@ -1,142 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { TransactionStatus, DECIDED_STATES, isDecidedState } from "../src/types/transactions";
3
- import { receiptActions } from "../src/transactions/actions";
4
- import { localnet } from "../src/chains/localnet";
5
-
6
- const mockFetch = vi.fn();
7
- vi.stubGlobal("fetch", mockFetch);
8
-
9
- describe("DECIDED_STATES constant", () => {
10
- it("should contain all expected decided states", () => {
11
- const expectedStates = [
12
- TransactionStatus.ACCEPTED,
13
- TransactionStatus.UNDETERMINED,
14
- TransactionStatus.LEADER_TIMEOUT,
15
- TransactionStatus.VALIDATORS_TIMEOUT,
16
- TransactionStatus.CANCELED,
17
- TransactionStatus.FINALIZED
18
- ];
19
-
20
- expect(DECIDED_STATES).toEqual(expectedStates);
21
- });
22
- });
23
-
24
- describe("isDecidedState utility function", () => {
25
- it("should return true for all decided states", () => {
26
- const decidedStatusNumbers = ["5", "6", "13", "12", "8", "7"]; // ACCEPTED, UNDETERMINED, LEADER_TIMEOUT, VALIDATORS_TIMEOUT, CANCELED, FINALIZED
27
-
28
- decidedStatusNumbers.forEach(statusNum => {
29
- expect(isDecidedState(statusNum)).toBe(true);
30
- });
31
- });
32
-
33
- it("should return false for non-decided states", () => {
34
- const nonDecidedStatusNumbers = ["0", "1", "2", "3", "4", "9", "10", "11"]; // UNINITIALIZED, PENDING, PROPOSING, COMMITTING, REVEALING, APPEAL_REVEALING, APPEAL_COMMITTING, READY_TO_FINALIZE
35
-
36
- nonDecidedStatusNumbers.forEach(statusNum => {
37
- expect(isDecidedState(statusNum)).toBe(false);
38
- });
39
- });
40
-
41
- it("should return false for invalid statuses", () => {
42
- const invalidStatuses = ["999", "invalid", ""];
43
-
44
- invalidStatuses.forEach(status => {
45
- expect(isDecidedState(status)).toBe(false);
46
- });
47
- });
48
- });
49
-
50
- describe("waitForTransactionReceipt with DECIDED_STATES", () => {
51
- beforeEach(() => {
52
- mockFetch.mockReset();
53
- });
54
-
55
- it("should accept all decided states when waiting for ACCEPTED", async () => {
56
- const decidedStatusNumbers = ["5", "6", "13", "12", "8", "7"]; // All decided states
57
-
58
- for (const statusNum of decidedStatusNumbers) {
59
- const mockTransaction = {
60
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6",
61
- status: statusNum,
62
- from_address: "0x123",
63
- to_address: "0x456",
64
- value: "0",
65
- gaslimit: "1000000",
66
- nonce: "1",
67
- created_at: "2023-01-01T00:00:00Z",
68
- };
69
-
70
- const mockClient = {
71
- chain: localnet,
72
- getTransaction: vi.fn().mockResolvedValue(mockTransaction)
73
- };
74
-
75
- const mockPublicClient = {} as any;
76
-
77
- const actions = receiptActions(mockClient as any, mockPublicClient);
78
- const result = await actions.waitForTransactionReceipt({
79
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6" as any,
80
- status: TransactionStatus.ACCEPTED,
81
- });
82
-
83
- expect(result).toEqual(mockTransaction);
84
- }
85
- });
86
-
87
- it("should not affect waiting for specific non-ACCEPTED statuses", async () => {
88
- const mockTransaction = {
89
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6",
90
- status: "7", // FINALIZED
91
- from_address: "0x123",
92
- to_address: "0x456",
93
- value: "0",
94
- gaslimit: "1000000",
95
- nonce: "1",
96
- created_at: "2023-01-01T00:00:00Z",
97
- };
98
-
99
- const mockClient = {
100
- chain: localnet,
101
- getTransaction: vi.fn().mockResolvedValue(mockTransaction)
102
- };
103
-
104
- const mockPublicClient = {} as any;
105
-
106
- const actions = receiptActions(mockClient as any, mockPublicClient);
107
- const result = await actions.waitForTransactionReceipt({
108
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6" as any,
109
- status: TransactionStatus.FINALIZED,
110
- });
111
-
112
- expect(result).toEqual(mockTransaction);
113
- });
114
-
115
- it("should maintain backward compatibility", async () => {
116
- const mockTransaction = {
117
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6",
118
- status: "5", // ACCEPTED
119
- from_address: "0x123",
120
- to_address: "0x456",
121
- value: "0",
122
- gaslimit: "1000000",
123
- nonce: "1",
124
- created_at: "2023-01-01T00:00:00Z",
125
- };
126
-
127
- const mockClient = {
128
- chain: localnet,
129
- getTransaction: vi.fn().mockResolvedValue(mockTransaction)
130
- };
131
-
132
- const mockPublicClient = {} as any;
133
-
134
- const actions = receiptActions(mockClient as any, mockPublicClient);
135
- const result = await actions.waitForTransactionReceipt({
136
- hash: "0x4b8037744adab7ea8335b4f839979d20031d83a8ccdf706e0ae61312930335f6" as any,
137
- status: TransactionStatus.ACCEPTED,
138
- });
139
-
140
- expect(result).toEqual(mockTransaction);
141
- });
142
- });