-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update transaction controller to v8.0.1 (#8866)
## **Description** This PR aims to update the transaction controller to version 8.0.1. The Approval Controller was also updated on this PR to the version of 3.5.0 and approval controller patched was updated. All the changes are present in this core branch for easy review: patch/mobile-transaction-controller-8-0-1 ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** transactions: https://recordit.co/mpcRkPQElC sign: http://recordit.co/yPI78aEozu ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
Showing
8 changed files
with
2,920 additions
and
4,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts | ||
index 32f61cb..4e4d7a1 100644 | ||
--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts | ||
+++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts | ||
@@ -99,6 +99,12 @@ export declare type AcceptOptions = { | ||
* If false or unspecified, the promise will resolve immediately. | ||
*/ | ||
waitForResult?: boolean; | ||
+ /** | ||
+ * Whether to delete the approval request after a result callback is called. | ||
+ * If false or unspecified, the approval request will be deleted immediately. | ||
+ * Ignored if `waitForResult` is false or unspecified. | ||
+ */ | ||
+ deleteAfterResult?: boolean; | ||
}; | ||
export declare type StartFlowOptions = OptionalField<ApprovalFlow, 'id' | 'loadingText'>; | ||
export declare type EndFlowOptions = Pick<ApprovalFlow, 'id'>; | ||
diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.js b/node_modules/@metamask/approval-controller/dist/ApprovalController.js | ||
index 3709ab3..43c8bb9 100644 | ||
--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.js | ||
+++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.js | ||
@@ -19,7 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
-var _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_deleteApprovalAndGetCallbacks, _ApprovalController_result; | ||
+var _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_getCallbacks, _ApprovalController_result; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ApprovalController = exports.APPROVAL_TYPE_RESULT_SUCCESS = exports.APPROVAL_TYPE_RESULT_ERROR = exports.ORIGIN_METAMASK = void 0; | ||
const base_controller_1 = require("@metamask/base-controller"); | ||
@@ -227,7 +227,12 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { | ||
accept(id, value, options) { | ||
// Safe to cast as the delete method below will throw if the ID is not found | ||
const approval = this.get(id); | ||
- const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id); | ||
+ const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); | ||
+ let requestDeleted = false; | ||
+ if (!(options === null || options === void 0 ? void 0 : options.deleteAfterResult) || !options.waitForResult) { | ||
+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); | ||
+ requestDeleted = true; | ||
+ } | ||
return new Promise((resolve, reject) => { | ||
const resultCallbacks = { | ||
success: (acceptValue) => resolve({ value: acceptValue }), | ||
@@ -245,6 +250,10 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { | ||
if (!(options === null || options === void 0 ? void 0 : options.waitForResult)) { | ||
resolve({ value: undefined }); | ||
} | ||
+ }).finally(() => { | ||
+ if (!requestDeleted) { | ||
+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); | ||
+ } | ||
}); | ||
} | ||
/** | ||
@@ -255,7 +264,9 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { | ||
* @param error - The error to reject the approval promise with. | ||
*/ | ||
reject(id, error) { | ||
- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id).reject(error); | ||
+ const callbacks = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); | ||
+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); | ||
+ callbacks.reject(error); | ||
} | ||
/** | ||
* Rejects and deletes all approval requests. | ||
@@ -441,10 +452,10 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new | ||
draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; | ||
}); | ||
}, _ApprovalController_delete = function _ApprovalController_delete(id) { | ||
+ if (!__classPrivateFieldGet(this, _ApprovalController_approvals, "f").has(id)) { | ||
+ throw new errors_1.ApprovalRequestNotFoundError(id); | ||
+ } | ||
__classPrivateFieldGet(this, _ApprovalController_approvals, "f").delete(id); | ||
- // This method is only called after verifying that the approval with the | ||
- // specified id exists. | ||
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const { origin, type } = this.state.pendingApprovals[id]; | ||
const originMap = __classPrivateFieldGet(this, _ApprovalController_origins, "f").get(origin); | ||
const originTotalCount = this.getApprovalCount({ origin }); | ||
@@ -459,12 +470,11 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new | ||
delete draftState.pendingApprovals[id]; | ||
draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; | ||
}); | ||
-}, _ApprovalController_deleteApprovalAndGetCallbacks = function _ApprovalController_deleteApprovalAndGetCallbacks(id) { | ||
+ }, _ApprovalController_getCallbacks = function _ApprovalController_getCallbacks(id) { | ||
const callbacks = __classPrivateFieldGet(this, _ApprovalController_approvals, "f").get(id); | ||
if (!callbacks) { | ||
throw new errors_1.ApprovalRequestNotFoundError(id); | ||
} | ||
- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); | ||
return callbacks; | ||
}, _ApprovalController_result = function _ApprovalController_result(type, opts, requestData) { | ||
return __awaiter(this, void 0, void 0, function* () { |
Oops, something went wrong.