@metamask-previews/money-account-upgrade-controller 0.0.0-preview-8e9c439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.cjs +7 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.cjs.map +1 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.cts +22 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.cts.map +1 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.mts +22 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.d.mts.map +1 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.mjs +6 -0
- package/dist/MoneyAccountUpgradeController-method-action-types.mjs.map +1 -0
- package/dist/MoneyAccountUpgradeController.cjs +84 -0
- package/dist/MoneyAccountUpgradeController.cjs.map +1 -0
- package/dist/MoneyAccountUpgradeController.d.cts +51 -0
- package/dist/MoneyAccountUpgradeController.d.cts.map +1 -0
- package/dist/MoneyAccountUpgradeController.d.mts +51 -0
- package/dist/MoneyAccountUpgradeController.d.mts.map +1 -0
- package/dist/MoneyAccountUpgradeController.mjs +80 -0
- package/dist/MoneyAccountUpgradeController.mjs.map +1 -0
- package/dist/associate-address.cjs +34 -0
- package/dist/associate-address.cjs.map +1 -0
- package/dist/associate-address.d.cts +15 -0
- package/dist/associate-address.d.cts.map +1 -0
- package/dist/associate-address.d.mts +15 -0
- package/dist/associate-address.d.mts.map +1 -0
- package/dist/associate-address.mjs +31 -0
- package/dist/associate-address.mjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/step.cjs +3 -0
- package/dist/step.cjs.map +1 -0
- package/dist/step.d.cts +29 -0
- package/dist/step.d.cts.map +1 -0
- package/dist/step.d.mts +29 -0
- package/dist/step.d.mts.map +1 -0
- package/dist/step.mjs +2 -0
- package/dist/step.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +27 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +27 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +77 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `MoneyAccountUpgradeController` with `upgradeAccount` method ([#8426](https://github.com/MetaMask/core/pull/8426))
|
|
13
|
+
|
|
14
|
+
[Unreleased]: https://github.com/MetaMask/core/
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/money-account-upgrade-controller`
|
|
2
|
+
|
|
3
|
+
MetaMask Money account upgrade controller.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/money-account-upgrade-controller`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/money-account-upgrade-controller`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController-method-action-types.cjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MoneyAccountUpgradeController } from './MoneyAccountUpgradeController';\n\n/**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step propagates and halts the sequence.\n *\n * @param address - The Money Account address to upgrade.\n */\nexport type MoneyAccountUpgradeControllerUpgradeAccountAction = {\n type: `MoneyAccountUpgradeController:upgradeAccount`;\n handler: MoneyAccountUpgradeController['upgradeAccount'];\n};\n\n/**\n * Union of all MoneyAccountUpgradeController action types.\n */\nexport type MoneyAccountUpgradeControllerMethodActions =\n MoneyAccountUpgradeControllerUpgradeAccountAction;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { MoneyAccountUpgradeController } from "./MoneyAccountUpgradeController.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
8
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
9
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
10
|
+
* step propagates and halts the sequence.
|
|
11
|
+
*
|
|
12
|
+
* @param address - The Money Account address to upgrade.
|
|
13
|
+
*/
|
|
14
|
+
export type MoneyAccountUpgradeControllerUpgradeAccountAction = {
|
|
15
|
+
type: `MoneyAccountUpgradeController:upgradeAccount`;
|
|
16
|
+
handler: MoneyAccountUpgradeController['upgradeAccount'];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Union of all MoneyAccountUpgradeController action types.
|
|
20
|
+
*/
|
|
21
|
+
export type MoneyAccountUpgradeControllerMethodActions = MoneyAccountUpgradeControllerUpgradeAccountAction;
|
|
22
|
+
//# sourceMappingURL=MoneyAccountUpgradeController-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController-method-action-types.d.cts","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,4CAAwC;AAErF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0CAA0C,GACpD,iDAAiD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { MoneyAccountUpgradeController } from "./MoneyAccountUpgradeController.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
8
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
9
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
10
|
+
* step propagates and halts the sequence.
|
|
11
|
+
*
|
|
12
|
+
* @param address - The Money Account address to upgrade.
|
|
13
|
+
*/
|
|
14
|
+
export type MoneyAccountUpgradeControllerUpgradeAccountAction = {
|
|
15
|
+
type: `MoneyAccountUpgradeController:upgradeAccount`;
|
|
16
|
+
handler: MoneyAccountUpgradeController['upgradeAccount'];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Union of all MoneyAccountUpgradeController action types.
|
|
20
|
+
*/
|
|
21
|
+
export type MoneyAccountUpgradeControllerMethodActions = MoneyAccountUpgradeControllerUpgradeAccountAction;
|
|
22
|
+
//# sourceMappingURL=MoneyAccountUpgradeController-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController-method-action-types.d.mts","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,4CAAwC;AAErF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0CAA0C,GACpD,iDAAiD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController-method-action-types.mjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MoneyAccountUpgradeController } from './MoneyAccountUpgradeController';\n\n/**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step propagates and halts the sequence.\n *\n * @param address - The Money Account address to upgrade.\n */\nexport type MoneyAccountUpgradeControllerUpgradeAccountAction = {\n type: `MoneyAccountUpgradeController:upgradeAccount`;\n handler: MoneyAccountUpgradeController['upgradeAccount'];\n};\n\n/**\n * Union of all MoneyAccountUpgradeController action types.\n */\nexport type MoneyAccountUpgradeControllerMethodActions =\n MoneyAccountUpgradeControllerUpgradeAccountAction;\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _MoneyAccountUpgradeController_initialized, _MoneyAccountUpgradeController_steps;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MoneyAccountUpgradeController = exports.controllerName = void 0;
|
|
16
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
const associate_address_1 = require("./associate-address.cjs");
|
|
18
|
+
exports.controllerName = 'MoneyAccountUpgradeController';
|
|
19
|
+
const moneyAccountUpgradeControllerMetadata = {};
|
|
20
|
+
const MESSENGER_EXPOSED_METHODS = ['upgradeAccount'];
|
|
21
|
+
/**
|
|
22
|
+
* Controller that orchestrates the Money Account upgrade sequence.
|
|
23
|
+
*/
|
|
24
|
+
class MoneyAccountUpgradeController extends base_controller_1.BaseController {
|
|
25
|
+
/**
|
|
26
|
+
* Constructor for the MoneyAccountUpgradeController.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The options for constructing the controller.
|
|
29
|
+
* @param options.messenger - The messenger to use for inter-controller communication.
|
|
30
|
+
*/
|
|
31
|
+
constructor({ messenger, }) {
|
|
32
|
+
super({
|
|
33
|
+
messenger,
|
|
34
|
+
metadata: moneyAccountUpgradeControllerMetadata,
|
|
35
|
+
name: exports.controllerName,
|
|
36
|
+
state: {},
|
|
37
|
+
});
|
|
38
|
+
_MoneyAccountUpgradeController_initialized.set(this, void 0);
|
|
39
|
+
_MoneyAccountUpgradeController_steps.set(this, [associate_address_1.associateAddressStep]);
|
|
40
|
+
__classPrivateFieldSet(this, _MoneyAccountUpgradeController_initialized, false, "f");
|
|
41
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fetches service details and validates the controller can operate on the
|
|
45
|
+
* given chain.
|
|
46
|
+
*
|
|
47
|
+
* @param chainId - The chain to initialize for.
|
|
48
|
+
* @param _initConfig - Contract addresses not available from the service details API.
|
|
49
|
+
*/
|
|
50
|
+
async init(chainId, _initConfig) {
|
|
51
|
+
const response = await this.messenger.call('ChompApiService:getServiceDetails', [chainId]);
|
|
52
|
+
const chain = response.chains[chainId];
|
|
53
|
+
if (!chain) {
|
|
54
|
+
throw new Error(`Chain ${chainId} not found in service details response`);
|
|
55
|
+
}
|
|
56
|
+
const { vedaProtocol } = chain.protocol;
|
|
57
|
+
if (!vedaProtocol) {
|
|
58
|
+
throw new Error(`vedaProtocol not found for chain ${chainId} in service details response`);
|
|
59
|
+
}
|
|
60
|
+
if (vedaProtocol.supportedTokens.length === 0) {
|
|
61
|
+
throw new Error(`No supported tokens found for vedaProtocol on chain ${chainId}`);
|
|
62
|
+
}
|
|
63
|
+
__classPrivateFieldSet(this, _MoneyAccountUpgradeController_initialized, true, "f");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
67
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
68
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
69
|
+
* step propagates and halts the sequence.
|
|
70
|
+
*
|
|
71
|
+
* @param address - The Money Account address to upgrade.
|
|
72
|
+
*/
|
|
73
|
+
async upgradeAccount(address) {
|
|
74
|
+
if (!__classPrivateFieldGet(this, _MoneyAccountUpgradeController_initialized, "f")) {
|
|
75
|
+
throw new Error('MoneyAccountUpgradeController must be initialized via init() before upgradeAccount() can be called');
|
|
76
|
+
}
|
|
77
|
+
for (const step of __classPrivateFieldGet(this, _MoneyAccountUpgradeController_steps, "f")) {
|
|
78
|
+
await step.run({ messenger: this.messenger, address });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.MoneyAccountUpgradeController = MoneyAccountUpgradeController;
|
|
83
|
+
_MoneyAccountUpgradeController_initialized = new WeakMap(), _MoneyAccountUpgradeController_steps = new WeakMap();
|
|
84
|
+
//# sourceMappingURL=MoneyAccountUpgradeController.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController.cjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAS3D,+DAA2D;AAK9C,QAAA,cAAc,GAAG,+BAA+B,CAAC;AAI9D,MAAM,qCAAqC,GACzC,EAA8D,CAAC;AAEjE,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAkC9D;;GAEG;AACH,MAAa,6BAA8B,SAAQ,gCAIlD;IAKC;;;;;OAKG;IACH,YAAY,EACV,SAAS,GAGV;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,qCAAqC;YAC/C,IAAI,EAAE,sBAAc;YACpB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;QApBL,6DAAsB;QAEb,+CAAiB,CAAC,wCAAoB,CAAC,EAAC;QAoB/C,uBAAA,IAAI,8CAAgB,KAAK,MAAA,CAAC;QAE1B,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,OAAY,EAAE,WAAuB;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACxC,mCAAmC,EACnC,CAAC,OAAO,CAAC,CACV,CAAC;QAEF,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,wCAAwC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,oCAAoC,OAAO,8BAA8B,CAC1E,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,uDAAuD,OAAO,EAAE,CACjE,CAAC;QACJ,CAAC;QAED,uBAAA,IAAI,8CAAgB,IAAI,MAAA,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAC,OAAY;QAC/B,IAAI,CAAC,uBAAA,IAAI,kDAAa,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,uBAAA,IAAI,4CAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF;AAxFD,sEAwFC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceGetServiceDetailsAction,\n} from '@metamask/chomp-api-service';\nimport type { KeyringControllerSignPersonalMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport { associateAddressStep } from './associate-address';\nimport type { MoneyAccountUpgradeControllerMethodActions } from './MoneyAccountUpgradeController-method-action-types';\nimport type { Step } from './step';\nimport type { InitConfig } from './types';\n\nexport const controllerName = 'MoneyAccountUpgradeController';\n\nexport type MoneyAccountUpgradeControllerState = Record<string, never>;\n\nconst moneyAccountUpgradeControllerMetadata =\n {} satisfies StateMetadata<MoneyAccountUpgradeControllerState>;\n\nconst MESSENGER_EXPOSED_METHODS = ['upgradeAccount'] as const;\n\nexport type MoneyAccountUpgradeControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerActions =\n | MoneyAccountUpgradeControllerGetStateAction\n | MoneyAccountUpgradeControllerMethodActions;\n\ntype AllowedActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceGetServiceDetailsAction\n | KeyringControllerSignPersonalMessageAction;\n\nexport type MoneyAccountUpgradeControllerStateChangedEvent =\n ControllerStateChangedEvent<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerEvents =\n MoneyAccountUpgradeControllerStateChangedEvent;\n\ntype AllowedEvents = never;\n\nexport type MoneyAccountUpgradeControllerMessenger = Messenger<\n typeof controllerName,\n MoneyAccountUpgradeControllerActions | AllowedActions,\n MoneyAccountUpgradeControllerEvents | AllowedEvents\n>;\n\n/**\n * Controller that orchestrates the Money Account upgrade sequence.\n */\nexport class MoneyAccountUpgradeController extends BaseController<\n typeof controllerName,\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerMessenger\n> {\n #initialized: boolean;\n\n readonly #steps: Step[] = [associateAddressStep];\n\n /**\n * Constructor for the MoneyAccountUpgradeController.\n *\n * @param options - The options for constructing the controller.\n * @param options.messenger - The messenger to use for inter-controller communication.\n */\n constructor({\n messenger,\n }: {\n messenger: MoneyAccountUpgradeControllerMessenger;\n }) {\n super({\n messenger,\n metadata: moneyAccountUpgradeControllerMetadata,\n name: controllerName,\n state: {},\n });\n\n this.#initialized = false;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches service details and validates the controller can operate on the\n * given chain.\n *\n * @param chainId - The chain to initialize for.\n * @param _initConfig - Contract addresses not available from the service details API.\n */\n async init(chainId: Hex, _initConfig: InitConfig): Promise<void> {\n const response = await this.messenger.call(\n 'ChompApiService:getServiceDetails',\n [chainId],\n );\n\n const chain = response.chains[chainId];\n if (!chain) {\n throw new Error(`Chain ${chainId} not found in service details response`);\n }\n\n const { vedaProtocol } = chain.protocol;\n if (!vedaProtocol) {\n throw new Error(\n `vedaProtocol not found for chain ${chainId} in service details response`,\n );\n }\n\n if (vedaProtocol.supportedTokens.length === 0) {\n throw new Error(\n `No supported tokens found for vedaProtocol on chain ${chainId}`,\n );\n }\n\n this.#initialized = true;\n }\n\n /**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step propagates and halts the sequence.\n *\n * @param address - The Money Account address to upgrade.\n */\n async upgradeAccount(address: Hex): Promise<void> {\n if (!this.#initialized) {\n throw new Error(\n 'MoneyAccountUpgradeController must be initialized via init() before upgradeAccount() can be called',\n );\n }\n\n for (const step of this.#steps) {\n await step.run({ messenger: this.messenger, address });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangedEvent } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { ChompApiServiceAssociateAddressAction, ChompApiServiceGetServiceDetailsAction } from "@metamask/chomp-api-service";
|
|
4
|
+
import type { KeyringControllerSignPersonalMessageAction } from "@metamask/keyring-controller";
|
|
5
|
+
import type { Messenger } from "@metamask/messenger";
|
|
6
|
+
import type { Hex } from "@metamask/utils";
|
|
7
|
+
import type { MoneyAccountUpgradeControllerMethodActions } from "./MoneyAccountUpgradeController-method-action-types.cjs";
|
|
8
|
+
import type { InitConfig } from "./types.cjs";
|
|
9
|
+
export declare const controllerName = "MoneyAccountUpgradeController";
|
|
10
|
+
export type MoneyAccountUpgradeControllerState = Record<string, never>;
|
|
11
|
+
export type MoneyAccountUpgradeControllerGetStateAction = ControllerGetStateAction<typeof controllerName, MoneyAccountUpgradeControllerState>;
|
|
12
|
+
export type MoneyAccountUpgradeControllerActions = MoneyAccountUpgradeControllerGetStateAction | MoneyAccountUpgradeControllerMethodActions;
|
|
13
|
+
type AllowedActions = ChompApiServiceAssociateAddressAction | ChompApiServiceGetServiceDetailsAction | KeyringControllerSignPersonalMessageAction;
|
|
14
|
+
export type MoneyAccountUpgradeControllerStateChangedEvent = ControllerStateChangedEvent<typeof controllerName, MoneyAccountUpgradeControllerState>;
|
|
15
|
+
export type MoneyAccountUpgradeControllerEvents = MoneyAccountUpgradeControllerStateChangedEvent;
|
|
16
|
+
type AllowedEvents = never;
|
|
17
|
+
export type MoneyAccountUpgradeControllerMessenger = Messenger<typeof controllerName, MoneyAccountUpgradeControllerActions | AllowedActions, MoneyAccountUpgradeControllerEvents | AllowedEvents>;
|
|
18
|
+
/**
|
|
19
|
+
* Controller that orchestrates the Money Account upgrade sequence.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MoneyAccountUpgradeController extends BaseController<typeof controllerName, MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerMessenger> {
|
|
22
|
+
#private;
|
|
23
|
+
/**
|
|
24
|
+
* Constructor for the MoneyAccountUpgradeController.
|
|
25
|
+
*
|
|
26
|
+
* @param options - The options for constructing the controller.
|
|
27
|
+
* @param options.messenger - The messenger to use for inter-controller communication.
|
|
28
|
+
*/
|
|
29
|
+
constructor({ messenger, }: {
|
|
30
|
+
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Fetches service details and validates the controller can operate on the
|
|
34
|
+
* given chain.
|
|
35
|
+
*
|
|
36
|
+
* @param chainId - The chain to initialize for.
|
|
37
|
+
* @param _initConfig - Contract addresses not available from the service details API.
|
|
38
|
+
*/
|
|
39
|
+
init(chainId: Hex, _initConfig: InitConfig): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
42
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
43
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
44
|
+
* step propagates and halts the sequence.
|
|
45
|
+
*
|
|
46
|
+
* @param address - The Money Account address to upgrade.
|
|
47
|
+
*/
|
|
48
|
+
upgradeAccount(address: Hex): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=MoneyAccountUpgradeController.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController.d.cts","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAE5B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,qCAAqC,EACrC,sCAAsC,EACvC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0CAA0C,EAAE,qCAAqC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,0CAA0C,EAAE,gEAA4D;AAEtH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAE1C,eAAO,MAAM,cAAc,kCAAkC,CAAC;AAE9D,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAOvE,MAAM,MAAM,2CAA2C,GACrD,wBAAwB,CACtB,OAAO,cAAc,EACrB,kCAAkC,CACnC,CAAC;AAEJ,MAAM,MAAM,oCAAoC,GAC5C,2CAA2C,GAC3C,0CAA0C,CAAC;AAE/C,KAAK,cAAc,GACf,qCAAqC,GACrC,sCAAsC,GACtC,0CAA0C,CAAC;AAE/C,MAAM,MAAM,8CAA8C,GACxD,2BAA2B,CACzB,OAAO,cAAc,EACrB,kCAAkC,CACnC,CAAC;AAEJ,MAAM,MAAM,mCAAmC,GAC7C,8CAA8C,CAAC;AAEjD,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B,MAAM,MAAM,sCAAsC,GAAG,SAAS,CAC5D,OAAO,cAAc,EACrB,oCAAoC,GAAG,cAAc,EACrD,mCAAmC,GAAG,aAAa,CACpD,CAAC;AAEF;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,cAAc,CAC/D,OAAO,cAAc,EACrB,kCAAkC,EAClC,sCAAsC,CACvC;;IAKC;;;;;OAKG;gBACS,EACV,SAAS,GACV,EAAE;QACD,SAAS,EAAE,sCAAsC,CAAC;KACnD;IAgBD;;;;;;OAMG;IACG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BhE;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAWlD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangedEvent } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { ChompApiServiceAssociateAddressAction, ChompApiServiceGetServiceDetailsAction } from "@metamask/chomp-api-service";
|
|
4
|
+
import type { KeyringControllerSignPersonalMessageAction } from "@metamask/keyring-controller";
|
|
5
|
+
import type { Messenger } from "@metamask/messenger";
|
|
6
|
+
import type { Hex } from "@metamask/utils";
|
|
7
|
+
import type { MoneyAccountUpgradeControllerMethodActions } from "./MoneyAccountUpgradeController-method-action-types.mjs";
|
|
8
|
+
import type { InitConfig } from "./types.mjs";
|
|
9
|
+
export declare const controllerName = "MoneyAccountUpgradeController";
|
|
10
|
+
export type MoneyAccountUpgradeControllerState = Record<string, never>;
|
|
11
|
+
export type MoneyAccountUpgradeControllerGetStateAction = ControllerGetStateAction<typeof controllerName, MoneyAccountUpgradeControllerState>;
|
|
12
|
+
export type MoneyAccountUpgradeControllerActions = MoneyAccountUpgradeControllerGetStateAction | MoneyAccountUpgradeControllerMethodActions;
|
|
13
|
+
type AllowedActions = ChompApiServiceAssociateAddressAction | ChompApiServiceGetServiceDetailsAction | KeyringControllerSignPersonalMessageAction;
|
|
14
|
+
export type MoneyAccountUpgradeControllerStateChangedEvent = ControllerStateChangedEvent<typeof controllerName, MoneyAccountUpgradeControllerState>;
|
|
15
|
+
export type MoneyAccountUpgradeControllerEvents = MoneyAccountUpgradeControllerStateChangedEvent;
|
|
16
|
+
type AllowedEvents = never;
|
|
17
|
+
export type MoneyAccountUpgradeControllerMessenger = Messenger<typeof controllerName, MoneyAccountUpgradeControllerActions | AllowedActions, MoneyAccountUpgradeControllerEvents | AllowedEvents>;
|
|
18
|
+
/**
|
|
19
|
+
* Controller that orchestrates the Money Account upgrade sequence.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MoneyAccountUpgradeController extends BaseController<typeof controllerName, MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerMessenger> {
|
|
22
|
+
#private;
|
|
23
|
+
/**
|
|
24
|
+
* Constructor for the MoneyAccountUpgradeController.
|
|
25
|
+
*
|
|
26
|
+
* @param options - The options for constructing the controller.
|
|
27
|
+
* @param options.messenger - The messenger to use for inter-controller communication.
|
|
28
|
+
*/
|
|
29
|
+
constructor({ messenger, }: {
|
|
30
|
+
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Fetches service details and validates the controller can operate on the
|
|
34
|
+
* given chain.
|
|
35
|
+
*
|
|
36
|
+
* @param chainId - The chain to initialize for.
|
|
37
|
+
* @param _initConfig - Contract addresses not available from the service details API.
|
|
38
|
+
*/
|
|
39
|
+
init(chainId: Hex, _initConfig: InitConfig): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
42
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
43
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
44
|
+
* step propagates and halts the sequence.
|
|
45
|
+
*
|
|
46
|
+
* @param address - The Money Account address to upgrade.
|
|
47
|
+
*/
|
|
48
|
+
upgradeAccount(address: Hex): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=MoneyAccountUpgradeController.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController.d.mts","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAE5B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,qCAAqC,EACrC,sCAAsC,EACvC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0CAA0C,EAAE,qCAAqC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,0CAA0C,EAAE,gEAA4D;AAEtH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAE1C,eAAO,MAAM,cAAc,kCAAkC,CAAC;AAE9D,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAOvE,MAAM,MAAM,2CAA2C,GACrD,wBAAwB,CACtB,OAAO,cAAc,EACrB,kCAAkC,CACnC,CAAC;AAEJ,MAAM,MAAM,oCAAoC,GAC5C,2CAA2C,GAC3C,0CAA0C,CAAC;AAE/C,KAAK,cAAc,GACf,qCAAqC,GACrC,sCAAsC,GACtC,0CAA0C,CAAC;AAE/C,MAAM,MAAM,8CAA8C,GACxD,2BAA2B,CACzB,OAAO,cAAc,EACrB,kCAAkC,CACnC,CAAC;AAEJ,MAAM,MAAM,mCAAmC,GAC7C,8CAA8C,CAAC;AAEjD,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B,MAAM,MAAM,sCAAsC,GAAG,SAAS,CAC5D,OAAO,cAAc,EACrB,oCAAoC,GAAG,cAAc,EACrD,mCAAmC,GAAG,aAAa,CACpD,CAAC;AAEF;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,cAAc,CAC/D,OAAO,cAAc,EACrB,kCAAkC,EAClC,sCAAsC,CACvC;;IAKC;;;;;OAKG;gBACS,EACV,SAAS,GACV,EAAE;QACD,SAAS,EAAE,sCAAsC,CAAC;KACnD;IAgBD;;;;;;OAMG;IACG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BhE;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAWlD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _MoneyAccountUpgradeController_initialized, _MoneyAccountUpgradeController_steps;
|
|
13
|
+
import { BaseController } from "@metamask/base-controller";
|
|
14
|
+
import { associateAddressStep } from "./associate-address.mjs";
|
|
15
|
+
export const controllerName = 'MoneyAccountUpgradeController';
|
|
16
|
+
const moneyAccountUpgradeControllerMetadata = {};
|
|
17
|
+
const MESSENGER_EXPOSED_METHODS = ['upgradeAccount'];
|
|
18
|
+
/**
|
|
19
|
+
* Controller that orchestrates the Money Account upgrade sequence.
|
|
20
|
+
*/
|
|
21
|
+
export class MoneyAccountUpgradeController extends BaseController {
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for the MoneyAccountUpgradeController.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The options for constructing the controller.
|
|
26
|
+
* @param options.messenger - The messenger to use for inter-controller communication.
|
|
27
|
+
*/
|
|
28
|
+
constructor({ messenger, }) {
|
|
29
|
+
super({
|
|
30
|
+
messenger,
|
|
31
|
+
metadata: moneyAccountUpgradeControllerMetadata,
|
|
32
|
+
name: controllerName,
|
|
33
|
+
state: {},
|
|
34
|
+
});
|
|
35
|
+
_MoneyAccountUpgradeController_initialized.set(this, void 0);
|
|
36
|
+
_MoneyAccountUpgradeController_steps.set(this, [associateAddressStep]);
|
|
37
|
+
__classPrivateFieldSet(this, _MoneyAccountUpgradeController_initialized, false, "f");
|
|
38
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetches service details and validates the controller can operate on the
|
|
42
|
+
* given chain.
|
|
43
|
+
*
|
|
44
|
+
* @param chainId - The chain to initialize for.
|
|
45
|
+
* @param _initConfig - Contract addresses not available from the service details API.
|
|
46
|
+
*/
|
|
47
|
+
async init(chainId, _initConfig) {
|
|
48
|
+
const response = await this.messenger.call('ChompApiService:getServiceDetails', [chainId]);
|
|
49
|
+
const chain = response.chains[chainId];
|
|
50
|
+
if (!chain) {
|
|
51
|
+
throw new Error(`Chain ${chainId} not found in service details response`);
|
|
52
|
+
}
|
|
53
|
+
const { vedaProtocol } = chain.protocol;
|
|
54
|
+
if (!vedaProtocol) {
|
|
55
|
+
throw new Error(`vedaProtocol not found for chain ${chainId} in service details response`);
|
|
56
|
+
}
|
|
57
|
+
if (vedaProtocol.supportedTokens.length === 0) {
|
|
58
|
+
throw new Error(`No supported tokens found for vedaProtocol on chain ${chainId}`);
|
|
59
|
+
}
|
|
60
|
+
__classPrivateFieldSet(this, _MoneyAccountUpgradeController_initialized, true, "f");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Runs each step in the upgrade sequence in order. A step that reports
|
|
64
|
+
* `'already-done'` is skipped without performing any action; a step that
|
|
65
|
+
* reports `'completed'` has performed its action. An error thrown by any
|
|
66
|
+
* step propagates and halts the sequence.
|
|
67
|
+
*
|
|
68
|
+
* @param address - The Money Account address to upgrade.
|
|
69
|
+
*/
|
|
70
|
+
async upgradeAccount(address) {
|
|
71
|
+
if (!__classPrivateFieldGet(this, _MoneyAccountUpgradeController_initialized, "f")) {
|
|
72
|
+
throw new Error('MoneyAccountUpgradeController must be initialized via init() before upgradeAccount() can be called');
|
|
73
|
+
}
|
|
74
|
+
for (const step of __classPrivateFieldGet(this, _MoneyAccountUpgradeController_steps, "f")) {
|
|
75
|
+
await step.run({ messenger: this.messenger, address });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_MoneyAccountUpgradeController_initialized = new WeakMap(), _MoneyAccountUpgradeController_steps = new WeakMap();
|
|
80
|
+
//# sourceMappingURL=MoneyAccountUpgradeController.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyAccountUpgradeController.mjs","sourceRoot":"","sources":["../src/MoneyAccountUpgradeController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAS3D,OAAO,EAAE,oBAAoB,EAAE,gCAA4B;AAK3D,MAAM,CAAC,MAAM,cAAc,GAAG,+BAA+B,CAAC;AAI9D,MAAM,qCAAqC,GACzC,EAA8D,CAAC;AAEjE,MAAM,yBAAyB,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAkC9D;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,cAIlD;IAKC;;;;;OAKG;IACH,YAAY,EACV,SAAS,GAGV;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,qCAAqC;YAC/C,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;QApBL,6DAAsB;QAEb,+CAAiB,CAAC,oBAAoB,CAAC,EAAC;QAoB/C,uBAAA,IAAI,8CAAgB,KAAK,MAAA,CAAC;QAE1B,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,OAAY,EAAE,WAAuB;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACxC,mCAAmC,EACnC,CAAC,OAAO,CAAC,CACV,CAAC;QAEF,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,wCAAwC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,oCAAoC,OAAO,8BAA8B,CAC1E,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,uDAAuD,OAAO,EAAE,CACjE,CAAC;QACJ,CAAC;QAED,uBAAA,IAAI,8CAAgB,IAAI,MAAA,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAC,OAAY;QAC/B,IAAI,CAAC,uBAAA,IAAI,kDAAa,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,uBAAA,IAAI,4CAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceGetServiceDetailsAction,\n} from '@metamask/chomp-api-service';\nimport type { KeyringControllerSignPersonalMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport { associateAddressStep } from './associate-address';\nimport type { MoneyAccountUpgradeControllerMethodActions } from './MoneyAccountUpgradeController-method-action-types';\nimport type { Step } from './step';\nimport type { InitConfig } from './types';\n\nexport const controllerName = 'MoneyAccountUpgradeController';\n\nexport type MoneyAccountUpgradeControllerState = Record<string, never>;\n\nconst moneyAccountUpgradeControllerMetadata =\n {} satisfies StateMetadata<MoneyAccountUpgradeControllerState>;\n\nconst MESSENGER_EXPOSED_METHODS = ['upgradeAccount'] as const;\n\nexport type MoneyAccountUpgradeControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerActions =\n | MoneyAccountUpgradeControllerGetStateAction\n | MoneyAccountUpgradeControllerMethodActions;\n\ntype AllowedActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceGetServiceDetailsAction\n | KeyringControllerSignPersonalMessageAction;\n\nexport type MoneyAccountUpgradeControllerStateChangedEvent =\n ControllerStateChangedEvent<\n typeof controllerName,\n MoneyAccountUpgradeControllerState\n >;\n\nexport type MoneyAccountUpgradeControllerEvents =\n MoneyAccountUpgradeControllerStateChangedEvent;\n\ntype AllowedEvents = never;\n\nexport type MoneyAccountUpgradeControllerMessenger = Messenger<\n typeof controllerName,\n MoneyAccountUpgradeControllerActions | AllowedActions,\n MoneyAccountUpgradeControllerEvents | AllowedEvents\n>;\n\n/**\n * Controller that orchestrates the Money Account upgrade sequence.\n */\nexport class MoneyAccountUpgradeController extends BaseController<\n typeof controllerName,\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerMessenger\n> {\n #initialized: boolean;\n\n readonly #steps: Step[] = [associateAddressStep];\n\n /**\n * Constructor for the MoneyAccountUpgradeController.\n *\n * @param options - The options for constructing the controller.\n * @param options.messenger - The messenger to use for inter-controller communication.\n */\n constructor({\n messenger,\n }: {\n messenger: MoneyAccountUpgradeControllerMessenger;\n }) {\n super({\n messenger,\n metadata: moneyAccountUpgradeControllerMetadata,\n name: controllerName,\n state: {},\n });\n\n this.#initialized = false;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches service details and validates the controller can operate on the\n * given chain.\n *\n * @param chainId - The chain to initialize for.\n * @param _initConfig - Contract addresses not available from the service details API.\n */\n async init(chainId: Hex, _initConfig: InitConfig): Promise<void> {\n const response = await this.messenger.call(\n 'ChompApiService:getServiceDetails',\n [chainId],\n );\n\n const chain = response.chains[chainId];\n if (!chain) {\n throw new Error(`Chain ${chainId} not found in service details response`);\n }\n\n const { vedaProtocol } = chain.protocol;\n if (!vedaProtocol) {\n throw new Error(\n `vedaProtocol not found for chain ${chainId} in service details response`,\n );\n }\n\n if (vedaProtocol.supportedTokens.length === 0) {\n throw new Error(\n `No supported tokens found for vedaProtocol on chain ${chainId}`,\n );\n }\n\n this.#initialized = true;\n }\n\n /**\n * Runs each step in the upgrade sequence in order. A step that reports\n * `'already-done'` is skipped without performing any action; a step that\n * reports `'completed'` has performed its action. An error thrown by any\n * step propagates and halts the sequence.\n *\n * @param address - The Money Account address to upgrade.\n */\n async upgradeAccount(address: Hex): Promise<void> {\n if (!this.#initialized) {\n throw new Error(\n 'MoneyAccountUpgradeController must be initialized via init() before upgradeAccount() can be called',\n );\n }\n\n for (const step of this.#steps) {\n await step.run({ messenger: this.messenger, address });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.associateAddressStep = void 0;
|
|
4
|
+
const ALREADY_ASSOCIATED_STATUS = 'already_associated';
|
|
5
|
+
/**
|
|
6
|
+
* Associates the Money Account address with the user's CHOMP profile.
|
|
7
|
+
*
|
|
8
|
+
* Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key
|
|
9
|
+
* and submits the signature to CHOMP, which verifies the timestamp is fresh,
|
|
10
|
+
* recovers the signer, and records the profile–address mapping.
|
|
11
|
+
*
|
|
12
|
+
* CHOMP responds with 201 and `status: 'created'` when the association is
|
|
13
|
+
* made, and 409 with `status: 'already_associated'` when the address is
|
|
14
|
+
* already linked to a profile. The service surfaces both responses, so this
|
|
15
|
+
* step reports `'already-done'` for the 409 case and `'completed'` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
exports.associateAddressStep = {
|
|
18
|
+
name: 'associate-address',
|
|
19
|
+
async run({ messenger, address }) {
|
|
20
|
+
const timestamp = Date.now().toString();
|
|
21
|
+
const message = `CHOMP Authentication ${timestamp}`;
|
|
22
|
+
const signature = (await messenger.call('KeyringController:signPersonalMessage', { data: message, from: address }));
|
|
23
|
+
const response = await messenger.call('ChompApiService:associateAddress', {
|
|
24
|
+
signature,
|
|
25
|
+
timestamp,
|
|
26
|
+
address,
|
|
27
|
+
});
|
|
28
|
+
if (response.status === ALREADY_ASSOCIATED_STATUS) {
|
|
29
|
+
return 'already-done';
|
|
30
|
+
}
|
|
31
|
+
return 'completed';
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=associate-address.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associate-address.cjs","sourceRoot":"","sources":["../src/associate-address.ts"],"names":[],"mappings":";;;AAIA,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACU,QAAA,oBAAoB,GAAS;IACxC,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,wBAAwB,SAAS,EAAE,CAAC;QAEpD,MAAM,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,CACrC,uCAAuC,EACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CACjC,CAAQ,CAAC;QAEV,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,kCAAkC,EAAE;YACxE,SAAS;YACT,SAAS;YACT,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,yBAAyB,EAAE,CAAC;YAClD,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { Step } from './step';\n\nconst ALREADY_ASSOCIATED_STATUS = 'already_associated';\n\n/**\n * Associates the Money Account address with the user's CHOMP profile.\n *\n * Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key\n * and submits the signature to CHOMP, which verifies the timestamp is fresh,\n * recovers the signer, and records the profile–address mapping.\n *\n * CHOMP responds with 201 and `status: 'created'` when the association is\n * made, and 409 with `status: 'already_associated'` when the address is\n * already linked to a profile. The service surfaces both responses, so this\n * step reports `'already-done'` for the 409 case and `'completed'` otherwise.\n */\nexport const associateAddressStep: Step = {\n name: 'associate-address',\n async run({ messenger, address }) {\n const timestamp = Date.now().toString();\n const message = `CHOMP Authentication ${timestamp}`;\n\n const signature = (await messenger.call(\n 'KeyringController:signPersonalMessage',\n { data: message, from: address },\n )) as Hex;\n\n const response = await messenger.call('ChompApiService:associateAddress', {\n signature,\n timestamp,\n address,\n });\n\n if (response.status === ALREADY_ASSOCIATED_STATUS) {\n return 'already-done';\n }\n\n return 'completed';\n },\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Step } from "./step.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Associates the Money Account address with the user's CHOMP profile.
|
|
4
|
+
*
|
|
5
|
+
* Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key
|
|
6
|
+
* and submits the signature to CHOMP, which verifies the timestamp is fresh,
|
|
7
|
+
* recovers the signer, and records the profile–address mapping.
|
|
8
|
+
*
|
|
9
|
+
* CHOMP responds with 201 and `status: 'created'` when the association is
|
|
10
|
+
* made, and 409 with `status: 'already_associated'` when the address is
|
|
11
|
+
* already linked to a profile. The service surfaces both responses, so this
|
|
12
|
+
* step reports `'already-done'` for the 409 case and `'completed'` otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export declare const associateAddressStep: Step;
|
|
15
|
+
//# sourceMappingURL=associate-address.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associate-address.d.cts","sourceRoot":"","sources":["../src/associate-address.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,mBAAe;AAInC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,IAuBlC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Step } from "./step.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Associates the Money Account address with the user's CHOMP profile.
|
|
4
|
+
*
|
|
5
|
+
* Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key
|
|
6
|
+
* and submits the signature to CHOMP, which verifies the timestamp is fresh,
|
|
7
|
+
* recovers the signer, and records the profile–address mapping.
|
|
8
|
+
*
|
|
9
|
+
* CHOMP responds with 201 and `status: 'created'` when the association is
|
|
10
|
+
* made, and 409 with `status: 'already_associated'` when the address is
|
|
11
|
+
* already linked to a profile. The service surfaces both responses, so this
|
|
12
|
+
* step reports `'already-done'` for the 409 case and `'completed'` otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export declare const associateAddressStep: Step;
|
|
15
|
+
//# sourceMappingURL=associate-address.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associate-address.d.mts","sourceRoot":"","sources":["../src/associate-address.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,mBAAe;AAInC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,IAuBlC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ALREADY_ASSOCIATED_STATUS = 'already_associated';
|
|
2
|
+
/**
|
|
3
|
+
* Associates the Money Account address with the user's CHOMP profile.
|
|
4
|
+
*
|
|
5
|
+
* Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key
|
|
6
|
+
* and submits the signature to CHOMP, which verifies the timestamp is fresh,
|
|
7
|
+
* recovers the signer, and records the profile–address mapping.
|
|
8
|
+
*
|
|
9
|
+
* CHOMP responds with 201 and `status: 'created'` when the association is
|
|
10
|
+
* made, and 409 with `status: 'already_associated'` when the address is
|
|
11
|
+
* already linked to a profile. The service surfaces both responses, so this
|
|
12
|
+
* step reports `'already-done'` for the 409 case and `'completed'` otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export const associateAddressStep = {
|
|
15
|
+
name: 'associate-address',
|
|
16
|
+
async run({ messenger, address }) {
|
|
17
|
+
const timestamp = Date.now().toString();
|
|
18
|
+
const message = `CHOMP Authentication ${timestamp}`;
|
|
19
|
+
const signature = (await messenger.call('KeyringController:signPersonalMessage', { data: message, from: address }));
|
|
20
|
+
const response = await messenger.call('ChompApiService:associateAddress', {
|
|
21
|
+
signature,
|
|
22
|
+
timestamp,
|
|
23
|
+
address,
|
|
24
|
+
});
|
|
25
|
+
if (response.status === ALREADY_ASSOCIATED_STATUS) {
|
|
26
|
+
return 'already-done';
|
|
27
|
+
}
|
|
28
|
+
return 'completed';
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=associate-address.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associate-address.mjs","sourceRoot":"","sources":["../src/associate-address.ts"],"names":[],"mappings":"AAIA,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAS;IACxC,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,wBAAwB,SAAS,EAAE,CAAC;QAEpD,MAAM,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,CACrC,uCAAuC,EACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CACjC,CAAQ,CAAC;QAEV,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,kCAAkC,EAAE;YACxE,SAAS;YACT,SAAS;YACT,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,yBAAyB,EAAE,CAAC;YAClD,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { Step } from './step';\n\nconst ALREADY_ASSOCIATED_STATUS = 'already_associated';\n\n/**\n * Associates the Money Account address with the user's CHOMP profile.\n *\n * Signs `CHOMP Authentication {timestamp}` (EIP-191) with the account's key\n * and submits the signature to CHOMP, which verifies the timestamp is fresh,\n * recovers the signer, and records the profile–address mapping.\n *\n * CHOMP responds with 201 and `status: 'created'` when the association is\n * made, and 409 with `status: 'already_associated'` when the address is\n * already linked to a profile. The service surfaces both responses, so this\n * step reports `'already-done'` for the 409 case and `'completed'` otherwise.\n */\nexport const associateAddressStep: Step = {\n name: 'associate-address',\n async run({ messenger, address }) {\n const timestamp = Date.now().toString();\n const message = `CHOMP Authentication ${timestamp}`;\n\n const signature = (await messenger.call(\n 'KeyringController:signPersonalMessage',\n { data: message, from: address },\n )) as Hex;\n\n const response = await messenger.call('ChompApiService:associateAddress', {\n signature,\n timestamp,\n address,\n });\n\n if (response.status === ALREADY_ASSOCIATED_STATUS) {\n return 'already-done';\n }\n\n return 'completed';\n },\n};\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MoneyAccountUpgradeController = void 0;
|
|
4
|
+
var MoneyAccountUpgradeController_1 = require("./MoneyAccountUpgradeController.cjs");
|
|
5
|
+
Object.defineProperty(exports, "MoneyAccountUpgradeController", { enumerable: true, get: function () { return MoneyAccountUpgradeController_1.MoneyAccountUpgradeController; } });
|
|
6
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,qFAAgF;AAAvE,8IAAA,6BAA6B,OAAA","sourcesContent":["export type { Step, StepResult } from './step';\nexport type { InitConfig, UpgradeConfig } from './types';\nexport { MoneyAccountUpgradeController } from './MoneyAccountUpgradeController';\nexport type {\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerGetStateAction,\n MoneyAccountUpgradeControllerActions,\n MoneyAccountUpgradeControllerStateChangedEvent,\n MoneyAccountUpgradeControllerEvents,\n MoneyAccountUpgradeControllerMessenger,\n} from './MoneyAccountUpgradeController';\nexport type { MoneyAccountUpgradeControllerUpgradeAccountAction } from './MoneyAccountUpgradeController-method-action-types';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { Step, StepResult } from "./step.cjs";
|
|
2
|
+
export type { InitConfig, UpgradeConfig } from "./types.cjs";
|
|
3
|
+
export { MoneyAccountUpgradeController } from "./MoneyAccountUpgradeController.cjs";
|
|
4
|
+
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, } from "./MoneyAccountUpgradeController.cjs";
|
|
5
|
+
export type { MoneyAccountUpgradeControllerUpgradeAccountAction } from "./MoneyAccountUpgradeController-method-action-types.cjs";
|
|
6
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAe;AAC/C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAgB;AACzD,OAAO,EAAE,6BAA6B,EAAE,4CAAwC;AAChF,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,GACvC,4CAAwC;AACzC,YAAY,EAAE,iDAAiD,EAAE,gEAA4D"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { Step, StepResult } from "./step.mjs";
|
|
2
|
+
export type { InitConfig, UpgradeConfig } from "./types.mjs";
|
|
3
|
+
export { MoneyAccountUpgradeController } from "./MoneyAccountUpgradeController.mjs";
|
|
4
|
+
export type { MoneyAccountUpgradeControllerState, MoneyAccountUpgradeControllerGetStateAction, MoneyAccountUpgradeControllerActions, MoneyAccountUpgradeControllerStateChangedEvent, MoneyAccountUpgradeControllerEvents, MoneyAccountUpgradeControllerMessenger, } from "./MoneyAccountUpgradeController.mjs";
|
|
5
|
+
export type { MoneyAccountUpgradeControllerUpgradeAccountAction } from "./MoneyAccountUpgradeController-method-action-types.mjs";
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAe;AAC/C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAgB;AACzD,OAAO,EAAE,6BAA6B,EAAE,4CAAwC;AAChF,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,oCAAoC,EACpC,8CAA8C,EAC9C,mCAAmC,EACnC,sCAAsC,GACvC,4CAAwC;AACzC,YAAY,EAAE,iDAAiD,EAAE,gEAA4D"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,4CAAwC","sourcesContent":["export type { Step, StepResult } from './step';\nexport type { InitConfig, UpgradeConfig } from './types';\nexport { MoneyAccountUpgradeController } from './MoneyAccountUpgradeController';\nexport type {\n MoneyAccountUpgradeControllerState,\n MoneyAccountUpgradeControllerGetStateAction,\n MoneyAccountUpgradeControllerActions,\n MoneyAccountUpgradeControllerStateChangedEvent,\n MoneyAccountUpgradeControllerEvents,\n MoneyAccountUpgradeControllerMessenger,\n} from './MoneyAccountUpgradeController';\nexport type { MoneyAccountUpgradeControllerUpgradeAccountAction } from './MoneyAccountUpgradeController-method-action-types';\n"]}
|
package/dist/step.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.cjs","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { MoneyAccountUpgradeControllerMessenger } from './MoneyAccountUpgradeController';\n\n/**\n * Context supplied to each step when it is run.\n */\nexport type StepContext = {\n messenger: MoneyAccountUpgradeControllerMessenger;\n address: Hex;\n};\n\n/**\n * The outcome of running a single step in the Money Account upgrade sequence.\n *\n * - `'already-done'` — the step's remote check determined that no work was\n * required; no action was taken.\n * - `'completed'` — the step performed its action and is now done.\n */\nexport type StepResult = 'already-done' | 'completed';\n\n/**\n * A single step in the Money Account upgrade sequence.\n *\n * Each step is responsible for checking whether its action has already been\n * applied (returning `'already-done'` if so) and otherwise performing the\n * action and returning `'completed'`.\n */\nexport type Step = {\n name: string;\n run: (context: StepContext) => Promise<StepResult>;\n};\n"]}
|
package/dist/step.d.cts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { MoneyAccountUpgradeControllerMessenger } from "./MoneyAccountUpgradeController.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Context supplied to each step when it is run.
|
|
5
|
+
*/
|
|
6
|
+
export type StepContext = {
|
|
7
|
+
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
8
|
+
address: Hex;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The outcome of running a single step in the Money Account upgrade sequence.
|
|
12
|
+
*
|
|
13
|
+
* - `'already-done'` — the step's remote check determined that no work was
|
|
14
|
+
* required; no action was taken.
|
|
15
|
+
* - `'completed'` — the step performed its action and is now done.
|
|
16
|
+
*/
|
|
17
|
+
export type StepResult = 'already-done' | 'completed';
|
|
18
|
+
/**
|
|
19
|
+
* A single step in the Money Account upgrade sequence.
|
|
20
|
+
*
|
|
21
|
+
* Each step is responsible for checking whether its action has already been
|
|
22
|
+
* applied (returning `'already-done'` if so) and otherwise performing the
|
|
23
|
+
* action and returning `'completed'`.
|
|
24
|
+
*/
|
|
25
|
+
export type Step = {
|
|
26
|
+
name: string;
|
|
27
|
+
run: (context: StepContext) => Promise<StepResult>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=step.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.cts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,4CAAwC;AAE9F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,WAAW,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/step.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { MoneyAccountUpgradeControllerMessenger } from "./MoneyAccountUpgradeController.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Context supplied to each step when it is run.
|
|
5
|
+
*/
|
|
6
|
+
export type StepContext = {
|
|
7
|
+
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
8
|
+
address: Hex;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The outcome of running a single step in the Money Account upgrade sequence.
|
|
12
|
+
*
|
|
13
|
+
* - `'already-done'` — the step's remote check determined that no work was
|
|
14
|
+
* required; no action was taken.
|
|
15
|
+
* - `'completed'` — the step performed its action and is now done.
|
|
16
|
+
*/
|
|
17
|
+
export type StepResult = 'already-done' | 'completed';
|
|
18
|
+
/**
|
|
19
|
+
* A single step in the Money Account upgrade sequence.
|
|
20
|
+
*
|
|
21
|
+
* Each step is responsible for checking whether its action has already been
|
|
22
|
+
* applied (returning `'already-done'` if so) and otherwise performing the
|
|
23
|
+
* action and returning `'completed'`.
|
|
24
|
+
*/
|
|
25
|
+
export type Step = {
|
|
26
|
+
name: string;
|
|
27
|
+
run: (context: StepContext) => Promise<StepResult>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=step.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.mts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,4CAAwC;AAE9F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,WAAW,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD,CAAC"}
|
package/dist/step.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.mjs","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { MoneyAccountUpgradeControllerMessenger } from './MoneyAccountUpgradeController';\n\n/**\n * Context supplied to each step when it is run.\n */\nexport type StepContext = {\n messenger: MoneyAccountUpgradeControllerMessenger;\n address: Hex;\n};\n\n/**\n * The outcome of running a single step in the Money Account upgrade sequence.\n *\n * - `'already-done'` — the step's remote check determined that no work was\n * required; no action was taken.\n * - `'completed'` — the step performed its action and is now done.\n */\nexport type StepResult = 'already-done' | 'completed';\n\n/**\n * A single step in the Money Account upgrade sequence.\n *\n * Each step is responsible for checking whether its action has already been\n * applied (returning `'already-done'` if so) and otherwise performing the\n * action and returning `'completed'`.\n */\nexport type Step = {\n name: string;\n run: (context: StepContext) => Promise<StepResult>;\n};\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Contract addresses and configuration required to perform the\n * Money Account upgrade sequence.\n */\nexport type UpgradeConfig = {\n /** CHOMP's delegate address — receives the delegation. */\n delegateAddress: Hex;\n /** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */\n delegatorImplAddress: Hex;\n /** The mUSD token contract address. */\n musdTokenAddress: Hex;\n /** The Veda vault adapter contract address. */\n vedaVaultAdapterAddress: Hex;\n /** Address of the ERC20TransferAmountEnforcer caveat enforcer. */\n erc20TransferAmountEnforcer: Hex;\n /** Address of the RedeemerEnforcer caveat enforcer. */\n redeemerEnforcer: Hex;\n /** Address of the ValueLteEnforcer caveat enforcer. */\n valueLteEnforcer: Hex;\n};\n\n/**\n * Configuration values passed to {@link MoneyAccountUpgradeController.init}\n * that cannot be derived from the service details API.\n */\nexport type InitConfig = Pick<\n UpgradeConfig,\n | 'delegatorImplAddress'\n | 'musdTokenAddress'\n | 'redeemerEnforcer'\n | 'valueLteEnforcer'\n>;\n"]}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Contract addresses and configuration required to perform the
|
|
4
|
+
* Money Account upgrade sequence.
|
|
5
|
+
*/
|
|
6
|
+
export type UpgradeConfig = {
|
|
7
|
+
/** CHOMP's delegate address — receives the delegation. */
|
|
8
|
+
delegateAddress: Hex;
|
|
9
|
+
/** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */
|
|
10
|
+
delegatorImplAddress: Hex;
|
|
11
|
+
/** The mUSD token contract address. */
|
|
12
|
+
musdTokenAddress: Hex;
|
|
13
|
+
/** The Veda vault adapter contract address. */
|
|
14
|
+
vedaVaultAdapterAddress: Hex;
|
|
15
|
+
/** Address of the ERC20TransferAmountEnforcer caveat enforcer. */
|
|
16
|
+
erc20TransferAmountEnforcer: Hex;
|
|
17
|
+
/** Address of the RedeemerEnforcer caveat enforcer. */
|
|
18
|
+
redeemerEnforcer: Hex;
|
|
19
|
+
/** Address of the ValueLteEnforcer caveat enforcer. */
|
|
20
|
+
valueLteEnforcer: Hex;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Configuration values passed to {@link MoneyAccountUpgradeController.init}
|
|
24
|
+
* that cannot be derived from the service details API.
|
|
25
|
+
*/
|
|
26
|
+
export type InitConfig = Pick<UpgradeConfig, 'delegatorImplAddress' | 'musdTokenAddress' | 'redeemerEnforcer' | 'valueLteEnforcer'>;
|
|
27
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,eAAe,EAAE,GAAG,CAAC;IACrB,sEAAsE;IACtE,oBAAoB,EAAE,GAAG,CAAC;IAC1B,uCAAuC;IACvC,gBAAgB,EAAE,GAAG,CAAC;IACtB,+CAA+C;IAC/C,uBAAuB,EAAE,GAAG,CAAC;IAC7B,kEAAkE;IAClE,2BAA2B,EAAE,GAAG,CAAC;IACjC,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;IACtB,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,aAAa,EACX,sBAAsB,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,CACrB,CAAC"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Contract addresses and configuration required to perform the
|
|
4
|
+
* Money Account upgrade sequence.
|
|
5
|
+
*/
|
|
6
|
+
export type UpgradeConfig = {
|
|
7
|
+
/** CHOMP's delegate address — receives the delegation. */
|
|
8
|
+
delegateAddress: Hex;
|
|
9
|
+
/** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */
|
|
10
|
+
delegatorImplAddress: Hex;
|
|
11
|
+
/** The mUSD token contract address. */
|
|
12
|
+
musdTokenAddress: Hex;
|
|
13
|
+
/** The Veda vault adapter contract address. */
|
|
14
|
+
vedaVaultAdapterAddress: Hex;
|
|
15
|
+
/** Address of the ERC20TransferAmountEnforcer caveat enforcer. */
|
|
16
|
+
erc20TransferAmountEnforcer: Hex;
|
|
17
|
+
/** Address of the RedeemerEnforcer caveat enforcer. */
|
|
18
|
+
redeemerEnforcer: Hex;
|
|
19
|
+
/** Address of the ValueLteEnforcer caveat enforcer. */
|
|
20
|
+
valueLteEnforcer: Hex;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Configuration values passed to {@link MoneyAccountUpgradeController.init}
|
|
24
|
+
* that cannot be derived from the service details API.
|
|
25
|
+
*/
|
|
26
|
+
export type InitConfig = Pick<UpgradeConfig, 'delegatorImplAddress' | 'musdTokenAddress' | 'redeemerEnforcer' | 'valueLteEnforcer'>;
|
|
27
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,eAAe,EAAE,GAAG,CAAC;IACrB,sEAAsE;IACtE,oBAAoB,EAAE,GAAG,CAAC;IAC1B,uCAAuC;IACvC,gBAAgB,EAAE,GAAG,CAAC;IACtB,+CAA+C;IAC/C,uBAAuB,EAAE,GAAG,CAAC;IAC7B,kEAAkE;IAClE,2BAA2B,EAAE,GAAG,CAAC;IACjC,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;IACtB,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,aAAa,EACX,sBAAsB,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,CACrB,CAAC"}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Contract addresses and configuration required to perform the\n * Money Account upgrade sequence.\n */\nexport type UpgradeConfig = {\n /** CHOMP's delegate address — receives the delegation. */\n delegateAddress: Hex;\n /** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */\n delegatorImplAddress: Hex;\n /** The mUSD token contract address. */\n musdTokenAddress: Hex;\n /** The Veda vault adapter contract address. */\n vedaVaultAdapterAddress: Hex;\n /** Address of the ERC20TransferAmountEnforcer caveat enforcer. */\n erc20TransferAmountEnforcer: Hex;\n /** Address of the RedeemerEnforcer caveat enforcer. */\n redeemerEnforcer: Hex;\n /** Address of the ValueLteEnforcer caveat enforcer. */\n valueLteEnforcer: Hex;\n};\n\n/**\n * Configuration values passed to {@link MoneyAccountUpgradeController.init}\n * that cannot be derived from the service details API.\n */\nexport type InitConfig = Pick<\n UpgradeConfig,\n | 'delegatorImplAddress'\n | 'musdTokenAddress'\n | 'redeemerEnforcer'\n | 'valueLteEnforcer'\n>;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask-previews/money-account-upgrade-controller",
|
|
3
|
+
"version": "0.0.0-preview-8e9c439",
|
|
4
|
+
"description": "MetaMask Money account upgrade controller",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Ethereum",
|
|
7
|
+
"MetaMask"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/money-account-upgrade-controller#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/MetaMask/core.git"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
43
|
+
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
44
|
+
"build:docs": "typedoc",
|
|
45
|
+
"changelog:update": "../../scripts/update-changelog.sh @metamask/money-account-upgrade-controller",
|
|
46
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/money-account-upgrade-controller",
|
|
47
|
+
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --check",
|
|
48
|
+
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --generate",
|
|
49
|
+
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
50
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
51
|
+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
52
|
+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
53
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@metamask/base-controller": "^9.1.0",
|
|
57
|
+
"@metamask/chomp-api-service": "^1.0.0",
|
|
58
|
+
"@metamask/keyring-controller": "^25.2.0",
|
|
59
|
+
"@metamask/messenger": "^1.1.1"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@metamask/auto-changelog": "^6.1.0",
|
|
63
|
+
"@metamask/utils": "^11.9.0",
|
|
64
|
+
"@ts-bridge/cli": "^0.6.4",
|
|
65
|
+
"@types/jest": "^29.5.14",
|
|
66
|
+
"deepmerge": "^4.2.2",
|
|
67
|
+
"jest": "^29.7.0",
|
|
68
|
+
"ts-jest": "^29.2.5",
|
|
69
|
+
"tsx": "^4.20.5",
|
|
70
|
+
"typedoc": "^0.25.13",
|
|
71
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
72
|
+
"typescript": "~5.3.3"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": "^18.18 || >=20"
|
|
76
|
+
}
|
|
77
|
+
}
|