@metamask-previews/transaction-controller 69.7.0-preview-a302de5c3 → 69.8.0-preview-e12b5ece6
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 +12 -1
- 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 +132 -1
- package/dist/utils/recipient.cjs.map +1 -1
- package/dist/utils/recipient.d.cts +33 -0
- package/dist/utils/recipient.d.cts.map +1 -1
- package/dist/utils/recipient.d.mts +33 -0
- package/dist/utils/recipient.d.mts.map +1 -1
- package/dist/utils/recipient.mjs +130 -0
- package/dist/utils/recipient.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [69.8.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Export `getSendRecipients`, which returns user-chosen send payees for a transaction (native `simpleSend` recipients, decoded ERC-20/721/1155 transfer payees including ERC-1155 batch transfers, `swapAndSendRecipient`, and nested batch sends) and omits protocol addresses such as token, Permit2, and router contracts ([#9943](https://github.com/MetaMask/core/pull/9943))
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
|
|
19
|
+
|
|
10
20
|
## [69.7.0]
|
|
11
21
|
|
|
12
22
|
### Added
|
|
@@ -2707,7 +2717,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
2707
2717
|
|
|
2708
2718
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
2709
2719
|
|
|
2710
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.
|
|
2720
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.8.0...HEAD
|
|
2721
|
+
[69.8.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.7.0...@metamask/transaction-controller@69.8.0
|
|
2711
2722
|
[69.7.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.6.1...@metamask/transaction-controller@69.7.0
|
|
2712
2723
|
[69.6.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.6.0...@metamask/transaction-controller@69.6.1
|
|
2713
2724
|
[69.6.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@69.5.2...@metamask/transaction-controller@69.6.0
|
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,mBAA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;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,6CAA6C,EAC7C,8CAA8C,EAC9C,+CAA+C,EAC/C,+CAA+C,EAC/C,2DAA2D,EAC3D,yCAAyC,EACzC,0CAA0C,EAC1C,0CAA0C,EAC1C,sDAAsD,EACtD,kDAAkD,EAClD,gDAAgD,EAChD,2CAA2C,EAC3C,sDAAsD,EACtD,mDAAmD,EACnD,kDAAkD,EAClD,oDAAoD,EACpD,uDAAuD,GACxD,wDAAuD;AACxD,OAAO,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,GACtB,oCAAmC;AACpC,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACrB,GAAG,EACH,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,oBAAmB;AACpB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,GACb,oBAAmB;AACpB,OAAO,EAAE,oBAAoB,EAAE,6BAA4B;AAC3D,OAAO,EACL,4BAA4B,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,8BAA6B;
|
|
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,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AAiB,EACjB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,oBAAmB;AACpB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,GACb,oBAAmB;AACpB,OAAO,EAAE,oBAAoB,EAAE,6BAA4B;AAC3D,OAAO,EACL,4BAA4B,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.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,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,6CAA6C,EAC7C,8CAA8C,EAC9C,+CAA+C,EAC/C,+CAA+C,EAC/C,2DAA2D,EAC3D,yCAAyC,EACzC,0CAA0C,EAC1C,0CAA0C,EAC1C,sDAAsD,EACtD,kDAAkD,EAClD,gDAAgD,EAChD,2CAA2C,EAC3C,sDAAsD,EACtD,mDAAmD,EACnD,kDAAkD,EAClD,oDAAoD,EACpD,uDAAuD,GACxD,wDAAuD;AACxD,OAAO,EACL,WAAW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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 = [
|
|
@@ -8,6 +8,7 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
8
8
|
types_js_1.TransactionType.tokenMethodTransferFrom,
|
|
9
9
|
types_js_1.TransactionType.tokenMethodSafeTransferFrom,
|
|
10
10
|
];
|
|
11
|
+
const ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR = '0x2eb2c2d6';
|
|
11
12
|
/**
|
|
12
13
|
* Returns the effective recipient of a transaction.
|
|
13
14
|
* For ERC-20/ERC-721/ERC-1155 token transfer methods, the recipient is decoded
|
|
@@ -15,6 +16,10 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
15
16
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
16
17
|
* is returned as-is.
|
|
17
18
|
*
|
|
19
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
20
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
21
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
22
|
+
*
|
|
18
23
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
19
24
|
* @returns Effective recipient address, or undefined.
|
|
20
25
|
*/
|
|
@@ -28,4 +33,130 @@ function getEffectiveRecipient(transactionMeta) {
|
|
|
28
33
|
return to;
|
|
29
34
|
}
|
|
30
35
|
exports.getEffectiveRecipient = getEffectiveRecipient;
|
|
36
|
+
/**
|
|
37
|
+
* Returns user-chosen send payees for a transaction.
|
|
38
|
+
*
|
|
39
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
40
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
41
|
+
* dapp-supplied and must not be treated as payees.
|
|
42
|
+
*
|
|
43
|
+
* Included:
|
|
44
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
45
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
46
|
+
* - Decoded `to` for ERC-1155 `safeBatchTransferFrom`
|
|
47
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
48
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
49
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
50
|
+
* - Speed-up transactions (`type: retry`), classified using `originalType`,
|
|
51
|
+
* since `txParams` are otherwise unchanged from the transaction being sped
|
|
52
|
+
* up.
|
|
53
|
+
* - Cancellations and retries of cancellations return no payees. Their
|
|
54
|
+
* original params, nested transactions, and swap-and-send recipient can
|
|
55
|
+
* remain on the metadata even though none of those sends executed.
|
|
56
|
+
* - A native transfer with no calldata to an address that happens to be a
|
|
57
|
+
* contract. `determineTransactionType` only returns `simpleSend` when `to`
|
|
58
|
+
* is not a contract, so these are typed `contractInteraction` even though
|
|
59
|
+
* the user chose that address as a plain payee.
|
|
60
|
+
*
|
|
61
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
62
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
63
|
+
*/
|
|
64
|
+
function getSendRecipients(transactionMeta) {
|
|
65
|
+
if (isCancellation(transactionMeta)) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
// Swap the whole params object rather than falling back field by field.
|
|
69
|
+
// `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so
|
|
70
|
+
// its `to` and `data` always describe the same call. Mixing an original `to`
|
|
71
|
+
// with a wrapped `data` would misread an untyped transaction as a contract
|
|
72
|
+
// call and drop a real payee.
|
|
73
|
+
const originalParams = transactionMeta.txParamsOriginal;
|
|
74
|
+
const params = originalParams ?? transactionMeta.txParams;
|
|
75
|
+
const recipients = [];
|
|
76
|
+
const seen = new Set();
|
|
77
|
+
const addRecipient = (address) => {
|
|
78
|
+
const normalized = address?.toLowerCase();
|
|
79
|
+
if (!address || !normalized || seen.has(normalized)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
seen.add(normalized);
|
|
83
|
+
recipients.push(address);
|
|
84
|
+
};
|
|
85
|
+
addRecipient(getSendRecipientFromSource({
|
|
86
|
+
data: params?.data,
|
|
87
|
+
inferTransferType: Boolean(originalParams),
|
|
88
|
+
to: params?.to,
|
|
89
|
+
type: getEffectiveType(transactionMeta.type, transactionMeta.originalType),
|
|
90
|
+
}));
|
|
91
|
+
addRecipient(transactionMeta.swapAndSendRecipient);
|
|
92
|
+
for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {
|
|
93
|
+
addRecipient(getSendRecipientFromSource(nestedTransaction));
|
|
94
|
+
}
|
|
95
|
+
return recipients;
|
|
96
|
+
}
|
|
97
|
+
exports.getSendRecipients = getSendRecipients;
|
|
98
|
+
function isCancellation({ type, originalType, }) {
|
|
99
|
+
return (type === types_js_1.TransactionType.cancel ||
|
|
100
|
+
(type === types_js_1.TransactionType.retry && originalType === types_js_1.TransactionType.cancel));
|
|
101
|
+
}
|
|
102
|
+
function getSendRecipientFromSource({ data, inferTransferType, to, type, }) {
|
|
103
|
+
if (isNativeSendType(type, data)) {
|
|
104
|
+
return to;
|
|
105
|
+
}
|
|
106
|
+
if (!hasCalldata(data)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
// Wrapping can replace the current type while preserving the original
|
|
110
|
+
// calldata without its original type. Infer only for original params so
|
|
111
|
+
// ordinary contract interactions remain excluded.
|
|
112
|
+
const inferredType = inferTransferType
|
|
113
|
+
? (0, transaction_type_js_1.decodeTransactionData)(data, {
|
|
114
|
+
getMethodName: true,
|
|
115
|
+
})
|
|
116
|
+
: undefined;
|
|
117
|
+
if (isTokenTransferType(type) || isTokenTransferType(inferredType)) {
|
|
118
|
+
return decodeTokenTransferRecipient(data);
|
|
119
|
+
}
|
|
120
|
+
if (data.slice(0, 10).toLowerCase() ===
|
|
121
|
+
ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR) {
|
|
122
|
+
return decodeTokenTransferRecipient(data);
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
function isTokenTransferType(type) {
|
|
127
|
+
return Boolean(type &&
|
|
128
|
+
TOKEN_TRANSFER_TYPES.some((transferType) => transferType.toLowerCase() === type.toLowerCase()));
|
|
129
|
+
}
|
|
130
|
+
function isNativeSendType(type, data) {
|
|
131
|
+
if (type === types_js_1.TransactionType.simpleSend) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return (!hasCalldata(data) &&
|
|
135
|
+
(type === undefined || type === types_js_1.TransactionType.contractInteraction));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Resolves the type used to classify a transaction as a send.
|
|
139
|
+
*
|
|
140
|
+
* Speed-up transactions keep the original `txParams`, so they should be
|
|
141
|
+
* classified by what they originally were, not by `retry`. Cancellations
|
|
142
|
+
* overwrite `to`/`data` into a self-send, so `originalType` would misclassify
|
|
143
|
+
* them; `type` is returned unchanged instead.
|
|
144
|
+
*
|
|
145
|
+
* @param type - The transaction's own type.
|
|
146
|
+
* @param originalType - The type before a speed-up replaced it, if any.
|
|
147
|
+
* @returns The type to use when classifying the transaction as a send.
|
|
148
|
+
*/
|
|
149
|
+
function getEffectiveType(type, originalType) {
|
|
150
|
+
if (type === types_js_1.TransactionType.retry && originalType) {
|
|
151
|
+
return originalType;
|
|
152
|
+
}
|
|
153
|
+
return type;
|
|
154
|
+
}
|
|
155
|
+
function hasCalldata(data) {
|
|
156
|
+
return Boolean(data && data !== '0x');
|
|
157
|
+
}
|
|
158
|
+
function decodeTokenTransferRecipient(data) {
|
|
159
|
+
const parsed = (0, transaction_type_js_1.decodeTransactionData)(data);
|
|
160
|
+
return (parsed?.args?._to ?? parsed?.args?.to);
|
|
161
|
+
}
|
|
31
162
|
//# 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;AAEF;;;;;;;;;GASG;AACH,SAAgB,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,IAAA,2CAAqB,EAAC,IAAI,CAA2B,CAAC;QACrE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAuB,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAZD,sDAYC","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\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 * @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 | und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O,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,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\nconst ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR = '0x2eb2c2d6';\n\ntype SendRecipientSource = {\n data?: string;\n inferTransferType?: boolean;\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 * - Decoded `to` for ERC-1155 `safeBatchTransferFrom`\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 * - Speed-up transactions (`type: retry`), classified using `originalType`,\n * since `txParams` are otherwise unchanged from the transaction being sped\n * up.\n * - Cancellations and retries of cancellations return no payees. Their\n * original params, nested transactions, and swap-and-send recipient can\n * remain on the metadata even though none of those sends executed.\n * - A native transfer with no calldata to an address that happens to be a\n * contract. `determineTransactionType` only returns `simpleSend` when `to`\n * is not a contract, so these are typed `contractInteraction` even though\n * the user chose that address as a plain payee.\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 if (isCancellation(transactionMeta)) {\n return [];\n }\n\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 originalParams = transactionMeta.txParamsOriginal;\n const params = originalParams ?? 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 inferTransferType: Boolean(originalParams),\n to: params?.to,\n type: getEffectiveType(\n transactionMeta.type,\n transactionMeta.originalType,\n ),\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 isCancellation({\n type,\n originalType,\n}: Pick<TransactionMeta, 'type' | 'originalType'>): boolean {\n return (\n type === TransactionType.cancel ||\n (type === TransactionType.retry && originalType === TransactionType.cancel)\n );\n}\n\nfunction getSendRecipientFromSource({\n data,\n inferTransferType,\n to,\n type,\n}: SendRecipientSource): string | undefined {\n if (isNativeSendType(type, data)) {\n return to;\n }\n\n if (!hasCalldata(data)) {\n return undefined;\n }\n\n // Wrapping can replace the current type while preserving the original\n // calldata without its original type. Infer only for original params so\n // ordinary contract interactions remain excluded.\n const inferredType = inferTransferType\n ? (decodeTransactionData(data, {\n getMethodName: true,\n }) as string | undefined)\n : undefined;\n\n if (isTokenTransferType(type) || isTokenTransferType(inferredType)) {\n return decodeTokenTransferRecipient(data);\n }\n\n if (\n data.slice(0, 10).toLowerCase() ===\n ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR\n ) {\n return decodeTokenTransferRecipient(data);\n }\n\n return undefined;\n}\n\nfunction isTokenTransferType(type?: string): boolean {\n return Boolean(\n type &&\n TOKEN_TRANSFER_TYPES.some(\n (transferType) => transferType.toLowerCase() === type.toLowerCase(),\n ),\n );\n}\n\nfunction isNativeSendType(\n type: TransactionType | undefined,\n data?: string,\n): boolean {\n if (type === TransactionType.simpleSend) {\n return true;\n }\n\n return (\n !hasCalldata(data) &&\n (type === undefined || type === TransactionType.contractInteraction)\n );\n}\n\n/**\n * Resolves the type used to classify a transaction as a send.\n *\n * Speed-up transactions keep the original `txParams`, so they should be\n * classified by what they originally were, not by `retry`. Cancellations\n * overwrite `to`/`data` into a self-send, so `originalType` would misclassify\n * them; `type` is returned unchanged instead.\n *\n * @param type - The transaction's own type.\n * @param originalType - The type before a speed-up replaced it, if any.\n * @returns The type to use when classifying the transaction as a send.\n */\nfunction getEffectiveType(\n type: TransactionType | undefined,\n originalType: TransactionType | undefined,\n): TransactionType | undefined {\n if (type === TransactionType.retry && originalType) {\n return originalType;\n }\n\n return type;\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,41 @@ 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
|
+
* - Decoded `to` for ERC-1155 `safeBatchTransferFrom`
|
|
28
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
29
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
30
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
31
|
+
* - Speed-up transactions (`type: retry`), classified using `originalType`,
|
|
32
|
+
* since `txParams` are otherwise unchanged from the transaction being sped
|
|
33
|
+
* up.
|
|
34
|
+
* - Cancellations and retries of cancellations return no payees. Their
|
|
35
|
+
* original params, nested transactions, and swap-and-send recipient can
|
|
36
|
+
* remain on the metadata even though none of those sends executed.
|
|
37
|
+
* - A native transfer with no calldata to an address that happens to be a
|
|
38
|
+
* contract. `determineTransactionType` only returns `simpleSend` when `to`
|
|
39
|
+
* is not a contract, so these are typed `contractInteraction` even though
|
|
40
|
+
* the user chose that address as a plain payee.
|
|
41
|
+
*
|
|
42
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
43
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSendRecipients(transactionMeta: TransactionMeta): string[];
|
|
13
46
|
//# 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;AAkBnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,GAC/B,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,EAAE,CA0C5E"}
|
|
@@ -6,8 +6,41 @@ 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
|
+
* - Decoded `to` for ERC-1155 `safeBatchTransferFrom`
|
|
28
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
29
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
30
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
31
|
+
* - Speed-up transactions (`type: retry`), classified using `originalType`,
|
|
32
|
+
* since `txParams` are otherwise unchanged from the transaction being sped
|
|
33
|
+
* up.
|
|
34
|
+
* - Cancellations and retries of cancellations return no payees. Their
|
|
35
|
+
* original params, nested transactions, and swap-and-send recipient can
|
|
36
|
+
* remain on the metadata even though none of those sends executed.
|
|
37
|
+
* - A native transfer with no calldata to an address that happens to be a
|
|
38
|
+
* contract. `determineTransactionType` only returns `simpleSend` when `to`
|
|
39
|
+
* is not a contract, so these are typed `contractInteraction` even though
|
|
40
|
+
* the user chose that address as a plain payee.
|
|
41
|
+
*
|
|
42
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
43
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSendRecipients(transactionMeta: TransactionMeta): string[];
|
|
13
46
|
//# 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;AAkBnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,GAC/B,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,EAAE,CA0C5E"}
|
package/dist/utils/recipient.mjs
CHANGED
|
@@ -5,6 +5,7 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
5
5
|
TransactionType.tokenMethodTransferFrom,
|
|
6
6
|
TransactionType.tokenMethodSafeTransferFrom,
|
|
7
7
|
];
|
|
8
|
+
const ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR = '0x2eb2c2d6';
|
|
8
9
|
/**
|
|
9
10
|
* Returns the effective recipient of a transaction.
|
|
10
11
|
* For ERC-20/ERC-721/ERC-1155 token transfer methods, the recipient is decoded
|
|
@@ -12,6 +13,10 @@ const TOKEN_TRANSFER_TYPES = [
|
|
|
12
13
|
* address receiving the tokens. For all other transaction types, `txParams.to`
|
|
13
14
|
* is returned as-is.
|
|
14
15
|
*
|
|
16
|
+
* Address poisoning should use {@link getSendRecipients} instead. This helper
|
|
17
|
+
* is for first-time interaction and similar "who are we calling" checks, where
|
|
18
|
+
* the contract `to` is the right address for approves and contract calls.
|
|
19
|
+
*
|
|
15
20
|
* @param transactionMeta - Transaction meta with txParams and type.
|
|
16
21
|
* @returns Effective recipient address, or undefined.
|
|
17
22
|
*/
|
|
@@ -24,4 +29,129 @@ export function getEffectiveRecipient(transactionMeta) {
|
|
|
24
29
|
}
|
|
25
30
|
return to;
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns user-chosen send payees for a transaction.
|
|
34
|
+
*
|
|
35
|
+
* Address poisoning compares a candidate against prior recipients the user
|
|
36
|
+
* actually sent to. Protocol addresses (token, Permit2, router, spender) are
|
|
37
|
+
* dapp-supplied and must not be treated as payees.
|
|
38
|
+
*
|
|
39
|
+
* Included:
|
|
40
|
+
* - `simpleSend` `to`, preferring `txParamsOriginal` when present
|
|
41
|
+
* - Decoded `to` / `_to` for ERC-20/721/1155 transfer methods
|
|
42
|
+
* - Decoded `to` for ERC-1155 `safeBatchTransferFrom`
|
|
43
|
+
* - `swapAndSendRecipient` whenever set (only ever a user-entered payee)
|
|
44
|
+
* - Nested batch calls that themselves are sends or token transfers
|
|
45
|
+
* - Untyped transactions with no calldata, treated as legacy native sends
|
|
46
|
+
* - Speed-up transactions (`type: retry`), classified using `originalType`,
|
|
47
|
+
* since `txParams` are otherwise unchanged from the transaction being sped
|
|
48
|
+
* up.
|
|
49
|
+
* - Cancellations and retries of cancellations return no payees. Their
|
|
50
|
+
* original params, nested transactions, and swap-and-send recipient can
|
|
51
|
+
* remain on the metadata even though none of those sends executed.
|
|
52
|
+
* - A native transfer with no calldata to an address that happens to be a
|
|
53
|
+
* contract. `determineTransactionType` only returns `simpleSend` when `to`
|
|
54
|
+
* is not a contract, so these are typed `contractInteraction` even though
|
|
55
|
+
* the user chose that address as a plain payee.
|
|
56
|
+
*
|
|
57
|
+
* @param transactionMeta - Transaction meta with txParams and type.
|
|
58
|
+
* @returns Deduplicated send recipient addresses, possibly empty.
|
|
59
|
+
*/
|
|
60
|
+
export function getSendRecipients(transactionMeta) {
|
|
61
|
+
if (isCancellation(transactionMeta)) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
// Swap the whole params object rather than falling back field by field.
|
|
65
|
+
// `txParamsOriginal` is a `cloneDeep` snapshot of the pre-wrapping params, so
|
|
66
|
+
// its `to` and `data` always describe the same call. Mixing an original `to`
|
|
67
|
+
// with a wrapped `data` would misread an untyped transaction as a contract
|
|
68
|
+
// call and drop a real payee.
|
|
69
|
+
const originalParams = transactionMeta.txParamsOriginal;
|
|
70
|
+
const params = originalParams ?? transactionMeta.txParams;
|
|
71
|
+
const recipients = [];
|
|
72
|
+
const seen = new Set();
|
|
73
|
+
const addRecipient = (address) => {
|
|
74
|
+
const normalized = address?.toLowerCase();
|
|
75
|
+
if (!address || !normalized || seen.has(normalized)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
seen.add(normalized);
|
|
79
|
+
recipients.push(address);
|
|
80
|
+
};
|
|
81
|
+
addRecipient(getSendRecipientFromSource({
|
|
82
|
+
data: params?.data,
|
|
83
|
+
inferTransferType: Boolean(originalParams),
|
|
84
|
+
to: params?.to,
|
|
85
|
+
type: getEffectiveType(transactionMeta.type, transactionMeta.originalType),
|
|
86
|
+
}));
|
|
87
|
+
addRecipient(transactionMeta.swapAndSendRecipient);
|
|
88
|
+
for (const nestedTransaction of transactionMeta.nestedTransactions ?? []) {
|
|
89
|
+
addRecipient(getSendRecipientFromSource(nestedTransaction));
|
|
90
|
+
}
|
|
91
|
+
return recipients;
|
|
92
|
+
}
|
|
93
|
+
function isCancellation({ type, originalType, }) {
|
|
94
|
+
return (type === TransactionType.cancel ||
|
|
95
|
+
(type === TransactionType.retry && originalType === TransactionType.cancel));
|
|
96
|
+
}
|
|
97
|
+
function getSendRecipientFromSource({ data, inferTransferType, to, type, }) {
|
|
98
|
+
if (isNativeSendType(type, data)) {
|
|
99
|
+
return to;
|
|
100
|
+
}
|
|
101
|
+
if (!hasCalldata(data)) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
// Wrapping can replace the current type while preserving the original
|
|
105
|
+
// calldata without its original type. Infer only for original params so
|
|
106
|
+
// ordinary contract interactions remain excluded.
|
|
107
|
+
const inferredType = inferTransferType
|
|
108
|
+
? decodeTransactionData(data, {
|
|
109
|
+
getMethodName: true,
|
|
110
|
+
})
|
|
111
|
+
: undefined;
|
|
112
|
+
if (isTokenTransferType(type) || isTokenTransferType(inferredType)) {
|
|
113
|
+
return decodeTokenTransferRecipient(data);
|
|
114
|
+
}
|
|
115
|
+
if (data.slice(0, 10).toLowerCase() ===
|
|
116
|
+
ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR) {
|
|
117
|
+
return decodeTokenTransferRecipient(data);
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
function isTokenTransferType(type) {
|
|
122
|
+
return Boolean(type &&
|
|
123
|
+
TOKEN_TRANSFER_TYPES.some((transferType) => transferType.toLowerCase() === type.toLowerCase()));
|
|
124
|
+
}
|
|
125
|
+
function isNativeSendType(type, data) {
|
|
126
|
+
if (type === TransactionType.simpleSend) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
return (!hasCalldata(data) &&
|
|
130
|
+
(type === undefined || type === TransactionType.contractInteraction));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolves the type used to classify a transaction as a send.
|
|
134
|
+
*
|
|
135
|
+
* Speed-up transactions keep the original `txParams`, so they should be
|
|
136
|
+
* classified by what they originally were, not by `retry`. Cancellations
|
|
137
|
+
* overwrite `to`/`data` into a self-send, so `originalType` would misclassify
|
|
138
|
+
* them; `type` is returned unchanged instead.
|
|
139
|
+
*
|
|
140
|
+
* @param type - The transaction's own type.
|
|
141
|
+
* @param originalType - The type before a speed-up replaced it, if any.
|
|
142
|
+
* @returns The type to use when classifying the transaction as a send.
|
|
143
|
+
*/
|
|
144
|
+
function getEffectiveType(type, originalType) {
|
|
145
|
+
if (type === TransactionType.retry && originalType) {
|
|
146
|
+
return originalType;
|
|
147
|
+
}
|
|
148
|
+
return type;
|
|
149
|
+
}
|
|
150
|
+
function hasCalldata(data) {
|
|
151
|
+
return Boolean(data && data !== '0x');
|
|
152
|
+
}
|
|
153
|
+
function decodeTokenTransferRecipient(data) {
|
|
154
|
+
const parsed = decodeTransactionData(data);
|
|
155
|
+
return (parsed?.args?._to ?? parsed?.args?.to);
|
|
156
|
+
}
|
|
27
157
|
//# 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;AAEF;;;;;;;;;GASG;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;IACD,OAAO,EAAE,CAAC;AACZ,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\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 * @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"]}
|
|
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;AAEF,MAAM,yCAAyC,GAAG,YAAY,CAAC;AAS/D;;;;;;;;;;;;;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;IACD,OAAO,EAAE,CAAC;AACZ,CAA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AAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAiC,EACjC,IAAa;IAEb,IAAI,IAAI,KAAK,eAAe,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,CAAC,WAAW,CAAC,IAAI,CAAC;QAClB,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,eAAe,CAAC,mBAAmB,CAAC,CACrE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,gBAAgB,CACvB,IAAiC,EACjC,YAAyC;IAEzC,IAAI,IAAI,KAAK,eAAe,CAAC,KAAK,IAAI,YAAY,EAAE,CAAC;QACnD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,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\nconst ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR = '0x2eb2c2d6';\n\ntype SendRecipientSource = {\n data?: string;\n inferTransferType?: boolean;\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 * - Decoded `to` for ERC-1155 `safeBatchTransferFrom`\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 * - Speed-up transactions (`type: retry`), classified using `originalType`,\n * since `txParams` are otherwise unchanged from the transaction being sped\n * up.\n * - Cancellations and retries of cancellations return no payees. Their\n * original params, nested transactions, and swap-and-send recipient can\n * remain on the metadata even though none of those sends executed.\n * - A native transfer with no calldata to an address that happens to be a\n * contract. `determineTransactionType` only returns `simpleSend` when `to`\n * is not a contract, so these are typed `contractInteraction` even though\n * the user chose that address as a plain payee.\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 if (isCancellation(transactionMeta)) {\n return [];\n }\n\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 originalParams = transactionMeta.txParamsOriginal;\n const params = originalParams ?? 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 inferTransferType: Boolean(originalParams),\n to: params?.to,\n type: getEffectiveType(\n transactionMeta.type,\n transactionMeta.originalType,\n ),\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 isCancellation({\n type,\n originalType,\n}: Pick<TransactionMeta, 'type' | 'originalType'>): boolean {\n return (\n type === TransactionType.cancel ||\n (type === TransactionType.retry && originalType === TransactionType.cancel)\n );\n}\n\nfunction getSendRecipientFromSource({\n data,\n inferTransferType,\n to,\n type,\n}: SendRecipientSource): string | undefined {\n if (isNativeSendType(type, data)) {\n return to;\n }\n\n if (!hasCalldata(data)) {\n return undefined;\n }\n\n // Wrapping can replace the current type while preserving the original\n // calldata without its original type. Infer only for original params so\n // ordinary contract interactions remain excluded.\n const inferredType = inferTransferType\n ? (decodeTransactionData(data, {\n getMethodName: true,\n }) as string | undefined)\n : undefined;\n\n if (isTokenTransferType(type) || isTokenTransferType(inferredType)) {\n return decodeTokenTransferRecipient(data);\n }\n\n if (\n data.slice(0, 10).toLowerCase() ===\n ERC1155_SAFE_BATCH_TRANSFER_FROM_SELECTOR\n ) {\n return decodeTokenTransferRecipient(data);\n }\n\n return undefined;\n}\n\nfunction isTokenTransferType(type?: string): boolean {\n return Boolean(\n type &&\n TOKEN_TRANSFER_TYPES.some(\n (transferType) => transferType.toLowerCase() === type.toLowerCase(),\n ),\n );\n}\n\nfunction isNativeSendType(\n type: TransactionType | undefined,\n data?: string,\n): boolean {\n if (type === TransactionType.simpleSend) {\n return true;\n }\n\n return (\n !hasCalldata(data) &&\n (type === undefined || type === TransactionType.contractInteraction)\n );\n}\n\n/**\n * Resolves the type used to classify a transaction as a send.\n *\n * Speed-up transactions keep the original `txParams`, so they should be\n * classified by what they originally were, not by `retry`. Cancellations\n * overwrite `to`/`data` into a self-send, so `originalType` would misclassify\n * them; `type` is returned unchanged instead.\n *\n * @param type - The transaction's own type.\n * @param originalType - The type before a speed-up replaced it, if any.\n * @returns The type to use when classifying the transaction as a send.\n */\nfunction getEffectiveType(\n type: TransactionType | undefined,\n originalType: TransactionType | undefined,\n): TransactionType | undefined {\n if (type === TransactionType.retry && originalType) {\n return originalType;\n }\n\n return type;\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.
|
|
3
|
+
"version": "69.8.0-preview-e12b5ece6",
|
|
4
4
|
"description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@metamask/nonce-tracker": "^6.0.0",
|
|
75
75
|
"@metamask/remote-feature-flag-controller": "^6.1.0",
|
|
76
76
|
"@metamask/rpc-errors": "^7.0.2",
|
|
77
|
-
"@metamask/utils": "^11.
|
|
77
|
+
"@metamask/utils": "^11.12.0",
|
|
78
78
|
"async-mutex": "^0.5.0",
|
|
79
79
|
"bignumber.js": "^9.1.2",
|
|
80
80
|
"bn.js": "^5.2.1",
|