@atomiqlabs/chain-starknet 7.0.14 → 7.0.16

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.
@@ -22,8 +22,8 @@ function serializeBlockHeader(e) {
22
22
  hash: buffer_1.Buffer.from(e.getHash(), "hex").reverse()
23
23
  });
24
24
  }
25
- const GAS_PER_BLOCKHEADER = { l1DataGas: 600, l2Gas: 40000000, l1Gas: 0 };
26
- const GAS_PER_BLOCKHEADER_FORK = { l1DataGas: 1000, l2Gas: 60000000, l1Gas: 0 };
25
+ const GAS_PER_BLOCKHEADER = { l1DataGas: 600, l2Gas: 24000000, l1Gas: 0 };
26
+ const GAS_PER_BLOCKHEADER_FORK = { l1DataGas: 1000, l2Gas: 40000000, l1Gas: 0 };
27
27
  const btcRelayAddreses = {
28
28
  [base_1.BitcoinNetwork.TESTNET4]: "0x0099b63f39f0cabb767361de3d8d3e97212351a51540e2687c2571f4da490dbe",
29
29
  [base_1.BitcoinNetwork.TESTNET]: "0x068601c79da2231d21e015ccfd59c243861156fa523a12c9f987ec28eb8dbc8c",
@@ -159,20 +159,20 @@ class StarknetTransactions extends StarknetModule_1.StarknetModule {
159
159
  txReplaceListener = (oldTx, oldTxId, newTx, newTxId) => {
160
160
  if (checkTxns.has(oldTxId))
161
161
  checkTxns.add(newTxId);
162
- if (this.root.wsChannel != null)
163
- this.confirmTransactionWs(newTxId, abortController.signal)
164
- .then(resolve)
165
- .catch(reject);
162
+ //TODO: Add this when websocket subscriptions get stable
163
+ // if(this.root.wsChannel!=null) this.confirmTransactionWs(newTxId, abortController.signal)
164
+ // .then(resolve)
165
+ // .catch(reject);
166
166
  return Promise.resolve();
167
167
  };
168
168
  this.onBeforeTxReplace(txReplaceListener);
169
169
  this.confirmTransactionPolling(tx.details.walletAddress, BigInt(tx.details.nonce), checkTxns, abortController.signal)
170
170
  .then(resolve)
171
171
  .catch(reject);
172
- if (this.root.wsChannel != null)
173
- this.confirmTransactionWs(tx.txId, abortController.signal)
174
- .then(resolve)
175
- .catch(reject);
172
+ //TODO: Add this when websocket subscriptions get stable
173
+ // if(this.root.wsChannel!=null) this.confirmTransactionWs(tx.txId, abortController.signal)
174
+ // .then(resolve)
175
+ // .catch(reject);
176
176
  });
177
177
  this.offBeforeTxReplace(txReplaceListener);
178
178
  abortController.abort();
@@ -31,8 +31,8 @@ class StarknetChainEventsBrowser {
31
31
  }
32
32
  getEventFingerprint(event) {
33
33
  const eventData = buffer_1.Buffer.concat([
34
- ...event.keys.map(value => (0, Utils_1.bigNumberishToBuffer)(value, 64)),
35
- ...event.data.map(value => (0, Utils_1.bigNumberishToBuffer)(value, 64))
34
+ ...event.keys.map(value => (0, Utils_1.bigNumberishToBuffer)(value, 32)),
35
+ ...event.data.map(value => (0, Utils_1.bigNumberishToBuffer)(value, 32))
36
36
  ]);
37
37
  const fingerprint = buffer_1.Buffer.from((0, sha2_1.sha256)(eventData));
38
38
  return event.txHash + ":" + fingerprint.toString("hex");
@@ -467,7 +467,7 @@ class StarknetSpvVaultContract extends StarknetContractBase_1.StarknetContractBa
467
467
  }
468
468
  async getClaimFee(signer, vault, withdrawalData, feeRate) {
469
469
  feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
470
- return StarknetFees_1.StarknetFees.getGasFee(StarknetSpvVaultContract.GasCosts.CLAIM, feeRate);
470
+ return StarknetFees_1.StarknetFees.getGasFee(withdrawalData == null ? StarknetSpvVaultContract.GasCosts.CLAIM_OPTIMISTIC_ESTIMATE : StarknetSpvVaultContract.GasCosts.CLAIM, feeRate);
471
471
  }
472
472
  async getFrontFee(signer, vault, withdrawalData, feeRate) {
473
473
  feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
@@ -479,5 +479,6 @@ StarknetSpvVaultContract.GasCosts = {
479
479
  DEPOSIT: { l1DataGas: 400, l2Gas: 4000000, l1Gas: 0 },
480
480
  OPEN: { l1DataGas: 1200, l2Gas: 3200000, l1Gas: 0 },
481
481
  FRONT: { l1DataGas: 800, l2Gas: 12000000, l1Gas: 0 },
482
- CLAIM: { l1DataGas: 1000, l2Gas: 400000000, l1Gas: 0 }
482
+ CLAIM: { l1DataGas: 1000, l2Gas: 400000000, l1Gas: 0 },
483
+ CLAIM_OPTIMISTIC_ESTIMATE: { l1DataGas: 1000, l2Gas: 80000000, l1Gas: 0 } //If claimer uses sierra 1.7.0 or later
483
484
  };
@@ -41,4 +41,4 @@ class HashlockClaimHandler {
41
41
  }
42
42
  exports.HashlockClaimHandler = HashlockClaimHandler;
43
43
  HashlockClaimHandler.type = base_1.ChainSwapType.HTLC;
44
- HashlockClaimHandler.gas = { l1DataGas: 0, l2Gas: 800 * 40000, l1Gas: 0 };
44
+ HashlockClaimHandler.gas = { l1DataGas: 0, l2Gas: 16000000, l1Gas: 0 };
@@ -45,4 +45,4 @@ class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinCla
45
45
  }
46
46
  exports.BitcoinNoncedOutputClaimHandler = BitcoinNoncedOutputClaimHandler;
47
47
  BitcoinNoncedOutputClaimHandler.type = base_1.ChainSwapType.CHAIN_NONCED;
48
- BitcoinNoncedOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
48
+ BitcoinNoncedOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 10000 * 40000, l1Gas: 0 };
@@ -37,4 +37,4 @@ class BitcoinOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHand
37
37
  }
38
38
  exports.BitcoinOutputClaimHandler = BitcoinOutputClaimHandler;
39
39
  BitcoinOutputClaimHandler.type = base_1.ChainSwapType.CHAIN;
40
- BitcoinOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
40
+ BitcoinOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 10000 * 40000, l1Gas: 0 };
@@ -27,4 +27,4 @@ class BitcoinTxIdClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHandle
27
27
  }
28
28
  exports.BitcoinTxIdClaimHandler = BitcoinTxIdClaimHandler;
29
29
  BitcoinTxIdClaimHandler.type = base_1.ChainSwapType.CHAIN_TXID;
30
- BitcoinTxIdClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
30
+ BitcoinTxIdClaimHandler.gas = { l1DataGas: 0, l2Gas: 10000 * 40000, l1Gas: 0 };
@@ -49,4 +49,4 @@ class IBitcoinClaimHandler {
49
49
  exports.IBitcoinClaimHandler = IBitcoinClaimHandler;
50
50
  IBitcoinClaimHandler.address = "";
51
51
  IBitcoinClaimHandler.type = base_1.ChainSwapType.CHAIN_TXID;
52
- IBitcoinClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
52
+ IBitcoinClaimHandler.gas = { l1DataGas: 0, l2Gas: 10000 * 40000, l1Gas: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-starknet",
3
- "version": "7.0.14",
3
+ "version": "7.0.16",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -29,8 +29,8 @@ function serializeBlockHeader(e: BtcBlock): StarknetBtcHeader {
29
29
  });
30
30
  }
31
31
 
32
- const GAS_PER_BLOCKHEADER = {l1DataGas: 600, l2Gas: 40_000_000, l1Gas: 0};
33
- const GAS_PER_BLOCKHEADER_FORK = {l1DataGas: 1000, l2Gas: 60_000_000, l1Gas: 0};
32
+ const GAS_PER_BLOCKHEADER = {l1DataGas: 600, l2Gas: 24_000_000, l1Gas: 0};
33
+ const GAS_PER_BLOCKHEADER_FORK = {l1DataGas: 1000, l2Gas: 40_000_000, l1Gas: 0};
34
34
 
35
35
  const btcRelayAddreses = {
36
36
  [BitcoinNetwork.TESTNET4]: "0x0099b63f39f0cabb767361de3d8d3e97212351a51540e2687c2571f4da490dbe",
@@ -201,9 +201,10 @@ export class StarknetTransactions extends StarknetModule {
201
201
 
202
202
  txReplaceListener = (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => {
203
203
  if(checkTxns.has(oldTxId)) checkTxns.add(newTxId);
204
- if(this.root.wsChannel!=null) this.confirmTransactionWs(newTxId, abortController.signal)
205
- .then(resolve)
206
- .catch(reject);
204
+ //TODO: Add this when websocket subscriptions get stable
205
+ // if(this.root.wsChannel!=null) this.confirmTransactionWs(newTxId, abortController.signal)
206
+ // .then(resolve)
207
+ // .catch(reject);
207
208
  return Promise.resolve();
208
209
  };
209
210
  this.onBeforeTxReplace(txReplaceListener);
@@ -211,9 +212,10 @@ export class StarknetTransactions extends StarknetModule {
211
212
  this.confirmTransactionPolling(tx.details.walletAddress, BigInt(tx.details.nonce), checkTxns, abortController.signal)
212
213
  .then(resolve)
213
214
  .catch(reject);
214
- if(this.root.wsChannel!=null) this.confirmTransactionWs(tx.txId, abortController.signal)
215
- .then(resolve)
216
- .catch(reject);
215
+ //TODO: Add this when websocket subscriptions get stable
216
+ // if(this.root.wsChannel!=null) this.confirmTransactionWs(tx.txId, abortController.signal)
217
+ // .then(resolve)
218
+ // .catch(reject);
217
219
  });
218
220
  this.offBeforeTxReplace(txReplaceListener);
219
221
  abortController.abort();
@@ -95,8 +95,8 @@ export class StarknetChainEventsBrowser implements ChainEvents<StarknetSwapData>
95
95
 
96
96
  private getEventFingerprint(event: {keys: string[], data: string[], txHash: string}): string {
97
97
  const eventData = Buffer.concat([
98
- ...event.keys.map(value => bigNumberishToBuffer(value, 64)),
99
- ...event.data.map(value => bigNumberishToBuffer(value, 64))
98
+ ...event.keys.map(value => bigNumberishToBuffer(value, 32)),
99
+ ...event.data.map(value => bigNumberishToBuffer(value, 32))
100
100
  ]);
101
101
  const fingerprint = Buffer.from(sha256(eventData));
102
102
 
@@ -57,7 +57,8 @@ export class StarknetSpvVaultContract
57
57
  DEPOSIT: {l1DataGas: 400, l2Gas: 4_000_000, l1Gas: 0},
58
58
  OPEN: {l1DataGas: 1200, l2Gas: 3_200_000, l1Gas: 0},
59
59
  FRONT: {l1DataGas: 800, l2Gas: 12_000_000, l1Gas: 0},
60
- CLAIM: {l1DataGas: 1000, l2Gas: 400_000_000, l1Gas: 0}
60
+ CLAIM: {l1DataGas: 1000, l2Gas: 400_000_000, l1Gas: 0},
61
+ CLAIM_OPTIMISTIC_ESTIMATE: {l1DataGas: 1000, l2Gas: 80_000_000, l1Gas: 0} //If claimer uses sierra 1.7.0 or later
61
62
  };
62
63
 
63
64
  readonly chainId = "STARKNET";
@@ -590,7 +591,10 @@ export class StarknetSpvVaultContract
590
591
 
591
592
  async getClaimFee(signer: string, vault: StarknetSpvVaultData, withdrawalData: StarknetSpvWithdrawalData, feeRate?: string): Promise<bigint> {
592
593
  feeRate ??= await this.Chain.Fees.getFeeRate();
593
- return StarknetFees.getGasFee(StarknetSpvVaultContract.GasCosts.CLAIM, feeRate);
594
+ return StarknetFees.getGasFee(
595
+ withdrawalData==null ? StarknetSpvVaultContract.GasCosts.CLAIM_OPTIMISTIC_ESTIMATE : StarknetSpvVaultContract.GasCosts.CLAIM,
596
+ feeRate
597
+ );
594
598
  }
595
599
 
596
600
  async getFrontFee(signer: string, vault: StarknetSpvVaultData, withdrawalData: StarknetSpvWithdrawalData, feeRate?: string): Promise<bigint> {
@@ -12,7 +12,7 @@ export class HashlockClaimHandler implements IClaimHandler<Buffer, string> {
12
12
 
13
13
  public readonly address: string;
14
14
  public static readonly type: ChainSwapType = ChainSwapType.HTLC;
15
- public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 800*40_000, l1Gas: 0};
15
+ public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 16_000_000, l1Gas: 0};
16
16
 
17
17
  constructor(address: string) {
18
18
  this.address = address;
@@ -27,7 +27,7 @@ function getTransactionNonce(btcTx: Transaction): bigint {
27
27
  export class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler<BitcoinNoncedOutputCommitmentData, BitcoinOutputWitnessData> {
28
28
 
29
29
  public static readonly type: ChainSwapType = ChainSwapType.CHAIN_NONCED;
30
- public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 20_000*40_000, l1Gas: 0};
30
+ public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 10_000*40_000, l1Gas: 0};
31
31
 
32
32
  protected serializeCommitment(data: BitcoinNoncedOutputCommitmentData & BitcoinCommitmentData): BigNumberish[] {
33
33
  return [
@@ -22,7 +22,7 @@ const logger = getLogger("BitcoinOutputClaimHandler: ");
22
22
  export class BitcoinOutputClaimHandler extends IBitcoinClaimHandler<BitcoinOutputCommitmentData, BitcoinOutputWitnessData> {
23
23
 
24
24
  public static readonly type: ChainSwapType = ChainSwapType.CHAIN;
25
- public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 20_000 * 40_000, l1Gas: 0};
25
+ public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 10_000 * 40_000, l1Gas: 0};
26
26
 
27
27
  protected serializeCommitment(data: BitcoinOutputCommitmentData & BitcoinCommitmentData): BigNumberish[] {
28
28
  return [
@@ -16,7 +16,7 @@ const logger = getLogger("BitcoinTxIdClaimHandler: ");
16
16
  export class BitcoinTxIdClaimHandler extends IBitcoinClaimHandler<BitcoinTxIdCommitmentData, BitcoinWitnessData> {
17
17
 
18
18
  public static readonly type: ChainSwapType = ChainSwapType.CHAIN_TXID;
19
- public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 20_000 * 40_000, l1Gas: 0};
19
+ public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 10_000 * 40_000, l1Gas: 0};
20
20
 
21
21
  protected serializeCommitment(data: BitcoinTxIdCommitmentData & BitcoinCommitmentData): BigNumberish[] {
22
22
  return [
@@ -33,7 +33,7 @@ export abstract class IBitcoinClaimHandler<C, W extends BitcoinWitnessData> impl
33
33
 
34
34
  public static readonly address = "";
35
35
  public static readonly type: ChainSwapType = ChainSwapType.CHAIN_TXID;
36
- public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 20_000 * 40_000, l1Gas: 0};
36
+ public static readonly gas: StarknetGas = {l1DataGas: 0, l2Gas: 10_000 * 40_000, l1Gas: 0};
37
37
 
38
38
  protected serializeCommitment(data: BitcoinCommitmentData): BigNumberish[] {
39
39
  return [