starknet 3.18.2 → 4.0.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 +70 -0
- package/README.md +1 -2
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/jest.setup.ts +2 -3
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +444 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.js +6 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +2 -3
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +444 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +299 -0
- package/src/provider/sequencer.ts +385 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/fetchPonyfill.ts +4 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/fetchPonyfill.d.ts +2 -0
- package/utils/fetchPonyfill.js +6 -0
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- package/types/api.js +0 -2
package/provider/errors.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CustomError } from 'ts-custom-error';
|
|
2
2
|
export declare class GatewayError extends CustomError {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
errorCode: string;
|
|
4
|
+
constructor(message: string, errorCode: string);
|
|
5
5
|
}
|
|
6
6
|
export declare class HttpError extends CustomError {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
errorCode: number;
|
|
8
|
+
constructor(message: string, errorCode: number);
|
|
9
9
|
}
|
package/provider/errors.js
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
var __extends =
|
|
3
|
-
(this && this.__extends) ||
|
|
4
|
-
(function () {
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
3
|
var extendStatics = function (d, b) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
}) ||
|
|
12
|
-
function (d, b) {
|
|
13
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
16
8
|
};
|
|
17
9
|
return function (d, b) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
25
15
|
};
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports,
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
18
|
exports.HttpError = exports.GatewayError = void 0;
|
|
29
19
|
/* eslint-disable max-classes-per-file */
|
|
30
|
-
var ts_custom_error_1 = require(
|
|
20
|
+
var ts_custom_error_1 = require("ts-custom-error");
|
|
31
21
|
var GatewayError = /** @class */ (function (_super) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
22
|
+
__extends(GatewayError, _super);
|
|
23
|
+
function GatewayError(message, errorCode) {
|
|
24
|
+
var _this = _super.call(this, message) || this;
|
|
25
|
+
_this.errorCode = errorCode;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
return GatewayError;
|
|
29
|
+
}(ts_custom_error_1.CustomError));
|
|
40
30
|
exports.GatewayError = GatewayError;
|
|
41
31
|
var HttpError = /** @class */ (function (_super) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
32
|
+
__extends(HttpError, _super);
|
|
33
|
+
function HttpError(message, errorCode) {
|
|
34
|
+
var _this = _super.call(this, message) || this;
|
|
35
|
+
_this.errorCode = errorCode;
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
return HttpError;
|
|
39
|
+
}(ts_custom_error_1.CustomError));
|
|
50
40
|
exports.HttpError = HttpError;
|
package/provider/index.d.ts
CHANGED
package/provider/index.js
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
: function (o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __exportStar =
|
|
23
|
-
(this && this.__exportStar) ||
|
|
24
|
-
function (m, exports) {
|
|
25
|
-
for (var p in m)
|
|
26
|
-
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
27
|
-
__createBinding(exports, m, p);
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
17
|
exports.defaultProvider = void 0;
|
|
31
|
-
var default_1 = require(
|
|
32
|
-
__exportStar(require(
|
|
33
|
-
__exportStar(require(
|
|
34
|
-
__exportStar(require(
|
|
18
|
+
var default_1 = require("./default");
|
|
19
|
+
__exportStar(require("./default"), exports);
|
|
20
|
+
__exportStar(require("./errors"), exports);
|
|
21
|
+
__exportStar(require("./sequencer"), exports);
|
|
22
|
+
__exportStar(require("./interface"), exports);
|
|
23
|
+
__exportStar(require("./rpc"), exports);
|
|
35
24
|
exports.defaultProvider = new default_1.Provider();
|
package/provider/interface.d.ts
CHANGED
|
@@ -1,136 +1,109 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import type {
|
|
3
|
-
AddTransactionResponse,
|
|
4
|
-
Call,
|
|
5
|
-
CallContractResponse,
|
|
6
|
-
DeployContractPayload,
|
|
7
|
-
GetBlockResponse,
|
|
8
|
-
GetCodeResponse,
|
|
9
|
-
GetContractAddressesResponse,
|
|
10
|
-
GetTransactionResponse,
|
|
11
|
-
GetTransactionStatusResponse,
|
|
12
|
-
Invocation,
|
|
13
|
-
TransactionReceiptResponse,
|
|
14
|
-
} from '../types';
|
|
2
|
+
import type { BlockTag, Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetails, InvokeFunctionResponse } from '../types';
|
|
15
3
|
import type { BigNumberish } from '../utils/number';
|
|
16
4
|
import { BlockIdentifier } from './utils';
|
|
17
5
|
export declare abstract class ProviderInterface {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
* @param invocation the invocation object containing:
|
|
123
|
-
* - contractAddress - the address of the contract
|
|
124
|
-
* - entrypoint - the entrypoint of the contract
|
|
125
|
-
* - calldata - (defaults to []) the calldata
|
|
126
|
-
* - signature - (defaults to []) the signature
|
|
127
|
-
*
|
|
128
|
-
* @returns response from addTransaction
|
|
129
|
-
*/
|
|
130
|
-
abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;
|
|
131
|
-
abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated use `waitForTransaction` instead
|
|
134
|
-
*/
|
|
135
|
-
abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
6
|
+
abstract chainId: StarknetChainId;
|
|
7
|
+
/**
|
|
8
|
+
* Calls a function on the StarkNet contract.
|
|
9
|
+
*
|
|
10
|
+
* @param call transaction to be called
|
|
11
|
+
* @param blockIdentifier block identifier
|
|
12
|
+
* @returns the result of the function on the smart contract.
|
|
13
|
+
*/
|
|
14
|
+
abstract callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the block information
|
|
17
|
+
*
|
|
18
|
+
* @param blockIdentifier block identifier
|
|
19
|
+
* @returns the block object
|
|
20
|
+
*/
|
|
21
|
+
abstract getBlock(blockIdentifier: BlockIdentifier): Promise<GetBlockResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the contract class of the deployed contract.
|
|
24
|
+
*
|
|
25
|
+
* @param contractAddress - contract address
|
|
26
|
+
* @param blockIdentifier - block identifier
|
|
27
|
+
* @returns Contract class of compiled contract
|
|
28
|
+
*/
|
|
29
|
+
abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the contract's storage variable at a specific key.
|
|
32
|
+
*
|
|
33
|
+
* @param contractAddress
|
|
34
|
+
* @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
|
|
35
|
+
* @param blockHashOrTag - block hash or tag (pending, latest)
|
|
36
|
+
* @returns the value of the storage variable
|
|
37
|
+
*/
|
|
38
|
+
abstract getStorageAt(contractAddress: string, key: BigNumberish, blockHashOrTag?: BlockTag | BigNumberish): Promise<BigNumberish>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the transaction information from a tx id.
|
|
41
|
+
*
|
|
42
|
+
* @param txHash
|
|
43
|
+
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
44
|
+
*/
|
|
45
|
+
abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the transaction receipt from a tx hash.
|
|
48
|
+
*
|
|
49
|
+
* @param txHash
|
|
50
|
+
* @returns the transaction receipt object
|
|
51
|
+
*/
|
|
52
|
+
abstract getTransactionReceipt(transactionHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Deploys a given compiled contract (json) to starknet
|
|
55
|
+
*
|
|
56
|
+
* @param payload payload to be deployed containing:
|
|
57
|
+
* - compiled contract code
|
|
58
|
+
* - constructor calldata
|
|
59
|
+
* - address salt
|
|
60
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
61
|
+
*/
|
|
62
|
+
abstract deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Declares a given compiled contract (json) to starknet
|
|
65
|
+
*
|
|
66
|
+
* @param payload payload to be deployed containing:
|
|
67
|
+
* - compiled contract code
|
|
68
|
+
* - optional version
|
|
69
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
70
|
+
*/
|
|
71
|
+
abstract declareContract(payload: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Invokes a function on starknet
|
|
74
|
+
* @deprecated This method wont be supported as soon as fees are mandatory
|
|
75
|
+
*
|
|
76
|
+
* @param invocation the invocation object containing:
|
|
77
|
+
* - contractAddress - the address of the contract
|
|
78
|
+
* - entrypoint - the entrypoint of the contract
|
|
79
|
+
* - calldata - (defaults to []) the calldata
|
|
80
|
+
* - signature - (defaults to []) the signature
|
|
81
|
+
* @param details - optional details containing:
|
|
82
|
+
* - nonce - optional nonce
|
|
83
|
+
* - version - optional version
|
|
84
|
+
* - maxFee - optional maxFee
|
|
85
|
+
* @returns response from addTransaction
|
|
86
|
+
*/
|
|
87
|
+
abstract invokeFunction(invocation: Invocation, details?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Estimates the fee for a given transaction
|
|
90
|
+
*
|
|
91
|
+
* @param invocation the invocation object containing:
|
|
92
|
+
* - contractAddress - the address of the contract
|
|
93
|
+
* - entrypoint - the entrypoint of the contract
|
|
94
|
+
* - calldata - (defaults to []) the calldata
|
|
95
|
+
* - signature - (defaults to []) the signature
|
|
96
|
+
* @param blockIdentifier - block identifier
|
|
97
|
+
* @param details - optional details containing:
|
|
98
|
+
* - nonce - optional nonce
|
|
99
|
+
* - version - optional version
|
|
100
|
+
* @returns the estimated fee
|
|
101
|
+
*/
|
|
102
|
+
abstract getEstimateFee(invocation: Invocation, blockIdentifier: BlockIdentifier, details?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Wait for the transaction to be accepted
|
|
105
|
+
* @param txHash - transaction hash
|
|
106
|
+
* @param retryInterval - retry interval
|
|
107
|
+
*/
|
|
108
|
+
abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
136
109
|
}
|
package/provider/interface.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProviderInterface = void 0;
|
|
4
4
|
var ProviderInterface = /** @class */ (function () {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function ProviderInterface() {
|
|
6
|
+
}
|
|
7
|
+
return ProviderInterface;
|
|
8
|
+
}());
|
|
8
9
|
exports.ProviderInterface = ProviderInterface;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { StarknetChainId } from '../constants';
|
|
2
|
+
import { BlockTag, Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetails, InvokeFunctionResponse } from '../types';
|
|
3
|
+
import { RPC } from '../types/api';
|
|
4
|
+
import { BigNumberish } from '../utils/number';
|
|
5
|
+
import { ProviderInterface } from './interface';
|
|
6
|
+
import { BlockIdentifier } from './utils';
|
|
7
|
+
export declare type RpcProviderOptions = {
|
|
8
|
+
nodeUrl: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class RpcProvider implements ProviderInterface {
|
|
11
|
+
nodeUrl: string;
|
|
12
|
+
chainId: StarknetChainId;
|
|
13
|
+
private responseParser;
|
|
14
|
+
constructor(optionsOrProvider: RpcProviderOptions);
|
|
15
|
+
protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, request?: RPC.Methods[T]['REQUEST']): Promise<RPC.Methods[T]['RESPONSE']>;
|
|
16
|
+
getChainId(): Promise<StarknetChainId>;
|
|
17
|
+
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
18
|
+
getStorageAt(contractAddress: string, key: BigNumberish, blockHashOrTag?: BlockTag | BigNumberish): Promise<BigNumberish>;
|
|
19
|
+
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
20
|
+
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
21
|
+
getClassAt(contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<any>;
|
|
22
|
+
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
|
23
|
+
declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
24
|
+
deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
|
|
25
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
26
|
+
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
27
|
+
waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the transaction count from a block.
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @param blockIdentifier
|
|
33
|
+
* @returns Number of transactions
|
|
34
|
+
*/
|
|
35
|
+
getTransactionCount(blockIdentifier: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the latest block number
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* @returns Number of the latest block
|
|
41
|
+
*/
|
|
42
|
+
getBlockNumber(): Promise<RPC.GetBlockNumberResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets syncing status of the node
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* @returns Object with the stats data
|
|
48
|
+
*/
|
|
49
|
+
getSyncingStats(): Promise<RPC.GetSyncingStatsResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets all the events filtered
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* @returns events and the pagination of the events
|
|
55
|
+
*/
|
|
56
|
+
getEvents(eventFilter: RPC.EventFilter): Promise<RPC.GetEventsResponse>;
|
|
57
|
+
}
|