starknet 8.5.3 → 8.5.4
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 +6 -0
- package/README.md +1 -1
- package/dist/index.d.ts +37 -8
- package/dist/index.global.js +423 -79
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -34
package/dist/index.js
CHANGED
|
@@ -1974,10 +1974,13 @@ var errorCodes = {
|
|
|
1974
1974
|
UNSUPPORTED_TX_VERSION: 61,
|
|
1975
1975
|
UNSUPPORTED_CONTRACT_CLASS_VERSION: 62,
|
|
1976
1976
|
UNEXPECTED_ERROR: 63,
|
|
1977
|
+
REPLACEMENT_TRANSACTION_UNDERPRICED: 64,
|
|
1978
|
+
FEE_BELOW_MINIMUM: 65,
|
|
1977
1979
|
INVALID_SUBSCRIPTION_ID: 66,
|
|
1978
1980
|
TOO_MANY_ADDRESSES_IN_FILTER: 67,
|
|
1979
1981
|
TOO_MANY_BLOCKS_BACK: 68,
|
|
1980
1982
|
COMPILATION_ERROR: 100,
|
|
1983
|
+
//
|
|
1981
1984
|
INVALID_ADDRESS: 150,
|
|
1982
1985
|
TOKEN_NOT_SUPPORTED: 151,
|
|
1983
1986
|
INVALID_SIGNATURE: 153,
|
|
@@ -5881,7 +5884,7 @@ var RpcChannel = class {
|
|
|
5881
5884
|
}
|
|
5882
5885
|
/**
|
|
5883
5886
|
* fetch rpc node specVersion
|
|
5884
|
-
* @example this.specVersion = "0.
|
|
5887
|
+
* @example this.specVersion = "0.8.1"
|
|
5885
5888
|
*/
|
|
5886
5889
|
getSpecVersion() {
|
|
5887
5890
|
return this.fetchEndpoint("starknet_specVersion");
|
|
@@ -6032,21 +6035,22 @@ var RpcChannel = class {
|
|
|
6032
6035
|
}
|
|
6033
6036
|
async waitForTransaction(txHash, options) {
|
|
6034
6037
|
const transactionHash = toHex(txHash);
|
|
6035
|
-
let
|
|
6038
|
+
let retries = options?.retries ?? this.retries;
|
|
6039
|
+
let lifeCycleRetries = options?.lifeCycleRetries ?? 3;
|
|
6036
6040
|
let onchain = false;
|
|
6037
6041
|
let isErrorState = false;
|
|
6038
6042
|
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
6039
|
-
const errorStates = options?.errorStates ?? [
|
|
6040
|
-
RPCSPEC08.ETransactionStatus.REJECTED
|
|
6041
|
-
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
6042
|
-
// should decide which behavior to keep in the future
|
|
6043
|
-
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
6044
|
-
];
|
|
6043
|
+
const errorStates = options?.errorStates ?? [RPCSPEC08.ETransactionStatus.REJECTED];
|
|
6045
6044
|
const successStates = options?.successStates ?? [
|
|
6046
6045
|
// RPC.ETransactionExecutionStatus.SUCCEEDED, Starknet 0.14.0 this one can have incomplete events
|
|
6047
6046
|
RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L2,
|
|
6048
6047
|
RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L1
|
|
6049
6048
|
];
|
|
6049
|
+
const LifeCycleErrorMessages = {
|
|
6050
|
+
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
6051
|
+
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6052
|
+
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6053
|
+
};
|
|
6050
6054
|
const txLife = [];
|
|
6051
6055
|
let txStatus;
|
|
6052
6056
|
while (!onchain) {
|
|
@@ -6075,15 +6079,11 @@ var RpcChannel = class {
|
|
|
6075
6079
|
}
|
|
6076
6080
|
if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
|
|
6077
6081
|
logger.info("txLife: ", txLife);
|
|
6078
|
-
const
|
|
6079
|
-
|
|
6080
|
-
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6081
|
-
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6082
|
-
};
|
|
6083
|
-
const errorMessage = errorMessages[txLife.at(-1)];
|
|
6084
|
-
if (errorMessage) {
|
|
6082
|
+
const errorMessage = LifeCycleErrorMessages[txLife.at(-1)];
|
|
6083
|
+
if (errorMessage && lifeCycleRetries <= 0) {
|
|
6085
6084
|
throw new Error(errorMessage);
|
|
6086
6085
|
}
|
|
6086
|
+
lifeCycleRetries -= 1;
|
|
6087
6087
|
}
|
|
6088
6088
|
if (retries <= 0) {
|
|
6089
6089
|
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
@@ -6473,14 +6473,14 @@ var RpcChannel2 = class {
|
|
|
6473
6473
|
}
|
|
6474
6474
|
/**
|
|
6475
6475
|
* fetch rpc node specVersion
|
|
6476
|
-
* @example this.specVersion = "0.
|
|
6476
|
+
* @example this.specVersion = "0.9.0"
|
|
6477
6477
|
*/
|
|
6478
6478
|
getSpecVersion() {
|
|
6479
6479
|
return this.fetchEndpoint("starknet_specVersion");
|
|
6480
6480
|
}
|
|
6481
6481
|
/**
|
|
6482
6482
|
* fetch if undefined else just return this.specVersion
|
|
6483
|
-
* @example this.specVersion = "0.
|
|
6483
|
+
* @example this.specVersion = "0.9.0"
|
|
6484
6484
|
*/
|
|
6485
6485
|
async setUpSpecVersion() {
|
|
6486
6486
|
if (!this.specVersion) {
|
|
@@ -6624,7 +6624,8 @@ var RpcChannel2 = class {
|
|
|
6624
6624
|
}
|
|
6625
6625
|
async waitForTransaction(txHash, options) {
|
|
6626
6626
|
const transactionHash = toHex(txHash);
|
|
6627
|
-
let
|
|
6627
|
+
let retries = options?.retries ?? this.retries;
|
|
6628
|
+
let lifeCycleRetries = options?.lifeCycleRetries ?? 3;
|
|
6628
6629
|
let onchain = false;
|
|
6629
6630
|
let isErrorState = false;
|
|
6630
6631
|
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
@@ -6634,6 +6635,11 @@ var RpcChannel2 = class {
|
|
|
6634
6635
|
RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L2,
|
|
6635
6636
|
RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L1
|
|
6636
6637
|
];
|
|
6638
|
+
const errorMessages = {
|
|
6639
|
+
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
6640
|
+
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6641
|
+
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6642
|
+
};
|
|
6637
6643
|
const txLife = [];
|
|
6638
6644
|
let txStatus;
|
|
6639
6645
|
while (!onchain) {
|
|
@@ -6662,15 +6668,11 @@ var RpcChannel2 = class {
|
|
|
6662
6668
|
}
|
|
6663
6669
|
if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
|
|
6664
6670
|
logger.info("txLife: ", txLife);
|
|
6665
|
-
const errorMessages = {
|
|
6666
|
-
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
6667
|
-
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6668
|
-
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6669
|
-
};
|
|
6670
6671
|
const errorMessage = errorMessages[txLife.at(-1)];
|
|
6671
|
-
if (errorMessage) {
|
|
6672
|
+
if (errorMessage && lifeCycleRetries <= 0) {
|
|
6672
6673
|
throw new Error(errorMessage);
|
|
6673
6674
|
}
|
|
6675
|
+
lifeCycleRetries -= 1;
|
|
6674
6676
|
}
|
|
6675
6677
|
if (retries <= 0) {
|
|
6676
6678
|
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
@@ -7857,12 +7859,15 @@ function createTransactionReceipt(receipt) {
|
|
|
7857
7859
|
match(callbacks) {
|
|
7858
7860
|
return statusReceipt in callbacks ? callbacks[statusReceipt](value) : callbacks._();
|
|
7859
7861
|
},
|
|
7862
|
+
// @ts-ignore - docs
|
|
7860
7863
|
isSuccess() {
|
|
7861
7864
|
return statusReceipt === "SUCCEEDED";
|
|
7862
7865
|
},
|
|
7866
|
+
// @ts-ignore - docs
|
|
7863
7867
|
isReverted() {
|
|
7864
7868
|
return statusReceipt === "REVERTED";
|
|
7865
7869
|
},
|
|
7870
|
+
// @ts-ignore - docs
|
|
7866
7871
|
isError() {
|
|
7867
7872
|
return false;
|
|
7868
7873
|
}
|
|
@@ -7875,12 +7880,15 @@ function createTransactionReceipt(receipt) {
|
|
|
7875
7880
|
match(callbacks) {
|
|
7876
7881
|
return "ERROR" in callbacks ? callbacks.ERROR(errorValue) : callbacks._();
|
|
7877
7882
|
},
|
|
7883
|
+
// @ts-ignore - docs
|
|
7878
7884
|
isSuccess() {
|
|
7879
7885
|
return false;
|
|
7880
7886
|
},
|
|
7887
|
+
// @ts-ignore - docs
|
|
7881
7888
|
isReverted() {
|
|
7882
7889
|
return false;
|
|
7883
7890
|
},
|
|
7891
|
+
// @ts-ignore - docs
|
|
7884
7892
|
isError() {
|
|
7885
7893
|
return true;
|
|
7886
7894
|
}
|