@metamask/transaction-pay-controller 22.6.3 → 22.8.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/CHANGELOG.md +27 -1
- package/dist/TransactionPayController-method-action-types.cjs.map +1 -1
- package/dist/TransactionPayController-method-action-types.d.cts +15 -1
- package/dist/TransactionPayController-method-action-types.d.cts.map +1 -1
- package/dist/TransactionPayController-method-action-types.d.mts +15 -1
- package/dist/TransactionPayController-method-action-types.d.mts.map +1 -1
- package/dist/TransactionPayController-method-action-types.mjs.map +1 -1
- package/dist/TransactionPayController.cjs +21 -3
- package/dist/TransactionPayController.cjs.map +1 -1
- package/dist/TransactionPayController.d.cts +13 -2
- package/dist/TransactionPayController.d.cts.map +1 -1
- package/dist/TransactionPayController.d.mts +13 -2
- package/dist/TransactionPayController.d.mts.map +1 -1
- package/dist/TransactionPayController.mjs +21 -3
- package/dist/TransactionPayController.mjs.map +1 -1
- package/dist/constants.cjs +8 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +6 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +6 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +7 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/strategy/relay/relay-quotes.cjs +20 -3
- package/dist/strategy/relay/relay-quotes.cjs.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.cts.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.mts.map +1 -1
- package/dist/strategy/relay/relay-quotes.mjs +20 -3
- package/dist/strategy/relay/relay-quotes.mjs.map +1 -1
- package/dist/strategy/relay/relay-submit.cjs +24 -11
- package/dist/strategy/relay/relay-submit.cjs.map +1 -1
- package/dist/strategy/relay/relay-submit.mjs +24 -11
- package/dist/strategy/relay/relay-submit.mjs.map +1 -1
- package/dist/strategy/server/ServerStrategy.cjs +35 -0
- package/dist/strategy/server/ServerStrategy.cjs.map +1 -0
- package/dist/strategy/server/ServerStrategy.d.cts +15 -0
- package/dist/strategy/server/ServerStrategy.d.cts.map +1 -0
- package/dist/strategy/server/ServerStrategy.d.mts +15 -0
- package/dist/strategy/server/ServerStrategy.d.mts.map +1 -0
- package/dist/strategy/server/ServerStrategy.mjs +31 -0
- package/dist/strategy/server/ServerStrategy.mjs.map +1 -0
- package/dist/strategy/server/constants.cjs +11 -0
- package/dist/strategy/server/constants.cjs.map +1 -0
- package/dist/strategy/server/constants.d.cts +8 -0
- package/dist/strategy/server/constants.d.cts.map +1 -0
- package/dist/strategy/server/constants.d.mts +8 -0
- package/dist/strategy/server/constants.d.mts.map +1 -0
- package/dist/strategy/server/constants.mjs +8 -0
- package/dist/strategy/server/constants.mjs.map +1 -0
- package/dist/strategy/server/perps.cjs +71 -0
- package/dist/strategy/server/perps.cjs.map +1 -0
- package/dist/strategy/server/perps.d.cts +36 -0
- package/dist/strategy/server/perps.d.cts.map +1 -0
- package/dist/strategy/server/perps.d.mts +36 -0
- package/dist/strategy/server/perps.d.mts.map +1 -0
- package/dist/strategy/server/perps.mjs +66 -0
- package/dist/strategy/server/perps.mjs.map +1 -0
- package/dist/strategy/server/server-api.cjs +98 -0
- package/dist/strategy/server/server-api.cjs.map +1 -0
- package/dist/strategy/server/server-api.d.cts +35 -0
- package/dist/strategy/server/server-api.d.cts.map +1 -0
- package/dist/strategy/server/server-api.d.mts +35 -0
- package/dist/strategy/server/server-api.d.mts.map +1 -0
- package/dist/strategy/server/server-api.mjs +92 -0
- package/dist/strategy/server/server-api.mjs.map +1 -0
- package/dist/strategy/server/server-quotes.cjs +315 -0
- package/dist/strategy/server/server-quotes.cjs.map +1 -0
- package/dist/strategy/server/server-quotes.d.cts +10 -0
- package/dist/strategy/server/server-quotes.d.cts.map +1 -0
- package/dist/strategy/server/server-quotes.d.mts +10 -0
- package/dist/strategy/server/server-quotes.d.mts.map +1 -0
- package/dist/strategy/server/server-quotes.mjs +311 -0
- package/dist/strategy/server/server-quotes.mjs.map +1 -0
- package/dist/strategy/server/server-submit.cjs +296 -0
- package/dist/strategy/server/server-submit.cjs.map +1 -0
- package/dist/strategy/server/server-submit.d.cts +13 -0
- package/dist/strategy/server/server-submit.d.cts.map +1 -0
- package/dist/strategy/server/server-submit.d.mts +13 -0
- package/dist/strategy/server/server-submit.d.mts.map +1 -0
- package/dist/strategy/server/server-submit.mjs +292 -0
- package/dist/strategy/server/server-submit.mjs.map +1 -0
- package/dist/strategy/server/types.cjs +26 -0
- package/dist/strategy/server/types.cjs.map +1 -0
- package/dist/strategy/server/types.d.cts +153 -0
- package/dist/strategy/server/types.d.cts.map +1 -0
- package/dist/strategy/server/types.d.mts +153 -0
- package/dist/strategy/server/types.d.mts.map +1 -0
- package/dist/strategy/server/types.mjs +23 -0
- package/dist/strategy/server/types.mjs.map +1 -0
- package/dist/tests/messenger-mock.cjs +3 -0
- package/dist/tests/messenger-mock.cjs.map +1 -1
- package/dist/tests/messenger-mock.d.cts +255 -3
- package/dist/tests/messenger-mock.d.cts.map +1 -1
- package/dist/tests/messenger-mock.d.mts +255 -3
- package/dist/tests/messenger-mock.d.mts.map +1 -1
- package/dist/tests/messenger-mock.mjs +3 -0
- package/dist/tests/messenger-mock.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +44 -14
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +44 -14
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.cjs +43 -3
- package/dist/utils/feature-flags.cjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +21 -0
- package/dist/utils/feature-flags.d.cts.map +1 -1
- package/dist/utils/feature-flags.d.mts +21 -0
- package/dist/utils/feature-flags.d.mts.map +1 -1
- package/dist/utils/feature-flags.mjs +40 -2
- package/dist/utils/feature-flags.mjs.map +1 -1
- package/dist/utils/gas.cjs +11 -10
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +12 -0
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +12 -0
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +10 -10
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/quotes.cjs +9 -3
- package/dist/utils/quotes.cjs.map +1 -1
- package/dist/utils/quotes.d.cts.map +1 -1
- package/dist/utils/quotes.d.mts.map +1 -1
- package/dist/utils/quotes.mjs +10 -4
- package/dist/utils/quotes.mjs.map +1 -1
- package/dist/utils/strategy.cjs +3 -0
- package/dist/utils/strategy.cjs.map +1 -1
- package/dist/utils/strategy.d.cts.map +1 -1
- package/dist/utils/strategy.d.mts.map +1 -1
- package/dist/utils/strategy.mjs +3 -0
- package/dist/utils/strategy.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PayStrategy, PayStrategyExecuteRequest, PayStrategyGetQuotesRequest, TransactionPayQuote } from "../../types.mjs";
|
|
2
|
+
import type { ServerQuote } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Pay strategy that routes quote, submit, and status requests through the
|
|
5
|
+
* MetaMask intents API. Supports both gasless (delegated server-execute) and
|
|
6
|
+
* non-gasless (TransactionController-submitted) execution paths. Gated by the
|
|
7
|
+
* `payStrategies.server.enabled` remote feature flag.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ServerStrategy implements PayStrategy<ServerQuote> {
|
|
10
|
+
supports(request: PayStrategyGetQuotesRequest): boolean;
|
|
11
|
+
getQuotes(request: PayStrategyGetQuotesRequest): Promise<TransactionPayQuote<ServerQuote>[]>;
|
|
12
|
+
getBatchTransactions(): Promise<[]>;
|
|
13
|
+
execute(request: PayStrategyExecuteRequest<ServerQuote>): ReturnType<PayStrategy<ServerQuote>['execute']>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ServerStrategy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerStrategy.d.mts","sourceRoot":"","sources":["../../../src/strategy/server/ServerStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACpB,wBAAoB;AAIrB,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAgB;AAE3C;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,WAAW,CAAC,WAAW,CAAC;IAC7D,QAAQ,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO;IAKjD,SAAS,CACb,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;IAIxC,oBAAoB,IAAI,OAAO,CAAC,EAAE,CAAC;IAInC,OAAO,CACX,OAAO,EAAE,yBAAyB,CAAC,WAAW,CAAC,GAC9C,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC;CAQnD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getPayStrategiesConfig } from "../../utils/feature-flags.mjs";
|
|
2
|
+
import { getServerQuotes } from "./server-quotes.mjs";
|
|
3
|
+
import { submitServerQuotes } from "./server-submit.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Pay strategy that routes quote, submit, and status requests through the
|
|
6
|
+
* MetaMask intents API. Supports both gasless (delegated server-execute) and
|
|
7
|
+
* non-gasless (TransactionController-submitted) execution paths. Gated by the
|
|
8
|
+
* `payStrategies.server.enabled` remote feature flag.
|
|
9
|
+
*/
|
|
10
|
+
export class ServerStrategy {
|
|
11
|
+
supports(request) {
|
|
12
|
+
const config = getPayStrategiesConfig(request.messenger);
|
|
13
|
+
return config.server.enabled;
|
|
14
|
+
}
|
|
15
|
+
async getQuotes(request) {
|
|
16
|
+
return getServerQuotes(request);
|
|
17
|
+
}
|
|
18
|
+
async getBatchTransactions() {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
async execute(request) {
|
|
22
|
+
try {
|
|
23
|
+
return await submitServerQuotes(request);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
throw new Error(`Server submit: ${message}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ServerStrategy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerStrategy.mjs","sourceRoot":"","sources":["../../../src/strategy/server/ServerStrategy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AACnE,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAClD,OAAO,EAAE,kBAAkB,EAAE,4BAAwB;AAGrD;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACzB,QAAQ,CAAC,OAAoC;QAC3C,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CACb,OAAoC;QAEpC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,OAAO,CACX,OAA+C;QAE/C,IAAI,CAAC;YACH,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF","sourcesContent":["import type {\n PayStrategy,\n PayStrategyExecuteRequest,\n PayStrategyGetQuotesRequest,\n TransactionPayQuote,\n} from '../../types';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags';\nimport { getServerQuotes } from './server-quotes';\nimport { submitServerQuotes } from './server-submit';\nimport type { ServerQuote } from './types';\n\n/**\n * Pay strategy that routes quote, submit, and status requests through the\n * MetaMask intents API. Supports both gasless (delegated server-execute) and\n * non-gasless (TransactionController-submitted) execution paths. Gated by the\n * `payStrategies.server.enabled` remote feature flag.\n */\nexport class ServerStrategy implements PayStrategy<ServerQuote> {\n supports(request: PayStrategyGetQuotesRequest): boolean {\n const config = getPayStrategiesConfig(request.messenger);\n return config.server.enabled;\n }\n\n async getQuotes(\n request: PayStrategyGetQuotesRequest,\n ): Promise<TransactionPayQuote<ServerQuote>[]> {\n return getServerQuotes(request);\n }\n\n async getBatchTransactions(): Promise<[]> {\n return [];\n }\n\n async execute(\n request: PayStrategyExecuteRequest<ServerQuote>,\n ): ReturnType<PayStrategy<ServerQuote>['execute']> {\n try {\n return await submitServerQuotes(request);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Server submit: ${message}`);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVER_POLLING_INTERVAL = exports.SERVER_URL_BASE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default base URL for the server intents API.
|
|
6
|
+
* Override via `payStrategies.server.baseUrl` remote feature flag.
|
|
7
|
+
*/
|
|
8
|
+
exports.SERVER_URL_BASE = 'https://intents.api.cx.metamask.io';
|
|
9
|
+
/** Polling interval in milliseconds. */
|
|
10
|
+
exports.SERVER_POLLING_INTERVAL = 2000;
|
|
11
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/strategy/server/constants.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,eAAe,GAAG,oCAAoC,CAAC;AAEpE,wCAAwC;AAC3B,QAAA,uBAAuB,GAAG,IAAI,CAAC","sourcesContent":["/**\n * Default base URL for the server intents API.\n * Override via `payStrategies.server.baseUrl` remote feature flag.\n */\nexport const SERVER_URL_BASE = 'https://intents.api.cx.metamask.io';\n\n/** Polling interval in milliseconds. */\nexport const SERVER_POLLING_INTERVAL = 2000;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default base URL for the server intents API.
|
|
3
|
+
* Override via `payStrategies.server.baseUrl` remote feature flag.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SERVER_URL_BASE = "https://intents.api.cx.metamask.io";
|
|
6
|
+
/** Polling interval in milliseconds. */
|
|
7
|
+
export declare const SERVER_POLLING_INTERVAL = 2000;
|
|
8
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/strategy/server/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,uCAAuC,CAAC;AAEpE,wCAAwC;AACxC,eAAO,MAAM,uBAAuB,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default base URL for the server intents API.
|
|
3
|
+
* Override via `payStrategies.server.baseUrl` remote feature flag.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SERVER_URL_BASE = "https://intents.api.cx.metamask.io";
|
|
6
|
+
/** Polling interval in milliseconds. */
|
|
7
|
+
export declare const SERVER_POLLING_INTERVAL = 2000;
|
|
8
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/strategy/server/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,uCAAuC,CAAC;AAEpE,wCAAwC;AACxC,eAAO,MAAM,uBAAuB,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default base URL for the server intents API.
|
|
3
|
+
* Override via `payStrategies.server.baseUrl` remote feature flag.
|
|
4
|
+
*/
|
|
5
|
+
export const SERVER_URL_BASE = 'https://intents.api.cx.metamask.io';
|
|
6
|
+
/** Polling interval in milliseconds. */
|
|
7
|
+
export const SERVER_POLLING_INTERVAL = 2000;
|
|
8
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/strategy/server/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAEpE,wCAAwC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC","sourcesContent":["/**\n * Default base URL for the server intents API.\n * Override via `payStrategies.server.baseUrl` remote feature flag.\n */\nexport const SERVER_URL_BASE = 'https://intents.api.cx.metamask.io';\n\n/** Polling interval in milliseconds. */\nexport const SERVER_POLLING_INTERVAL = 2000;\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeServerPerpsRequest = exports.isServerPerpsDepositRequest = exports.SERVER_HYPERCORE_USDC_PERPS_ADDRESS = void 0;
|
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
const constants_1 = require("../../constants.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Shared 20-byte sentinel address emitted by the server strategy to flag a
|
|
8
|
+
* Hyperliquid perps deposit. Backend providers translate this to their own
|
|
9
|
+
* on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's
|
|
10
|
+
* native USDC-PERPS token at the same address).
|
|
11
|
+
*/
|
|
12
|
+
exports.SERVER_HYPERCORE_USDC_PERPS_ADDRESS = '0x2100000000000000000000000000000000000000';
|
|
13
|
+
const HYPERLIQUID_BRIDGE_ADDRESS_LOWER = '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7';
|
|
14
|
+
const HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT = HYPERLIQUID_BRIDGE_ADDRESS_LOWER.slice(2);
|
|
15
|
+
/**
|
|
16
|
+
* Detect whether a quote request represents a Hyperliquid perps deposit by
|
|
17
|
+
* sniffing the parent transaction calldata for a reference to the Hyperliquid
|
|
18
|
+
* bridge contract. Transaction type is intentionally NOT consulted so that any
|
|
19
|
+
* caller funnelling a bridge deposit through Pay is supported.
|
|
20
|
+
*
|
|
21
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
22
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
23
|
+
* @returns Whether the request matches a Hyperliquid bridge deposit.
|
|
24
|
+
*/
|
|
25
|
+
function isServerPerpsDepositRequest(request, transaction) {
|
|
26
|
+
if (request.isPostQuote === true ||
|
|
27
|
+
request.targetChainId !== constants_1.CHAIN_ID_ARBITRUM ||
|
|
28
|
+
request.targetTokenAddress.toLowerCase() !==
|
|
29
|
+
constants_1.ARBITRUM_USDC_ADDRESS.toLowerCase()) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return transactionDataReferencesBridge(transaction);
|
|
33
|
+
}
|
|
34
|
+
exports.isServerPerpsDepositRequest = isServerPerpsDepositRequest;
|
|
35
|
+
/**
|
|
36
|
+
* Translate a Hyperliquid perps-deposit quote request into the HyperCore
|
|
37
|
+
* direct-deposit shape with a provider-agnostic sentinel destination. Backend
|
|
38
|
+
* providers detect the sentinel and rewrite it to their respective on-chain
|
|
39
|
+
* destinations.
|
|
40
|
+
*
|
|
41
|
+
* Transaction pay starts from the parent on-chain asset (Arbitrum USDC,
|
|
42
|
+
* 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is
|
|
43
|
+
* shifted accordingly.
|
|
44
|
+
*
|
|
45
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
46
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
47
|
+
* @returns Normalized request, or the original request if not a perps deposit.
|
|
48
|
+
*/
|
|
49
|
+
function normalizeServerPerpsRequest(request, transaction) {
|
|
50
|
+
if (!isServerPerpsDepositRequest(request, transaction)) {
|
|
51
|
+
return request;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...request,
|
|
55
|
+
targetAmountMinimum: new bignumber_js_1.BigNumber(request.targetAmountMinimum)
|
|
56
|
+
.shiftedBy(constants_1.HYPERCORE_USDC_DECIMALS - constants_1.USDC_DECIMALS)
|
|
57
|
+
.toFixed(0),
|
|
58
|
+
targetChainId: constants_1.CHAIN_ID_HYPERCORE,
|
|
59
|
+
targetTokenAddress: exports.SERVER_HYPERCORE_USDC_PERPS_ADDRESS,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.normalizeServerPerpsRequest = normalizeServerPerpsRequest;
|
|
63
|
+
function transactionDataReferencesBridge(transaction) {
|
|
64
|
+
const fragments = [
|
|
65
|
+
transaction.txParams?.to,
|
|
66
|
+
...(transaction.nestedTransactions ?? []).map((tx) => tx.to),
|
|
67
|
+
];
|
|
68
|
+
return fragments.some((value) => typeof value === 'string' &&
|
|
69
|
+
value.toLowerCase().includes(HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=perps.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perps.cjs","sourceRoot":"","sources":["../../../src/strategy/server/perps.ts"],"names":[],"mappings":";;;AAEA,+CAAyC;AAEzC,mDAMyB;AAGzB;;;;;GAKG;AACU,QAAA,mCAAmC,GAC9C,4CAAmD,CAAC;AAEtD,MAAM,gCAAgC,GACpC,4CAA4C,CAAC;AAE/C,MAAM,oCAAoC,GACxC,gCAAgC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;GASG;AACH,SAAgB,2BAA2B,CACzC,OAGC,EACD,WAAqE;IAErE,IACE,OAAO,CAAC,WAAW,KAAK,IAAI;QAC5B,OAAO,CAAC,aAAa,KAAK,6BAAiB;QAC3C,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE;YACtC,iCAAqB,CAAC,WAAW,EAAE,EACrC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,+BAA+B,CAAC,WAAW,CAAC,CAAC;AACtD,CAAC;AAjBD,kEAiBC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,2BAA2B,CACzC,OAAqB,EACrB,WAAqE;IAErE,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,mBAAmB,EAAE,IAAI,wBAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC;aAC5D,SAAS,CAAC,mCAAuB,GAAG,yBAAa,CAAC;aAClD,OAAO,CAAC,CAAC,CAAC;QACb,aAAa,EAAE,8BAAkB;QACjC,kBAAkB,EAAE,2CAAmC;KACxD,CAAC;AACJ,CAAC;AAhBD,kEAgBC;AAED,SAAS,+BAA+B,CACtC,WAAqE;IAErE,MAAM,SAAS,GAA2B;QACxC,WAAW,CAAC,QAAQ,EAAE,EAAE;QACxB,GAAG,CAAC,WAAW,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KAC7D,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,CACnB,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport {\n ARBITRUM_USDC_ADDRESS,\n CHAIN_ID_ARBITRUM,\n CHAIN_ID_HYPERCORE,\n HYPERCORE_USDC_DECIMALS,\n USDC_DECIMALS,\n} from '../../constants';\nimport type { QuoteRequest } from '../../types';\n\n/**\n * Shared 20-byte sentinel address emitted by the server strategy to flag a\n * Hyperliquid perps deposit. Backend providers translate this to their own\n * on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's\n * native USDC-PERPS token at the same address).\n */\nexport const SERVER_HYPERCORE_USDC_PERPS_ADDRESS =\n '0x2100000000000000000000000000000000000000' as Hex;\n\nconst HYPERLIQUID_BRIDGE_ADDRESS_LOWER =\n '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7';\n\nconst HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT =\n HYPERLIQUID_BRIDGE_ADDRESS_LOWER.slice(2);\n\n/**\n * Detect whether a quote request represents a Hyperliquid perps deposit by\n * sniffing the parent transaction calldata for a reference to the Hyperliquid\n * bridge contract. Transaction type is intentionally NOT consulted so that any\n * caller funnelling a bridge deposit through Pay is supported.\n *\n * @param request - Quote request from the transaction-pay controller.\n * @param transaction - Parent transaction whose calldata is inspected.\n * @returns Whether the request matches a Hyperliquid bridge deposit.\n */\nexport function isServerPerpsDepositRequest(\n request: Pick<\n QuoteRequest,\n 'isPostQuote' | 'targetChainId' | 'targetTokenAddress'\n >,\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): boolean {\n if (\n request.isPostQuote === true ||\n request.targetChainId !== CHAIN_ID_ARBITRUM ||\n request.targetTokenAddress.toLowerCase() !==\n ARBITRUM_USDC_ADDRESS.toLowerCase()\n ) {\n return false;\n }\n\n return transactionDataReferencesBridge(transaction);\n}\n\n/**\n * Translate a Hyperliquid perps-deposit quote request into the HyperCore\n * direct-deposit shape with a provider-agnostic sentinel destination. Backend\n * providers detect the sentinel and rewrite it to their respective on-chain\n * destinations.\n *\n * Transaction pay starts from the parent on-chain asset (Arbitrum USDC,\n * 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is\n * shifted accordingly.\n *\n * @param request - Quote request from the transaction-pay controller.\n * @param transaction - Parent transaction whose calldata is inspected.\n * @returns Normalized request, or the original request if not a perps deposit.\n */\nexport function normalizeServerPerpsRequest(\n request: QuoteRequest,\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): QuoteRequest {\n if (!isServerPerpsDepositRequest(request, transaction)) {\n return request;\n }\n\n return {\n ...request,\n targetAmountMinimum: new BigNumber(request.targetAmountMinimum)\n .shiftedBy(HYPERCORE_USDC_DECIMALS - USDC_DECIMALS)\n .toFixed(0),\n targetChainId: CHAIN_ID_HYPERCORE,\n targetTokenAddress: SERVER_HYPERCORE_USDC_PERPS_ADDRESS,\n };\n}\n\nfunction transactionDataReferencesBridge(\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): boolean {\n const fragments: (string | undefined)[] = [\n transaction.txParams?.to,\n ...(transaction.nestedTransactions ?? []).map((tx) => tx.to),\n ];\n\n return fragments.some(\n (value) =>\n typeof value === 'string' &&\n value.toLowerCase().includes(HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT),\n );\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TransactionMeta } from "@metamask/transaction-controller";
|
|
2
|
+
import type { QuoteRequest } from "../../types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Shared 20-byte sentinel address emitted by the server strategy to flag a
|
|
5
|
+
* Hyperliquid perps deposit. Backend providers translate this to their own
|
|
6
|
+
* on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's
|
|
7
|
+
* native USDC-PERPS token at the same address).
|
|
8
|
+
*/
|
|
9
|
+
export declare const SERVER_HYPERCORE_USDC_PERPS_ADDRESS: `0x${string}`;
|
|
10
|
+
/**
|
|
11
|
+
* Detect whether a quote request represents a Hyperliquid perps deposit by
|
|
12
|
+
* sniffing the parent transaction calldata for a reference to the Hyperliquid
|
|
13
|
+
* bridge contract. Transaction type is intentionally NOT consulted so that any
|
|
14
|
+
* caller funnelling a bridge deposit through Pay is supported.
|
|
15
|
+
*
|
|
16
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
17
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
18
|
+
* @returns Whether the request matches a Hyperliquid bridge deposit.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isServerPerpsDepositRequest(request: Pick<QuoteRequest, 'isPostQuote' | 'targetChainId' | 'targetTokenAddress'>, transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Translate a Hyperliquid perps-deposit quote request into the HyperCore
|
|
23
|
+
* direct-deposit shape with a provider-agnostic sentinel destination. Backend
|
|
24
|
+
* providers detect the sentinel and rewrite it to their respective on-chain
|
|
25
|
+
* destinations.
|
|
26
|
+
*
|
|
27
|
+
* Transaction pay starts from the parent on-chain asset (Arbitrum USDC,
|
|
28
|
+
* 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is
|
|
29
|
+
* shifted accordingly.
|
|
30
|
+
*
|
|
31
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
32
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
33
|
+
* @returns Normalized request, or the original request if not a perps deposit.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeServerPerpsRequest(request: QuoteRequest, transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>): QuoteRequest;
|
|
36
|
+
//# sourceMappingURL=perps.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perps.d.cts","sourceRoot":"","sources":["../../../src/strategy/server/perps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAWxE,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAoB;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,eACK,CAAC;AAQtD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,IAAI,CACX,YAAY,EACZ,aAAa,GAAG,eAAe,GAAG,oBAAoB,CACvD,EACD,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,oBAAoB,CAAC,GACpE,OAAO,CAWT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,oBAAoB,CAAC,GACpE,YAAY,CAad"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TransactionMeta } from "@metamask/transaction-controller";
|
|
2
|
+
import type { QuoteRequest } from "../../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Shared 20-byte sentinel address emitted by the server strategy to flag a
|
|
5
|
+
* Hyperliquid perps deposit. Backend providers translate this to their own
|
|
6
|
+
* on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's
|
|
7
|
+
* native USDC-PERPS token at the same address).
|
|
8
|
+
*/
|
|
9
|
+
export declare const SERVER_HYPERCORE_USDC_PERPS_ADDRESS: `0x${string}`;
|
|
10
|
+
/**
|
|
11
|
+
* Detect whether a quote request represents a Hyperliquid perps deposit by
|
|
12
|
+
* sniffing the parent transaction calldata for a reference to the Hyperliquid
|
|
13
|
+
* bridge contract. Transaction type is intentionally NOT consulted so that any
|
|
14
|
+
* caller funnelling a bridge deposit through Pay is supported.
|
|
15
|
+
*
|
|
16
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
17
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
18
|
+
* @returns Whether the request matches a Hyperliquid bridge deposit.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isServerPerpsDepositRequest(request: Pick<QuoteRequest, 'isPostQuote' | 'targetChainId' | 'targetTokenAddress'>, transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Translate a Hyperliquid perps-deposit quote request into the HyperCore
|
|
23
|
+
* direct-deposit shape with a provider-agnostic sentinel destination. Backend
|
|
24
|
+
* providers detect the sentinel and rewrite it to their respective on-chain
|
|
25
|
+
* destinations.
|
|
26
|
+
*
|
|
27
|
+
* Transaction pay starts from the parent on-chain asset (Arbitrum USDC,
|
|
28
|
+
* 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is
|
|
29
|
+
* shifted accordingly.
|
|
30
|
+
*
|
|
31
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
32
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
33
|
+
* @returns Normalized request, or the original request if not a perps deposit.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeServerPerpsRequest(request: QuoteRequest, transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>): QuoteRequest;
|
|
36
|
+
//# sourceMappingURL=perps.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perps.d.mts","sourceRoot":"","sources":["../../../src/strategy/server/perps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAWxE,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAoB;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,eACK,CAAC;AAQtD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,IAAI,CACX,YAAY,EACZ,aAAa,GAAG,eAAe,GAAG,oBAAoB,CACvD,EACD,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,oBAAoB,CAAC,GACpE,OAAO,CAWT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,oBAAoB,CAAC,GACpE,YAAY,CAad"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { ARBITRUM_USDC_ADDRESS, CHAIN_ID_ARBITRUM, CHAIN_ID_HYPERCORE, HYPERCORE_USDC_DECIMALS, USDC_DECIMALS } from "../../constants.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Shared 20-byte sentinel address emitted by the server strategy to flag a
|
|
5
|
+
* Hyperliquid perps deposit. Backend providers translate this to their own
|
|
6
|
+
* on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's
|
|
7
|
+
* native USDC-PERPS token at the same address).
|
|
8
|
+
*/
|
|
9
|
+
export const SERVER_HYPERCORE_USDC_PERPS_ADDRESS = '0x2100000000000000000000000000000000000000';
|
|
10
|
+
const HYPERLIQUID_BRIDGE_ADDRESS_LOWER = '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7';
|
|
11
|
+
const HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT = HYPERLIQUID_BRIDGE_ADDRESS_LOWER.slice(2);
|
|
12
|
+
/**
|
|
13
|
+
* Detect whether a quote request represents a Hyperliquid perps deposit by
|
|
14
|
+
* sniffing the parent transaction calldata for a reference to the Hyperliquid
|
|
15
|
+
* bridge contract. Transaction type is intentionally NOT consulted so that any
|
|
16
|
+
* caller funnelling a bridge deposit through Pay is supported.
|
|
17
|
+
*
|
|
18
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
19
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
20
|
+
* @returns Whether the request matches a Hyperliquid bridge deposit.
|
|
21
|
+
*/
|
|
22
|
+
export function isServerPerpsDepositRequest(request, transaction) {
|
|
23
|
+
if (request.isPostQuote === true ||
|
|
24
|
+
request.targetChainId !== CHAIN_ID_ARBITRUM ||
|
|
25
|
+
request.targetTokenAddress.toLowerCase() !==
|
|
26
|
+
ARBITRUM_USDC_ADDRESS.toLowerCase()) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return transactionDataReferencesBridge(transaction);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Translate a Hyperliquid perps-deposit quote request into the HyperCore
|
|
33
|
+
* direct-deposit shape with a provider-agnostic sentinel destination. Backend
|
|
34
|
+
* providers detect the sentinel and rewrite it to their respective on-chain
|
|
35
|
+
* destinations.
|
|
36
|
+
*
|
|
37
|
+
* Transaction pay starts from the parent on-chain asset (Arbitrum USDC,
|
|
38
|
+
* 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is
|
|
39
|
+
* shifted accordingly.
|
|
40
|
+
*
|
|
41
|
+
* @param request - Quote request from the transaction-pay controller.
|
|
42
|
+
* @param transaction - Parent transaction whose calldata is inspected.
|
|
43
|
+
* @returns Normalized request, or the original request if not a perps deposit.
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeServerPerpsRequest(request, transaction) {
|
|
46
|
+
if (!isServerPerpsDepositRequest(request, transaction)) {
|
|
47
|
+
return request;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...request,
|
|
51
|
+
targetAmountMinimum: new BigNumber(request.targetAmountMinimum)
|
|
52
|
+
.shiftedBy(HYPERCORE_USDC_DECIMALS - USDC_DECIMALS)
|
|
53
|
+
.toFixed(0),
|
|
54
|
+
targetChainId: CHAIN_ID_HYPERCORE,
|
|
55
|
+
targetTokenAddress: SERVER_HYPERCORE_USDC_PERPS_ADDRESS,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function transactionDataReferencesBridge(transaction) {
|
|
59
|
+
const fragments = [
|
|
60
|
+
transaction.txParams?.to,
|
|
61
|
+
...(transaction.nestedTransactions ?? []).map((tx) => tx.to),
|
|
62
|
+
];
|
|
63
|
+
return fragments.some((value) => typeof value === 'string' &&
|
|
64
|
+
value.toLowerCase().includes(HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=perps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perps.mjs","sourceRoot":"","sources":["../../../src/strategy/server/perps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,aAAa,EACd,4BAAwB;AAGzB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAC9C,4CAAmD,CAAC;AAEtD,MAAM,gCAAgC,GACpC,4CAA4C,CAAC;AAE/C,MAAM,oCAAoC,GACxC,gCAAgC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAGC,EACD,WAAqE;IAErE,IACE,OAAO,CAAC,WAAW,KAAK,IAAI;QAC5B,OAAO,CAAC,aAAa,KAAK,iBAAiB;QAC3C,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE;YACtC,qBAAqB,CAAC,WAAW,EAAE,EACrC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,+BAA+B,CAAC,WAAW,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAqB,EACrB,WAAqE;IAErE,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,mBAAmB,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC;aAC5D,SAAS,CAAC,uBAAuB,GAAG,aAAa,CAAC;aAClD,OAAO,CAAC,CAAC,CAAC;QACb,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,mCAAmC;KACxD,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CACtC,WAAqE;IAErE,MAAM,SAAS,GAA2B;QACxC,WAAW,CAAC,QAAQ,EAAE,EAAE;QACxB,GAAG,CAAC,WAAW,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KAC7D,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,CACnB,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport {\n ARBITRUM_USDC_ADDRESS,\n CHAIN_ID_ARBITRUM,\n CHAIN_ID_HYPERCORE,\n HYPERCORE_USDC_DECIMALS,\n USDC_DECIMALS,\n} from '../../constants';\nimport type { QuoteRequest } from '../../types';\n\n/**\n * Shared 20-byte sentinel address emitted by the server strategy to flag a\n * Hyperliquid perps deposit. Backend providers translate this to their own\n * on-chain destination (e.g. Relay's 16-byte HyperCore USDC sentinel, Across's\n * native USDC-PERPS token at the same address).\n */\nexport const SERVER_HYPERCORE_USDC_PERPS_ADDRESS =\n '0x2100000000000000000000000000000000000000' as Hex;\n\nconst HYPERLIQUID_BRIDGE_ADDRESS_LOWER =\n '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7';\n\nconst HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT =\n HYPERLIQUID_BRIDGE_ADDRESS_LOWER.slice(2);\n\n/**\n * Detect whether a quote request represents a Hyperliquid perps deposit by\n * sniffing the parent transaction calldata for a reference to the Hyperliquid\n * bridge contract. Transaction type is intentionally NOT consulted so that any\n * caller funnelling a bridge deposit through Pay is supported.\n *\n * @param request - Quote request from the transaction-pay controller.\n * @param transaction - Parent transaction whose calldata is inspected.\n * @returns Whether the request matches a Hyperliquid bridge deposit.\n */\nexport function isServerPerpsDepositRequest(\n request: Pick<\n QuoteRequest,\n 'isPostQuote' | 'targetChainId' | 'targetTokenAddress'\n >,\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): boolean {\n if (\n request.isPostQuote === true ||\n request.targetChainId !== CHAIN_ID_ARBITRUM ||\n request.targetTokenAddress.toLowerCase() !==\n ARBITRUM_USDC_ADDRESS.toLowerCase()\n ) {\n return false;\n }\n\n return transactionDataReferencesBridge(transaction);\n}\n\n/**\n * Translate a Hyperliquid perps-deposit quote request into the HyperCore\n * direct-deposit shape with a provider-agnostic sentinel destination. Backend\n * providers detect the sentinel and rewrite it to their respective on-chain\n * destinations.\n *\n * Transaction pay starts from the parent on-chain asset (Arbitrum USDC,\n * 6 decimals); HyperCore expects an 8-decimal amount, so the target amount is\n * shifted accordingly.\n *\n * @param request - Quote request from the transaction-pay controller.\n * @param transaction - Parent transaction whose calldata is inspected.\n * @returns Normalized request, or the original request if not a perps deposit.\n */\nexport function normalizeServerPerpsRequest(\n request: QuoteRequest,\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): QuoteRequest {\n if (!isServerPerpsDepositRequest(request, transaction)) {\n return request;\n }\n\n return {\n ...request,\n targetAmountMinimum: new BigNumber(request.targetAmountMinimum)\n .shiftedBy(HYPERCORE_USDC_DECIMALS - USDC_DECIMALS)\n .toFixed(0),\n targetChainId: CHAIN_ID_HYPERCORE,\n targetTokenAddress: SERVER_HYPERCORE_USDC_PERPS_ADDRESS,\n };\n}\n\nfunction transactionDataReferencesBridge(\n transaction: Pick<TransactionMeta, 'txParams' | 'nestedTransactions'>,\n): boolean {\n const fragments: (string | undefined)[] = [\n transaction.txParams?.to,\n ...(transaction.nestedTransactions ?? []).map((tx) => tx.to),\n ];\n\n return fragments.some(\n (value) =>\n typeof value === 'string' &&\n value.toLowerCase().includes(HYPERLIQUID_BRIDGE_CALLDATA_FRAGMENT),\n );\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServerStatus = exports.submitServerIntent = exports.fetchServerQuote = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
const logger_1 = require("../../logger.cjs");
|
|
6
|
+
const feature_flags_1 = require("../../utils/feature-flags.cjs");
|
|
7
|
+
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'server-api');
|
|
8
|
+
/**
|
|
9
|
+
* Fetch a quote from the server intents API.
|
|
10
|
+
*
|
|
11
|
+
* @param messenger - Controller messenger.
|
|
12
|
+
* @param body - Quote request parameters.
|
|
13
|
+
* @param signal - Optional abort signal that cancels the underlying fetch.
|
|
14
|
+
* @returns The server quote response.
|
|
15
|
+
*/
|
|
16
|
+
async function fetchServerQuote(messenger, body, signal) {
|
|
17
|
+
const { server } = (0, feature_flags_1.getPayStrategiesConfig)(messenger);
|
|
18
|
+
const quoteUrl = `${server.baseUrl}/quote`;
|
|
19
|
+
log('Fetching quote', { url: quoteUrl });
|
|
20
|
+
const response = await serverFetch(quoteUrl, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'Content-Type': 'application/json' },
|
|
23
|
+
body: JSON.stringify(body),
|
|
24
|
+
signal,
|
|
25
|
+
});
|
|
26
|
+
return (await response.json());
|
|
27
|
+
}
|
|
28
|
+
exports.fetchServerQuote = fetchServerQuote;
|
|
29
|
+
/**
|
|
30
|
+
* Submit a gasless intent via the server intents API.
|
|
31
|
+
*
|
|
32
|
+
* @param messenger - Controller messenger.
|
|
33
|
+
* @param body - Submit request parameters.
|
|
34
|
+
* @returns The submit response.
|
|
35
|
+
*/
|
|
36
|
+
async function submitServerIntent(messenger, body) {
|
|
37
|
+
const { server } = (0, feature_flags_1.getPayStrategiesConfig)(messenger);
|
|
38
|
+
const submitUrl = `${server.baseUrl}/submit`;
|
|
39
|
+
log('Submitting intent', { url: submitUrl });
|
|
40
|
+
const response = await serverFetch(submitUrl, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: { 'Content-Type': 'application/json' },
|
|
43
|
+
body: JSON.stringify(body),
|
|
44
|
+
});
|
|
45
|
+
return (await response.json());
|
|
46
|
+
}
|
|
47
|
+
exports.submitServerIntent = submitServerIntent;
|
|
48
|
+
/**
|
|
49
|
+
* Fetch the status of a server intent.
|
|
50
|
+
*
|
|
51
|
+
* @param messenger - Controller messenger.
|
|
52
|
+
* @param params - Status query parameters.
|
|
53
|
+
* @param params.provider - The provider that the intent was submitted to.
|
|
54
|
+
* @param params.id - The intent ID.
|
|
55
|
+
* @param params.hash - Optional transaction hash to include in the status query.
|
|
56
|
+
* @returns The current status of the intent.
|
|
57
|
+
*/
|
|
58
|
+
async function getServerStatus(messenger, params) {
|
|
59
|
+
const { server } = (0, feature_flags_1.getPayStrategiesConfig)(messenger);
|
|
60
|
+
const query = new URLSearchParams({
|
|
61
|
+
provider: params.provider,
|
|
62
|
+
id: params.id,
|
|
63
|
+
});
|
|
64
|
+
if (params.hash) {
|
|
65
|
+
query.set('hash', params.hash);
|
|
66
|
+
}
|
|
67
|
+
const url = `${server.baseUrl}/status?${query.toString()}`;
|
|
68
|
+
log('Fetching status', { url });
|
|
69
|
+
const response = await serverFetch(url, { method: 'GET' });
|
|
70
|
+
return (await response.json());
|
|
71
|
+
}
|
|
72
|
+
exports.getServerStatus = getServerStatus;
|
|
73
|
+
/**
|
|
74
|
+
* Fetch a server intents-api endpoint, throwing an error containing the
|
|
75
|
+
* response body's `message` or `error` field (or status code) on non-OK
|
|
76
|
+
* responses so the server's actual reason is preserved without leaking the
|
|
77
|
+
* request URL.
|
|
78
|
+
*
|
|
79
|
+
* @param url - The endpoint to fetch.
|
|
80
|
+
* @param init - Fetch init options.
|
|
81
|
+
* @returns The successful response.
|
|
82
|
+
*/
|
|
83
|
+
async function serverFetch(url, init) {
|
|
84
|
+
const response = await fetch(url, init);
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
let detail;
|
|
87
|
+
try {
|
|
88
|
+
const body = (await response.json());
|
|
89
|
+
detail = body.message ?? body.error;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Body wasn't JSON; fall through to status-only error.
|
|
93
|
+
}
|
|
94
|
+
throw new Error(detail ? `${response.status} - ${detail}` : String(response.status));
|
|
95
|
+
}
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=server-api.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-api.cjs","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"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","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../../logger';\nimport type { TransactionPayControllerMessenger } from '../../types';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags';\nimport type {\n ServerProviderName,\n ServerQuoteRequest,\n ServerQuoteResponse,\n ServerStatusResponse,\n ServerSubmitRequest,\n ServerSubmitResponse,\n} from './types';\n\nconst log = createModuleLogger(projectLogger, 'server-api');\n\n/**\n * Fetch a quote from the server intents API.\n *\n * @param messenger - Controller messenger.\n * @param body - Quote request parameters.\n * @param signal - Optional abort signal that cancels the underlying fetch.\n * @returns The server quote response.\n */\nexport async function fetchServerQuote(\n messenger: TransactionPayControllerMessenger,\n body: ServerQuoteRequest,\n signal?: AbortSignal,\n): Promise<ServerQuoteResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const quoteUrl = `${server.baseUrl}/quote`;\n\n log('Fetching quote', { url: quoteUrl });\n\n const response = await serverFetch(quoteUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal,\n });\n\n return (await response.json()) as ServerQuoteResponse;\n}\n\n/**\n * Submit a gasless intent via the server intents API.\n *\n * @param messenger - Controller messenger.\n * @param body - Submit request parameters.\n * @returns The submit response.\n */\nexport async function submitServerIntent(\n messenger: TransactionPayControllerMessenger,\n body: ServerSubmitRequest,\n): Promise<ServerSubmitResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const submitUrl = `${server.baseUrl}/submit`;\n\n log('Submitting intent', { url: submitUrl });\n\n const response = await serverFetch(submitUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n\n return (await response.json()) as ServerSubmitResponse;\n}\n\n/**\n * Fetch the status of a server intent.\n *\n * @param messenger - Controller messenger.\n * @param params - Status query parameters.\n * @param params.provider - The provider that the intent was submitted to.\n * @param params.id - The intent ID.\n * @param params.hash - Optional transaction hash to include in the status query.\n * @returns The current status of the intent.\n */\nexport async function getServerStatus(\n messenger: TransactionPayControllerMessenger,\n params: { provider: ServerProviderName; id: string; hash?: string },\n): Promise<ServerStatusResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const query = new URLSearchParams({\n provider: params.provider,\n id: params.id,\n });\n if (params.hash) {\n query.set('hash', params.hash);\n }\n const url = `${server.baseUrl}/status?${query.toString()}`;\n\n log('Fetching status', { url });\n\n const response = await serverFetch(url, { method: 'GET' });\n\n return (await response.json()) as ServerStatusResponse;\n}\n\n/**\n * Fetch a server intents-api endpoint, throwing an error containing the\n * response body's `message` or `error` field (or status code) on non-OK\n * responses so the server's actual reason is preserved without leaking the\n * request URL.\n *\n * @param url - The endpoint to fetch.\n * @param init - Fetch init options.\n * @returns The successful response.\n */\nasync function serverFetch(url: string, init?: RequestInit): Promise<Response> {\n const response = await fetch(url, init);\n\n if (!response.ok) {\n let detail: string | undefined;\n try {\n const body = (await response.json()) as {\n message?: string;\n error?: string;\n };\n detail = body.message ?? body.error;\n } catch {\n // Body wasn't JSON; fall through to status-only error.\n }\n throw new Error(\n detail ? `${response.status} - ${detail}` : String(response.status),\n );\n }\n\n return response;\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TransactionPayControllerMessenger } from "../../types.cjs";
|
|
2
|
+
import type { ServerProviderName, ServerQuoteRequest, ServerQuoteResponse, ServerStatusResponse, ServerSubmitRequest, ServerSubmitResponse } from "./types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch a quote from the server intents API.
|
|
5
|
+
*
|
|
6
|
+
* @param messenger - Controller messenger.
|
|
7
|
+
* @param body - Quote request parameters.
|
|
8
|
+
* @param signal - Optional abort signal that cancels the underlying fetch.
|
|
9
|
+
* @returns The server quote response.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchServerQuote(messenger: TransactionPayControllerMessenger, body: ServerQuoteRequest, signal?: AbortSignal): Promise<ServerQuoteResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Submit a gasless intent via the server intents API.
|
|
14
|
+
*
|
|
15
|
+
* @param messenger - Controller messenger.
|
|
16
|
+
* @param body - Submit request parameters.
|
|
17
|
+
* @returns The submit response.
|
|
18
|
+
*/
|
|
19
|
+
export declare function submitServerIntent(messenger: TransactionPayControllerMessenger, body: ServerSubmitRequest): Promise<ServerSubmitResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch the status of a server intent.
|
|
22
|
+
*
|
|
23
|
+
* @param messenger - Controller messenger.
|
|
24
|
+
* @param params - Status query parameters.
|
|
25
|
+
* @param params.provider - The provider that the intent was submitted to.
|
|
26
|
+
* @param params.id - The intent ID.
|
|
27
|
+
* @param params.hash - Optional transaction hash to include in the status query.
|
|
28
|
+
* @returns The current status of the intent.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getServerStatus(messenger: TransactionPayControllerMessenger, params: {
|
|
31
|
+
provider: ServerProviderName;
|
|
32
|
+
id: string;
|
|
33
|
+
hash?: string;
|
|
34
|
+
}): Promise<ServerStatusResponse>;
|
|
35
|
+
//# sourceMappingURL=server-api.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-api.d.cts","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,wBAAoB;AAErE,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,oBAAgB;AAIjB;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,kBAAkB,EACxB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAc9B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,iCAAiC,EAC5C,MAAM,EAAE;IAAE,QAAQ,EAAE,kBAAkB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE,OAAO,CAAC,oBAAoB,CAAC,CAgB/B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TransactionPayControllerMessenger } from "../../types.mjs";
|
|
2
|
+
import type { ServerProviderName, ServerQuoteRequest, ServerQuoteResponse, ServerStatusResponse, ServerSubmitRequest, ServerSubmitResponse } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch a quote from the server intents API.
|
|
5
|
+
*
|
|
6
|
+
* @param messenger - Controller messenger.
|
|
7
|
+
* @param body - Quote request parameters.
|
|
8
|
+
* @param signal - Optional abort signal that cancels the underlying fetch.
|
|
9
|
+
* @returns The server quote response.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchServerQuote(messenger: TransactionPayControllerMessenger, body: ServerQuoteRequest, signal?: AbortSignal): Promise<ServerQuoteResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Submit a gasless intent via the server intents API.
|
|
14
|
+
*
|
|
15
|
+
* @param messenger - Controller messenger.
|
|
16
|
+
* @param body - Submit request parameters.
|
|
17
|
+
* @returns The submit response.
|
|
18
|
+
*/
|
|
19
|
+
export declare function submitServerIntent(messenger: TransactionPayControllerMessenger, body: ServerSubmitRequest): Promise<ServerSubmitResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch the status of a server intent.
|
|
22
|
+
*
|
|
23
|
+
* @param messenger - Controller messenger.
|
|
24
|
+
* @param params - Status query parameters.
|
|
25
|
+
* @param params.provider - The provider that the intent was submitted to.
|
|
26
|
+
* @param params.id - The intent ID.
|
|
27
|
+
* @param params.hash - Optional transaction hash to include in the status query.
|
|
28
|
+
* @returns The current status of the intent.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getServerStatus(messenger: TransactionPayControllerMessenger, params: {
|
|
31
|
+
provider: ServerProviderName;
|
|
32
|
+
id: string;
|
|
33
|
+
hash?: string;
|
|
34
|
+
}): Promise<ServerStatusResponse>;
|
|
35
|
+
//# sourceMappingURL=server-api.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-api.d.mts","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,wBAAoB;AAErE,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,oBAAgB;AAIjB;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,kBAAkB,EACxB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAc9B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,iCAAiC,EAC5C,MAAM,EAAE;IAAE,QAAQ,EAAE,kBAAkB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE,OAAO,CAAC,oBAAoB,CAAC,CAgB/B"}
|