@metamask/money-account-upgrade-controller 1.3.1 → 2.0.0
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 +30 -1
- package/dist/MoneyAccountUpgradeController.cjs +36 -6
- package/dist/MoneyAccountUpgradeController.cjs.map +1 -1
- package/dist/MoneyAccountUpgradeController.d.cts +16 -7
- package/dist/MoneyAccountUpgradeController.d.cts.map +1 -1
- package/dist/MoneyAccountUpgradeController.d.mts +16 -7
- package/dist/MoneyAccountUpgradeController.d.mts.map +1 -1
- package/dist/MoneyAccountUpgradeController.mjs +36 -6
- package/dist/MoneyAccountUpgradeController.mjs.map +1 -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.map +1 -1
- package/dist/steps/build-delegations.cjs +130 -0
- package/dist/steps/build-delegations.cjs.map +1 -0
- package/dist/steps/build-delegations.d.cts +3 -0
- package/dist/steps/build-delegations.d.cts.map +1 -0
- package/dist/steps/build-delegations.d.mts +3 -0
- package/dist/steps/build-delegations.d.mts.map +1 -0
- package/dist/steps/build-delegations.mjs +127 -0
- package/dist/steps/build-delegations.mjs.map +1 -0
- package/dist/steps/delegation-matchers.cjs +26 -0
- package/dist/steps/delegation-matchers.cjs.map +1 -0
- package/dist/steps/delegation-matchers.d.cts +16 -0
- package/dist/steps/delegation-matchers.d.cts.map +1 -0
- package/dist/steps/delegation-matchers.d.mts +16 -0
- package/dist/steps/delegation-matchers.d.mts.map +1 -0
- package/dist/steps/delegation-matchers.mjs +21 -0
- package/dist/steps/delegation-matchers.mjs.map +1 -0
- package/dist/steps/eip-7702-authorization.cjs +29 -9
- package/dist/steps/eip-7702-authorization.cjs.map +1 -1
- package/dist/steps/eip-7702-authorization.d.cts.map +1 -1
- package/dist/steps/eip-7702-authorization.d.mts.map +1 -1
- package/dist/steps/eip-7702-authorization.mjs +29 -9
- package/dist/steps/eip-7702-authorization.mjs.map +1 -1
- package/dist/steps/register-intents.cjs +69 -0
- package/dist/steps/register-intents.cjs.map +1 -0
- package/dist/steps/register-intents.d.cts +18 -0
- package/dist/steps/register-intents.d.cts.map +1 -0
- package/dist/steps/register-intents.d.mts +18 -0
- package/dist/steps/register-intents.d.mts.map +1 -0
- package/dist/steps/register-intents.mjs +66 -0
- package/dist/steps/register-intents.mjs.map +1 -0
- package/dist/steps/step.cjs.map +1 -1
- package/dist/steps/step.d.cts +7 -0
- package/dist/steps/step.d.cts.map +1 -1
- package/dist/steps/step.d.mts +7 -0
- package/dist/steps/step.d.mts.map +1 -1
- package/dist/steps/step.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +12 -10
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +12 -10
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { equalsIgnoreCase, makeHasVedaRedeemerCaveat } from "./delegation-matchers.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a delegation's metadata `type` field — typed as `string` in storage —
|
|
4
|
+
* into the narrow set of CHOMP intent types. Throws if the field carries any
|
|
5
|
+
* other value, since registering it as an intent would be a category error.
|
|
6
|
+
*
|
|
7
|
+
* @param type - The `type` field from `DelegationMetadata`.
|
|
8
|
+
* @returns The same value, narrowed to `IntentMetadataType`.
|
|
9
|
+
*/
|
|
10
|
+
function parseIntentMetadataType(type) {
|
|
11
|
+
if (type !== 'cash-deposit' && type !== 'cash-withdrawal') {
|
|
12
|
+
throw new Error(`Expected delegation type to be "cash-deposit" or "cash-withdrawal", got "${type}"`);
|
|
13
|
+
}
|
|
14
|
+
return type;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Registers CHOMP intents for the auto-deposit / auto-withdrawal delegations
|
|
18
|
+
* persisted by the build-delegation step.
|
|
19
|
+
*
|
|
20
|
+
* For each stored delegation between this account and CHOMP's delegate on
|
|
21
|
+
* this chain, the step builds an intent referencing the stored
|
|
22
|
+
* `delegationHash` and submits the batch to `POST /v1/intent`. Delegations
|
|
23
|
+
* whose `delegationHash` already has an active intent on CHOMP are skipped
|
|
24
|
+
* (revoked intents are re-registered). Reports `'already-done'` when every
|
|
25
|
+
* eligible delegation already has an active intent.
|
|
26
|
+
*
|
|
27
|
+
* Once registered, CHOMP re-fetches the delegation from Authenticated User
|
|
28
|
+
* Storage, re-validates it, and adds the account to its monitoring list so
|
|
29
|
+
* subsequent eligible operations can be picked up automatically.
|
|
30
|
+
*/
|
|
31
|
+
export const registerIntentsStep = {
|
|
32
|
+
name: 'register-intents',
|
|
33
|
+
async run({ messenger, address, chainId, delegateAddress, redeemerEnforcer, vedaVaultAdapterAddress, }) {
|
|
34
|
+
const [delegations, existingIntents] = await Promise.all([
|
|
35
|
+
messenger.call('AuthenticatedUserStorageService:listDelegations'),
|
|
36
|
+
messenger.call('ChompApiService:getIntentsByAddress', address),
|
|
37
|
+
]);
|
|
38
|
+
const activeIntentHashes = new Set(existingIntents
|
|
39
|
+
.filter((intent) => intent.status === 'active')
|
|
40
|
+
.map((intent) => intent.delegationHash.toLowerCase()));
|
|
41
|
+
const hasVedaRedeemerCaveat = makeHasVedaRedeemerCaveat(redeemerEnforcer, vedaVaultAdapterAddress);
|
|
42
|
+
const needsIntent = (entry) => equalsIgnoreCase(entry.signedDelegation.delegator, address) &&
|
|
43
|
+
equalsIgnoreCase(entry.signedDelegation.delegate, delegateAddress) &&
|
|
44
|
+
equalsIgnoreCase(entry.metadata.chainIdHex, chainId) &&
|
|
45
|
+
hasVedaRedeemerCaveat(entry) &&
|
|
46
|
+
!activeIntentHashes.has(entry.metadata.delegationHash.toLowerCase());
|
|
47
|
+
const toIntent = (entry) => ({
|
|
48
|
+
account: address,
|
|
49
|
+
delegationHash: entry.metadata.delegationHash,
|
|
50
|
+
chainId,
|
|
51
|
+
metadata: {
|
|
52
|
+
allowance: entry.metadata.allowance,
|
|
53
|
+
tokenSymbol: entry.metadata.tokenSymbol,
|
|
54
|
+
tokenAddress: entry.metadata.tokenAddress,
|
|
55
|
+
type: parseIntentMetadataType(entry.metadata.type),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const intents = delegations.filter(needsIntent).map(toIntent);
|
|
59
|
+
if (intents.length === 0) {
|
|
60
|
+
return 'already-done';
|
|
61
|
+
}
|
|
62
|
+
await messenger.call('ChompApiService:createIntents', intents);
|
|
63
|
+
return 'completed';
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=register-intents.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-intents.mjs","sourceRoot":"","sources":["../../src/steps/register-intents.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EAC1B,kCAA8B;AAK/B;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAAC,IAAY;IAC3C,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,4EAA4E,IAAI,GAAG,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAS;IACvC,IAAI,EAAE,kBAAkB;IACxB,KAAK,CAAC,GAAG,CAAC,EACR,SAAS,EACT,OAAO,EACP,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB;QACC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACvD,SAAS,CAAC,IAAI,CAAC,iDAAiD,CAAC;YACjE,SAAS,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC;SAC/D,CAAC,CAAC;QAEH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAChC,eAAe;aACZ,MAAM,CAAC,CAAC,MAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC;aAC3D,GAAG,CAAC,CAAC,MAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CACrE,CAAC;QAEF,MAAM,qBAAqB,GAAG,yBAAyB,CACrD,gBAAgB,EAChB,uBAAuB,CACxB,CAAC;QAEF,MAAM,WAAW,GAAG,CAAC,KAAyB,EAAW,EAAE,CACzD,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC;YAC3D,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,eAAe,CAAC;YAClE,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;YACpD,qBAAqB,CAAC,KAAK,CAAC;YAC5B,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAoB,EAAE,CAAC,CAAC;YACjE,OAAO,EAAE,OAAO;YAChB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc;YAC7C,OAAO;YACP,QAAQ,EAAE;gBACR,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS;gBACnC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;gBACvC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,YAAY;gBACzC,IAAI,EAAE,uBAAuB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;aACnD;SACF,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,MAAM,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["import type { DelegationResponse } from '@metamask/authenticated-user-storage';\nimport type {\n IntentEntry,\n SendIntentParams,\n} from '@metamask/chomp-api-service';\n\nimport {\n equalsIgnoreCase,\n makeHasVedaRedeemerCaveat,\n} from './delegation-matchers';\nimport type { Step } from './step';\n\ntype IntentMetadataType = SendIntentParams['metadata']['type'];\n\n/**\n * Parses a delegation's metadata `type` field — typed as `string` in storage —\n * into the narrow set of CHOMP intent types. Throws if the field carries any\n * other value, since registering it as an intent would be a category error.\n *\n * @param type - The `type` field from `DelegationMetadata`.\n * @returns The same value, narrowed to `IntentMetadataType`.\n */\nfunction parseIntentMetadataType(type: string): IntentMetadataType {\n if (type !== 'cash-deposit' && type !== 'cash-withdrawal') {\n throw new Error(\n `Expected delegation type to be \"cash-deposit\" or \"cash-withdrawal\", got \"${type}\"`,\n );\n }\n return type;\n}\n\n/**\n * Registers CHOMP intents for the auto-deposit / auto-withdrawal delegations\n * persisted by the build-delegation step.\n *\n * For each stored delegation between this account and CHOMP's delegate on\n * this chain, the step builds an intent referencing the stored\n * `delegationHash` and submits the batch to `POST /v1/intent`. Delegations\n * whose `delegationHash` already has an active intent on CHOMP are skipped\n * (revoked intents are re-registered). Reports `'already-done'` when every\n * eligible delegation already has an active intent.\n *\n * Once registered, CHOMP re-fetches the delegation from Authenticated User\n * Storage, re-validates it, and adds the account to its monitoring list so\n * subsequent eligible operations can be picked up automatically.\n */\nexport const registerIntentsStep: Step = {\n name: 'register-intents',\n async run({\n messenger,\n address,\n chainId,\n delegateAddress,\n redeemerEnforcer,\n vedaVaultAdapterAddress,\n }) {\n const [delegations, existingIntents] = await Promise.all([\n messenger.call('AuthenticatedUserStorageService:listDelegations'),\n messenger.call('ChompApiService:getIntentsByAddress', address),\n ]);\n\n const activeIntentHashes = new Set(\n existingIntents\n .filter((intent: IntentEntry) => intent.status === 'active')\n .map((intent: IntentEntry) => intent.delegationHash.toLowerCase()),\n );\n\n const hasVedaRedeemerCaveat = makeHasVedaRedeemerCaveat(\n redeemerEnforcer,\n vedaVaultAdapterAddress,\n );\n\n const needsIntent = (entry: DelegationResponse): boolean =>\n equalsIgnoreCase(entry.signedDelegation.delegator, address) &&\n equalsIgnoreCase(entry.signedDelegation.delegate, delegateAddress) &&\n equalsIgnoreCase(entry.metadata.chainIdHex, chainId) &&\n hasVedaRedeemerCaveat(entry) &&\n !activeIntentHashes.has(entry.metadata.delegationHash.toLowerCase());\n\n const toIntent = (entry: DelegationResponse): SendIntentParams => ({\n account: address,\n delegationHash: entry.metadata.delegationHash,\n chainId,\n metadata: {\n allowance: entry.metadata.allowance,\n tokenSymbol: entry.metadata.tokenSymbol,\n tokenAddress: entry.metadata.tokenAddress,\n type: parseIntentMetadataType(entry.metadata.type),\n },\n });\n\n const intents = delegations.filter(needsIntent).map(toIntent);\n\n if (intents.length === 0) {\n return 'already-done';\n }\n\n await messenger.call('ChompApiService:createIntents', intents);\n return 'completed';\n },\n};\n"]}
|
package/dist/steps/step.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.cjs","sourceRoot":"","sources":["../../src/steps/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 chainId: Hex;\n delegatorImplAddress: 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"]}
|
|
1
|
+
{"version":3,"file":"step.cjs","sourceRoot":"","sources":["../../src/steps/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 chainId: Hex;\n boringVaultAddress: Hex;\n delegateAddress: Hex;\n delegatorImplAddress: Hex;\n erc20TransferAmountEnforcer: Hex;\n musdTokenAddress: Hex;\n redeemerEnforcer: Hex;\n valueLteEnforcer: Hex;\n vedaVaultAdapterAddress: 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/steps/step.d.cts
CHANGED
|
@@ -7,7 +7,14 @@ export type StepContext = {
|
|
|
7
7
|
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
8
8
|
address: Hex;
|
|
9
9
|
chainId: Hex;
|
|
10
|
+
boringVaultAddress: Hex;
|
|
11
|
+
delegateAddress: Hex;
|
|
10
12
|
delegatorImplAddress: Hex;
|
|
13
|
+
erc20TransferAmountEnforcer: Hex;
|
|
14
|
+
musdTokenAddress: Hex;
|
|
15
|
+
redeemerEnforcer: Hex;
|
|
16
|
+
valueLteEnforcer: Hex;
|
|
17
|
+
vedaVaultAdapterAddress: Hex;
|
|
11
18
|
};
|
|
12
19
|
/**
|
|
13
20
|
* The outcome of running a single step in the Money Account upgrade sequence.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.cts","sourceRoot":"","sources":["../../src/steps/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,6CAAyC;AAE/F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,oBAAoB,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"step.d.cts","sourceRoot":"","sources":["../../src/steps/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,6CAAyC;AAE/F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,kBAAkB,EAAE,GAAG,CAAC;IACxB,eAAe,EAAE,GAAG,CAAC;IACrB,oBAAoB,EAAE,GAAG,CAAC;IAC1B,2BAA2B,EAAE,GAAG,CAAC;IACjC,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,uBAAuB,EAAE,GAAG,CAAC;CAC9B,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/steps/step.d.mts
CHANGED
|
@@ -7,7 +7,14 @@ export type StepContext = {
|
|
|
7
7
|
messenger: MoneyAccountUpgradeControllerMessenger;
|
|
8
8
|
address: Hex;
|
|
9
9
|
chainId: Hex;
|
|
10
|
+
boringVaultAddress: Hex;
|
|
11
|
+
delegateAddress: Hex;
|
|
10
12
|
delegatorImplAddress: Hex;
|
|
13
|
+
erc20TransferAmountEnforcer: Hex;
|
|
14
|
+
musdTokenAddress: Hex;
|
|
15
|
+
redeemerEnforcer: Hex;
|
|
16
|
+
valueLteEnforcer: Hex;
|
|
17
|
+
vedaVaultAdapterAddress: Hex;
|
|
11
18
|
};
|
|
12
19
|
/**
|
|
13
20
|
* The outcome of running a single step in the Money Account upgrade sequence.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.mts","sourceRoot":"","sources":["../../src/steps/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,6CAAyC;AAE/F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,oBAAoB,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"step.d.mts","sourceRoot":"","sources":["../../src/steps/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,sCAAsC,EAAE,6CAAyC;AAE/F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,sCAAsC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,kBAAkB,EAAE,GAAG,CAAC;IACxB,eAAe,EAAE,GAAG,CAAC;IACrB,oBAAoB,EAAE,GAAG,CAAC;IAC1B,2BAA2B,EAAE,GAAG,CAAC;IACjC,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,uBAAuB,EAAE,GAAG,CAAC;CAC9B,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/steps/step.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.mjs","sourceRoot":"","sources":["../../src/steps/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 chainId: Hex;\n delegatorImplAddress: 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"]}
|
|
1
|
+
{"version":3,"file":"step.mjs","sourceRoot":"","sources":["../../src/steps/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 chainId: Hex;\n boringVaultAddress: Hex;\n delegateAddress: Hex;\n delegatorImplAddress: Hex;\n erc20TransferAmountEnforcer: Hex;\n musdTokenAddress: Hex;\n redeemerEnforcer: Hex;\n valueLteEnforcer: Hex;\n vedaVaultAdapterAddress: 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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Configuration required to perform the Money Account upgrade sequence.\n *\n * `delegateAddress`, `musdTokenAddress`, and `vedaVaultAdapterAddress` come\n * from the CHOMP service details API. `delegatorImplAddress` and the caveat\n * enforcer addresses are resolved from `@metamask/delegation-deployments` for\n * the target chain. (DelegationManager resolution is delegated to\n * `@metamask/delegation-controller`, which handles delegation signing.)\n */\nexport type UpgradeConfig = {\n /** CHOMP's delegate address — receives the delegation. */\n delegateAddress: Hex;\n /** The mUSD token contract address (deposit-side delegation token). */\n musdTokenAddress: Hex;\n /** The Veda boring vault contract address (withdrawal-side delegation token, vmUSD). */\n boringVaultAddress: Hex;\n /** The Veda vault adapter contract address. */\n vedaVaultAdapterAddress: Hex;\n /** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */\n delegatorImplAddress: 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"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import type { Hex } from "@metamask/utils";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Configuration required to perform the Money Account upgrade sequence.
|
|
4
|
+
*
|
|
5
|
+
* `delegateAddress`, `musdTokenAddress`, and `vedaVaultAdapterAddress` come
|
|
6
|
+
* from the CHOMP service details API. `delegatorImplAddress` and the caveat
|
|
7
|
+
* enforcer addresses are resolved from `@metamask/delegation-deployments` for
|
|
8
|
+
* the target chain. (DelegationManager resolution is delegated to
|
|
9
|
+
* `@metamask/delegation-controller`, which handles delegation signing.)
|
|
5
10
|
*/
|
|
6
11
|
export type UpgradeConfig = {
|
|
7
12
|
/** CHOMP's delegate address — receives the delegation. */
|
|
8
13
|
delegateAddress: Hex;
|
|
9
|
-
/** The
|
|
10
|
-
delegatorImplAddress: Hex;
|
|
11
|
-
/** The mUSD token contract address. */
|
|
14
|
+
/** The mUSD token contract address (deposit-side delegation token). */
|
|
12
15
|
musdTokenAddress: Hex;
|
|
16
|
+
/** The Veda boring vault contract address (withdrawal-side delegation token, vmUSD). */
|
|
17
|
+
boringVaultAddress: Hex;
|
|
13
18
|
/** The Veda vault adapter contract address. */
|
|
14
19
|
vedaVaultAdapterAddress: Hex;
|
|
20
|
+
/** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */
|
|
21
|
+
delegatorImplAddress: Hex;
|
|
15
22
|
/** Address of the ERC20TransferAmountEnforcer caveat enforcer. */
|
|
16
23
|
erc20TransferAmountEnforcer: Hex;
|
|
17
24
|
/** Address of the RedeemerEnforcer caveat enforcer. */
|
|
@@ -19,9 +26,4 @@ export type UpgradeConfig = {
|
|
|
19
26
|
/** Address of the ValueLteEnforcer caveat enforcer. */
|
|
20
27
|
valueLteEnforcer: Hex;
|
|
21
28
|
};
|
|
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
29
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,eAAe,EAAE,GAAG,CAAC;IACrB,uEAAuE;IACvE,gBAAgB,EAAE,GAAG,CAAC;IACtB,wFAAwF;IACxF,kBAAkB,EAAE,GAAG,CAAC;IACxB,+CAA+C;IAC/C,uBAAuB,EAAE,GAAG,CAAC;IAC7B,sEAAsE;IACtE,oBAAoB,EAAE,GAAG,CAAC;IAC1B,kEAAkE;IAClE,2BAA2B,EAAE,GAAG,CAAC;IACjC,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;IACtB,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;CACvB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import type { Hex } from "@metamask/utils";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Configuration required to perform the Money Account upgrade sequence.
|
|
4
|
+
*
|
|
5
|
+
* `delegateAddress`, `musdTokenAddress`, and `vedaVaultAdapterAddress` come
|
|
6
|
+
* from the CHOMP service details API. `delegatorImplAddress` and the caveat
|
|
7
|
+
* enforcer addresses are resolved from `@metamask/delegation-deployments` for
|
|
8
|
+
* the target chain. (DelegationManager resolution is delegated to
|
|
9
|
+
* `@metamask/delegation-controller`, which handles delegation signing.)
|
|
5
10
|
*/
|
|
6
11
|
export type UpgradeConfig = {
|
|
7
12
|
/** CHOMP's delegate address — receives the delegation. */
|
|
8
13
|
delegateAddress: Hex;
|
|
9
|
-
/** The
|
|
10
|
-
delegatorImplAddress: Hex;
|
|
11
|
-
/** The mUSD token contract address. */
|
|
14
|
+
/** The mUSD token contract address (deposit-side delegation token). */
|
|
12
15
|
musdTokenAddress: Hex;
|
|
16
|
+
/** The Veda boring vault contract address (withdrawal-side delegation token, vmUSD). */
|
|
17
|
+
boringVaultAddress: Hex;
|
|
13
18
|
/** The Veda vault adapter contract address. */
|
|
14
19
|
vedaVaultAdapterAddress: Hex;
|
|
20
|
+
/** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */
|
|
21
|
+
delegatorImplAddress: Hex;
|
|
15
22
|
/** Address of the ERC20TransferAmountEnforcer caveat enforcer. */
|
|
16
23
|
erc20TransferAmountEnforcer: Hex;
|
|
17
24
|
/** Address of the RedeemerEnforcer caveat enforcer. */
|
|
@@ -19,9 +26,4 @@ export type UpgradeConfig = {
|
|
|
19
26
|
/** Address of the ValueLteEnforcer caveat enforcer. */
|
|
20
27
|
valueLteEnforcer: Hex;
|
|
21
28
|
};
|
|
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
29
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,eAAe,EAAE,GAAG,CAAC;IACrB,uEAAuE;IACvE,gBAAgB,EAAE,GAAG,CAAC;IACtB,wFAAwF;IACxF,kBAAkB,EAAE,GAAG,CAAC;IACxB,+CAA+C;IAC/C,uBAAuB,EAAE,GAAG,CAAC;IAC7B,sEAAsE;IACtE,oBAAoB,EAAE,GAAG,CAAC;IAC1B,kEAAkE;IAClE,2BAA2B,EAAE,GAAG,CAAC;IACjC,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;IACtB,uDAAuD;IACvD,gBAAgB,EAAE,GAAG,CAAC;CACvB,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * Configuration required to perform the Money Account upgrade sequence.\n *\n * `delegateAddress`, `musdTokenAddress`, and `vedaVaultAdapterAddress` come\n * from the CHOMP service details API. `delegatorImplAddress` and the caveat\n * enforcer addresses are resolved from `@metamask/delegation-deployments` for\n * the target chain. (DelegationManager resolution is delegated to\n * `@metamask/delegation-controller`, which handles delegation signing.)\n */\nexport type UpgradeConfig = {\n /** CHOMP's delegate address — receives the delegation. */\n delegateAddress: Hex;\n /** The mUSD token contract address (deposit-side delegation token). */\n musdTokenAddress: Hex;\n /** The Veda boring vault contract address (withdrawal-side delegation token, vmUSD). */\n boringVaultAddress: Hex;\n /** The Veda vault adapter contract address. */\n vedaVaultAdapterAddress: Hex;\n /** The EIP-7702 delegation target (EIP7702StatelessDeleGatorImpl). */\n delegatorImplAddress: 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/money-account-upgrade-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MetaMask Money account upgrade controller",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -53,11 +53,15 @@
|
|
|
53
53
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@metamask/authenticated-user-storage": "^1.0.1",
|
|
56
57
|
"@metamask/base-controller": "^9.1.0",
|
|
57
|
-
"@metamask/chomp-api-service": "^3.
|
|
58
|
-
"@metamask/
|
|
58
|
+
"@metamask/chomp-api-service": "^3.1.0",
|
|
59
|
+
"@metamask/delegation-controller": "^3.0.0",
|
|
60
|
+
"@metamask/delegation-core": "^2.0.0",
|
|
61
|
+
"@metamask/delegation-deployments": "^1.3.0",
|
|
62
|
+
"@metamask/keyring-controller": "^25.5.0",
|
|
59
63
|
"@metamask/messenger": "^1.2.0",
|
|
60
|
-
"@metamask/network-controller": "^
|
|
64
|
+
"@metamask/network-controller": "^31.1.0",
|
|
61
65
|
"@metamask/utils": "^11.9.0"
|
|
62
66
|
},
|
|
63
67
|
"devDependencies": {
|
|
@@ -66,6 +70,7 @@
|
|
|
66
70
|
"@types/jest": "^29.5.14",
|
|
67
71
|
"deepmerge": "^4.2.2",
|
|
68
72
|
"jest": "^29.7.0",
|
|
73
|
+
"jest-environment-node": "^29.7.0",
|
|
69
74
|
"ts-jest": "^29.2.5",
|
|
70
75
|
"tsx": "^4.20.5",
|
|
71
76
|
"typedoc": "^0.25.13",
|