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.
- package/CHANGELOG.md +20 -0
- package/README.md +2 -10
- package/dist/index.d.ts +27 -9
- package/dist/index.global.js +30 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
- package/.babelrc +0 -6
- package/.commitlintrc +0 -22
- package/.eslintignore +0 -2
- package/.eslintrc +0 -28
- package/.prettierrc +0 -6
- package/.releaserc +0 -28
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -52
- package/__mocks__/Account.json +0 -25486
- package/__mocks__/ERC20.json +0 -40027
- package/__mocks__/TestDapp.json +0 -12962
- package/__mocks__/contract.json +0 -33191
- package/__mocks__/l1l2_compiled.json +0 -10107
- package/__mocks__/multicall.json +0 -8139
- package/__mocks__/naming_compiled.json +0 -53283
- package/__mocks__/starknetId_compiled.json +0 -44703
- package/__mocks__/typedDataExample.json +0 -35
- package/__mocks__/typedDataSessionExample.json +0 -42
- package/__mocks__/typedDataStructArrayExample.json +0 -44
- package/__tests__/account.test.ts +0 -345
- package/__tests__/contract.test.ts +0 -249
- package/__tests__/defaultProvider.test.ts +0 -177
- package/__tests__/fixtures.ts +0 -84
- package/__tests__/jest.setup.ts +0 -30
- package/__tests__/rpcProvider.test.ts +0 -132
- package/__tests__/sequencerProvider.test.ts +0 -123
- package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
- package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
- package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
- package/__tests__/utils/address.test.ts +0 -45
- package/__tests__/utils/ellipticalCurve.test.ts +0 -91
- package/__tests__/utils/merkle.test.ts +0 -256
- package/__tests__/utils/shortString.test.ts +0 -22
- package/__tests__/utils/starknetId.test.ts +0 -53
- package/__tests__/utils/transactionHash.test.ts +0 -17
- package/__tests__/utils/typedData.test.ts +0 -223
- package/__tests__/utils/uint256.test.ts +0 -32
- package/__tests__/utils/utils.browser.test.ts +0 -29
- package/__tests__/utils/utils.test.ts +0 -141
- package/img/logo.svg +0 -17
- package/index.d.ts +0 -2683
- package/index.global.js +0 -23192
- package/index.global.js.map +0 -1
- package/index.js +0 -4910
- package/index.js.map +0 -1
- package/index.mjs +0 -4852
- package/index.mjs.map +0 -1
- package/src/account/default.ts +0 -501
- package/src/account/index.ts +0 -2
- package/src/account/interface.ts +0 -309
- package/src/constants.ts +0 -2065
- package/src/contract/contractFactory.ts +0 -88
- package/src/contract/default.ts +0 -425
- package/src/contract/index.ts +0 -3
- package/src/contract/interface.ts +0 -106
- package/src/index.ts +0 -26
- package/src/provider/default.ts +0 -187
- package/src/provider/errors.ts +0 -14
- package/src/provider/index.ts +0 -9
- package/src/provider/interface.ts +0 -281
- package/src/provider/rpc.ts +0 -482
- package/src/provider/sequencer.ts +0 -523
- package/src/provider/utils.ts +0 -100
- package/src/signer/default.ts +0 -99
- package/src/signer/index.ts +0 -2
- package/src/signer/interface.ts +0 -77
- package/src/types/account.ts +0 -43
- package/src/types/api/index.ts +0 -10
- package/src/types/api/openrpc.ts +0 -607
- package/src/types/api/rpc.ts +0 -45
- package/src/types/api/sequencer.ts +0 -369
- package/src/types/contract.ts +0 -5
- package/src/types/index.ts +0 -8
- package/src/types/lib.ts +0 -143
- package/src/types/provider.ts +0 -134
- package/src/types/signer.ts +0 -24
- package/src/utils/address.ts +0 -44
- package/src/utils/calldata.ts +0 -250
- package/src/utils/ellipticCurve.ts +0 -120
- package/src/utils/encode.ts +0 -66
- package/src/utils/events.ts +0 -32
- package/src/utils/fetchPonyfill.ts +0 -5
- package/src/utils/hash.ts +0 -235
- package/src/utils/json.ts +0 -15
- package/src/utils/merkle.ts +0 -69
- package/src/utils/number.ts +0 -98
- package/src/utils/provider.ts +0 -28
- package/src/utils/responseParser/index.ts +0 -28
- package/src/utils/responseParser/rpc.ts +0 -70
- package/src/utils/responseParser/sequencer.ts +0 -135
- package/src/utils/shortString.ts +0 -21
- package/src/utils/stark.ts +0 -57
- package/src/utils/starknetId.ts +0 -116
- package/src/utils/transaction.ts +0 -56
- package/src/utils/typedData/index.ts +0 -247
- package/src/utils/typedData/types.ts +0 -37
- package/src/utils/typedData/utils.ts +0 -16
- package/src/utils/uint256.ts +0 -32
- package/src/utils/url.ts +0 -53
- package/tsconfig.eslint.json +0 -4
- package/tsup.config.ts +0 -9
- package/www/README.md +0 -41
- package/www/babel.config.js +0 -3
- package/www/code-examples/account.js +0 -65
- package/www/code-examples/amm.js +0 -44
- package/www/code-examples/erc20.js +0 -13
- package/www/code-examples/package-lock.json +0 -336
- package/www/code-examples/package.json +0 -15
- package/www/docs/API/_category_.json +0 -5
- package/www/docs/API/account.md +0 -463
- package/www/docs/API/changelog.md +0 -15
- package/www/docs/API/contract.md +0 -135
- package/www/docs/API/contractFactory.md +0 -45
- package/www/docs/API/index.md +0 -3
- package/www/docs/API/provider.md +0 -725
- package/www/docs/API/signer.md +0 -105
- package/www/docs/API/utils.md +0 -374
- package/www/docusaurus.config.js +0 -130
- package/www/guides/account.md +0 -140
- package/www/guides/cra.md +0 -3
- package/www/guides/erc20.md +0 -163
- package/www/guides/intro.md +0 -63
- package/www/package-lock.json +0 -20405
- package/www/package.json +0 -43
- package/www/sidebars.js +0 -31
- package/www/src/components/HomepageFeatures/index.tsx +0 -67
- package/www/src/components/HomepageFeatures/styles.module.css +0 -10
- package/www/src/css/custom.css +0 -39
- package/www/src/pages/index.module.css +0 -23
- package/www/src/pages/index.tsx +0 -40
- package/www/src/pages/markdown-page.md +0 -7
- package/www/static/.nojekyll +0 -0
- package/www/static/img/docusaurus.png +0 -0
- package/www/static/img/favicon.ico +0 -0
- package/www/static/img/logo.svg +0 -17
- package/www/static/img/starknet-1.png +0 -0
- package/www/static/img/starknet-2.png +0 -0
- package/www/static/img/starknet-3.png +0 -0
- package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
- package/www/static/img/tutorial/localeDropdown.png +0 -0
package/www/docs/API/signer.md
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 3
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Signer
|
|
6
|
-
|
|
7
|
-
The **Signer** API allows you to sign transactions and messages, and also allows you to get the public key.
|
|
8
|
-
|
|
9
|
-
## Creating an instance
|
|
10
|
-
|
|
11
|
-
`new starknet.Signer(keyPair)`
|
|
12
|
-
|
|
13
|
-
## Methods
|
|
14
|
-
|
|
15
|
-
### getPubKey()
|
|
16
|
-
|
|
17
|
-
signer.**getPubKey**() => _Promise < string >_
|
|
18
|
-
|
|
19
|
-
Returns the public key of the signer.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
### signTransaction()
|
|
24
|
-
|
|
25
|
-
signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
26
|
-
|
|
27
|
-
Signs a transaction with the starknet private key and returns the signature.
|
|
28
|
-
|
|
29
|
-
The _transactions_ object for write methods may include any of:
|
|
30
|
-
|
|
31
|
-
- transactions.**contractAddress** - the address of the contract
|
|
32
|
-
- transactions.**entrypoint** - the entrypoint of the contract
|
|
33
|
-
- transactions.**calldata** - (defaults to []) the calldata
|
|
34
|
-
|
|
35
|
-
_abi_ - (optional) the abi of the contract for better displaying
|
|
36
|
-
|
|
37
|
-
###### _Signature_
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
string[]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
### signMessage()
|
|
46
|
-
|
|
47
|
-
signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_
|
|
48
|
-
|
|
49
|
-
Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
|
|
50
|
-
|
|
51
|
-
_typedData_ - JSON object to be signed
|
|
52
|
-
_accountAddress_ - calldata to be passed in deploy constructor
|
|
53
|
-
|
|
54
|
-
###### _Signature_
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
string[]
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
### signDeployAccountTransaction()
|
|
63
|
-
|
|
64
|
-
signer.**signDeployAccountTransaction**(transaction) => _Promise < Signature >_
|
|
65
|
-
|
|
66
|
-
Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature.
|
|
67
|
-
|
|
68
|
-
The _transactions_ object for write methods may include any of:
|
|
69
|
-
|
|
70
|
-
- transactions.**contractAddress** - the address of the contract
|
|
71
|
-
- transactions.**constructorCalldata** - calldata to be passed in deploy constructor
|
|
72
|
-
- transactions.**addressSalt** - contract address salt
|
|
73
|
-
- transactions.**chainId** - the chainId to declare contract on
|
|
74
|
-
- transactions.**maxFee** - maxFee for the declare transaction
|
|
75
|
-
- transactions.**version** - transaction version
|
|
76
|
-
- transactions.**nonce** - Nonce of the declare transaction
|
|
77
|
-
|
|
78
|
-
###### _Signature_
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
string[]
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### signDeclareTransaction()
|
|
87
|
-
|
|
88
|
-
signer.**signDeclareTransaction**(transaction, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
89
|
-
|
|
90
|
-
Signs a DECLARE transaction with the starknet private key and returns the signature.
|
|
91
|
-
|
|
92
|
-
The _transaction_ object for write methods may include any of:
|
|
93
|
-
|
|
94
|
-
- transactions.**classHash** - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
|
|
95
|
-
- transactions.**senderAddress** - the address of the sender
|
|
96
|
-
- transactions.**chainId** - the chainId to declare contract on
|
|
97
|
-
- transactions.**maxFee** - maxFee for the declare transaction
|
|
98
|
-
- transactions.**version** - transaction version
|
|
99
|
-
- transactions.**nonce** - Nonce of the declare transaction
|
|
100
|
-
|
|
101
|
-
###### _Signature_
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
string[]
|
|
105
|
-
```
|
package/www/docs/API/utils.md
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 6
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Utils
|
|
6
|
-
|
|
7
|
-
Util functions are provided so you can use various low level functions in your application.
|
|
8
|
-
|
|
9
|
-
## **address**
|
|
10
|
-
|
|
11
|
-
Helper functions for starknet addresses.
|
|
12
|
-
|
|
13
|
-
### validateAndParseAddress
|
|
14
|
-
|
|
15
|
-
`validateAndParseAddress(address: BigNumberish): string`
|
|
16
|
-
|
|
17
|
-
Checks if the address is valid and, if it is, parses it to the correct format (0x prefix is added if not provided).
|
|
18
|
-
|
|
19
|
-
### getChecksumAddress
|
|
20
|
-
|
|
21
|
-
`getChecksumAddress(address: BigNumberish): string`
|
|
22
|
-
|
|
23
|
-
This function accepts an address as a `BigNumberish` and returns the checksummed address as a string.
|
|
24
|
-
An example:
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
import { address } from 'starknet.js';
|
|
28
|
-
|
|
29
|
-
const addressToCheck = '0x2fd23d9182193775423497fc0c472e156c57c69e4089a1967fb288a2d84e914';
|
|
30
|
-
|
|
31
|
-
const checksummedAddress = address.getChecksumAddress(addressToCheck);
|
|
32
|
-
|
|
33
|
-
console.log(checksummedAddress); // 0x02FD23D9182193775423497Fc0c472E156C57C69E4089a1967fb288a2D84e914
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### validateChecksumAddress
|
|
37
|
-
|
|
38
|
-
`validateChecksumAddress(address: string): boolean`
|
|
39
|
-
|
|
40
|
-
This function validates the checksum address.
|
|
41
|
-
|
|
42
|
-
Returns true if the address is valid, false otherwise.
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## **stark**
|
|
47
|
-
|
|
48
|
-
Functions for stark specific manipulations.
|
|
49
|
-
|
|
50
|
-
### compressProgram
|
|
51
|
-
|
|
52
|
-
`compressProgram(jsonProgram: Program | string): CompressedProgram`
|
|
53
|
-
|
|
54
|
-
Function to compress compiled cairo program. Accepts a json file representing the compiled cairo program and returns a compressed cairo program.
|
|
55
|
-
|
|
56
|
-
### randomAddress
|
|
57
|
-
|
|
58
|
-
`randomAddress(): string`
|
|
59
|
-
|
|
60
|
-
Function that generates a random stark address.
|
|
61
|
-
|
|
62
|
-
### makeAddress
|
|
63
|
-
|
|
64
|
-
`makeAddress(input: string): string`
|
|
65
|
-
|
|
66
|
-
Function that turns an incompatible address string into stark address format.
|
|
67
|
-
|
|
68
|
-
Returns a string.
|
|
69
|
-
|
|
70
|
-
Example: `0xdFD0F27FCe99b50909de0bDD328Aed6eAbe76BC5` -> `0xdfd0f27fce99b50909de0bdd328aed6eabe76bc5`
|
|
71
|
-
|
|
72
|
-
### formatSignature
|
|
73
|
-
|
|
74
|
-
`formatSignature(sig?: Signature): string[]`
|
|
75
|
-
|
|
76
|
-
Function that formats a Signature to BigNum and then to string array.
|
|
77
|
-
|
|
78
|
-
Returns a string array.
|
|
79
|
-
|
|
80
|
-
### compileCalldata
|
|
81
|
-
|
|
82
|
-
`compileCalldata(args: RawArgs): Calldata`
|
|
83
|
-
|
|
84
|
-
Function that creates calldata that gets sent to the contract.
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
await this.callContract({
|
|
88
|
-
contractAddress: this.address,
|
|
89
|
-
entrypoint: 'is_valid_signature',
|
|
90
|
-
calldata: compileCalldata({
|
|
91
|
-
hash: toBN(hash).toString(),
|
|
92
|
-
signature: signature.map((x) => toBN(x).toString()),
|
|
93
|
-
}),
|
|
94
|
-
});
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### estimatedFeeToMaxFee
|
|
98
|
-
|
|
99
|
-
`estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead: number = 0.5): BN`
|
|
100
|
-
|
|
101
|
-
Function that calculates and returns maximum fee based on the previously estimated one.
|
|
102
|
-
|
|
103
|
-
Returns a BN.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## **number**
|
|
108
|
-
|
|
109
|
-
Various number formatting functions.
|
|
110
|
-
|
|
111
|
-
`BN` is the `BigNum` representation imported from `bn.js` library.
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
export type BigNumberish = string | number | BN;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### isHex
|
|
118
|
-
|
|
119
|
-
`isHex(hex: string): boolean`
|
|
120
|
-
|
|
121
|
-
Check if number is in hex format.
|
|
122
|
-
|
|
123
|
-
### toBN
|
|
124
|
-
|
|
125
|
-
`toBN(number: BigNumberish, base?: number | 'hex'): BN`
|
|
126
|
-
|
|
127
|
-
Converts BigNumberish to BN.
|
|
128
|
-
|
|
129
|
-
Returns a BN.
|
|
130
|
-
|
|
131
|
-
### toHex
|
|
132
|
-
|
|
133
|
-
`toHex(number: BN): string`
|
|
134
|
-
|
|
135
|
-
Converts BN to hex.
|
|
136
|
-
|
|
137
|
-
Returns a string.
|
|
138
|
-
|
|
139
|
-
### cleanHex
|
|
140
|
-
|
|
141
|
-
`cleanHex(hex: string): string`
|
|
142
|
-
|
|
143
|
-
Remove leading zeroes and lowercase hex string after '0x'
|
|
144
|
-
|
|
145
|
-
`0x01AFF` -> `0x1aff`
|
|
146
|
-
|
|
147
|
-
### hexToDecimalString
|
|
148
|
-
|
|
149
|
-
`hexToDecimalString(hex: string): string`
|
|
150
|
-
|
|
151
|
-
Converts hex string to decimal string.
|
|
152
|
-
|
|
153
|
-
### toFelt
|
|
154
|
-
|
|
155
|
-
`toFelt(num: BigNumberish): string`
|
|
156
|
-
|
|
157
|
-
Converts BN to Felt.
|
|
158
|
-
|
|
159
|
-
Returns a string.
|
|
160
|
-
|
|
161
|
-
### assertInRange
|
|
162
|
-
|
|
163
|
-
`assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName = '')`
|
|
164
|
-
|
|
165
|
-
Asserts input is equal to or greater then `lowerBound` and lower then `upperBound`. Assert message specifies inputName.
|
|
166
|
-
`input`, `lowerBound`, and `upperBound` should be of type BN.
|
|
167
|
-
`inputName` should be a string.
|
|
168
|
-
|
|
169
|
-
### bigNumberishArrayToDecimalStringArray
|
|
170
|
-
|
|
171
|
-
`bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[]`
|
|
172
|
-
|
|
173
|
-
Convert BigNumberish array to decimal array. Used for signature conversion.
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
const signature = await this.signer.signTransaction(transactions, signerDetails);
|
|
177
|
-
|
|
178
|
-
{
|
|
179
|
-
contract_address: this.address,
|
|
180
|
-
entry_point_selector: getSelectorFromName('__execute__'),
|
|
181
|
-
calldata,
|
|
182
|
-
version: toHex(version),
|
|
183
|
-
signature: bigNumberishArrayToDecimalStringArray(signature),
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### bigNumberishArrayToHexadecimalStringArray
|
|
188
|
-
|
|
189
|
-
`bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[]`
|
|
190
|
-
|
|
191
|
-
Convert BigNumberish array to hexadecimal string array. Used for signature conversion.
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## **uint256**
|
|
196
|
-
|
|
197
|
-
```js
|
|
198
|
-
// Represents an integer in the range [0, 2^256).
|
|
199
|
-
export interface Uint256 {
|
|
200
|
-
// The low 128 bits of the value.
|
|
201
|
-
low: BigNumberish;
|
|
202
|
-
// The high 128 bits of the value.
|
|
203
|
-
high: BigNumberish;
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### uint256ToBN
|
|
208
|
-
|
|
209
|
-
`uint256ToBN(uint256: Uint256): BN`
|
|
210
|
-
|
|
211
|
-
Function to convert `Uint256` to `BN` (big number), which uses the `bn.js` library.
|
|
212
|
-
|
|
213
|
-
### isUint256
|
|
214
|
-
|
|
215
|
-
`isUint256(bn: BigNumberish): boolean`
|
|
216
|
-
|
|
217
|
-
Function to check if `BN` is smaller or equal to `2**256-1`.
|
|
218
|
-
|
|
219
|
-
### bnToUint256
|
|
220
|
-
|
|
221
|
-
`bnToUint256(bignumber: BigNumberish): Uint256`
|
|
222
|
-
|
|
223
|
-
Function to convert `BN` to `Uint256`.
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## **hash**
|
|
228
|
-
|
|
229
|
-
Various hashing helpers.
|
|
230
|
-
|
|
231
|
-
### starknetKeccak
|
|
232
|
-
|
|
233
|
-
`starknetKeccak(value: string): BN`
|
|
234
|
-
|
|
235
|
-
Function to get the starknet keccak hash from a string. Returns starknet keccak hash as BigNumber.
|
|
236
|
-
|
|
237
|
-
Returns starknet keccak hash as BigNumber.
|
|
238
|
-
|
|
239
|
-
### getSelectorFromName
|
|
240
|
-
|
|
241
|
-
`getSelectorFromName(funcName: string)`
|
|
242
|
-
|
|
243
|
-
Function to get the hex selector from a given function name.
|
|
244
|
-
|
|
245
|
-
Returns hex selector of given abi function name.
|
|
246
|
-
|
|
247
|
-
### pedersen
|
|
248
|
-
|
|
249
|
-
`pedersen(input: [BigNumberish, BigNumberish])`
|
|
250
|
-
|
|
251
|
-
Function to get the Pedersen hash for two arguments.
|
|
252
|
-
|
|
253
|
-
Returns a string.
|
|
254
|
-
|
|
255
|
-
### computeHashOnElements
|
|
256
|
-
|
|
257
|
-
`computeHashOnElements(data: BigNumberish[])`
|
|
258
|
-
|
|
259
|
-
Function to compute a Pedersen hash on a array of elements.
|
|
260
|
-
|
|
261
|
-
Returns a string.
|
|
262
|
-
|
|
263
|
-
### calculateTransactionHashCommon
|
|
264
|
-
|
|
265
|
-
`calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish,contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, additionalData: BigNumberish[] = []): string`
|
|
266
|
-
|
|
267
|
-
Calculates the transaction hash in the StarkNet network - a unique identifier of the transaction.
|
|
268
|
-
|
|
269
|
-
Called internally in `calculateDeployTransactionHash` and `calculcateTransactionHash`.
|
|
270
|
-
|
|
271
|
-
### calculateDeployTransactionHash
|
|
272
|
-
|
|
273
|
-
`calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: BigNumberish[], version: BigNumberish, chainId: StarknetChainId): string`
|
|
274
|
-
|
|
275
|
-
Function that calculates the deployment transaction hash in the StarkNet network.
|
|
276
|
-
|
|
277
|
-
Internally calls `calculateTransactionHashCommon` with `TransactionHashPrefix.DEPLOY`.
|
|
278
|
-
|
|
279
|
-
### calculateTransactionHash
|
|
280
|
-
|
|
281
|
-
`calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string`
|
|
282
|
-
|
|
283
|
-
Function that internally calls `calculateTransactionHashCommon`, with `TransactionHashPrefix.INVOKE`.
|
|
284
|
-
|
|
285
|
-
```js
|
|
286
|
-
const hashMsg = calculcateTransactionHash(
|
|
287
|
-
account,
|
|
288
|
-
transactionVersion,
|
|
289
|
-
getSelectorFromName('__execute__'),
|
|
290
|
-
calldata,
|
|
291
|
-
maxFee,
|
|
292
|
-
StarknetChainId.TESTNET
|
|
293
|
-
);
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### calculateContractAddressFromHash
|
|
297
|
-
|
|
298
|
-
`calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, deployerAddress: BigNumberish)`
|
|
299
|
-
|
|
300
|
-
Function that calculates contract address from hash.
|
|
301
|
-
|
|
302
|
-
Returns a string.
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## **ellipticCurve**
|
|
307
|
-
|
|
308
|
-
Wrapper around the javascript `elliptic` library with additional functionality.
|
|
309
|
-
|
|
310
|
-
### genKeyPair
|
|
311
|
-
|
|
312
|
-
`ec.genKeyPair()`
|
|
313
|
-
|
|
314
|
-
Generate a random key pair.
|
|
315
|
-
|
|
316
|
-
### getKeyPair
|
|
317
|
-
|
|
318
|
-
`getKeyPair(pk: BigNumberish): KeyPair`
|
|
319
|
-
|
|
320
|
-
Get a key pair from a private key.
|
|
321
|
-
|
|
322
|
-
### getStarkKey
|
|
323
|
-
|
|
324
|
-
`getStarkKey(keyPair: KeyPair): string`
|
|
325
|
-
|
|
326
|
-
Public key defined over a Stark-friendly elliptic curve that is different from the standard Ethereum elliptic curve
|
|
327
|
-
|
|
328
|
-
### getKeyPairFromPublicKey
|
|
329
|
-
|
|
330
|
-
`getKeyPairFromPublicKey(publicKey: BigNumberish): KeyPair`
|
|
331
|
-
|
|
332
|
-
Takes a public key and casts it into `elliptic` KeyPair format.
|
|
333
|
-
|
|
334
|
-
Returns keyPair with public key only, which can be used to verify signatures, but can't sign anything.
|
|
335
|
-
|
|
336
|
-
### sign
|
|
337
|
-
|
|
338
|
-
`sign(keyPair: KeyPair, msgHash: string): Signature`
|
|
339
|
-
|
|
340
|
-
Signs a message using the provided key.
|
|
341
|
-
|
|
342
|
-
keyPair should be an KeyPair with a valid private key.
|
|
343
|
-
|
|
344
|
-
Returns an Signature.
|
|
345
|
-
|
|
346
|
-
### verify
|
|
347
|
-
|
|
348
|
-
`verify(keyPair: KeyPair | KeyPair[], msgHash: string, sig: Signature): boolean`
|
|
349
|
-
|
|
350
|
-
Verifies a message using the provided key.
|
|
351
|
-
|
|
352
|
-
keyPair should be an KeyPair with a valid public key.
|
|
353
|
-
|
|
354
|
-
sig should be an Signature.
|
|
355
|
-
|
|
356
|
-
Returns true if the verification succeeds.
|
|
357
|
-
|
|
358
|
-
<hr />
|
|
359
|
-
|
|
360
|
-
## **calldata**
|
|
361
|
-
|
|
362
|
-
Functions to compile and validate arguments passed in invoke, call and deploy functions.
|
|
363
|
-
|
|
364
|
-
### compile
|
|
365
|
-
|
|
366
|
-
`compileCalldata(args: Array<any>, inputs: AbiEntry[]): Calldata`
|
|
367
|
-
|
|
368
|
-
Parse the calldata by using input fields from the abi for that method.
|
|
369
|
-
|
|
370
|
-
### validate
|
|
371
|
-
|
|
372
|
-
`validateMethodAndArgs(type: 'INVOKE' | 'CALL' | 'DEPLOY', method: string, args: Array<any> = [])`
|
|
373
|
-
|
|
374
|
-
Validates if all arguments that are passed to the method are corresponding to the ones in the abi.
|
package/www/docusaurus.config.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// Note: type annotations allow type checking and IDEs autocompletion
|
|
3
|
-
|
|
4
|
-
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
|
5
|
-
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
|
6
|
-
|
|
7
|
-
/** @type {import('@docusaurus/types').Config} */
|
|
8
|
-
const config = {
|
|
9
|
-
title: 'Starknet.js',
|
|
10
|
-
tagline: 'JavaScript libray for StarkNet',
|
|
11
|
-
url: 'https://starknetjs.com',
|
|
12
|
-
baseUrl: '/',
|
|
13
|
-
onBrokenLinks: 'throw',
|
|
14
|
-
onBrokenMarkdownLinks: 'warn',
|
|
15
|
-
favicon: 'img/favicon.ico',
|
|
16
|
-
organizationName: '0xs34n', // Usually your GitHub org/user name.
|
|
17
|
-
projectName: 'starknet.js', // Usually your repo name.
|
|
18
|
-
|
|
19
|
-
plugins: [
|
|
20
|
-
[
|
|
21
|
-
'@docusaurus/plugin-content-docs',
|
|
22
|
-
{
|
|
23
|
-
id: 'guides',
|
|
24
|
-
path: 'guides',
|
|
25
|
-
routeBasePath: 'guides',
|
|
26
|
-
sidebarPath: require.resolve('./sidebars.js'),
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
],
|
|
30
|
-
|
|
31
|
-
presets: [
|
|
32
|
-
[
|
|
33
|
-
'classic',
|
|
34
|
-
/** @type {import('@docusaurus/preset-classic').Options} */
|
|
35
|
-
({
|
|
36
|
-
docs: {
|
|
37
|
-
sidebarPath: require.resolve('./sidebars.js'),
|
|
38
|
-
// Please change this to your repo.
|
|
39
|
-
editUrl: 'https://github.com/0xs34n/starknet.js',
|
|
40
|
-
},
|
|
41
|
-
blog: {
|
|
42
|
-
showReadingTime: true,
|
|
43
|
-
// Please change this to your repo.
|
|
44
|
-
editUrl: 'https://github.com/0xs34n/starknet.js',
|
|
45
|
-
},
|
|
46
|
-
theme: {
|
|
47
|
-
customCss: require.resolve('./src/css/custom.css'),
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
],
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
themeConfig:
|
|
54
|
-
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
|
55
|
-
({
|
|
56
|
-
navbar: {
|
|
57
|
-
title: 'Home',
|
|
58
|
-
logo: {
|
|
59
|
-
alt: 'Starknet.js Logo',
|
|
60
|
-
src: 'img/logo.svg',
|
|
61
|
-
},
|
|
62
|
-
items: [
|
|
63
|
-
{
|
|
64
|
-
type: 'doc',
|
|
65
|
-
docId: 'API/index',
|
|
66
|
-
position: 'left',
|
|
67
|
-
label: 'API',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
position: 'left',
|
|
71
|
-
label: 'Guides',
|
|
72
|
-
to: '/guides/intro',
|
|
73
|
-
},
|
|
74
|
-
// {to: '/blog', label: 'Blog', position: 'left'},
|
|
75
|
-
{
|
|
76
|
-
href: 'https://github.com/0xs34n/starknet.js',
|
|
77
|
-
label: 'GitHub',
|
|
78
|
-
position: 'right',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
footer: {
|
|
83
|
-
style: 'dark',
|
|
84
|
-
links: [
|
|
85
|
-
{
|
|
86
|
-
title: 'Docs',
|
|
87
|
-
items: [
|
|
88
|
-
{
|
|
89
|
-
label: 'API',
|
|
90
|
-
to: '/docs/API/',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: 'Guides',
|
|
94
|
-
to: '/guides/intro',
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
title: 'Community',
|
|
100
|
-
items: [
|
|
101
|
-
{
|
|
102
|
-
label: 'Twitter',
|
|
103
|
-
href: 'https://twitter.com/0xs34n',
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
title: 'More',
|
|
109
|
-
items: [
|
|
110
|
-
// {
|
|
111
|
-
// label: 'Blog',
|
|
112
|
-
// to: '/blog',
|
|
113
|
-
// },
|
|
114
|
-
{
|
|
115
|
-
label: 'GitHub',
|
|
116
|
-
href: 'https://github.com/0xs34n/starknet.js',
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
copyright: `Copyright © ${new Date().getFullYear()} 0xs34n`,
|
|
122
|
-
},
|
|
123
|
-
prism: {
|
|
124
|
-
theme: lightCodeTheme,
|
|
125
|
-
darkTheme: darkCodeTheme,
|
|
126
|
-
},
|
|
127
|
-
}),
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
module.exports = config;
|