@atomiqlabs/chain-starknet 4.0.0-dev.23 → 4.0.0-dev.25
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.
|
@@ -33,10 +33,10 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
33
33
|
this.logger = (0, Utils_1.getLogger)("StarknetPersistentSigner(" + this.account.address + "): ");
|
|
34
34
|
}
|
|
35
35
|
async load() {
|
|
36
|
-
const fileExists = await promises_1.
|
|
36
|
+
const fileExists = await (0, promises_1.access)(this.directory + "/txs.json", promises_1.constants.F_OK).then(() => true).catch(() => false);
|
|
37
37
|
if (!fileExists)
|
|
38
38
|
return;
|
|
39
|
-
const res = await promises_1.
|
|
39
|
+
const res = await (0, promises_1.readFile)(this.directory + "/txs.json");
|
|
40
40
|
if (res != null) {
|
|
41
41
|
const pendingTxs = JSON.parse(res.toString());
|
|
42
42
|
for (let nonceStr in pendingTxs) {
|
|
@@ -71,7 +71,7 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
71
71
|
await this.priorSavePromise;
|
|
72
72
|
}
|
|
73
73
|
if (requiredSaveCount === this.saveCount) {
|
|
74
|
-
this.priorSavePromise = promises_1.
|
|
74
|
+
this.priorSavePromise = (0, promises_1.writeFile)(this.directory + "/txs.json", JSON.stringify(pendingTxs));
|
|
75
75
|
await this.priorSavePromise;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -141,7 +141,7 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
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
143
|
this.logger.info("checkPastTransactions(): Bump fee for tx: ", lastTx.txId);
|
|
144
|
-
await this.
|
|
144
|
+
await this._signTransaction(newTx);
|
|
145
145
|
//Double check pending txns still has nonce after async signTransaction was called
|
|
146
146
|
if (!this.pendingTxs.has(nonce))
|
|
147
147
|
continue;
|
|
@@ -184,7 +184,7 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
184
184
|
}
|
|
185
185
|
async init() {
|
|
186
186
|
try {
|
|
187
|
-
await promises_1.
|
|
187
|
+
await (0, promises_1.mkdir)(this.directory);
|
|
188
188
|
}
|
|
189
189
|
catch (e) { }
|
|
190
190
|
const nonce = await this.chainInterface.Transactions.getNonce(this.account.address);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import {StarknetTransactions, StarknetTx} from "../chain/modules/StarknetTransac
|
|
|
3
3
|
import {StarknetChainInterface} from "../chain/StarknetChainInterface";
|
|
4
4
|
import {bigIntMax, getLogger, LoggerType} from "../../utils/Utils";
|
|
5
5
|
import {Account} from "starknet";
|
|
6
|
-
import
|
|
6
|
+
import {access, readFile, writeFile, mkdir, constants} from "fs/promises";
|
|
7
7
|
import {StarknetFees} from "../chain/modules/StarknetFees";
|
|
8
8
|
import {cloneDeep} from "@scure/btc-signer/transaction";
|
|
9
9
|
import { PromiseQueue } from "promise-queue-ts";
|
|
@@ -65,9 +65,9 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
private async load() {
|
|
68
|
-
const fileExists = await
|
|
68
|
+
const fileExists = await access(this.directory+"/txs.json", constants.F_OK).then(() => true).catch(() => false);
|
|
69
69
|
if(!fileExists) return;
|
|
70
|
-
const res = await
|
|
70
|
+
const res = await readFile(this.directory+"/txs.json");
|
|
71
71
|
if(res!=null) {
|
|
72
72
|
const pendingTxs: {
|
|
73
73
|
[nonce: string]: {
|
|
@@ -118,7 +118,7 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
118
118
|
await this.priorSavePromise;
|
|
119
119
|
}
|
|
120
120
|
if(requiredSaveCount===this.saveCount) {
|
|
121
|
-
this.priorSavePromise =
|
|
121
|
+
this.priorSavePromise = writeFile(this.directory+"/txs.json", JSON.stringify(pendingTxs));
|
|
122
122
|
await this.priorSavePromise;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -196,7 +196,7 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
196
196
|
newTx.details.resourceBounds.l1_data_gas.max_price_per_unit = l1DataGasCost;
|
|
197
197
|
this.logger.info("checkPastTransactions(): Bump fee for tx: ", lastTx.txId);
|
|
198
198
|
|
|
199
|
-
await this.
|
|
199
|
+
await this._signTransaction(newTx);
|
|
200
200
|
|
|
201
201
|
//Double check pending txns still has nonce after async signTransaction was called
|
|
202
202
|
if(!this.pendingTxs.has(nonce)) continue;
|
|
@@ -244,7 +244,7 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
244
244
|
|
|
245
245
|
async init(): Promise<void> {
|
|
246
246
|
try {
|
|
247
|
-
await
|
|
247
|
+
await mkdir(this.directory)
|
|
248
248
|
} catch (e) {}
|
|
249
249
|
|
|
250
250
|
const nonce = await this.chainInterface.Transactions.getNonce(this.account.address);
|