@atomiqlabs/chain-starknet 5.1.2 → 5.1.3

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.
@@ -49,7 +49,17 @@ class StarknetChainEventsBrowser {
49
49
  */
50
50
  getSwapDataGetter(event, claimHandler) {
51
51
  return async () => {
52
- const trace = await this.provider.getTransactionTrace(event.txHash);
52
+ let trace;
53
+ try {
54
+ trace = await this.provider.getTransactionTrace(event.txHash);
55
+ }
56
+ catch (e) {
57
+ this.logger.warn("getSwapDataGetter(): getter: starknet_traceTransaction not supported by the RPC: ", e);
58
+ const blockTraces = await this.provider.getBlockTransactionsTraces(event.blockHash);
59
+ trace = blockTraces.find(val => (0, Utils_1.toHex)(val.transaction_hash) === (0, Utils_1.toHex)(event.txHash));
60
+ if (trace == null)
61
+ throw new Error(`Cannot find ${event.txHash} in the block traces, block: ${event.blockHash}`);
62
+ }
53
63
  if (trace == null)
54
64
  return null;
55
65
  if (trace.execute_invocation.revert_reason != null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-starknet",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -100,7 +100,15 @@ export class StarknetChainEventsBrowser implements ChainEvents<StarknetSwapData>
100
100
  claimHandler: IClaimHandler<any, any>
101
101
  ): () => Promise<StarknetSwapData> {
102
102
  return async () => {
103
- const trace: any = await this.provider.getTransactionTrace(event.txHash);
103
+ let trace: any;
104
+ try {
105
+ trace = await this.provider.getTransactionTrace(event.txHash);
106
+ } catch (e) {
107
+ this.logger.warn("getSwapDataGetter(): getter: starknet_traceTransaction not supported by the RPC: ", e);
108
+ const blockTraces: any[] = await this.provider.getBlockTransactionsTraces(event.blockHash);
109
+ trace = blockTraces.find(val => toHex(val.transaction_hash)===toHex(event.txHash));
110
+ if(trace==null) throw new Error(`Cannot find ${event.txHash} in the block traces, block: ${event.blockHash}`);
111
+ }
104
112
  if(trace==null) return null;
105
113
  if(trace.execute_invocation.revert_reason!=null) return null;
106
114
  return this.findInitSwapData(trace.execute_invocation as any, event.params.escrow_hash, claimHandler);