@atomiqlabs/chain-starknet 4.0.0-dev.26 → 4.0.0-dev.27
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/dist/starknet/chain/modules/StarknetTransactions.d.ts +2 -2
- package/dist/starknet/chain/modules/StarknetTransactions.js +10 -4
- package/dist/starknet/wallet/StarknetPersistentSigner.js +8 -4
- package/package.json +1 -1
- package/src/starknet/chain/modules/StarknetTransactions.ts +9 -4
- package/src/starknet/wallet/StarknetPersistentSigner.ts +8 -4
|
@@ -74,13 +74,13 @@ export declare class StarknetTransactions extends StarknetModule {
|
|
|
74
74
|
*/
|
|
75
75
|
sendAndConfirm(signer: StarknetSigner, txs: StarknetTx[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
76
76
|
/**
|
|
77
|
-
* Serializes the
|
|
77
|
+
* Serializes the starknet transaction, saves the transaction, signers & last valid blockheight
|
|
78
78
|
*
|
|
79
79
|
* @param tx
|
|
80
80
|
*/
|
|
81
81
|
static serializeTx(tx: StarknetTx): string;
|
|
82
82
|
/**
|
|
83
|
-
* Deserializes saved
|
|
83
|
+
* Deserializes saved starknet transaction, extracting the transaction, signers & last valid blockheight
|
|
84
84
|
*
|
|
85
85
|
* @param txData
|
|
86
86
|
*/
|
|
@@ -266,24 +266,30 @@ class StarknetTransactions extends StarknetModule_1.StarknetModule {
|
|
|
266
266
|
return txIds;
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
|
-
* Serializes the
|
|
269
|
+
* Serializes the starknet transaction, saves the transaction, signers & last valid blockheight
|
|
270
270
|
*
|
|
271
271
|
* @param tx
|
|
272
272
|
*/
|
|
273
273
|
static serializeTx(tx) {
|
|
274
274
|
return JSON.stringify(tx, (key, value) => {
|
|
275
275
|
if (typeof (value) === "bigint")
|
|
276
|
-
return
|
|
276
|
+
return {
|
|
277
|
+
_type: "bigint",
|
|
278
|
+
_value: (0, Utils_1.toHex)(value)
|
|
279
|
+
};
|
|
277
280
|
return value;
|
|
278
281
|
});
|
|
279
282
|
}
|
|
280
283
|
/**
|
|
281
|
-
* Deserializes saved
|
|
284
|
+
* Deserializes saved starknet transaction, extracting the transaction, signers & last valid blockheight
|
|
282
285
|
*
|
|
283
286
|
* @param txData
|
|
284
287
|
*/
|
|
285
288
|
static deserializeTx(txData) {
|
|
286
|
-
return JSON.parse(txData)
|
|
289
|
+
return JSON.parse(txData, (key, value) => {
|
|
290
|
+
if (typeof (value) === "object" && value._type === "bigint")
|
|
291
|
+
return BigInt(value._value);
|
|
292
|
+
});
|
|
287
293
|
}
|
|
288
294
|
/**
|
|
289
295
|
* Gets the status of the raw starknet transaction
|
|
@@ -94,10 +94,10 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
94
94
|
const feeRate = await this.chainInterface.Fees.getFeeRate();
|
|
95
95
|
_gasPrice = StarknetFees_1.StarknetFees.extractFromFeeRateString(feeRate);
|
|
96
96
|
}
|
|
97
|
-
let l1GasCost = (
|
|
98
|
-
let l2GasCost = (
|
|
99
|
-
let l1DataGasCost = (
|
|
100
|
-
let tip = (
|
|
97
|
+
let l1GasCost = BigInt(lastTx.details.resourceBounds.l1_gas.max_price_per_unit);
|
|
98
|
+
let l2GasCost = BigInt(lastTx.details.resourceBounds.l2_gas.max_price_per_unit);
|
|
99
|
+
let l1DataGasCost = BigInt(lastTx.details.resourceBounds.l1_data_gas.max_price_per_unit);
|
|
100
|
+
let tip = BigInt(lastTx.details.tip);
|
|
101
101
|
let feeBumped = false;
|
|
102
102
|
if (_gasPrice.l1GasCost > l1GasCost) {
|
|
103
103
|
//Bump by minimum allowed or to the actual _gasPrice.l1GasCost
|
|
@@ -140,6 +140,10 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
140
140
|
newTx.details.resourceBounds.l1_gas.max_price_per_unit = l1GasCost;
|
|
141
141
|
newTx.details.resourceBounds.l2_gas.max_price_per_unit = l2GasCost;
|
|
142
142
|
newTx.details.resourceBounds.l1_data_gas.max_price_per_unit = l1DataGasCost;
|
|
143
|
+
this.logger.info("checkPastTransactions(): Bump tip to: ", tip);
|
|
144
|
+
this.logger.info("checkPastTransactions(): Bump l1Gas to: ", l1GasCost);
|
|
145
|
+
this.logger.info("checkPastTransactions(): Bump l2Gas to: ", l2GasCost);
|
|
146
|
+
this.logger.info("checkPastTransactions(): Bump l1DataGas to: ", l1DataGasCost);
|
|
143
147
|
this.logger.info("checkPastTransactions(): Bump fee for tx: ", lastTx.txId);
|
|
144
148
|
await this._signTransaction(newTx);
|
|
145
149
|
//Double check pending txns still has nonce after async signTransaction was called
|
package/package.json
CHANGED
|
@@ -308,24 +308,29 @@ export class StarknetTransactions extends StarknetModule {
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/**
|
|
311
|
-
* Serializes the
|
|
311
|
+
* Serializes the starknet transaction, saves the transaction, signers & last valid blockheight
|
|
312
312
|
*
|
|
313
313
|
* @param tx
|
|
314
314
|
*/
|
|
315
315
|
public static serializeTx(tx: StarknetTx): string {
|
|
316
316
|
return JSON.stringify(tx, (key, value) => {
|
|
317
|
-
if(typeof(value)==="bigint") return
|
|
317
|
+
if(typeof(value)==="bigint") return {
|
|
318
|
+
_type: "bigint",
|
|
319
|
+
_value: toHex(value)
|
|
320
|
+
};
|
|
318
321
|
return value;
|
|
319
322
|
});
|
|
320
323
|
}
|
|
321
324
|
|
|
322
325
|
/**
|
|
323
|
-
* Deserializes saved
|
|
326
|
+
* Deserializes saved starknet transaction, extracting the transaction, signers & last valid blockheight
|
|
324
327
|
*
|
|
325
328
|
* @param txData
|
|
326
329
|
*/
|
|
327
330
|
public static deserializeTx(txData: string): StarknetTx {
|
|
328
|
-
return JSON.parse(txData)
|
|
331
|
+
return JSON.parse(txData, (key, value) => {
|
|
332
|
+
if(typeof(value)==="object" && value._type==="bigint") return BigInt(value._value);
|
|
333
|
+
});
|
|
329
334
|
}
|
|
330
335
|
|
|
331
336
|
/**
|
|
@@ -145,10 +145,10 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
145
145
|
_gasPrice = StarknetFees.extractFromFeeRateString(feeRate);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
let l1GasCost =
|
|
149
|
-
let l2GasCost =
|
|
150
|
-
let l1DataGasCost =
|
|
151
|
-
let tip =
|
|
148
|
+
let l1GasCost = BigInt(lastTx.details.resourceBounds.l1_gas.max_price_per_unit);
|
|
149
|
+
let l2GasCost = BigInt(lastTx.details.resourceBounds.l2_gas.max_price_per_unit);
|
|
150
|
+
let l1DataGasCost = BigInt(lastTx.details.resourceBounds.l1_data_gas.max_price_per_unit);
|
|
151
|
+
let tip = BigInt(lastTx.details.tip);
|
|
152
152
|
|
|
153
153
|
let feeBumped: boolean = false;
|
|
154
154
|
if(_gasPrice.l1GasCost > l1GasCost) {
|
|
@@ -194,6 +194,10 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
194
194
|
newTx.details.resourceBounds.l1_gas.max_price_per_unit = l1GasCost;
|
|
195
195
|
newTx.details.resourceBounds.l2_gas.max_price_per_unit = l2GasCost;
|
|
196
196
|
newTx.details.resourceBounds.l1_data_gas.max_price_per_unit = l1DataGasCost;
|
|
197
|
+
this.logger.info("checkPastTransactions(): Bump tip to: ", tip);
|
|
198
|
+
this.logger.info("checkPastTransactions(): Bump l1Gas to: ", l1GasCost);
|
|
199
|
+
this.logger.info("checkPastTransactions(): Bump l2Gas to: ", l2GasCost);
|
|
200
|
+
this.logger.info("checkPastTransactions(): Bump l1DataGas to: ", l1DataGasCost);
|
|
197
201
|
this.logger.info("checkPastTransactions(): Bump fee for tx: ", lastTx.txId);
|
|
198
202
|
|
|
199
203
|
await this._signTransaction(newTx);
|