@hyperbridge/sdk 2.8.12 → 2.8.13
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/browser/index.d.ts +61 -2
- package/dist/browser/index.js +133 -22
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +134 -20
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +133 -22
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-C9PJp8rx.d.cts → intents-helpers-fntBuoYM.d.cts} +61 -2
- package/dist/node/{intents-helpers-C9PJp8rx.d.ts → intents-helpers-fntBuoYM.d.ts} +61 -2
- package/dist/node/intents-helpers.cjs +135 -21
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +1 -1
- package/dist/node/intents-helpers.d.ts +1 -1
- package/dist/node/intents-helpers.js +134 -23
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -20606,8 +20606,67 @@ async function rpcCall(url, payload) {
|
|
|
20606
20606
|
var FILL_ORDER_ABI = IntentGatewayV2_default.ABI;
|
|
20607
20607
|
var DECLARATION_V1 = 1;
|
|
20608
20608
|
var DECLARATION_V2 = 2;
|
|
20609
|
+
var PAYMASTER_ADDRESS_BYTES = 20;
|
|
20610
|
+
var PAYMASTER_GAS_LIMIT_BYTES = 16;
|
|
20611
|
+
var PAYMASTER_DATA_OFFSET = PAYMASTER_ADDRESS_BYTES + 2 * PAYMASTER_GAS_LIMIT_BYTES;
|
|
20612
|
+
var SIMPLEX_MODE_PERMIT2 = 2;
|
|
20613
|
+
var PERMIT2_DATA_BYTES = 1 + 20 + 32 + 32 + 32 + 1 + 32 + 32;
|
|
20614
|
+
var PERMIT2_SPONSORSHIP_BYTES = PAYMASTER_DATA_OFFSET + PERMIT2_DATA_BYTES;
|
|
20609
20615
|
var MAX_DECLARED_ENTRIES = 255;
|
|
20610
20616
|
var MAX_TOKEN_ID_BYTES = 32;
|
|
20617
|
+
function utf8Encode(text) {
|
|
20618
|
+
const bytes = [];
|
|
20619
|
+
for (const char of text) {
|
|
20620
|
+
const codePoint = char.codePointAt(0);
|
|
20621
|
+
if (codePoint < 128) bytes.push(codePoint);
|
|
20622
|
+
else if (codePoint < 2048) bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
|
|
20623
|
+
else if (codePoint < 65536) {
|
|
20624
|
+
bytes.push(224 | codePoint >> 12, 128 | codePoint >> 6 & 63, 128 | codePoint & 63);
|
|
20625
|
+
} else {
|
|
20626
|
+
bytes.push(
|
|
20627
|
+
240 | codePoint >> 18,
|
|
20628
|
+
128 | codePoint >> 12 & 63,
|
|
20629
|
+
128 | codePoint >> 6 & 63,
|
|
20630
|
+
128 | codePoint & 63
|
|
20631
|
+
);
|
|
20632
|
+
}
|
|
20633
|
+
}
|
|
20634
|
+
return bytes;
|
|
20635
|
+
}
|
|
20636
|
+
function utf8Decode(bytes) {
|
|
20637
|
+
let text = "";
|
|
20638
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
20639
|
+
const lead = bytes[offset];
|
|
20640
|
+
let codePoint;
|
|
20641
|
+
let continuations;
|
|
20642
|
+
if (lead < 128) {
|
|
20643
|
+
codePoint = lead;
|
|
20644
|
+
continuations = 0;
|
|
20645
|
+
} else if ((lead & 224) === 192) {
|
|
20646
|
+
codePoint = lead & 31;
|
|
20647
|
+
continuations = 1;
|
|
20648
|
+
} else if ((lead & 240) === 224) {
|
|
20649
|
+
codePoint = lead & 15;
|
|
20650
|
+
continuations = 2;
|
|
20651
|
+
} else if ((lead & 248) === 240) {
|
|
20652
|
+
codePoint = lead & 7;
|
|
20653
|
+
continuations = 3;
|
|
20654
|
+
} else {
|
|
20655
|
+
return null;
|
|
20656
|
+
}
|
|
20657
|
+
if (offset + continuations >= bytes.length) return null;
|
|
20658
|
+
for (let index = 1; index <= continuations; index++) {
|
|
20659
|
+
const byte = bytes[offset + index];
|
|
20660
|
+
if ((byte & 192) !== 128) return null;
|
|
20661
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
20662
|
+
}
|
|
20663
|
+
const overlong = continuations === 1 && codePoint < 128 || continuations === 2 && codePoint < 2048 || continuations === 3 && codePoint < 65536;
|
|
20664
|
+
if (overlong || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343) return null;
|
|
20665
|
+
text += String.fromCodePoint(codePoint);
|
|
20666
|
+
offset += continuations + 1;
|
|
20667
|
+
}
|
|
20668
|
+
return text;
|
|
20669
|
+
}
|
|
20611
20670
|
function tokenIdToBytes(tokenId) {
|
|
20612
20671
|
if (tokenId < 0n) throw new Error(`Uniswap V4 tokenId cannot be negative: ${tokenId}`);
|
|
20613
20672
|
const bytes = [];
|
|
@@ -20630,7 +20689,7 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20630
20689
|
const version = positions.length > 0 ? DECLARATION_V2 : DECLARATION_V1;
|
|
20631
20690
|
const bytes = [version, chains2.length];
|
|
20632
20691
|
for (const chain of chains2) {
|
|
20633
|
-
const encoded =
|
|
20692
|
+
const encoded = utf8Encode(chain);
|
|
20634
20693
|
if (encoded.length === 0 || encoded.length > 255) {
|
|
20635
20694
|
throw new Error(`Invalid state machine id in source chain declaration: ${chain}`);
|
|
20636
20695
|
}
|
|
@@ -20648,42 +20707,94 @@ function encodePhantomBidDeclaration(declaration) {
|
|
|
20648
20707
|
}
|
|
20649
20708
|
return util.u8aToHex(new Uint8Array(bytes));
|
|
20650
20709
|
}
|
|
20651
|
-
function
|
|
20652
|
-
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
if (bytes.length < 2) return absent;
|
|
20656
|
-
const version = bytes[0];
|
|
20657
|
-
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return absent;
|
|
20710
|
+
function parseDeclaration(bytes, start) {
|
|
20711
|
+
if (bytes.length - start < 2) return null;
|
|
20712
|
+
const version = bytes[start];
|
|
20713
|
+
if (version !== DECLARATION_V1 && version !== DECLARATION_V2) return null;
|
|
20658
20714
|
const chains2 = [];
|
|
20659
|
-
let offset = 2;
|
|
20660
|
-
for (let entry = 0; entry < bytes[1]; entry++) {
|
|
20661
|
-
if (offset >= bytes.length) return
|
|
20715
|
+
let offset = start + 2;
|
|
20716
|
+
for (let entry = 0; entry < bytes[start + 1]; entry++) {
|
|
20717
|
+
if (offset >= bytes.length) return null;
|
|
20662
20718
|
const length = bytes[offset];
|
|
20663
20719
|
offset += 1;
|
|
20664
|
-
if (length === 0 || offset + length > bytes.length) return
|
|
20665
|
-
|
|
20720
|
+
if (length === 0 || offset + length > bytes.length) return null;
|
|
20721
|
+
const chain = utf8Decode(bytes.subarray(offset, offset + length));
|
|
20722
|
+
if (chain === null) return null;
|
|
20723
|
+
chains2.push(chain);
|
|
20666
20724
|
offset += length;
|
|
20667
20725
|
}
|
|
20668
20726
|
const positions = [];
|
|
20669
20727
|
if (version === DECLARATION_V2) {
|
|
20670
|
-
if (offset >= bytes.length) return
|
|
20728
|
+
if (offset >= bytes.length) return null;
|
|
20671
20729
|
const count = bytes[offset];
|
|
20672
20730
|
offset += 1;
|
|
20673
20731
|
for (let entry = 0; entry < count; entry++) {
|
|
20674
|
-
if (offset >= bytes.length) return
|
|
20732
|
+
if (offset >= bytes.length) return null;
|
|
20675
20733
|
const length = bytes[offset];
|
|
20676
20734
|
offset += 1;
|
|
20677
|
-
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return
|
|
20678
|
-
|
|
20679
|
-
for (const byte of bytes.subarray(offset, offset + length)) tokenId = tokenId << 8n | BigInt(byte);
|
|
20680
|
-
positions.push(tokenId);
|
|
20735
|
+
if (length === 0 || length > MAX_TOKEN_ID_BYTES || offset + length > bytes.length) return null;
|
|
20736
|
+
positions.push(bytesToBigInt3(bytes.subarray(offset, offset + length)));
|
|
20681
20737
|
offset += length;
|
|
20682
20738
|
}
|
|
20683
20739
|
}
|
|
20684
|
-
if (offset !== bytes.length) return
|
|
20740
|
+
if (offset !== bytes.length) return null;
|
|
20685
20741
|
return { acceptedSources: chains2, uniswapV4Positions: positions };
|
|
20686
20742
|
}
|
|
20743
|
+
function bytesToBigInt3(bytes) {
|
|
20744
|
+
let value = 0n;
|
|
20745
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
20746
|
+
return value;
|
|
20747
|
+
}
|
|
20748
|
+
function bytesToAddress(bytes) {
|
|
20749
|
+
return util.u8aToHex(bytes);
|
|
20750
|
+
}
|
|
20751
|
+
function hasPermit2Sponsorship(bytes) {
|
|
20752
|
+
return bytes.length >= PERMIT2_SPONSORSHIP_BYTES && bytes[PAYMASTER_DATA_OFFSET] === SIMPLEX_MODE_PERMIT2;
|
|
20753
|
+
}
|
|
20754
|
+
function parseSponsorship(bytes) {
|
|
20755
|
+
let offset = 0;
|
|
20756
|
+
const take = (length) => {
|
|
20757
|
+
const slice = bytes.subarray(offset, offset + length);
|
|
20758
|
+
offset += length;
|
|
20759
|
+
return slice;
|
|
20760
|
+
};
|
|
20761
|
+
const paymaster = bytesToAddress(take(PAYMASTER_ADDRESS_BYTES));
|
|
20762
|
+
take(2 * PAYMASTER_GAS_LIMIT_BYTES);
|
|
20763
|
+
take(1);
|
|
20764
|
+
const token = bytesToAddress(take(20));
|
|
20765
|
+
const permitAmount = bytesToBigInt3(take(32));
|
|
20766
|
+
const nonce = bytesToBigInt3(take(32));
|
|
20767
|
+
const deadline = bytesToBigInt3(take(32));
|
|
20768
|
+
return { paymaster, token, permitAmount, nonce, deadline };
|
|
20769
|
+
}
|
|
20770
|
+
var absentDeclaration = () => ({ acceptedSources: null, uniswapV4Positions: [] });
|
|
20771
|
+
function decodePhantomBidPaymasterAndData(paymasterAndData) {
|
|
20772
|
+
const none = { mode: "none", declaration: absentDeclaration(), sponsorship: null };
|
|
20773
|
+
if (!paymasterAndData || !util.isHex(paymasterAndData)) return none;
|
|
20774
|
+
const bytes = util.hexToU8a(paymasterAndData);
|
|
20775
|
+
const bare = parseDeclaration(bytes, 0);
|
|
20776
|
+
if (bare) return { mode: "declaration", declaration: bare, sponsorship: null };
|
|
20777
|
+
if (!hasPermit2Sponsorship(bytes)) return none;
|
|
20778
|
+
const sponsorship = parseSponsorship(bytes);
|
|
20779
|
+
const tail = bytes.length > PERMIT2_SPONSORSHIP_BYTES ? parseDeclaration(bytes, PERMIT2_SPONSORSHIP_BYTES) : null;
|
|
20780
|
+
return { mode: "permit2", declaration: tail ?? absentDeclaration(), sponsorship };
|
|
20781
|
+
}
|
|
20782
|
+
function decodePhantomBidDeclaration(paymasterAndData) {
|
|
20783
|
+
return decodePhantomBidPaymasterAndData(paymasterAndData).declaration;
|
|
20784
|
+
}
|
|
20785
|
+
function encodePhantomBidPaymasterAndData(bid) {
|
|
20786
|
+
const declaration = encodePhantomBidDeclaration(bid);
|
|
20787
|
+
const sponsorship = bid.sponsorship;
|
|
20788
|
+
if (!sponsorship || sponsorship === "0x") return declaration;
|
|
20789
|
+
if (!util.isHex(sponsorship)) throw new Error("Phantom bid sponsorship is not hex");
|
|
20790
|
+
const bytes = util.hexToU8a(sponsorship);
|
|
20791
|
+
if (bytes.length !== PERMIT2_SPONSORSHIP_BYTES || !hasPermit2Sponsorship(bytes)) {
|
|
20792
|
+
throw new Error(
|
|
20793
|
+
`Phantom bid sponsorship must be a ${PERMIT2_SPONSORSHIP_BYTES}-byte Permit2-mode paymasterAndData, got ${bytes.length} bytes`
|
|
20794
|
+
);
|
|
20795
|
+
}
|
|
20796
|
+
return `${sponsorship}${declaration.slice(2)}`;
|
|
20797
|
+
}
|
|
20687
20798
|
function encodeAcceptedSourceChains(chains2) {
|
|
20688
20799
|
return encodePhantomBidDeclaration({ acceptedSourceChains: chains2 });
|
|
20689
20800
|
}
|
|
@@ -25229,6 +25340,7 @@ exports.ORDER_V2_PARAM_TYPE = ORDER_V2_PARAM_TYPE;
|
|
|
25229
25340
|
exports.OrderStatus = OrderStatus;
|
|
25230
25341
|
exports.OrderStatusChecker = OrderStatusChecker;
|
|
25231
25342
|
exports.PACKED_USEROP_TYPEHASH = PACKED_USEROP_TYPEHASH;
|
|
25343
|
+
exports.PERMIT2_SPONSORSHIP_BYTES = PERMIT2_SPONSORSHIP_BYTES;
|
|
25232
25344
|
exports.PLACE_ORDER_SELECTOR = PLACE_ORDER_SELECTOR;
|
|
25233
25345
|
exports.PhantomSnapshotUnavailableError = PhantomSnapshotUnavailableError;
|
|
25234
25346
|
exports.PharosChain = PharosChain;
|
|
@@ -25279,6 +25391,7 @@ exports.decodeAcceptedSourceChains = decodeAcceptedSourceChains;
|
|
|
25279
25391
|
exports.decodeERC7821ExecuteBatch = decodeERC7821ExecuteBatch;
|
|
25280
25392
|
exports.decodeFillOrder = decodeFillOrder;
|
|
25281
25393
|
exports.decodePhantomBidDeclaration = decodePhantomBidDeclaration;
|
|
25394
|
+
exports.decodePhantomBidPaymasterAndData = decodePhantomBidPaymasterAndData;
|
|
25282
25395
|
exports.decodeUserOpScale = decodeUserOpScale;
|
|
25283
25396
|
exports.deriveHttpUrl = deriveHttpUrl;
|
|
25284
25397
|
exports.encodeAcceptedSourceChains = encodeAcceptedSourceChains;
|
|
@@ -25286,6 +25399,7 @@ exports.encodeERC7821ExecuteBatch = encodeERC7821ExecuteBatch;
|
|
|
25286
25399
|
exports.encodeFillOrder = encodeFillOrder;
|
|
25287
25400
|
exports.encodeISMPMessage = encodeISMPMessage;
|
|
25288
25401
|
exports.encodePhantomBidDeclaration = encodePhantomBidDeclaration;
|
|
25402
|
+
exports.encodePhantomBidPaymasterAndData = encodePhantomBidPaymasterAndData;
|
|
25289
25403
|
exports.encodeStateMachineId = encodeStateMachineId;
|
|
25290
25404
|
exports.encodeUserOpScale = encodeUserOpScale;
|
|
25291
25405
|
exports.encodeWithdrawalRequest = encodeWithdrawalRequest;
|