@metamask-previews/bridge-status-controller 12.0.1-preview-c555b24d → 12.0.1-preview-23d1c73f
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 +14 -0
- package/dist/bridge-status-controller.cjs +301 -6
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +25 -4
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +25 -4
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +304 -9
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +3 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +2 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +10 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +18 -7
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +18 -7
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +9 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs +6 -5
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs +6 -5
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/gas.cjs +23 -0
- package/dist/utils/gas.cjs.map +1 -0
- package/dist/utils/gas.d.cts +12 -0
- package/dist/utils/gas.d.cts.map +1 -0
- package/dist/utils/gas.d.mts +12 -0
- package/dist/utils/gas.d.mts.map +1 -0
- package/dist/utils/gas.mjs +19 -0
- package/dist/utils/gas.mjs.map +1 -0
- package/dist/utils/smart-transactions.cjs +13 -0
- package/dist/utils/smart-transactions.cjs.map +1 -0
- package/dist/utils/smart-transactions.d.cts +3 -0
- package/dist/utils/smart-transactions.d.cts.map +1 -0
- package/dist/utils/smart-transactions.d.mts +3 -0
- package/dist/utils/smart-transactions.d.mts.map +1 -0
- package/dist/utils/smart-transactions.mjs +9 -0
- package/dist/utils/smart-transactions.mjs.map +1 -0
- package/dist/utils/transaction.cjs +78 -0
- package/dist/utils/transaction.cjs.map +1 -0
- package/dist/utils/transaction.d.cts +31 -0
- package/dist/utils/transaction.d.cts.map +1 -0
- package/dist/utils/transaction.d.mts +31 -0
- package/dist/utils/transaction.d.mts.map +1 -0
- package/dist/utils/transaction.mjs +71 -0
- package/dist/utils/transaction.mjs.map +1 -0
- package/dist/utils/validators.cjs +1 -1
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.mjs +2 -2
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +19 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bridge-status.mjs","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,yBAAqB;AAQ5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,aAAa,EAAE,QAAQ;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,gBAAwB,EAAE,EAAE,CAC7D,GAAG,gBAAgB,cAAc,CAAC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,aAAyC,EACvB,EAAE;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,oBAAoB,EAAE,GAAG,aAAa,CAAC;IAEzD,MAAM,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C,CAAC;IAEH,WAAW;IACX,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAE1C,SAAS;IACT,OAAO,WAA6B,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,KAAY,EACZ,SAAiB,EACW,EAAE;IAC9B,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACrE,OAAO;QACL,QAAQ;QACR,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClB,UAAU;QACV,WAAW;QACX,KAAK;QACL,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;KACxB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Quote } from '@metamask/bridge-controller';\n\nimport { validateBridgeStatusResponse } from './validators';\nimport type {\n StatusResponse,\n StatusRequestWithSrcTxHash,\n StatusRequestDto,\n FetchFunction,\n} from '../types';\n\nexport const getClientIdHeader = (clientId: string) => ({\n 'X-Client-Id': clientId,\n});\n\nexport const getBridgeStatusUrl = (bridgeApiBaseUrl: string) =>\n `${bridgeApiBaseUrl}/getTxStatus`;\n\nexport const getStatusRequestDto = (\n statusRequest: StatusRequestWithSrcTxHash,\n): StatusRequestDto => {\n const { quote, ...statusRequestNoQuote } = statusRequest;\n\n const statusRequestNoQuoteFormatted = Object.fromEntries(\n Object.entries(statusRequestNoQuote).map(([key, value]) => [\n key,\n value.toString(),\n ]),\n ) as unknown as Omit<StatusRequestDto, 'requestId'>;\n\n const requestId: { requestId: string } | Record<string, never> =\n quote?.requestId ? { requestId: quote.requestId } : {};\n\n return {\n ...statusRequestNoQuoteFormatted,\n ...requestId,\n };\n};\n\nexport const fetchBridgeTxStatus = async (\n statusRequest: StatusRequestWithSrcTxHash,\n clientId: string,\n fetchFn: FetchFunction,\n bridgeApiBaseUrl: string,\n): Promise<StatusResponse> => {\n const statusRequestDto = getStatusRequestDto(statusRequest);\n const params = new URLSearchParams(statusRequestDto);\n\n // Fetch\n const url = `${getBridgeStatusUrl(bridgeApiBaseUrl)}?${params.toString()}`;\n\n const rawTxStatus: unknown = await fetchFn(url, {\n headers: getClientIdHeader(clientId),\n });\n\n // Validate\n validateBridgeStatusResponse(rawTxStatus);\n\n // Return\n return rawTxStatus as StatusResponse;\n};\n\nexport const getStatusRequestWithSrcTxHash = (\n quote: Quote,\n srcTxHash: string,\n): StatusRequestWithSrcTxHash => {\n const { bridgeId, bridges, srcChainId, destChainId, refuel } = quote;\n return {\n bridgeId,\n srcTxHash,\n bridge: bridges[0],\n srcChainId,\n destChainId,\n quote,\n refuel: Boolean(refuel),\n };\n};\n"]}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getTxGasEstimates = void 0;
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
5
|
+
const getTransaction1559GasFeeEstimates = (txGasFeeEstimates, estimatedBaseFee) => {
|
6
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.high ?? {};
|
7
|
+
const baseAndPriorityFeePerGas = maxPriorityFeePerGas
|
8
|
+
? new bignumber_js_1.BigNumber(estimatedBaseFee, 10)
|
9
|
+
.times(10 ** 9)
|
10
|
+
.plus(maxPriorityFeePerGas, 16)
|
11
|
+
: undefined;
|
12
|
+
return {
|
13
|
+
baseAndPriorityFeePerGas,
|
14
|
+
maxFeePerGas,
|
15
|
+
maxPriorityFeePerGas,
|
16
|
+
};
|
17
|
+
};
|
18
|
+
const getTxGasEstimates = async ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
|
19
|
+
const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
|
20
|
+
return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
|
21
|
+
};
|
22
|
+
exports.getTxGasEstimates = getTxGasEstimates;
|
23
|
+
//# sourceMappingURL=gas.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gas.cjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AAQA,+CAAyC;AAEzC,MAAM,iCAAiC,GAAG,CACxC,iBAA2C,EAC3C,gBAAwB,EACxB,EAAE;IACF,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,iBAAiB,EAAE,IAAI,IAAI,EAAE,CAAC;IAE7E,MAAM,wBAAwB,GAAG,oBAAoB;QACnD,CAAC,CAAC,IAAI,wBAAS,CAAC,gBAAgB,EAAE,EAAE,CAAC;aAChC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;aACd,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,wBAAwB;QACxB,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,iBAAiB,EACjB,sBAAsB,GAMvB,EAAE,EAAE;IACH,MAAM,EAAE,gBAAgB,GAAG,GAAG,EAAE,GAAG,sBAAyC,CAAC;IAC7E,OAAO,iCAAiC,CACtC,iBAAwD,EACxD,gBAAgB,CACjB,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B","sourcesContent":["import type {\n GasFeeEstimates,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type {\n FeeMarketGasFeeEstimates,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nconst getTransaction1559GasFeeEstimates = (\n txGasFeeEstimates: FeeMarketGasFeeEstimates,\n estimatedBaseFee: string,\n) => {\n const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.high ?? {};\n\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const getTxGasEstimates = async ({\n txGasFeeEstimates,\n networkGasFeeEstimates,\n}: {\n txGasFeeEstimates: Awaited<\n ReturnType<TransactionController['estimateGasFee']>\n >['estimates'];\n networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];\n}) => {\n const { estimatedBaseFee = '0' } = networkGasFeeEstimates as GasFeeEstimates;\n return getTransaction1559GasFeeEstimates(\n txGasFeeEstimates as unknown as FeeMarketGasFeeEstimates,\n estimatedBaseFee,\n );\n};\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { GasFeeState } from "@metamask/gas-fee-controller";
|
2
|
+
import type { TransactionController } from "@metamask/transaction-controller";
|
3
|
+
import { BigNumber } from "bignumber.js";
|
4
|
+
export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
|
5
|
+
txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
|
6
|
+
networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
|
7
|
+
}) => Promise<{
|
8
|
+
baseAndPriorityFeePerGas: BigNumber | undefined;
|
9
|
+
maxFeePerGas: `0x${string}`;
|
10
|
+
maxPriorityFeePerGas: `0x${string}`;
|
11
|
+
}>;
|
12
|
+
//# sourceMappingURL=gas.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gas.d.cts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACZ,qCAAqC;AACtC,OAAO,KAAK,EAEV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAqBzC,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;EAOvD,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { GasFeeState } from "@metamask/gas-fee-controller";
|
2
|
+
import type { TransactionController } from "@metamask/transaction-controller";
|
3
|
+
import { BigNumber } from "bignumber.js";
|
4
|
+
export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
|
5
|
+
txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
|
6
|
+
networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
|
7
|
+
}) => Promise<{
|
8
|
+
baseAndPriorityFeePerGas: BigNumber | undefined;
|
9
|
+
maxFeePerGas: `0x${string}`;
|
10
|
+
maxPriorityFeePerGas: `0x${string}`;
|
11
|
+
}>;
|
12
|
+
//# sourceMappingURL=gas.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gas.d.mts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACZ,qCAAqC;AACtC,OAAO,KAAK,EAEV,qBAAqB,EACtB,yCAAyC;AAC1C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAqBzC,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;EAOvD,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
2
|
+
const getTransaction1559GasFeeEstimates = (txGasFeeEstimates, estimatedBaseFee) => {
|
3
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.high ?? {};
|
4
|
+
const baseAndPriorityFeePerGas = maxPriorityFeePerGas
|
5
|
+
? new BigNumber(estimatedBaseFee, 10)
|
6
|
+
.times(10 ** 9)
|
7
|
+
.plus(maxPriorityFeePerGas, 16)
|
8
|
+
: undefined;
|
9
|
+
return {
|
10
|
+
baseAndPriorityFeePerGas,
|
11
|
+
maxFeePerGas,
|
12
|
+
maxPriorityFeePerGas,
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export const getTxGasEstimates = async ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
|
16
|
+
const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
|
17
|
+
return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
|
18
|
+
};
|
19
|
+
//# sourceMappingURL=gas.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gas.mjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,MAAM,iCAAiC,GAAG,CACxC,iBAA2C,EAC3C,gBAAwB,EACxB,EAAE;IACF,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,iBAAiB,EAAE,IAAI,IAAI,EAAE,CAAC;IAE7E,MAAM,wBAAwB,GAAG,oBAAoB;QACnD,CAAC,CAAC,IAAI,SAAS,CAAC,gBAAgB,EAAE,EAAE,CAAC;aAChC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;aACd,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,wBAAwB;QACxB,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,iBAAiB,EACjB,sBAAsB,GAMvB,EAAE,EAAE;IACH,MAAM,EAAE,gBAAgB,GAAG,GAAG,EAAE,GAAG,sBAAyC,CAAC;IAC7E,OAAO,iCAAiC,CACtC,iBAAwD,EACxD,gBAAgB,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type {\n GasFeeEstimates,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type {\n FeeMarketGasFeeEstimates,\n TransactionController,\n} from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nconst getTransaction1559GasFeeEstimates = (\n txGasFeeEstimates: FeeMarketGasFeeEstimates,\n estimatedBaseFee: string,\n) => {\n const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.high ?? {};\n\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const getTxGasEstimates = async ({\n txGasFeeEstimates,\n networkGasFeeEstimates,\n}: {\n txGasFeeEstimates: Awaited<\n ReturnType<TransactionController['estimateGasFee']>\n >['estimates'];\n networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];\n}) => {\n const { estimatedBaseFee = '0' } = networkGasFeeEstimates as GasFeeEstimates;\n return getTransaction1559GasFeeEstimates(\n txGasFeeEstimates as unknown as FeeMarketGasFeeEstimates,\n estimatedBaseFee,\n );\n};\n"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isSmartTransactionsEnabled = void 0;
|
4
|
+
const transaction_controller_1 = require("@metamask/transaction-controller");
|
5
|
+
const isSmartTransactionsEnabled = (txType, defaultStxPreference, isStxEnabledOnClient, // getSmartTransactionsEnabled selector value should be passed in
|
6
|
+
isUserOptedInToStx) => {
|
7
|
+
// User has no opt in status, use default value from client
|
8
|
+
return (txType === transaction_controller_1.TransactionType.bridge &&
|
9
|
+
(isUserOptedInToStx ?? defaultStxPreference) &&
|
10
|
+
isStxEnabledOnClient);
|
11
|
+
};
|
12
|
+
exports.isSmartTransactionsEnabled = isSmartTransactionsEnabled;
|
13
|
+
//# sourceMappingURL=smart-transactions.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"smart-transactions.cjs","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":";;;AAAA,6EAAmE;AAE5D,MAAM,0BAA0B,GAAG,CACxC,MAAuB,EACvB,oBAA6B,EAC7B,oBAA6B,EAAE,iEAAiE;AAChG,kBAA4B,EAC5B,EAAE;IACF,2DAA2D;IAC3D,OAAO,CACL,MAAM,KAAK,wCAAe,CAAC,MAAM;QACjC,CAAC,kBAAkB,IAAI,oBAAoB,CAAC;QAC5C,oBAAoB,CACrB,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\n\nexport const isSmartTransactionsEnabled = (\n txType: TransactionType,\n defaultStxPreference: boolean,\n isStxEnabledOnClient: boolean, // getSmartTransactionsEnabled selector value should be passed in\n isUserOptedInToStx?: boolean,\n) => {\n // User has no opt in status, use default value from client\n return (\n txType === TransactionType.bridge &&\n (isUserOptedInToStx ?? defaultStxPreference) &&\n isStxEnabledOnClient\n );\n};\n"]}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { TransactionType } from "@metamask/transaction-controller";
|
2
|
+
export declare const isSmartTransactionsEnabled: (txType: TransactionType, defaultStxPreference: boolean, isStxEnabledOnClient: boolean, isUserOptedInToStx?: boolean) => boolean;
|
3
|
+
//# sourceMappingURL=smart-transactions.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"smart-transactions.d.cts","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE,eAAO,MAAM,0BAA0B,WAC7B,eAAe,wBACD,OAAO,wBACP,OAAO,uBACR,OAAO,YAQ7B,CAAC"}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { TransactionType } from "@metamask/transaction-controller";
|
2
|
+
export declare const isSmartTransactionsEnabled: (txType: TransactionType, defaultStxPreference: boolean, isStxEnabledOnClient: boolean, isUserOptedInToStx?: boolean) => boolean;
|
3
|
+
//# sourceMappingURL=smart-transactions.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"smart-transactions.d.mts","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE,eAAO,MAAM,0BAA0B,WAC7B,eAAe,wBACD,OAAO,wBACP,OAAO,uBACR,OAAO,YAQ7B,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { TransactionType } from "@metamask/transaction-controller";
|
2
|
+
export const isSmartTransactionsEnabled = (txType, defaultStxPreference, isStxEnabledOnClient, // getSmartTransactionsEnabled selector value should be passed in
|
3
|
+
isUserOptedInToStx) => {
|
4
|
+
// User has no opt in status, use default value from client
|
5
|
+
return (txType === TransactionType.bridge &&
|
6
|
+
(isUserOptedInToStx ?? defaultStxPreference) &&
|
7
|
+
isStxEnabledOnClient);
|
8
|
+
};
|
9
|
+
//# sourceMappingURL=smart-transactions.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"smart-transactions.mjs","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,MAAuB,EACvB,oBAA6B,EAC7B,oBAA6B,EAAE,iEAAiE;AAChG,kBAA4B,EAC5B,EAAE;IACF,2DAA2D;IAC3D,OAAO,CACL,MAAM,KAAK,eAAe,CAAC,MAAM;QACjC,CAAC,kBAAkB,IAAI,oBAAoB,CAAC;QAC5C,oBAAoB,CACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\n\nexport const isSmartTransactionsEnabled = (\n txType: TransactionType,\n defaultStxPreference: boolean,\n isStxEnabledOnClient: boolean, // getSmartTransactionsEnabled selector value should be passed in\n isUserOptedInToStx?: boolean,\n) => {\n // User has no opt in status, use default value from client\n return (\n txType === TransactionType.bridge &&\n (isUserOptedInToStx ?? defaultStxPreference) &&\n isStxEnabledOnClient\n );\n};\n"]}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.handleSolanaTxResponse = exports.getTxMetaFields = exports.getStatusRequestParams = exports.generateActionId = void 0;
|
4
|
+
const bridge_controller_1 = require("@metamask/bridge-controller");
|
5
|
+
const transaction_controller_1 = require("@metamask/transaction-controller");
|
6
|
+
const uuid_1 = require("uuid");
|
7
|
+
const generateActionId = () => Date.now() + Math.random();
|
8
|
+
exports.generateActionId = generateActionId;
|
9
|
+
const getStatusRequestParams = (quoteResponse) => {
|
10
|
+
return {
|
11
|
+
bridgeId: quoteResponse.quote.bridgeId,
|
12
|
+
bridge: quoteResponse.quote.bridges[0],
|
13
|
+
srcChainId: quoteResponse.quote.srcChainId,
|
14
|
+
destChainId: quoteResponse.quote.destChainId,
|
15
|
+
quote: quoteResponse.quote,
|
16
|
+
refuel: Boolean(quoteResponse.quote.refuel),
|
17
|
+
};
|
18
|
+
};
|
19
|
+
exports.getStatusRequestParams = getStatusRequestParams;
|
20
|
+
const getTxMetaFields = (quoteResponse, approvalTxId) => {
|
21
|
+
return {
|
22
|
+
destinationChainId: (0, bridge_controller_1.formatChainIdToHex)(quoteResponse.quote.destChainId),
|
23
|
+
sourceTokenAmount: quoteResponse.quote.srcTokenAmount,
|
24
|
+
sourceTokenSymbol: quoteResponse.quote.srcAsset.symbol,
|
25
|
+
sourceTokenDecimals: quoteResponse.quote.srcAsset.decimals,
|
26
|
+
sourceTokenAddress: quoteResponse.quote.srcAsset.address,
|
27
|
+
destinationTokenAmount: quoteResponse.quote.destTokenAmount,
|
28
|
+
destinationTokenSymbol: quoteResponse.quote.destAsset.symbol,
|
29
|
+
destinationTokenDecimals: quoteResponse.quote.destAsset.decimals,
|
30
|
+
destinationTokenAddress: quoteResponse.quote.destAsset.address,
|
31
|
+
chainId: (0, bridge_controller_1.formatChainIdToHex)(quoteResponse.quote.srcChainId),
|
32
|
+
approvalTxId,
|
33
|
+
// this is the decimal (non atomic) amount (not USD value) of source token to swap
|
34
|
+
swapTokenValue: quoteResponse.sentAmount.amount,
|
35
|
+
// Ensure it's marked as a bridge transaction for UI detection
|
36
|
+
isBridgeTx: true, // TODO deprecate this and use tx type
|
37
|
+
};
|
38
|
+
};
|
39
|
+
exports.getTxMetaFields = getTxMetaFields;
|
40
|
+
const handleSolanaTxResponse = (snapResponse, quoteResponse, snapId, // TODO use SnapId type
|
41
|
+
selectedAccountAddress) => {
|
42
|
+
let hash;
|
43
|
+
// Handle different response formats
|
44
|
+
if (typeof snapResponse === 'string') {
|
45
|
+
hash = snapResponse;
|
46
|
+
}
|
47
|
+
else if (snapResponse && typeof snapResponse === 'object') {
|
48
|
+
// If it's an object with result property, try to get the signature
|
49
|
+
if (snapResponse.result && typeof snapResponse.result === 'object') {
|
50
|
+
// Try to extract signature from common locations in response object
|
51
|
+
hash =
|
52
|
+
snapResponse.result.signature ||
|
53
|
+
snapResponse.result.txid ||
|
54
|
+
snapResponse.result.hash ||
|
55
|
+
snapResponse.result.txHash;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
// Create a transaction meta object with bridge-specific fields
|
59
|
+
const txMeta = {
|
60
|
+
...(0, exports.getTxMetaFields)(quoteResponse),
|
61
|
+
id: (0, uuid_1.v4)(),
|
62
|
+
chainId: (0, bridge_controller_1.formatChainIdToHex)(quoteResponse.quote.srcChainId),
|
63
|
+
// networkClientId: selectedAccount.id, //TODO optional for solana or no?
|
64
|
+
txParams: { from: selectedAccountAddress },
|
65
|
+
type: transaction_controller_1.TransactionType.bridge,
|
66
|
+
status: transaction_controller_1.TransactionStatus.submitted,
|
67
|
+
hash,
|
68
|
+
// Add an explicit flag to mark this as a Solana transaction
|
69
|
+
isSolana: true,
|
70
|
+
isBridgeTx: true,
|
71
|
+
// Add key bridge-specific fields for proper categorization
|
72
|
+
// actionId: txType,
|
73
|
+
origin: snapId,
|
74
|
+
}; // TODO remove this override once deprecated fields are removed
|
75
|
+
return txMeta;
|
76
|
+
};
|
77
|
+
exports.handleSolanaTxResponse = handleSolanaTxResponse;
|
78
|
+
//# sourceMappingURL=transaction.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AACA,mEAIqC;AACrC,6EAI0C;AAC1C,+BAAkC;AAE3B,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAApD,QAAA,gBAAgB,oBAAoC;AAE1D,MAAM,sBAAsB,GAAG,CACpC,aAA6C,EAC7C,EAAE;IACF,OAAO;QACL,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ;QACtC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,UAAU;QAC1C,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW;QAC5C,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC;AAEK,MAAM,eAAe,GAAG,CAC7B,aACe,EACf,YAAqB,EACrB,EAAE;IACF,OAAO;QACL,kBAAkB,EAAE,IAAA,sCAAkB,EAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC;QACvE,iBAAiB,EAAE,aAAa,CAAC,KAAK,CAAC,cAAc;QACrD,iBAAiB,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM;QACtD,mBAAmB,EAAE,aAAa,CAA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AAe,EAAC,aAAa,CAAC;QACjC,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,OAAO,EAAE,IAAA,sCAAkB,EAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC;QAC3D,yEAAyE;QACzE,QAAQ,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;QAC1C,IAAI,EAAE,wCAAe,CAAC,MAAM;QAC5B,MAAM,EAAE,0CAAiB,CAAC,SAAS;QACnC,IAAI;QACJ,4DAA4D;QAC5D,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;QAChB,2DAA2D;QAC3D,oBAAoB;QACpB,MAAM,EAAE,MAAM;KACN,CAAC,CAAC,+DAA+D;IAE3E,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA1CW,QAAA,sBAAsB,0BA0CjC","sourcesContent":["import type { TxData } from '@metamask/bridge-controller';\nimport {\n formatChainIdToHex,\n type QuoteMetadata,\n type QuoteResponse,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n type TransactionMeta,\n} from '@metamask/transaction-controller';\nimport { v4 as uuid } from 'uuid';\n\nexport const generateActionId = () => Date.now() + Math.random();\n\nexport const getStatusRequestParams = (\n quoteResponse: QuoteResponse<string | TxData>,\n) => {\n return {\n bridgeId: quoteResponse.quote.bridgeId,\n bridge: quoteResponse.quote.bridges[0],\n srcChainId: quoteResponse.quote.srcChainId,\n destChainId: quoteResponse.quote.destChainId,\n quote: quoteResponse.quote,\n refuel: Boolean(quoteResponse.quote.refuel),\n };\n};\n\nexport const getTxMetaFields = (\n quoteResponse: Omit<QuoteResponse<string | TxData>, 'approval' | 'trade'> &\n QuoteMetadata,\n approvalTxId?: string,\n) => {\n return {\n destinationChainId: formatChainIdToHex(quoteResponse.quote.destChainId),\n sourceTokenAmount: quoteResponse.quote.srcTokenAmount,\n sourceTokenSymbol: quoteResponse.quote.srcAsset.symbol,\n sourceTokenDecimals: quoteResponse.quote.srcAsset.decimals,\n sourceTokenAddress: quoteResponse.quote.srcAsset.address,\n\n destinationTokenAmount: quoteResponse.quote.destTokenAmount,\n destinationTokenSymbol: quoteResponse.quote.destAsset.symbol,\n destinationTokenDecimals: quoteResponse.quote.destAsset.decimals,\n destinationTokenAddress: quoteResponse.quote.destAsset.address,\n\n chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),\n approvalTxId,\n // this is the decimal (non atomic) amount (not USD value) of source token to swap\n swapTokenValue: quoteResponse.sentAmount.amount,\n // Ensure it's marked as a bridge transaction for UI detection\n isBridgeTx: true, // TODO deprecate this and use tx type\n };\n};\n\nexport const handleSolanaTxResponse = (\n snapResponse: string | { result: Record<string, string> },\n quoteResponse: Omit<QuoteResponse<string>, 'approval' | 'trade'> &\n QuoteMetadata,\n snapId: string, // TODO use SnapId type\n selectedAccountAddress: string,\n) => {\n let hash;\n // Handle different response formats\n if (typeof snapResponse === 'string') {\n hash = snapResponse;\n } else if (snapResponse && typeof snapResponse === 'object') {\n // If it's an object with result property, try to get the signature\n if (snapResponse.result && typeof snapResponse.result === 'object') {\n // Try to extract signature from common locations in response object\n hash =\n snapResponse.result.signature ||\n snapResponse.result.txid ||\n snapResponse.result.hash ||\n snapResponse.result.txHash;\n }\n }\n\n // Create a transaction meta object with bridge-specific fields\n const txMeta: TransactionMeta = {\n ...getTxMetaFields(quoteResponse),\n id: uuid(),\n chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),\n // networkClientId: selectedAccount.id, //TODO optional for solana or no?\n txParams: { from: selectedAccountAddress }, // { data: quoteResponse.trade }, // TODO not reading this for solana\n type: TransactionType.bridge,\n status: TransactionStatus.submitted,\n hash, // Add the transaction signature as hash\n // Add an explicit flag to mark this as a Solana transaction\n isSolana: true, // TODO deprecate this and use chainId\n isBridgeTx: true, // TODO deprecate this and use type\n // Add key bridge-specific fields for proper categorization\n // actionId: txType,\n origin: snapId,\n } as never; // TODO remove this override once deprecated fields are removed\n\n return txMeta;\n};\n"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { TxData } from "@metamask/bridge-controller";
|
2
|
+
import { type QuoteMetadata, type QuoteResponse } from "@metamask/bridge-controller";
|
3
|
+
import { type TransactionMeta } from "@metamask/transaction-controller";
|
4
|
+
export declare const generateActionId: () => number;
|
5
|
+
export declare const getStatusRequestParams: (quoteResponse: QuoteResponse<string | TxData>) => {
|
6
|
+
bridgeId: string;
|
7
|
+
bridge: string;
|
8
|
+
srcChainId: import("@metamask/bridge-controller").ChainId;
|
9
|
+
destChainId: import("@metamask/bridge-controller").ChainId;
|
10
|
+
quote: import("@metamask/bridge-controller").Quote;
|
11
|
+
refuel: boolean;
|
12
|
+
};
|
13
|
+
export declare const getTxMetaFields: (quoteResponse: Omit<QuoteResponse<string | TxData>, 'approval' | 'trade'> & QuoteMetadata, approvalTxId?: string) => {
|
14
|
+
destinationChainId: `0x${string}`;
|
15
|
+
sourceTokenAmount: string;
|
16
|
+
sourceTokenSymbol: string;
|
17
|
+
sourceTokenDecimals: number;
|
18
|
+
sourceTokenAddress: string;
|
19
|
+
destinationTokenAmount: string;
|
20
|
+
destinationTokenSymbol: string;
|
21
|
+
destinationTokenDecimals: number;
|
22
|
+
destinationTokenAddress: string;
|
23
|
+
chainId: `0x${string}`;
|
24
|
+
approvalTxId: string | undefined;
|
25
|
+
swapTokenValue: string;
|
26
|
+
isBridgeTx: boolean;
|
27
|
+
};
|
28
|
+
export declare const handleSolanaTxResponse: (snapResponse: string | {
|
29
|
+
result: Record<string, string>;
|
30
|
+
}, quoteResponse: Omit<QuoteResponse<string>, 'approval' | 'trade'> & QuoteMetadata, snapId: string, selectedAccountAddress: string) => TransactionMeta;
|
31
|
+
//# sourceMappingURL=transaction.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,oCAAoC;AAC1D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,oCAAoC;AACrC,OAAO,EAGL,KAAK,eAAe,EACrB,yCAAyC;AAG1C,eAAO,MAAM,gBAAgB,cAAmC,CAAC;AAEjE,eAAO,MAAM,sBAAsB,kBAClB,cAAc,MAAM,GAAG,MAAM,CAAC;;;;;;;CAU9C,CAAC;AAEF,eAAO,MAAM,eAAe,kBACX,KAAK,cAAc,MAAM,GAAG,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GACvE,aAAa,iBACA,MAAM;;;;;;;;;;;;;;CAqBtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,iBACnB,MAAM,GAAG;IAAE,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,iBAC1C,KAAK,cAAc,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAC9D,aAAa,UACP,MAAM,0BACU,MAAM,oBAqC/B,CAAC"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { TxData } from "@metamask/bridge-controller";
|
2
|
+
import { type QuoteMetadata, type QuoteResponse } from "@metamask/bridge-controller";
|
3
|
+
import { type TransactionMeta } from "@metamask/transaction-controller";
|
4
|
+
export declare const generateActionId: () => number;
|
5
|
+
export declare const getStatusRequestParams: (quoteResponse: QuoteResponse<string | TxData>) => {
|
6
|
+
bridgeId: string;
|
7
|
+
bridge: string;
|
8
|
+
srcChainId: import("@metamask/bridge-controller").ChainId;
|
9
|
+
destChainId: import("@metamask/bridge-controller").ChainId;
|
10
|
+
quote: import("@metamask/bridge-controller").Quote;
|
11
|
+
refuel: boolean;
|
12
|
+
};
|
13
|
+
export declare const getTxMetaFields: (quoteResponse: Omit<QuoteResponse<string | TxData>, 'approval' | 'trade'> & QuoteMetadata, approvalTxId?: string) => {
|
14
|
+
destinationChainId: `0x${string}`;
|
15
|
+
sourceTokenAmount: string;
|
16
|
+
sourceTokenSymbol: string;
|
17
|
+
sourceTokenDecimals: number;
|
18
|
+
sourceTokenAddress: string;
|
19
|
+
destinationTokenAmount: string;
|
20
|
+
destinationTokenSymbol: string;
|
21
|
+
destinationTokenDecimals: number;
|
22
|
+
destinationTokenAddress: string;
|
23
|
+
chainId: `0x${string}`;
|
24
|
+
approvalTxId: string | undefined;
|
25
|
+
swapTokenValue: string;
|
26
|
+
isBridgeTx: boolean;
|
27
|
+
};
|
28
|
+
export declare const handleSolanaTxResponse: (snapResponse: string | {
|
29
|
+
result: Record<string, string>;
|
30
|
+
}, quoteResponse: Omit<QuoteResponse<string>, 'approval' | 'trade'> & QuoteMetadata, snapId: string, selectedAccountAddress: string) => TransactionMeta;
|
31
|
+
//# sourceMappingURL=transaction.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.d.mts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,oCAAoC;AAC1D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,oCAAoC;AACrC,OAAO,EAGL,KAAK,eAAe,EACrB,yCAAyC;AAG1C,eAAO,MAAM,gBAAgB,cAAmC,CAAC;AAEjE,eAAO,MAAM,sBAAsB,kBAClB,cAAc,MAAM,GAAG,MAAM,CAAC;;;;;;;CAU9C,CAAC;AAEF,eAAO,MAAM,eAAe,kBACX,KAAK,cAAc,MAAM,GAAG,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GACvE,aAAa,iBACA,MAAM;;;;;;;;;;;;;;CAqBtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,iBACnB,MAAM,GAAG;IAAE,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,iBAC1C,KAAK,cAAc,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAC9D,aAAa,UACP,MAAM,0BACU,MAAM,oBAqC/B,CAAC"}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { formatChainIdToHex } from "@metamask/bridge-controller";
|
2
|
+
import { TransactionStatus, TransactionType } from "@metamask/transaction-controller";
|
3
|
+
import { v4 as uuid } from "uuid";
|
4
|
+
export const generateActionId = () => Date.now() + Math.random();
|
5
|
+
export const getStatusRequestParams = (quoteResponse) => {
|
6
|
+
return {
|
7
|
+
bridgeId: quoteResponse.quote.bridgeId,
|
8
|
+
bridge: quoteResponse.quote.bridges[0],
|
9
|
+
srcChainId: quoteResponse.quote.srcChainId,
|
10
|
+
destChainId: quoteResponse.quote.destChainId,
|
11
|
+
quote: quoteResponse.quote,
|
12
|
+
refuel: Boolean(quoteResponse.quote.refuel),
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export const getTxMetaFields = (quoteResponse, approvalTxId) => {
|
16
|
+
return {
|
17
|
+
destinationChainId: formatChainIdToHex(quoteResponse.quote.destChainId),
|
18
|
+
sourceTokenAmount: quoteResponse.quote.srcTokenAmount,
|
19
|
+
sourceTokenSymbol: quoteResponse.quote.srcAsset.symbol,
|
20
|
+
sourceTokenDecimals: quoteResponse.quote.srcAsset.decimals,
|
21
|
+
sourceTokenAddress: quoteResponse.quote.srcAsset.address,
|
22
|
+
destinationTokenAmount: quoteResponse.quote.destTokenAmount,
|
23
|
+
destinationTokenSymbol: quoteResponse.quote.destAsset.symbol,
|
24
|
+
destinationTokenDecimals: quoteResponse.quote.destAsset.decimals,
|
25
|
+
destinationTokenAddress: quoteResponse.quote.destAsset.address,
|
26
|
+
chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),
|
27
|
+
approvalTxId,
|
28
|
+
// this is the decimal (non atomic) amount (not USD value) of source token to swap
|
29
|
+
swapTokenValue: quoteResponse.sentAmount.amount,
|
30
|
+
// Ensure it's marked as a bridge transaction for UI detection
|
31
|
+
isBridgeTx: true, // TODO deprecate this and use tx type
|
32
|
+
};
|
33
|
+
};
|
34
|
+
export const handleSolanaTxResponse = (snapResponse, quoteResponse, snapId, // TODO use SnapId type
|
35
|
+
selectedAccountAddress) => {
|
36
|
+
let hash;
|
37
|
+
// Handle different response formats
|
38
|
+
if (typeof snapResponse === 'string') {
|
39
|
+
hash = snapResponse;
|
40
|
+
}
|
41
|
+
else if (snapResponse && typeof snapResponse === 'object') {
|
42
|
+
// If it's an object with result property, try to get the signature
|
43
|
+
if (snapResponse.result && typeof snapResponse.result === 'object') {
|
44
|
+
// Try to extract signature from common locations in response object
|
45
|
+
hash =
|
46
|
+
snapResponse.result.signature ||
|
47
|
+
snapResponse.result.txid ||
|
48
|
+
snapResponse.result.hash ||
|
49
|
+
snapResponse.result.txHash;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
// Create a transaction meta object with bridge-specific fields
|
53
|
+
const txMeta = {
|
54
|
+
...getTxMetaFields(quoteResponse),
|
55
|
+
id: uuid(),
|
56
|
+
chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),
|
57
|
+
// networkClientId: selectedAccount.id, //TODO optional for solana or no?
|
58
|
+
txParams: { from: selectedAccountAddress },
|
59
|
+
type: TransactionType.bridge,
|
60
|
+
status: TransactionStatus.submitted,
|
61
|
+
hash,
|
62
|
+
// Add an explicit flag to mark this as a Solana transaction
|
63
|
+
isSolana: true,
|
64
|
+
isBridgeTx: true,
|
65
|
+
// Add key bridge-specific fields for proper categorization
|
66
|
+
// actionId: txType,
|
67
|
+
origin: snapId,
|
68
|
+
}; // TODO remove this override once deprecated fields are removed
|
69
|
+
return txMeta;
|
70
|
+
};
|
71
|
+
//# sourceMappingURL=transaction.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGnB,oCAAoC;AACrC,OAAO,EACL,iBAAiB,EACjB,eAAe,EAEhB,yCAAyC;AAC1C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAElC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAA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dToHex,\n type QuoteMetadata,\n type QuoteResponse,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n type TransactionMeta,\n} from '@metamask/transaction-controller';\nimport { v4 as uuid } from 'uuid';\n\nexport const generateActionId = () => Date.now() + Math.random();\n\nexport const getStatusRequestParams = (\n quoteResponse: QuoteResponse<string | TxData>,\n) => {\n return {\n bridgeId: quoteResponse.quote.bridgeId,\n bridge: quoteResponse.quote.bridges[0],\n srcChainId: quoteResponse.quote.srcChainId,\n destChainId: quoteResponse.quote.destChainId,\n quote: quoteResponse.quote,\n refuel: Boolean(quoteResponse.quote.refuel),\n };\n};\n\nexport const getTxMetaFields = (\n quoteResponse: Omit<QuoteResponse<string | TxData>, 'approval' | 'trade'> &\n QuoteMetadata,\n approvalTxId?: string,\n) => {\n return {\n destinationChainId: formatChainIdToHex(quoteResponse.quote.destChainId),\n sourceTokenAmount: quoteResponse.quote.srcTokenAmount,\n sourceTokenSymbol: quoteResponse.quote.srcAsset.symbol,\n sourceTokenDecimals: quoteResponse.quote.srcAsset.decimals,\n sourceTokenAddress: quoteResponse.quote.srcAsset.address,\n\n destinationTokenAmount: quoteResponse.quote.destTokenAmount,\n destinationTokenSymbol: quoteResponse.quote.destAsset.symbol,\n destinationTokenDecimals: quoteResponse.quote.destAsset.decimals,\n destinationTokenAddress: quoteResponse.quote.destAsset.address,\n\n chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),\n approvalTxId,\n // this is the decimal (non atomic) amount (not USD value) of source token to swap\n swapTokenValue: quoteResponse.sentAmount.amount,\n // Ensure it's marked as a bridge transaction for UI detection\n isBridgeTx: true, // TODO deprecate this and use tx type\n };\n};\n\nexport const handleSolanaTxResponse = (\n snapResponse: string | { result: Record<string, string> },\n quoteResponse: Omit<QuoteResponse<string>, 'approval' | 'trade'> &\n QuoteMetadata,\n snapId: string, // TODO use SnapId type\n selectedAccountAddress: string,\n) => {\n let hash;\n // Handle different response formats\n if (typeof snapResponse === 'string') {\n hash = snapResponse;\n } else if (snapResponse && typeof snapResponse === 'object') {\n // If it's an object with result property, try to get the signature\n if (snapResponse.result && typeof snapResponse.result === 'object') {\n // Try to extract signature from common locations in response object\n hash =\n snapResponse.result.signature ||\n snapResponse.result.txid ||\n snapResponse.result.hash ||\n snapResponse.result.txHash;\n }\n }\n\n // Create a transaction meta object with bridge-specific fields\n const txMeta: TransactionMeta = {\n ...getTxMetaFields(quoteResponse),\n id: uuid(),\n chainId: formatChainIdToHex(quoteResponse.quote.srcChainId),\n // networkClientId: selectedAccount.id, //TODO optional for solana or no?\n txParams: { from: selectedAccountAddress }, // { data: quoteResponse.trade }, // TODO not reading this for solana\n type: TransactionType.bridge,\n status: TransactionStatus.submitted,\n hash, // Add the transaction signature as hash\n // Add an explicit flag to mark this as a Solana transaction\n isSolana: true, // TODO deprecate this and use chainId\n isBridgeTx: true, // TODO deprecate this and use type\n // Add key bridge-specific fields for proper categorization\n // actionId: txType,\n origin: snapId,\n } as never; // TODO remove this override once deprecated fields are removed\n\n return txMeta;\n};\n"]}
|
@@ -31,7 +31,7 @@ const validateBridgeStatusResponse = (data) => {
|
|
31
31
|
status: (0, superstruct_1.enums)(Object.values(types_1.StatusTypes)),
|
32
32
|
srcChain: SrcChainStatusSchema,
|
33
33
|
destChain: (0, superstruct_1.optional)(DestChainStatusSchema),
|
34
|
-
bridge: (0, superstruct_1.optional)((0, superstruct_1.
|
34
|
+
bridge: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
35
35
|
isExpectedToken: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
36
36
|
isUnrecognizedRouterAddress: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
37
37
|
refuel: (0, superstruct_1.optional)(RefuelStatusResponseSchema),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validators.cjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":";;;AAAA,uDAW+B;AAE/B,
|
1
|
+
{"version":3,"file":"validators.c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,WAAW,CAAC,CAAC,CAAC;KACzD,CAAC,CAAC;IAEH,MAAM,0BAA0B,GAAG,IAAA,oBAAM,GAAE,CAAC;IAE5C,MAAM,oBAAoB,GAAG,IAAA,kBAAI,EAAC;QAChC,MAAM,EAAE,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC,CAAC;QACzC,QAAQ,EAAE,oBAAoB;QAC9B,SAAS,EAAE,IAAA,sBAAQ,EAAC,qBAAqB,CAAC;QAC1C,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;QAC1B,eAAe,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;QACpC,2BAA2B,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;QAChD,MAAM,EAAE,IAAA,sBAAQ,EAAC,0BAA0B,CAAC;KAC7C,CAAC,CAAC;IAEH,IAAA,oBAAM,EAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;AACrC,CAAC,CAAC;AAzCW,QAAA,4BAA4B,gCAyCvC","sourcesContent":["import {\n object,\n string,\n boolean,\n number,\n optional,\n enums,\n union,\n type,\n nullable,\n assert,\n} from '@metamask/superstruct';\n\nimport { StatusTypes } from '../types';\n\nexport const validateBridgeStatusResponse = (data: unknown) => {\n const ChainIdSchema = union([number(), string()]);\n\n const AssetSchema = type({\n chainId: ChainIdSchema,\n address: string(),\n symbol: string(),\n name: string(),\n decimals: number(),\n icon: optional(nullable(string())),\n });\n\n const EmptyObjectSchema = object({});\n\n const SrcChainStatusSchema = type({\n chainId: ChainIdSchema,\n txHash: optional(string()),\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, AssetSchema])),\n });\n\n const DestChainStatusSchema = type({\n chainId: ChainIdSchema,\n txHash: optional(string()),\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, AssetSchema])),\n });\n\n const RefuelStatusResponseSchema = object();\n\n const StatusResponseSchema = type({\n status: enums(Object.values(StatusTypes)),\n srcChain: SrcChainStatusSchema,\n destChain: optional(DestChainStatusSchema),\n bridge: optional(string()),\n isExpectedToken: optional(boolean()),\n isUnrecognizedRouterAddress: optional(boolean()),\n refuel: optional(RefuelStatusResponseSchema),\n });\n\n assert(data, StatusResponseSchema);\n};\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { object, string, boolean, number, optional, enums, union, type, nullable, assert } from "@metamask/superstruct";
|
2
|
-
import {
|
2
|
+
import { StatusTypes } from "../types.mjs";
|
3
3
|
export const validateBridgeStatusResponse = (data) => {
|
4
4
|
const ChainIdSchema = union([number(), string()]);
|
5
5
|
const AssetSchema = type({
|
@@ -28,7 +28,7 @@ export const validateBridgeStatusResponse = (data) => {
|
|
28
28
|
status: enums(Object.values(StatusTypes)),
|
29
29
|
srcChain: SrcChainStatusSchema,
|
30
30
|
destChain: optional(DestChainStatusSchema),
|
31
|
-
bridge: optional(
|
31
|
+
bridge: optional(string()),
|
32
32
|
isExpectedToken: optional(boolean()),
|
33
33
|
isUnrecognizedRouterAddress: optional(boolean()),
|
34
34
|
refuel: optional(RefuelStatusResponseSchema),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACP,8BAA8B;AAE/B,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"validators.mjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACP,8BAA8B;AAE/B,OAAO,EAAE,WAAW,EAAE,qBAAiB;AAEvC,MAAM,CAAC,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C1C,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC1B,eAAe,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QACpC,2BAA2B,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QAChD,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC;KAC7C,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import {\n object,\n string,\n boolean,\n number,\n optional,\n enums,\n union,\n type,\n nullable,\n assert,\n} from '@metamask/superstruct';\n\nimport { StatusTypes } from '../types';\n\nexport const validateBridgeStatusResponse = (data: unknown) => {\n const ChainIdSchema = union([number(), string()]);\n\n const AssetSchema = type({\n chainId: ChainIdSchema,\n address: string(),\n symbol: string(),\n name: string(),\n decimals: number(),\n icon: optional(nullable(string())),\n });\n\n const EmptyObjectSchema = object({});\n\n const SrcChainStatusSchema = type({\n chainId: ChainIdSchema,\n txHash: optional(string()),\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, AssetSchema])),\n });\n\n const DestChainStatusSchema = type({\n chainId: ChainIdSchema,\n txHash: optional(string()),\n amount: optional(string()),\n token: optional(union([EmptyObjectSchema, AssetSchema])),\n });\n\n const RefuelStatusResponseSchema = object();\n\n const StatusResponseSchema = type({\n status: enums(Object.values(StatusTypes)),\n srcChain: SrcChainStatusSchema,\n destChain: optional(DestChainStatusSchema),\n bridge: optional(string()),\n isExpectedToken: optional(boolean()),\n isUnrecognizedRouterAddress: optional(boolean()),\n refuel: optional(RefuelStatusResponseSchema),\n });\n\n assert(data, StatusResponseSchema);\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask-previews/bridge-status-controller",
|
3
|
-
"version": "12.0.1-preview-
|
3
|
+
"version": "12.0.1-preview-23d1c73f",
|
4
4
|
"description": "Manages bridge-related status fetching functionality for MetaMask",
|
5
5
|
"keywords": [
|
6
6
|
"MetaMask",
|
@@ -50,15 +50,25 @@
|
|
50
50
|
"@metamask/base-controller": "^8.0.0",
|
51
51
|
"@metamask/bridge-controller": "^13.0.0",
|
52
52
|
"@metamask/controller-utils": "^11.7.0",
|
53
|
+
"@metamask/keyring-api": "^17.4.0",
|
53
54
|
"@metamask/polling-controller": "^13.0.0",
|
54
55
|
"@metamask/superstruct": "^3.1.0",
|
55
|
-
"@metamask/utils": "^11.2.0"
|
56
|
+
"@metamask/utils": "^11.2.0",
|
57
|
+
"bignumber.js": "^9.1.2",
|
58
|
+
"uuid": "^8.3.2"
|
56
59
|
},
|
57
60
|
"devDependencies": {
|
58
61
|
"@metamask/accounts-controller": "^27.0.0",
|
62
|
+
"@metamask/assets-controllers": "^56.0.0",
|
59
63
|
"@metamask/auto-changelog": "^3.4.4",
|
64
|
+
"@metamask/bridge-controller": "^13.0.0",
|
65
|
+
"@metamask/gas-fee-controller": "^22.0.3",
|
60
66
|
"@metamask/network-controller": "^23.2.0",
|
67
|
+
"@metamask/preferences-controller": "^17.0.0",
|
68
|
+
"@metamask/snaps-controllers": "^9.19.0",
|
61
69
|
"@metamask/transaction-controller": "^54.0.0",
|
70
|
+
"@metamask/user-operation-controller": "^31.0.0",
|
71
|
+
"@ts-bridge/cli": "^0.6.3",
|
62
72
|
"@types/jest": "^27.4.1",
|
63
73
|
"deepmerge": "^4.2.2",
|
64
74
|
"jest": "^27.5.1",
|
@@ -72,8 +82,14 @@
|
|
72
82
|
},
|
73
83
|
"peerDependencies": {
|
74
84
|
"@metamask/accounts-controller": "^27.0.0",
|
85
|
+
"@metamask/assets-controllers": "^56.0.0",
|
86
|
+
"@metamask/bridge-controller": "^13.0.0",
|
87
|
+
"@metamask/gas-fee-controller": "^22.0.3",
|
75
88
|
"@metamask/network-controller": "^23.0.0",
|
76
|
-
"@metamask/
|
89
|
+
"@metamask/preferences-controller": "^17.0.0",
|
90
|
+
"@metamask/snaps-controllers": "^9.19.0",
|
91
|
+
"@metamask/transaction-controller": "^54.0.0",
|
92
|
+
"@metamask/user-operation-controller": "^31.0.0"
|
77
93
|
},
|
78
94
|
"engines": {
|
79
95
|
"node": "^18.18 || >=20"
|