starknet 6.9.0 → 6.10.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.
Files changed (315) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +1 -1
  3. package/README.md +5 -9
  4. package/dist/account/default.cjs +655 -0
  5. package/dist/account/default.d.ts +67 -0
  6. package/dist/account/default.mjs +652 -0
  7. package/dist/account/index.cjs +27 -0
  8. package/dist/account/index.d.ts +2 -0
  9. package/dist/account/index.mjs +2 -0
  10. package/dist/account/interface.cjs +9 -0
  11. package/dist/account/interface.d.ts +301 -0
  12. package/dist/account/interface.mjs +3 -0
  13. package/dist/channel/index.cjs +27 -0
  14. package/dist/channel/index.d.ts +3 -0
  15. package/dist/channel/index.mjs +3 -0
  16. package/dist/channel/rpc_0_6.cjs +607 -0
  17. package/dist/channel/rpc_0_6.d.ts +78 -0
  18. package/dist/channel/rpc_0_6.mjs +543 -0
  19. package/dist/channel/rpc_0_7.cjs +619 -0
  20. package/dist/channel/rpc_0_7.d.ts +81 -0
  21. package/dist/channel/rpc_0_7.mjs +561 -0
  22. package/dist/constants.cjs +76 -0
  23. package/dist/constants.d.ts +70 -0
  24. package/dist/constants.mjs +60 -0
  25. package/dist/contract/contractFactory.cjs +93 -0
  26. package/dist/contract/contractFactory.d.ts +46 -0
  27. package/dist/contract/contractFactory.mjs +83 -0
  28. package/dist/contract/default.cjs +269 -0
  29. package/dist/contract/default.d.ts +58 -0
  30. package/dist/contract/default.mjs +254 -0
  31. package/dist/contract/index.cjs +38 -0
  32. package/dist/contract/index.d.ts +3 -0
  33. package/dist/contract/index.mjs +3 -0
  34. package/dist/contract/interface.cjs +13 -0
  35. package/dist/contract/interface.d.ts +128 -0
  36. package/dist/contract/interface.mjs +6 -0
  37. package/dist/index.cjs +267 -0
  38. package/dist/index.d.ts +45 -5991
  39. package/dist/index.global.js +728 -609
  40. package/dist/index.global.js.map +1 -1
  41. package/dist/index.mjs +39 -7320
  42. package/dist/provider/errors.cjs +50 -0
  43. package/dist/provider/errors.d.ts +16 -0
  44. package/dist/provider/errors.mjs +35 -0
  45. package/dist/provider/extensions/default.cjs +11 -0
  46. package/dist/provider/extensions/default.d.ts +6 -0
  47. package/dist/provider/extensions/default.mjs +5 -0
  48. package/dist/provider/extensions/starknetId.cjs +174 -0
  49. package/dist/provider/extensions/starknetId.d.ts +10 -0
  50. package/dist/provider/extensions/starknetId.mjs +230 -0
  51. package/dist/provider/index.cjs +56 -0
  52. package/dist/provider/index.d.ts +6 -0
  53. package/dist/provider/index.mjs +6 -0
  54. package/dist/provider/interface.cjs +8 -0
  55. package/dist/provider/interface.d.ts +261 -0
  56. package/dist/provider/interface.mjs +2 -0
  57. package/dist/provider/rpc.cjs +301 -0
  58. package/dist/provider/rpc.d.ts +115 -0
  59. package/dist/provider/rpc.mjs +302 -0
  60. package/dist/service/types.cjs +1 -0
  61. package/dist/service/types.d.ts +5 -0
  62. package/dist/service/types.mjs +0 -0
  63. package/dist/signer/default.cjs +105 -0
  64. package/dist/signer/default.d.ts +12 -0
  65. package/dist/signer/default.mjs +102 -0
  66. package/dist/signer/ethSigner.cjs +123 -0
  67. package/dist/signer/ethSigner.d.ts +25 -0
  68. package/dist/signer/ethSigner.mjs +140 -0
  69. package/dist/signer/index.cjs +38 -0
  70. package/dist/signer/index.d.ts +3 -0
  71. package/dist/signer/index.mjs +3 -0
  72. package/dist/signer/interface.cjs +8 -0
  73. package/dist/signer/interface.d.ts +115 -0
  74. package/dist/signer/interface.mjs +2 -0
  75. package/dist/types/account.cjs +1 -0
  76. package/dist/types/account.d.ts +79 -0
  77. package/dist/types/account.mjs +0 -0
  78. package/dist/types/api/index.cjs +30 -0
  79. package/dist/types/api/index.d.ts +4 -0
  80. package/dist/types/api/index.mjs +4 -0
  81. package/dist/types/api/jsonrpc/index.cjs +1 -0
  82. package/dist/types/api/jsonrpc/index.d.ts +21 -0
  83. package/dist/types/api/jsonrpc/index.mjs +0 -0
  84. package/dist/types/api/rpcspec_0_6/components.cjs +1 -0
  85. package/dist/types/api/rpcspec_0_6/components.d.ts +541 -0
  86. package/dist/types/api/rpcspec_0_6/components.mjs +0 -0
  87. package/dist/types/api/rpcspec_0_6/contract.cjs +1 -0
  88. package/dist/types/api/rpcspec_0_6/contract.d.ts +85 -0
  89. package/dist/types/api/rpcspec_0_6/contract.mjs +0 -0
  90. package/dist/types/api/rpcspec_0_6/errors.cjs +1 -0
  91. package/dist/types/api/rpcspec_0_6/errors.d.ts +128 -0
  92. package/dist/types/api/rpcspec_0_6/errors.mjs +0 -0
  93. package/dist/types/api/rpcspec_0_6/index.cjs +45 -0
  94. package/dist/types/api/rpcspec_0_6/index.d.ts +8 -0
  95. package/dist/types/api/rpcspec_0_6/index.mjs +5 -0
  96. package/dist/types/api/rpcspec_0_6/methods.cjs +1 -0
  97. package/dist/types/api/rpcspec_0_6/methods.d.ts +207 -0
  98. package/dist/types/api/rpcspec_0_6/methods.mjs +0 -0
  99. package/dist/types/api/rpcspec_0_6/nonspec.cjs +65 -0
  100. package/dist/types/api/rpcspec_0_6/nonspec.d.ts +147 -0
  101. package/dist/types/api/rpcspec_0_6/nonspec.mjs +59 -0
  102. package/dist/types/cairoEnum.cjs +1 -0
  103. package/dist/types/cairoEnum.d.ts +2 -0
  104. package/dist/types/cairoEnum.mjs +0 -0
  105. package/dist/types/calldata.cjs +27 -0
  106. package/dist/types/calldata.d.ts +23 -0
  107. package/dist/types/calldata.mjs +21 -0
  108. package/dist/types/contract.cjs +1 -0
  109. package/dist/types/contract.d.ts +27 -0
  110. package/dist/types/contract.mjs +0 -0
  111. package/dist/types/helpers/valuesType.cjs +1 -0
  112. package/dist/types/helpers/valuesType.d.ts +1 -0
  113. package/dist/types/helpers/valuesType.mjs +0 -0
  114. package/dist/types/index.cjs +121 -0
  115. package/dist/types/index.d.ts +10 -0
  116. package/dist/types/index.mjs +10 -0
  117. package/dist/types/lib/contract/abi.cjs +1 -0
  118. package/dist/types/lib/contract/abi.d.ts +71 -0
  119. package/dist/types/lib/contract/abi.mjs +0 -0
  120. package/dist/types/lib/contract/index.cjs +50 -0
  121. package/dist/types/lib/contract/index.d.ts +26 -0
  122. package/dist/types/lib/contract/index.mjs +8 -0
  123. package/dist/types/lib/contract/legacy.cjs +1 -0
  124. package/dist/types/lib/contract/legacy.d.ts +33 -0
  125. package/dist/types/lib/contract/legacy.mjs +0 -0
  126. package/dist/types/lib/contract/sierra.cjs +1 -0
  127. package/dist/types/lib/contract/sierra.d.ts +52 -0
  128. package/dist/types/lib/contract/sierra.mjs +0 -0
  129. package/dist/types/lib/index.cjs +61 -0
  130. package/dist/types/lib/index.d.ts +259 -0
  131. package/dist/types/lib/index.mjs +36 -0
  132. package/dist/types/provider/configuration.cjs +1 -0
  133. package/dist/types/provider/configuration.d.ts +20 -0
  134. package/dist/types/provider/configuration.mjs +0 -0
  135. package/dist/types/provider/index.cjs +27 -0
  136. package/dist/types/provider/index.d.ts +2 -0
  137. package/dist/types/provider/index.mjs +2 -0
  138. package/dist/types/provider/response.cjs +30 -0
  139. package/dist/types/provider/response.d.ts +98 -0
  140. package/dist/types/provider/response.mjs +1 -0
  141. package/dist/types/provider/spec.cjs +1 -0
  142. package/dist/types/provider/spec.d.ts +49 -0
  143. package/dist/types/provider/spec.mjs +0 -0
  144. package/dist/types/signer.cjs +1 -0
  145. package/dist/types/signer.d.ts +49 -0
  146. package/dist/types/signer.mjs +0 -0
  147. package/dist/types/transactionReceipt.cjs +1 -0
  148. package/dist/types/transactionReceipt.d.ts +23 -0
  149. package/dist/types/transactionReceipt.mjs +0 -0
  150. package/dist/types/typedData.cjs +12 -0
  151. package/dist/types/typedData.d.ts +1 -0
  152. package/dist/types/typedData.mjs +3 -0
  153. package/dist/utils/address.cjs +44 -0
  154. package/dist/utils/address.d.ts +55 -0
  155. package/dist/utils/address.mjs +35 -0
  156. package/dist/utils/assert.cjs +11 -0
  157. package/dist/utils/assert.d.ts +12 -0
  158. package/dist/utils/assert.mjs +5 -0
  159. package/dist/utils/cairoDataTypes/felt.cjs +31 -0
  160. package/dist/utils/cairoDataTypes/felt.d.ts +6 -0
  161. package/dist/utils/cairoDataTypes/felt.mjs +27 -0
  162. package/dist/utils/cairoDataTypes/uint256.cjs +113 -0
  163. package/dist/utils/cairoDataTypes/uint256.d.ts +72 -0
  164. package/dist/utils/cairoDataTypes/uint256.mjs +103 -0
  165. package/dist/utils/cairoDataTypes/uint512.cjs +125 -0
  166. package/dist/utils/cairoDataTypes/uint512.d.ts +76 -0
  167. package/dist/utils/cairoDataTypes/uint512.mjs +123 -0
  168. package/dist/utils/calldata/byteArray.cjs +27 -0
  169. package/dist/utils/calldata/byteArray.d.ts +32 -0
  170. package/dist/utils/calldata/byteArray.mjs +20 -0
  171. package/dist/utils/calldata/cairo.cjs +114 -0
  172. package/dist/utils/calldata/cairo.d.ts +196 -0
  173. package/dist/utils/calldata/cairo.mjs +68 -0
  174. package/dist/utils/calldata/enum/CairoCustomEnum.cjs +55 -0
  175. package/dist/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  176. package/dist/utils/calldata/enum/CairoCustomEnum.mjs +50 -0
  177. package/dist/utils/calldata/enum/CairoOption.cjs +55 -0
  178. package/dist/utils/calldata/enum/CairoOption.d.ts +37 -0
  179. package/dist/utils/calldata/enum/CairoOption.mjs +50 -0
  180. package/dist/utils/calldata/enum/CairoResult.cjs +54 -0
  181. package/dist/utils/calldata/enum/CairoResult.d.ts +36 -0
  182. package/dist/utils/calldata/enum/CairoResult.mjs +47 -0
  183. package/dist/utils/calldata/enum/index.cjs +38 -0
  184. package/dist/utils/calldata/enum/index.d.ts +3 -0
  185. package/dist/utils/calldata/enum/index.mjs +3 -0
  186. package/dist/utils/calldata/formatter.cjs +55 -0
  187. package/dist/utils/calldata/formatter.d.ts +9 -0
  188. package/dist/utils/calldata/formatter.mjs +58 -0
  189. package/dist/utils/calldata/index.cjs +272 -0
  190. package/dist/utils/calldata/index.d.ts +90 -0
  191. package/dist/utils/calldata/index.mjs +276 -0
  192. package/dist/utils/calldata/parser/index.cjs +29 -0
  193. package/dist/utils/calldata/parser/index.d.ts +5 -0
  194. package/dist/utils/calldata/parser/index.mjs +21 -0
  195. package/dist/utils/calldata/parser/interface.cjs +8 -0
  196. package/dist/utils/calldata/parser/interface.d.ts +20 -0
  197. package/dist/utils/calldata/parser/interface.mjs +2 -0
  198. package/dist/utils/calldata/parser/parser-0-1.1.0.cjs +38 -0
  199. package/dist/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  200. package/dist/utils/calldata/parser/parser-0-1.1.0.mjs +31 -0
  201. package/dist/utils/calldata/parser/parser-2.0.0.cjs +42 -0
  202. package/dist/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  203. package/dist/utils/calldata/parser/parser-2.0.0.mjs +37 -0
  204. package/dist/utils/calldata/propertyOrder.cjs +159 -0
  205. package/dist/utils/calldata/propertyOrder.d.ts +2 -0
  206. package/dist/utils/calldata/propertyOrder.mjs +189 -0
  207. package/dist/utils/calldata/requestParser.cjs +204 -0
  208. package/dist/utils/calldata/requestParser.d.ts +11 -0
  209. package/dist/utils/calldata/requestParser.mjs +231 -0
  210. package/dist/utils/calldata/responseParser.cjs +200 -0
  211. package/dist/utils/calldata/responseParser.d.ts +11 -0
  212. package/dist/utils/calldata/responseParser.mjs +201 -0
  213. package/dist/utils/calldata/tuple.cjs +106 -0
  214. package/dist/utils/calldata/tuple.d.ts +6 -0
  215. package/dist/utils/calldata/tuple.mjs +88 -0
  216. package/dist/utils/calldata/validate.cjs +241 -0
  217. package/dist/utils/calldata/validate.d.ts +6 -0
  218. package/dist/utils/calldata/validate.mjs +315 -0
  219. package/dist/utils/contract.cjs +40 -0
  220. package/dist/utils/contract.d.ts +37 -0
  221. package/dist/utils/contract.mjs +31 -0
  222. package/dist/utils/ec.cjs +12 -0
  223. package/dist/utils/ec.d.ts +2 -0
  224. package/dist/utils/ec.mjs +2 -0
  225. package/dist/utils/encode.cjs +78 -0
  226. package/dist/utils/encode.d.ts +207 -0
  227. package/dist/utils/encode.mjs +56 -0
  228. package/dist/utils/eth.cjs +22 -0
  229. package/dist/utils/eth.d.ts +22 -0
  230. package/dist/utils/eth.mjs +14 -0
  231. package/dist/utils/events/index.cjs +144 -0
  232. package/dist/utils/events/index.d.ts +84 -0
  233. package/dist/utils/events/index.mjs +136 -0
  234. package/dist/utils/fetchPonyfill.cjs +14 -0
  235. package/dist/utils/fetchPonyfill.d.ts +2 -0
  236. package/dist/utils/fetchPonyfill.mjs +5 -0
  237. package/dist/utils/hash/classHash.cjs +151 -0
  238. package/dist/utils/hash/classHash.d.ts +120 -0
  239. package/dist/utils/hash/classHash.mjs +168 -0
  240. package/dist/utils/hash/index.cjs +49 -0
  241. package/dist/utils/hash/index.d.ts +7 -0
  242. package/dist/utils/hash/index.mjs +4 -0
  243. package/dist/utils/hash/selector.cjs +37 -0
  244. package/dist/utils/hash/selector.d.ts +57 -0
  245. package/dist/utils/hash/selector.mjs +28 -0
  246. package/dist/utils/hash/transactionHash/index.cjs +38 -0
  247. package/dist/utils/hash/transactionHash/index.d.ts +81 -0
  248. package/dist/utils/hash/transactionHash/index.mjs +102 -0
  249. package/dist/utils/hash/transactionHash/v2.cjs +31 -0
  250. package/dist/utils/hash/transactionHash/v2.d.ts +34 -0
  251. package/dist/utils/hash/transactionHash/v2.mjs +57 -0
  252. package/dist/utils/hash/transactionHash/v3.cjs +45 -0
  253. package/dist/utils/hash/transactionHash/v3.d.ts +24 -0
  254. package/dist/utils/hash/transactionHash/v3.mjs +80 -0
  255. package/dist/utils/json.cjs +21 -0
  256. package/dist/utils/json.d.ts +50 -0
  257. package/dist/utils/json.mjs +10 -0
  258. package/dist/utils/merkle.cjs +118 -0
  259. package/dist/utils/merkle.d.ts +87 -0
  260. package/dist/utils/merkle.mjs +114 -0
  261. package/dist/utils/num.cjs +109 -0
  262. package/dist/utils/num.d.ts +283 -0
  263. package/dist/utils/num.mjs +86 -0
  264. package/dist/utils/provider.cjs +182 -0
  265. package/dist/utils/provider.d.ts +217 -0
  266. package/dist/utils/provider.mjs +158 -0
  267. package/dist/utils/responseParser/index.cjs +27 -0
  268. package/dist/utils/responseParser/index.d.ts +2 -0
  269. package/dist/utils/responseParser/index.mjs +2 -0
  270. package/dist/utils/responseParser/interface.cjs +8 -0
  271. package/dist/utils/responseParser/interface.d.ts +13 -0
  272. package/dist/utils/responseParser/interface.mjs +2 -0
  273. package/dist/utils/responseParser/rpc.cjs +83 -0
  274. package/dist/utils/responseParser/rpc.d.ts +19 -0
  275. package/dist/utils/responseParser/rpc.mjs +77 -0
  276. package/dist/utils/shortString.cjs +56 -0
  277. package/dist/utils/shortString.d.ts +116 -0
  278. package/dist/utils/shortString.mjs +39 -0
  279. package/dist/utils/stark.cjs +137 -0
  280. package/dist/utils/stark.d.ts +224 -0
  281. package/dist/utils/stark.mjs +109 -0
  282. package/dist/utils/starknetId.cjs +196 -0
  283. package/dist/utils/starknetId.d.ts +182 -0
  284. package/dist/utils/starknetId.mjs +185 -0
  285. package/dist/utils/transaction.cjs +115 -0
  286. package/dist/utils/transaction.d.ts +185 -0
  287. package/dist/utils/transaction.mjs +98 -0
  288. package/dist/utils/transactionReceipt.cjs +54 -0
  289. package/dist/utils/transactionReceipt.d.ts +33 -0
  290. package/dist/utils/transactionReceipt.mjs +49 -0
  291. package/dist/utils/typedData.cjs +285 -0
  292. package/dist/utils/typedData.d.ts +54 -0
  293. package/dist/utils/typedData.mjs +286 -0
  294. package/dist/utils/uint256.cjs +30 -0
  295. package/dist/utils/uint256.d.ts +45 -0
  296. package/dist/utils/uint256.mjs +11 -0
  297. package/dist/utils/url.cjs +35 -0
  298. package/dist/utils/url.d.ts +29 -0
  299. package/dist/utils/url.mjs +27 -0
  300. package/dist/wallet/account.cjs +115 -0
  301. package/dist/wallet/account.d.ts +31 -0
  302. package/dist/wallet/account.mjs +112 -0
  303. package/dist/wallet/connect.cjs +90 -0
  304. package/dist/wallet/connect.d.ts +82 -0
  305. package/dist/wallet/connect.mjs +64 -0
  306. package/dist/wallet/index.cjs +16 -0
  307. package/dist/wallet/index.d.ts +1 -0
  308. package/dist/wallet/index.mjs +1 -0
  309. package/dist/wallet/types.cjs +1 -0
  310. package/dist/wallet/types.d.ts +4 -0
  311. package/dist/wallet/types.mjs +0 -0
  312. package/package.json +13 -13
  313. package/dist/index.js +0 -7426
  314. package/dist/index.js.map +0 -1
  315. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,140 @@
1
+ import { secp256k1 } from "@noble/curves/secp256k1";
2
+ import { ETransactionVersion2, ETransactionVersion3 } from "../types/api/index.mjs";
3
+ import { CallData } from "../utils/calldata/index.mjs";
4
+ import { addHexPrefix, buf2hex, removeHexPrefix, sanitizeHex } from "../utils/encode.mjs";
5
+ import { ethRandomPrivateKey } from "../utils/eth.mjs";
6
+ import {
7
+ calculateDeclareTransactionHash,
8
+ calculateDeployAccountTransactionHash,
9
+ calculateInvokeTransactionHash
10
+ } from "../utils/hash/index.mjs";
11
+ import { toHex } from "../utils/num.mjs";
12
+ import { intDAM } from "../utils/stark.mjs";
13
+ import { getExecuteCalldata } from "../utils/transaction.mjs";
14
+ import { getMessageHash } from "../utils/typedData.mjs";
15
+ import { bnToUint256 } from "../utils/uint256.mjs";
16
+ export class EthSigner {
17
+ pk;
18
+ // hex string without 0x and with an odd number of characters
19
+ constructor(pk = ethRandomPrivateKey()) {
20
+ this.pk = pk instanceof Uint8Array ? buf2hex(pk).padStart(64, "0") : removeHexPrefix(toHex(pk)).padStart(64, "0");
21
+ }
22
+ /**
23
+ * provides the Ethereum full public key (without parity prefix)
24
+ * @returns an hex string : 64 first characters are Point X coordinate. 64 last characters are Point Y coordinate.
25
+ */
26
+ async getPubKey() {
27
+ return addHexPrefix(
28
+ buf2hex(secp256k1.getPublicKey(this.pk, false)).padStart(130, "0").slice(2)
29
+ );
30
+ }
31
+ async signMessage(typedData, accountAddress) {
32
+ const msgHash = getMessageHash(typedData, accountAddress);
33
+ const signature = secp256k1.sign(
34
+ removeHexPrefix(sanitizeHex(msgHash)),
35
+ this.pk
36
+ );
37
+ return this.formatEthSignature(signature);
38
+ }
39
+ async signTransaction(transactions, details) {
40
+ const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
41
+ let msgHash;
42
+ if (Object.values(ETransactionVersion2).includes(details.version)) {
43
+ const det = details;
44
+ msgHash = calculateInvokeTransactionHash({
45
+ ...det,
46
+ senderAddress: det.walletAddress,
47
+ compiledCalldata,
48
+ version: det.version
49
+ });
50
+ } else if (Object.values(ETransactionVersion3).includes(details.version)) {
51
+ const det = details;
52
+ msgHash = calculateInvokeTransactionHash({
53
+ ...det,
54
+ senderAddress: det.walletAddress,
55
+ compiledCalldata,
56
+ version: det.version,
57
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
58
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
59
+ });
60
+ } else {
61
+ throw Error("unsupported signTransaction version");
62
+ }
63
+ const signature = secp256k1.sign(
64
+ removeHexPrefix(sanitizeHex(msgHash)),
65
+ this.pk
66
+ );
67
+ return this.formatEthSignature(signature);
68
+ }
69
+ async signDeployAccountTransaction(details) {
70
+ const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
71
+ let msgHash;
72
+ if (Object.values(ETransactionVersion2).includes(details.version)) {
73
+ const det = details;
74
+ msgHash = calculateDeployAccountTransactionHash({
75
+ ...det,
76
+ salt: det.addressSalt,
77
+ constructorCalldata: compiledConstructorCalldata,
78
+ version: det.version
79
+ });
80
+ } else if (Object.values(ETransactionVersion3).includes(details.version)) {
81
+ const det = details;
82
+ msgHash = calculateDeployAccountTransactionHash({
83
+ ...det,
84
+ salt: det.addressSalt,
85
+ compiledConstructorCalldata,
86
+ version: det.version,
87
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
88
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
89
+ });
90
+ } else {
91
+ throw Error("unsupported signDeployAccountTransaction version");
92
+ }
93
+ const signature = secp256k1.sign(
94
+ removeHexPrefix(sanitizeHex(msgHash)),
95
+ this.pk
96
+ );
97
+ return this.formatEthSignature(signature);
98
+ }
99
+ async signDeclareTransaction(details) {
100
+ let msgHash;
101
+ if (Object.values(ETransactionVersion2).includes(details.version)) {
102
+ const det = details;
103
+ msgHash = calculateDeclareTransactionHash({
104
+ ...det,
105
+ version: det.version
106
+ });
107
+ } else if (Object.values(ETransactionVersion3).includes(details.version)) {
108
+ const det = details;
109
+ msgHash = calculateDeclareTransactionHash({
110
+ ...det,
111
+ version: det.version,
112
+ nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
113
+ feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
114
+ });
115
+ } else {
116
+ throw Error("unsupported signDeclareTransaction version");
117
+ }
118
+ const signature = secp256k1.sign(
119
+ removeHexPrefix(sanitizeHex(msgHash)),
120
+ this.pk
121
+ );
122
+ return this.formatEthSignature(signature);
123
+ }
124
+ /**
125
+ * Serialize the signature in conformity with starknet::eth_signature::Signature
126
+ * @param ethSignature secp256k1 signature from Noble curves library
127
+ * @return an array of felts, representing a Cairo Eth Signature.
128
+ */
129
+ formatEthSignature(ethSignature) {
130
+ const r = bnToUint256(ethSignature.r);
131
+ const s = bnToUint256(ethSignature.s);
132
+ return [
133
+ toHex(r.low),
134
+ toHex(r.high),
135
+ toHex(s.low),
136
+ toHex(s.high),
137
+ toHex(ethSignature.recovery)
138
+ ];
139
+ }
140
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _interface = require("./interface.cjs");
7
+ Object.keys(_interface).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _interface[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _interface[key];
14
+ }
15
+ });
16
+ });
17
+ var _default = require("./default.cjs");
18
+ Object.keys(_default).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _default[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _default[key];
25
+ }
26
+ });
27
+ });
28
+ var _ethSigner = require("./ethSigner.cjs");
29
+ Object.keys(_ethSigner).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _ethSigner[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _ethSigner[key];
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,3 @@
1
+ export * from './interface';
2
+ export * from './default';
3
+ export * from './ethSigner';
@@ -0,0 +1,3 @@
1
+ export * from "./interface.mjs";
2
+ export * from "./default.mjs";
3
+ export * from "./ethSigner.mjs";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SignerInterface = void 0;
7
+ class SignerInterface {}
8
+ exports.SignerInterface = SignerInterface;
@@ -0,0 +1,115 @@
1
+ import { Call, DeclareSignerDetails, DeployAccountSignerDetails, InvocationsSignerDetails, Signature, TypedData } from '../types';
2
+ export declare abstract class SignerInterface {
3
+ /**
4
+ * Method to get the public key of the signer
5
+ *
6
+ * @returns {string} hex-string
7
+ * @example
8
+ * ```typescript
9
+ * const mySigner = new Signer("0x123");
10
+ * const result = await mySigner.getPubKey();
11
+ * // result = "0x566d69d8c99f62bc71118399bab25c1f03719463eab8d6a444cd11ece131616"
12
+ * ```
13
+ */
14
+ abstract getPubKey(): Promise<string>;
15
+ /**
16
+ * Signs a JSON object for off-chain usage with the private key and returns the signature.
17
+ * This adds a message prefix so it can't be interchanged with transactions
18
+ *
19
+ * @param {TypedData} typedData JSON object to be signed
20
+ * @param {string} accountAddress Hex string of the account's address
21
+ * @returns {Promise<Signature>} the signature of the message
22
+ * @example
23
+ * ```typescript
24
+ * const mySigner = new Signer("0x123");
25
+ * const myTypedData: TypedData = {
26
+ * domain: {name: "Example DApp",
27
+ * chainId: constants.StarknetChainId.SN_SEPOLIA,
28
+ * version: "0.0.3"},
29
+ * types: {StarkNetDomain: [
30
+ * { name: "name", type: "string" },
31
+ * { name: "chainId", type: "felt" },
32
+ * { name: "version", type: "string" }],
33
+ * Message: [{ name: "message", type: "felt" }]},
34
+ * primaryType: "Message", message: {message: "1234"}};
35
+ * const result = await mySigner.signMessage(myTypedData,"0x5d08a4e9188429da4e993c9bf25aafe5cd491ee2b501505d4d059f0c938f82d");
36
+ * // result = Signature {r: 684915484701699003335398790608214855489903651271362390249153620883122231253n,
37
+ * // s: 1399150959912500412309102776989465580949387575375484933432871778355496929189n, recovery: 1}
38
+ * ```
39
+
40
+ */
41
+ abstract signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
42
+ /**
43
+ * Signs transactions with the private key and returns the signature
44
+ *
45
+ * @param {Call[]} transactions array of Call objects
46
+ * @param {InvocationsSignerDetails} transactionsDetail InvocationsSignerDetails object
47
+ * @returns {Promise<Signature>} the signature of the transaction
48
+ * @example
49
+ * ```typescript
50
+ * const mySigner = new Signer("0x123");
51
+ * const calls: Call[] = [{
52
+ * contractAddress: "0x1234567890123456789012345678901234567890",
53
+ * entrypoint: "functionName",
54
+ * calldata: [1, 2, 3]
55
+ * }];
56
+ * const transactionsDetail: InvocationsSignerDetails = {
57
+ * walletAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
58
+ * chainId: constants.StarknetChainId.SN_MAIN,
59
+ * cairoVersion: "1",
60
+ * maxFee: '0x1234567890abcdef',
61
+ * version: "0x0", nonce: 1};
62
+ * const result = await mySigner.signTransaction(calls, transactionsDetail);
63
+ * // result = Signature {r: 304910226421970384958146916800275294114105560641204815169249090836676768876n,
64
+ * // s: 1072798866000813654190523783606274062837012608648308896325315895472901074693n, recovery: 0}
65
+ * ```
66
+ */
67
+ abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails): Promise<Signature>;
68
+ /**
69
+ * Signs a DEPLOY_ACCOUNT transaction with the private key and returns the signature
70
+ *
71
+ * @param {DeployAccountSignerDetails} transaction to deploy an account contract
72
+ * @returns {Promise<Signature>} the signature of the transaction to deploy an account
73
+ * @example
74
+ * ```typescript
75
+ * const mySigner = new Signer("0x123");
76
+ * const myDeployAcc: DeployAccountSignerDetails = {
77
+ * contractAddress: "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641",
78
+ * version: "0x2", chainId: constants.StarknetChainId.SN_SEPOLIA,
79
+ * classHash: "0x5f3614e8671257aff9ac38e929c74d65b02d460ae966cd826c9f04a7fa8e0d4",
80
+ * constructorCalldata: [1, 2],addressSalt: 1234,
81
+ * nonce: 45, maxFee: 10 ** 15, tip: 0, paymasterData: [],accountDeploymentData: [],
82
+ * nonceDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
83
+ * feeDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
84
+ * resourceBounds: stark.estimateFeeToBounds(constants.ZERO),
85
+ * }
86
+ * const result = await mySigner.signDeployAccountTransaction(myDeployAcc);
87
+ * // result = Signature {r: 2871311234341436528393212130310036951068553852419934781736214693308640202748n,
88
+ * // s: 1746271646048888422437132495446973163454853863041370993384284773665861377605n, recovery: 1}
89
+ * ```
90
+ */
91
+ abstract signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
92
+ /**
93
+ * Signs a DECLARE transaction with the private key and returns the signature
94
+ *
95
+ * @param {DeclareSignerDetails} transaction to declare a class
96
+ * @returns {Promise<Signature>} the signature of the transaction to declare a class
97
+ * @example
98
+ * ```typescript
99
+ * const mySigner = new Signer("0x123");
100
+ * const myDeclare: DeclareSignerDetails = {
101
+ * version: "0x2", chainId: constants.StarknetChainId.SN_SEPOLIA,
102
+ * senderAddress: "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641",
103
+ * classHash: "0x5f3614e8671257aff9ac38e929c74d65b02d460ae966cd826c9f04a7fa8e0d4",
104
+ * nonce: 45, maxFee: 10 ** 15, tip: 0, paymasterData: [], accountDeploymentData: [],
105
+ * nonceDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
106
+ * feeDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
107
+ * resourceBounds: stark.estimateFeeToBounds(constants.ZERO),
108
+ }
109
+ * const result = await mySigner.signDeclareTransaction(myDeclare);
110
+ * // result = Signature {r: 2432056944313955951711774394836075930010416436707488863728289188289211995670n,
111
+ * // s: 3407649393310177489888603098175002856596469926897298636282244411990343146307n, recovery: 1}
112
+ * ```
113
+ */
114
+ abstract signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
115
+ }
@@ -0,0 +1,2 @@
1
+ export class SignerInterface {
2
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,79 @@
1
+ import { EDataAvailabilityMode, ETransactionVersion, ResourceBounds } from './api';
2
+ import { AllowArray, BigNumberish, BlockIdentifier, Call, DeclareContractPayload, DeployAccountContractPayload, TransactionType, UniversalDeployerContractPayload, V3TransactionDetails } from './lib';
3
+ import { DeclareTransactionReceiptResponse, EstimateFeeResponse } from './provider';
4
+ export interface EstimateFee extends EstimateFeeResponse {
5
+ }
6
+ export type EstimateFeeBulk = Array<EstimateFee>;
7
+ export type AccountInvocationsFactoryDetails = {
8
+ versions: Array<`${ETransactionVersion}`>;
9
+ nonce?: BigNumberish;
10
+ blockIdentifier?: BlockIdentifier;
11
+ skipValidate?: boolean;
12
+ } & Partial<V3TransactionDetails>;
13
+ export interface UniversalDetails {
14
+ nonce?: BigNumberish;
15
+ blockIdentifier?: BlockIdentifier;
16
+ maxFee?: BigNumberish;
17
+ tip?: BigNumberish;
18
+ paymasterData?: BigNumberish[];
19
+ accountDeploymentData?: BigNumberish[];
20
+ nonceDataAvailabilityMode?: EDataAvailabilityMode;
21
+ feeDataAvailabilityMode?: EDataAvailabilityMode;
22
+ version?: BigNumberish;
23
+ resourceBounds?: ResourceBounds;
24
+ skipValidate?: boolean;
25
+ }
26
+ export interface EstimateFeeDetails extends UniversalDetails {
27
+ }
28
+ export interface DeployContractResponse {
29
+ contract_address: string;
30
+ transaction_hash: string;
31
+ }
32
+ export type MultiDeployContractResponse = {
33
+ contract_address: Array<string>;
34
+ transaction_hash: string;
35
+ };
36
+ export type DeployContractUDCResponse = {
37
+ contract_address: string;
38
+ transaction_hash: string;
39
+ address: string;
40
+ deployer: string;
41
+ unique: string;
42
+ classHash: string;
43
+ calldata_len: string;
44
+ calldata: Array<string>;
45
+ salt: string;
46
+ };
47
+ export type DeclareDeployUDCResponse = {
48
+ declare: {
49
+ class_hash: BigNumberish;
50
+ } & Partial<DeclareTransactionReceiptResponse>;
51
+ deploy: DeployContractUDCResponse;
52
+ };
53
+ export type SimulateTransactionDetails = {
54
+ nonce?: BigNumberish;
55
+ blockIdentifier?: BlockIdentifier;
56
+ skipValidate?: boolean;
57
+ skipExecute?: boolean;
58
+ } & Partial<V3TransactionDetails>;
59
+ export type EstimateFeeAction = {
60
+ type: typeof TransactionType.INVOKE;
61
+ payload: AllowArray<Call>;
62
+ } | {
63
+ type: typeof TransactionType.DECLARE;
64
+ payload: DeclareContractPayload;
65
+ } | {
66
+ type: typeof TransactionType.DEPLOY_ACCOUNT;
67
+ payload: DeployAccountContractPayload;
68
+ } | {
69
+ type: typeof TransactionType.DEPLOY;
70
+ payload: UniversalDeployerContractPayload;
71
+ };
72
+ export type StarkProfile = {
73
+ name?: string;
74
+ profilePicture?: string;
75
+ discord?: string;
76
+ twitter?: string;
77
+ github?: string;
78
+ proofOfPersonhood?: boolean;
79
+ };
File without changes
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ JRPC: true,
8
+ RPCSPEC06: true,
9
+ RPCSPEC07: true
10
+ };
11
+ exports.RPCSPEC07 = exports.RPCSPEC06 = exports.JRPC = void 0;
12
+ var _JRPC = _interopRequireWildcard(require("./jsonrpc/index.cjs"));
13
+ exports.JRPC = _JRPC;
14
+ var _RPCSPEC = _interopRequireWildcard(require("./rpcspec_0_6/index.cjs"));
15
+ exports.RPCSPEC06 = _RPCSPEC;
16
+ var _RPCSPEC2 = _interopRequireWildcard(require("starknet-types-07"));
17
+ exports.RPCSPEC07 = _RPCSPEC2;
18
+ Object.keys(_RPCSPEC2).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _RPCSPEC2[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _RPCSPEC2[key];
26
+ }
27
+ });
28
+ });
29
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
30
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -0,0 +1,4 @@
1
+ export * as JRPC from './jsonrpc';
2
+ export * as RPCSPEC06 from './rpcspec_0_6';
3
+ export * as RPCSPEC07 from 'starknet-types-07';
4
+ export * from 'starknet-types-07';
@@ -0,0 +1,4 @@
1
+ export * as JRPC from "./jsonrpc/index.mjs";
2
+ export * as RPCSPEC06 from "./rpcspec_0_6/index.mjs";
3
+ export * as RPCSPEC07 from "starknet-types-07";
4
+ export * from "starknet-types-07";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,21 @@
1
+ export type RequestBody = {
2
+ id: number | string;
3
+ jsonrpc: '2.0';
4
+ method: string;
5
+ params?: {};
6
+ };
7
+ export type ResponseBody = {
8
+ id: number | string;
9
+ jsonrpc: '2.0';
10
+ } & (SuccessResponseBody | ErrorResponseBody);
11
+ export type SuccessResponseBody = {
12
+ result: unknown;
13
+ };
14
+ export type ErrorResponseBody = {
15
+ error: Error;
16
+ };
17
+ export type Error = {
18
+ code: number;
19
+ message: string;
20
+ data?: unknown;
21
+ };
File without changes
@@ -0,0 +1 @@
1
+ "use strict";