starknet 4.12.0 → 4.13.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.
Files changed (224) hide show
  1. package/.eslintrc +1 -0
  2. package/CHANGELOG.md +14 -0
  3. package/__tests__/account.test.ts +0 -2
  4. package/dist/index.d.ts +2683 -24
  5. package/dist/index.global.js +22994 -0
  6. package/dist/index.global.js.map +1 -0
  7. package/dist/index.js +4713 -53
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +4655 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/index.d.ts +2683 -24
  12. package/index.global.js +22994 -0
  13. package/index.global.js.map +1 -0
  14. package/index.js +4713 -53
  15. package/index.js.map +1 -0
  16. package/index.mjs +4655 -0
  17. package/index.mjs.map +1 -0
  18. package/package.json +8 -2
  19. package/src/account/default.ts +43 -8
  20. package/src/account/interface.ts +25 -2
  21. package/src/constants.ts +0 -1
  22. package/src/provider/default.ts +3 -0
  23. package/src/provider/interface.ts +2 -0
  24. package/src/provider/rpc.ts +4 -4
  25. package/src/provider/sequencer.ts +4 -1
  26. package/src/types/lib.ts +1 -1
  27. package/src/types/provider.ts +5 -0
  28. package/src/utils/ellipticCurve.ts +3 -1
  29. package/src/utils/fetchPonyfill.ts +3 -2
  30. package/src/utils/hash.ts +3 -2
  31. package/src/utils/number.ts +2 -2
  32. package/tsup.config.ts +10 -0
  33. package/account/default.d.ts +0 -30
  34. package/account/default.js +0 -526
  35. package/account/index.d.ts +0 -2
  36. package/account/index.js +0 -18
  37. package/account/interface.d.ts +0 -161
  38. package/account/interface.js +0 -27
  39. package/constants.d.ts +0 -36
  40. package/constants.js +0 -2067
  41. package/contract/contractFactory.d.ts +0 -31
  42. package/contract/contractFactory.js +0 -102
  43. package/contract/default.d.ts +0 -108
  44. package/contract/default.js +0 -640
  45. package/contract/index.d.ts +0 -3
  46. package/contract/index.js +0 -19
  47. package/contract/interface.d.ts +0 -80
  48. package/contract/interface.js +0 -9
  49. package/dist/account/default.d.ts +0 -30
  50. package/dist/account/default.js +0 -526
  51. package/dist/account/index.d.ts +0 -2
  52. package/dist/account/index.js +0 -18
  53. package/dist/account/interface.d.ts +0 -161
  54. package/dist/account/interface.js +0 -27
  55. package/dist/constants.d.ts +0 -36
  56. package/dist/constants.js +0 -2067
  57. package/dist/contract/contractFactory.d.ts +0 -31
  58. package/dist/contract/contractFactory.js +0 -102
  59. package/dist/contract/default.d.ts +0 -108
  60. package/dist/contract/default.js +0 -640
  61. package/dist/contract/index.d.ts +0 -3
  62. package/dist/contract/index.js +0 -19
  63. package/dist/contract/interface.d.ts +0 -80
  64. package/dist/contract/interface.js +0 -9
  65. package/dist/provider/default.d.ts +0 -37
  66. package/dist/provider/default.js +0 -207
  67. package/dist/provider/errors.d.ts +0 -9
  68. package/dist/provider/errors.js +0 -40
  69. package/dist/provider/index.d.ts +0 -7
  70. package/dist/provider/index.js +0 -24
  71. package/dist/provider/interface.d.ts +0 -203
  72. package/dist/provider/interface.js +0 -9
  73. package/dist/provider/rpc.d.ts +0 -86
  74. package/dist/provider/rpc.js +0 -605
  75. package/dist/provider/sequencer.d.ts +0 -79
  76. package/dist/provider/sequencer.js +0 -575
  77. package/dist/provider/utils.d.ts +0 -30
  78. package/dist/provider/utils.js +0 -84
  79. package/dist/signer/default.d.ts +0 -13
  80. package/dist/signer/default.js +0 -102
  81. package/dist/signer/index.d.ts +0 -2
  82. package/dist/signer/index.js +0 -18
  83. package/dist/signer/interface.d.ts +0 -60
  84. package/dist/signer/interface.js +0 -9
  85. package/dist/types/account.d.ts +0 -11
  86. package/dist/types/account.js +0 -2
  87. package/dist/types/api/index.d.ts +0 -10
  88. package/dist/types/api/index.js +0 -18
  89. package/dist/types/api/openrpc.d.ts +0 -572
  90. package/dist/types/api/openrpc.js +0 -45
  91. package/dist/types/api/rpc.d.ts +0 -43
  92. package/dist/types/api/rpc.js +0 -2
  93. package/dist/types/api/sequencer.d.ts +0 -320
  94. package/dist/types/api/sequencer.js +0 -2
  95. package/dist/types/contract.d.ts +0 -5
  96. package/dist/types/contract.js +0 -2
  97. package/dist/types/index.d.ts +0 -7
  98. package/dist/types/index.js +0 -35
  99. package/dist/types/lib.d.ts +0 -120
  100. package/dist/types/lib.js +0 -8
  101. package/dist/types/provider.d.ts +0 -99
  102. package/dist/types/provider.js +0 -2
  103. package/dist/types/signer.d.ts +0 -19
  104. package/dist/types/signer.js +0 -2
  105. package/dist/utils/address.d.ts +0 -5
  106. package/dist/utils/address.js +0 -41
  107. package/dist/utils/ellipticCurve.d.ts +0 -29
  108. package/dist/utils/ellipticCurve.js +0 -132
  109. package/dist/utils/encode.d.ts +0 -15
  110. package/dist/utils/encode.js +0 -96
  111. package/dist/utils/fetchPonyfill.d.ts +0 -2
  112. package/dist/utils/fetchPonyfill.js +0 -6
  113. package/dist/utils/hash.d.ts +0 -37
  114. package/dist/utils/hash.js +0 -162
  115. package/dist/utils/json.d.ts +0 -16
  116. package/dist/utils/json.js +0 -19
  117. package/dist/utils/merkle.d.ts +0 -10
  118. package/dist/utils/merkle.js +0 -89
  119. package/dist/utils/number.d.ts +0 -16
  120. package/dist/utils/number.js +0 -112
  121. package/dist/utils/provider.d.ts +0 -4
  122. package/dist/utils/provider.js +0 -38
  123. package/dist/utils/responseParser/index.d.ts +0 -11
  124. package/dist/utils/responseParser/index.js +0 -9
  125. package/dist/utils/responseParser/rpc.d.ts +0 -20
  126. package/dist/utils/responseParser/rpc.js +0 -44
  127. package/dist/utils/responseParser/sequencer.d.ts +0 -17
  128. package/dist/utils/responseParser/sequencer.js +0 -99
  129. package/dist/utils/shortString.d.ts +0 -4
  130. package/dist/utils/shortString.js +0 -26
  131. package/dist/utils/stark.d.ts +0 -16
  132. package/dist/utils/stark.js +0 -91
  133. package/dist/utils/transaction.d.ts +0 -20
  134. package/dist/utils/transaction.js +0 -79
  135. package/dist/utils/typedData/index.d.ts +0 -72
  136. package/dist/utils/typedData/index.js +0 -239
  137. package/dist/utils/typedData/types.d.ts +0 -32
  138. package/dist/utils/typedData/types.js +0 -2
  139. package/dist/utils/typedData/utils.d.ts +0 -8
  140. package/dist/utils/typedData/utils.js +0 -16
  141. package/dist/utils/uint256.d.ts +0 -11
  142. package/dist/utils/uint256.js +0 -28
  143. package/dist/utils/url.d.ts +0 -7
  144. package/dist/utils/url.js +0 -49
  145. package/provider/default.d.ts +0 -37
  146. package/provider/default.js +0 -207
  147. package/provider/errors.d.ts +0 -9
  148. package/provider/errors.js +0 -40
  149. package/provider/index.d.ts +0 -7
  150. package/provider/index.js +0 -24
  151. package/provider/interface.d.ts +0 -203
  152. package/provider/interface.js +0 -9
  153. package/provider/rpc.d.ts +0 -86
  154. package/provider/rpc.js +0 -605
  155. package/provider/sequencer.d.ts +0 -79
  156. package/provider/sequencer.js +0 -575
  157. package/provider/utils.d.ts +0 -30
  158. package/provider/utils.js +0 -84
  159. package/signer/default.d.ts +0 -13
  160. package/signer/default.js +0 -102
  161. package/signer/index.d.ts +0 -2
  162. package/signer/index.js +0 -18
  163. package/signer/interface.d.ts +0 -60
  164. package/signer/interface.js +0 -9
  165. package/types/account.d.ts +0 -11
  166. package/types/account.js +0 -2
  167. package/types/api/index.d.ts +0 -10
  168. package/types/api/index.js +0 -18
  169. package/types/api/openrpc.d.ts +0 -572
  170. package/types/api/openrpc.js +0 -45
  171. package/types/api/rpc.d.ts +0 -43
  172. package/types/api/rpc.js +0 -2
  173. package/types/api/sequencer.d.ts +0 -320
  174. package/types/api/sequencer.js +0 -2
  175. package/types/contract.d.ts +0 -5
  176. package/types/contract.js +0 -2
  177. package/types/index.d.ts +0 -7
  178. package/types/index.js +0 -35
  179. package/types/lib.d.ts +0 -120
  180. package/types/lib.js +0 -8
  181. package/types/provider.d.ts +0 -99
  182. package/types/provider.js +0 -2
  183. package/types/signer.d.ts +0 -19
  184. package/types/signer.js +0 -2
  185. package/utils/address.d.ts +0 -5
  186. package/utils/address.js +0 -41
  187. package/utils/ellipticCurve.d.ts +0 -29
  188. package/utils/ellipticCurve.js +0 -132
  189. package/utils/encode.d.ts +0 -15
  190. package/utils/encode.js +0 -96
  191. package/utils/fetchPonyfill.d.ts +0 -2
  192. package/utils/fetchPonyfill.js +0 -6
  193. package/utils/hash.d.ts +0 -37
  194. package/utils/hash.js +0 -162
  195. package/utils/json.d.ts +0 -16
  196. package/utils/json.js +0 -19
  197. package/utils/merkle.d.ts +0 -10
  198. package/utils/merkle.js +0 -89
  199. package/utils/number.d.ts +0 -16
  200. package/utils/number.js +0 -112
  201. package/utils/provider.d.ts +0 -4
  202. package/utils/provider.js +0 -38
  203. package/utils/responseParser/index.d.ts +0 -11
  204. package/utils/responseParser/index.js +0 -9
  205. package/utils/responseParser/rpc.d.ts +0 -20
  206. package/utils/responseParser/rpc.js +0 -44
  207. package/utils/responseParser/sequencer.d.ts +0 -17
  208. package/utils/responseParser/sequencer.js +0 -99
  209. package/utils/shortString.d.ts +0 -4
  210. package/utils/shortString.js +0 -26
  211. package/utils/stark.d.ts +0 -16
  212. package/utils/stark.js +0 -91
  213. package/utils/transaction.d.ts +0 -20
  214. package/utils/transaction.js +0 -79
  215. package/utils/typedData/index.d.ts +0 -72
  216. package/utils/typedData/index.js +0 -239
  217. package/utils/typedData/types.d.ts +0 -32
  218. package/utils/typedData/types.js +0 -2
  219. package/utils/typedData/utils.d.ts +0 -8
  220. package/utils/typedData/utils.js +0 -16
  221. package/utils/uint256.d.ts +0 -11
  222. package/utils/uint256.js +0 -28
  223. package/utils/url.d.ts +0 -7
  224. package/utils/url.js +0 -49
@@ -1,161 +0,0 @@
1
- import { ProviderInterface } from '../provider';
2
- import { BlockIdentifier } from '../provider/utils';
3
- import { SignerInterface } from '../signer';
4
- import { Abi, Call, DeclareContractResponse, DeployContractResponse, EstimateFeeAction, EstimateFeeDetails, EstimateFeeResponse, InvocationsDetails, InvokeFunctionResponse, Signature } from '../types';
5
- import { AllowArray, DeclareContractPayload, DeployAccountContractPayload, UniversalDeployerContractPayload } from '../types/lib';
6
- import { BigNumberish } from '../utils/number';
7
- import { TypedData } from '../utils/typedData/types';
8
- export declare abstract class AccountInterface extends ProviderInterface {
9
- abstract address: string;
10
- abstract signer: SignerInterface;
11
- /**
12
- * @deprecated Use estimateInvokeFee or estimateDeclareFee instead
13
- * Estimate Fee for executing an INVOKE transaction on starknet
14
- *
15
- * @param calls the invocation object containing:
16
- * - contractAddress - the address of the contract
17
- * - entrypoint - the entrypoint of the contract
18
- * - calldata - (defaults to []) the calldata
19
- *
20
- * @returns response from estimate_fee
21
- */
22
- abstract estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
23
- /**
24
- * Estimate Fee for executing an INVOKE transaction on starknet
25
- *
26
- * @param calls the invocation object containing:
27
- * - contractAddress - the address of the contract
28
- * - entrypoint - the entrypoint of the contract
29
- * - calldata - (defaults to []) the calldata
30
- *
31
- * @returns response from estimate_fee
32
- */
33
- abstract estimateInvokeFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
34
- /**
35
- * Estimate Fee for executing a DECLARE transaction on starknet
36
- *
37
- * @param contractPayload the payload object containing:
38
- * - contract - the compiled contract to be declared
39
- * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
40
- *
41
- * @returns response from estimate_fee
42
- */
43
- abstract estimateDeclareFee(contractPayload: DeclareContractPayload, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
44
- /**
45
- * Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
46
- *
47
- * @param contractPayload the payload object containing:
48
- * - contract - the compiled contract to be deployed
49
- * - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
50
- *
51
- * @returns response from estimate_fee
52
- */
53
- abstract estimateAccountDeployFee(contractPayload: DeployAccountContractPayload, estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
54
- /**
55
- * Invoke execute function in account contract
56
- *
57
- * @param transactions the invocation object or an array of them, containing:
58
- * - contractAddress - the address of the contract
59
- * - entrypoint - the entrypoint of the contract
60
- * - calldata - (defaults to []) the calldata
61
- * - signature - (defaults to []) the signature
62
- * @param abi (optional) the abi of the contract for better displaying
63
- *
64
- * @returns response from addTransaction
65
- */
66
- abstract execute(transactions: AllowArray<Call>, abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
67
- /**
68
- * Declares a given compiled contract (json) to starknet
69
- *
70
- * @param contractPayload transaction payload to be deployed containing:
71
- - contract: compiled contract code
72
- - classHash: computed class hash of compiled contract
73
- - signature
74
- * @param transactionsDetail Invocation Details containing:
75
- - optional nonce
76
- - optional version
77
- - optional maxFee
78
- * @returns a confirmation of sending a transaction on the starknet contract
79
- */
80
- abstract declare(contractPayload: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
81
- /**
82
- * @param deployContractPayload containing
83
- * - classHash: computed class hash of compiled contract
84
- * - salt: address salt
85
- * - unique: bool if true ensure unique salt
86
- * - calldata: constructor calldata
87
- * @param additionalCalls - optional additional calls array to support multicall
88
- * @param transactionsDetail Invocation Details containing:
89
- * - optional nonce
90
- * - optional version
91
- * - optional maxFee
92
- */
93
- abstract deploy(deployContractPayload: UniversalDeployerContractPayload, additionalCalls?: AllowArray<Call>, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
94
- /**
95
- * Deploy the account on Starknet
96
- *
97
- * @param contractPayload transaction payload to be deployed containing:
98
- - classHash: computed class hash of compiled contract
99
- - optional constructor calldata
100
- - optional address salt
101
- - optional contractAddress
102
- * @param transactionsDetail Invocation Details containing:
103
- - optional nonce
104
- - optional version
105
- - optional maxFee
106
- * @returns a confirmation of sending a transaction on the starknet contract
107
- */
108
- abstract deployAccount(contractPayload: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
109
- /**
110
- * Sign an JSON object for off-chain usage with the starknet private key and return the signature
111
- * This adds a message prefix so it cant be interchanged with transactions
112
- *
113
- * @param json - JSON object to be signed
114
- * @returns the signature of the JSON object
115
- * @throws {Error} if the JSON object is not a valid JSON
116
- */
117
- abstract signMessage(typedData: TypedData): Promise<Signature>;
118
- /**
119
- * Hash a JSON object with pederson hash and return the hash
120
- * This adds a message prefix so it cant be interchanged with transactions
121
- *
122
- * @param json - JSON object to be hashed
123
- * @returns the hash of the JSON object
124
- * @throws {Error} if the JSON object is not a valid JSON
125
- */
126
- abstract hashMessage(typedData: TypedData): Promise<string>;
127
- /**
128
- * Verify a signature of a JSON object
129
- *
130
- * @param typedData - JSON object to be verified
131
- * @param signature - signature of the JSON object
132
- * @returns true if the signature is valid, false otherwise
133
- * @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
134
- */
135
- abstract verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
136
- /**
137
- * Verify a signature of a given hash
138
- * @warning This method is not recommended, use verifyMessage instead
139
- *
140
- * @param hash - hash to be verified
141
- * @param signature - signature of the hash
142
- * @returns true if the signature is valid, false otherwise
143
- * @throws {Error} if the signature is not a valid signature
144
- */
145
- abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
146
- /**
147
- * Gets the nonce of the account with respect to a specific block
148
- *
149
- * @param {BlockIdentifier} blockIdentifier - optional blockIdentifier. Defaults to 'pending'
150
- * @returns nonce of the account
151
- */
152
- abstract getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
153
- /**
154
- * Gets Suggested Max Fee based on the transaction type
155
- *
156
- * @param {EstimateFeeAction} estimateFeeAction
157
- * @param {EstimateFeeDetails} details
158
- * @returns suggestedMaxFee
159
- */
160
- abstract getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<BigNumberish>;
161
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (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);
8
- };
9
- return function (d, b) {
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 __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.AccountInterface = void 0;
19
- var provider_1 = require("../provider");
20
- var AccountInterface = /** @class */ (function (_super) {
21
- __extends(AccountInterface, _super);
22
- function AccountInterface() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- return AccountInterface;
26
- }(provider_1.ProviderInterface));
27
- exports.AccountInterface = AccountInterface;
@@ -1,36 +0,0 @@
1
- /// <reference types="bn.js" />
2
- export { IS_BROWSER } from './utils/encode';
3
- export declare const ZERO: import("bn.js");
4
- export declare const ONE: import("bn.js");
5
- export declare const TWO: import("bn.js");
6
- export declare const MASK_250: import("bn.js");
7
- export declare const MASK_251: import("bn.js");
8
- export declare enum StarknetChainId {
9
- MAINNET = "0x534e5f4d41494e",
10
- TESTNET = "0x534e5f474f45524c49",
11
- TESTNET2 = "0x534e5f474f45524c4932"
12
- }
13
- export declare enum TransactionHashPrefix {
14
- DECLARE = "0x6465636c617265",
15
- DEPLOY = "0x6465706c6f79",
16
- DEPLOY_ACCOUNT = "0x6465706c6f795f6163636f756e74",
17
- INVOKE = "0x696e766f6b65",
18
- L1_HANDLER = "0x6c315f68616e646c6572"
19
- }
20
- export declare const UDC: {
21
- ADDRESS: string;
22
- ENTRYPOINT: string;
23
- ADDRESS_DEVNET: string;
24
- };
25
- /**
26
- * The following is taken from https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/pedersen_params.json but converted to hex, because JS is very bad handling big integers by default
27
- * Please do not edit until the JSON changes.
28
- */
29
- export declare const FIELD_PRIME = "800000000000011000000000000000000000000000000000000000000000001";
30
- export declare const FIELD_GEN = "3";
31
- export declare const FIELD_SIZE = 251;
32
- export declare const EC_ORDER = "800000000000010FFFFFFFFFFFFFFFFB781126DCAE7B2321E66A241ADC64D2F";
33
- export declare const ALPHA = "1";
34
- export declare const BETA = "6F21413EFBE40DE150E596D72F7A8C5609AD26C15C915C1F4CDFCB99CEE9E89";
35
- export declare const MAX_ECDSA_VAL = "800000000000000000000000000000000000000000000000000000000000000";
36
- export declare const CONSTANT_POINTS: string[][];