@metamask-previews/bridge-status-controller 12.0.1-preview-1b8ef4d5 → 12.0.1-preview-6c44e568

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/dist/bridge-status-controller.cjs +21 -195
  3. package/dist/bridge-status-controller.cjs.map +1 -1
  4. package/dist/bridge-status-controller.d.cts +8 -12
  5. package/dist/bridge-status-controller.d.cts.map +1 -1
  6. package/dist/bridge-status-controller.d.mts +8 -12
  7. package/dist/bridge-status-controller.d.mts.map +1 -1
  8. package/dist/bridge-status-controller.mjs +23 -197
  9. package/dist/bridge-status-controller.mjs.map +1 -1
  10. package/dist/constants.cjs +1 -2
  11. package/dist/constants.cjs.map +1 -1
  12. package/dist/constants.d.cts +0 -1
  13. package/dist/constants.d.cts.map +1 -1
  14. package/dist/constants.d.mts +0 -1
  15. package/dist/constants.d.mts.map +1 -1
  16. package/dist/constants.mjs +0 -1
  17. package/dist/constants.mjs.map +1 -1
  18. package/dist/types.cjs.map +1 -1
  19. package/dist/types.d.cts +3 -15
  20. package/dist/types.d.cts.map +1 -1
  21. package/dist/types.d.mts +3 -15
  22. package/dist/types.d.mts.map +1 -1
  23. package/dist/types.mjs.map +1 -1
  24. package/dist/utils/transaction.cjs +16 -28
  25. package/dist/utils/transaction.cjs.map +1 -1
  26. package/dist/utils/transaction.d.cts +18 -8
  27. package/dist/utils/transaction.d.cts.map +1 -1
  28. package/dist/utils/transaction.d.mts +18 -8
  29. package/dist/utils/transaction.d.mts.map +1 -1
  30. package/dist/utils/transaction.mjs +16 -26
  31. package/dist/utils/transaction.mjs.map +1 -1
  32. package/package.json +5 -18
  33. package/dist/utils/gas.cjs +0 -31
  34. package/dist/utils/gas.cjs.map +0 -1
  35. package/dist/utils/gas.d.cts +0 -20
  36. package/dist/utils/gas.d.cts.map +0 -1
  37. package/dist/utils/gas.d.mts +0 -20
  38. package/dist/utils/gas.d.mts.map +0 -1
  39. package/dist/utils/gas.mjs +0 -27
  40. package/dist/utils/gas.mjs.map +0 -1
  41. package/dist/utils/smart-transactions.cjs +0 -21
  42. package/dist/utils/smart-transactions.cjs.map +0 -1
  43. package/dist/utils/smart-transactions.d.cts +0 -12
  44. package/dist/utils/smart-transactions.d.cts.map +0 -1
  45. package/dist/utils/smart-transactions.d.mts +0 -12
  46. package/dist/utils/smart-transactions.d.mts.map +0 -1
  47. package/dist/utils/smart-transactions.mjs +0 -17
  48. package/dist/utils/smart-transactions.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,kBAAkB,EAGnB,oCAAoC;AACrC,OAAO,EACL,iBAAiB,EACjB,eAAe,EAEhB,yCAAyC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,wBAAwB;AACtD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAElC,OAAO,EAAE,cAAc,EAAE,yBAAqB;AAG9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAE9E,MAAM,CAAC,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,CA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KACnB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,aAAsE,EACtE,eAAgF,EAChF,EAAE;IACF,MAAM,YAAY,GAAG,IAAI,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,IAAI,EAAE,CAAC;IAE7B,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAW;QAClD,OAAO,EAAE,kBAA2B;QACpC,OAAO,EAAE;YACP,EAAE,EAAE,YAAY;YAChB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,uBAAuB;YAC/B,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE;wBAC7C,WAAW,EAAE,aAAa,CAAC,KAAK;wBAChC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK;qBACrC;oBACD,MAAM,EAAE,wBAAwB;iBACjC;gBACD,EAAE,EAAE,aAAa;gBACjB,OAAO,EAAE,eAAe,CAAC,EAAE;gBAC3B,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK;aACrC;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\nimport type { TxData } from '@metamask/bridge-controller';\nimport {\n ChainId,\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 { createProjectLogger } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport { LINEA_DELAY_MS } from '../constants';\nimport type { SolanaTransactionMeta } from '../types';\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\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): Omit<\n TransactionMeta,\n 'networkClientId' | 'status' | 'time' | 'txParams' | 'id'\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 };\n};\n\nexport const handleSolanaTxResponse = (\n snapResponse: string | { result: Record<string, string> },\n quoteResponse: Omit<QuoteResponse<string>, 'approval'> & QuoteMetadata,\n selectedAccount: AccountsControllerState['internalAccounts']['accounts'][string],\n): TransactionMeta & SolanaTransactionMeta => {\n const selectedAccountAddress = selectedAccount.address;\n const snapId = selectedAccount.metadata.snap?.id;\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 const hexChainId = formatChainIdToHex(quoteResponse.quote.srcChainId);\n // Create a transaction meta object with bridge-specific fields\n return {\n ...getTxMetaFields(quoteResponse),\n time: Date.now(),\n id: uuid(),\n chainId: hexChainId,\n networkClientId: snapId ?? hexChainId,\n txParams: { from: selectedAccountAddress, data: quoteResponse.trade },\n type: TransactionType.bridge,\n status: TransactionStatus.submitted,\n hash, // Add the transaction signature as hash\n origin: snapId,\n // Add an explicit bridge 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 };\n};\n\nexport const handleLineaDelay = async (\n quoteResponse: QuoteResponse<TxData | string>,\n) => {\n if (ChainId.LINEA === quoteResponse.quote.srcChainId) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, LINEA_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\nexport const getKeyringRequest = (\n quoteResponse: Omit<QuoteResponse<string>, 'approval'> & QuoteMetadata,\n selectedAccount: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const keyringReqId = uuid();\n const snapRequestId = uuid();\n\n return {\n origin: 'metamask',\n snapId: selectedAccount.metadata.snap?.id as never,\n handler: 'onKeyringRequest' as never,\n request: {\n id: keyringReqId,\n jsonrpc: '2.0',\n method: 'keyring_submitRequest',\n params: {\n request: {\n params: {\n account: { address: selectedAccount.address },\n transaction: quoteResponse.trade,\n scope: selectedAccount.options.scope,\n },\n method: 'signAndSendTransaction',\n },\n id: snapRequestId,\n account: selectedAccount.id,\n scope: selectedAccount.options.scope,\n },\n },\n };\n};\n"]}
1
+ {"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAGnB,oCAAoC;AACrC,OAAO,EACL,iBAAiB,EACjB,eAAe,EAEhB,yCAAyC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AAG,IAAI,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,IAAI,EAAE,CAAC;IAE7B,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAW;QAClD,OAAO,EAAE,kBAA2B;QACpC,OAAO,EAAE;YACP,EAAE,EAAE,YAAY;YAChB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,uBAAuB;YAC/B,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE;wBAC7C,WAAW,EAAE,aAAa,CAAC,KAAK;wBAChC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK;qBACrC;oBACD,MAAM,EAAE,wBAAwB;iBACjC;gBACD,EAAE,EAAE,aAAa;gBACjB,OAAO,EAAE,eAAe,CAAC,EAAE;gBAC3B,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK;aACrC;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\nimport 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 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 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\nexport const getKeyringRequest = (\n quoteResponse: Omit<QuoteResponse<string>, 'approval'> & QuoteMetadata,\n selectedAccount: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const keyringReqId = uuid();\n const snapRequestId = uuid();\n\n return {\n origin: 'metamask',\n snapId: selectedAccount.metadata.snap?.id as never,\n handler: 'onKeyringRequest' as never,\n request: {\n id: keyringReqId,\n jsonrpc: '2.0',\n method: 'keyring_submitRequest',\n params: {\n request: {\n params: {\n account: { address: selectedAccount.address },\n transaction: quoteResponse.trade,\n scope: selectedAccount.options.scope,\n },\n method: 'signAndSendTransaction',\n },\n id: snapRequestId,\n account: selectedAccount.id,\n scope: selectedAccount.options.scope,\n },\n },\n };\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-1b8ef4d5",
3
+ "version": "12.0.1-preview-6c44e568",
4
4
  "description": "Manages bridge-related status fetching functionality for MetaMask",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -48,27 +48,19 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@metamask/base-controller": "^8.0.0",
51
- "@metamask/bridge-controller": "^14.0.0",
51
+ "@metamask/bridge-controller": "^15.0.0",
52
52
  "@metamask/controller-utils": "^11.7.0",
53
- "@metamask/keyring-api": "^17.4.0",
54
53
  "@metamask/polling-controller": "^13.0.0",
55
54
  "@metamask/superstruct": "^3.1.0",
56
55
  "@metamask/utils": "^11.2.0",
57
- "bignumber.js": "^9.1.2",
58
56
  "uuid": "^8.3.2"
59
57
  },
60
58
  "devDependencies": {
61
59
  "@metamask/accounts-controller": "^27.0.0",
62
- "@metamask/assets-controllers": "^56.0.0",
63
60
  "@metamask/auto-changelog": "^3.4.4",
64
- "@metamask/bridge-controller": "^14.0.0",
65
- "@metamask/gas-fee-controller": "^22.0.3",
66
61
  "@metamask/network-controller": "^23.2.0",
67
- "@metamask/preferences-controller": "^17.0.0",
68
- "@metamask/snaps-controllers": "^9.19.0",
62
+ "@metamask/snaps-controllers": "^11.2.1",
69
63
  "@metamask/transaction-controller": "^54.1.0",
70
- "@metamask/user-operation-controller": "^31.0.0",
71
- "@ts-bridge/cli": "^0.6.3",
72
64
  "@types/jest": "^27.4.1",
73
65
  "deepmerge": "^4.2.2",
74
66
  "jest": "^27.5.1",
@@ -82,14 +74,9 @@
82
74
  },
83
75
  "peerDependencies": {
84
76
  "@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",
88
77
  "@metamask/network-controller": "^23.0.0",
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"
78
+ "@metamask/snaps-controllers": "^11.0.0",
79
+ "@metamask/transaction-controller": "^54.0.0"
93
80
  },
94
81
  "engines": {
95
82
  "node": "^18.18 || >=20"
@@ -1,31 +0,0 @@
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
- /**
19
- * Get the gas fee estimates for a transaction
20
- *
21
- * @param params - The parameters for the gas fee estimates
22
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
23
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
24
- * @returns The gas fee estimates for the transaction
25
- */
26
- const getTxGasEstimates = ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
27
- const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
28
- return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
29
- };
30
- exports.getTxGasEstimates = getTxGasEstimates;
31
- //# sourceMappingURL=gas.cjs.map
@@ -1 +0,0 @@
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;AAEF;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAChC,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\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param params - The parameters for the gas fee estimates\n * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)\n * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)\n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = ({\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"]}
@@ -1,20 +0,0 @@
1
- import type { GasFeeState } from "@metamask/gas-fee-controller";
2
- import type { TransactionController } from "@metamask/transaction-controller";
3
- import { BigNumber } from "bignumber.js";
4
- /**
5
- * Get the gas fee estimates for a transaction
6
- *
7
- * @param params - The parameters for the gas fee estimates
8
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
9
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
10
- * @returns The gas fee estimates for the transaction
11
- */
12
- export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
13
- txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
14
- networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
15
- }) => {
16
- baseAndPriorityFeePerGas: BigNumber | undefined;
17
- maxFeePerGas: `0x${string}`;
18
- maxPriorityFeePerGas: `0x${string}`;
19
- };
20
- //# sourceMappingURL=gas.d.cts.map
@@ -1 +0,0 @@
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;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;CAOvD,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { GasFeeState } from "@metamask/gas-fee-controller";
2
- import type { TransactionController } from "@metamask/transaction-controller";
3
- import { BigNumber } from "bignumber.js";
4
- /**
5
- * Get the gas fee estimates for a transaction
6
- *
7
- * @param params - The parameters for the gas fee estimates
8
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
9
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
10
- * @returns The gas fee estimates for the transaction
11
- */
12
- export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
13
- txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
14
- networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
15
- }) => {
16
- baseAndPriorityFeePerGas: BigNumber | undefined;
17
- maxFeePerGas: `0x${string}`;
18
- maxPriorityFeePerGas: `0x${string}`;
19
- };
20
- //# sourceMappingURL=gas.d.mts.map
@@ -1 +0,0 @@
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;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;CAOvD,CAAC"}
@@ -1,27 +0,0 @@
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
- /**
16
- * Get the gas fee estimates for a transaction
17
- *
18
- * @param params - The parameters for the gas fee estimates
19
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
20
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
21
- * @returns The gas fee estimates for the transaction
22
- */
23
- export const getTxGasEstimates = ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
24
- const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
25
- return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
26
- };
27
- //# sourceMappingURL=gas.mjs.map
@@ -1 +0,0 @@
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;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,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\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param params - The parameters for the gas fee estimates\n * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)\n * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)\n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = ({\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"]}
@@ -1,21 +0,0 @@
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
- /**
6
- * Check if smart transactions are enabled
7
- *
8
- * @param txType - The type of transaction
9
- * @param defaultStxPreference - The default preference for smart transactions for the client
10
- * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client
11
- * @param isUserOptedInToStx - Whether the user has opted in to smart transactions
12
- * @returns Whether smart transactions should be used for the transaction
13
- */
14
- const isSmartTransactionsEnabled = (txType, defaultStxPreference, isStxEnabledOnClient, isUserOptedInToStx) => {
15
- return (txType === transaction_controller_1.TransactionType.bridge &&
16
- // If user has no opt in status, use default value from client
17
- (isUserOptedInToStx ?? defaultStxPreference) &&
18
- isStxEnabledOnClient);
19
- };
20
- exports.isSmartTransactionsEnabled = isSmartTransactionsEnabled;
21
- //# sourceMappingURL=smart-transactions.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smart-transactions.cjs","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":";;;AAAA,6EAAmE;AAEnE;;;;;;;;GAQG;AACI,MAAM,0BAA0B,GAAG,CACxC,MAAuB,EACvB,oBAA6B,EAC7B,oBAA6B,EAC7B,kBAA4B,EAC5B,EAAE;IACF,OAAO,CACL,MAAM,KAAK,wCAAe,CAAC,MAAM;QACjC,8DAA8D;QAC9D,CAAC,kBAAkB,IAAI,oBAAoB,CAAC;QAC5C,oBAAoB,CACrB,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\n\n/**\n * Check if smart transactions are enabled\n *\n * @param txType - The type of transaction\n * @param defaultStxPreference - The default preference for smart transactions for the client\n * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client\n * @param isUserOptedInToStx - Whether the user has opted in to smart transactions\n * @returns Whether smart transactions should be used for the transaction\n */\nexport const isSmartTransactionsEnabled = (\n txType: TransactionType,\n defaultStxPreference: boolean,\n isStxEnabledOnClient: boolean,\n isUserOptedInToStx?: boolean,\n) => {\n return (\n txType === TransactionType.bridge &&\n // If user has no opt in status, use default value from client\n (isUserOptedInToStx ?? defaultStxPreference) &&\n isStxEnabledOnClient\n );\n};\n"]}
@@ -1,12 +0,0 @@
1
- import { TransactionType } from "@metamask/transaction-controller";
2
- /**
3
- * Check if smart transactions are enabled
4
- *
5
- * @param txType - The type of transaction
6
- * @param defaultStxPreference - The default preference for smart transactions for the client
7
- * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client
8
- * @param isUserOptedInToStx - Whether the user has opted in to smart transactions
9
- * @returns Whether smart transactions should be used for the transaction
10
- */
11
- export declare const isSmartTransactionsEnabled: (txType: TransactionType, defaultStxPreference: boolean, isStxEnabledOnClient: boolean, isUserOptedInToStx?: boolean) => boolean;
12
- //# sourceMappingURL=smart-transactions.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smart-transactions.d.cts","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,WAC7B,eAAe,wBACD,OAAO,wBACP,OAAO,uBACR,OAAO,YAQ7B,CAAC"}
@@ -1,12 +0,0 @@
1
- import { TransactionType } from "@metamask/transaction-controller";
2
- /**
3
- * Check if smart transactions are enabled
4
- *
5
- * @param txType - The type of transaction
6
- * @param defaultStxPreference - The default preference for smart transactions for the client
7
- * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client
8
- * @param isUserOptedInToStx - Whether the user has opted in to smart transactions
9
- * @returns Whether smart transactions should be used for the transaction
10
- */
11
- export declare const isSmartTransactionsEnabled: (txType: TransactionType, defaultStxPreference: boolean, isStxEnabledOnClient: boolean, isUserOptedInToStx?: boolean) => boolean;
12
- //# sourceMappingURL=smart-transactions.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smart-transactions.d.mts","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,WAC7B,eAAe,wBACD,OAAO,wBACP,OAAO,uBACR,OAAO,YAQ7B,CAAC"}
@@ -1,17 +0,0 @@
1
- import { TransactionType } from "@metamask/transaction-controller";
2
- /**
3
- * Check if smart transactions are enabled
4
- *
5
- * @param txType - The type of transaction
6
- * @param defaultStxPreference - The default preference for smart transactions for the client
7
- * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client
8
- * @param isUserOptedInToStx - Whether the user has opted in to smart transactions
9
- * @returns Whether smart transactions should be used for the transaction
10
- */
11
- export const isSmartTransactionsEnabled = (txType, defaultStxPreference, isStxEnabledOnClient, isUserOptedInToStx) => {
12
- return (txType === TransactionType.bridge &&
13
- // If user has no opt in status, use default value from client
14
- (isUserOptedInToStx ?? defaultStxPreference) &&
15
- isStxEnabledOnClient);
16
- };
17
- //# sourceMappingURL=smart-transactions.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smart-transactions.mjs","sourceRoot":"","sources":["../../src/utils/smart-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,MAAuB,EACvB,oBAA6B,EAC7B,oBAA6B,EAC7B,kBAA4B,EAC5B,EAAE;IACF,OAAO,CACL,MAAM,KAAK,eAAe,CAAC,MAAM;QACjC,8DAA8D;QAC9D,CAAC,kBAAkB,IAAI,oBAAoB,CAAC;QAC5C,oBAAoB,CACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\n\n/**\n * Check if smart transactions are enabled\n *\n * @param txType - The type of transaction\n * @param defaultStxPreference - The default preference for smart transactions for the client\n * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client\n * @param isUserOptedInToStx - Whether the user has opted in to smart transactions\n * @returns Whether smart transactions should be used for the transaction\n */\nexport const isSmartTransactionsEnabled = (\n txType: TransactionType,\n defaultStxPreference: boolean,\n isStxEnabledOnClient: boolean,\n isUserOptedInToStx?: boolean,\n) => {\n return (\n txType === TransactionType.bridge &&\n // If user has no opt in status, use default value from client\n (isUserOptedInToStx ?? defaultStxPreference) &&\n isStxEnabledOnClient\n );\n};\n"]}