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.mjs
CHANGED
|
@@ -1800,10 +1800,13 @@ var errorCodes = {
|
|
|
1800
1800
|
UNSUPPORTED_TX_VERSION: 61,
|
|
1801
1801
|
UNSUPPORTED_CONTRACT_CLASS_VERSION: 62,
|
|
1802
1802
|
UNEXPECTED_ERROR: 63,
|
|
1803
|
+
REPLACEMENT_TRANSACTION_UNDERPRICED: 64,
|
|
1804
|
+
FEE_BELOW_MINIMUM: 65,
|
|
1803
1805
|
INVALID_SUBSCRIPTION_ID: 66,
|
|
1804
1806
|
TOO_MANY_ADDRESSES_IN_FILTER: 67,
|
|
1805
1807
|
TOO_MANY_BLOCKS_BACK: 68,
|
|
1806
1808
|
COMPILATION_ERROR: 100,
|
|
1809
|
+
//
|
|
1807
1810
|
INVALID_ADDRESS: 150,
|
|
1808
1811
|
TOKEN_NOT_SUPPORTED: 151,
|
|
1809
1812
|
INVALID_SIGNATURE: 153,
|
|
@@ -5707,7 +5710,7 @@ var RpcChannel = class {
|
|
|
5707
5710
|
}
|
|
5708
5711
|
/**
|
|
5709
5712
|
* fetch rpc node specVersion
|
|
5710
|
-
* @example this.specVersion = "0.
|
|
5713
|
+
* @example this.specVersion = "0.8.1"
|
|
5711
5714
|
*/
|
|
5712
5715
|
getSpecVersion() {
|
|
5713
5716
|
return this.fetchEndpoint("starknet_specVersion");
|
|
@@ -5858,21 +5861,22 @@ var RpcChannel = class {
|
|
|
5858
5861
|
}
|
|
5859
5862
|
async waitForTransaction(txHash, options) {
|
|
5860
5863
|
const transactionHash = toHex(txHash);
|
|
5861
|
-
let
|
|
5864
|
+
let retries = options?.retries ?? this.retries;
|
|
5865
|
+
let lifeCycleRetries = options?.lifeCycleRetries ?? 3;
|
|
5862
5866
|
let onchain = false;
|
|
5863
5867
|
let isErrorState = false;
|
|
5864
5868
|
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
5865
|
-
const errorStates = options?.errorStates ?? [
|
|
5866
|
-
RPCSPEC08.ETransactionStatus.REJECTED
|
|
5867
|
-
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
5868
|
-
// should decide which behavior to keep in the future
|
|
5869
|
-
// RPC.ETransactionExecutionStatus.REVERTED,
|
|
5870
|
-
];
|
|
5869
|
+
const errorStates = options?.errorStates ?? [RPCSPEC08.ETransactionStatus.REJECTED];
|
|
5871
5870
|
const successStates = options?.successStates ?? [
|
|
5872
5871
|
// RPC.ETransactionExecutionStatus.SUCCEEDED, Starknet 0.14.0 this one can have incomplete events
|
|
5873
5872
|
RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L2,
|
|
5874
5873
|
RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L1
|
|
5875
5874
|
];
|
|
5875
|
+
const LifeCycleErrorMessages = {
|
|
5876
|
+
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
5877
|
+
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
5878
|
+
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
5879
|
+
};
|
|
5876
5880
|
const txLife = [];
|
|
5877
5881
|
let txStatus;
|
|
5878
5882
|
while (!onchain) {
|
|
@@ -5901,15 +5905,11 @@ var RpcChannel = class {
|
|
|
5901
5905
|
}
|
|
5902
5906
|
if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
|
|
5903
5907
|
logger.info("txLife: ", txLife);
|
|
5904
|
-
const
|
|
5905
|
-
|
|
5906
|
-
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
5907
|
-
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
5908
|
-
};
|
|
5909
|
-
const errorMessage = errorMessages[txLife.at(-1)];
|
|
5910
|
-
if (errorMessage) {
|
|
5908
|
+
const errorMessage = LifeCycleErrorMessages[txLife.at(-1)];
|
|
5909
|
+
if (errorMessage && lifeCycleRetries <= 0) {
|
|
5911
5910
|
throw new Error(errorMessage);
|
|
5912
5911
|
}
|
|
5912
|
+
lifeCycleRetries -= 1;
|
|
5913
5913
|
}
|
|
5914
5914
|
if (retries <= 0) {
|
|
5915
5915
|
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
@@ -6299,14 +6299,14 @@ var RpcChannel2 = class {
|
|
|
6299
6299
|
}
|
|
6300
6300
|
/**
|
|
6301
6301
|
* fetch rpc node specVersion
|
|
6302
|
-
* @example this.specVersion = "0.
|
|
6302
|
+
* @example this.specVersion = "0.9.0"
|
|
6303
6303
|
*/
|
|
6304
6304
|
getSpecVersion() {
|
|
6305
6305
|
return this.fetchEndpoint("starknet_specVersion");
|
|
6306
6306
|
}
|
|
6307
6307
|
/**
|
|
6308
6308
|
* fetch if undefined else just return this.specVersion
|
|
6309
|
-
* @example this.specVersion = "0.
|
|
6309
|
+
* @example this.specVersion = "0.9.0"
|
|
6310
6310
|
*/
|
|
6311
6311
|
async setUpSpecVersion() {
|
|
6312
6312
|
if (!this.specVersion) {
|
|
@@ -6450,7 +6450,8 @@ var RpcChannel2 = class {
|
|
|
6450
6450
|
}
|
|
6451
6451
|
async waitForTransaction(txHash, options) {
|
|
6452
6452
|
const transactionHash = toHex(txHash);
|
|
6453
|
-
let
|
|
6453
|
+
let retries = options?.retries ?? this.retries;
|
|
6454
|
+
let lifeCycleRetries = options?.lifeCycleRetries ?? 3;
|
|
6454
6455
|
let onchain = false;
|
|
6455
6456
|
let isErrorState = false;
|
|
6456
6457
|
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
@@ -6460,6 +6461,11 @@ var RpcChannel2 = class {
|
|
|
6460
6461
|
RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L2,
|
|
6461
6462
|
RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L1
|
|
6462
6463
|
];
|
|
6464
|
+
const errorMessages = {
|
|
6465
|
+
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
6466
|
+
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6467
|
+
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6468
|
+
};
|
|
6463
6469
|
const txLife = [];
|
|
6464
6470
|
let txStatus;
|
|
6465
6471
|
while (!onchain) {
|
|
@@ -6488,15 +6494,11 @@ var RpcChannel2 = class {
|
|
|
6488
6494
|
}
|
|
6489
6495
|
if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
|
|
6490
6496
|
logger.info("txLife: ", txLife);
|
|
6491
|
-
const errorMessages = {
|
|
6492
|
-
[RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
|
|
6493
|
-
[RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
|
|
6494
|
-
[RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
|
|
6495
|
-
};
|
|
6496
6497
|
const errorMessage = errorMessages[txLife.at(-1)];
|
|
6497
|
-
if (errorMessage) {
|
|
6498
|
+
if (errorMessage && lifeCycleRetries <= 0) {
|
|
6498
6499
|
throw new Error(errorMessage);
|
|
6499
6500
|
}
|
|
6501
|
+
lifeCycleRetries -= 1;
|
|
6500
6502
|
}
|
|
6501
6503
|
if (retries <= 0) {
|
|
6502
6504
|
throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
|
|
@@ -7683,12 +7685,15 @@ function createTransactionReceipt(receipt) {
|
|
|
7683
7685
|
match(callbacks) {
|
|
7684
7686
|
return statusReceipt in callbacks ? callbacks[statusReceipt](value) : callbacks._();
|
|
7685
7687
|
},
|
|
7688
|
+
// @ts-ignore - docs
|
|
7686
7689
|
isSuccess() {
|
|
7687
7690
|
return statusReceipt === "SUCCEEDED";
|
|
7688
7691
|
},
|
|
7692
|
+
// @ts-ignore - docs
|
|
7689
7693
|
isReverted() {
|
|
7690
7694
|
return statusReceipt === "REVERTED";
|
|
7691
7695
|
},
|
|
7696
|
+
// @ts-ignore - docs
|
|
7692
7697
|
isError() {
|
|
7693
7698
|
return false;
|
|
7694
7699
|
}
|
|
@@ -7701,12 +7706,15 @@ function createTransactionReceipt(receipt) {
|
|
|
7701
7706
|
match(callbacks) {
|
|
7702
7707
|
return "ERROR" in callbacks ? callbacks.ERROR(errorValue) : callbacks._();
|
|
7703
7708
|
},
|
|
7709
|
+
// @ts-ignore - docs
|
|
7704
7710
|
isSuccess() {
|
|
7705
7711
|
return false;
|
|
7706
7712
|
},
|
|
7713
|
+
// @ts-ignore - docs
|
|
7707
7714
|
isReverted() {
|
|
7708
7715
|
return false;
|
|
7709
7716
|
},
|
|
7717
|
+
// @ts-ignore - docs
|
|
7710
7718
|
isError() {
|
|
7711
7719
|
return true;
|
|
7712
7720
|
}
|