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/src/signer/default.ts
DELETED
|
@@ -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
|
-
}
|
package/src/signer/index.ts
DELETED
package/src/signer/interface.ts
DELETED
|
@@ -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
|
-
}
|
package/src/types/account.ts
DELETED
|
@@ -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
|
-
};
|
package/src/types/api/index.ts
DELETED