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
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "browser": "dist/index.global.js",
6
8
  "types": "dist/index.d.ts",
7
9
  "scripts": {
8
10
  "prepare": "npm run build && husky install",
9
- "build": "tsc",
11
+ "build": "tsup && npm run build:esm && npm run build:iife",
12
+ "build:esm": "tsup --clean false --format esm --platform node",
13
+ "build:iife": "tsup --clean false --format iife --platform browser",
10
14
  "pretest": "npm run lint",
11
15
  "test": "jest",
12
16
  "posttest": "npm run format",
@@ -38,6 +42,7 @@
38
42
  "@semantic-release/npm": "^9.0.1",
39
43
  "@semantic-release/release-notes-generator": "^10.0.3",
40
44
  "@types/elliptic": "^6.4.14",
45
+ "@types/isomorphic-fetch": "^0.0.36",
41
46
  "@types/jest": "^28.1.1",
42
47
  "@types/json-bigint": "^1.0.1",
43
48
  "@types/minimalistic-assert": "^1.0.1",
@@ -59,6 +64,7 @@
59
64
  "lint-staged": "^13.0.1",
60
65
  "prettier": "^2.7.0",
61
66
  "prettier-plugin-import-sort": "^0.0.7",
67
+ "tsup": "^6.3.0",
62
68
  "typedoc": "^0.22.17",
63
69
  "typescript": "^4.7.3"
64
70
  },
@@ -166,6 +166,38 @@ export class Account extends Provider implements AccountInterface {
166
166
  };
167
167
  }
168
168
 
169
+ public async estimateDeployFee(
170
+ {
171
+ classHash,
172
+ salt,
173
+ unique = true,
174
+ constructorCalldata = [],
175
+ additionalCalls = [],
176
+ }: UniversalDeployerContractPayload,
177
+ transactionsDetail?: InvocationsDetails | undefined
178
+ ): Promise<EstimateFee> {
179
+ const compiledConstructorCallData = compileCalldata(constructorCalldata);
180
+
181
+ const callsArray = Array.isArray(additionalCalls) ? additionalCalls : [additionalCalls];
182
+ return this.estimateInvokeFee(
183
+ [
184
+ {
185
+ contractAddress: UDC.ADDRESS,
186
+ entrypoint: UDC.ENTRYPOINT,
187
+ calldata: [
188
+ classHash,
189
+ salt,
190
+ toCairoBool(unique),
191
+ compiledConstructorCallData.length,
192
+ ...compiledConstructorCallData,
193
+ ],
194
+ },
195
+ ...callsArray,
196
+ ],
197
+ transactionsDetail
198
+ );
199
+ }
200
+
169
201
  public async execute(
170
202
  calls: AllowArray<Call>,
171
203
  abis: Abi[] | undefined = undefined,
@@ -243,9 +275,8 @@ export class Account extends Provider implements AccountInterface {
243
275
  salt,
244
276
  unique = true,
245
277
  constructorCalldata = [],
246
- isDevnet = false,
278
+ additionalCalls = [],
247
279
  }: UniversalDeployerContractPayload,
248
- additionalCalls: AllowArray<Call> = [], // support multicall
249
280
  transactionsDetail: InvocationsDetails = {}
250
281
  ): Promise<InvokeFunctionResponse> {
251
282
  const compiledConstructorCallData = compileCalldata(constructorCalldata);
@@ -255,7 +286,7 @@ export class Account extends Provider implements AccountInterface {
255
286
  return this.execute(
256
287
  [
257
288
  {
258
- contractAddress: isDevnet ? UDC.ADDRESS_DEVNET : UDC.ADDRESS,
289
+ contractAddress: UDC.ADDRESS,
259
290
  entrypoint: UDC.ENTRYPOINT,
260
291
  calldata: [
261
292
  classHash,
@@ -350,22 +381,26 @@ export class Account extends Provider implements AccountInterface {
350
381
  }
351
382
 
352
383
  public async getSuggestedMaxFee(
353
- estimateFeeAction: EstimateFeeAction,
384
+ { type, payload }: EstimateFeeAction,
354
385
  details: EstimateFeeDetails
355
386
  ) {
356
387
  let feeEstimate: EstimateFee;
357
388
 
358
- switch (estimateFeeAction.type) {
389
+ switch (type) {
359
390
  case 'INVOKE':
360
- feeEstimate = await this.estimateInvokeFee(estimateFeeAction.payload, details);
391
+ feeEstimate = await this.estimateInvokeFee(payload, details);
361
392
  break;
362
393
 
363
394
  case 'DECLARE':
364
- feeEstimate = await this.estimateDeclareFee(estimateFeeAction.payload, details);
395
+ feeEstimate = await this.estimateDeclareFee(payload, details);
365
396
  break;
366
397
 
367
398
  case 'DEPLOY_ACCOUNT':
368
- feeEstimate = await this.estimateAccountDeployFee(estimateFeeAction.payload, details);
399
+ feeEstimate = await this.estimateAccountDeployFee(payload, details);
400
+ break;
401
+
402
+ case 'DEPLOY':
403
+ feeEstimate = await this.estimateDeployFee(payload, details);
369
404
  break;
370
405
 
371
406
  default:
@@ -86,6 +86,27 @@ export abstract class AccountInterface extends ProviderInterface {
86
86
  estimateFeeDetails?: EstimateFeeDetails
87
87
  ): Promise<EstimateFeeResponse>;
88
88
 
89
+ /**
90
+ * Estimate Fee for executing a UDC DEPLOY transaction on starknet
91
+ * This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
92
+
93
+ * @param deployContractPayload containing
94
+ * - classHash: computed class hash of compiled contract
95
+ * - salt: address salt
96
+ * - unique: bool if true ensure unique salt
97
+ * - calldata: constructor calldata
98
+ * - additionalCalls - optional additional calls array to support multicall
99
+ *
100
+ * @param transactionsDetail Invocation Details containing:
101
+ * - optional nonce
102
+ * - optional version
103
+ * - optional maxFee
104
+ */
105
+ public abstract estimateDeployFee(
106
+ deployContractPayload: UniversalDeployerContractPayload,
107
+ transactionsDetail?: InvocationsDetails
108
+ ): Promise<EstimateFeeResponse>;
109
+
89
110
  /**
90
111
  * Invoke execute function in account contract
91
112
  *
@@ -123,12 +144,15 @@ export abstract class AccountInterface extends ProviderInterface {
123
144
  ): Promise<DeclareContractResponse>;
124
145
 
125
146
  /**
147
+ * Deploys a given compiled contract (json) to starknet using Universal Deployer Contract (UDC)
148
+ * This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
149
+ *
126
150
  * @param deployContractPayload containing
127
151
  * - classHash: computed class hash of compiled contract
128
152
  * - salt: address salt
129
153
  * - unique: bool if true ensure unique salt
130
154
  * - calldata: constructor calldata
131
- * @param additionalCalls - optional additional calls array to support multicall
155
+ * - additionalCalls - optional additional calls array to support multicall
132
156
  * @param transactionsDetail Invocation Details containing:
133
157
  * - optional nonce
134
158
  * - optional version
@@ -136,7 +160,6 @@ export abstract class AccountInterface extends ProviderInterface {
136
160
  */
137
161
  public abstract deploy(
138
162
  deployContractPayload: UniversalDeployerContractPayload,
139
- additionalCalls?: AllowArray<Call>,
140
163
  transactionsDetail?: InvocationsDetails
141
164
  ): Promise<InvokeFunctionResponse>;
142
165
 
package/src/constants.ts CHANGED
@@ -24,7 +24,6 @@ export enum TransactionHashPrefix {
24
24
  export const UDC = {
25
25
  ADDRESS: '0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf',
26
26
  ENTRYPOINT: 'deployContract',
27
- ADDRESS_DEVNET: '0x25fcb74260022bd8ed7e8d542408941826b53345e478b8303d6f31744838a36',
28
27
  };
29
28
 
30
29
  /**
@@ -133,6 +133,9 @@ export class Provider implements ProviderInterface {
133
133
  return this.provider.invokeFunction(functionInvocation, details);
134
134
  }
135
135
 
136
+ /**
137
+ * @deprecated This method won't be supported, use Account.deploy instead
138
+ */
136
139
  public async deployContract(
137
140
  payload: DeployContractPayload,
138
141
  details: InvocationsDetails
@@ -140,6 +140,8 @@ export abstract class ProviderInterface {
140
140
  /**
141
141
  * Deploys a given compiled contract (json) to starknet
142
142
  *
143
+ * @deprecated This method won't be supported, use Account.deploy instead
144
+ *
143
145
  * @param payload payload to be deployed containing:
144
146
  * - compiled contract code
145
147
  * - constructor calldata
@@ -64,10 +64,10 @@ export class RpcProvider implements ProviderInterface {
64
64
  }
65
65
 
66
66
  public fetch(method: any, params: any): Promise<any> {
67
- return fetch(`${this.nodeUrl}/rpc/v0.2`, {
67
+ return fetch(this.nodeUrl, {
68
68
  method: 'POST',
69
69
  body: stringify({ method, jsonrpc: '2.0', params, id: 0 }),
70
- headers: this.headers,
70
+ headers: this.headers as Record<string, string>,
71
71
  });
72
72
  }
73
73
 
@@ -242,7 +242,7 @@ export class RpcProvider implements ProviderInterface {
242
242
  return this.fetchEndpoint('starknet_estimateFee', {
243
243
  request: {
244
244
  type: 'INVOKE',
245
- contract_address: invocation.contractAddress,
245
+ sender_address: invocation.contractAddress,
246
246
  calldata: parseCalldata(invocation.calldata),
247
247
  signature: bigNumberishArrayToHexadecimalStringArray(invocation.signature || []),
248
248
  version: toHex(toBN(invocationDetails?.version || 0)),
@@ -323,7 +323,7 @@ export class RpcProvider implements ProviderInterface {
323
323
  }
324
324
 
325
325
  /**
326
- * @deprecated This method wont be supported soon, use Account.deploy instead
326
+ * @deprecated This method won't be supported, use Account.deploy instead
327
327
  */
328
328
  public async deployContract(
329
329
  { contract, constructorCalldata, addressSalt }: DeployContractPayload,
@@ -193,7 +193,7 @@ export class SequencerProvider implements ProviderInterface {
193
193
  const res = await fetch(url, {
194
194
  method,
195
195
  body: stringify(request),
196
- headers,
196
+ headers: headers as Record<string, string>,
197
197
  });
198
198
  const textResponse = await res.text();
199
199
  if (!res.ok) {
@@ -326,6 +326,9 @@ export class SequencerProvider implements ProviderInterface {
326
326
  }).then(this.responseParser.parseInvokeFunctionResponse);
327
327
  }
328
328
 
329
+ /**
330
+ * @deprecated This method won't be supported, use Account.deploy instead
331
+ */
329
332
  public async deployContract({
330
333
  contract,
331
334
  constructorCalldata,
package/src/types/lib.ts CHANGED
@@ -24,7 +24,7 @@ export type UniversalDeployerContractPayload = {
24
24
  salt: string;
25
25
  unique: boolean;
26
26
  constructorCalldata?: RawArgs;
27
- isDevnet?: boolean;
27
+ additionalCalls?: AllowArray<Call>; // support multicall
28
28
  };
29
29
 
30
30
  export type DeployContractPayload = {
@@ -12,6 +12,7 @@ import {
12
12
  RawCalldata,
13
13
  Signature,
14
14
  Status,
15
+ UniversalDeployerContractPayload,
15
16
  } from './lib';
16
17
 
17
18
  export interface GetBlockResponse {
@@ -131,4 +132,8 @@ export type EstimateFeeAction =
131
132
  | {
132
133
  type: 'DEPLOY_ACCOUNT';
133
134
  payload: DeployAccountContractPayload;
135
+ }
136
+ | {
137
+ type: 'DEPLOY';
138
+ payload: UniversalDeployerContractPayload;
134
139
  };
@@ -1,4 +1,4 @@
1
- import { ec as EC, curves } from 'elliptic';
1
+ import elliptic from 'elliptic';
2
2
  import hashJS from 'hash.js';
3
3
  import assert from 'minimalistic-assert';
4
4
 
@@ -7,6 +7,8 @@ import { KeyPair, Signature } from '../types';
7
7
  import { addHexPrefix, removeHexPrefix, sanitizeBytes } from './encode';
8
8
  import { BigNumberish, assertInRange, toBN, toHex } from './number';
9
9
 
10
+ const { ec: EC, curves } = elliptic;
11
+
10
12
  export const ec = new EC(
11
13
  new curves.PresetCurve({
12
14
  type: 'short',
@@ -1,4 +1,5 @@
1
+ import isomorphicFetch from 'isomorphic-fetch';
2
+
1
3
  export default (typeof window !== 'undefined' && window.fetch) || // use buildin fetch in browser if available
2
4
  (typeof global !== 'undefined' && global.fetch) || // use buildin fetch in node, react-native and service worker if available
3
- // eslint-disable-next-line global-require
4
- require('isomorphic-fetch'); // ponyfill fetch in node and browsers that don't have it
5
+ isomorphicFetch; // ponyfill fetch in node and browsers that don't have it
package/src/utils/hash.ts CHANGED
@@ -1,6 +1,7 @@
1
+ /* eslint-disable import/extensions */
1
2
  import BN from 'bn.js';
2
- import { keccak256 } from 'ethereum-cryptography/keccak';
3
- import { hexToBytes } from 'ethereum-cryptography/utils';
3
+ import { keccak256 } from 'ethereum-cryptography/keccak.js';
4
+ import { hexToBytes } from 'ethereum-cryptography/utils.js';
4
5
  import assert from 'minimalistic-assert';
5
6
 
6
7
  import {
@@ -1,4 +1,4 @@
1
- import BN, { isBN } from 'bn.js';
1
+ import BN from 'bn.js';
2
2
  import assert from 'minimalistic-assert';
3
3
 
4
4
  import { addHexPrefix, removeHexPrefix } from './encode';
@@ -28,7 +28,7 @@ export function hexToDecimalString(hex: string): string {
28
28
  }
29
29
 
30
30
  export function toFelt(num: BigNumberish): string {
31
- if (isBN(num)) {
31
+ if (BN.isBN(num)) {
32
32
  return num.toString();
33
33
  }
34
34
  return toBN(num).toString();
package/tsup.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ dts: true,
6
+ sourcemap: true,
7
+ clean: true,
8
+ format: ['cjs'],
9
+ globalName: 'starknet',
10
+ });
@@ -1,30 +0,0 @@
1
- import { ProviderInterface, ProviderOptions } from '../provider';
2
- import { Provider } from '../provider/default';
3
- import { BlockIdentifier } from '../provider/utils';
4
- import { SignerInterface } from '../signer';
5
- import { Abi, Call, DeclareContractResponse, DeployContractResponse, EstimateFeeAction, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
6
- import { EstimateFee, EstimateFeeDetails } from '../types/account';
7
- import { AllowArray, DeclareContractPayload, DeployAccountContractPayload, UniversalDeployerContractPayload } from '../types/lib';
8
- import { BigNumberish } from '../utils/number';
9
- import { TypedData } from '../utils/typedData';
10
- import { AccountInterface } from './interface';
11
- export declare class Account extends Provider implements AccountInterface {
12
- signer: SignerInterface;
13
- address: string;
14
- constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
15
- getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
16
- estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails | undefined): Promise<EstimateFee>;
17
- estimateInvokeFee(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
18
- estimateDeclareFee({ classHash, contract }: DeclareContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
19
- estimateAccountDeployFee({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
20
- execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
21
- declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
22
- deploy({ classHash, salt, unique, constructorCalldata, isDevnet, }: UniversalDeployerContractPayload, additionalCalls?: AllowArray<Call>, // support multicall
23
- transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
24
- deployAccount({ classHash, constructorCalldata, addressSalt, contractAddress: providedContractAddress, }: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
25
- signMessage(typedData: TypedData): Promise<Signature>;
26
- hashMessage(typedData: TypedData): Promise<string>;
27
- verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
28
- verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
29
- getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
30
- }