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/account/index.js
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __exportStar =
|
|
23
|
-
(this && this.__exportStar) ||
|
|
24
|
-
function (m, exports) {
|
|
25
|
-
for (var p in m)
|
|
26
|
-
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
27
|
-
__createBinding(exports, m, p);
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
30
|
-
__exportStar(require('./default'), exports);
|
|
31
|
-
__exportStar(require('./interface'), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./default"), exports);
|
|
18
|
+
__exportStar(require("./interface"), exports);
|
package/account/interface.d.ts
CHANGED
|
@@ -1,101 +1,72 @@
|
|
|
1
1
|
import { ProviderInterface } from '../provider';
|
|
2
2
|
import { SignerInterface } from '../signer';
|
|
3
|
-
import {
|
|
4
|
-
Abi,
|
|
5
|
-
AddTransactionResponse,
|
|
6
|
-
Call,
|
|
7
|
-
DeployContractPayload,
|
|
8
|
-
InvocationsDetails,
|
|
9
|
-
Signature,
|
|
10
|
-
} from '../types';
|
|
11
|
-
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
3
|
+
import { Abi, Call, EstimateFeeDetails, EstimateFeeResponse, InvocationsDetails, InvokeFunctionResponse, Signature } from '../types';
|
|
12
4
|
import { BigNumberish } from '../utils/number';
|
|
13
5
|
import { TypedData } from '../utils/typedData/types';
|
|
14
6
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
abstract hashMessage(typedData: TypedData): Promise<string>;
|
|
81
|
-
/**
|
|
82
|
-
* Verify a signature of a JSON object
|
|
83
|
-
*
|
|
84
|
-
* @param json - JSON object to be verified
|
|
85
|
-
* @param signature - signature of the JSON object
|
|
86
|
-
* @returns true if the signature is valid, false otherwise
|
|
87
|
-
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
|
88
|
-
*/
|
|
89
|
-
abstract verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Verify a signature of a given hash
|
|
92
|
-
* @warning This method is not recommended, use verifyMessage instead
|
|
93
|
-
*
|
|
94
|
-
* @param hash - hash to be verified
|
|
95
|
-
* @param signature - signature of the hash
|
|
96
|
-
* @returns true if the signature is valid, false otherwise
|
|
97
|
-
* @throws {Error} if the signature is not a valid signature
|
|
98
|
-
*/
|
|
99
|
-
abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
100
|
-
abstract getNonce(): Promise<string>;
|
|
7
|
+
abstract address: string;
|
|
8
|
+
abstract signer: SignerInterface;
|
|
9
|
+
/**
|
|
10
|
+
* Estimate Fee for a method on starknet
|
|
11
|
+
*
|
|
12
|
+
* @param invocation the invocation object containing:
|
|
13
|
+
* - contractAddress - the address of the contract
|
|
14
|
+
* - entrypoint - the entrypoint of the contract
|
|
15
|
+
* - calldata - (defaults to []) the calldata
|
|
16
|
+
* - signature - (defaults to []) the signature
|
|
17
|
+
*
|
|
18
|
+
* @returns response from addTransaction
|
|
19
|
+
*/
|
|
20
|
+
abstract estimateFee(calls: Call | Call[], estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Invoke execute function in account contract
|
|
23
|
+
*
|
|
24
|
+
* @param transactions the invocation object or an array of them, containing:
|
|
25
|
+
* - contractAddress - the address of the contract
|
|
26
|
+
* - entrypoint - the entrypoint of the contract
|
|
27
|
+
* - calldata - (defaults to []) the calldata
|
|
28
|
+
* - signature - (defaults to []) the signature
|
|
29
|
+
* @param abi (optional) the abi of the contract for better displaying
|
|
30
|
+
*
|
|
31
|
+
* @returns response from addTransaction
|
|
32
|
+
*/
|
|
33
|
+
abstract execute(transactions: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
36
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
37
|
+
*
|
|
38
|
+
* @param json - JSON object to be signed
|
|
39
|
+
* @returns the signature of the JSON object
|
|
40
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
41
|
+
*/
|
|
42
|
+
abstract signMessage(typedData: TypedData): Promise<Signature>;
|
|
43
|
+
/**
|
|
44
|
+
* Hash a JSON object with pederson hash and return the hash
|
|
45
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
46
|
+
*
|
|
47
|
+
* @param json - JSON object to be hashed
|
|
48
|
+
* @returns the hash of the JSON object
|
|
49
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
50
|
+
*/
|
|
51
|
+
abstract hashMessage(typedData: TypedData): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Verify a signature of a JSON object
|
|
54
|
+
*
|
|
55
|
+
* @param json - JSON object to be verified
|
|
56
|
+
* @param signature - signature of the JSON object
|
|
57
|
+
* @returns true if the signature is valid, false otherwise
|
|
58
|
+
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
|
59
|
+
*/
|
|
60
|
+
abstract verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Verify a signature of a given hash
|
|
63
|
+
* @warning This method is not recommended, use verifyMessage instead
|
|
64
|
+
*
|
|
65
|
+
* @param hash - hash to be verified
|
|
66
|
+
* @param signature - signature of the hash
|
|
67
|
+
* @returns true if the signature is valid, false otherwise
|
|
68
|
+
* @throws {Error} if the signature is not a valid signature
|
|
69
|
+
*/
|
|
70
|
+
abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
71
|
+
abstract getNonce(): Promise<string>;
|
|
101
72
|
}
|
package/account/interface.js
CHANGED
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
var __extends =
|
|
3
|
-
(this && this.__extends) ||
|
|
4
|
-
(function () {
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
3
|
var extendStatics = function (d, b) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
}) ||
|
|
12
|
-
function (d, b) {
|
|
13
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
16
8
|
};
|
|
17
9
|
return function (d, b) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
25
15
|
};
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports,
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
18
|
exports.AccountInterface = void 0;
|
|
29
|
-
var provider_1 = require(
|
|
19
|
+
var provider_1 = require("../provider");
|
|
30
20
|
var AccountInterface = /** @class */ (function (_super) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
21
|
+
__extends(AccountInterface, _super);
|
|
22
|
+
function AccountInterface() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return AccountInterface;
|
|
26
|
+
}(provider_1.ProviderInterface));
|
|
37
27
|
exports.AccountInterface = AccountInterface;
|
package/constants.d.ts
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
export { IS_BROWSER } from './utils/encode';
|
|
3
|
-
export declare const ZERO: import(
|
|
4
|
-
export declare const ONE: import(
|
|
5
|
-
export declare const TWO: import(
|
|
6
|
-
export declare const MASK_250: import(
|
|
7
|
-
export declare const MASK_251: import(
|
|
3
|
+
export declare const ZERO: import("bn.js");
|
|
4
|
+
export declare const ONE: import("bn.js");
|
|
5
|
+
export declare const TWO: import("bn.js");
|
|
6
|
+
export declare const MASK_250: import("bn.js");
|
|
7
|
+
export declare const MASK_251: import("bn.js");
|
|
8
8
|
export declare enum StarknetChainId {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
MAINNET = "0x534e5f4d41494e",
|
|
10
|
+
TESTNET = "0x534e5f474f45524c49"
|
|
11
11
|
}
|
|
12
12
|
export declare enum TransactionHashPrefix {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
DECLARE = "0x6465636c617265",
|
|
14
|
+
DEPLOY = "0x6465706c6f79",
|
|
15
|
+
INVOKE = "0x696e766f6b65",
|
|
16
|
+
L1_HANDLER = "0x6c315f68616e646c6572"
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* The following is taken from https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/pedersen_params.json but converted to hex, because JS is very bad handling big integers by default
|
|
20
20
|
* Please do not edit until the JSON changes.
|
|
21
21
|
*/
|
|
22
|
-
export declare const FIELD_PRIME =
|
|
23
|
-
|
|
24
|
-
export declare const FIELD_GEN = '3';
|
|
22
|
+
export declare const FIELD_PRIME = "800000000000011000000000000000000000000000000000000000000000001";
|
|
23
|
+
export declare const FIELD_GEN = "3";
|
|
25
24
|
export declare const FIELD_SIZE = 251;
|
|
26
|
-
export declare const EC_ORDER =
|
|
27
|
-
export declare const ALPHA =
|
|
28
|
-
export declare const BETA =
|
|
29
|
-
export declare const MAX_ECDSA_VAL =
|
|
30
|
-
'800000000000000000000000000000000000000000000000000000000000000';
|
|
25
|
+
export declare const EC_ORDER = "800000000000010FFFFFFFFFFFFFFFFB781126DCAE7B2321E66A241ADC64D2F";
|
|
26
|
+
export declare const ALPHA = "1";
|
|
27
|
+
export declare const BETA = "6F21413EFBE40DE150E596D72F7A8C5609AD26C15C915C1F4CDFCB99CEE9E89";
|
|
28
|
+
export declare const MAX_ECDSA_VAL = "800000000000000000000000000000000000000000000000000000000000000";
|
|
31
29
|
export declare const CONSTANT_POINTS: string[][];
|