starknet 3.18.2 → 3.19.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 +53 -0
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +443 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +1 -1
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +443 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +300 -0
- package/src/provider/sequencer.ts +384 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- package/types/api.js +0 -2
package/dist/contract/default.js
CHANGED
|
@@ -592,6 +592,8 @@ var Contract = /** @class */ (function () {
|
|
|
592
592
|
nonce: options.nonce,
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
|
+
// eslint-disable-next-line no-console
|
|
596
|
+
console.warn("Invoking ".concat(method, " without an account. This will not work on a public node."));
|
|
595
597
|
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: options.signature || [] }));
|
|
596
598
|
};
|
|
597
599
|
Contract.prototype.call = function (method, args, _a) {
|
|
@@ -612,7 +614,7 @@ var Contract = /** @class */ (function () {
|
|
|
612
614
|
contractAddress: this.address,
|
|
613
615
|
calldata: calldata,
|
|
614
616
|
entrypoint: method,
|
|
615
|
-
},
|
|
617
|
+
}, blockIdentifier)
|
|
616
618
|
.then(function (x) { return _this.parseResponse(method, x.result); })];
|
|
617
619
|
});
|
|
618
620
|
});
|
|
@@ -623,7 +625,6 @@ var Contract = /** @class */ (function () {
|
|
|
623
625
|
var invocation;
|
|
624
626
|
var _a;
|
|
625
627
|
return __generator(this, function (_b) {
|
|
626
|
-
// TODO; remove error as soon as estimate fees are supported
|
|
627
628
|
// ensure contract is connected
|
|
628
629
|
(0, minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
|
|
629
630
|
// validate method and args
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountInterface } from '../account';
|
|
2
2
|
import { ProviderInterface } from '../provider';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
-
import { Abi,
|
|
4
|
+
import { Abi, AsyncContractFunction, ContractFunction, Invocation, InvokeFunctionResponse, Overrides, Result } from '../types';
|
|
5
5
|
export declare abstract class ContractInterface {
|
|
6
6
|
abstract abi: Abi;
|
|
7
7
|
abstract address: string;
|
|
@@ -56,7 +56,7 @@ export declare abstract class ContractInterface {
|
|
|
56
56
|
* @param args Array of the arguments for the invoke
|
|
57
57
|
* @returns Add Transaction Response
|
|
58
58
|
*/
|
|
59
|
-
abstract invoke(method: string, args?: Array<any>, options?: Overrides): Promise<
|
|
59
|
+
abstract invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
60
60
|
/**
|
|
61
61
|
* Calls a method on a contract
|
|
62
62
|
*
|
|
@@ -1,143 +1,27 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockTag, Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetails, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { BigNumberish } from '../utils/number';
|
|
4
4
|
import { ProviderInterface } from './interface';
|
|
5
|
+
import { RpcProviderOptions } from './rpc';
|
|
6
|
+
import { SequencerProviderOptions } from './sequencer';
|
|
5
7
|
import { BlockIdentifier } from './utils';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
baseUrl: string;
|
|
11
|
-
};
|
|
8
|
+
export interface ProviderOptions {
|
|
9
|
+
sequencer?: SequencerProviderOptions;
|
|
10
|
+
rpc?: RpcProviderOptions;
|
|
11
|
+
}
|
|
12
12
|
export declare class Provider implements ProviderInterface {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
chainId: StarknetChainId;
|
|
17
|
-
constructor(optionsOrProvider?: ProviderOptions | ProviderInterface);
|
|
18
|
-
protected static getNetworkFromName(name: NetworkName): "https://alpha-mainnet.starknet.io" | "https://alpha4.starknet.io";
|
|
19
|
-
protected static getChainIdFromBaseUrl(baseUrl: string): StarknetChainId;
|
|
20
|
-
private getFetchUrl;
|
|
21
|
-
private getFetchMethod;
|
|
22
|
-
private getQueryString;
|
|
23
|
-
private getHeaders;
|
|
24
|
-
protected fetchEndpoint<T extends keyof Endpoints>(endpoint: T, ...[query, request]: Endpoints[T]['QUERY'] extends never ? Endpoints[T]['REQUEST'] extends never ? [] : [undefined, Endpoints[T]['REQUEST']] : Endpoints[T]['REQUEST'] extends never ? [Endpoints[T]['QUERY']] : [Endpoints[T]['QUERY'], Endpoints[T]['REQUEST']]): Promise<Endpoints[T]['RESPONSE']>;
|
|
25
|
-
/**
|
|
26
|
-
* Gets the smart contract address on the goerli testnet.
|
|
27
|
-
*
|
|
28
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L13-L15)
|
|
29
|
-
* @returns starknet smart contract addresses
|
|
30
|
-
*/
|
|
31
|
-
getContractAddresses(): Promise<GetContractAddressesResponse>;
|
|
32
|
-
/**
|
|
33
|
-
* Calls a function on the StarkNet contract.
|
|
34
|
-
*
|
|
35
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L25-L39)
|
|
36
|
-
*
|
|
37
|
-
* @param invokeTransaction - transaction to be invoked
|
|
38
|
-
* @param blockHash
|
|
39
|
-
* @param blockNumber
|
|
40
|
-
* @returns the result of the function on the smart contract.
|
|
41
|
-
*/
|
|
42
|
-
callContract({ contractAddress, entrypoint, calldata }: Call, { blockIdentifier }?: {
|
|
43
|
-
blockIdentifier?: BlockIdentifier;
|
|
44
|
-
}): Promise<CallContractResponse>;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the block information
|
|
47
|
-
*
|
|
48
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L41-L53)
|
|
49
|
-
*
|
|
50
|
-
* @param blockHash
|
|
51
|
-
* @param blockNumber
|
|
52
|
-
* @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
|
|
53
|
-
*/
|
|
13
|
+
private provider;
|
|
14
|
+
constructor(providerOrOptions?: ProviderOptions | ProviderInterface);
|
|
15
|
+
get chainId(): StarknetChainId;
|
|
54
16
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L55-L68)
|
|
59
|
-
*
|
|
60
|
-
* @param contractAddress
|
|
61
|
-
* @param blockHash
|
|
62
|
-
* @param blockNumber
|
|
63
|
-
* @returns Bytecode and ABI of compiled contract
|
|
64
|
-
*/
|
|
65
|
-
getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
66
|
-
/**
|
|
67
|
-
* Gets the contract's storage variable at a specific key.
|
|
68
|
-
*
|
|
69
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L70-L85)
|
|
70
|
-
*
|
|
71
|
-
* @param contractAddress
|
|
72
|
-
* @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
|
|
73
|
-
* @param blockHash
|
|
74
|
-
* @param blockNumber
|
|
75
|
-
* @returns the value of the storage variable
|
|
76
|
-
*/
|
|
77
|
-
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<object>;
|
|
78
|
-
/**
|
|
79
|
-
* Gets the status of a transaction.
|
|
80
|
-
*
|
|
81
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
|
|
82
|
-
*
|
|
83
|
-
* @param txHash
|
|
84
|
-
* @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
|
|
85
|
-
*/
|
|
86
|
-
getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
|
|
87
|
-
/**
|
|
88
|
-
* Gets the transaction receipt from a tx hash.
|
|
89
|
-
*
|
|
90
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
|
|
91
|
-
*
|
|
92
|
-
* @param txHash
|
|
93
|
-
* @returns the transaction receipt object
|
|
94
|
-
*/
|
|
95
|
-
getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
|
|
96
|
-
/**
|
|
97
|
-
* Gets the transaction information from a tx id.
|
|
98
|
-
*
|
|
99
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
|
|
100
|
-
*
|
|
101
|
-
* @param txHash
|
|
102
|
-
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
103
|
-
*/
|
|
17
|
+
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
18
|
+
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
|
19
|
+
getStorageAt(contractAddress: string, key: BigNumberish, blockTagOrHash?: BlockTag | BigNumberish): Promise<BigNumberish>;
|
|
104
20
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* @returns the transaction trace
|
|
111
|
-
*/
|
|
112
|
-
getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
|
|
113
|
-
/**
|
|
114
|
-
* Declare a given compiled contract (json) on starknet
|
|
115
|
-
*
|
|
116
|
-
* @param contract - a json object containing the compiled contract
|
|
117
|
-
* @returns a confirmation of sending a transaction on the starknet contract
|
|
118
|
-
*/
|
|
119
|
-
declareContract(payload: DeclareContractPayload): Promise<AddTransactionResponse>;
|
|
120
|
-
/**
|
|
121
|
-
* Deploys a given compiled contract (json) to starknet
|
|
122
|
-
*
|
|
123
|
-
* @param contract - a json object containing the compiled contract
|
|
124
|
-
* @param address - (optional, defaults to a random address) the address where the contract should be deployed (alpha)
|
|
125
|
-
* @returns a confirmation of sending a transaction on the starknet contract
|
|
126
|
-
*/
|
|
127
|
-
deployContract(payload: DeployContractPayload, _abi?: Abi): Promise<AddTransactionResponse>;
|
|
128
|
-
/**
|
|
129
|
-
* Invokes a function on starknet
|
|
130
|
-
* @deprecated This method wont be supported as soon as fees are mandatory
|
|
131
|
-
*
|
|
132
|
-
* @param invocation
|
|
133
|
-
* @param _abi - (optional) signature to send along
|
|
134
|
-
* @returns response from addTransaction
|
|
135
|
-
*/
|
|
136
|
-
invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
|
|
21
|
+
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
22
|
+
callContract(request: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
23
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
24
|
+
deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
25
|
+
declareContract(payload: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
137
26
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated use `waitForTransaction` instead
|
|
140
|
-
*/
|
|
141
|
-
waitForTx(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
142
27
|
}
|
|
143
|
-
export {};
|