starknet 4.17.0 → 4.18.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 (150) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +27 -9
  4. package/dist/index.global.js +30 -13
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +30 -13
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +30 -13
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +5 -1
  11. package/.babelrc +0 -6
  12. package/.commitlintrc +0 -22
  13. package/.eslintignore +0 -2
  14. package/.eslintrc +0 -28
  15. package/.prettierrc +0 -6
  16. package/.releaserc +0 -28
  17. package/CODE_OF_CONDUCT.md +0 -128
  18. package/CONTRIBUTING.md +0 -52
  19. package/__mocks__/Account.json +0 -25486
  20. package/__mocks__/ERC20.json +0 -40027
  21. package/__mocks__/TestDapp.json +0 -12962
  22. package/__mocks__/contract.json +0 -33191
  23. package/__mocks__/l1l2_compiled.json +0 -10107
  24. package/__mocks__/multicall.json +0 -8139
  25. package/__mocks__/naming_compiled.json +0 -53283
  26. package/__mocks__/starknetId_compiled.json +0 -44703
  27. package/__mocks__/typedDataExample.json +0 -35
  28. package/__mocks__/typedDataSessionExample.json +0 -42
  29. package/__mocks__/typedDataStructArrayExample.json +0 -44
  30. package/__tests__/account.test.ts +0 -345
  31. package/__tests__/contract.test.ts +0 -249
  32. package/__tests__/defaultProvider.test.ts +0 -177
  33. package/__tests__/fixtures.ts +0 -84
  34. package/__tests__/jest.setup.ts +0 -30
  35. package/__tests__/rpcProvider.test.ts +0 -132
  36. package/__tests__/sequencerProvider.test.ts +0 -123
  37. package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
  38. package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
  39. package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
  40. package/__tests__/utils/address.test.ts +0 -45
  41. package/__tests__/utils/ellipticalCurve.test.ts +0 -91
  42. package/__tests__/utils/merkle.test.ts +0 -256
  43. package/__tests__/utils/shortString.test.ts +0 -22
  44. package/__tests__/utils/starknetId.test.ts +0 -53
  45. package/__tests__/utils/transactionHash.test.ts +0 -17
  46. package/__tests__/utils/typedData.test.ts +0 -223
  47. package/__tests__/utils/uint256.test.ts +0 -32
  48. package/__tests__/utils/utils.browser.test.ts +0 -29
  49. package/__tests__/utils/utils.test.ts +0 -141
  50. package/img/logo.svg +0 -17
  51. package/index.d.ts +0 -2683
  52. package/index.global.js +0 -23192
  53. package/index.global.js.map +0 -1
  54. package/index.js +0 -4910
  55. package/index.js.map +0 -1
  56. package/index.mjs +0 -4852
  57. package/index.mjs.map +0 -1
  58. package/src/account/default.ts +0 -501
  59. package/src/account/index.ts +0 -2
  60. package/src/account/interface.ts +0 -309
  61. package/src/constants.ts +0 -2065
  62. package/src/contract/contractFactory.ts +0 -88
  63. package/src/contract/default.ts +0 -425
  64. package/src/contract/index.ts +0 -3
  65. package/src/contract/interface.ts +0 -106
  66. package/src/index.ts +0 -26
  67. package/src/provider/default.ts +0 -187
  68. package/src/provider/errors.ts +0 -14
  69. package/src/provider/index.ts +0 -9
  70. package/src/provider/interface.ts +0 -281
  71. package/src/provider/rpc.ts +0 -482
  72. package/src/provider/sequencer.ts +0 -523
  73. package/src/provider/utils.ts +0 -100
  74. package/src/signer/default.ts +0 -99
  75. package/src/signer/index.ts +0 -2
  76. package/src/signer/interface.ts +0 -77
  77. package/src/types/account.ts +0 -43
  78. package/src/types/api/index.ts +0 -10
  79. package/src/types/api/openrpc.ts +0 -607
  80. package/src/types/api/rpc.ts +0 -45
  81. package/src/types/api/sequencer.ts +0 -369
  82. package/src/types/contract.ts +0 -5
  83. package/src/types/index.ts +0 -8
  84. package/src/types/lib.ts +0 -143
  85. package/src/types/provider.ts +0 -134
  86. package/src/types/signer.ts +0 -24
  87. package/src/utils/address.ts +0 -44
  88. package/src/utils/calldata.ts +0 -250
  89. package/src/utils/ellipticCurve.ts +0 -120
  90. package/src/utils/encode.ts +0 -66
  91. package/src/utils/events.ts +0 -32
  92. package/src/utils/fetchPonyfill.ts +0 -5
  93. package/src/utils/hash.ts +0 -235
  94. package/src/utils/json.ts +0 -15
  95. package/src/utils/merkle.ts +0 -69
  96. package/src/utils/number.ts +0 -98
  97. package/src/utils/provider.ts +0 -28
  98. package/src/utils/responseParser/index.ts +0 -28
  99. package/src/utils/responseParser/rpc.ts +0 -70
  100. package/src/utils/responseParser/sequencer.ts +0 -135
  101. package/src/utils/shortString.ts +0 -21
  102. package/src/utils/stark.ts +0 -57
  103. package/src/utils/starknetId.ts +0 -116
  104. package/src/utils/transaction.ts +0 -56
  105. package/src/utils/typedData/index.ts +0 -247
  106. package/src/utils/typedData/types.ts +0 -37
  107. package/src/utils/typedData/utils.ts +0 -16
  108. package/src/utils/uint256.ts +0 -32
  109. package/src/utils/url.ts +0 -53
  110. package/tsconfig.eslint.json +0 -4
  111. package/tsup.config.ts +0 -9
  112. package/www/README.md +0 -41
  113. package/www/babel.config.js +0 -3
  114. package/www/code-examples/account.js +0 -65
  115. package/www/code-examples/amm.js +0 -44
  116. package/www/code-examples/erc20.js +0 -13
  117. package/www/code-examples/package-lock.json +0 -336
  118. package/www/code-examples/package.json +0 -15
  119. package/www/docs/API/_category_.json +0 -5
  120. package/www/docs/API/account.md +0 -463
  121. package/www/docs/API/changelog.md +0 -15
  122. package/www/docs/API/contract.md +0 -135
  123. package/www/docs/API/contractFactory.md +0 -45
  124. package/www/docs/API/index.md +0 -3
  125. package/www/docs/API/provider.md +0 -725
  126. package/www/docs/API/signer.md +0 -105
  127. package/www/docs/API/utils.md +0 -374
  128. package/www/docusaurus.config.js +0 -130
  129. package/www/guides/account.md +0 -140
  130. package/www/guides/cra.md +0 -3
  131. package/www/guides/erc20.md +0 -163
  132. package/www/guides/intro.md +0 -63
  133. package/www/package-lock.json +0 -20405
  134. package/www/package.json +0 -43
  135. package/www/sidebars.js +0 -31
  136. package/www/src/components/HomepageFeatures/index.tsx +0 -67
  137. package/www/src/components/HomepageFeatures/styles.module.css +0 -10
  138. package/www/src/css/custom.css +0 -39
  139. package/www/src/pages/index.module.css +0 -23
  140. package/www/src/pages/index.tsx +0 -40
  141. package/www/src/pages/markdown-page.md +0 -7
  142. package/www/static/.nojekyll +0 -0
  143. package/www/static/img/docusaurus.png +0 -0
  144. package/www/static/img/favicon.ico +0 -0
  145. package/www/static/img/logo.svg +0 -17
  146. package/www/static/img/starknet-1.png +0 -0
  147. package/www/static/img/starknet-2.png +0 -0
  148. package/www/static/img/starknet-3.png +0 -0
  149. package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
  150. package/www/static/img/tutorial/localeDropdown.png +0 -0
@@ -1,99 +0,0 @@
1
- import {
2
- Abi,
3
- Call,
4
- DeclareSignerDetails,
5
- DeployAccountSignerDetails,
6
- InvocationsSignerDetails,
7
- KeyPair,
8
- Signature,
9
- } from '../types';
10
- import { genKeyPair, getStarkKey, sign } from '../utils/ellipticCurve';
11
- import {
12
- calculateDeclareTransactionHash,
13
- calculateDeployAccountTransactionHash,
14
- calculateTransactionHash,
15
- } from '../utils/hash';
16
- import { fromCallsToExecuteCalldata } from '../utils/transaction';
17
- import { TypedData, getMessageHash } from '../utils/typedData';
18
- import { SignerInterface } from './interface';
19
-
20
- export class Signer implements SignerInterface {
21
- protected keyPair: KeyPair;
22
-
23
- constructor(keyPair: KeyPair = genKeyPair()) {
24
- this.keyPair = keyPair;
25
- }
26
-
27
- public async getPubKey(): Promise<string> {
28
- return getStarkKey(this.keyPair);
29
- }
30
-
31
- public async signMessage(typedData: TypedData, accountAddress: string): Promise<Signature> {
32
- const msgHash = getMessageHash(typedData, accountAddress);
33
- return sign(this.keyPair, msgHash);
34
- }
35
-
36
- public async signTransaction(
37
- transactions: Call[],
38
- transactionsDetail: InvocationsSignerDetails,
39
- abis?: Abi[]
40
- ): Promise<Signature> {
41
- if (abis && abis.length !== transactions.length) {
42
- throw new Error('ABI must be provided for each transaction or no transaction');
43
- }
44
- // now use abi to display decoded data somewhere, but as this signer is headless, we can't do that
45
-
46
- const calldata = fromCallsToExecuteCalldata(transactions);
47
-
48
- const msgHash = calculateTransactionHash(
49
- transactionsDetail.walletAddress,
50
- transactionsDetail.version,
51
- calldata,
52
- transactionsDetail.maxFee,
53
- transactionsDetail.chainId,
54
- transactionsDetail.nonce
55
- );
56
-
57
- return sign(this.keyPair, msgHash);
58
- }
59
-
60
- public async signDeployAccountTransaction({
61
- classHash,
62
- contractAddress,
63
- constructorCalldata,
64
- addressSalt,
65
- maxFee,
66
- version,
67
- chainId,
68
- nonce,
69
- }: DeployAccountSignerDetails) {
70
- const msgHash = calculateDeployAccountTransactionHash(
71
- contractAddress,
72
- classHash,
73
- constructorCalldata,
74
- addressSalt,
75
- version,
76
- maxFee,
77
- chainId,
78
- nonce
79
- );
80
-
81
- return sign(this.keyPair, msgHash);
82
- }
83
-
84
- public async signDeclareTransaction(
85
- // contractClass: ContractClass, // Should be used once class hash is present in ContractClass
86
- { classHash, senderAddress, chainId, maxFee, version, nonce }: DeclareSignerDetails
87
- ) {
88
- const msgHash = calculateDeclareTransactionHash(
89
- classHash,
90
- senderAddress,
91
- version,
92
- maxFee,
93
- chainId,
94
- nonce
95
- );
96
-
97
- return sign(this.keyPair, msgHash);
98
- }
99
- }
@@ -1,2 +0,0 @@
1
- export * from './interface';
2
- export * from './default';
@@ -1,77 +0,0 @@
1
- import {
2
- Abi,
3
- Call,
4
- DeclareSignerDetails,
5
- DeployAccountSignerDetails,
6
- InvocationsSignerDetails,
7
- Signature,
8
- } from '../types';
9
- import { TypedData } from '../utils/typedData';
10
-
11
- export abstract class SignerInterface {
12
- /**
13
- * Method to get the public key of the signer
14
- *
15
- * @returns public key of signer as hex string with 0x prefix
16
- */
17
- public abstract getPubKey(): Promise<string>;
18
-
19
- /**
20
- * Sign an JSON object for off-chain usage with the starknet private key and return the signature
21
- * This adds a message prefix so it cant be interchanged with transactions
22
- *
23
- * @param typedData - JSON object to be signed
24
- * @param accountAddress - account
25
- * @returns the signature of the JSON object
26
- * @throws {Error} if the JSON object is not a valid JSON
27
- */
28
- public abstract signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
29
-
30
- /**
31
- * Signs a transaction with the starknet private key and returns the signature
32
- *
33
- * @param invocation the invocation object containing:
34
- * - contractAddress - the address of the contract
35
- * - entrypoint - the entrypoint of the contract
36
- * - calldata - (defaults to []) the calldata
37
- * @param abi (optional) the abi of the contract for better displaying
38
- *
39
- * @returns signature
40
- */
41
- public abstract signTransaction(
42
- transactions: Call[],
43
- transactionsDetail: InvocationsSignerDetails,
44
- abis?: Abi[]
45
- ): Promise<Signature>;
46
-
47
- /**
48
- * Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature
49
- *
50
- * @param transaction
51
- * - contractAddress - the computed address of the contract
52
- * - constructorCalldata - calldata to be passed in deploy constructor
53
- * - addressSalt - contract address salt
54
- * - chainId - the chainId to declare contract on
55
- * - maxFee - maxFee for the declare transaction
56
- * - version - transaction version
57
- * - nonce - Nonce of the declare transaction
58
- * @returns signature
59
- */
60
- public abstract signDeployAccountTransaction(
61
- transaction: DeployAccountSignerDetails
62
- ): Promise<Signature>;
63
-
64
- /**
65
- * Signs a DECLARE transaction with the starknet private key and returns the signature
66
- *
67
- * @param transaction
68
- * - classHash - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
69
- * - senderAddress - the address of the sender
70
- * - chainId - the chainId to declare contract on
71
- * - maxFee - maxFee for the declare transaction
72
- * - version - transaction version
73
- * - nonce - Nonce of the declare transaction
74
- * @returns signature
75
- */
76
- public abstract signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
77
- }
@@ -1,43 +0,0 @@
1
- import BN from 'bn.js';
2
-
3
- import { BlockIdentifier } from '../provider/utils';
4
- import { BigNumberish } from '../utils/number';
5
- import { DeclareTransactionReceiptResponse, EstimateFeeResponse } from './provider';
6
-
7
- export interface EstimateFee extends EstimateFeeResponse {
8
- suggestedMaxFee: BN;
9
- }
10
-
11
- export interface EstimateFeeDetails {
12
- nonce?: BigNumberish;
13
- blockIdentifier?: BlockIdentifier;
14
- }
15
-
16
- export interface DeployContractResponse {
17
- contract_address: string;
18
- transaction_hash: string;
19
- }
20
-
21
- export type MultiDeployContractResponse = {
22
- contract_address: Array<string>;
23
- transaction_hash: string;
24
- };
25
-
26
- export type DeployContractUDCResponse = {
27
- contract_address: string;
28
- transaction_hash: string;
29
- address: string;
30
- deployer: string;
31
- unique: string;
32
- classHash: string;
33
- calldata_len: string;
34
- calldata: Array<string>;
35
- salt: string;
36
- };
37
-
38
- export type DeclareDeployUDCResponse = {
39
- declare: {
40
- class_hash: BigNumberish;
41
- } & DeclareTransactionReceiptResponse;
42
- deploy: DeployContractUDCResponse;
43
- };
@@ -1,10 +0,0 @@
1
- import { BigNumberish } from '../../utils/number';
2
- import { Signature } from '../lib';
3
-
4
- export type Calldata = string[];
5
-
6
- export type Overrides = {
7
- maxFee?: BigNumberish;
8
- nonce?: BigNumberish;
9
- signature?: Signature;
10
- };