starknet 5.24.3 → 5.24.5
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 +14 -0
- package/README.md +2 -0
- package/dist/index.d.ts +42 -36
- package/dist/index.global.js +17 -12
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [5.24.5](https://github.com/starknet-io/starknet.js/compare/v5.24.4...v5.24.5) (2023-12-10)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- apply bound for contract address from hash calculation ([6d8c291](https://github.com/starknet-io/starknet.js/commit/6d8c291bce130d7b00ae6d81aff071c4986f04af))
|
|
6
|
+
- **Calldata.compile:** do not split long `entrypoint` names before calling `getSelectorFromName` ([89715da](https://github.com/starknet-io/starknet.js/commit/89715da3fdb4b497cc5771eb83a88460007740b6))
|
|
7
|
+
- prioritize error states in waitForTransaction evaluation ([ac54404](https://github.com/starknet-io/starknet.js/commit/ac544045e2079b68042d850a09b203fc5536c0d0))
|
|
8
|
+
|
|
9
|
+
## [5.24.4](https://github.com/starknet-io/starknet.js/compare/v5.24.3...v5.24.4) (2023-12-06)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- typos ([#862](https://github.com/starknet-io/starknet.js/issues/862)) ([b2431d3](https://github.com/starknet-io/starknet.js/commit/b2431d36d636821b32403ef0aa4def2312b10254))
|
|
14
|
+
|
|
1
15
|
## [5.24.3](https://github.com/starknet-io/starknet.js/compare/v5.24.2...v5.24.3) (2023-11-20)
|
|
2
16
|
|
|
3
17
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ If you consider to contribute to this project please read [CONTRIBUTING.md](http
|
|
|
64
64
|
|
|
65
65
|
Special thanks to all the [contributors](https://github.com/starknet-io/starknet.js/graphs/contributors), especially to:
|
|
66
66
|
|
|
67
|
+
- Sean ([@0xs34n](https://github.com/0xs34n)), the original creator of Straknet.js!
|
|
68
|
+
|
|
67
69
|
- Janek ([@janek26](https://github.com/janek26)) and Dhruv ([@dhruvkelawala](https://github.com/dhruvkelawala)) from [Argent](https://github.com/argentlabs)
|
|
68
70
|
|
|
69
71
|
- Toni ([@tabaktoni](https://github.com/tabaktoni)) and Ivan ([@ivpavici](https://github.com/ivpavici)) from [SpaceShard](https://www.spaceshard.io/)
|
package/dist/index.d.ts
CHANGED
|
@@ -128,8 +128,9 @@ declare const BN_FEE_TRANSACTION_VERSION_1: bigint;
|
|
|
128
128
|
declare const BN_FEE_TRANSACTION_VERSION_2: bigint;
|
|
129
129
|
declare const ZERO = 0n;
|
|
130
130
|
declare const MASK_250: bigint;
|
|
131
|
-
declare const MASK_251: bigint;
|
|
132
131
|
declare const API_VERSION = 0n;
|
|
132
|
+
declare const MAX_STORAGE_ITEM_SIZE = 256n;
|
|
133
|
+
declare const ADDR_BOUND: bigint;
|
|
133
134
|
declare enum BaseUrl {
|
|
134
135
|
SN_MAIN = "https://alpha-mainnet.starknet.io",
|
|
135
136
|
SN_GOERLI = "https://alpha4.starknet.io"
|
|
@@ -156,6 +157,7 @@ declare const UDC: {
|
|
|
156
157
|
declare const RPC_GOERLI_NODES: string[];
|
|
157
158
|
declare const RPC_MAINNET_NODES: string[];
|
|
158
159
|
|
|
160
|
+
declare const constants_ADDR_BOUND: typeof ADDR_BOUND;
|
|
159
161
|
declare const constants_API_VERSION: typeof API_VERSION;
|
|
160
162
|
declare const constants_BN_FEE_TRANSACTION_VERSION_1: typeof BN_FEE_TRANSACTION_VERSION_1;
|
|
161
163
|
declare const constants_BN_FEE_TRANSACTION_VERSION_2: typeof BN_FEE_TRANSACTION_VERSION_2;
|
|
@@ -167,7 +169,7 @@ declare const constants_HEX_STR_TRANSACTION_VERSION_1: typeof HEX_STR_TRANSACTIO
|
|
|
167
169
|
declare const constants_HEX_STR_TRANSACTION_VERSION_2: typeof HEX_STR_TRANSACTION_VERSION_2;
|
|
168
170
|
declare const constants_IS_BROWSER: typeof IS_BROWSER;
|
|
169
171
|
declare const constants_MASK_250: typeof MASK_250;
|
|
170
|
-
declare const
|
|
172
|
+
declare const constants_MAX_STORAGE_ITEM_SIZE: typeof MAX_STORAGE_ITEM_SIZE;
|
|
171
173
|
type constants_NetworkName = NetworkName;
|
|
172
174
|
declare const constants_NetworkName: typeof NetworkName;
|
|
173
175
|
declare const constants_RPC_GOERLI_NODES: typeof RPC_GOERLI_NODES;
|
|
@@ -181,6 +183,7 @@ declare const constants_UDC: typeof UDC;
|
|
|
181
183
|
declare const constants_ZERO: typeof ZERO;
|
|
182
184
|
declare namespace constants {
|
|
183
185
|
export {
|
|
186
|
+
constants_ADDR_BOUND as ADDR_BOUND,
|
|
184
187
|
constants_API_VERSION as API_VERSION,
|
|
185
188
|
constants_BN_FEE_TRANSACTION_VERSION_1 as BN_FEE_TRANSACTION_VERSION_1,
|
|
186
189
|
constants_BN_FEE_TRANSACTION_VERSION_2 as BN_FEE_TRANSACTION_VERSION_2,
|
|
@@ -191,7 +194,7 @@ declare namespace constants {
|
|
|
191
194
|
constants_HEX_STR_TRANSACTION_VERSION_2 as HEX_STR_TRANSACTION_VERSION_2,
|
|
192
195
|
constants_IS_BROWSER as IS_BROWSER,
|
|
193
196
|
constants_MASK_250 as MASK_250,
|
|
194
|
-
|
|
197
|
+
constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE,
|
|
195
198
|
constants_NetworkName as NetworkName,
|
|
196
199
|
constants_RPC_GOERLI_NODES as RPC_GOERLI_NODES,
|
|
197
200
|
constants_RPC_MAINNET_NODES as RPC_MAINNET_NODES,
|
|
@@ -3802,56 +3805,59 @@ declare abstract class SignerInterface {
|
|
|
3802
3805
|
/**
|
|
3803
3806
|
* Method to get the public key of the signer
|
|
3804
3807
|
*
|
|
3805
|
-
* @returns
|
|
3808
|
+
* @returns format: hex-string
|
|
3806
3809
|
*/
|
|
3807
3810
|
abstract getPubKey(): Promise<string>;
|
|
3808
3811
|
/**
|
|
3809
|
-
*
|
|
3810
|
-
* This adds a message prefix so it
|
|
3812
|
+
* Signs a JSON object for off-chain usage with the Starknet private key and returns the signature
|
|
3813
|
+
* This adds a message prefix so it can't be interchanged with transactions
|
|
3811
3814
|
*
|
|
3812
3815
|
* @param typedData - JSON object to be signed
|
|
3813
|
-
* @param accountAddress
|
|
3814
|
-
* @returns the signature of the JSON object
|
|
3815
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
3816
|
+
* @param accountAddress
|
|
3816
3817
|
*/
|
|
3817
3818
|
abstract signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
|
|
3818
3819
|
/**
|
|
3819
|
-
* Signs
|
|
3820
|
-
*
|
|
3821
|
-
* @param invocation the invocation object containing:
|
|
3822
|
-
* - contractAddress - the address of the contract
|
|
3823
|
-
* - entrypoint - the entrypoint of the contract
|
|
3824
|
-
* - calldata - (defaults to []) the calldata
|
|
3825
|
-
* @param abi (optional) the abi of the contract for better displaying
|
|
3820
|
+
* Signs transactions with the Starknet private key and returns the signature
|
|
3826
3821
|
*
|
|
3827
|
-
* @
|
|
3822
|
+
* @param transactions - Array of Call objects, each including:<br/>
|
|
3823
|
+
* - contractAddress<br/>
|
|
3824
|
+
* - entrypoint<br/>
|
|
3825
|
+
* - calldata<br/>
|
|
3826
|
+
* @param transactionsDetail - InvocationsSignerDetails object with:<br/>
|
|
3827
|
+
* - walletAddress<br/>
|
|
3828
|
+
* - chainId<br/>
|
|
3829
|
+
* - cairoVersion<br/>
|
|
3830
|
+
* - maxFee<br/>
|
|
3831
|
+
* - version<br/>
|
|
3832
|
+
* - nonce<br/>
|
|
3833
|
+
* @param abis - (optional) An array of Abi objects for displaying decoded data
|
|
3828
3834
|
*/
|
|
3829
3835
|
abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
|
|
3830
3836
|
/**
|
|
3831
|
-
* Signs a DEPLOY_ACCOUNT transaction with the
|
|
3837
|
+
* Signs a DEPLOY_ACCOUNT transaction with the Starknet private key and returns the signature
|
|
3832
3838
|
*
|
|
3833
|
-
* @param transaction
|
|
3834
|
-
* - contractAddress
|
|
3835
|
-
* -
|
|
3836
|
-
* -
|
|
3837
|
-
* -
|
|
3838
|
-
* -
|
|
3839
|
-
* -
|
|
3840
|
-
* -
|
|
3841
|
-
*
|
|
3839
|
+
* @param transaction<br/>
|
|
3840
|
+
* - contractAddress<br/>
|
|
3841
|
+
* - chainId<br/>
|
|
3842
|
+
* - classHash<br/>
|
|
3843
|
+
* - constructorCalldata<br/>
|
|
3844
|
+
* - addressSalt<br/>
|
|
3845
|
+
* - maxFee<br/>
|
|
3846
|
+
* - version<br/>
|
|
3847
|
+
* - nonce<br/>
|
|
3842
3848
|
*/
|
|
3843
3849
|
abstract signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
3844
3850
|
/**
|
|
3845
|
-
* Signs a DECLARE transaction with the
|
|
3851
|
+
* Signs a DECLARE transaction with the Starknet private key and returns the signature
|
|
3846
3852
|
*
|
|
3847
|
-
* @param transaction
|
|
3848
|
-
* - classHash
|
|
3849
|
-
* -
|
|
3850
|
-
* -
|
|
3851
|
-
* -
|
|
3852
|
-
* -
|
|
3853
|
-
* -
|
|
3854
|
-
*
|
|
3853
|
+
* @param transaction<br/>
|
|
3854
|
+
* - classHash<br/>
|
|
3855
|
+
* - compiledClassHash? - used for Cairo1<br/>
|
|
3856
|
+
* - senderAddress<br/>
|
|
3857
|
+
* - chainId<br/>
|
|
3858
|
+
* - maxFee<br/>
|
|
3859
|
+
* - version<br/>
|
|
3860
|
+
* - nonce<br/>
|
|
3855
3861
|
*/
|
|
3856
3862
|
abstract signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
|
|
3857
3863
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -720,6 +720,7 @@ var starknet = (() => {
|
|
|
720
720
|
// src/constants.ts
|
|
721
721
|
var constants_exports = {};
|
|
722
722
|
__export(constants_exports, {
|
|
723
|
+
ADDR_BOUND: () => ADDR_BOUND,
|
|
723
724
|
API_VERSION: () => API_VERSION,
|
|
724
725
|
BN_FEE_TRANSACTION_VERSION_1: () => BN_FEE_TRANSACTION_VERSION_1,
|
|
725
726
|
BN_FEE_TRANSACTION_VERSION_2: () => BN_FEE_TRANSACTION_VERSION_2,
|
|
@@ -730,7 +731,7 @@ var starknet = (() => {
|
|
|
730
731
|
HEX_STR_TRANSACTION_VERSION_2: () => HEX_STR_TRANSACTION_VERSION_2,
|
|
731
732
|
IS_BROWSER: () => IS_BROWSER,
|
|
732
733
|
MASK_250: () => MASK_250,
|
|
733
|
-
|
|
734
|
+
MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
|
|
734
735
|
NetworkName: () => NetworkName,
|
|
735
736
|
RPC_GOERLI_NODES: () => RPC_GOERLI_NODES,
|
|
736
737
|
RPC_MAINNET_NODES: () => RPC_MAINNET_NODES,
|
|
@@ -996,8 +997,9 @@ var starknet = (() => {
|
|
|
996
997
|
var BN_FEE_TRANSACTION_VERSION_2 = 2n ** 128n + BN_TRANSACTION_VERSION_2;
|
|
997
998
|
var ZERO = 0n;
|
|
998
999
|
var MASK_250 = 2n ** 250n - 1n;
|
|
999
|
-
var MASK_251 = 2n ** 251n;
|
|
1000
1000
|
var API_VERSION = ZERO;
|
|
1001
|
+
var MAX_STORAGE_ITEM_SIZE = 256n;
|
|
1002
|
+
var ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;
|
|
1001
1003
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
1002
1004
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
1003
1005
|
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
@@ -4939,7 +4941,7 @@ var starknet = (() => {
|
|
|
4939
4941
|
if (input.type === "core::starknet::eth_address::EthAddress") {
|
|
4940
4942
|
assert(
|
|
4941
4943
|
typeof parameter !== "object",
|
|
4942
|
-
`
|
|
4944
|
+
`EthAddress type is waiting a BigNumberish. Got ${parameter}`
|
|
4943
4945
|
);
|
|
4944
4946
|
const param = BigInt(parameter.toString(10));
|
|
4945
4947
|
assert(
|
|
@@ -5156,10 +5158,10 @@ var starknet = (() => {
|
|
|
5156
5158
|
const oe = Array.isArray(o) ? [o.length.toString(), ...o] : o;
|
|
5157
5159
|
return Object.entries(oe).flatMap(([k, v]) => {
|
|
5158
5160
|
let value = v;
|
|
5159
|
-
if (isLongText(value))
|
|
5160
|
-
value = splitLongString(value);
|
|
5161
5161
|
if (k === "entrypoint")
|
|
5162
5162
|
value = getSelectorFromName(value);
|
|
5163
|
+
else if (isLongText(value))
|
|
5164
|
+
value = splitLongString(value);
|
|
5163
5165
|
const kk = Array.isArray(oe) && k === "0" ? "$$len" : k;
|
|
5164
5166
|
if (isBigInt(value))
|
|
5165
5167
|
return [[`${prefix}${kk}`, felt(value)]];
|
|
@@ -6084,13 +6086,14 @@ var starknet = (() => {
|
|
|
6084
6086
|
const compiledCalldata = CallData.compile(constructorCalldata);
|
|
6085
6087
|
const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
|
|
6086
6088
|
const CONTRACT_ADDRESS_PREFIX = felt("0x535441524b4e45545f434f4e54524143545f41444452455353");
|
|
6087
|
-
|
|
6089
|
+
const hash2 = computeHashOnElements2([
|
|
6088
6090
|
CONTRACT_ADDRESS_PREFIX,
|
|
6089
6091
|
deployerAddress,
|
|
6090
6092
|
salt,
|
|
6091
6093
|
classHash,
|
|
6092
6094
|
constructorCalldataHash
|
|
6093
6095
|
]);
|
|
6096
|
+
return toHex(BigInt(hash2) % ADDR_BOUND);
|
|
6094
6097
|
}
|
|
6095
6098
|
function nullSkipReplacer(key, value) {
|
|
6096
6099
|
if (key === "attributes" || key === "accessible_scopes") {
|
|
@@ -11022,8 +11025,10 @@ var starknet = (() => {
|
|
|
11022
11025
|
let isErrorState = false;
|
|
11023
11026
|
const retryInterval = options?.retryInterval ?? 5e3;
|
|
11024
11027
|
const errorStates = options?.errorStates ?? [
|
|
11025
|
-
rpc_exports.ETransactionStatus.REJECTED
|
|
11026
|
-
|
|
11028
|
+
rpc_exports.ETransactionStatus.REJECTED
|
|
11029
|
+
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
11030
|
+
// should decide which behavior to keep in the future
|
|
11031
|
+
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
11027
11032
|
];
|
|
11028
11033
|
const successStates = options?.successStates ?? [
|
|
11029
11034
|
rpc_exports.ETransactionExecutionStatus.SUCCEEDED,
|
|
@@ -11041,14 +11046,14 @@ var starknet = (() => {
|
|
|
11041
11046
|
const error = new Error("waiting for transaction status");
|
|
11042
11047
|
throw error;
|
|
11043
11048
|
}
|
|
11044
|
-
if (
|
|
11045
|
-
onchain = true;
|
|
11046
|
-
} else if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
|
|
11049
|
+
if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
|
|
11047
11050
|
const message = `${executionStatus}: ${finalityStatus}`;
|
|
11048
11051
|
const error = new Error(message);
|
|
11049
11052
|
error.response = txStatus;
|
|
11050
11053
|
isErrorState = true;
|
|
11051
11054
|
throw error;
|
|
11055
|
+
} else if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
|
|
11056
|
+
onchain = true;
|
|
11052
11057
|
}
|
|
11053
11058
|
} catch (error) {
|
|
11054
11059
|
if (error instanceof Error && isErrorState) {
|
|
@@ -13402,7 +13407,7 @@ ${res.tx_failure_reason.error_message}`;
|
|
|
13402
13407
|
return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));
|
|
13403
13408
|
}
|
|
13404
13409
|
function validateAndParseAddress(address) {
|
|
13405
|
-
assertInRange(address, ZERO,
|
|
13410
|
+
assertInRange(address, ZERO, ADDR_BOUND - 1n, "Starknet Address");
|
|
13406
13411
|
const result = addAddressPadding(address);
|
|
13407
13412
|
if (!result.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
|
|
13408
13413
|
throw new Error("Invalid Address Format");
|