Skip to content

Commit fad707c

Browse files
authored
Merge branch 'develop' into develop
2 parents 1e8ff22 + 3055280 commit fad707c

File tree

349 files changed

+53179
-4506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+53179
-4506
lines changed

CHANGELOG.md

+89
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,92 @@
1+
# [7.1.0](https://github.com/starknet-io/starknet.js/compare/v7.0.1...v7.1.0) (2025-04-14)
2+
3+
### Bug Fixes
4+
5+
- ensure enum replacement objects are reachable for type resolution ([#1375](https://github.com/starknet-io/starknet.js/issues/1375)) ([eb8b10d](https://github.com/starknet-io/starknet.js/commit/eb8b10dd075475d83cbd4748b610d911f945823f))
6+
- make the provider create method generic to enable it when mixins are applied ([#1370](https://github.com/starknet-io/starknet.js/issues/1370)) ([1f48dc6](https://github.com/starknet-io/starknet.js/commit/1f48dc6957aea8d5480f5413c184ac82ea5dd0db))
7+
8+
### Features
9+
10+
- update to rpc 0.8.1 ([83e17b8](https://github.com/starknet-io/starknet.js/commit/83e17b8b385fe00b5d2ed476de80a6773565bd9a))
11+
12+
## [7.0.1](https://github.com/starknet-io/starknet.js/compare/v7.0.0...v7.0.1) (2025-03-28)
13+
14+
### Bug Fixes
15+
16+
- preserve value for numeric arguments within address padding utility ([abc7958](https://github.com/starknet-io/starknet.js/commit/abc7958a68f5edc396f038f2352a9d747980502f))
17+
18+
# [7.0.0](https://github.com/starknet-io/starknet.js/compare/v6.24.1...v7.0.0) (2025-03-28)
19+
20+
- Implement RPC 0.8 and V3 transactions ([#1328](https://github.com/starknet-io/starknet.js/issues/1328)) ([316ae27](https://github.com/starknet-io/starknet.js/commit/316ae2789376368dcffe653ce4817eebf0a63d97))
21+
22+
### Bug Fixes
23+
24+
- contract withOptions Fix/1252 ([#1255](https://github.com/starknet-io/starknet.js/issues/1255)) ([b59952e](https://github.com/starknet-io/starknet.js/commit/b59952e74baf82641d6028c96625db104049c02e))
25+
- update ws impl, add TEST_WS_URL, update token constants ([411eeec](https://github.com/starknet-io/starknet.js/commit/411eeec1df6a38358f28612260066b38fc942957))
26+
27+
### Features
28+
29+
- drop fetch-cookie dependency ([9a57daf](https://github.com/starknet-io/starknet.js/commit/9a57dafce473432df7040f68e0824e9e78f6e215))
30+
- drop isomorphic-fetch dependency ([9da0083](https://github.com/starknet-io/starknet.js/commit/9da0083d2084b0bd9ec7da06ea9a80f267f4e397))
31+
- prune deprecated functionalities ([cbd18f5](https://github.com/starknet-io/starknet.js/commit/cbd18f59fb0749c558ba4eabc0f094464941b088))
32+
- the WebSockets ([#1251](https://github.com/starknet-io/starknet.js/issues/1251)) ([fabca27](https://github.com/starknet-io/starknet.js/commit/fabca27a7a3e398030a99cf8d78bffa51cebfe9a)), closes [#1272](https://github.com/starknet-io/starknet.js/issues/1272)
33+
- Update Beta to latest Develop ([#1312](https://github.com/starknet-io/starknet.js/issues/1312)) ([2958051](https://github.com/starknet-io/starknet.js/commit/295805116cf0f57b8708f545cc187f19f79588f4)), closes [#949](https://github.com/starknet-io/starknet.js/issues/949) [#970](https://github.com/starknet-io/starknet.js/issues/970)
34+
- v7 fee, new methods, tests ([#1337](https://github.com/starknet-io/starknet.js/issues/1337)) ([00743de](https://github.com/starknet-io/starknet.js/commit/00743de2cad5375a558844646f11b4adef15188b))
35+
36+
### BREAKING CHANGES
37+
38+
- Removed multiple functionalities that have been marked as deprecated
39+
- Library defaults to RPC 0.8 with the corresponding API changes, dropped RPC 0.6 support
40+
41+
# [7.0.0-beta.4](https://github.com/starknet-io/starknet.js/compare/v7.0.0-beta.3...v7.0.0-beta.4) (2025-03-28)
42+
43+
### Bug Fixes
44+
45+
- repair snip-12 enum type nested dependency ([#1289](https://github.com/starknet-io/starknet.js/issues/1289)) ([1cd4219](https://github.com/starknet-io/starknet.js/commit/1cd4219df5e61a676bc58ba8c8673269695fc2db))
46+
47+
### Features
48+
49+
- drop fetch-cookie dependency ([9a57daf](https://github.com/starknet-io/starknet.js/commit/9a57dafce473432df7040f68e0824e9e78f6e215))
50+
- drop isomorphic-fetch dependency ([9da0083](https://github.com/starknet-io/starknet.js/commit/9da0083d2084b0bd9ec7da06ea9a80f267f4e397))
51+
- prune deprecated functionalities ([cbd18f5](https://github.com/starknet-io/starknet.js/commit/cbd18f59fb0749c558ba4eabc0f094464941b088))
52+
53+
### BREAKING CHANGES
54+
55+
- Removed multiple functionalities that have been marked as deprecated
56+
57+
# [7.0.0-beta.3](https://github.com/starknet-io/starknet.js/compare/v7.0.0-beta.2...v7.0.0-beta.3) (2025-03-13)
58+
59+
### Features
60+
61+
- add simulate and estimate fee utility methods for outside execution ([#1327](https://github.com/starknet-io/starknet.js/issues/1327)) ([3668b01](https://github.com/starknet-io/starknet.js/commit/3668b01c4f63969bb0770ee6120fe3eac72d0335))
62+
- implement cairo fixed array support ([#1310](https://github.com/starknet-io/starknet.js/issues/1310)) ([45df63e](https://github.com/starknet-io/starknet.js/commit/45df63e7bb7f7cb2de2e98900387b1c44a95f257))
63+
64+
# [7.0.0-beta.2](https://github.com/starknet-io/starknet.js/compare/v7.0.0-beta.1...v7.0.0-beta.2) (2025-03-10)
65+
66+
### Bug Fixes
67+
68+
- contract withOptions Fix/1252 ([#1255](https://github.com/starknet-io/starknet.js/issues/1255)) ([b59952e](https://github.com/starknet-io/starknet.js/commit/b59952e74baf82641d6028c96625db104049c02e))
69+
- update ws impl, add TEST_WS_URL, update token constants ([411eeec](https://github.com/starknet-io/starknet.js/commit/411eeec1df6a38358f28612260066b38fc942957))
70+
71+
### Features
72+
73+
- the WebSockets ([#1251](https://github.com/starknet-io/starknet.js/issues/1251)) ([fabca27](https://github.com/starknet-io/starknet.js/commit/fabca27a7a3e398030a99cf8d78bffa51cebfe9a)), closes [#1272](https://github.com/starknet-io/starknet.js/issues/1272)
74+
- v7 fee, new methods, tests ([#1337](https://github.com/starknet-io/starknet.js/issues/1337)) ([00743de](https://github.com/starknet-io/starknet.js/commit/00743de2cad5375a558844646f11b4adef15188b))
75+
76+
# [7.0.0-beta.1](https://github.com/starknet-io/starknet.js/compare/v6.24.0-beta.1...v7.0.0-beta.1) (2025-03-04)
77+
78+
- Implement RPC 0.8 and V3 transactions ([#1328](https://github.com/starknet-io/starknet.js/issues/1328)) ([316ae27](https://github.com/starknet-io/starknet.js/commit/316ae2789376368dcffe653ce4817eebf0a63d97))
79+
80+
### BREAKING CHANGES
81+
82+
- Library defaults to RPC 0.8 with the corresponding API changes, dropped RPC 0.6 support
83+
84+
## [6.24.1](https://github.com/starknet-io/starknet.js/compare/v6.24.0...v6.24.1) (2025-03-20)
85+
86+
### Bug Fixes
87+
88+
- repair snip-12 enum type nested dependency ([#1289](https://github.com/starknet-io/starknet.js/issues/1289)) ([1cd4219](https://github.com/starknet-io/starknet.js/commit/1cd4219df5e61a676bc58ba8c8673269695fc2db))
89+
190
# [6.24.0](https://github.com/starknet-io/starknet.js/compare/v6.23.1...v6.24.0) (2025-03-12)
291

392
### Features
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"types": {
3+
"StarknetDomain": [
4+
{ "name": "name", "type": "shortstring" },
5+
{ "name": "version", "type": "shortstring" },
6+
{ "name": "chainId", "type": "shortstring" },
7+
{ "name": "revision", "type": "shortstring" }
8+
],
9+
"Example": [{ "name": "someEnum", "type": "enum", "contains": "EnumA" }],
10+
"EnumA": [
11+
{ "name": "Variant 1", "type": "()" },
12+
{ "name": "Variant 2", "type": "(u128,StructA)" }
13+
],
14+
"StructA": [{ "name": "nestedEnum", "type": "enum", "contains": "EnumB" }],
15+
"EnumB": [
16+
{ "name": "Variant A", "type": "()" },
17+
{ "name": "Variant B", "type": "(StructB*)" }
18+
],
19+
"StructB": [{ "name": "flag", "type": "bool" }]
20+
},
21+
"primaryType": "Example",
22+
"domain": {
23+
"name": "StarkNet Mail",
24+
"version": "1",
25+
"chainId": "1",
26+
"revision": "1"
27+
},
28+
"message": {
29+
"someEnum": {
30+
"Variant 2": [2, { "nestedEnum": { "Variant B": [[{ "flag": true }, { "flag": false }]] } }]
31+
}
32+
}
33+
}

__tests__/WebSocketChannel.test.ts

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import { WebSocket } from 'isows';
2+
3+
import { Provider, WSSubscriptions, WebSocketChannel } from '../src';
4+
import { StarknetChainId } from '../src/global/constants';
5+
import { getTestAccount, getTestProvider, STRKtokenAddress, TEST_WS_URL } from './config/fixtures';
6+
7+
const nodeUrl = 'wss://sepolia-pathfinder-rpc.spaceshard.io/rpc/v0_8';
8+
9+
describe('websocket specific endpoints - pathfinder test', () => {
10+
// account provider
11+
const provider = new Provider(getTestProvider());
12+
const account = getTestAccount(provider);
13+
14+
// websocket
15+
let webSocketChannel: WebSocketChannel;
16+
17+
beforeAll(async () => {
18+
webSocketChannel = new WebSocketChannel({ nodeUrl: TEST_WS_URL });
19+
expect(webSocketChannel.isConnected()).toBe(false);
20+
try {
21+
await webSocketChannel.waitForConnection();
22+
} catch (error: any) {
23+
console.log(error.message);
24+
}
25+
expect(webSocketChannel.isConnected()).toBe(true);
26+
});
27+
28+
afterAll(async () => {
29+
expect(webSocketChannel.isConnected()).toBe(true);
30+
webSocketChannel.disconnect();
31+
await expect(webSocketChannel.waitForDisconnection()).resolves.toBe(WebSocket.CLOSED);
32+
});
33+
34+
test('Test WS Error and edge cases', async () => {
35+
webSocketChannel.disconnect();
36+
37+
// should fail as disconnected
38+
await expect(webSocketChannel.subscribeNewHeads()).rejects.toThrow();
39+
40+
// should reconnect
41+
webSocketChannel.reconnect();
42+
await webSocketChannel.waitForConnection();
43+
44+
// should succeed after reconnection
45+
await expect(webSocketChannel.subscribeNewHeads()).resolves.toEqual(expect.any(Number));
46+
47+
// should fail because already subscribed
48+
await expect(webSocketChannel.subscribeNewHeads()).resolves.toBe(false);
49+
});
50+
51+
test('onUnsubscribe with unsubscribeNewHeads', async () => {
52+
const mockOnUnsubscribe = jest.fn().mockImplementation((subId: number) => {
53+
expect(subId).toEqual(expect.any(Number));
54+
});
55+
webSocketChannel.onUnsubscribe = mockOnUnsubscribe;
56+
57+
await webSocketChannel.subscribeNewHeads();
58+
await expect(webSocketChannel.unsubscribeNewHeads()).resolves.toBe(true);
59+
await expect(webSocketChannel.unsubscribeNewHeads()).rejects.toThrow();
60+
61+
expect(mockOnUnsubscribe).toHaveBeenCalled();
62+
expect(webSocketChannel.subscriptions.has(WSSubscriptions.NEW_HEADS)).toBeFalsy();
63+
});
64+
65+
test('Test subscribeNewHeads', async () => {
66+
await webSocketChannel.subscribeNewHeads();
67+
68+
let i = 0;
69+
webSocketChannel.onNewHeads = async function (data) {
70+
expect(this).toBeInstanceOf(WebSocketChannel);
71+
i += 1;
72+
// TODO : Add data format validation
73+
expect(data.result).toBeDefined();
74+
if (i === 2) {
75+
const status = await webSocketChannel.unsubscribeNewHeads();
76+
expect(status).toBe(true);
77+
}
78+
};
79+
const expectedId = webSocketChannel.subscriptions.get(WSSubscriptions.NEW_HEADS);
80+
const subscriptionId = await webSocketChannel.waitForUnsubscription(expectedId);
81+
expect(subscriptionId).toBe(expectedId);
82+
expect(webSocketChannel.subscriptions.get(WSSubscriptions.NEW_HEADS)).toBe(undefined);
83+
});
84+
85+
test('Test subscribeEvents', async () => {
86+
await webSocketChannel.subscribeEvents();
87+
88+
let i = 0;
89+
webSocketChannel.onEvents = async (data) => {
90+
i += 1;
91+
// TODO : Add data format validation
92+
expect(data.result).toBeDefined();
93+
if (i === 5) {
94+
const status = await webSocketChannel.unsubscribeEvents();
95+
expect(status).toBe(true);
96+
}
97+
};
98+
const expectedId = webSocketChannel.subscriptions.get(WSSubscriptions.EVENTS);
99+
const subscriptionId = await webSocketChannel.waitForUnsubscription(expectedId);
100+
expect(subscriptionId).toBe(expectedId);
101+
expect(webSocketChannel.subscriptions.get(WSSubscriptions.EVENTS)).toBe(undefined);
102+
});
103+
104+
test('Test subscribePendingTransaction', async () => {
105+
await webSocketChannel.subscribePendingTransaction(true);
106+
107+
let i = 0;
108+
webSocketChannel.onPendingTransaction = async (data) => {
109+
i += 1;
110+
// TODO : Add data format validation
111+
expect(data.result).toBeDefined();
112+
if (i === 5) {
113+
const status = await webSocketChannel.unsubscribePendingTransaction();
114+
expect(status).toBe(true);
115+
}
116+
};
117+
const expectedId = webSocketChannel.subscriptions.get(WSSubscriptions.PENDING_TRANSACTION);
118+
const subscriptionId = await webSocketChannel.waitForUnsubscription(expectedId);
119+
expect(subscriptionId).toBe(expectedId);
120+
expect(webSocketChannel.subscriptions.get(WSSubscriptions.PENDING_TRANSACTION)).toBe(undefined);
121+
});
122+
123+
test('Test subscribeTransactionStatus', async () => {
124+
const { transaction_hash } = await account.execute({
125+
contractAddress: STRKtokenAddress,
126+
entrypoint: 'transfer',
127+
calldata: [account.address, '10', '0'],
128+
});
129+
130+
let i = 0;
131+
webSocketChannel.onTransactionStatus = async (data) => {
132+
i += 1;
133+
// TODO : Add data format validation
134+
expect(data.result).toBeDefined();
135+
if (i >= 1) {
136+
const status = await webSocketChannel.unsubscribeTransactionStatus();
137+
expect(status).toBe(true);
138+
}
139+
};
140+
141+
const subid = await webSocketChannel.subscribeTransactionStatus(transaction_hash);
142+
expect(subid).toEqual(expect.any(Number));
143+
const expectedId = webSocketChannel.subscriptions.get(WSSubscriptions.TRANSACTION_STATUS);
144+
const subscriptionId = await webSocketChannel.waitForUnsubscription(expectedId);
145+
expect(subscriptionId).toEqual(expectedId);
146+
expect(webSocketChannel.subscriptions.get(WSSubscriptions.TRANSACTION_STATUS)).toBe(undefined);
147+
});
148+
149+
test('Test subscribeTransactionStatus and block_id', async () => {
150+
const { transaction_hash } = await account.execute({
151+
contractAddress: STRKtokenAddress,
152+
entrypoint: 'transfer',
153+
calldata: [account.address, '10', '0'],
154+
});
155+
156+
let i = 0;
157+
webSocketChannel.onTransactionStatus = async (data) => {
158+
i += 1;
159+
// TODO : Add data format validation
160+
expect(data.result).toBeDefined();
161+
if (i >= 1) {
162+
const status = await webSocketChannel.unsubscribeTransactionStatus();
163+
expect(status).toBe(true);
164+
}
165+
};
166+
167+
const subid = await webSocketChannel.subscribeTransactionStatus(transaction_hash);
168+
expect(subid).toEqual(expect.any(Number));
169+
const expectedId = webSocketChannel.subscriptions.get(WSSubscriptions.TRANSACTION_STATUS);
170+
const subscriptionId = await webSocketChannel.waitForUnsubscription(expectedId);
171+
expect(subscriptionId).toEqual(expectedId);
172+
expect(webSocketChannel.subscriptions.get(WSSubscriptions.TRANSACTION_STATUS)).toBe(undefined);
173+
});
174+
});
175+
176+
describe('websocket regular endpoints - pathfinder test', () => {
177+
let webSocketChannel: WebSocketChannel;
178+
179+
beforeAll(async () => {
180+
webSocketChannel = new WebSocketChannel({ nodeUrl });
181+
expect(webSocketChannel.isConnected()).toBe(false);
182+
const status = await webSocketChannel.waitForConnection();
183+
expect(status).toBe(WebSocket.OPEN);
184+
});
185+
186+
afterAll(async () => {
187+
expect(webSocketChannel.isConnected()).toBe(true);
188+
webSocketChannel.disconnect();
189+
});
190+
191+
test('regular rpc endpoint', async () => {
192+
const response = await webSocketChannel.sendReceiveAny('starknet_chainId');
193+
expect(response).toBe(StarknetChainId.SN_SEPOLIA);
194+
});
195+
});

0 commit comments

Comments
 (0)