@t402/evm 2.1.0 → 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.
- package/dist/cjs/index.d.ts +30 -3
- package/dist/cjs/index.js +37 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +30 -3
- package/dist/esm/index.mjs +25 -3
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.d.mts
CHANGED
|
@@ -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
|
*/
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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
|
|
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
|
*/
|
|
@@ -1594,7 +1616,7 @@ import {
|
|
|
1594
1616
|
encodeFunctionData as encodeFunctionData2,
|
|
1595
1617
|
encodeAbiParameters as encodeAbiParameters2,
|
|
1596
1618
|
concat as concat4,
|
|
1597
|
-
keccak256 as
|
|
1619
|
+
keccak256 as keccak2563,
|
|
1598
1620
|
getContractAddress,
|
|
1599
1621
|
hexToBytes
|
|
1600
1622
|
} from "viem";
|