starknet 3.13.0 → 3.14.1
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 +22 -0
- package/__tests__/provider.test.ts +46 -13
- package/account/default.d.ts +2 -9
- package/account/default.js +1 -0
- package/account/interface.d.ts +5 -3
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/contract/default.d.ts +1 -1
- package/dist/account/default.d.ts +2 -6
- package/dist/account/default.js +2 -0
- package/dist/account/interface.d.ts +3 -3
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/contract/default.d.ts +1 -1
- package/dist/provider/default.d.ts +10 -3
- package/dist/provider/default.js +21 -2
- package/dist/provider/interface.d.ts +8 -0
- package/dist/types/account.d.ts +6 -0
- package/dist/types/api.d.ts +38 -9
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/lib.d.ts +4 -1
- package/package.json +1 -1
- package/provider/default.d.ts +10 -2
- package/provider/default.js +22 -2
- package/provider/interface.d.ts +8 -0
- package/src/account/default.ts +3 -6
- package/src/account/interface.ts +5 -3
- package/src/constants.ts +1 -0
- package/src/provider/default.ts +29 -4
- package/src/provider/interface.ts +8 -0
- package/src/types/account.ts +7 -0
- package/src/types/api.ts +45 -9
- package/src/types/index.ts +1 -0
- package/src/types/lib.ts +5 -1
- package/types/account.d.ts +6 -0
- package/types/api.d.ts +45 -9
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/lib.d.ts +4 -1
- package/www/docs/API/provider.md +20 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [3.14.1](https://github.com/0xs34n/starknet.js/compare/v3.14.0...v3.14.1) (2022-06-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- update api typings ([44796af](https://github.com/0xs34n/starknet.js/commit/44796af4849b6bab3d99065bb1e1948e4ea0b55e))
|
|
6
|
+
|
|
7
|
+
# [3.14.0](https://github.com/0xs34n/starknet.js/compare/v3.13.1...v3.14.0) (2022-06-15)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- remove redundant \_abi from declareContract() ([53d6578](https://github.com/0xs34n/starknet.js/commit/53d6578b932ed6046b5e0df83d748673d7efc3d5))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- support contract declaration API introduced at SN 0.9.0 ([ca6203f](https://github.com/0xs34n/starknet.js/commit/ca6203f93471d7fb421d580e07d6de7c183e40f3))
|
|
16
|
+
|
|
17
|
+
## [3.13.1](https://github.com/0xs34n/starknet.js/compare/v3.13.0...v3.13.1) (2022-06-14)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- account estimate fee interface ([51e8cf6](https://github.com/0xs34n/starknet.js/commit/51e8cf6858acd5aed003f8f1c4d755088684f134))
|
|
22
|
+
|
|
1
23
|
# [3.13.0](https://github.com/0xs34n/starknet.js/compare/v3.12.3...v3.13.0) (2022-06-14)
|
|
2
24
|
|
|
3
25
|
### Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defaultProvider, stark } from '../src';
|
|
2
2
|
import { toBN } from '../src/utils/number';
|
|
3
|
-
import { compiledArgentAccount } from './fixtures';
|
|
3
|
+
import { compiledArgentAccount, compiledErc20 } from './fixtures';
|
|
4
4
|
|
|
5
5
|
const { compileCalldata } = stark;
|
|
6
6
|
|
|
@@ -85,20 +85,43 @@ describe('defaultProvider', () => {
|
|
|
85
85
|
)
|
|
86
86
|
).resolves.not.toThrow();
|
|
87
87
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
|
|
89
|
+
test('getTransaction() - successful transaction', async () => {
|
|
90
|
+
const transaction = await defaultProvider.getTransaction(
|
|
91
|
+
'0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(transaction).not.toHaveProperty('transaction_failure_reason');
|
|
95
|
+
|
|
96
|
+
expect(transaction.transaction).toHaveProperty('transaction_hash');
|
|
97
|
+
|
|
98
|
+
return expect(transaction.status).not.toEqual('REJECTED');
|
|
94
99
|
});
|
|
95
100
|
|
|
96
|
-
test('
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
).
|
|
101
|
+
test('getTransaction() - failed transaction', async () => {
|
|
102
|
+
const transaction = await defaultProvider.getTransaction(
|
|
103
|
+
'0x698e60db2bae3ef8d5fafda10ff83b6ba634351aa1f4fcf8455ec0cffa738d9'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(transaction).toHaveProperty('transaction_failure_reason');
|
|
107
|
+
|
|
108
|
+
return expect(transaction.status).toEqual('REJECTED');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('getTransactionReceipt() - successful transaction', async () => {
|
|
112
|
+
const transactionReceipt = await defaultProvider.getTransactionReceipt(
|
|
113
|
+
'0x18c49389193b40e178dfc9f2f595a7c79a7a55639e9951d956329f2ce6cfd4f'
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return expect(transactionReceipt).toHaveProperty('actual_fee');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('getTransactionReceipt() - failed transaction', async () => {
|
|
120
|
+
const transactionReceipt = await defaultProvider.getTransactionReceipt(
|
|
121
|
+
'0x698e60db2bae3ef8d5fafda10ff83b6ba634351aa1f4fcf8455ec0cffa738d9'
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return expect(transactionReceipt).not.toHaveProperty('actual_fee');
|
|
102
125
|
});
|
|
103
126
|
|
|
104
127
|
test('callContract()', () => {
|
|
@@ -123,6 +146,16 @@ describe('defaultProvider', () => {
|
|
|
123
146
|
});
|
|
124
147
|
|
|
125
148
|
describe('addTransaction()', () => {
|
|
149
|
+
test('declareContract()', async () => {
|
|
150
|
+
const response = await defaultProvider.declareContract({
|
|
151
|
+
contract: compiledErc20,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(response.code).toBe('TRANSACTION_RECEIVED');
|
|
155
|
+
expect(response.transaction_hash).toBeDefined();
|
|
156
|
+
expect(response.class_hash).toBeDefined();
|
|
157
|
+
});
|
|
158
|
+
|
|
126
159
|
test('deployContract()', async () => {
|
|
127
160
|
const response = await defaultProvider.deployContract({
|
|
128
161
|
contract: compiledArgentAccount,
|
package/account/default.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Provider, ProviderInterface } from '../provider';
|
|
2
|
-
import { BlockIdentifier } from '../provider/utils';
|
|
3
2
|
import { SignerInterface } from '../signer';
|
|
4
3
|
import {
|
|
5
4
|
Abi,
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
Signature,
|
|
11
10
|
Transaction,
|
|
12
11
|
} from '../types';
|
|
13
|
-
import { EstimateFee } from '../types/account';
|
|
12
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
14
13
|
import { BigNumberish } from '../utils/number';
|
|
15
14
|
import { TypedData } from '../utils/typedData';
|
|
16
15
|
import { AccountInterface } from './interface';
|
|
@@ -25,13 +24,7 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
25
24
|
getNonce(): Promise<string>;
|
|
26
25
|
estimateFee(
|
|
27
26
|
calls: Call | Call[],
|
|
28
|
-
{
|
|
29
|
-
nonce: providedNonce,
|
|
30
|
-
blockIdentifier,
|
|
31
|
-
}?: {
|
|
32
|
-
nonce?: BigNumberish;
|
|
33
|
-
blockIdentifier?: BlockIdentifier;
|
|
34
|
-
}
|
|
27
|
+
{ nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails
|
|
35
28
|
): Promise<EstimateFee>;
|
|
36
29
|
/**
|
|
37
30
|
* Invoke execute function in account contract
|
package/account/default.js
CHANGED
|
@@ -424,6 +424,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
424
424
|
switch (_a.label) {
|
|
425
425
|
case 0:
|
|
426
426
|
if (transaction.type === 'DEPLOY') throw new Error('No DEPLOYS');
|
|
427
|
+
if (transaction.type === 'DECLARE') throw new Error('No DECLARES');
|
|
427
428
|
(0,
|
|
428
429
|
minimalistic_assert_1.default)(!transaction.signature, "Adding signatures to a signer transaction currently isn't supported");
|
|
429
430
|
if (!transaction.nonce) return [3 /*break*/, 1];
|
package/account/interface.d.ts
CHANGED
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
AddTransactionResponse,
|
|
6
6
|
Call,
|
|
7
7
|
DeployContractPayload,
|
|
8
|
-
Invocation,
|
|
9
8
|
InvocationsDetails,
|
|
10
9
|
Signature,
|
|
11
10
|
} from '../types';
|
|
12
|
-
import { EstimateFee } from '../types/account';
|
|
11
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
13
12
|
import { BigNumberish } from '../utils/number';
|
|
14
13
|
import { TypedData } from '../utils/typedData/types';
|
|
15
14
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
@@ -40,7 +39,10 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
40
39
|
*
|
|
41
40
|
* @returns response from addTransaction
|
|
42
41
|
*/
|
|
43
|
-
abstract estimateFee(
|
|
42
|
+
abstract estimateFee(
|
|
43
|
+
calls: Call | Call[],
|
|
44
|
+
estimateFeeDetails?: EstimateFeeDetails
|
|
45
|
+
): Promise<EstimateFee>;
|
|
44
46
|
/**
|
|
45
47
|
* Invoke execute function in account contract
|
|
46
48
|
*
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -37,6 +37,7 @@ var StarknetChainId;
|
|
|
37
37
|
})((StarknetChainId = exports.StarknetChainId || (exports.StarknetChainId = {})));
|
|
38
38
|
var TransactionHashPrefix;
|
|
39
39
|
(function (TransactionHashPrefix) {
|
|
40
|
+
TransactionHashPrefix['DECLARE'] = '0x6465636c617265';
|
|
40
41
|
TransactionHashPrefix['DEPLOY'] = '0x6465706c6f79';
|
|
41
42
|
TransactionHashPrefix['INVOKE'] = '0x696e766f6b65';
|
|
42
43
|
TransactionHashPrefix['L1_HANDLER'] = '0x6c315f68616e646c6572';
|
package/contract/default.d.ts
CHANGED
|
@@ -148,6 +148,6 @@ export declare class Contract implements ContractInterface {
|
|
|
148
148
|
blockIdentifier?: BlockIdentifier;
|
|
149
149
|
}
|
|
150
150
|
): Promise<Result>;
|
|
151
|
-
estimate(method: string, args?: Array<any>): Promise<import('../types
|
|
151
|
+
estimate(method: string, args?: Array<any>): Promise<import('../types').EstimateFee>;
|
|
152
152
|
populate(method: string, args?: Array<any>): Invocation;
|
|
153
153
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Provider, ProviderInterface } from '../provider';
|
|
2
|
-
import { BlockIdentifier } from '../provider/utils';
|
|
3
2
|
import { SignerInterface } from '../signer';
|
|
4
3
|
import { Abi, AddTransactionResponse, Call, InvocationsDetails, KeyPair, Signature, Transaction } from '../types';
|
|
5
|
-
import { EstimateFee } from '../types/account';
|
|
4
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
6
5
|
import { BigNumberish } from '../utils/number';
|
|
7
6
|
import { TypedData } from '../utils/typedData';
|
|
8
7
|
import { AccountInterface } from './interface';
|
|
@@ -11,10 +10,7 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
11
10
|
signer: SignerInterface;
|
|
12
11
|
constructor(provider: ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
|
|
13
12
|
getNonce(): Promise<string>;
|
|
14
|
-
estimateFee(calls: Call | Call[], { nonce: providedNonce, blockIdentifier
|
|
15
|
-
nonce?: BigNumberish;
|
|
16
|
-
blockIdentifier?: BlockIdentifier;
|
|
17
|
-
}): Promise<EstimateFee>;
|
|
13
|
+
estimateFee(calls: Call | Call[], { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
18
14
|
/**
|
|
19
15
|
* Invoke execute function in account contract
|
|
20
16
|
*
|
package/dist/account/default.js
CHANGED
|
@@ -267,6 +267,8 @@ var Account = /** @class */ (function (_super) {
|
|
|
267
267
|
case 0:
|
|
268
268
|
if (transaction.type === 'DEPLOY')
|
|
269
269
|
throw new Error('No DEPLOYS');
|
|
270
|
+
if (transaction.type === 'DECLARE')
|
|
271
|
+
throw new Error('No DECLARES');
|
|
270
272
|
(0, minimalistic_assert_1.default)(!transaction.signature, "Adding signatures to a signer transaction currently isn't supported");
|
|
271
273
|
if (!transaction.nonce) return [3 /*break*/, 1];
|
|
272
274
|
nonceBn = (0, number_1.toBN)(transaction.nonce);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProviderInterface } from '../provider';
|
|
2
2
|
import { SignerInterface } from '../signer';
|
|
3
|
-
import { Abi, AddTransactionResponse, Call, DeployContractPayload,
|
|
4
|
-
import { EstimateFee } from '../types/account';
|
|
3
|
+
import { Abi, AddTransactionResponse, Call, DeployContractPayload, InvocationsDetails, Signature } from '../types';
|
|
4
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
5
5
|
import { BigNumberish } from '../utils/number';
|
|
6
6
|
import { TypedData } from '../utils/typedData/types';
|
|
7
7
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
@@ -29,7 +29,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
29
29
|
*
|
|
30
30
|
* @returns response from addTransaction
|
|
31
31
|
*/
|
|
32
|
-
abstract estimateFee(
|
|
32
|
+
abstract estimateFee(calls: Call | Call[], estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
33
33
|
/**
|
|
34
34
|
* Invoke execute function in account contract
|
|
35
35
|
*
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -16,6 +16,7 @@ var StarknetChainId;
|
|
|
16
16
|
})(StarknetChainId = exports.StarknetChainId || (exports.StarknetChainId = {}));
|
|
17
17
|
var TransactionHashPrefix;
|
|
18
18
|
(function (TransactionHashPrefix) {
|
|
19
|
+
TransactionHashPrefix["DECLARE"] = "0x6465636c617265";
|
|
19
20
|
TransactionHashPrefix["DEPLOY"] = "0x6465706c6f79";
|
|
20
21
|
TransactionHashPrefix["INVOKE"] = "0x696e766f6b65";
|
|
21
22
|
TransactionHashPrefix["L1_HANDLER"] = "0x6c315f68616e646c6572";
|
|
@@ -119,6 +119,6 @@ export declare class Contract implements ContractInterface {
|
|
|
119
119
|
call(method: string, args?: Array<any>, { blockIdentifier, }?: {
|
|
120
120
|
blockIdentifier?: BlockIdentifier;
|
|
121
121
|
}): Promise<Result>;
|
|
122
|
-
estimate(method: string, args?: Array<any>): Promise<import("../types
|
|
122
|
+
estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFee>;
|
|
123
123
|
populate(method: string, args?: Array<any>): Invocation;
|
|
124
124
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Abi, AddTransactionResponse, Call, CallContractResponse, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, Invocation, TransactionReceiptResponse } from '../types';
|
|
2
|
+
import { Abi, AddTransactionResponse, Call, CallContractResponse, DeclareContractPayload, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, Invocation, TransactionReceiptResponse } from '../types';
|
|
3
3
|
import { BigNumberish } from '../utils/number';
|
|
4
4
|
import { ProviderInterface } from './interface';
|
|
5
5
|
import { BlockIdentifier } from './utils';
|
|
@@ -85,9 +85,9 @@ export declare class Provider implements ProviderInterface {
|
|
|
85
85
|
*/
|
|
86
86
|
getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
|
|
87
87
|
/**
|
|
88
|
-
* Gets the transaction receipt from a tx hash
|
|
88
|
+
* Gets the transaction receipt from a tx hash.
|
|
89
89
|
*
|
|
90
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
90
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
91
91
|
*
|
|
92
92
|
* @param txHash
|
|
93
93
|
* @returns the transaction receipt object
|
|
@@ -110,6 +110,13 @@ export declare class Provider implements ProviderInterface {
|
|
|
110
110
|
* @returns the transaction trace
|
|
111
111
|
*/
|
|
112
112
|
getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Declare a given compiled contract (json) on starknet
|
|
115
|
+
*
|
|
116
|
+
* @param contract - a json object containing the compiled contract
|
|
117
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
118
|
+
*/
|
|
119
|
+
declareContract(payload: DeclareContractPayload): Promise<AddTransactionResponse>;
|
|
113
120
|
/**
|
|
114
121
|
* Deploys a given compiled contract (json) to starknet
|
|
115
122
|
*
|
package/dist/provider/default.js
CHANGED
|
@@ -321,9 +321,9 @@ var Provider = /** @class */ (function () {
|
|
|
321
321
|
});
|
|
322
322
|
};
|
|
323
323
|
/**
|
|
324
|
-
* Gets the transaction receipt from a tx hash
|
|
324
|
+
* Gets the transaction receipt from a tx hash.
|
|
325
325
|
*
|
|
326
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
326
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
327
327
|
*
|
|
328
328
|
* @param txHash
|
|
329
329
|
* @returns the transaction receipt object
|
|
@@ -370,6 +370,25 @@ var Provider = /** @class */ (function () {
|
|
|
370
370
|
});
|
|
371
371
|
});
|
|
372
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Declare a given compiled contract (json) on starknet
|
|
375
|
+
*
|
|
376
|
+
* @param contract - a json object containing the compiled contract
|
|
377
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
378
|
+
*/
|
|
379
|
+
Provider.prototype.declareContract = function (payload) {
|
|
380
|
+
var parsedContract = typeof payload.contract === 'string'
|
|
381
|
+
? (0, json_1.parse)(payload.contract)
|
|
382
|
+
: payload.contract;
|
|
383
|
+
var contractDefinition = __assign(__assign({}, parsedContract), { program: (0, stark_1.compressProgram)(parsedContract.program) });
|
|
384
|
+
return this.fetchEndpoint('add_transaction', undefined, {
|
|
385
|
+
type: 'DECLARE',
|
|
386
|
+
contract_class: contractDefinition,
|
|
387
|
+
nonce: (0, number_1.toHex)(constants_1.ZERO),
|
|
388
|
+
signature: [],
|
|
389
|
+
sender_address: (0, number_1.toHex)(constants_1.ONE),
|
|
390
|
+
});
|
|
391
|
+
};
|
|
373
392
|
/**
|
|
374
393
|
* Deploys a given compiled contract (json) to starknet
|
|
375
394
|
*
|
|
@@ -74,6 +74,14 @@ export declare abstract class ProviderInterface {
|
|
|
74
74
|
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
75
75
|
*/
|
|
76
76
|
abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the transaction receipt from a tx hash.
|
|
79
|
+
*
|
|
80
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
81
|
+
*
|
|
82
|
+
* @param txHash
|
|
83
|
+
* @returns the transaction receipt object
|
|
84
|
+
*/
|
|
77
85
|
abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
|
|
78
86
|
/**
|
|
79
87
|
* Deploys a given compiled contract (json) to starknet
|
package/dist/types/account.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
|
+
import { BlockIdentifier } from '../provider/utils';
|
|
3
|
+
import { BigNumberish } from '../utils/number';
|
|
2
4
|
import { EstimateFeeResponse } from './api';
|
|
3
5
|
export interface EstimateFee extends EstimateFeeResponse {
|
|
4
6
|
suggestedMaxFee: BN;
|
|
5
7
|
}
|
|
8
|
+
export interface EstimateFeeDetails {
|
|
9
|
+
nonce?: BigNumberish;
|
|
10
|
+
blockIdentifier?: BlockIdentifier;
|
|
11
|
+
}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -84,6 +84,13 @@ export declare type GetContractAddressesResponse = {
|
|
|
84
84
|
Starknet: string;
|
|
85
85
|
GpsStatementVerifier: string;
|
|
86
86
|
};
|
|
87
|
+
export declare type DeclareTransaction = {
|
|
88
|
+
type: 'DECLARE';
|
|
89
|
+
contract_class: CompressedCompiledContract;
|
|
90
|
+
nonce: BigNumberish;
|
|
91
|
+
sender_address: BigNumberish;
|
|
92
|
+
signature: Signature;
|
|
93
|
+
};
|
|
87
94
|
export declare type DeployTransaction = {
|
|
88
95
|
type: 'DEPLOY';
|
|
89
96
|
contract_definition: CompressedCompiledContract;
|
|
@@ -122,12 +129,12 @@ export declare type ExecutionResources = {
|
|
|
122
129
|
bitwise_builtin: number;
|
|
123
130
|
output_builtin: number;
|
|
124
131
|
ecdsa_builtin: number;
|
|
125
|
-
ec_op_builtin
|
|
132
|
+
ec_op_builtin?: number;
|
|
126
133
|
};
|
|
127
134
|
n_memory_holes: number;
|
|
128
135
|
};
|
|
129
136
|
export declare type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
|
|
130
|
-
export declare type Transaction = DeployTransaction | InvokeFunctionTransaction;
|
|
137
|
+
export declare type Transaction = DeclareTransaction | DeployTransaction | InvokeFunctionTransaction;
|
|
131
138
|
export declare type CallContractResponse = {
|
|
132
139
|
result: string[];
|
|
133
140
|
};
|
|
@@ -153,8 +160,9 @@ export declare type GetBlockResponse = {
|
|
|
153
160
|
transaction_index: number;
|
|
154
161
|
};
|
|
155
162
|
};
|
|
156
|
-
|
|
163
|
+
parent_block_hash: string;
|
|
157
164
|
status: Status;
|
|
165
|
+
gas_price: string;
|
|
158
166
|
};
|
|
159
167
|
export declare type GetCodeResponse = {
|
|
160
168
|
bytecode: string[];
|
|
@@ -162,9 +170,8 @@ export declare type GetCodeResponse = {
|
|
|
162
170
|
};
|
|
163
171
|
export declare type GetTransactionStatusResponse = {
|
|
164
172
|
tx_status: Status;
|
|
165
|
-
block_hash
|
|
173
|
+
block_hash?: string;
|
|
166
174
|
tx_failure_reason?: {
|
|
167
|
-
tx_id: number;
|
|
168
175
|
code: string;
|
|
169
176
|
error_message: string;
|
|
170
177
|
};
|
|
@@ -177,27 +184,36 @@ export declare type GetTransactionTraceResponse = {
|
|
|
177
184
|
selector: string;
|
|
178
185
|
calldata: RawArgs;
|
|
179
186
|
result: Array<any>;
|
|
180
|
-
execution_resources:
|
|
187
|
+
execution_resources: ExecutionResources;
|
|
181
188
|
internal_call: Array<any>;
|
|
182
189
|
events: Array<any>;
|
|
183
190
|
messages: Array<any>;
|
|
184
191
|
};
|
|
185
192
|
signature: Signature;
|
|
186
193
|
};
|
|
187
|
-
export declare type
|
|
194
|
+
export declare type SuccessfulTransactionResponse = {
|
|
188
195
|
status: Status;
|
|
189
196
|
transaction: Transaction;
|
|
190
197
|
block_hash: string;
|
|
191
198
|
block_number: BlockNumber;
|
|
192
199
|
transaction_index: number;
|
|
193
|
-
transaction_hash: string;
|
|
194
200
|
};
|
|
201
|
+
export declare type FailedTransactionResponse = {
|
|
202
|
+
status: 'REJECTED';
|
|
203
|
+
transaction_failure_reason: {
|
|
204
|
+
code: string;
|
|
205
|
+
error_message: string;
|
|
206
|
+
};
|
|
207
|
+
transaction: Transaction;
|
|
208
|
+
};
|
|
209
|
+
export declare type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
|
|
195
210
|
export declare type AddTransactionResponse = {
|
|
196
211
|
code: TransactionStatus;
|
|
197
212
|
transaction_hash: string;
|
|
198
213
|
address?: string;
|
|
214
|
+
class_hash?: string;
|
|
199
215
|
};
|
|
200
|
-
export declare type
|
|
216
|
+
export declare type SuccessfulTransactionReceiptResponse = {
|
|
201
217
|
status: Status;
|
|
202
218
|
transaction_hash: string;
|
|
203
219
|
transaction_index: number;
|
|
@@ -205,7 +221,20 @@ export declare type TransactionReceiptResponse = {
|
|
|
205
221
|
block_number: BlockNumber;
|
|
206
222
|
l2_to_l1_messages: string[];
|
|
207
223
|
events: string[];
|
|
224
|
+
actual_fee: string;
|
|
225
|
+
execution_resources: ExecutionResources;
|
|
226
|
+
};
|
|
227
|
+
export declare type FailedTransactionReceiptResponse = {
|
|
228
|
+
status: 'REJECTED';
|
|
229
|
+
transaction_failure_reason: {
|
|
230
|
+
code: string;
|
|
231
|
+
error_message: string;
|
|
232
|
+
};
|
|
233
|
+
transaction_hash: string;
|
|
234
|
+
l2_to_l1_messages: string[];
|
|
235
|
+
events: string[];
|
|
208
236
|
};
|
|
237
|
+
export declare type TransactionReceiptResponse = SuccessfulTransactionReceiptResponse | FailedTransactionReceiptResponse;
|
|
209
238
|
export declare type EstimateFeeResponse = {
|
|
210
239
|
amount: BN;
|
|
211
240
|
unit: string;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/lib.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare type DeployContractPayload = {
|
|
|
8
8
|
constructorCalldata?: RawCalldata;
|
|
9
9
|
addressSalt?: BigNumberish;
|
|
10
10
|
};
|
|
11
|
+
export declare type DeclareContractPayload = {
|
|
12
|
+
contract: CompiledContract | string;
|
|
13
|
+
};
|
|
11
14
|
export declare type Invocation = {
|
|
12
15
|
contractAddress: string;
|
|
13
16
|
entrypoint: string;
|
|
@@ -22,7 +25,7 @@ export declare type InvocationsDetails = {
|
|
|
22
25
|
};
|
|
23
26
|
export declare type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
24
27
|
export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
25
|
-
export declare type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
28
|
+
export declare type Type = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
26
29
|
export declare type EntryPointType = 'EXTERNAL';
|
|
27
30
|
export declare type CompressedProgram = string;
|
|
28
31
|
export declare type AbiEntry = {
|
package/package.json
CHANGED
package/provider/default.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AddTransactionResponse,
|
|
5
5
|
Call,
|
|
6
6
|
CallContractResponse,
|
|
7
|
+
DeclareContractPayload,
|
|
7
8
|
DeployContractPayload,
|
|
8
9
|
Endpoints,
|
|
9
10
|
GetBlockResponse,
|
|
@@ -122,9 +123,9 @@ export declare class Provider implements ProviderInterface {
|
|
|
122
123
|
*/
|
|
123
124
|
getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
|
|
124
125
|
/**
|
|
125
|
-
* Gets the transaction receipt from a tx hash
|
|
126
|
+
* Gets the transaction receipt from a tx hash.
|
|
126
127
|
*
|
|
127
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
128
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
128
129
|
*
|
|
129
130
|
* @param txHash
|
|
130
131
|
* @returns the transaction receipt object
|
|
@@ -147,6 +148,13 @@ export declare class Provider implements ProviderInterface {
|
|
|
147
148
|
* @returns the transaction trace
|
|
148
149
|
*/
|
|
149
150
|
getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Declare a given compiled contract (json) on starknet
|
|
153
|
+
*
|
|
154
|
+
* @param contract - a json object containing the compiled contract
|
|
155
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
156
|
+
*/
|
|
157
|
+
declareContract(payload: DeclareContractPayload): Promise<AddTransactionResponse>;
|
|
150
158
|
/**
|
|
151
159
|
* Deploys a given compiled contract (json) to starknet
|
|
152
160
|
*
|
package/provider/default.js
CHANGED
|
@@ -478,9 +478,9 @@ var Provider = /** @class */ (function () {
|
|
|
478
478
|
});
|
|
479
479
|
};
|
|
480
480
|
/**
|
|
481
|
-
* Gets the transaction receipt from a tx hash
|
|
481
|
+
* Gets the transaction receipt from a tx hash.
|
|
482
482
|
*
|
|
483
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
483
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
484
484
|
*
|
|
485
485
|
* @param txHash
|
|
486
486
|
* @returns the transaction receipt object
|
|
@@ -536,6 +536,26 @@ var Provider = /** @class */ (function () {
|
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
538
|
};
|
|
539
|
+
/**
|
|
540
|
+
* Declare a given compiled contract (json) on starknet
|
|
541
|
+
*
|
|
542
|
+
* @param contract - a json object containing the compiled contract
|
|
543
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
544
|
+
*/
|
|
545
|
+
Provider.prototype.declareContract = function (payload) {
|
|
546
|
+
var parsedContract =
|
|
547
|
+
typeof payload.contract === 'string' ? (0, json_1.parse)(payload.contract) : payload.contract;
|
|
548
|
+
var contractDefinition = __assign(__assign({}, parsedContract), {
|
|
549
|
+
program: (0, stark_1.compressProgram)(parsedContract.program),
|
|
550
|
+
});
|
|
551
|
+
return this.fetchEndpoint('add_transaction', undefined, {
|
|
552
|
+
type: 'DECLARE',
|
|
553
|
+
contract_class: contractDefinition,
|
|
554
|
+
nonce: (0, number_1.toHex)(constants_1.ZERO),
|
|
555
|
+
signature: [],
|
|
556
|
+
sender_address: (0, number_1.toHex)(constants_1.ONE),
|
|
557
|
+
});
|
|
558
|
+
};
|
|
539
559
|
/**
|
|
540
560
|
* Deploys a given compiled contract (json) to starknet
|
|
541
561
|
*
|
package/provider/interface.d.ts
CHANGED
|
@@ -96,6 +96,14 @@ export declare abstract class ProviderInterface {
|
|
|
96
96
|
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
97
97
|
*/
|
|
98
98
|
abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the transaction receipt from a tx hash.
|
|
101
|
+
*
|
|
102
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
103
|
+
*
|
|
104
|
+
* @param txHash
|
|
105
|
+
* @returns the transaction receipt object
|
|
106
|
+
*/
|
|
99
107
|
abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
|
|
100
108
|
/**
|
|
101
109
|
* Deploys a given compiled contract (json) to starknet
|
package/src/account/default.ts
CHANGED
|
@@ -2,7 +2,6 @@ import assert from 'minimalistic-assert';
|
|
|
2
2
|
|
|
3
3
|
import { ZERO } from '../constants';
|
|
4
4
|
import { Provider, ProviderInterface } from '../provider';
|
|
5
|
-
import { BlockIdentifier } from '../provider/utils';
|
|
6
5
|
import { Signer, SignerInterface } from '../signer';
|
|
7
6
|
import {
|
|
8
7
|
Abi,
|
|
@@ -15,7 +14,7 @@ import {
|
|
|
15
14
|
Signature,
|
|
16
15
|
Transaction,
|
|
17
16
|
} from '../types';
|
|
18
|
-
import { EstimateFee } from '../types/account';
|
|
17
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
19
18
|
import { sign } from '../utils/ellipticCurve';
|
|
20
19
|
import {
|
|
21
20
|
computeHashOnElements,
|
|
@@ -56,10 +55,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
56
55
|
|
|
57
56
|
public async estimateFee(
|
|
58
57
|
calls: Call | Call[],
|
|
59
|
-
{
|
|
60
|
-
nonce: providedNonce,
|
|
61
|
-
blockIdentifier = 'pending',
|
|
62
|
-
}: { nonce?: BigNumberish; blockIdentifier?: BlockIdentifier } = {}
|
|
58
|
+
{ nonce: providedNonce, blockIdentifier = 'pending' }: EstimateFeeDetails = {}
|
|
63
59
|
): Promise<EstimateFee> {
|
|
64
60
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
65
61
|
const nonce = providedNonce ?? (await this.getNonce());
|
|
@@ -147,6 +143,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
147
143
|
*/
|
|
148
144
|
public async LEGACY_addTransaction(transaction: Transaction): Promise<AddTransactionResponse> {
|
|
149
145
|
if (transaction.type === 'DEPLOY') throw new Error('No DEPLOYS');
|
|
146
|
+
if (transaction.type === 'DECLARE') throw new Error('No DECLARES');
|
|
150
147
|
|
|
151
148
|
assert(
|
|
152
149
|
!transaction.signature,
|
package/src/account/interface.ts
CHANGED
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
AddTransactionResponse,
|
|
6
6
|
Call,
|
|
7
7
|
DeployContractPayload,
|
|
8
|
-
Invocation,
|
|
9
8
|
InvocationsDetails,
|
|
10
9
|
Signature,
|
|
11
10
|
} from '../types';
|
|
12
|
-
import { EstimateFee } from '../types/account';
|
|
11
|
+
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
13
12
|
import { BigNumberish } from '../utils/number';
|
|
14
13
|
import { TypedData } from '../utils/typedData/types';
|
|
15
14
|
|
|
@@ -44,7 +43,10 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
44
43
|
*
|
|
45
44
|
* @returns response from addTransaction
|
|
46
45
|
*/
|
|
47
|
-
public abstract estimateFee(
|
|
46
|
+
public abstract estimateFee(
|
|
47
|
+
calls: Call | Call[],
|
|
48
|
+
estimateFeeDetails?: EstimateFeeDetails
|
|
49
|
+
): Promise<EstimateFee>;
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Invoke execute function in account contract
|
package/src/constants.ts
CHANGED
|
@@ -13,6 +13,7 @@ export enum StarknetChainId {
|
|
|
13
13
|
TESTNET = '0x534e5f474f45524c49', // encodeShortString('SN_GOERLI'),
|
|
14
14
|
}
|
|
15
15
|
export enum TransactionHashPrefix {
|
|
16
|
+
DECLARE = '0x6465636c617265', // encodeShortString('declare'),
|
|
16
17
|
DEPLOY = '0x6465706c6f79', // encodeShortString('deploy'),
|
|
17
18
|
INVOKE = '0x696e766f6b65', // encodeShortString('invoke'),
|
|
18
19
|
L1_HANDLER = '0x6c315f68616e646c6572', // encodeShortString('l1_handler'),
|
package/src/provider/default.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fetch from 'cross-fetch';
|
|
2
2
|
import urljoin from 'url-join';
|
|
3
3
|
|
|
4
|
-
import { StarknetChainId } from '../constants';
|
|
4
|
+
import { ONE, StarknetChainId, ZERO } from '../constants';
|
|
5
5
|
import {
|
|
6
6
|
Abi,
|
|
7
7
|
AddTransactionResponse,
|
|
8
8
|
Call,
|
|
9
9
|
CallContractResponse,
|
|
10
10
|
CompiledContract,
|
|
11
|
+
DeclareContractPayload,
|
|
11
12
|
DeployContractPayload,
|
|
12
13
|
Endpoints,
|
|
13
14
|
GetBlockResponse,
|
|
@@ -272,14 +273,13 @@ export class Provider implements ProviderInterface {
|
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
/**
|
|
275
|
-
* Gets the transaction receipt from a tx hash
|
|
276
|
+
* Gets the transaction receipt from a tx hash.
|
|
276
277
|
*
|
|
277
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
278
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
278
279
|
*
|
|
279
280
|
* @param txHash
|
|
280
281
|
* @returns the transaction receipt object
|
|
281
282
|
*/
|
|
282
|
-
|
|
283
283
|
public async getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse> {
|
|
284
284
|
const txHashHex = toHex(toBN(txHash));
|
|
285
285
|
return this.fetchEndpoint('get_transaction_receipt', { transactionHash: txHashHex });
|
|
@@ -310,6 +310,31 @@ export class Provider implements ProviderInterface {
|
|
|
310
310
|
return this.fetchEndpoint('get_transaction_trace', { transactionHash: txHashHex });
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Declare a given compiled contract (json) on starknet
|
|
315
|
+
*
|
|
316
|
+
* @param contract - a json object containing the compiled contract
|
|
317
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
318
|
+
*/
|
|
319
|
+
public declareContract(payload: DeclareContractPayload): Promise<AddTransactionResponse> {
|
|
320
|
+
const parsedContract =
|
|
321
|
+
typeof payload.contract === 'string'
|
|
322
|
+
? (parse(payload.contract) as CompiledContract)
|
|
323
|
+
: payload.contract;
|
|
324
|
+
const contractDefinition = {
|
|
325
|
+
...parsedContract,
|
|
326
|
+
program: compressProgram(parsedContract.program),
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
return this.fetchEndpoint('add_transaction', undefined, {
|
|
330
|
+
type: 'DECLARE',
|
|
331
|
+
contract_class: contractDefinition,
|
|
332
|
+
nonce: toHex(ZERO),
|
|
333
|
+
signature: [],
|
|
334
|
+
sender_address: toHex(ONE),
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
313
338
|
/**
|
|
314
339
|
* Deploys a given compiled contract (json) to starknet
|
|
315
340
|
*
|
|
@@ -109,6 +109,14 @@ export abstract class ProviderInterface {
|
|
|
109
109
|
*/
|
|
110
110
|
public abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Gets the transaction receipt from a tx hash.
|
|
114
|
+
*
|
|
115
|
+
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
116
|
+
*
|
|
117
|
+
* @param txHash
|
|
118
|
+
* @returns the transaction receipt object
|
|
119
|
+
*/
|
|
112
120
|
public abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
|
|
113
121
|
|
|
114
122
|
/**
|
package/src/types/account.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
|
|
3
|
+
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
+
import { BigNumberish } from '../utils/number';
|
|
3
5
|
import { EstimateFeeResponse } from './api';
|
|
4
6
|
|
|
5
7
|
export interface EstimateFee extends EstimateFeeResponse {
|
|
6
8
|
suggestedMaxFee: BN;
|
|
7
9
|
}
|
|
10
|
+
|
|
11
|
+
export interface EstimateFeeDetails {
|
|
12
|
+
nonce?: BigNumberish;
|
|
13
|
+
blockIdentifier?: BlockIdentifier;
|
|
14
|
+
}
|
package/src/types/api.ts
CHANGED
|
@@ -97,6 +97,14 @@ export type GetContractAddressesResponse = {
|
|
|
97
97
|
GpsStatementVerifier: string;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
export type DeclareTransaction = {
|
|
101
|
+
type: 'DECLARE';
|
|
102
|
+
contract_class: CompressedCompiledContract;
|
|
103
|
+
nonce: BigNumberish;
|
|
104
|
+
sender_address: BigNumberish;
|
|
105
|
+
signature: Signature;
|
|
106
|
+
};
|
|
107
|
+
|
|
100
108
|
export type DeployTransaction = {
|
|
101
109
|
type: 'DEPLOY';
|
|
102
110
|
contract_definition: CompressedCompiledContract;
|
|
@@ -138,7 +146,7 @@ export type ExecutionResources = {
|
|
|
138
146
|
bitwise_builtin: number;
|
|
139
147
|
output_builtin: number;
|
|
140
148
|
ecdsa_builtin: number;
|
|
141
|
-
ec_op_builtin
|
|
149
|
+
ec_op_builtin?: number;
|
|
142
150
|
};
|
|
143
151
|
n_memory_holes: number;
|
|
144
152
|
};
|
|
@@ -148,7 +156,7 @@ export type CallContractTransaction = Omit<
|
|
|
148
156
|
'type' | 'entry_point_type' | 'nonce'
|
|
149
157
|
>;
|
|
150
158
|
|
|
151
|
-
export type Transaction = DeployTransaction | InvokeFunctionTransaction;
|
|
159
|
+
export type Transaction = DeclareTransaction | DeployTransaction | InvokeFunctionTransaction;
|
|
152
160
|
|
|
153
161
|
export type CallContractResponse = {
|
|
154
162
|
result: string[];
|
|
@@ -176,8 +184,9 @@ export type GetBlockResponse = {
|
|
|
176
184
|
transaction_index: number;
|
|
177
185
|
};
|
|
178
186
|
};
|
|
179
|
-
|
|
187
|
+
parent_block_hash: string;
|
|
180
188
|
status: Status;
|
|
189
|
+
gas_price: string;
|
|
181
190
|
};
|
|
182
191
|
|
|
183
192
|
export type GetCodeResponse = {
|
|
@@ -187,9 +196,8 @@ export type GetCodeResponse = {
|
|
|
187
196
|
|
|
188
197
|
export type GetTransactionStatusResponse = {
|
|
189
198
|
tx_status: Status;
|
|
190
|
-
block_hash
|
|
199
|
+
block_hash?: string;
|
|
191
200
|
tx_failure_reason?: {
|
|
192
|
-
tx_id: number;
|
|
193
201
|
code: string;
|
|
194
202
|
error_message: string;
|
|
195
203
|
};
|
|
@@ -203,7 +211,7 @@ export type GetTransactionTraceResponse = {
|
|
|
203
211
|
selector: string;
|
|
204
212
|
calldata: RawArgs;
|
|
205
213
|
result: Array<any>;
|
|
206
|
-
execution_resources:
|
|
214
|
+
execution_resources: ExecutionResources;
|
|
207
215
|
internal_call: Array<any>;
|
|
208
216
|
events: Array<any>;
|
|
209
217
|
messages: Array<any>;
|
|
@@ -211,22 +219,33 @@ export type GetTransactionTraceResponse = {
|
|
|
211
219
|
signature: Signature;
|
|
212
220
|
};
|
|
213
221
|
|
|
214
|
-
export type
|
|
222
|
+
export type SuccessfulTransactionResponse = {
|
|
215
223
|
status: Status;
|
|
216
224
|
transaction: Transaction;
|
|
217
225
|
block_hash: string;
|
|
218
226
|
block_number: BlockNumber;
|
|
219
227
|
transaction_index: number;
|
|
220
|
-
transaction_hash: string;
|
|
221
228
|
};
|
|
222
229
|
|
|
230
|
+
export type FailedTransactionResponse = {
|
|
231
|
+
status: 'REJECTED';
|
|
232
|
+
transaction_failure_reason: {
|
|
233
|
+
code: string;
|
|
234
|
+
error_message: string;
|
|
235
|
+
};
|
|
236
|
+
transaction: Transaction;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
|
|
240
|
+
|
|
223
241
|
export type AddTransactionResponse = {
|
|
224
242
|
code: TransactionStatus;
|
|
225
243
|
transaction_hash: string;
|
|
226
244
|
address?: string;
|
|
245
|
+
class_hash?: string;
|
|
227
246
|
};
|
|
228
247
|
|
|
229
|
-
export type
|
|
248
|
+
export type SuccessfulTransactionReceiptResponse = {
|
|
230
249
|
status: Status;
|
|
231
250
|
transaction_hash: string;
|
|
232
251
|
transaction_index: number;
|
|
@@ -234,8 +253,25 @@ export type TransactionReceiptResponse = {
|
|
|
234
253
|
block_number: BlockNumber;
|
|
235
254
|
l2_to_l1_messages: string[];
|
|
236
255
|
events: string[];
|
|
256
|
+
actual_fee: string;
|
|
257
|
+
execution_resources: ExecutionResources;
|
|
237
258
|
};
|
|
238
259
|
|
|
260
|
+
export type FailedTransactionReceiptResponse = {
|
|
261
|
+
status: 'REJECTED';
|
|
262
|
+
transaction_failure_reason: {
|
|
263
|
+
code: string;
|
|
264
|
+
error_message: string;
|
|
265
|
+
};
|
|
266
|
+
transaction_hash: string;
|
|
267
|
+
l2_to_l1_messages: string[];
|
|
268
|
+
events: string[];
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export type TransactionReceiptResponse =
|
|
272
|
+
| SuccessfulTransactionReceiptResponse
|
|
273
|
+
| FailedTransactionReceiptResponse;
|
|
274
|
+
|
|
239
275
|
export type EstimateFeeResponse = {
|
|
240
276
|
amount: BN;
|
|
241
277
|
unit: string;
|
package/src/types/index.ts
CHANGED
package/src/types/lib.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type DeployContractPayload = {
|
|
|
12
12
|
addressSalt?: BigNumberish;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export type DeclareContractPayload = {
|
|
16
|
+
contract: CompiledContract | string;
|
|
17
|
+
};
|
|
18
|
+
|
|
15
19
|
export type Invocation = {
|
|
16
20
|
contractAddress: string;
|
|
17
21
|
entrypoint: string;
|
|
@@ -35,7 +39,7 @@ export type Status =
|
|
|
35
39
|
| 'ACCEPTED_ON_L1'
|
|
36
40
|
| 'REJECTED';
|
|
37
41
|
export type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
38
|
-
export type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
42
|
+
export type Type = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
39
43
|
export type EntryPointType = 'EXTERNAL';
|
|
40
44
|
export type CompressedProgram = string;
|
|
41
45
|
|
package/types/account.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
|
|
3
|
+
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
+
import { BigNumberish } from '../utils/number';
|
|
3
5
|
import { EstimateFeeResponse } from './api';
|
|
4
6
|
export interface EstimateFee extends EstimateFeeResponse {
|
|
5
7
|
suggestedMaxFee: BN;
|
|
6
8
|
}
|
|
9
|
+
export interface EstimateFeeDetails {
|
|
10
|
+
nonce?: BigNumberish;
|
|
11
|
+
blockIdentifier?: BlockIdentifier;
|
|
12
|
+
}
|
package/types/api.d.ts
CHANGED
|
@@ -94,6 +94,13 @@ export declare type GetContractAddressesResponse = {
|
|
|
94
94
|
Starknet: string;
|
|
95
95
|
GpsStatementVerifier: string;
|
|
96
96
|
};
|
|
97
|
+
export declare type DeclareTransaction = {
|
|
98
|
+
type: 'DECLARE';
|
|
99
|
+
contract_class: CompressedCompiledContract;
|
|
100
|
+
nonce: BigNumberish;
|
|
101
|
+
sender_address: BigNumberish;
|
|
102
|
+
signature: Signature;
|
|
103
|
+
};
|
|
97
104
|
export declare type DeployTransaction = {
|
|
98
105
|
type: 'DEPLOY';
|
|
99
106
|
contract_definition: CompressedCompiledContract;
|
|
@@ -132,7 +139,7 @@ export declare type ExecutionResources = {
|
|
|
132
139
|
bitwise_builtin: number;
|
|
133
140
|
output_builtin: number;
|
|
134
141
|
ecdsa_builtin: number;
|
|
135
|
-
ec_op_builtin
|
|
142
|
+
ec_op_builtin?: number;
|
|
136
143
|
};
|
|
137
144
|
n_memory_holes: number;
|
|
138
145
|
};
|
|
@@ -140,7 +147,10 @@ export declare type CallContractTransaction = Omit<
|
|
|
140
147
|
InvokeFunctionTransaction,
|
|
141
148
|
'type' | 'entry_point_type' | 'nonce'
|
|
142
149
|
>;
|
|
143
|
-
export declare type Transaction =
|
|
150
|
+
export declare type Transaction =
|
|
151
|
+
| DeclareTransaction
|
|
152
|
+
| DeployTransaction
|
|
153
|
+
| InvokeFunctionTransaction;
|
|
144
154
|
export declare type CallContractResponse = {
|
|
145
155
|
result: string[];
|
|
146
156
|
};
|
|
@@ -166,8 +176,9 @@ export declare type GetBlockResponse = {
|
|
|
166
176
|
transaction_index: number;
|
|
167
177
|
};
|
|
168
178
|
};
|
|
169
|
-
|
|
179
|
+
parent_block_hash: string;
|
|
170
180
|
status: Status;
|
|
181
|
+
gas_price: string;
|
|
171
182
|
};
|
|
172
183
|
export declare type GetCodeResponse = {
|
|
173
184
|
bytecode: string[];
|
|
@@ -175,9 +186,8 @@ export declare type GetCodeResponse = {
|
|
|
175
186
|
};
|
|
176
187
|
export declare type GetTransactionStatusResponse = {
|
|
177
188
|
tx_status: Status;
|
|
178
|
-
block_hash
|
|
189
|
+
block_hash?: string;
|
|
179
190
|
tx_failure_reason?: {
|
|
180
|
-
tx_id: number;
|
|
181
191
|
code: string;
|
|
182
192
|
error_message: string;
|
|
183
193
|
};
|
|
@@ -190,27 +200,38 @@ export declare type GetTransactionTraceResponse = {
|
|
|
190
200
|
selector: string;
|
|
191
201
|
calldata: RawArgs;
|
|
192
202
|
result: Array<any>;
|
|
193
|
-
execution_resources:
|
|
203
|
+
execution_resources: ExecutionResources;
|
|
194
204
|
internal_call: Array<any>;
|
|
195
205
|
events: Array<any>;
|
|
196
206
|
messages: Array<any>;
|
|
197
207
|
};
|
|
198
208
|
signature: Signature;
|
|
199
209
|
};
|
|
200
|
-
export declare type
|
|
210
|
+
export declare type SuccessfulTransactionResponse = {
|
|
201
211
|
status: Status;
|
|
202
212
|
transaction: Transaction;
|
|
203
213
|
block_hash: string;
|
|
204
214
|
block_number: BlockNumber;
|
|
205
215
|
transaction_index: number;
|
|
206
|
-
transaction_hash: string;
|
|
207
216
|
};
|
|
217
|
+
export declare type FailedTransactionResponse = {
|
|
218
|
+
status: 'REJECTED';
|
|
219
|
+
transaction_failure_reason: {
|
|
220
|
+
code: string;
|
|
221
|
+
error_message: string;
|
|
222
|
+
};
|
|
223
|
+
transaction: Transaction;
|
|
224
|
+
};
|
|
225
|
+
export declare type GetTransactionResponse =
|
|
226
|
+
| SuccessfulTransactionResponse
|
|
227
|
+
| FailedTransactionResponse;
|
|
208
228
|
export declare type AddTransactionResponse = {
|
|
209
229
|
code: TransactionStatus;
|
|
210
230
|
transaction_hash: string;
|
|
211
231
|
address?: string;
|
|
232
|
+
class_hash?: string;
|
|
212
233
|
};
|
|
213
|
-
export declare type
|
|
234
|
+
export declare type SuccessfulTransactionReceiptResponse = {
|
|
214
235
|
status: Status;
|
|
215
236
|
transaction_hash: string;
|
|
216
237
|
transaction_index: number;
|
|
@@ -218,7 +239,22 @@ export declare type TransactionReceiptResponse = {
|
|
|
218
239
|
block_number: BlockNumber;
|
|
219
240
|
l2_to_l1_messages: string[];
|
|
220
241
|
events: string[];
|
|
242
|
+
actual_fee: string;
|
|
243
|
+
execution_resources: ExecutionResources;
|
|
244
|
+
};
|
|
245
|
+
export declare type FailedTransactionReceiptResponse = {
|
|
246
|
+
status: 'REJECTED';
|
|
247
|
+
transaction_failure_reason: {
|
|
248
|
+
code: string;
|
|
249
|
+
error_message: string;
|
|
250
|
+
};
|
|
251
|
+
transaction_hash: string;
|
|
252
|
+
l2_to_l1_messages: string[];
|
|
253
|
+
events: string[];
|
|
221
254
|
};
|
|
255
|
+
export declare type TransactionReceiptResponse =
|
|
256
|
+
| SuccessfulTransactionReceiptResponse
|
|
257
|
+
| FailedTransactionReceiptResponse;
|
|
222
258
|
export declare type EstimateFeeResponse = {
|
|
223
259
|
amount: BN;
|
|
224
260
|
unit: string;
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
package/types/lib.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare type DeployContractPayload = {
|
|
|
9
9
|
constructorCalldata?: RawCalldata;
|
|
10
10
|
addressSalt?: BigNumberish;
|
|
11
11
|
};
|
|
12
|
+
export declare type DeclareContractPayload = {
|
|
13
|
+
contract: CompiledContract | string;
|
|
14
|
+
};
|
|
12
15
|
export declare type Invocation = {
|
|
13
16
|
contractAddress: string;
|
|
14
17
|
entrypoint: string;
|
|
@@ -29,7 +32,7 @@ export declare type Status =
|
|
|
29
32
|
| 'ACCEPTED_ON_L1'
|
|
30
33
|
| 'REJECTED';
|
|
31
34
|
export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
32
|
-
export declare type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
35
|
+
export declare type Type = 'DECLARE' | 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
33
36
|
export declare type EntryPointType = 'EXTERNAL';
|
|
34
37
|
export declare type CompressedProgram = string;
|
|
35
38
|
export declare type AbiEntry = {
|
package/www/docs/API/provider.md
CHANGED
|
@@ -131,11 +131,11 @@ Gets the status of a transaction.
|
|
|
131
131
|
|
|
132
132
|
<hr/>
|
|
133
133
|
|
|
134
|
-
provider.**getTransactionReceipt**(txHash
|
|
134
|
+
provider.**getTransactionReceipt**(txHash) => _Promise < TransactionReceiptResponse >_
|
|
135
135
|
|
|
136
136
|
Gets the status of a transaction.
|
|
137
137
|
|
|
138
|
-
######
|
|
138
|
+
###### _TransactionReceiptResponse_
|
|
139
139
|
|
|
140
140
|
```
|
|
141
141
|
{
|
|
@@ -198,9 +198,26 @@ Gets the transaction trace from a tx hash.
|
|
|
198
198
|
|
|
199
199
|
<hr/>
|
|
200
200
|
|
|
201
|
+
provider.**declareContract**(payload) => _Promise < AddTransactionResponse >_
|
|
202
|
+
|
|
203
|
+
Declares a contract on Starknet
|
|
204
|
+
|
|
205
|
+
###### _AddTransactionResponse_
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
{
|
|
209
|
+
code: 'TRANSACTION_RECEIVED';
|
|
210
|
+
transaction_hash: string;
|
|
211
|
+
class_hash: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
<hr/>
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
201
218
|
provider.**deployContract**(payload [ , abi ]) => _Promise < AddTransactionResponse >_
|
|
202
219
|
|
|
203
|
-
|
|
220
|
+
Deploys a contract on Starknet
|
|
204
221
|
|
|
205
222
|
###### _AddTransactionResponse_
|
|
206
223
|
|