Skip to content

Commit c5c849d

Browse files
tabaktoniPhilippeR26gregoryguillouivpavicipenovicp
authored
Next version (#1043)
* test: eth signer * test: move secp256k1Point tests in a dedicated test file * feat: helper for transaction receipt * simplify extends for account class * feat: handling of cairo u512 type * refactor: change name of variable : GetTxReceiptResponseWithoutHelper * fix: double lines for same imports * fix: solve an error in validate.ts initiated by pr 1007 * fix: correction of a word in guide * docs: validateChecksumAddress * fix: jsdoc correction * docs: add tsdoc in utils/address.ts * test: add extra fees * fix: estimateFeeBulk include skipValidate in accountInvocationsFactory * feat: add type guard to receipt response status methods * fix: repair i128 typed data encoding and add typed data range checks * chore: update left over StarkNet casing * feat: bundle resolution, module, type import for walletacc * feat: bundle resolution, module, type import for walletaccount * chore: fix connect import * chore: add get-starknet-core next as dependencie * chore: import fix * fix: estimateMessageFee - eth address format (#1040) * fix: estimatemessagefee eth address format * fix: implement requests * docs: small guides cleanup (#1048) * docs: fix nodeUrl code typo (#1046) * docs: small guides cleanup --------- Co-authored-by: Joel Mun <[email protected]> * fix(RpcProvider): allow client to provide `specVersion` in 0.7 provider this saves an extra call on RPC for optionally-known information (like the `chainId` case). also fixed speck -> spec typo * fix: remove abis parameter from signer and account execute * feat: configure u512 and Secp256k1Point for abiwan * chore: bump dependencies * chore: expose data gas consumed and data gas price for 0.7 rpc * refactor: create wallet namespace * refactor: create wallet namespace * fix: change name to connect.ts --------- Co-authored-by: Toni Tabak <[email protected]> --------- Co-authored-by: PhilippeR26 <[email protected]> Co-authored-by: Philippe ROSTAN <[email protected]> Co-authored-by: gregory <[email protected]> Co-authored-by: ivpavici <[email protected]> Co-authored-by: Petar Penovic <[email protected]> Co-authored-by: Joel Mun <[email protected]> Co-authored-by: Abraham Makovetsky <[email protected]> Co-authored-by: Haroune Mohammedi <[email protected]> Co-authored-by: Dhruv Kelawala <[email protected]>
1 parent e74ba31 commit c5c849d

39 files changed

+2098
-2742
lines changed

__tests__/account.test.ts

Lines changed: 12 additions & 0 deletions
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

Lines changed: 32 additions & 7 deletions
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

Lines changed: 15 additions & 0 deletions
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)