@atomiqlabs/chain-starknet 7.0.0 → 7.0.2
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.
|
@@ -250,15 +250,15 @@ class StarknetPersistentSigner extends StarknetSigner_1.StarknetSigner {
|
|
|
250
250
|
return result;
|
|
251
251
|
}
|
|
252
252
|
catch (e) {
|
|
253
|
+
this.chainInterface.Transactions._knownTxSet.delete(signedTx.txId);
|
|
254
|
+
this.pendingTxs.delete(transaction.details.nonce);
|
|
255
|
+
this.pendingNonce--;
|
|
256
|
+
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
253
257
|
if (e.baseError?.code === 52) { //Invalid transaction nonce
|
|
254
258
|
//Re-check nonce from on-chain
|
|
255
259
|
this.logger.info("sendTransaction(): Got INVALID_TRANSACTION_NONCE (52) back from backend, re-checking latest nonce from chain!");
|
|
256
260
|
await this.syncNonceFromChain();
|
|
257
261
|
}
|
|
258
|
-
this.chainInterface.Transactions._knownTxSet.delete(signedTx.txId);
|
|
259
|
-
this.pendingTxs.delete(transaction.details.nonce);
|
|
260
|
-
this.pendingNonce--;
|
|
261
|
-
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
262
262
|
throw e;
|
|
263
263
|
}
|
|
264
264
|
});
|
package/package.json
CHANGED
|
@@ -318,15 +318,15 @@ export class StarknetPersistentSigner extends StarknetSigner {
|
|
|
318
318
|
pendingTxObject.sending = false;
|
|
319
319
|
return result;
|
|
320
320
|
} catch (e) {
|
|
321
|
+
this.chainInterface.Transactions._knownTxSet.delete(signedTx.txId);
|
|
322
|
+
this.pendingTxs.delete(transaction.details.nonce);
|
|
323
|
+
this.pendingNonce--;
|
|
324
|
+
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
321
325
|
if(e.baseError?.code === 52) { //Invalid transaction nonce
|
|
322
326
|
//Re-check nonce from on-chain
|
|
323
327
|
this.logger.info("sendTransaction(): Got INVALID_TRANSACTION_NONCE (52) back from backend, re-checking latest nonce from chain!");
|
|
324
328
|
await this.syncNonceFromChain();
|
|
325
329
|
}
|
|
326
|
-
this.chainInterface.Transactions._knownTxSet.delete(signedTx.txId);
|
|
327
|
-
this.pendingTxs.delete(transaction.details.nonce);
|
|
328
|
-
this.pendingNonce--;
|
|
329
|
-
this.logger.debug("sendTransaction(): Error when broadcasting transaction, reverting pending nonce to: ", this.pendingNonce);
|
|
330
330
|
throw e;
|
|
331
331
|
}
|
|
332
332
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Account, DeployAccountContractPayload, Provider } from "starknet";
|
|
2
|
-
export declare class StarknetKeypairWallet extends Account {
|
|
3
|
-
readonly publicKey: string;
|
|
4
|
-
constructor(provider: Provider, privateKey: string);
|
|
5
|
-
getDeploymentData(): DeployAccountContractPayload;
|
|
6
|
-
static generateRandomPrivateKey(): string;
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StarknetKeypairWallet = void 0;
|
|
4
|
-
const starknet_1 = require("starknet");
|
|
5
|
-
const Utils_1 = require("../../utils/Utils");
|
|
6
|
-
const buffer_1 = require("buffer");
|
|
7
|
-
const OZaccountClassHash = '0x00261c293c8084cd79086214176b33e5911677cec55104fddc8d25b0b736dcad';
|
|
8
|
-
//Openzeppelin Account wallet
|
|
9
|
-
class StarknetKeypairWallet extends starknet_1.Account {
|
|
10
|
-
constructor(provider, privateKey) {
|
|
11
|
-
const publicKey = starknet_1.ec.starkCurve.getStarkKey((0, Utils_1.toHex)(privateKey));
|
|
12
|
-
// Calculate future address of the account
|
|
13
|
-
const OZaccountConstructorCallData = starknet_1.CallData.compile({ publicKey });
|
|
14
|
-
const OZcontractAddress = starknet_1.hash.calculateContractAddressFromHash(publicKey, OZaccountClassHash, OZaccountConstructorCallData, 0);
|
|
15
|
-
super({
|
|
16
|
-
provider,
|
|
17
|
-
address: OZcontractAddress,
|
|
18
|
-
signer: privateKey,
|
|
19
|
-
cairoVersion: "1"
|
|
20
|
-
});
|
|
21
|
-
this.publicKey = publicKey;
|
|
22
|
-
}
|
|
23
|
-
getDeploymentData() {
|
|
24
|
-
return {
|
|
25
|
-
classHash: OZaccountClassHash,
|
|
26
|
-
constructorCalldata: starknet_1.CallData.compile({ publicKey: this.publicKey }),
|
|
27
|
-
addressSalt: this.publicKey,
|
|
28
|
-
contractAddress: this.address
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
static generateRandomPrivateKey() {
|
|
32
|
-
return "0x" + buffer_1.Buffer.from(starknet_1.ec.starkCurve.utils.randomPrivateKey()).toString("hex");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.StarknetKeypairWallet = StarknetKeypairWallet;
|