@metamask-previews/transaction-controller 69.6.1-preview-99421bfe4 → 69.6.1-preview-878689a26
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 +4 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/recipient.cjs +71 -1
- package/dist/utils/recipient.cjs.map +1 -1
- package/dist/utils/recipient.d.cts +22 -0
- package/dist/utils/recipient.d.cts.map +1 -1
- package/dist/utils/recipient.d.mts +22 -0
- package/dist/utils/recipient.d.mts.map +1 -1
- package/dist/utils/recipient.mjs +69 -0
- package/dist/utils/recipient.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Export `getSendRecipients`, which returns user-chosen send payees for a transaction (native `simpleSend` recipients, decoded ERC-20/721/1155 transfer payees, `swapAndSendRecipient`, and nested batch sends) and omits protocol addresses such as token, Permit2, and router contracts ([#9943](https://github.com/MetaMask/core/pull/9943))
|
|
13
|
+
|
|
10
14
|
### Changed
|
|
11
15
|
|
|
12
16
|
- Bump `@metamask/remote-feature-flag-controller` from `^6.0.0` to `^6.1.0` ([#9980](https://github.com/MetaMask/core/pull/9980))
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateBatchId = exports.getAccountAddressRelationship = exports.HARDFORK = exports.CHAIN_IDS = exports.getEffectiveRecipient = exports.hasTransactionType = exports.normalizeTransactionParams = exports.isEIP1559Transaction = exports.updateEIP7702BatchData = exports.generateEIP7702BatchTransaction = exports.decodeAuthorizationSignature = exports.mergeGasFeeEstimates = exports.WalletDevice = exports.UserFeeLevel = exports.TransactionType = exports.TransactionStatus = exports.TransactionEnvelopeType = exports.TransactionContainerType = exports.SimulationTokenStandard = exports.SimulationErrorCode = exports.GasFeeEstimateType = exports.GasFeeEstimateLevel = exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
3
|
+
exports.generateBatchId = exports.getAccountAddressRelationship = exports.HARDFORK = exports.CHAIN_IDS = exports.getSendRecipients = exports.getEffectiveRecipient = exports.hasTransactionType = exports.normalizeTransactionParams = exports.isEIP1559Transaction = exports.updateEIP7702BatchData = exports.generateEIP7702BatchTransaction = exports.decodeAuthorizationSignature = exports.mergeGasFeeEstimates = exports.WalletDevice = exports.UserFeeLevel = exports.TransactionType = exports.TransactionStatus = exports.TransactionEnvelopeType = exports.TransactionContainerType = exports.SimulationTokenStandard = exports.SimulationErrorCode = exports.GasFeeEstimateType = exports.GasFeeEstimateLevel = exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
4
4
|
var TransactionController_js_1 = require("./TransactionController.cjs");
|
|
5
5
|
Object.defineProperty(exports, "CANCEL_RATE", { enumerable: true, get: function () { return TransactionController_js_1.CANCEL_RATE; } });
|
|
6
6
|
Object.defineProperty(exports, "SPEED_UP_RATE", { enumerable: true, get: function () { return TransactionController_js_1.SPEED_UP_RATE; } });
|
|
@@ -29,6 +29,7 @@ var transaction_type_js_1 = require("./utils/transaction-type.cjs");
|
|
|
29
29
|
Object.defineProperty(exports, "hasTransactionType", { enumerable: true, get: function () { return transaction_type_js_1.hasTransactionType; } });
|
|
30
30
|
var recipient_js_1 = require("./utils/recipient.cjs");
|
|
31
31
|
Object.defineProperty(exports, "getEffectiveRecipient", { enumerable: true, get: function () { return recipient_js_1.getEffectiveRecipient; } });
|
|
32
|
+
Object.defineProperty(exports, "getSendRecipients", { enumerable: true, get: function () { return recipient_js_1.getSendRecipients; } });
|
|
32
33
|
var constants_js_1 = require("./constants.cjs");
|
|
33
34
|
Object.defineProperty(exports, "CHAIN_IDS", { enumerable: true, get: function () { return constants_js_1.CHAIN_IDS; } });
|
|
34
35
|
var prepare_js_1 = require("./utils/prepare.cjs");
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4DA,wEAIoC;AAHlC,uHAAA,WAAW,OAAA;AACX,yHAAA,aAAa,OAAA;AACb,iIAAA,qBAAqB,OAAA;AAyDvB,wCAWoB;AAVlB,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,mHAAA,uBAAuB,OAAA;AACvB,oHAAA,wBAAwB,OAAA;AACxB,mHAAA,uBAAuB,OAAA;AACvB,6GAAA,iBAAiB,OAAA;AACjB,2GAAA,eAAe,OAAA;AACf,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AAEd,oDAA2D;AAAlD,mHAAA,oBAAoB,OAAA;AAC7B,kDAI4B;AAH1B,0HAAA,4BAA4B,OAAA;AAC5B,6HAAA,+BAA+B,OAAA;AAC/B,oHAAA,sBAAsB,OAAA;AAExB,8CAG0B;AAFxB,gHAAA,oBAAoB,OAAA;AACpB,sHAAA,0BAA0B,OAAA;AAE5B,oEAAiE;AAAxD,yHAAA,kBAAkB,OAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4DA,wEAIoC;AAHlC,uHAAA,WAAW,OAAA;AACX,yHAAA,aAAa,OAAA;AACb,iIAAA,qBAAqB,OAAA;AAyDvB,wCAWoB;AAVlB,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,mHAAA,uBAAuB,OAAA;AACvB,oHAAA,wBAAwB,OAAA;AACxB,mHAAA,uBAAuB,OAAA;AACvB,6GAAA,iBAAiB,OAAA;AACjB,2GAAA,eAAe,OAAA;AACf,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AAEd,oDAA2D;AAAlD,mHAAA,oBAAoB,OAAA;AAC7B,kDAI4B;AAH1B,0HAAA,4BAA4B,OAAA;AAC5B,6HAAA,+BAA+B,OAAA;AAC/B,oHAAA,sBAAsB,OAAA;AAExB,8CAG0B;AAFxB,gHAAA,oBAAoB,OAAA;AACpB,sHAAA,0BAA0B,OAAA;AAE5B,oEAAiE;AAAxD,yHAAA,kBAAkB,OAAA;AAC3B,sDAAgF;AAAvE,qHAAA,qBAAqB,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AACjD,gDAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,kDAA8C;AAArC,sGAAA,QAAQ,OAAA;AACjB,0DAAsE;AAA7D,gIAAA,6BAA6B,OAAA;AAKtC,8CAAmD;AAA1C,2GAAA,eAAe,OAAA","sourcesContent":["export type {\n MethodData,\n Result,\n TransactionControllerActions,\n TransactionControllerEvents,\n TransactionControllerGetStateAction,\n TransactionControllerPostTransactionBalanceUpdatedEvent,\n TransactionControllerSpeedupTransactionAddedEvent,\n TransactionControllerState,\n TransactionControllerStateChangeEvent,\n TransactionControllerTransactionApprovedEvent,\n TransactionControllerTransactionConfirmedEvent,\n TransactionControllerTransactionDroppedEvent,\n TransactionControllerTransactionFailedEvent,\n TransactionControllerTransactionFinishedEvent,\n TransactionControllerTransactionNewSwapApprovalEvent,\n TransactionControllerTransactionNewSwapEvent,\n TransactionControllerTransactionPublishingSkipped,\n TransactionControllerTransactionRejectedEvent,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerTransactionSubmittedEvent,\n TransactionControllerUnapprovedTransactionAddedEvent,\n TransactionControllerMessenger,\n TransactionControllerOptions,\n} from './TransactionController.js';\nexport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerConfirmExternalTransactionAction,\n TransactionControllerEmulateNewTransactionAction,\n TransactionControllerEmulateTransactionUpdateAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetNonceLockAction,\n TransactionControllerGetTransactionsAction,\n TransactionControllerUpdateCustodialTransactionAction,\n TransactionControllerUpdateTransactionAction,\n TransactionControllerUpdateTransactionMetadataAction,\n TransactionControllerHandleMethodDataAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerStopTransactionAction,\n TransactionControllerSpeedUpTransactionAction,\n TransactionControllerEstimateGasBufferedAction,\n TransactionControllerUpdateEditableParamsAction,\n TransactionControllerSetTransactionActiveAction,\n TransactionControllerApproveTransactionsWithSameNonceAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerFailTransactionAction,\n TransactionControllerGetLayer1GasFeeAction,\n TransactionControllerClearUnapprovedTransactionsAction,\n TransactionControllerAbortTransactionSigningAction,\n TransactionControllerUpdateAtomicBatchDataAction,\n TransactionControllerWipeTransactionsAction,\n TransactionControllerUpdateSecurityAlertResponseAction,\n TransactionControllerUpdateTransactionGasFeesAction,\n TransactionControllerUpdatePreviousGasParamsAction,\n TransactionControllerUpdateSelectedGasFeeTokenAction,\n TransactionControllerUpdateRequiredTransactionIdsAction,\n} from './TransactionController-method-action-types.js';\nexport {\n CANCEL_RATE,\n SPEED_UP_RATE,\n TransactionController,\n} from './TransactionController.js';\nexport type {\n AddTransactionOptions,\n AfterAddHook,\n Authorization,\n AuthorizationList,\n BatchTransaction,\n BatchTransactionParams,\n BeforeSignHook,\n DappSuggestedGasFees,\n DefaultGasEstimates,\n FeeMarketEIP1559Values,\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeToken,\n GasPriceGasFeeEstimates,\n GasPriceValue,\n GetGasFeeTokensRequest,\n GetSimulationConfig,\n InferTransactionTypeResult,\n IsAtomicBatchSupportedRequest,\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n LegacyGasFeeEstimates,\n Log,\n MetamaskPayMetadata,\n NestedTransactionMetadata,\n NestedTransactionUpdate,\n PublishBatchHook,\n PublishBatchHookRequest,\n PublishBatchHookResult,\n PublishBatchHookTransaction,\n PublishHook,\n PublishHookResult,\n RequiredAsset,\n SavedGasFees,\n SecurityAlertResponse,\n SendFlowHistoryEntry,\n SimulationBalanceChange,\n SimulationData,\n SimulationError,\n SimulationToken,\n SimulationTokenBalanceChange,\n TransactionBatchMeta,\n TransactionBatchRequest,\n TransactionBatchResult,\n TransactionBatchSingleRequest,\n TransactionError,\n TransactionHistory,\n TransactionHistoryEntry,\n TransactionMeta,\n TransactionParams,\n TransactionReceipt,\n ValidateSecurityRequest,\n} from './types.js';\nexport {\n GasFeeEstimateLevel,\n GasFeeEstimateType,\n SimulationErrorCode,\n SimulationTokenStandard,\n TransactionContainerType,\n TransactionEnvelopeType,\n TransactionStatus,\n TransactionType,\n UserFeeLevel,\n WalletDevice,\n} from './types.js';\nexport { mergeGasFeeEstimates } from './utils/gas-flow.js';\nexport {\n decodeAuthorizationSignature,\n generateEIP7702BatchTransaction,\n updateEIP7702BatchData,\n} from './utils/eip7702.js';\nexport {\n isEIP1559Transaction,\n normalizeTransactionParams,\n} from './utils/utils.js';\nexport { hasTransactionType } from './utils/transaction-type.js';\nexport { getEffectiveRecipient, getSendRecipients } from './utils/recipient.js';\nexport { CHAIN_IDS } from './constants.js';\nexport { HARDFORK } from './utils/prepare.js';\nexport { getAccountAddressRelationship } from './api/accounts-api.js';\nexport type {\n GetAccountAddressRelationshipRequest,\n AccountAddressRelationshipResult,\n} from './api/accounts-api.js';\nexport { generateBatchId } from './utils/batch.js';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ export { mergeGasFeeEstimates } from "./utils/gas-flow.cjs";
|
|
|
7
7
|
export { decodeAuthorizationSignature, generateEIP7702BatchTransaction, updateEIP7702BatchData, } from "./utils/eip7702.cjs";
|
|
8
8
|
export { isEIP1559Transaction, normalizeTransactionParams, } from "./utils/utils.cjs";
|
|
9
9
|
export { hasTransactionType } from "./utils/transaction-type.cjs";
|
|
10
|
-
export { getEffectiveRecipient } from "./utils/recipient.cjs";
|
|
10
|
+
export { getEffectiveRecipient, getSendRecipients } from "./utils/recipient.cjs";
|
|
11
11
|
export { CHAIN_IDS } from "./constants.cjs";
|
|
12
12
|
export { HARDFORK } from "./utils/prepare.cjs";
|
|
13
13
|
export { getAccountAddressRelationship } from "./api/accounts-api.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,MAAM,EACN,4BAA4B,EAC5B,2BAA2B,EAC3B,mCAAmC,EACnC,uDAAuD,EACvD,iDAAiD,EACjD,0BAA0B,EAC1B,qCAAqC,EACrC,6CAA6C,EAC7C,8CAA8C,EAC9C,4CAA4C,EAC5C,2CAA2C,EAC3C,6CAA6C,EAC7C,oDAAoD,EACpD,4CAA4C,EAC5C,iDAAiD,EACjD,6CAA6C,EAC7C,kDAAkD,EAClD,8CAA8C,EAC9C,oDAAoD,EACpD,8BAA8B,EAC9B,4BAA4B,GAC7B,oCAAmC;AACpC,YAAY,EACV,yCAAyC,EACzC,8CAA8C,EAC9C,qDAAqD,EACrD,gDAAgD,EAChD,mDAAmD,EACnD,sCAAsC,EACtC,2CAA2C,EAC3C,0CAA0C,EAC1C,uCAAuC,EACvC,0CAA0C,EAC1C,qDAAqD,EACrD,4CAA4C,EAC5C,oDAAoD,EACpD,2CAA2C,EAC3C,iDAAiD,EACjD,0CAA0C,EAC1C,6CAA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AE,SAAS,EAAE,wBAAuB;AAC3C,OAAO,EAAE,QAAQ,EAAE,4BAA2B;AAC9C,OAAO,EAAE,6BAA6B,EAAE,+BAA8B;AACtE,YAAY,EACV,oCAAoC,EACpC,gCAAgC,GACjC,+BAA8B;AAC/B,OAAO,EAAE,eAAe,EAAE,0BAAyB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ export { mergeGasFeeEstimates } from "./utils/gas-flow.mjs";
|
|
|
7
7
|
export { decodeAuthorizationSignature, generateEIP7702BatchTransaction, updateEIP7702BatchData, } from "./utils/eip7702.mjs";
|
|
8
8
|
export { isEIP1559Transaction, normalizeTransactionParams, } from "./utils/utils.mjs";
|
|
9
9
|
export { hasTransactionType } from "./utils/transaction-type.mjs";
|
|
10
|
-
export { getEffectiveRecipient } from "./utils/recipient.mjs";
|
|
10
|
+
export { getEffectiveRecipient, getSendRecipients } from "./utils/recipient.mjs";
|
|
11
11
|
export { CHAIN_IDS } from "./constants.mjs";
|
|
12
12
|
export { HARDFORK } from "./utils/prepare.mjs";
|
|
13
13
|
export { getAccountAddressRelationship } from "./api/accounts-api.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,MAAM,EACN,4BAA4B,EAC5B,2BAA2B,EAC3B,mCAAmC,EACnC,uDAAuD,EACvD,iDAAiD,EACjD,0BAA0B,EAC1B,qCAAqC,EACrC,6CAA6C,EAC7C,8CAA8C,EAC9C,4CAA4C,EAC5C,2CAA2C,EAC3C,6CAA6C,EAC7C,oDAAoD,EACpD,4CAA4C,EAC5C,iDAAiD,EACjD,6CAA6C,EAC7C,kDAAkD,EAClD,8CAA8C,EAC9C,oDAAoD,EACpD,8BAA8B,EAC9B,4BAA4B,GAC7B,oCAAmC;AACpC,YAAY,EACV,yCAAyC,EACzC,8CAA8C,EA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A4B,EAC5B,+BAA+B,EAC/B,sBAAsB,GACvB,4BAA2B;AAC5B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,0BAAyB;AAC1B,OAAO,EAAE,kBAAkB,EAAE,qCAAoC;AACjE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,8BAA6B;AAChF,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAC3C,OAAO,EAAE,QAAQ,EAAE,4BAA2B;AAC9C,OAAO,EAAE,6BAA6B,EAAE,+BAA8B;AACtE,YAAY,EACV,oCAAoC,EACpC,gCAAgC,GACjC,+BAA8B;AAC/B,OAAO,EAAE,eAAe,EAAE,0BAAyB"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ export { mergeGasFeeEstimates } from "./utils/gas-flow.mjs";
|
|
|
4
4
|
export { decodeAuthorizationSignature, generateEIP7702BatchTransaction, updateEIP7702BatchData } from "./utils/eip7702.mjs";
|
|
5
5
|
export { isEIP1559Transaction, normalizeTransactionParams } from "./utils/utils.mjs";
|
|
6
6
|
export { hasTransactionType } from "./utils/transaction-type.mjs";
|
|
7
|
-
export { getEffectiveRecipient } from "./utils/recipient.mjs";
|
|
7
|
+
export { getEffectiveRecipient, getSendRecipients } from "./utils/recipient.mjs";
|
|
8
8
|
export { CHAIN_IDS } from "./constants.mjs";
|
|
9
9
|
export { HARDFORK } from "./utils/prepare.mjs";
|
|
10
10
|
export { getAccountAddressRelationship } from "./api/accounts-api.mjs";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4DA,OAAO,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,EACtB,oCAAmC;AAwDpC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACb,oBAAmB;AACpB,OAAO,EAAE,oBAAoB,EAAE,6BAA4B;AAC3D,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,sBAAsB,EACvB,4BAA2B;AAC5B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC3B,0BAAyB;AAC1B,OAAO,EAAE,kBAAkB,EAAE,qCAAoC;AACjE,OAAO,EAAE,qBAAqB,EAAE,8BAA6B;
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4DA,OAAO,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,EACtB,oCAAmC;AAwDpC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACb,oBAAmB;AACpB,OAAO,EAAE,oBAAoB,EAAE,6BAA4B;AAC3D,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,sBAAsB,EACvB,4BAA2B;AAC5B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC3B,0BAAyB;AAC1B,OAAO,EAAE,kBAAkB,EAAE,qCAAoC;AACjE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,8BAA6B;AAChF,OAAO,EAAE,SAAS,EAAE,wBAAuB;AAC3C,OAAO,EAAE,QAAQ,EAAE,4BAA2B;AAC9C,OAAO,EAAE,6BAA6B,EAAE,+BAA8B;AAKtE,OAAO,EAAE,eAAe,EAAE,0BAAyB","sourcesContent":["export type {\n MethodData,\n Result,\n TransactionControllerActions,\n TransactionControllerEvents,\n TransactionControllerGetStateAction,\n TransactionControllerPostTransactionBalanceUpdatedEvent,\n TransactionControllerSpeedupTransactionAddedEvent,\n TransactionControllerState,\n TransactionControllerStateChangeEvent,\n TransactionControllerTransactionApprovedEvent,\n TransactionControllerTransactionConfirmedEvent,\n TransactionControllerTransactionDroppedEvent,\n TransactionControllerTransactionFailedEvent,\n TransactionControllerTransactionFinishedEvent,\n TransactionControllerTransactionNewSwapApprovalEvent,\n TransactionControllerTransactionNewSwapEvent,\n TransactionControllerTransactionPublishingSkipped,\n TransactionControllerTransactionRejectedEvent,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerTransactionSubmittedEvent,\n TransactionControllerUnapprovedTransactionAddedEvent,\n TransactionControllerMessenger,\n TransactionControllerOptions,\n} from './TransactionController.js';\nexport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerConfirmExternalTransactionAction,\n TransactionControllerEmulateNewTransactionAction,\n TransactionControllerEmulateTransactionUpdateAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetNonceLockAction,\n TransactionControllerGetTransactionsAction,\n TransactionControllerUpdateCustodialTransactionAction,\n TransactionControllerUpdateTransactionAction,\n TransactionControllerUpdateTransactionMetadataAction,\n TransactionControllerHandleMethodDataAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerStopTransactionAction,\n TransactionControllerSpeedUpTransactionAction,\n TransactionControllerEstimateGasBufferedAction,\n TransactionControllerUpdateEditableParamsAction,\n TransactionControllerSetTransactionActiveAction,\n TransactionControllerApproveTransactionsWithSameNonceAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerFailTransactionAction,\n TransactionControllerGetLayer1GasFeeAction,\n TransactionControllerClearUnapprovedTransactionsAction,\n TransactionControllerAbortTransactionSigningAction,\n TransactionControllerUpdateAtomicBatchDataAction,\n TransactionControllerWipeTransactionsAction,\n TransactionControllerUpdateSecurityAlertResponseAction,\n TransactionControllerUpdateTransactionGasFeesAction,\n TransactionControllerUpdatePreviousGasParamsAction,\n TransactionControllerUpdateSelectedGasFeeTokenAction,\n TransactionControllerUpdateRequiredTransactionIdsAction,\n} from './TransactionController-method-action-types.js';\nexport {\n CANCEL_RATE,\n SPEED_UP_RATE,\n TransactionController,\n} from './TransactionController.js';\nexport type {\n AddTransactionOptions,\n AfterAddHook,\n Authorization,\n AuthorizationList,\n BatchTransaction,\n BatchTransactionParams,\n BeforeSignHook,\n DappSuggestedGasFees,\n DefaultGasEstimates,\n FeeMarketEIP1559Values,\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeToken,\n GasPriceGasFeeEstimates,\n GasPriceValue,\n GetGasFeeTokensRequest,\n GetSimulationConfig,\n InferTransactionTypeResult,\n IsAtomicBatchSupportedRequest,\n IsAtomicBatchSupportedResult,\n IsAtomicBatchSupportedResultEntry,\n LegacyGasFeeEstimates,\n Log,\n MetamaskPayMetadata,\n NestedTransactionMetadata,\n NestedTransactionUpdate,\n PublishBatchHook,\n PublishBatchHookRequest,\n PublishBatchHookResult,\n PublishBatchHookTransaction,\n PublishHook,\n PublishHookResult,\n RequiredAsset,\n SavedGasFees,\n SecurityAlertResponse,\n SendFlowHistoryEntry,\n SimulationBalanceChange,\n SimulationData,\n SimulationError,\n SimulationToken,\n SimulationTokenBalanceChange,\n TransactionBatchMeta,\n TransactionBatchRequest,\n TransactionBatchResult,\n TransactionBatchSingleRequest,\n TransactionError,\n TransactionHistory,\n TransactionHistoryEntry,\n TransactionMeta,\n TransactionParams,\n TransactionReceipt,\n ValidateSecurityRequest,\n} from './types.js';\nexport {\n GasFeeEstimateLevel,\n GasFeeEstimateType,\n SimulationErrorCode,\n SimulationTokenStandard,\n TransactionContainerType,\n TransactionEnvelopeType,\n TransactionStatus,\n TransactionType,\n UserFeeLevel,\n WalletDevice,\n} from './types.js';\nexport { mergeGasFeeEstimates } from './utils/gas-flow.js';\nexport {\n decodeAuthorizationSignature,\n generateEIP7702BatchTransaction,\n updateEIP7702BatchData,\n} from './utils/eip7702.js';\nexport {\n isEIP1559Transaction,\n normalizeTransactionParams,\n} from './utils/utils.js';\nexport { hasTransactionType } from './utils/transaction-type.js';\nexport { getEffectiveRecipient, getSendRecipients } from './utils/recipient.js';\nexport { CHAIN_IDS } from './constants.js';\nexport { HARDFORK } from './utils/prepare.js';\nexport { getAccountAddressRelationship } from './api/accounts-api.js';\nexport type {\n GetAccountAddressRelationshipRequest,\n AccountAddressRelationshipResult,\n} from './api/accounts-api.js';\nexport { generateBatchId } from './utils/batch.js';\n"]}
|
package/dist/utils/recipient.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEffectiveRecipient = void 0;
|
|
3
|
+
exports.getSendRecipients = exports.getEffectiveRecipient = void 0;
|
|
4
4
|
const types_js_1 = require("../types.cjs");
|
|
5
5
|
const transaction_type_js_1 = require("./transaction-type.cjs");
|
|
6
6
|
const TOKEN_TRANSFER_TYPES = [
|
|
@@ -15,6 +15,10 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
15
15
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
16
16
|
* is returned as-is.
|
|
17
17
|
*
|
|
18
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
19
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
20
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
21
|
+
*
|
|
18
22
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
19
23
|
* @returns Effective recipient address, or undefined.
|
|
20
24
|
*/
|
|
@@ -28,4 +32,70 @@ function getEffectiveRecipient(transactionMeta) {
|
|
|
28
32
|
return to;
|
|
29
33
|
}
|
|
30
34
|
exports.getEffectiveRecipient = getEffectiveRecipient;
|
|
35
|
+
/**
|
|
36
|
+
* Returns user-chosen send payees for a transaction.
|
|
37
|
+
*
|
|
38
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
39
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
40
|
+
* dapp-supplied and must not be treated as payees.
|
|
41
|
+
*
|
|
42
|
+
* Included:
|
|
43
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
44
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
45
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
46
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
47
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
48
|
+
*
|
|
49
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
50
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
51
|
+
*/
|
|
52
|
+
function getSendRecipients(transactionMeta) {
|
|
53
|
+
// Swap the whole params object rather than falling back field by field.
|
|
54
|
+
// `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so
|
|
55
|
+
// its `to` and `data` always describe the same call. Mixing an original `to`
|
|
56
|
+
// with a wrapped `data` would misread an untyped transaction as a contract
|
|
57
|
+
// call and drop a real payee.
|
|
58
|
+
const params = transactionMeta.txParamsOriginal ?? transactionMeta.txParams;
|
|
59
|
+
const recipients = [];
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
const addRecipient = (address) => {
|
|
62
|
+
const normalized = address?.toLowerCase();
|
|
63
|
+
if (!address || !normalized || seen.has(normalized)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
seen.add(normalized);
|
|
67
|
+
recipients.push(address);
|
|
68
|
+
};
|
|
69
|
+
addRecipient(getSendRecipientFromSource({
|
|
70
|
+
data: params?.data,
|
|
71
|
+
to: params?.to,
|
|
72
|
+
type: transactionMeta.type,
|
|
73
|
+
}));
|
|
74
|
+
addRecipient(transactionMeta.swapAndSendRecipient);
|
|
75
|
+
for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {
|
|
76
|
+
addRecipient(getSendRecipientFromSource(nestedTransaction));
|
|
77
|
+
}
|
|
78
|
+
return recipients;
|
|
79
|
+
}
|
|
80
|
+
exports.getSendRecipients = getSendRecipients;
|
|
81
|
+
function getSendRecipientFromSource({ data, to, type, }) {
|
|
82
|
+
if (isNativeSendType(type, data)) {
|
|
83
|
+
return to;
|
|
84
|
+
}
|
|
85
|
+
if (type && TOKEN_TRANSFER_TYPES.includes(type) && hasCalldata(data)) {
|
|
86
|
+
return decodeTokenTransferRecipient(data);
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function isNativeSendType(type, data) {
|
|
91
|
+
return (type === types_js_1.TransactionType.simpleSend ||
|
|
92
|
+
(type === undefined && !hasCalldata(data)));
|
|
93
|
+
}
|
|
94
|
+
function hasCalldata(data) {
|
|
95
|
+
return Boolean(data && data !== '0x');
|
|
96
|
+
}
|
|
97
|
+
function decodeTokenTransferRecipient(data) {
|
|
98
|
+
const parsed = (0, transaction_type_js_1.decodeTransactionData)(data);
|
|
99
|
+
return (parsed?.args?._to ?? parsed?.args?.to);
|
|
100
|
+
}
|
|
31
101
|
//# sourceMappingURL=recipient.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient.cjs","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAE9C,gEAA8D;AAE9D,MAAM,oBAAoB,GAAG;IAC3B,0BAAe,CAAC,mBAAmB;IACnC,0BAAe,CAAC,uBAAuB;IACvC,0BAAe,CAAC,2BAA2B;CAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"recipient.cjs","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAE9C,gEAA8D;AAE9D,MAAM,oBAAoB,GAAG;IAC3B,0BAAe,CAAC,mBAAmB;IACnC,0BAAe,CAAC,uBAAuB;IACvC,0BAAe,CAAC,2BAA2B;CAC5C,CAAC;AAQF;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CACnC,eAAgC;IAEhC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAA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AM,iBAAiB,IAAI,eAAe,CAAC,kBAAkB,IAAI,EAAE,EAAE,CAAC;QACzE,YAAY,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAjCD,8CAiCC;AAED,SAAS,0BAA0B,CAAC,EAClC,IAAI,EACJ,EAAE,EACF,IAAI,GACgB;IACpB,IAAI,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,IAAI,IAAI,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAiC,EACjC,IAAa;IAEb,OAAO,CACL,IAAI,KAAK,0BAAe,CAAC,UAAU;QACnC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC3C,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,OAAO,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,MAAM,MAAM,GAAG,IAAA,2CAAqB,EAAC,IAAI,CAE5B,CAAC;IACd,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,CAAuB,CAAC;AACvE,CAAC","sourcesContent":["import type { TransactionDescription } from '@ethersproject/abi';\n\nimport { TransactionType } from '../types.js';\nimport type { TransactionMeta } from '../types.js';\nimport { decodeTransactionData } from './transaction-type.js';\n\nconst TOKEN_TRANSFER_TYPES = [\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.tokenMethodSafeTransferFrom,\n];\n\ntype SendRecipientSource = {\n data?: string;\n to?: string;\n type?: TransactionType;\n};\n\n/**\n * Returns the effective recipient of a transaction.\n * For ERC-20/ERC-721/ERC-1155 token transfer methods, the recipient is decoded\n * from the calldata since `txParams.to` is the token contract rather than the\n * address receiving the tokens. For all other transaction types, `txParams.to`\n * is returned as-is.\n *\n * Address poisoning should use {@link getSendRecipients} instead. This helper\n * is for first-time interaction and similar \"who are we calling\" checks, where\n * the contract `to` is the right address for approves and contract calls.\n *\n * @param transactionMeta - Transaction meta with txParams and type.\n * @returns Effective recipient address, or undefined.\n */\nexport function getEffectiveRecipient(\n transactionMeta: TransactionMeta,\n): string | undefined {\n const { data, to } = transactionMeta?.txParams ?? {};\n if (\n data &&\n TOKEN_TRANSFER_TYPES.includes(transactionMeta?.type as TransactionType)\n ) {\n const parsed = decodeTransactionData(data) as TransactionDescription;\n return (parsed?.args?._to ?? parsed?.args?.to ?? to) as string | undefined;\n }\n return to;\n}\n\n/**\n * Returns user-chosen send payees for a transaction.\n *\n * Address poisoning compares a candidate against prior recipients the user\n * actually sent to. Protocol addresses (token, Permit2, router, spender) are\n * dapp-supplied and must not be treated as payees.\n *\n * Included:\n * - `simpleSend` `to`, preferring `txParamsOriginal` when present\n * - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods\n * - `swapAndSendRecipient` whenever set (only ever a user-entered payee)\n * - Nested batch calls that themselves are sends or token transfers\n * - Untyped transactions with no calldata, treated as legacy native sends\n *\n * @param transactionMeta - Transaction meta with txParams and type.\n * @returns Deduplicated send recipient addresses, possibly empty.\n */\nexport function getSendRecipients(transactionMeta: TransactionMeta): string[] {\n // Swap the whole params object rather than falling back field by field.\n // `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so\n // its `to` and `data` always describe the same call. Mixing an original `to`\n // with a wrapped `data` would misread an untyped transaction as a contract\n // call and drop a real payee.\n const params = transactionMeta.txParamsOriginal ?? transactionMeta.txParams;\n const recipients: string[] = [];\n const seen = new Set<string>();\n\n const addRecipient = (address?: string): void => {\n const normalized = address?.toLowerCase();\n if (!address || !normalized || seen.has(normalized)) {\n return;\n }\n seen.add(normalized);\n recipients.push(address);\n };\n\n addRecipient(\n getSendRecipientFromSource({\n data: params?.data,\n to: params?.to,\n type: transactionMeta.type,\n }),\n );\n addRecipient(transactionMeta.swapAndSendRecipient);\n\n for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {\n addRecipient(getSendRecipientFromSource(nestedTransaction));\n }\n\n return recipients;\n}\n\nfunction getSendRecipientFromSource({\n data,\n to,\n type,\n}: SendRecipientSource): string | undefined {\n if (isNativeSendType(type, data)) {\n return to;\n }\n\n if (type && TOKEN_TRANSFER_TYPES.includes(type) && hasCalldata(data)) {\n return decodeTokenTransferRecipient(data);\n }\n\n return undefined;\n}\n\nfunction isNativeSendType(\n type: TransactionType | undefined,\n data?: string,\n): boolean {\n return (\n type === TransactionType.simpleSend ||\n (type === undefined && !hasCalldata(data))\n );\n}\n\nfunction hasCalldata(data?: string): data is string {\n return Boolean(data && data !== '0x');\n}\n\nfunction decodeTokenTransferRecipient(data: string): string | undefined {\n const parsed = decodeTransactionData(data) as\n | TransactionDescription\n | undefined;\n return (parsed?.args?._to ?? parsed?.args?.to) as string | undefined;\n}\n"]}
|
|
@@ -6,8 +6,30 @@ import type { TransactionMeta } from "../types.cjs";
|
|
|
6
6
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
7
7
|
* is returned as-is.
|
|
8
8
|
*
|
|
9
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
10
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
11
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
12
|
+
*
|
|
9
13
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
10
14
|
* @returns Effective recipient address, or undefined.
|
|
11
15
|
*/
|
|
12
16
|
export declare function getEffectiveRecipient(transactionMeta: TransactionMeta): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns user-chosen send payees for a transaction.
|
|
19
|
+
*
|
|
20
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
21
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
22
|
+
* dapp-supplied and must not be treated as payees.
|
|
23
|
+
*
|
|
24
|
+
* Included:
|
|
25
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
26
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
27
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
28
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
29
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
30
|
+
*
|
|
31
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
32
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSendRecipients(transactionMeta: TransactionMeta): string[];
|
|
13
35
|
//# sourceMappingURL=recipient.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient.d.cts","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;
|
|
1
|
+
{"version":3,"file":"recipient.d.cts","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;AAenD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,GAC/B,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,EAAE,CAiC5E"}
|
|
@@ -6,8 +6,30 @@ import type { TransactionMeta } from "../types.mjs";
|
|
|
6
6
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
7
7
|
* is returned as-is.
|
|
8
8
|
*
|
|
9
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
10
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
11
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
12
|
+
*
|
|
9
13
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
10
14
|
* @returns Effective recipient address, or undefined.
|
|
11
15
|
*/
|
|
12
16
|
export declare function getEffectiveRecipient(transactionMeta: TransactionMeta): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns user-chosen send payees for a transaction.
|
|
19
|
+
*
|
|
20
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
21
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
22
|
+
* dapp-supplied and must not be treated as payees.
|
|
23
|
+
*
|
|
24
|
+
* Included:
|
|
25
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
26
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
27
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
28
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
29
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
30
|
+
*
|
|
31
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
32
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSendRecipients(transactionMeta: TransactionMeta): string[];
|
|
13
35
|
//# sourceMappingURL=recipient.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient.d.mts","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;
|
|
1
|
+
{"version":3,"file":"recipient.d.mts","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;AAenD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,GAC/B,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,EAAE,CAiC5E"}
|
package/dist/utils/recipient.mjs
CHANGED
|
@@ -12,6 +12,10 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
12
12
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
13
13
|
* is returned as-is.
|
|
14
14
|
*
|
|
15
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
16
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
17
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
18
|
+
*
|
|
15
19
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
16
20
|
* @returns Effective recipient address, or undefined.
|
|
17
21
|
*/
|
|
@@ -24,4 +28,69 @@ export function getEffectiveRecipient(transactionMeta) {
|
|
|
24
28
|
}
|
|
25
29
|
return to;
|
|
26
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns user-chosen send payees for a transaction.
|
|
33
|
+
*
|
|
34
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
35
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
36
|
+
* dapp-supplied and must not be treated as payees.
|
|
37
|
+
*
|
|
38
|
+
* Included:
|
|
39
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
40
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
41
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
42
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
43
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
44
|
+
*
|
|
45
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
46
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
47
|
+
*/
|
|
48
|
+
export function getSendRecipients(transactionMeta) {
|
|
49
|
+
// Swap the whole params object rather than falling back field by field.
|
|
50
|
+
// `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so
|
|
51
|
+
// its `to` and `data` always describe the same call. Mixing an original `to`
|
|
52
|
+
// with a wrapped `data` would misread an untyped transaction as a contract
|
|
53
|
+
// call and drop a real payee.
|
|
54
|
+
const params = transactionMeta.txParamsOriginal ?? transactionMeta.txParams;
|
|
55
|
+
const recipients = [];
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
const addRecipient = (address) => {
|
|
58
|
+
const normalized = address?.toLowerCase();
|
|
59
|
+
if (!address || !normalized || seen.has(normalized)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
seen.add(normalized);
|
|
63
|
+
recipients.push(address);
|
|
64
|
+
};
|
|
65
|
+
addRecipient(getSendRecipientFromSource({
|
|
66
|
+
data: params?.data,
|
|
67
|
+
to: params?.to,
|
|
68
|
+
type: transactionMeta.type,
|
|
69
|
+
}));
|
|
70
|
+
addRecipient(transactionMeta.swapAndSendRecipient);
|
|
71
|
+
for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {
|
|
72
|
+
addRecipient(getSendRecipientFromSource(nestedTransaction));
|
|
73
|
+
}
|
|
74
|
+
return recipients;
|
|
75
|
+
}
|
|
76
|
+
function getSendRecipientFromSource({ data, to, type, }) {
|
|
77
|
+
if (isNativeSendType(type, data)) {
|
|
78
|
+
return to;
|
|
79
|
+
}
|
|
80
|
+
if (type && TOKEN_TRANSFER_TYPES.includes(type) && hasCalldata(data)) {
|
|
81
|
+
return decodeTokenTransferRecipient(data);
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
function isNativeSendType(type, data) {
|
|
86
|
+
return (type === TransactionType.simpleSend ||
|
|
87
|
+
(type === undefined && !hasCalldata(data)));
|
|
88
|
+
}
|
|
89
|
+
function hasCalldata(data) {
|
|
90
|
+
return Boolean(data && data !== '0x');
|
|
91
|
+
}
|
|
92
|
+
function decodeTokenTransferRecipient(data) {
|
|
93
|
+
const parsed = decodeTransactionData(data);
|
|
94
|
+
return (parsed?.args?._to ?? parsed?.args?.to);
|
|
95
|
+
}
|
|
27
96
|
//# sourceMappingURL=recipient.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient.mjs","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,qBAAoB;AAE9C,OAAO,EAAE,qBAAqB,EAAE,+BAA8B;AAE9D,MAAM,oBAAoB,GAAG;IAC3B,eAAe,CAAC,mBAAmB;IACnC,eAAe,CAAC,uBAAuB;IACvC,eAAe,CAAC,2BAA2B;CAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"recipient.mjs","sourceRoot":"","sources":["../../src/utils/recipient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,qBAAoB;AAE9C,OAAO,EAAE,qBAAqB,EAAE,+BAA8B;AAE9D,MAAM,oBAAoB,GAAG;IAC3B,eAAe,CAAC,mBAAmB;IACnC,eAAe,CAAC,uBAAuB;IACvC,eAAe,CAAC,2BAA2B;CAC5C,CAAC;AAQF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CACnC,eAAgC;IAEhC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,eAAe,EAAE,QAAQ,IAAI,EAAE,CAAC;IACrD,IACE,IAAI;QACJ,oBAAoB,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAuB,CAAC,EACvE,CAAC;QACD,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAA2B,CAAC;QACrE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAuB,CAAC;IAC7E,CAAC;I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IACZ,CAAC;IAED,IAAI,IAAI,IAAI,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAiC,EACjC,IAAa;IAEb,OAAO,CACL,IAAI,KAAK,eAAe,CAAC,UAAU;QACnC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC3C,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,OAAO,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAY;IAChD,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAE5B,CAAC;IACd,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,CAAuB,CAAC;AACvE,CAAC","sourcesContent":["import type { TransactionDescription } from '@ethersproject/abi';\n\nimport { TransactionType } from '../types.js';\nimport type { TransactionMeta } from '../types.js';\nimport { decodeTransactionData } from './transaction-type.js';\n\nconst TOKEN_TRANSFER_TYPES = [\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.tokenMethodSafeTransferFrom,\n];\n\ntype SendRecipientSource = {\n data?: string;\n to?: string;\n type?: TransactionType;\n};\n\n/**\n * Returns the effective recipient of a transaction.\n * For ERC-20/ERC-721/ERC-1155 token transfer methods, the recipient is decoded\n * from the calldata since `txParams.to` is the token contract rather than the\n * address receiving the tokens. For all other transaction types, `txParams.to`\n * is returned as-is.\n *\n * Address poisoning should use {@link getSendRecipients} instead. This helper\n * is for first-time interaction and similar \"who are we calling\" checks, where\n * the contract `to` is the right address for approves and contract calls.\n *\n * @param transactionMeta - Transaction meta with txParams and type.\n * @returns Effective recipient address, or undefined.\n */\nexport function getEffectiveRecipient(\n transactionMeta: TransactionMeta,\n): string | undefined {\n const { data, to } = transactionMeta?.txParams ?? {};\n if (\n data &&\n TOKEN_TRANSFER_TYPES.includes(transactionMeta?.type as TransactionType)\n ) {\n const parsed = decodeTransactionData(data) as TransactionDescription;\n return (parsed?.args?._to ?? parsed?.args?.to ?? to) as string | undefined;\n }\n return to;\n}\n\n/**\n * Returns user-chosen send payees for a transaction.\n *\n * Address poisoning compares a candidate against prior recipients the user\n * actually sent to. Protocol addresses (token, Permit2, router, spender) are\n * dapp-supplied and must not be treated as payees.\n *\n * Included:\n * - `simpleSend` `to`, preferring `txParamsOriginal` when present\n * - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods\n * - `swapAndSendRecipient` whenever set (only ever a user-entered payee)\n * - Nested batch calls that themselves are sends or token transfers\n * - Untyped transactions with no calldata, treated as legacy native sends\n *\n * @param transactionMeta - Transaction meta with txParams and type.\n * @returns Deduplicated send recipient addresses, possibly empty.\n */\nexport function getSendRecipients(transactionMeta: TransactionMeta): string[] {\n // Swap the whole params object rather than falling back field by field.\n // `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so\n // its `to` and `data` always describe the same call. Mixing an original `to`\n // with a wrapped `data` would misread an untyped transaction as a contract\n // call and drop a real payee.\n const params = transactionMeta.txParamsOriginal ?? transactionMeta.txParams;\n const recipients: string[] = [];\n const seen = new Set<string>();\n\n const addRecipient = (address?: string): void => {\n const normalized = address?.toLowerCase();\n if (!address || !normalized || seen.has(normalized)) {\n return;\n }\n seen.add(normalized);\n recipients.push(address);\n };\n\n addRecipient(\n getSendRecipientFromSource({\n data: params?.data,\n to: params?.to,\n type: transactionMeta.type,\n }),\n );\n addRecipient(transactionMeta.swapAndSendRecipient);\n\n for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {\n addRecipient(getSendRecipientFromSource(nestedTransaction));\n }\n\n return recipients;\n}\n\nfunction getSendRecipientFromSource({\n data,\n to,\n type,\n}: SendRecipientSource): string | undefined {\n if (isNativeSendType(type, data)) {\n return to;\n }\n\n if (type && TOKEN_TRANSFER_TYPES.includes(type) && hasCalldata(data)) {\n return decodeTokenTransferRecipient(data);\n }\n\n return undefined;\n}\n\nfunction isNativeSendType(\n type: TransactionType | undefined,\n data?: string,\n): boolean {\n return (\n type === TransactionType.simpleSend ||\n (type === undefined && !hasCalldata(data))\n );\n}\n\nfunction hasCalldata(data?: string): data is string {\n return Boolean(data && data !== '0x');\n}\n\nfunction decodeTokenTransferRecipient(data: string): string | undefined {\n const parsed = decodeTransactionData(data) as\n | TransactionDescription\n | undefined;\n return (parsed?.args?._to ?? parsed?.args?.to) as string | undefined;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/transaction-controller",
|
|
3
|
-
"version": "69.6.1-preview-
|
|
3
|
+
"version": "69.6.1-preview-878689a26",
|
|
4
4
|
"description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|