Skip to content

Commit 9ecde1a

Browse files
authored
Merge pull request #1360 from starknet-io/feat/drop-deprecated
feat: prune deprecated functionalities
2 parents d110055 + cbd18f5 commit 9ecde1a

28 files changed

+77
-361
lines changed

__tests__/account.starknetId.test.ts

+42-48
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,36 @@ describe('deploy and test Wallet', () => {
4646
});
4747
multicallAddress = multicallResponse.deploy.contract_address;
4848

49-
const { transaction_hash } = await account.execute(
50-
[
51-
{
52-
contractAddress: devnetERC20Address,
53-
entrypoint: 'approve',
54-
calldata: [namingAddress, 0, 1], // Price of domain
55-
},
56-
{
57-
contractAddress: identityAddress,
58-
entrypoint: 'mint',
59-
calldata: ['1'], // TokenId
60-
},
61-
{
62-
contractAddress: namingAddress,
63-
entrypoint: 'buy',
64-
calldata: [
65-
'1', // Starknet id linked
66-
'1499554868251', // Domain encoded "fricoben"
67-
'62', // days
68-
'0', // resolver
69-
0, // sponsor
70-
0,
71-
0,
72-
],
73-
},
74-
{
75-
contractAddress: identityAddress,
76-
entrypoint: 'set_main_id',
77-
calldata: ['1'],
78-
},
79-
],
80-
undefined
81-
);
49+
const { transaction_hash } = await account.execute([
50+
{
51+
contractAddress: devnetERC20Address,
52+
entrypoint: 'approve',
53+
calldata: [namingAddress, 0, 1], // Price of domain
54+
},
55+
{
56+
contractAddress: identityAddress,
57+
entrypoint: 'mint',
58+
calldata: ['1'], // TokenId
59+
},
60+
{
61+
contractAddress: namingAddress,
62+
entrypoint: 'buy',
63+
calldata: [
64+
'1', // Starknet id linked
65+
'1499554868251', // Domain encoded "fricoben"
66+
'62', // days
67+
'0', // resolver
68+
0, // sponsor
69+
0,
70+
0,
71+
],
72+
},
73+
{
74+
contractAddress: identityAddress,
75+
entrypoint: 'set_main_id',
76+
calldata: ['1'],
77+
},
78+
]);
8279

8380
await provider.waitForTransaction(transaction_hash);
8481
});
@@ -102,21 +99,18 @@ describe('deploy and test Wallet', () => {
10299
describe('Test getStarkProfile', () => {
103100
beforeAll(async () => {
104101
// Add verifier data
105-
const { transaction_hash: transaction_hash_verifier } = await account.execute(
106-
[
107-
{
108-
contractAddress: identityAddress,
109-
entrypoint: 'set_verifier_data',
110-
calldata: [
111-
'1', // token_id
112-
shortString.encodeShortString('discord'), // field
113-
123, // value
114-
0,
115-
],
116-
},
117-
],
118-
undefined
119-
);
102+
const { transaction_hash: transaction_hash_verifier } = await account.execute([
103+
{
104+
contractAddress: identityAddress,
105+
entrypoint: 'set_verifier_data',
106+
calldata: [
107+
'1', // token_id
108+
shortString.encodeShortString('discord'), // field
109+
123, // value
110+
0,
111+
],
112+
},
113+
]);
120114
await provider.waitForTransaction(transaction_hash_verifier);
121115
});
122116

__tests__/account.test.ts

+10-32
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
DeclareDeployUDCResponse,
88
Provider,
99
ProviderInterface,
10-
RpcError,
1110
TransactionType,
1211
cairo,
1312
constants,
@@ -363,29 +362,6 @@ describe('deploy and test Wallet', () => {
363362
expect(balance.low).toStrictEqual(toBigInt(990));
364363
});
365364

366-
test('execute with and without deprecated abis parameter', async () => {
367-
const transaction = {
368-
contractAddress: erc20Address,
369-
entrypoint: 'transfer',
370-
calldata: [erc20.address, '10', '0'],
371-
};
372-
const details: Parameters<(typeof account)['execute']>[2] = { nonce: 0 };
373-
374-
let error1: RpcError | undefined;
375-
// eslint-disable-next-line no-return-assign
376-
await account.execute(transaction, details).catch((e) => (error1 = e));
377-
expect(error1).toBeDefined();
378-
expect(error1).toBeInstanceOf(RpcError);
379-
expect(error1!.isType('TRANSACTION_EXECUTION_ERROR')).toBe(true);
380-
381-
let error2: RpcError | undefined;
382-
// eslint-disable-next-line no-return-assign
383-
await account.execute(transaction, undefined, details).catch((e) => (error2 = e));
384-
expect(error2).toBeDefined();
385-
expect(error2).toBeInstanceOf(RpcError);
386-
expect(error2!.isType('TRANSACTION_EXECUTION_ERROR')).toBe(true);
387-
});
388-
389365
test('execute with custom nonce', async () => {
390366
const result = await account.getNonce();
391367
const nonce = toBigInt(result);
@@ -395,7 +371,6 @@ describe('deploy and test Wallet', () => {
395371
entrypoint: 'transfer',
396372
calldata: [account.address, '10', '0'],
397373
},
398-
undefined,
399374
{ nonce }
400375
);
401376

@@ -433,14 +408,14 @@ describe('deploy and test Wallet', () => {
433408
const r2 = toBigInt(r) + 123n;
434409

435410
const signature2 = new Signature(toBigInt(r2.toString()), toBigInt(s));
436-
437411
if (!signature2) return;
438412

439-
const verifMessageResponse: boolean = await account.verifyMessage(
413+
const verifyMessageResponse: boolean = await account.verifyMessageInStarknet(
440414
typedDataExample,
441-
signature2
415+
signature2,
416+
account.address
442417
);
443-
expect(verifMessageResponse).toBe(false);
418+
expect(verifyMessageResponse).toBe(false);
444419

445420
const wrongAccount = new Account(
446421
provider,
@@ -449,14 +424,17 @@ describe('deploy and test Wallet', () => {
449424
undefined,
450425
TEST_TX_VERSION
451426
); // non existing account
452-
await expect(wrongAccount.verifyMessage(typedDataExample, signature2)).rejects.toThrow();
427+
await expect(
428+
wrongAccount.verifyMessageInStarknet(typedDataExample, signature2, wrongAccount.address)
429+
).rejects.toThrow();
453430
});
454431

455432
test('sign and verify message', async () => {
456433
const signature = await account.signMessage(typedDataExample);
457-
const verifMessageResponse: boolean = await account.verifyMessage(
434+
const verifMessageResponse: boolean = await account.verifyMessageInStarknet(
458435
typedDataExample,
459-
signature
436+
signature,
437+
account.address
460438
);
461439
expect(verifMessageResponse).toBe(true);
462440
});

__tests__/cairov24onward.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ describe('Cairo v2.4 onwards', () => {
176176

177177
test('Tuple ((u256,(u16,Order2)), u8)', async () => {
178178
type Order2 = {
179-
p1: num.BigNumberish;
180-
p2: num.BigNumberish[];
179+
p1: BigNumberish;
180+
p2: BigNumberish[];
181181
};
182182
const myOrder2: Order2 = { p1: 100, p2: [5, 6, 7] };
183183
const calldata9 = myCallData.compile('get_tuple9', {

__tests__/rpcProvider.test.ts

-5
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,6 @@ describeIfRpc('RPCProvider', () => {
326326
expect(transaction).toHaveProperty('transaction_hash');
327327
});
328328

329-
test('getPendingTransactions', async () => {
330-
const transactions = await rpcProvider.getPendingTransactions();
331-
expect(Array.isArray(transactions)).toBe(true);
332-
});
333-
334329
test('getSyncingStats', async () => {
335330
const syncingStats = await rpcProvider.getSyncingStats();
336331
expect(syncingStats).toMatchSchemaRef('GetSyncingStatsResponse');

__tests__/transactionReceipt.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Transaction receipt utility - RPC 0.7 - V2', () => {
3333

3434
test('test for Success variant', async () => {
3535
const myCall: Call = contract.populate('test_fail', { p1: 100 });
36-
const res = await account.execute(myCall, undefined, { maxFee: 1 * 10 ** 15 }); // maxFee needed to not throw error in getEstimateFee
36+
const res = await account.execute(myCall, { maxFee: 1 * 10 ** 15 }); // maxFee needed to not throw error in getEstimateFee
3737
const txR = await provider.waitForTransaction(res.transaction_hash);
3838
expect(txR.value).toHaveProperty('execution_status', TransactionExecutionStatus.SUCCEEDED);
3939
expect(txR.statusReceipt).toBe('success');
@@ -54,7 +54,7 @@ describe('Transaction receipt utility - RPC 0.7 - V2', () => {
5454

5555
test('test for Reverted variant', async () => {
5656
const myCall: Call = contract.populate('test_fail', { p1: 10 }); // reverted if not 100
57-
const res = await account.execute(myCall, undefined, { maxFee: 1 * 10 ** 15 }); // maxFee needed to not throw error in getEstimateFee
57+
const res = await account.execute(myCall, { maxFee: 1 * 10 ** 15 }); // maxFee needed to not throw error in getEstimateFee
5858
const txR = await provider.waitForTransaction(res.transaction_hash);
5959
expect(txR.value).toHaveProperty('execution_status', TransactionExecutionStatus.REVERTED);
6060
expect(txR.statusReceipt).toBe('reverted');

__tests__/utils/ellipticalCurve.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { constants, ec } from '../../src';
22
import { StarknetChainId } from '../../src/global/constants';
33
import { computeHashOnElements } from '../../src/utils/hash';
44
import { calculateTransactionHash } from '../../src/utils/hash/transactionHash/v2';
5-
import { fromCallsToExecuteCalldataWithNonce } from '../../src/utils/transaction';
5+
import { fromCallsToExecuteCalldata } from '../../src/utils/transaction';
66

77
test('getKeyPair()', () => {
88
const privateKey = '0x019800ea6a9a73f94aee6a3d2edf018fc770443e90c7ba121e8303ec6b349279';
@@ -46,7 +46,7 @@ test('hashMessage()', () => {
4646
];
4747
const nonce = '3';
4848
const maxFee = '0';
49-
const calldata = fromCallsToExecuteCalldataWithNonce(transactions, nonce);
49+
const calldata = [...fromCallsToExecuteCalldata(transactions), nonce];
5050

5151
const hashMsg = calculateTransactionHash(
5252
account,

__tests__/utils/ethSigner.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ describe('Ethereum signer', () => {
286286
cairo.uint256(1 * 10 ** 4),
287287
]);
288288
const feeTransfer = await ethAccount.estimateInvokeFee(txCallData);
289-
const respTransfer = await ethAccount.execute(txCallData, undefined, {
289+
const respTransfer = await ethAccount.execute(txCallData, {
290290
resourceBounds: {
291291
l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' },
292292
l1_gas: {

__tests__/utils/merkle.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { BigNumberish } from '../../src';
12
import { computePedersenHash, computePoseidonHash } from '../../src/utils/hash';
23
import { MerkleTree, proofMerklePath } from '../../src/utils/merkle';
3-
import { BigNumberish } from '../../src/utils/num';
44

55
type RawHashMethod = (a: BigNumberish, b: BigNumberish) => string;
66

__tests__/utils/transaction.test.ts

+2-39
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
1-
import { Call, CallStruct } from '../../src/types';
2-
import {
3-
fromCallsToExecuteCalldata_cairo1,
4-
transformCallsToMulticallArrays_cairo1,
5-
} from '../../src/utils/transaction';
6-
7-
describe('transformCallsToMulticallArrays_cairo1', () => {
8-
it('should return an empty array when given an empty input', () => {
9-
expect(transformCallsToMulticallArrays_cairo1([])).toEqual([]);
10-
});
11-
12-
it('should transform a list of calls into an array of call structs', () => {
13-
const calls: Call[] = [
14-
{
15-
contractAddress: '0x123',
16-
entrypoint: 'transfer',
17-
calldata: [10],
18-
},
19-
{
20-
contractAddress: '0x456',
21-
entrypoint: 'mint',
22-
calldata: ['0x2000', BigInt(10000000)],
23-
},
24-
];
25-
const expected: CallStruct[] = [
26-
{
27-
to: '291',
28-
selector: '232670485425082704932579856502088130646006032362877466777181098476241604910',
29-
calldata: ['10'],
30-
},
31-
{
32-
to: '1110',
33-
selector: '1329909728320632088402217562277154056711815095720684343816173432540100887380',
34-
calldata: ['8192', '10000000'],
35-
},
36-
];
37-
expect(transformCallsToMulticallArrays_cairo1(calls)).toEqual(expected);
38-
});
39-
});
1+
import { Call } from '../../src/types';
2+
import { fromCallsToExecuteCalldata_cairo1 } from '../../src/utils/transaction';
403

414
describe('fromCallsToExecuteCalldata_cairo1', () => {
425
it('should return an array with a length of one when given an empty input', () => {

__tests__/utils/typedData.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
Account,
1313
BigNumberish,
1414
StarknetDomain,
15+
TypedDataRevision,
1516
num,
1617
stark,
1718
typedData,
@@ -22,7 +23,6 @@ import { PRIME } from '../../src/global/constants';
2223
import { getSelectorFromName } from '../../src/utils/hash';
2324
import { MerkleTree } from '../../src/utils/merkle';
2425
import {
25-
TypedDataRevision,
2626
encodeType,
2727
encodeValue,
2828
getMessageHash,

__tests__/utils/uint256.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { cairo, uint256 as u256 } from '../../src';
1+
import { cairo, uint256 as u256, UINT_128_MAX, UINT_256_MAX } from '../../src';
22

3-
const { bnToUint256, UINT_128_MAX, UINT_256_MAX, uint256ToBN } = u256;
3+
const { bnToUint256, uint256ToBN } = u256;
44

55
describe('cairo uint256', () => {
66
test('bnToUint256 should not convert -1 from BN to uint256 hex-string struct', () => {

__tests__/utils/utils.test.ts

-10
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ describe('cleanHex()', () => {
4545
});
4646
});
4747

48-
describe('makeAddress()', () => {
49-
test('test on eth address', () => {
50-
const ethAddress = '0xdFD0F27FCe99b50909de0bDD328Aed6eAbe76BC5';
51-
52-
const starkAddress = stark.makeAddress(ethAddress);
53-
54-
expect(starkAddress).toBe('0xdfd0f27fce99b50909de0bdd328aed6eabe76bc5');
55-
});
56-
});
57-
5848
describe('getSelectorFromName()', () => {
5949
test('hash works for value="test"', () => {
6050
expect(hash.getSelectorFromName('test')).toBe(

0 commit comments

Comments
 (0)