@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.
- package/dist/cjs/index.d.ts +30 -3
- package/dist/cjs/index.js +41 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +30 -3
- package/dist/esm/index.mjs +40 -5
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
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/cjs/index.js
CHANGED
|
@@ -986,6 +986,9 @@ function toFacilitatorEvmSigner(client) {
|
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
988
|
|
|
989
|
+
// src/bridge/client.ts
|
|
990
|
+
var import_viem5 = require("viem");
|
|
991
|
+
|
|
989
992
|
// src/bridge/constants.ts
|
|
990
993
|
var LAYERZERO_ENDPOINT_IDS = {
|
|
991
994
|
// Mainnets
|
|
@@ -1171,6 +1174,9 @@ function bytes32ToAddress(bytes32) {
|
|
|
1171
1174
|
}
|
|
1172
1175
|
|
|
1173
1176
|
// src/bridge/client.ts
|
|
1177
|
+
var OFT_SENT_EVENT_TOPIC = (0, import_viem5.keccak256)(
|
|
1178
|
+
(0, import_viem5.toBytes)("OFTSent(bytes32,uint32,address,uint256,uint256)")
|
|
1179
|
+
);
|
|
1174
1180
|
var DEFAULT_SLIPPAGE = 0.5;
|
|
1175
1181
|
var ESTIMATED_BRIDGE_TIME = 300;
|
|
1176
1182
|
var Usdt0Bridge = class {
|
|
@@ -1243,10 +1249,10 @@ var Usdt0Bridge = class {
|
|
|
1243
1249
|
if (receipt.status !== "success") {
|
|
1244
1250
|
throw new Error(`Bridge transaction failed: ${txHash}`);
|
|
1245
1251
|
}
|
|
1252
|
+
const messageGuid = this.extractMessageGuid(receipt);
|
|
1246
1253
|
return {
|
|
1247
1254
|
txHash,
|
|
1248
|
-
messageGuid
|
|
1249
|
-
// Would be extracted from event logs
|
|
1255
|
+
messageGuid,
|
|
1250
1256
|
amountSent: params.amount,
|
|
1251
1257
|
amountToReceive: sendParam.minAmountLD,
|
|
1252
1258
|
fromChain: params.fromChain,
|
|
@@ -1254,6 +1260,22 @@ var Usdt0Bridge = class {
|
|
|
1254
1260
|
estimatedTime: ESTIMATED_BRIDGE_TIME
|
|
1255
1261
|
};
|
|
1256
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Extract LayerZero message GUID from OFTSent event logs
|
|
1265
|
+
*
|
|
1266
|
+
* @param receipt - Transaction receipt with logs
|
|
1267
|
+
* @returns Message GUID as hex string
|
|
1268
|
+
*/
|
|
1269
|
+
extractMessageGuid(receipt) {
|
|
1270
|
+
for (const log of receipt.logs) {
|
|
1271
|
+
if (log.topics[0] === OFT_SENT_EVENT_TOPIC && log.topics[1]) {
|
|
1272
|
+
return log.topics[1];
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
throw new Error(
|
|
1276
|
+
"Failed to extract message GUID from transaction logs. The OFTSent event was not found in the transaction receipt."
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1257
1279
|
/**
|
|
1258
1280
|
* Ensure sufficient token allowance for the OFT contract
|
|
1259
1281
|
*/
|
|
@@ -1508,7 +1530,7 @@ function unpackGasFees(packed) {
|
|
|
1508
1530
|
}
|
|
1509
1531
|
|
|
1510
1532
|
// src/erc4337/builder.ts
|
|
1511
|
-
var
|
|
1533
|
+
var import_viem6 = require("viem");
|
|
1512
1534
|
var UserOpBuilder = class {
|
|
1513
1535
|
constructor(options = {}) {
|
|
1514
1536
|
this.entryPoint = options.entryPoint ?? ENTRYPOINT_V07_ADDRESS;
|
|
@@ -1676,11 +1698,11 @@ var UserOpBuilder = class {
|
|
|
1676
1698
|
*/
|
|
1677
1699
|
encodePaymasterData(paymaster) {
|
|
1678
1700
|
const paymasterAddress = paymaster.paymaster;
|
|
1679
|
-
const verificationGas = (0,
|
|
1701
|
+
const verificationGas = (0, import_viem6.pad)((0, import_viem6.toHex)(paymaster.paymasterVerificationGasLimit), {
|
|
1680
1702
|
size: 16
|
|
1681
1703
|
});
|
|
1682
|
-
const postOpGas = (0,
|
|
1683
|
-
return (0,
|
|
1704
|
+
const postOpGas = (0, import_viem6.pad)((0, import_viem6.toHex)(paymaster.paymasterPostOpGasLimit), { size: 16 });
|
|
1705
|
+
return (0, import_viem6.concat)([
|
|
1684
1706
|
paymasterAddress,
|
|
1685
1707
|
verificationGas,
|
|
1686
1708
|
postOpGas,
|
|
@@ -1869,7 +1891,7 @@ function createBundlerClient(config) {
|
|
|
1869
1891
|
}
|
|
1870
1892
|
|
|
1871
1893
|
// src/erc4337/paymaster.ts
|
|
1872
|
-
var
|
|
1894
|
+
var import_viem7 = require("viem");
|
|
1873
1895
|
var PaymasterClient = class {
|
|
1874
1896
|
constructor(config) {
|
|
1875
1897
|
this.config = config;
|
|
@@ -2053,10 +2075,10 @@ function createPaymasterClient(config) {
|
|
|
2053
2075
|
return new PaymasterClient(config);
|
|
2054
2076
|
}
|
|
2055
2077
|
function encodePaymasterAndData(data) {
|
|
2056
|
-
return (0,
|
|
2078
|
+
return (0, import_viem7.concat)([
|
|
2057
2079
|
data.paymaster,
|
|
2058
|
-
(0,
|
|
2059
|
-
(0,
|
|
2080
|
+
(0, import_viem7.pad)((0, import_viem7.toHex)(data.paymasterVerificationGasLimit), { size: 16 }),
|
|
2081
|
+
(0, import_viem7.pad)((0, import_viem7.toHex)(data.paymasterPostOpGasLimit), { size: 16 }),
|
|
2060
2082
|
data.paymasterData
|
|
2061
2083
|
]);
|
|
2062
2084
|
}
|
|
@@ -2078,8 +2100,14 @@ function decodePaymasterAndData(paymasterAndData) {
|
|
|
2078
2100
|
};
|
|
2079
2101
|
}
|
|
2080
2102
|
|
|
2103
|
+
// src/erc4337/paymasters/pimlico.ts
|
|
2104
|
+
var import_viem8 = require("viem");
|
|
2105
|
+
|
|
2106
|
+
// src/erc4337/accounts/safe.ts
|
|
2107
|
+
var import_viem9 = require("viem");
|
|
2108
|
+
|
|
2081
2109
|
// src/erc4337/t402.ts
|
|
2082
|
-
var
|
|
2110
|
+
var import_viem10 = require("viem");
|
|
2083
2111
|
var ERC20_TRANSFER_ABI = [
|
|
2084
2112
|
{
|
|
2085
2113
|
inputs: [
|
|
@@ -2210,7 +2238,7 @@ var GaslessT402Client = class {
|
|
|
2210
2238
|
* Build call data for a simple ERC20 transfer
|
|
2211
2239
|
*/
|
|
2212
2240
|
buildTransferCallData(params) {
|
|
2213
|
-
return (0,
|
|
2241
|
+
return (0, import_viem10.encodeFunctionData)({
|
|
2214
2242
|
abi: ERC20_TRANSFER_ABI,
|
|
2215
2243
|
functionName: "transfer",
|
|
2216
2244
|
args: [params.to, params.amount]
|
|
@@ -2227,7 +2255,7 @@ var GaslessT402Client = class {
|
|
|
2227
2255
|
const r = `0x${sig.slice(2, 66)}`;
|
|
2228
2256
|
const s = `0x${sig.slice(66, 130)}`;
|
|
2229
2257
|
const v = parseInt(sig.slice(130, 132), 16);
|
|
2230
|
-
return (0,
|
|
2258
|
+
return (0, import_viem10.encodeFunctionData)({
|
|
2231
2259
|
abi: EIP3009_TRANSFER_ABI,
|
|
2232
2260
|
functionName: "transferWithAuthorization",
|
|
2233
2261
|
args: [
|