starknet 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [3.3.0](https://github.com/seanjameshan/starknet.js/compare/v3.2.0...v3.3.0) (2022-03-08)
2
+
3
+ ### Features
4
+
5
+ - **provider:** add back legacy `invokeFunction` ([dbd00ff](https://github.com/seanjameshan/starknet.js/commit/dbd00ff822456f05df5ba1967d5cd0040b012fc0))
6
+
1
7
  # [3.2.0](https://github.com/seanjameshan/starknet.js/compare/v3.1.0...v3.2.0) (2022-03-04)
2
8
 
3
9
  ### Features
@@ -47,7 +47,7 @@ describe('deploy and test Wallet', () => {
47
47
  });
48
48
  dapp = new Contract(compiledTestDapp.abi, dappResponse.address);
49
49
  expect(dappResponse.code).toBe('TRANSACTION_RECEIVED');
50
- await defaultProvider.waitForTx(dappResponse.transaction_hash);
50
+ await defaultProvider.waitForTransaction(dappResponse.transaction_hash);
51
51
  });
52
52
 
53
53
  test('same wallet address', () => {
@@ -80,7 +80,7 @@ describe('deploy and test Wallet', () => {
80
80
  });
81
81
 
82
82
  expect(code).toBe('TRANSACTION_RECEIVED');
83
- await defaultProvider.waitForTx(transaction_hash);
83
+ await defaultProvider.waitForTransaction(transaction_hash);
84
84
  });
85
85
 
86
86
  test('read balance of wallet after transfer', async () => {
@@ -108,7 +108,7 @@ describe('deploy and test Wallet', () => {
108
108
  );
109
109
 
110
110
  expect(code).toBe('TRANSACTION_RECEIVED');
111
- await defaultProvider.waitForTx(transaction_hash);
111
+ await defaultProvider.waitForTransaction(transaction_hash);
112
112
  });
113
113
 
114
114
  test('execute multiple transactions', async () => {
@@ -126,7 +126,7 @@ describe('deploy and test Wallet', () => {
126
126
  ]);
127
127
 
128
128
  expect(code).toBe('TRANSACTION_RECEIVED');
129
- await defaultProvider.waitForTx(transaction_hash);
129
+ await defaultProvider.waitForTransaction(transaction_hash);
130
130
 
131
131
  const response = await dapp.call('get_number', { user: account.address });
132
132
  expect(toBN(response.number as string).toString()).toStrictEqual('57');
@@ -56,7 +56,7 @@ describe('deploy and test Wallet', () => {
56
56
  amount: '1000',
57
57
  });
58
58
  expect(mintResponse.code).toBe('TRANSACTION_RECEIVED');
59
- await defaultProvider.waitForTx(mintResponse.transaction_hash);
59
+ await defaultProvider.waitForTransaction(mintResponse.transaction_hash);
60
60
  });
61
61
 
62
62
  test('read nonce', async () => {
@@ -96,7 +96,7 @@ describe('deploy and test Wallet', () => {
96
96
 
97
97
  expect(code).toBe('TRANSACTION_RECEIVED');
98
98
 
99
- await defaultProvider.waitForTx(transaction_hash);
99
+ await defaultProvider.waitForTransaction(transaction_hash);
100
100
  });
101
101
 
102
102
  test('read balance of wallet after transfer', async () => {
@@ -19,7 +19,7 @@ describe('class Contract {}', () => {
19
19
  });
20
20
  erc20 = new Contract(compiledErc20.abi, address, defaultProvider);
21
21
  expect(code).toBe('TRANSACTION_RECEIVED');
22
- await defaultProvider.waitForTx(transaction_hash);
22
+ await defaultProvider.waitForTransaction(transaction_hash);
23
23
 
24
24
  // Deploy Multicall
25
25
 
@@ -35,7 +35,7 @@ describe('class Contract {}', () => {
35
35
 
36
36
  expect(m_code).toBe('TRANSACTION_RECEIVED');
37
37
 
38
- await defaultProvider.waitForTx(m_transaction_hash);
38
+ await defaultProvider.waitForTransaction(m_transaction_hash);
39
39
  });
40
40
 
41
41
  test('read initial balance of that account', async () => {
@@ -52,7 +52,7 @@ describe('class Contract {}', () => {
52
52
  });
53
53
  expect(response.code).toBe('TRANSACTION_RECEIVED');
54
54
 
55
- await defaultProvider.waitForTx(response.transaction_hash);
55
+ await defaultProvider.waitForTransaction(response.transaction_hash);
56
56
  });
57
57
 
58
58
  test('read balance after mint of that account', async () => {
@@ -93,7 +93,7 @@ describe('class Contract {}', () => {
93
93
  });
94
94
  contract = new Contract(compiledTypeTransformation.abi, address, defaultProvider);
95
95
  expect(code).toBe('TRANSACTION_RECEIVED');
96
- await defaultProvider.waitForTx(transaction_hash);
96
+ await defaultProvider.waitForTransaction(transaction_hash);
97
97
  });
98
98
 
99
99
  describe('Request Type Transformation', () => {
@@ -1,4 +1,4 @@
1
- import { Abi, AddTransactionResponse, Call, CallContractResponse, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Invocation, TransactionReceipt } from '../types';
1
+ import { Abi, AddTransactionResponse, Call, CallContractResponse, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Invocation, Signature, TransactionReceipt } from '../types';
2
2
  import { BigNumberish } from '../utils/number';
3
3
  import { ProviderInterface } from './interface';
4
4
  import { BlockIdentifier } from './utils';
@@ -109,6 +109,15 @@ export declare class Provider implements ProviderInterface {
109
109
  * @returns a confirmation of sending a transaction on the starknet contract
110
110
  */
111
111
  deployContract(payload: DeployContractPayload, _abi?: Abi): Promise<AddTransactionResponse>;
112
+ /**
113
+ * Invokes a function on starknet
114
+ * @deprecated This method wont be supported as soon as fees are mandatory
115
+ *
116
+ * @param invocation
117
+ * @param _abi - (optional) signature to send along
118
+ * @returns response from addTransaction
119
+ */
120
+ invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
112
121
  /**
113
122
  * Invokes a function on starknet
114
123
  * @deprecated This method wont be supported as soon as fees are mandatory
@@ -119,7 +128,11 @@ export declare class Provider implements ProviderInterface {
119
128
  * @param signature - (optional) signature to send along
120
129
  * @returns response from addTransaction
121
130
  */
122
- invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
131
+ LEGACY_invokeFunction(contractAddress: string, entrypointSelector: string, calldata?: string[], signature?: Signature): Promise<AddTransactionResponse>;
132
+ waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
133
+ /**
134
+ * @deprecated use `waitForTransaction` instead
135
+ */
123
136
  waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
124
137
  }
125
138
  export {};
@@ -371,10 +371,8 @@ var Provider = /** @class */ (function () {
371
371
  * Invokes a function on starknet
372
372
  * @deprecated This method wont be supported as soon as fees are mandatory
373
373
  *
374
- * @param contractAddress - target contract address for invoke
375
- * @param entrypointSelector - target entrypoint selector for
376
- * @param calldata - (optional, default []) calldata
377
- * @param signature - (optional) signature to send along
374
+ * @param invocation
375
+ * @param _abi - (optional) signature to send along
378
376
  * @returns response from addTransaction
379
377
  */
380
378
  Provider.prototype.invokeFunction = function (invocation, _abi) {
@@ -387,7 +385,26 @@ var Provider = /** @class */ (function () {
387
385
  signature: (0, number_1.bigNumberishArrayToDecimalStringArray)((_b = invocation.signature) !== null && _b !== void 0 ? _b : []),
388
386
  });
389
387
  };
390
- Provider.prototype.waitForTx = function (txHash, retryInterval) {
388
+ /**
389
+ * Invokes a function on starknet
390
+ * @deprecated This method wont be supported as soon as fees are mandatory
391
+ *
392
+ * @param contractAddress - target contract address for invoke
393
+ * @param entrypointSelector - target entrypoint selector for
394
+ * @param calldata - (optional, default []) calldata
395
+ * @param signature - (optional) signature to send along
396
+ * @returns response from addTransaction
397
+ */
398
+ Provider.prototype.LEGACY_invokeFunction = function (contractAddress, entrypointSelector, calldata, signature) {
399
+ return this.fetchEndpoint('add_transaction', undefined, {
400
+ type: 'INVOKE_FUNCTION',
401
+ contract_address: contractAddress,
402
+ entry_point_selector: entrypointSelector,
403
+ calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(calldata !== null && calldata !== void 0 ? calldata : []),
404
+ signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature !== null && signature !== void 0 ? signature : []),
405
+ });
406
+ };
407
+ Provider.prototype.waitForTransaction = function (txHash, retryInterval) {
391
408
  if (retryInterval === void 0) { retryInterval = 8000; }
392
409
  return __awaiter(this, void 0, void 0, function () {
393
410
  var onchain, res, message, error;
@@ -426,6 +443,17 @@ var Provider = /** @class */ (function () {
426
443
  });
427
444
  });
428
445
  };
446
+ /**
447
+ * @deprecated use `waitForTransaction` instead
448
+ */
449
+ Provider.prototype.waitForTx = function (txHash, retryInterval) {
450
+ if (retryInterval === void 0) { retryInterval = 8000; }
451
+ return __awaiter(this, void 0, void 0, function () {
452
+ return __generator(this, function (_a) {
453
+ return [2 /*return*/, this.waitForTransaction(txHash, retryInterval)];
454
+ });
455
+ });
456
+ };
429
457
  return Provider;
430
458
  }());
431
459
  exports.Provider = Provider;
@@ -97,5 +97,9 @@ export declare abstract class ProviderInterface {
97
97
  * @returns response from addTransaction
98
98
  */
99
99
  abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;
100
- abstract waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
100
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
101
+ /**
102
+ * @deprecated use `waitForTransaction` instead
103
+ */
104
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
101
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,6 +11,7 @@ import {
11
11
  GetTransactionResponse,
12
12
  GetTransactionStatusResponse,
13
13
  Invocation,
14
+ Signature,
14
15
  TransactionReceipt,
15
16
  } from '../types';
16
17
  import { BigNumberish } from '../utils/number';
@@ -146,6 +147,15 @@ export declare class Provider implements ProviderInterface {
146
147
  * @returns a confirmation of sending a transaction on the starknet contract
147
148
  */
148
149
  deployContract(payload: DeployContractPayload, _abi?: Abi): Promise<AddTransactionResponse>;
150
+ /**
151
+ * Invokes a function on starknet
152
+ * @deprecated This method wont be supported as soon as fees are mandatory
153
+ *
154
+ * @param invocation
155
+ * @param _abi - (optional) signature to send along
156
+ * @returns response from addTransaction
157
+ */
158
+ invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
149
159
  /**
150
160
  * Invokes a function on starknet
151
161
  * @deprecated This method wont be supported as soon as fees are mandatory
@@ -156,7 +166,16 @@ export declare class Provider implements ProviderInterface {
156
166
  * @param signature - (optional) signature to send along
157
167
  * @returns response from addTransaction
158
168
  */
159
- invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
169
+ LEGACY_invokeFunction(
170
+ contractAddress: string,
171
+ entrypointSelector: string,
172
+ calldata?: string[],
173
+ signature?: Signature
174
+ ): Promise<AddTransactionResponse>;
175
+ waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
176
+ /**
177
+ * @deprecated use `waitForTransaction` instead
178
+ */
160
179
  waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
161
180
  }
162
181
  export {};
@@ -550,10 +550,8 @@ var Provider = /** @class */ (function () {
550
550
  * Invokes a function on starknet
551
551
  * @deprecated This method wont be supported as soon as fees are mandatory
552
552
  *
553
- * @param contractAddress - target contract address for invoke
554
- * @param entrypointSelector - target entrypoint selector for
555
- * @param calldata - (optional, default []) calldata
556
- * @param signature - (optional) signature to send along
553
+ * @param invocation
554
+ * @param _abi - (optional) signature to send along
557
555
  * @returns response from addTransaction
558
556
  */
559
557
  Provider.prototype.invokeFunction = function (invocation, _abi) {
@@ -570,7 +568,35 @@ var Provider = /** @class */ (function () {
570
568
  ),
571
569
  });
572
570
  };
573
- Provider.prototype.waitForTx = function (txHash, retryInterval) {
571
+ /**
572
+ * Invokes a function on starknet
573
+ * @deprecated This method wont be supported as soon as fees are mandatory
574
+ *
575
+ * @param contractAddress - target contract address for invoke
576
+ * @param entrypointSelector - target entrypoint selector for
577
+ * @param calldata - (optional, default []) calldata
578
+ * @param signature - (optional) signature to send along
579
+ * @returns response from addTransaction
580
+ */
581
+ Provider.prototype.LEGACY_invokeFunction = function (
582
+ contractAddress,
583
+ entrypointSelector,
584
+ calldata,
585
+ signature
586
+ ) {
587
+ return this.fetchEndpoint('add_transaction', undefined, {
588
+ type: 'INVOKE_FUNCTION',
589
+ contract_address: contractAddress,
590
+ entry_point_selector: entrypointSelector,
591
+ calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(
592
+ calldata !== null && calldata !== void 0 ? calldata : []
593
+ ),
594
+ signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(
595
+ signature !== null && signature !== void 0 ? signature : []
596
+ ),
597
+ });
598
+ };
599
+ Provider.prototype.waitForTransaction = function (txHash, retryInterval) {
574
600
  if (retryInterval === void 0) {
575
601
  retryInterval = 8000;
576
602
  }
@@ -615,6 +641,19 @@ var Provider = /** @class */ (function () {
615
641
  });
616
642
  });
617
643
  };
644
+ /**
645
+ * @deprecated use `waitForTransaction` instead
646
+ */
647
+ Provider.prototype.waitForTx = function (txHash, retryInterval) {
648
+ if (retryInterval === void 0) {
649
+ retryInterval = 8000;
650
+ }
651
+ return __awaiter(this, void 0, void 0, function () {
652
+ return __generator(this, function (_a) {
653
+ return [2 /*return*/, this.waitForTransaction(txHash, retryInterval)];
654
+ });
655
+ });
656
+ };
618
657
  return Provider;
619
658
  })();
620
659
  exports.Provider = Provider;
@@ -122,5 +122,9 @@ export declare abstract class ProviderInterface {
122
122
  * @returns response from addTransaction
123
123
  */
124
124
  abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;
125
- abstract waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
125
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
126
+ /**
127
+ * @deprecated use `waitForTransaction` instead
128
+ */
129
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
126
130
  }
@@ -15,6 +15,7 @@ import {
15
15
  GetTransactionResponse,
16
16
  GetTransactionStatusResponse,
17
17
  Invocation,
18
+ Signature,
18
19
  TransactionReceipt,
19
20
  } from '../types';
20
21
  import { getSelectorFromName } from '../utils/hash';
@@ -317,10 +318,8 @@ export class Provider implements ProviderInterface {
317
318
  * Invokes a function on starknet
318
319
  * @deprecated This method wont be supported as soon as fees are mandatory
319
320
  *
320
- * @param contractAddress - target contract address for invoke
321
- * @param entrypointSelector - target entrypoint selector for
322
- * @param calldata - (optional, default []) calldata
323
- * @param signature - (optional) signature to send along
321
+ * @param invocation
322
+ * @param _abi - (optional) signature to send along
324
323
  * @returns response from addTransaction
325
324
  */
326
325
  public invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse> {
@@ -333,7 +332,32 @@ export class Provider implements ProviderInterface {
333
332
  });
334
333
  }
335
334
 
336
- public async waitForTx(txHash: BigNumberish, retryInterval: number = 8000) {
335
+ /**
336
+ * Invokes a function on starknet
337
+ * @deprecated This method wont be supported as soon as fees are mandatory
338
+ *
339
+ * @param contractAddress - target contract address for invoke
340
+ * @param entrypointSelector - target entrypoint selector for
341
+ * @param calldata - (optional, default []) calldata
342
+ * @param signature - (optional) signature to send along
343
+ * @returns response from addTransaction
344
+ */
345
+ public LEGACY_invokeFunction(
346
+ contractAddress: string,
347
+ entrypointSelector: string,
348
+ calldata?: string[],
349
+ signature?: Signature
350
+ ): Promise<AddTransactionResponse> {
351
+ return this.fetchEndpoint('add_transaction', undefined, {
352
+ type: 'INVOKE_FUNCTION',
353
+ contract_address: contractAddress,
354
+ entry_point_selector: entrypointSelector,
355
+ calldata: bigNumberishArrayToDecimalStringArray(calldata ?? []),
356
+ signature: bigNumberishArrayToDecimalStringArray(signature ?? []),
357
+ });
358
+ }
359
+
360
+ public async waitForTransaction(txHash: BigNumberish, retryInterval: number = 8000) {
337
361
  let onchain = false;
338
362
  await wait(retryInterval);
339
363
 
@@ -355,4 +379,11 @@ export class Provider implements ProviderInterface {
355
379
  }
356
380
  }
357
381
  }
382
+
383
+ /**
384
+ * @deprecated use `waitForTransaction` instead
385
+ */
386
+ public async waitForTx(txHash: BigNumberish, retryInterval: number = 8000) {
387
+ return this.waitForTransaction(txHash, retryInterval);
388
+ }
358
389
  }
@@ -137,5 +137,10 @@ export abstract class ProviderInterface {
137
137
  */
138
138
  public abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;
139
139
 
140
- public abstract waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
140
+ public abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
141
+
142
+ /**
143
+ * @deprecated use `waitForTransaction` instead
144
+ */
145
+ public abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
141
146
  }