Skip to content

Commit

Permalink
Merge branch 'starknet-io:develop' into calldata-decoder-api-encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanGodara authored Apr 23, 2024
2 parents 745eb9a + a85d48e commit 997f282
Show file tree
Hide file tree
Showing 42 changed files with 2,112 additions and 2,747 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [6.7.0](https://github.com/starknet-io/starknet.js/compare/v6.6.6...v6.7.0) (2024-04-03)

### Features

- readme & trigger release ([5341c42](https://github.com/starknet-io/starknet.js/commit/5341c42da8bf5d2f82e4446a60b5e4fdc9c4e2fe))

## [6.6.6](https://github.com/starknet-io/starknet.js/compare/v6.6.5...v6.6.6) (2024-03-25)

### Bug Fixes
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ Install starknet with `npm`
# latest official release (main branch)
$ npm install starknet

# or for latest pre-release version (develop branch):
# or for latest pre-release version (develop branch)
$ npm install starknet@next

# or for latest beta release version (beta branch)
$ npm install starknet@beta
```

Import `starknet` and use the [API](https://www.starknetjs.com/docs/API/).
Expand Down
12 changes: 12 additions & 0 deletions __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ describe('deploy and test Wallet', () => {
expect(balance.low).toStrictEqual(toBigInt(990));
});

test('execute with and without deprecated abis parameter', async () => {
const transaction = {
contractAddress: erc20Address,
entrypoint: 'transfer',
calldata: [erc20.address, '10', '0'],
};
const details = { maxFee: 0n };

await expect(account.execute(transaction, details)).rejects.toThrow(/zero/);
await expect(account.execute(transaction, undefined, details)).rejects.toThrow(/zero/);
});

test('execute with custom nonce', async () => {
const result = await account.getNonce();
const nonce = toBigInt(result);
Expand Down
39 changes: 32 additions & 7 deletions __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { StarknetChainId } from '../src/constants';
import { felt, uint256 } from '../src/utils/calldata/cairo';
import { toHexString } from '../src/utils/num';
import {
compiledC1v2,
compiledC1v2Casm,
compiledErc20Echo,
compiledL1L2,
compiledOpenZeppelinAccount,
Expand Down Expand Up @@ -109,24 +111,47 @@ describeIfRpc('RPCProvider', () => {
});

describe('Test Estimate message fee', () => {
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
let l1l2ContractAddress: string;
let l1l2ContractCairo0Address: string;
let l1l2ContractCairo1Address: string;

beforeAll(async () => {
const { deploy } = await account.declareAndDeploy({
contract: compiledL1L2,
});
l1l2ContractAddress = deploy.contract_address;
l1l2ContractCairo0Address = deploy.contract_address;
const { deploy: deploy2 } = await account.declareAndDeploy({
contract: compiledC1v2,
casm: compiledC1v2Casm,
});
l1l2ContractCairo1Address = deploy2.contract_address;
});

test('estimate message fee', async () => {
const estimation = await rpcProvider.estimateMessageFee({
test('estimate message fee Cairo 0', async () => {
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
const estimationCairo0 = await rpcProvider.estimateMessageFee({
from_address: L1_ADDRESS,
to_address: l1l2ContractAddress,
to_address: l1l2ContractCairo0Address,
entry_point_selector: 'deposit',
payload: ['556', '123'],
});
expect(estimation).toEqual(
expect(estimationCairo0).toEqual(
expect.objectContaining({
gas_consumed: expect.anything(),
gas_price: expect.anything(),
overall_fee: expect.anything(),
})
);
});

test('estimate message fee Cairo 1', async () => {
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not coded in 20 bytes
const estimationCairo1 = await rpcProvider.estimateMessageFee({
from_address: L1_ADDRESS,
to_address: l1l2ContractCairo1Address,
entry_point_selector: 'increase_bal',
payload: ['100'],
});
expect(estimationCairo1).toEqual(
expect.objectContaining({
gas_consumed: expect.anything(),
gas_price: expect.anything(),
Expand Down
15 changes: 15 additions & 0 deletions __tests__/utils/ethSigner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
num,
stark,
} from '../../src';
import { validateAndParseEthAddress } from '../../src/utils/eth';
import { ETransactionVersion } from '../../src/types/api';
import {
compiledDummy1Eth,
Expand Down Expand Up @@ -321,4 +322,18 @@ describe('Ethereum signer', () => {
);
});
});
describe('Ethereum address', () => {
test('Eth address format', async () => {
const ethAddr = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165'; // not a valid 20 bytes ETh address
expect(validateAndParseEthAddress(ethAddr)).toBe(
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
);
expect(validateAndParseEthAddress(BigInt(ethAddr))).toBe(
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
);
expect(validateAndParseEthAddress(BigInt(ethAddr).toString(10))).toBe(
'0x008359e4b0152ed5a731162d3c7b0d8d56edb165'
);
});
});
});
Loading

0 comments on commit 997f282

Please sign in to comment.