@hyperbridge/sdk 1.3.20 → 1.3.21

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.
@@ -1816,6 +1816,13 @@ type IStateMachine = {
1816
1816
  declare const ADDRESS_ZERO: HexString;
1817
1817
  declare const DUMMY_PRIVATE_KEY: HexString;
1818
1818
  declare const DEFAULT_GRAFFITI: HexString;
1819
+ /**
1820
+ * Returns the maximum of two bigint values
1821
+ * @param a - First bigint value
1822
+ * @param b - Second bigint value
1823
+ * @returns The larger of the two values
1824
+ */
1825
+ declare function maxBigInt(a: bigint, b: bigint): bigint;
1819
1826
  /**
1820
1827
  * Calculates the commitment hash for a post request.
1821
1828
  * @param post The post request to calculate the commitment hash for.
@@ -3099,4 +3106,4 @@ declare const coingeckoIds: {
3099
3106
  "EVM-130": string;
3100
3107
  };
3101
3108
 
3102
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
3109
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
@@ -4158,6 +4158,9 @@ var ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
4158
4158
  var MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
4159
4159
  var DUMMY_PRIVATE_KEY = "0x0000000000000000000000000000000000000000000000000000000000000000";
4160
4160
  var DEFAULT_GRAFFITI = "0x0000000000000000000000000000000000000000000000000000000000000000";
4161
+ function maxBigInt(a, b) {
4162
+ return a > b ? a : b;
4163
+ }
4161
4164
  function sleep(ms) {
4162
4165
  return new Promise((resolve) => setTimeout(resolve, ms || DEFAULT_POLL_INTERVAL));
4163
4166
  }
@@ -4516,33 +4519,95 @@ var ERC20Method = /* @__PURE__ */ ((ERC20Method2) => {
4516
4519
  return ERC20Method2;
4517
4520
  })(ERC20Method || {});
4518
4521
  async function getStorageSlot(client, contractAddress, data) {
4519
- const traceCallClient = client.extend((client2) => ({
4520
- async traceCall(args) {
4521
- return client2.request({
4522
- // @ts-ignore
4523
- method: "debug_traceCall",
4524
- // @ts-ignore
4525
- params: [args, "latest", {}]
4526
- });
4522
+ async function tryDefaultTracer() {
4523
+ const traceCallClient = client.extend((client2) => ({
4524
+ async traceCall(args) {
4525
+ return client2.request({
4526
+ // @ts-ignore
4527
+ method: "debug_traceCall",
4528
+ // @ts-ignore
4529
+ params: [args, "latest", {}]
4530
+ });
4531
+ }
4532
+ }));
4533
+ const response = await traceCallClient.traceCall({
4534
+ to: contractAddress,
4535
+ data
4536
+ });
4537
+ const methodSignature = data.slice(0, 10);
4538
+ const logs = response.structLogs;
4539
+ if (!logs || logs.length === 0) {
4540
+ throw new Error("No struct logs found");
4527
4541
  }
4528
- }));
4529
- const response = await traceCallClient.traceCall({
4530
- to: contractAddress,
4531
- data
4532
- });
4533
- const methodSignature = data.slice(0, 10);
4534
- const logs = response.structLogs;
4535
- for (let i = logs.length - 1; i >= 0; i--) {
4536
- const log = logs[i];
4537
- if (log.op === "SLOAD" && log.stack?.length >= 3) {
4538
- const sigHash = log.stack[0];
4539
- const slotHex = log.stack[log.stack.length - 1];
4540
- if (sigHash === methodSignature && slotHex.length === 66) {
4541
- return slotHex;
4542
+ for (let i = logs.length - 1; i >= 0; i--) {
4543
+ const log = logs[i];
4544
+ if (log.op === "SLOAD" && log.stack?.length >= 3) {
4545
+ const sigHash = log.stack[0];
4546
+ const slotHex = log.stack[log.stack.length - 1];
4547
+ if (sigHash === methodSignature && slotHex.length === 66) {
4548
+ return slotHex;
4549
+ }
4550
+ }
4551
+ }
4552
+ throw new Error(`Storage slot not found for data: ${methodSignature}`);
4553
+ }
4554
+ async function tryPrestateTracer() {
4555
+ const traceCallClient = client.extend((client2) => ({
4556
+ async traceCall(args) {
4557
+ return client2.request({
4558
+ // @ts-ignore
4559
+ method: "debug_traceCall",
4560
+ // @ts-ignore
4561
+ params: [
4562
+ // @ts-ignore
4563
+ args,
4564
+ "latest",
4565
+ {
4566
+ // @ts-ignore
4567
+ tracer: "prestateTracer",
4568
+ tracerConfig: {
4569
+ disableCode: true
4570
+ }
4571
+ }
4572
+ ]
4573
+ });
4542
4574
  }
4575
+ }));
4576
+ const response = await traceCallClient.traceCall({
4577
+ to: contractAddress,
4578
+ data
4579
+ });
4580
+ let contractData = response[contractAddress.toLowerCase()];
4581
+ if (!contractData) {
4582
+ const addressKey = Object.keys(response).find(
4583
+ (addr) => addr.toLowerCase() === contractAddress.toLowerCase()
4584
+ );
4585
+ if (addressKey) {
4586
+ contractData = response[addressKey];
4587
+ }
4588
+ }
4589
+ if (!contractData || !contractData.storage) {
4590
+ throw new Error(`No storage access found for contract ${contractAddress} with data: ${data}`);
4591
+ }
4592
+ let storageSlots = Object.keys(contractData.storage);
4593
+ const PROXY_SLOTS = [
4594
+ "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
4595
+ // EIP-1967 implementation
4596
+ "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
4597
+ // EIP-1967 beacon
4598
+ "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50"
4599
+ // EIP-1967 admin
4600
+ ];
4601
+ storageSlots = storageSlots.filter((slot) => !PROXY_SLOTS.includes(slot));
4602
+ if (storageSlots.length === 0) {
4603
+ throw new Error(`No storage slots accessed for contract ${contractAddress} with data: ${data}`);
4604
+ }
4605
+ if (storageSlots.length === 1) {
4606
+ return storageSlots[0];
4543
4607
  }
4608
+ return storageSlots[storageSlots.length - 1];
4544
4609
  }
4545
- throw new Error(`Storage slot not found for data: ${methodSignature}`);
4610
+ return tryDefaultTracer().catch(() => tryPrestateTracer());
4546
4611
  }
4547
4612
  function adjustFeeDecimals(feeInFeeToken, fromDecimals, toDecimals) {
4548
4613
  if (fromDecimals === toDecimals) return feeInFeeToken;
@@ -11732,7 +11797,9 @@ var IntentGateway = class {
11732
11797
  "source",
11733
11798
  order.sourceChain
11734
11799
  );
11735
- const relayerFeeInSourceFeeToken = postGasEstimateInSourceFeeToken + 25n * 10n ** BigInt(sourceChainFeeTokenDecimals - 2);
11800
+ const minRelayerFee = 5n * 10n ** BigInt(sourceChainFeeTokenDecimals - 2);
11801
+ const postGasWithIncentive = postGasEstimateInSourceFeeToken + postGasEstimateInSourceFeeToken * 1n / 100n;
11802
+ const relayerFeeInSourceFeeToken = maxBigInt(postGasWithIncentive, minRelayerFee);
11736
11803
  const relayerFeeInDestFeeToken = adjustFeeDecimals(
11737
11804
  relayerFeeInSourceFeeToken,
11738
11805
  sourceChainFeeTokenDecimals,
@@ -12864,6 +12931,6 @@ async function teleportDot(param_) {
12864
12931
  return stream;
12865
12932
  }
12866
12933
 
12867
- export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
12934
+ export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
12868
12935
  //# sourceMappingURL=index.js.map
12869
12936
  //# sourceMappingURL=index.js.map