@atomiqlabs/chain-starknet 5.1.2 → 5.1.4

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,18 @@ 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
+ const foundTrace = blockTraces.find(val => (0, Utils_1.toHex)(val.transaction_hash) === (0, Utils_1.toHex)(event.txHash));
60
+ if (foundTrace == null)
61
+ throw new Error(`Cannot find ${event.txHash} in the block traces, block: ${event.blockHash}`);
62
+ trace = foundTrace.trace_root;
63
+ }
53
64
  if (trace == null)
54
65
  return null;
55
66
  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.4",
4
4
  "description": "Starknet specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -100,7 +100,16 @@ 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
+ const foundTrace = blockTraces.find(val => toHex(val.transaction_hash)===toHex(event.txHash));
110
+ if(foundTrace==null) throw new Error(`Cannot find ${event.txHash} in the block traces, block: ${event.blockHash}`);
111
+ trace = foundTrace.trace_root;
112
+ }
104
113
  if(trace==null) return null;
105
114
  if(trace.execute_invocation.revert_reason!=null) return null;
106
115
  return this.findInitSwapData(trace.execute_invocation as any, event.params.escrow_hash, claimHandler);