Skip to content

Commit 997f282

Browse files
authored
Merge branch 'starknet-io:develop' into calldata-decoder-api-encoder
2 parents 745eb9a + a85d48e commit 997f282

Some content is hidden

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

42 files changed

+2112
-2747
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# [6.7.0](https://github.com/starknet-io/starknet.js/compare/v6.6.6...v6.7.0) (2024-04-03)
2+
3+
### Features
4+
5+
- readme & trigger release ([5341c42](https://github.com/starknet-io/starknet.js/commit/5341c42da8bf5d2f82e4446a60b5e4fdc9c4e2fe))
6+
17
## [6.6.6](https://github.com/starknet-io/starknet.js/compare/v6.6.5...v6.6.6) (2024-03-25)
28

39
### Bug Fixes

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Install starknet with `npm`
4242
# latest official release (main branch)
4343
$ npm install starknet
4444

45-
# or for latest pre-release version (develop branch):
45+
# or for latest pre-release version (develop branch)
4646
$ npm install starknet@next
47+
48+
# or for latest beta release version (beta branch)
49+
$ npm install starknet@beta
4750
```
4851

4952
Import `starknet` and use the [API](https://www.starknetjs.com/docs/API/).

__tests__/account.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ describe('deploy and test Wallet', () => {
370370
expect(balance.low).toStrictEqual(toBigInt(990));
371371
});
372372

373+
test('execute with and without deprecated abis parameter', async () => {
374+
const transaction = {
375+
contractAddress: erc20Address,
376+
entrypoint: 'transfer',
377+
calldata: [erc20.address, '10', '0'],
378+
};
379+
const details = { maxFee: 0n };
380+
381+
await expect(account.execute(transaction, details)).rejects.toThrow(/zero/);
382+
await expect(account.execute(transaction, undefined, details)).rejects.toThrow(/zero/);
383+
});
384+
373385
test('execute with custom nonce', async () => {
374386
const result = await account.getNonce();
375387
const nonce = toBigInt(result);

__tests__/rpcProvider.test.ts

+32-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { StarknetChainId } from '../src/constants';
1818
import { felt, uint256 } from '../src/utils/calldata/cairo';
1919
import { toHexString } from '../src/utils/num';
2020
import {
21+
compiledC1v2,
22+
compiledC1v2Casm,
2123
compiledErc20Echo,
2224
compiledL1L2,
2325
compiledOpenZeppelinAccount,
@@ -109,24 +111,47 @@ describeIfRpc('RPCProvider', () => {
109111
});
110112

111113
describe('Test Estimate message fee', () => {
112-
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
113-
let l1l2ContractAddress: string;
114+
let l1l2ContractCairo0Address: string;
115+
let l1l2ContractCairo1Address: string;
114116

115117
beforeAll(async () => {
116118
const { deploy } = await account.declareAndDeploy({
117119
contract: compiledL1L2,
118120
});
119-
l1l2ContractAddress = deploy.contract_address;
121+
l1l2ContractCairo0Address = deploy.contract_address;
122+
const { deploy: deploy2 } = await account.declareAndDeploy({
123+
contract: compiledC1v2,
124+
casm: compiledC1v2Casm,
125+
});
126+
l1l2ContractCairo1Address = deploy2.contract_address;
120127
});
121128

122-
test('estimate message fee', async () => {
123-
const estimation = await rpcProvider.estimateMessageFee({
129+
test('estimate message fee Cairo 0', async () => {
130+
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
131+
const estimationCairo0 = await rpcProvider.estimateMessageFee({
124132
from_address: L1_ADDRESS,
125-
to_address: l1l2ContractAddress,
133+
to_address: l1l2ContractCairo0Address,
126134
entry_point_selector: 'deposit',
127135
payload: ['556', '123'],
128136
});
129-
expect(estimation).toEqual(
137+
expect(estimationCairo0).toEqual(
138+
expect.objectContaining({
139+
gas_consumed: expect.anything(),
140+
gas_price: expect.anything(),
141+
overall_fee: expect.anything(),
142+
})
143+
);
144+
});
145+
146+
test('estimate message fee Cairo 1', async () => {
147+
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not coded in 20 bytes
148+
const estimationCairo1 = await rpcProvider.estimateMessageFee({
149+
from_address: L1_ADDRESS,
150+
to_address: l1l2ContractCairo1Address,
151+
entry_point_selector: 'increase_bal',
152+
payload: ['100'],
153+
});
154+
expect(estimationCairo1).toEqual(
130155
expect.objectContaining({
131156
gas_consumed: expect.anything(),
132157
gas_price: expect.anything(),

__tests__/utils/ethSigner.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
num,
1414
stark,
1515
} from '../../src';
16+
import { validateAndParseEthAddress } from '../../src/utils/eth';
1617
import { ETransactionVersion } from '../../src/types/api';
1718
import {
1819
compiledDummy1Eth,
@@ -321,4 +322,18 @@ describe('Ethereum signer', () => {
321322
);
322323
});
323324
});
325+
describe('Ethereum address', () => {
326+
test('Eth address format', async () => {
327+
const ethAddr = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not a valid 20 bytes ETh address
328+
expect(validateAndParseEthAddress(ethAddr)).toBe(
329+
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
330+
);
331+
expect(validateAndParseEthAddress(BigInt(ethAddr))).toBe(
332+
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
333+
);
334+
expect(validateAndParseEthAddress(BigInt(ethAddr).toString(10))).toBe(
335+
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
336+
);
337+
});
338+
});
324339
});

0 commit comments

Comments
 (0)