@t402/evm 2.0.1 → 2.2.0

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.
@@ -574,6 +574,28 @@ interface BridgeTransaction {
574
574
  /** Destination chain transaction hash (when completed) */
575
575
  dstTxHash?: `0x${string}`;
576
576
  }
577
+ /**
578
+ * Transaction log entry
579
+ */
580
+ interface TransactionLog {
581
+ /** Contract address that emitted the log */
582
+ address: Address;
583
+ /** Indexed event parameters */
584
+ topics: readonly `0x${string}`[];
585
+ /** Non-indexed event data */
586
+ data: `0x${string}`;
587
+ }
588
+ /**
589
+ * Transaction receipt with logs
590
+ */
591
+ interface TransactionReceipt {
592
+ /** Transaction status ("success" or "reverted") */
593
+ status: string;
594
+ /** Transaction hash */
595
+ transactionHash: `0x${string}`;
596
+ /** Event logs emitted during transaction */
597
+ logs: readonly TransactionLog[];
598
+ }
577
599
  /**
578
600
  * Signer interface for bridge operations
579
601
  */
@@ -598,9 +620,7 @@ interface BridgeSigner {
598
620
  /** Wait for transaction receipt */
599
621
  waitForTransactionReceipt(args: {
600
622
  hash: `0x${string}`;
601
- }): Promise<{
602
- status: string;
603
- }>;
623
+ }): Promise<TransactionReceipt>;
604
624
  }
605
625
 
606
626
  /**
@@ -667,6 +687,13 @@ declare class Usdt0Bridge {
667
687
  * @returns Bridge result with transaction hash
668
688
  */
669
689
  send(params: BridgeExecuteParams): Promise<BridgeResult>;
690
+ /**
691
+ * Extract LayerZero message GUID from OFTSent event logs
692
+ *
693
+ * @param receipt - Transaction receipt with logs
694
+ * @returns Message GUID as hex string
695
+ */
696
+ private extractMessageGuid;
670
697
  /**
671
698
  * Ensure sufficient token allowance for the OFT contract
672
699
  */
@@ -494,6 +494,9 @@ function toFacilitatorEvmSigner(client) {
494
494
  };
495
495
  }
496
496
 
497
+ // src/bridge/client.ts
498
+ import { keccak256, toBytes } from "viem";
499
+
497
500
  // src/bridge/constants.ts
498
501
  var LAYERZERO_ENDPOINT_IDS = {
499
502
  // Mainnets
@@ -679,6 +682,9 @@ function bytes32ToAddress(bytes32) {
679
682
  }
680
683
 
681
684
  // src/bridge/client.ts
685
+ var OFT_SENT_EVENT_TOPIC = keccak256(
686
+ toBytes("OFTSent(bytes32,uint32,address,uint256,uint256)")
687
+ );
682
688
  var DEFAULT_SLIPPAGE = 0.5;
683
689
  var ESTIMATED_BRIDGE_TIME = 300;
684
690
  var Usdt0Bridge = class {
@@ -751,10 +757,10 @@ var Usdt0Bridge = class {
751
757
  if (receipt.status !== "success") {
752
758
  throw new Error(`Bridge transaction failed: ${txHash}`);
753
759
  }
760
+ const messageGuid = this.extractMessageGuid(receipt);
754
761
  return {
755
762
  txHash,
756
- messageGuid: "0x" + "0".repeat(64),
757
- // Would be extracted from event logs
763
+ messageGuid,
758
764
  amountSent: params.amount,
759
765
  amountToReceive: sendParam.minAmountLD,
760
766
  fromChain: params.fromChain,
@@ -762,6 +768,22 @@ var Usdt0Bridge = class {
762
768
  estimatedTime: ESTIMATED_BRIDGE_TIME
763
769
  };
764
770
  }
771
+ /**
772
+ * Extract LayerZero message GUID from OFTSent event logs
773
+ *
774
+ * @param receipt - Transaction receipt with logs
775
+ * @returns Message GUID as hex string
776
+ */
777
+ extractMessageGuid(receipt) {
778
+ for (const log of receipt.logs) {
779
+ if (log.topics[0] === OFT_SENT_EVENT_TOPIC && log.topics[1]) {
780
+ return log.topics[1];
781
+ }
782
+ }
783
+ throw new Error(
784
+ "Failed to extract message GUID from transaction logs. The OFTSent event was not found in the transaction receipt."
785
+ );
786
+ }
765
787
  /**
766
788
  * Ensure sufficient token allowance for the OFT contract
767
789
  */
@@ -1586,8 +1608,21 @@ function decodePaymasterAndData(paymasterAndData) {
1586
1608
  };
1587
1609
  }
1588
1610
 
1611
+ // src/erc4337/paymasters/pimlico.ts
1612
+ import { concat as concat3, pad as pad3, toHex as toHex3 } from "viem";
1613
+
1614
+ // src/erc4337/accounts/safe.ts
1615
+ import {
1616
+ encodeFunctionData as encodeFunctionData2,
1617
+ encodeAbiParameters as encodeAbiParameters2,
1618
+ concat as concat4,
1619
+ keccak256 as keccak2563,
1620
+ getContractAddress,
1621
+ hexToBytes
1622
+ } from "viem";
1623
+
1589
1624
  // src/erc4337/t402.ts
1590
- import { encodeFunctionData as encodeFunctionData2 } from "viem";
1625
+ import { encodeFunctionData as encodeFunctionData3 } from "viem";
1591
1626
  var ERC20_TRANSFER_ABI = [
1592
1627
  {
1593
1628
  inputs: [
@@ -1718,7 +1753,7 @@ var GaslessT402Client = class {
1718
1753
  * Build call data for a simple ERC20 transfer
1719
1754
  */
1720
1755
  buildTransferCallData(params) {
1721
- return encodeFunctionData2({
1756
+ return encodeFunctionData3({
1722
1757
  abi: ERC20_TRANSFER_ABI,
1723
1758
  functionName: "transfer",
1724
1759
  args: [params.to, params.amount]
@@ -1735,7 +1770,7 @@ var GaslessT402Client = class {
1735
1770
  const r = `0x${sig.slice(2, 66)}`;
1736
1771
  const s = `0x${sig.slice(66, 130)}`;
1737
1772
  const v = parseInt(sig.slice(130, 132), 16);
1738
- return encodeFunctionData2({
1773
+ return encodeFunctionData3({
1739
1774
  abi: EIP3009_TRANSFER_ABI,
1740
1775
  functionName: "transferWithAuthorization",
1741
1776
  args: [