Skip to content

Commit

Permalink
Next version (#1043)
Browse files Browse the repository at this point in the history
* 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 <hj923@hotmail.com>

* 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 <tabaktoni@gmail.com>

---------

Co-authored-by: PhilippeR26 <philippe.rostan@yahoo.fr>
Co-authored-by: Philippe ROSTAN <81040730+PhilippeR26@users.noreply.github.com>
Co-authored-by: gregory <10611760+gregoryguillou@users.noreply.github.com>
Co-authored-by: ivpavici <ivan.pavicic@live.com>
Co-authored-by: Petar Penovic <pp@spaceshard.io>
Co-authored-by: Joel Mun <hj923@hotmail.com>
Co-authored-by: Abraham Makovetsky <avimak@gmail.com>
Co-authored-by: Haroune Mohammedi <haroune.mohammedi@quadratic-labs.com>
Co-authored-by: Dhruv Kelawala <dhruvrk2000@gmail.com>
  • Loading branch information
10 people committed Apr 3, 2024
1 parent e74ba31 commit c5c849d
Show file tree
Hide file tree
Showing 39 changed files with 2,098 additions and 2,742 deletions.
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 c5c849d

Please sign in to comment.