starknet 9.1.1 → 9.2.1

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.
package/dist/index.js CHANGED
@@ -72,8 +72,8 @@ __export(index_exports, {
72
72
  ETH_ADDRESS: () => ETH_ADDRESS,
73
73
  ETransactionExecutionStatus: () => ETransactionExecutionStatus,
74
74
  ETransactionStatus: () => ETransactionStatus,
75
- ETransactionVersion: () => ETransactionVersion2,
76
- ETransactionVersion2: () => ETransactionVersion22,
75
+ ETransactionVersion: () => ETransactionVersion,
76
+ ETransactionVersion2: () => ETransactionVersion2,
77
77
  ETransactionVersion3: () => ETransactionVersion3,
78
78
  EntryPointType: () => EntryPointType,
79
79
  EthSigner: () => EthSigner,
@@ -256,11 +256,31 @@ var import_starknet_types_010 = require("@starknet-io/starknet-types-010");
256
256
 
257
257
  // src/types/api/rpc.ts
258
258
  var rpc_exports = {};
259
- __reExport(rpc_exports, require("@starknet-io/starknet-types-09"));
259
+ __reExport(rpc_exports, require("@starknet-io/starknet-types-010"));
260
260
 
261
261
  // src/types/api/index.ts
262
262
  __reExport(api_exports, rpc_exports);
263
263
 
264
+ // src/provider/types/spec.type.ts
265
+ var { ETransactionVersion } = RPCSPEC09;
266
+ var { ETransactionVersion2 } = RPCSPEC09;
267
+ var { ETransactionVersion3 } = RPCSPEC09;
268
+ var { EDataAvailabilityMode } = RPCSPEC010;
269
+ var { EDAMode } = RPCSPEC010;
270
+ function isRPC08Plus_ResourceBounds(entry) {
271
+ return "l1_data_gas" in entry;
272
+ }
273
+ function isRPC08Plus_ResourceBoundsBN(entry) {
274
+ return "l1_data_gas" in entry;
275
+ }
276
+ var { ETransactionStatus } = RPCSPEC010;
277
+ var { ETransactionExecutionStatus } = RPCSPEC010;
278
+ var { ETransactionType: TransactionType } = RPCSPEC09;
279
+ var { EBlockStatus: BlockStatus } = RPCSPEC09;
280
+ var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
281
+ var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
282
+ var { EBlockTag: BlockTag } = RPCSPEC09;
283
+
264
284
  // src/utils/encode.ts
265
285
  var encode_exports = {};
266
286
  __export(encode_exports, {
@@ -491,6 +511,22 @@ var DEFAULT_GLOBAL_CONFIG = {
491
511
  }
492
512
  },
493
513
  defaultTipType: "recommendedTip",
514
+ channelDefaults: {
515
+ options: {
516
+ headers: { "Content-Type": "application/json" },
517
+ blockIdentifier: BlockTag.LATEST,
518
+ retries: 200
519
+ },
520
+ methods: {
521
+ simulateTransaction: {
522
+ skipValidate: true,
523
+ skipFeeCharge: true
524
+ },
525
+ getEstimateFee: {
526
+ skipValidate: true
527
+ }
528
+ }
529
+ },
494
530
  fetch: void 0,
495
531
  websocket: void 0,
496
532
  buffer: void 0,
@@ -535,11 +571,51 @@ var Configuration = class _Configuration {
535
571
  }
536
572
  return _Configuration.instance;
537
573
  }
574
+ /**
575
+ * Get a nested value from an object using a dot-notation path
576
+ * @param obj - The object to traverse
577
+ * @param path - The dot-notation path (e.g., 'a.b.c')
578
+ * @returns The value at the path, or undefined if not found
579
+ */
580
+ getNestedValue(obj, path) {
581
+ const keys = path.split(".");
582
+ return keys.reduce((current, key) => {
583
+ if (current === null || current === void 0) {
584
+ return void 0;
585
+ }
586
+ return current[key];
587
+ }, obj);
588
+ }
589
+ /**
590
+ * Set a nested value in an object using a dot-notation path
591
+ * @param obj - The object to modify
592
+ * @param path - The dot-notation path (e.g., 'a.b.c')
593
+ * @param value - The value to set
594
+ */
595
+ setNestedValue(obj, path, value) {
596
+ const keys = path.split(".");
597
+ const lastKey = keys.pop();
598
+ const target = keys.reduce((current, key) => {
599
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
600
+ current[key] = {};
601
+ }
602
+ return current[key];
603
+ }, obj);
604
+ target[lastKey] = value;
605
+ }
538
606
  get(key, defaultValue) {
607
+ if (key.includes(".")) {
608
+ const value = this.getNestedValue(this.config, key);
609
+ return value ?? defaultValue;
610
+ }
539
611
  return this.config[key] ?? defaultValue;
540
612
  }
541
613
  set(key, value) {
542
- this.config[key] = value;
614
+ if (key.includes(".")) {
615
+ this.setNestedValue(this.config, key, value);
616
+ } else {
617
+ this.config[key] = value;
618
+ }
543
619
  }
544
620
  update(configData) {
545
621
  this.config = {
@@ -708,26 +784,6 @@ var EntryPointType = {
708
784
  CONSTRUCTOR: "CONSTRUCTOR"
709
785
  };
710
786
 
711
- // src/provider/types/spec.type.ts
712
- var { ETransactionVersion: ETransactionVersion2 } = RPCSPEC09;
713
- var { ETransactionVersion2: ETransactionVersion22 } = RPCSPEC09;
714
- var { ETransactionVersion3 } = RPCSPEC09;
715
- var { EDataAvailabilityMode } = RPCSPEC010;
716
- var { EDAMode } = RPCSPEC010;
717
- function isRPC08Plus_ResourceBounds(entry) {
718
- return "l1_data_gas" in entry;
719
- }
720
- function isRPC08Plus_ResourceBoundsBN(entry) {
721
- return "l1_data_gas" in entry;
722
- }
723
- var { ETransactionStatus } = RPCSPEC010;
724
- var { ETransactionExecutionStatus } = RPCSPEC010;
725
- var { ETransactionType: TransactionType } = RPCSPEC09;
726
- var { EBlockStatus: BlockStatus } = RPCSPEC09;
727
- var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
728
- var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
729
- var { EBlockTag: BlockTag } = RPCSPEC09;
730
-
731
787
  // src/types/calldata.ts
732
788
  var ValidateType = {
733
789
  DEPLOY: "DEPLOY",
@@ -5358,8 +5414,8 @@ function computeCompiledClassHashBlake(casm) {
5358
5414
 
5359
5415
  // src/utils/resolve.ts
5360
5416
  function isV3Tx(details) {
5361
- const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5362
- return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5417
+ const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
5418
+ return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
5363
5419
  }
5364
5420
  function isVersion(expected, provided) {
5365
5421
  const expectedParts = expected.split(".");
@@ -5564,10 +5620,10 @@ function toTransactionVersion(defaultVersion, providedVersion) {
5564
5620
  function toFeeVersion(providedVersion) {
5565
5621
  if (!providedVersion) return void 0;
5566
5622
  const version = toHex(providedVersion);
5567
- if (version === ETransactionVersion2.V0) return ETransactionVersion2.F0;
5568
- if (version === ETransactionVersion2.V1) return ETransactionVersion2.F1;
5569
- if (version === ETransactionVersion2.V2) return ETransactionVersion2.F2;
5570
- if (version === ETransactionVersion2.V3) return ETransactionVersion2.F3;
5623
+ if (version === ETransactionVersion.V0) return ETransactionVersion.F0;
5624
+ if (version === ETransactionVersion.V1) return ETransactionVersion.F1;
5625
+ if (version === ETransactionVersion.V2) return ETransactionVersion.F2;
5626
+ if (version === ETransactionVersion.V3) return ETransactionVersion.F3;
5571
5627
  throw Error(`toFeeVersion: ${version} is not supported`);
5572
5628
  }
5573
5629
  function v3Details(details) {
@@ -5891,16 +5947,11 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
5891
5947
  };
5892
5948
  function getVersionsByType(versionType) {
5893
5949
  return versionType === "fee" ? {
5894
- v3: ETransactionVersion2.F3
5895
- } : { v3: ETransactionVersion2.V3 };
5950
+ v3: ETransactionVersion.F3
5951
+ } : { v3: ETransactionVersion.V3 };
5896
5952
  }
5897
5953
 
5898
5954
  // src/channel/rpc_0_9_0.ts
5899
- var defaultOptions = {
5900
- headers: { "Content-Type": "application/json" },
5901
- blockIdentifier: BlockTag.LATEST,
5902
- retries: 200
5903
- };
5904
5955
  var RpcChannel = class {
5905
5956
  id = "RPC090";
5906
5957
  /**
@@ -5950,11 +6001,12 @@ var RpcChannel = class {
5950
6001
  this.channelSpecVersion
5951
6002
  );
5952
6003
  }
6004
+ const channelDefaults = config.get("channelDefaults");
5953
6005
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
5954
- this.blockIdentifier = blockIdentifier ?? defaultOptions.blockIdentifier;
6006
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
5955
6007
  this.chainId = chainId;
5956
- this.headers = { ...defaultOptions.headers, ...headers };
5957
- this.retries = retries ?? defaultOptions.retries;
6008
+ this.headers = { ...channelDefaults.options.headers, ...headers };
6009
+ this.retries = retries ?? channelDefaults.options.retries;
5958
6010
  this.specVersion = specVersion;
5959
6011
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
5960
6012
  this.waitMode = waitMode ?? false;
@@ -6168,14 +6220,16 @@ var RpcChannel = class {
6168
6220
  * @param invocations AccountInvocations
6169
6221
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
6170
6222
  * - blockIdentifier<br/>
6171
- * - skipValidate (default false)<br/>
6223
+ * - skipValidate (default true)<br/>
6172
6224
  * - skipFeeCharge (default true)<br/>
6173
6225
  */
6174
6226
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6227
+ const channelDefaults = config.get("channelDefaults");
6228
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
6175
6229
  const {
6176
6230
  blockIdentifier = this.blockIdentifier,
6177
- skipValidate = true,
6178
- skipFeeCharge = true
6231
+ skipValidate = methodDefaults.skipValidate,
6232
+ skipFeeCharge = methodDefaults.skipFeeCharge
6179
6233
  } = simulateTransactionOptions;
6180
6234
  const block_id = new Block(blockIdentifier).identifier;
6181
6235
  const simulationFlags = [];
@@ -6335,7 +6389,10 @@ var RpcChannel = class {
6335
6389
  contract_address
6336
6390
  });
6337
6391
  }
6338
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6392
+ async getEstimateFee(invocations, options = {}) {
6393
+ const channelDefaults = config.get("channelDefaults");
6394
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6395
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6339
6396
  const block_id = new Block(blockIdentifier).identifier;
6340
6397
  const flags = {
6341
6398
  simulation_flags: skipValidate ? [RPCSPEC09.ESimulationFlag.SKIP_VALIDATE] : []
@@ -6493,11 +6550,6 @@ var rpc_0_10_0_exports = {};
6493
6550
  __export(rpc_0_10_0_exports, {
6494
6551
  RpcChannel: () => RpcChannel2
6495
6552
  });
6496
- var defaultOptions2 = {
6497
- headers: { "Content-Type": "application/json" },
6498
- blockIdentifier: BlockTag.LATEST,
6499
- retries: 200
6500
- };
6501
6553
  var RpcChannel2 = class {
6502
6554
  id = "RPC0.10.0";
6503
6555
  /**
@@ -6547,11 +6599,12 @@ var RpcChannel2 = class {
6547
6599
  this.channelSpecVersion
6548
6600
  );
6549
6601
  }
6602
+ const channelDefaults = config.get("channelDefaults");
6550
6603
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
6551
- this.blockIdentifier = blockIdentifier ?? defaultOptions2.blockIdentifier;
6604
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
6552
6605
  this.chainId = chainId;
6553
- this.headers = { ...defaultOptions2.headers, ...headers };
6554
- this.retries = retries ?? defaultOptions2.retries;
6606
+ this.headers = { ...channelDefaults.options.headers, ...headers };
6607
+ this.retries = retries ?? channelDefaults.options.retries;
6555
6608
  this.specVersion = specVersion;
6556
6609
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
6557
6610
  this.waitMode = waitMode ?? false;
@@ -6765,14 +6818,16 @@ var RpcChannel2 = class {
6765
6818
  * @param invocations AccountInvocations
6766
6819
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
6767
6820
  * - blockIdentifier<br/>
6768
- * - skipValidate (default false)<br/>
6821
+ * - skipValidate (default true)<br/>
6769
6822
  * - skipFeeCharge (default true)<br/>
6770
6823
  */
6771
6824
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6825
+ const channelDefaults = config.get("channelDefaults");
6826
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
6772
6827
  const {
6773
6828
  blockIdentifier = this.blockIdentifier,
6774
- skipValidate = true,
6775
- skipFeeCharge = true
6829
+ skipValidate = methodDefaults.skipValidate,
6830
+ skipFeeCharge = methodDefaults.skipFeeCharge
6776
6831
  } = simulateTransactionOptions;
6777
6832
  const block_id = new Block(blockIdentifier).identifier;
6778
6833
  const simulationFlags = [];
@@ -6932,7 +6987,10 @@ var RpcChannel2 = class {
6932
6987
  contract_address
6933
6988
  });
6934
6989
  }
6935
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6990
+ async getEstimateFee(invocations, options = {}) {
6991
+ const channelDefaults = config.get("channelDefaults");
6992
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6993
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6936
6994
  const block_id = new Block(blockIdentifier).identifier;
6937
6995
  const flags = {
6938
6996
  simulation_flags: skipValidate ? [RPCSPEC010.ESimulationFlag.SKIP_VALIDATE] : []
@@ -7221,7 +7279,7 @@ var Subscription = class {
7221
7279
  }
7222
7280
  };
7223
7281
 
7224
- // src/channel/ws/ws_0_9.ts
7282
+ // src/channel/ws/ws_0_10.ts
7225
7283
  var WebSocketChannel = class {
7226
7284
  /**
7227
7285
  * The URL of the WebSocket RPC Node.
@@ -10889,7 +10947,7 @@ var convertEXECUTION_PARAMETERS = (parameters) => ({
10889
10947
  feeMode: convertFEE_MODE(parameters.fee_mode),
10890
10948
  timeBounds: convertTIME_BOUNDS(parameters.time_bounds)
10891
10949
  });
10892
- var defaultOptions3 = {
10950
+ var defaultOptions = {
10893
10951
  headers: { "Content-Type": "application/json" }
10894
10952
  };
10895
10953
  var PaymasterRpc = class _PaymasterRpc {
@@ -10900,14 +10958,14 @@ var PaymasterRpc = class _PaymasterRpc {
10900
10958
  constructor(options) {
10901
10959
  if (options instanceof _PaymasterRpc) {
10902
10960
  this.nodeUrl = options.nodeUrl;
10903
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10961
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10904
10962
  this.baseFetch = options.baseFetch;
10905
10963
  this.requestId = options.requestId;
10906
10964
  return;
10907
10965
  }
10908
10966
  if (options && "nodeUrl" in options && "headers" in options && "baseFetch" in options) {
10909
10967
  this.nodeUrl = options.nodeUrl ?? getDefaultPaymasterNodeUrl(void 0);
10910
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10968
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10911
10969
  this.baseFetch = options.baseFetch ?? fetch_default;
10912
10970
  this.requestId = 0;
10913
10971
  return;
@@ -10921,7 +10979,7 @@ var PaymasterRpc = class _PaymasterRpc {
10921
10979
  this.nodeUrl = getDefaultPaymasterNodeUrl(void 0, options?.default);
10922
10980
  }
10923
10981
  this.baseFetch = baseFetch ?? fetch_default;
10924
- this.headers = { ...defaultOptions3.headers, ...headers };
10982
+ this.headers = { ...defaultOptions.headers, ...headers };
10925
10983
  this.requestId = 0;
10926
10984
  }
10927
10985
  fetch(method, params, id = 0) {
@@ -12313,7 +12371,10 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12313
12371
  // src/utils/events/index.ts
12314
12372
  var events_exports = {};
12315
12373
  __export(events_exports, {
12374
+ addGetByPathMethod: () => addGetByPathMethod,
12375
+ filterEventsByAddress: () => filterEventsByAddress,
12316
12376
  getAbiEvents: () => getAbiEvents,
12377
+ getEmittedEvents: () => getEmittedEvents,
12317
12378
  isAbiEvent: () => isAbiEvent,
12318
12379
  parseEvents: () => parseEvents
12319
12380
  });
@@ -12387,52 +12448,79 @@ function mergeAbiEvents(target, source) {
12387
12448
  return output;
12388
12449
  }
12389
12450
  function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums, parser) {
12390
- const ret = providerReceivedEvents.flat().reduce((acc, recEvent) => {
12391
- const currentEvent = JSON.parse(JSON.stringify(recEvent));
12392
- let abiEvent = abiEvents[currentEvent.keys.shift() ?? 0];
12451
+ const ret = providerReceivedEvents.reduce((acc, recEvent) => {
12452
+ const eventKeys = [...recEvent.keys];
12453
+ const eventData = [...recEvent.data];
12454
+ let abiEvent = abiEvents[eventKeys.shift() ?? 0];
12393
12455
  if (!abiEvent) {
12394
12456
  return acc;
12395
12457
  }
12396
12458
  while (!abiEvent.name) {
12397
- const hashName = currentEvent.keys.shift();
12459
+ const hashName = eventKeys.shift();
12398
12460
  assert(!!hashName, 'Not enough data in "keys" property of this event.');
12399
12461
  abiEvent = abiEvent[hashName];
12400
12462
  }
12401
- const parsedEvent = {};
12402
- parsedEvent[abiEvent.name] = {};
12403
- const keysIter = currentEvent.keys[Symbol.iterator]();
12404
- const dataIter = currentEvent.data[Symbol.iterator]();
12463
+ const { from_address: _from, keys: _keys, data: _data, ...eventMetadata } = recEvent;
12464
+ const parsedEvent = eventMetadata;
12465
+ const eventName = abiEvent.name;
12466
+ parsedEvent[eventName] = {};
12467
+ const keysIter = eventKeys[Symbol.iterator]();
12468
+ const dataIter = eventData[Symbol.iterator]();
12405
12469
  const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
12406
12470
  const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
12471
+ const parsedEventData = parsedEvent[eventName];
12407
12472
  abiEventKeys.forEach((key) => {
12408
- parsedEvent[abiEvent.name][key.name] = responseParser({
12473
+ parsedEventData[key.name] = responseParser({
12409
12474
  responseIterator: keysIter,
12410
12475
  output: key,
12411
12476
  structs: abiStructs,
12412
12477
  enums: abiEnums,
12413
12478
  parser,
12414
- parsedResult: parsedEvent[abiEvent.name]
12479
+ parsedResult: parsedEventData
12415
12480
  });
12416
12481
  });
12417
12482
  abiEventData.forEach((data) => {
12418
- parsedEvent[abiEvent.name][data.name] = responseParser({
12483
+ parsedEventData[data.name] = responseParser({
12419
12484
  responseIterator: dataIter,
12420
12485
  output: data,
12421
12486
  structs: abiStructs,
12422
12487
  enums: abiEnums,
12423
12488
  parser,
12424
- parsedResult: parsedEvent[abiEvent.name]
12489
+ parsedResult: parsedEventData
12425
12490
  });
12426
12491
  });
12427
- if ("block_hash" in currentEvent) parsedEvent.block_hash = currentEvent.block_hash;
12428
- if ("block_number" in currentEvent) parsedEvent.block_number = currentEvent.block_number;
12429
- if ("transaction_hash" in currentEvent)
12430
- parsedEvent.transaction_hash = currentEvent.transaction_hash;
12431
12492
  acc.push(parsedEvent);
12432
12493
  return acc;
12433
12494
  }, []);
12434
12495
  return ret;
12435
12496
  }
12497
+ function addGetByPathMethod(parsedEvents) {
12498
+ Object.defineProperty(parsedEvents, "getByPath", {
12499
+ value: (path) => {
12500
+ const event = parsedEvents.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
12501
+ const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
12502
+ return eventKey && event ? event[eventKey] : null;
12503
+ },
12504
+ writable: false,
12505
+ enumerable: false,
12506
+ configurable: false
12507
+ });
12508
+ return parsedEvents;
12509
+ }
12510
+ function getEmittedEvents(receipt, contractAddress) {
12511
+ if (!receipt.events) return [];
12512
+ const eventsToEnrich = contractAddress ? filterEventsByAddress(receipt.events, contractAddress) : receipt.events;
12513
+ return eventsToEnrich.map((event) => ({
12514
+ ...event,
12515
+ transaction_hash: receipt.transaction_hash,
12516
+ block_hash: receipt.block_hash,
12517
+ block_number: receipt.block_number
12518
+ }));
12519
+ }
12520
+ function filterEventsByAddress(events, contractAddress) {
12521
+ if (!events) return [];
12522
+ return events.filter((event) => toHex(event.from_address) === toHex(contractAddress));
12523
+ }
12436
12524
 
12437
12525
  // src/contract/default.ts
12438
12526
  function buildCall(contract, functionAbi) {
@@ -12693,45 +12781,19 @@ var Contract = class _Contract {
12693
12781
  calldata
12694
12782
  };
12695
12783
  }
12696
- // TODO: Demistify what is going on here ???
12697
- // TODO: receipt status filtering test and fix this do not look right
12698
12784
  parseEvents(receipt) {
12699
- let parsed = [];
12700
- receipt.match({
12701
- SUCCEEDED: (txR) => {
12702
- const emittedEvents = txR.events?.map((event) => {
12703
- return {
12704
- // TODO: this do not check that block is production and block_hash and block_number actually exists
12705
- // TODO: second issue is that ts do not complains about it
12706
- block_hash: txR.block_hash,
12707
- block_number: txR.block_number,
12708
- transaction_hash: txR.transaction_hash,
12709
- ...event
12710
- };
12711
- }).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
12712
- parsed = parseEvents(
12713
- emittedEvents,
12714
- this.events,
12715
- this.structs,
12716
- CallData.getAbiEnum(this.abi),
12717
- this.callData.parser
12718
- );
12719
- },
12720
- _: () => {
12721
- throw Error("This transaction was not successful.");
12722
- }
12723
- });
12724
- Object.defineProperty(parsed, "getByPath", {
12725
- value: (path) => {
12726
- const event = parsed.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
12727
- const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
12728
- return eventKey && event ? event[eventKey] : null;
12729
- },
12730
- writable: false,
12731
- enumerable: false,
12732
- configurable: false
12733
- });
12734
- return parsed;
12785
+ if (!receipt.isSuccess()) {
12786
+ throw Error("This transaction was not successful.");
12787
+ }
12788
+ return addGetByPathMethod(
12789
+ parseEvents(
12790
+ getEmittedEvents(receipt.value, this.address),
12791
+ this.events,
12792
+ this.structs,
12793
+ CallData.getAbiEnum(this.abi),
12794
+ this.callData.parser
12795
+ )
12796
+ );
12735
12797
  }
12736
12798
  isCairo1() {
12737
12799
  return cairo_exports.isCairo1Abi(this.abi);