@metamask-previews/money-account-utils 1.1.0-preview-00a181c → 1.1.0-preview-cfd35b8dd
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 +7 -0
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/vault-config.cjs +91 -0
- package/dist/vault-config.cjs.map +1 -0
- package/dist/vault-config.d.cts +48 -0
- package/dist/vault-config.d.cts.map +1 -0
- package/dist/vault-config.d.mts +48 -0
- package/dist/vault-config.d.mts.map +1 -0
- package/dist/vault-config.mjs +85 -0
- package/dist/vault-config.mjs.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add Money Account vault-config helpers, shared by the upgrade controller and clients ([#10072](https://github.com/MetaMask/core/pull/10072))
|
|
13
|
+
- `getMoneyAccountVaultConfig` and `parseMoneyAccountVaultConfig` read and validate the `moneyAccountVaultConfig` remote feature flag into a `MoneyAccountVaultConfig` whose chain id and addresses are known-good `Hex`
|
|
14
|
+
- `areMoneyAccountVaultConfigsEqual` compares configs field by field so consumers keyed on the config (bootstraps, caches) can detect changes
|
|
15
|
+
- `MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME` names the flag
|
|
16
|
+
|
|
10
17
|
### Changed
|
|
11
18
|
|
|
12
19
|
- Bump `@metamask/transaction-controller` from `^69.4.0` to `^69.7.0` ([#9780](https://github.com/MetaMask/core/pull/9780), [#9798](https://github.com/MetaMask/core/pull/9798), [#9823](https://github.com/MetaMask/core/pull/9823), [#9960](https://github.com/MetaMask/core/pull/9960), [#9969](https://github.com/MetaMask/core/pull/9969), [#10046](https://github.com/MetaMask/core/pull/10046))
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSharesForWithdrawal = exports.getMoneyAccountDepositAssetId = exports.getMoneyAccountDepositAssetAddress = exports.buildMoneyAccountWithdrawPlaceholderBatch = exports.buildMoneyAccountWithdrawBatch = exports.buildMoneyAccountDepositPlaceholderBatch = exports.buildMoneyAccountDepositBatch = exports.applySlippage = exports.TELLER_ABI = exports.isMusdOnMoneyAccountChain = exports.isMusdTokenOnChain = exports.isMusdToken = exports.getTokenDisplaySymbol = exports.MUSD_MONEY_ACCOUNT_CHAIN_IDS = exports.MUSD_CURRENCY = exports.MUSD_TOKEN_ASSET_ID_BY_CHAIN = exports.MUSD_TOKEN_ADDRESS_BY_CHAIN = exports.MUSD_TOKEN_ADDRESS = exports.MUSD_DECIMALS = exports.MUSD_TOKEN = void 0;
|
|
3
|
+
exports.parseMoneyAccountVaultConfig = exports.getMoneyAccountVaultConfig = exports.areMoneyAccountVaultConfigsEqual = exports.MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = exports.getSharesForWithdrawal = exports.getMoneyAccountDepositAssetId = exports.getMoneyAccountDepositAssetAddress = exports.buildMoneyAccountWithdrawPlaceholderBatch = exports.buildMoneyAccountWithdrawBatch = exports.buildMoneyAccountDepositPlaceholderBatch = exports.buildMoneyAccountDepositBatch = exports.applySlippage = exports.TELLER_ABI = exports.isMusdOnMoneyAccountChain = exports.isMusdTokenOnChain = exports.isMusdToken = exports.getTokenDisplaySymbol = exports.MUSD_MONEY_ACCOUNT_CHAIN_IDS = exports.MUSD_CURRENCY = exports.MUSD_TOKEN_ASSET_ID_BY_CHAIN = exports.MUSD_TOKEN_ADDRESS_BY_CHAIN = exports.MUSD_TOKEN_ADDRESS = exports.MUSD_DECIMALS = exports.MUSD_TOKEN = void 0;
|
|
4
4
|
var musd_js_1 = require("./musd.cjs");
|
|
5
5
|
Object.defineProperty(exports, "MUSD_TOKEN", { enumerable: true, get: function () { return musd_js_1.MUSD_TOKEN; } });
|
|
6
6
|
Object.defineProperty(exports, "MUSD_DECIMALS", { enumerable: true, get: function () { return musd_js_1.MUSD_DECIMALS; } });
|
|
@@ -23,4 +23,9 @@ Object.defineProperty(exports, "buildMoneyAccountWithdrawPlaceholderBatch", { en
|
|
|
23
23
|
Object.defineProperty(exports, "getMoneyAccountDepositAssetAddress", { enumerable: true, get: function () { return transactions_js_1.getMoneyAccountDepositAssetAddress; } });
|
|
24
24
|
Object.defineProperty(exports, "getMoneyAccountDepositAssetId", { enumerable: true, get: function () { return transactions_js_1.getMoneyAccountDepositAssetId; } });
|
|
25
25
|
Object.defineProperty(exports, "getSharesForWithdrawal", { enumerable: true, get: function () { return transactions_js_1.getSharesForWithdrawal; } });
|
|
26
|
+
var vault_config_js_1 = require("./vault-config.cjs");
|
|
27
|
+
Object.defineProperty(exports, "MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME", { enumerable: true, get: function () { return vault_config_js_1.MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME; } });
|
|
28
|
+
Object.defineProperty(exports, "areMoneyAccountVaultConfigsEqual", { enumerable: true, get: function () { return vault_config_js_1.areMoneyAccountVaultConfigsEqual; } });
|
|
29
|
+
Object.defineProperty(exports, "getMoneyAccountVaultConfig", { enumerable: true, get: function () { return vault_config_js_1.getMoneyAccountVaultConfig; } });
|
|
30
|
+
Object.defineProperty(exports, "parseMoneyAccountVaultConfig", { enumerable: true, get: function () { return vault_config_js_1.parseMoneyAccountVaultConfig; } });
|
|
26
31
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAYmB;AAXjB,qGAAA,UAAU,OAAA;AACV,wGAAA,aAAa,OAAA;AACb,6GAAA,kBAAkB,OAAA;AAClB,sHAAA,2BAA2B,OAAA;AAC3B,uHAAA,4BAA4B,OAAA;AAC5B,wGAAA,aAAa,OAAA;AACb,uHAAA,4BAA4B,OAAA;AAC5B,gHAAA,qBAAqB,OAAA;AACrB,sGAAA,WAAW,OAAA;AACX,6GAAA,kBAAkB,OAAA;AAClB,oHAAA,yBAAyB,OAAA;AAE3B,sDAU2B;AATzB,6GAAA,UAAU,OAAA;AACV,gHAAA,aAAa,OAAA;AACb,gIAAA,6BAA6B,OAAA;AAC7B,2IAAA,wCAAwC,OAAA;AACxC,iIAAA,8BAA8B,OAAA;AAC9B,4IAAA,yCAAyC,OAAA;AACzC,qIAAA,kCAAkC,OAAA;AAClC,gIAAA,6BAA6B,OAAA;AAC7B,yHAAA,sBAAsB,OAAA","sourcesContent":["export {\n MUSD_TOKEN,\n MUSD_DECIMALS,\n MUSD_TOKEN_ADDRESS,\n MUSD_TOKEN_ADDRESS_BY_CHAIN,\n MUSD_TOKEN_ASSET_ID_BY_CHAIN,\n MUSD_CURRENCY,\n MUSD_MONEY_ACCOUNT_CHAIN_IDS,\n getTokenDisplaySymbol,\n isMusdToken,\n isMusdTokenOnChain,\n isMusdOnMoneyAccountChain,\n} from './musd.js';\nexport {\n TELLER_ABI,\n applySlippage,\n buildMoneyAccountDepositBatch,\n buildMoneyAccountDepositPlaceholderBatch,\n buildMoneyAccountWithdrawBatch,\n buildMoneyAccountWithdrawPlaceholderBatch,\n getMoneyAccountDepositAssetAddress,\n getMoneyAccountDepositAssetId,\n getSharesForWithdrawal,\n} from './transactions.js';\nexport type {\n BuildMoneyAccountDepositBatchOptions,\n BuildMoneyAccountDepositPlaceholderBatchOptions,\n BuildMoneyAccountWithdrawBatchOptions,\n BuildMoneyAccountWithdrawPlaceholderBatchOptions,\n MoneyAccountDepositBatchResult,\n MoneyAccountDepositPlaceholderBatchResult,\n MoneyAccountPlaceholderTxParams,\n MoneyAccountTxParams,\n MoneyAccountWithdrawBatchResult,\n MoneyAccountWithdrawPlaceholderBatchResult,\n} from './transactions.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAYmB;AAXjB,qGAAA,UAAU,OAAA;AACV,wGAAA,aAAa,OAAA;AACb,6GAAA,kBAAkB,OAAA;AAClB,sHAAA,2BAA2B,OAAA;AAC3B,uHAAA,4BAA4B,OAAA;AAC5B,wGAAA,aAAa,OAAA;AACb,uHAAA,4BAA4B,OAAA;AAC5B,gHAAA,qBAAqB,OAAA;AACrB,sGAAA,WAAW,OAAA;AACX,6GAAA,kBAAkB,OAAA;AAClB,oHAAA,yBAAyB,OAAA;AAE3B,sDAU2B;AATzB,6GAAA,UAAU,OAAA;AACV,gHAAA,aAAa,OAAA;AACb,gIAAA,6BAA6B,OAAA;AAC7B,2IAAA,wCAAwC,OAAA;AACxC,iIAAA,8BAA8B,OAAA;AAC9B,4IAAA,yCAAyC,OAAA;AACzC,qIAAA,kCAAkC,OAAA;AAClC,gIAAA,6BAA6B,OAAA;AAC7B,yHAAA,sBAAsB,OAAA;AAExB,sDAK2B;AAJzB,uIAAA,oCAAoC,OAAA;AACpC,mIAAA,gCAAgC,OAAA;AAChC,6HAAA,0BAA0B,OAAA;AAC1B,+HAAA,4BAA4B,OAAA","sourcesContent":["export {\n MUSD_TOKEN,\n MUSD_DECIMALS,\n MUSD_TOKEN_ADDRESS,\n MUSD_TOKEN_ADDRESS_BY_CHAIN,\n MUSD_TOKEN_ASSET_ID_BY_CHAIN,\n MUSD_CURRENCY,\n MUSD_MONEY_ACCOUNT_CHAIN_IDS,\n getTokenDisplaySymbol,\n isMusdToken,\n isMusdTokenOnChain,\n isMusdOnMoneyAccountChain,\n} from './musd.js';\nexport {\n TELLER_ABI,\n applySlippage,\n buildMoneyAccountDepositBatch,\n buildMoneyAccountDepositPlaceholderBatch,\n buildMoneyAccountWithdrawBatch,\n buildMoneyAccountWithdrawPlaceholderBatch,\n getMoneyAccountDepositAssetAddress,\n getMoneyAccountDepositAssetId,\n getSharesForWithdrawal,\n} from './transactions.js';\nexport {\n MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME,\n areMoneyAccountVaultConfigsEqual,\n getMoneyAccountVaultConfig,\n parseMoneyAccountVaultConfig,\n} from './vault-config.js';\nexport type { MoneyAccountVaultConfig } from './vault-config.js';\nexport type {\n BuildMoneyAccountDepositBatchOptions,\n BuildMoneyAccountDepositPlaceholderBatchOptions,\n BuildMoneyAccountWithdrawBatchOptions,\n BuildMoneyAccountWithdrawPlaceholderBatchOptions,\n MoneyAccountDepositBatchResult,\n MoneyAccountDepositPlaceholderBatchResult,\n MoneyAccountPlaceholderTxParams,\n MoneyAccountTxParams,\n MoneyAccountWithdrawBatchResult,\n MoneyAccountWithdrawPlaceholderBatchResult,\n} from './transactions.js';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { MUSD_TOKEN, MUSD_DECIMALS, MUSD_TOKEN_ADDRESS, MUSD_TOKEN_ADDRESS_BY_CHAIN, MUSD_TOKEN_ASSET_ID_BY_CHAIN, MUSD_CURRENCY, MUSD_MONEY_ACCOUNT_CHAIN_IDS, getTokenDisplaySymbol, isMusdToken, isMusdTokenOnChain, isMusdOnMoneyAccountChain, } from "./musd.cjs";
|
|
2
2
|
export { TELLER_ABI, applySlippage, buildMoneyAccountDepositBatch, buildMoneyAccountDepositPlaceholderBatch, buildMoneyAccountWithdrawBatch, buildMoneyAccountWithdrawPlaceholderBatch, getMoneyAccountDepositAssetAddress, getMoneyAccountDepositAssetId, getSharesForWithdrawal, } from "./transactions.cjs";
|
|
3
|
+
export { MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME, areMoneyAccountVaultConfigsEqual, getMoneyAccountVaultConfig, parseMoneyAccountVaultConfig, } from "./vault-config.cjs";
|
|
4
|
+
export type { MoneyAccountVaultConfig } from "./vault-config.cjs";
|
|
3
5
|
export type { BuildMoneyAccountDepositBatchOptions, BuildMoneyAccountDepositPlaceholderBatchOptions, BuildMoneyAccountWithdrawBatchOptions, BuildMoneyAccountWithdrawPlaceholderBatchOptions, MoneyAccountDepositBatchResult, MoneyAccountDepositPlaceholderBatchResult, MoneyAccountPlaceholderTxParams, MoneyAccountTxParams, MoneyAccountWithdrawBatchResult, MoneyAccountWithdrawPlaceholderBatchResult, } from "./transactions.cjs";
|
|
4
6
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,GAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,GACvB,2BAA0B;AAC3B,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,qCAAqC,EACrC,gDAAgD,EAChD,8BAA8B,EAC9B,yCAAyC,EACzC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,0CAA0C,GAC3C,2BAA0B"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,GAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,GACvB,2BAA0B;AAC3B,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,GAC7B,2BAA0B;AAC3B,YAAY,EAAE,uBAAuB,EAAE,2BAA0B;AACjE,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,qCAAqC,EACrC,gDAAgD,EAChD,8BAA8B,EAC9B,yCAAyC,EACzC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,0CAA0C,GAC3C,2BAA0B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { MUSD_TOKEN, MUSD_DECIMALS, MUSD_TOKEN_ADDRESS, MUSD_TOKEN_ADDRESS_BY_CHAIN, MUSD_TOKEN_ASSET_ID_BY_CHAIN, MUSD_CURRENCY, MUSD_MONEY_ACCOUNT_CHAIN_IDS, getTokenDisplaySymbol, isMusdToken, isMusdTokenOnChain, isMusdOnMoneyAccountChain, } from "./musd.mjs";
|
|
2
2
|
export { TELLER_ABI, applySlippage, buildMoneyAccountDepositBatch, buildMoneyAccountDepositPlaceholderBatch, buildMoneyAccountWithdrawBatch, buildMoneyAccountWithdrawPlaceholderBatch, getMoneyAccountDepositAssetAddress, getMoneyAccountDepositAssetId, getSharesForWithdrawal, } from "./transactions.mjs";
|
|
3
|
+
export { MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME, areMoneyAccountVaultConfigsEqual, getMoneyAccountVaultConfig, parseMoneyAccountVaultConfig, } from "./vault-config.mjs";
|
|
4
|
+
export type { MoneyAccountVaultConfig } from "./vault-config.mjs";
|
|
3
5
|
export type { BuildMoneyAccountDepositBatchOptions, BuildMoneyAccountDepositPlaceholderBatchOptions, BuildMoneyAccountWithdrawBatchOptions, BuildMoneyAccountWithdrawPlaceholderBatchOptions, MoneyAccountDepositBatchResult, MoneyAccountDepositPlaceholderBatchResult, MoneyAccountPlaceholderTxParams, MoneyAccountTxParams, MoneyAccountWithdrawBatchResult, MoneyAccountWithdrawPlaceholderBatchResult, } from "./transactions.mjs";
|
|
4
6
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,GAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,GACvB,2BAA0B;AAC3B,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,qCAAqC,EACrC,gDAAgD,EAChD,8BAA8B,EAC9B,yCAAyC,EACzC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,0CAA0C,GAC3C,2BAA0B"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,GAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,GACvB,2BAA0B;AAC3B,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,GAC7B,2BAA0B;AAC3B,YAAY,EAAE,uBAAuB,EAAE,2BAA0B;AACjE,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,qCAAqC,EACrC,gDAAgD,EAChD,8BAA8B,EAC9B,yCAAyC,EACzC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,0CAA0C,GAC3C,2BAA0B"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { MUSD_TOKEN, MUSD_DECIMALS, MUSD_TOKEN_ADDRESS, MUSD_TOKEN_ADDRESS_BY_CHAIN, MUSD_TOKEN_ASSET_ID_BY_CHAIN, MUSD_CURRENCY, MUSD_MONEY_ACCOUNT_CHAIN_IDS, getTokenDisplaySymbol, isMusdToken, isMusdTokenOnChain, isMusdOnMoneyAccountChain } from "./musd.mjs";
|
|
2
2
|
export { TELLER_ABI, applySlippage, buildMoneyAccountDepositBatch, buildMoneyAccountDepositPlaceholderBatch, buildMoneyAccountWithdrawBatch, buildMoneyAccountWithdrawPlaceholderBatch, getMoneyAccountDepositAssetAddress, getMoneyAccountDepositAssetId, getSharesForWithdrawal } from "./transactions.mjs";
|
|
3
|
+
export { MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME, areMoneyAccountVaultConfigsEqual, getMoneyAccountVaultConfig, parseMoneyAccountVaultConfig } from "./vault-config.mjs";
|
|
3
4
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,EACvB,2BAA0B","sourcesContent":["export {\n MUSD_TOKEN,\n MUSD_DECIMALS,\n MUSD_TOKEN_ADDRESS,\n MUSD_TOKEN_ADDRESS_BY_CHAIN,\n MUSD_TOKEN_ASSET_ID_BY_CHAIN,\n MUSD_CURRENCY,\n MUSD_MONEY_ACCOUNT_CHAIN_IDS,\n getTokenDisplaySymbol,\n isMusdToken,\n isMusdTokenOnChain,\n isMusdOnMoneyAccountChain,\n} from './musd.js';\nexport {\n TELLER_ABI,\n applySlippage,\n buildMoneyAccountDepositBatch,\n buildMoneyAccountDepositPlaceholderBatch,\n buildMoneyAccountWithdrawBatch,\n buildMoneyAccountWithdrawPlaceholderBatch,\n getMoneyAccountDepositAssetAddress,\n getMoneyAccountDepositAssetId,\n getSharesForWithdrawal,\n} from './transactions.js';\nexport type {\n BuildMoneyAccountDepositBatchOptions,\n BuildMoneyAccountDepositPlaceholderBatchOptions,\n BuildMoneyAccountWithdrawBatchOptions,\n BuildMoneyAccountWithdrawPlaceholderBatchOptions,\n MoneyAccountDepositBatchResult,\n MoneyAccountDepositPlaceholderBatchResult,\n MoneyAccountPlaceholderTxParams,\n MoneyAccountTxParams,\n MoneyAccountWithdrawBatchResult,\n MoneyAccountWithdrawPlaceholderBatchResult,\n} from './transactions.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,4BAA4B,EAC5B,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EAC1B,mBAAkB;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,6BAA6B,EAC7B,wCAAwC,EACxC,8BAA8B,EAC9B,yCAAyC,EACzC,kCAAkC,EAClC,6BAA6B,EAC7B,sBAAsB,EACvB,2BAA0B;AAC3B,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,EAC7B,2BAA0B","sourcesContent":["export {\n MUSD_TOKEN,\n MUSD_DECIMALS,\n MUSD_TOKEN_ADDRESS,\n MUSD_TOKEN_ADDRESS_BY_CHAIN,\n MUSD_TOKEN_ASSET_ID_BY_CHAIN,\n MUSD_CURRENCY,\n MUSD_MONEY_ACCOUNT_CHAIN_IDS,\n getTokenDisplaySymbol,\n isMusdToken,\n isMusdTokenOnChain,\n isMusdOnMoneyAccountChain,\n} from './musd.js';\nexport {\n TELLER_ABI,\n applySlippage,\n buildMoneyAccountDepositBatch,\n buildMoneyAccountDepositPlaceholderBatch,\n buildMoneyAccountWithdrawBatch,\n buildMoneyAccountWithdrawPlaceholderBatch,\n getMoneyAccountDepositAssetAddress,\n getMoneyAccountDepositAssetId,\n getSharesForWithdrawal,\n} from './transactions.js';\nexport {\n MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME,\n areMoneyAccountVaultConfigsEqual,\n getMoneyAccountVaultConfig,\n parseMoneyAccountVaultConfig,\n} from './vault-config.js';\nexport type { MoneyAccountVaultConfig } from './vault-config.js';\nexport type {\n BuildMoneyAccountDepositBatchOptions,\n BuildMoneyAccountDepositPlaceholderBatchOptions,\n BuildMoneyAccountWithdrawBatchOptions,\n BuildMoneyAccountWithdrawPlaceholderBatchOptions,\n MoneyAccountDepositBatchResult,\n MoneyAccountDepositPlaceholderBatchResult,\n MoneyAccountPlaceholderTxParams,\n MoneyAccountTxParams,\n MoneyAccountWithdrawBatchResult,\n MoneyAccountWithdrawPlaceholderBatchResult,\n} from './transactions.js';\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.areMoneyAccountVaultConfigsEqual = exports.getMoneyAccountVaultConfig = exports.parseMoneyAccountVaultConfig = exports.MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
/**
|
|
6
|
+
* The LaunchDarkly flag carrying the Money Account vault contracts. The same
|
|
7
|
+
* flag `@metamask/money-account-balance-service` reads, so the parsed chain id
|
|
8
|
+
* here is the chain the balance service talks to.
|
|
9
|
+
*/
|
|
10
|
+
exports.MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = 'moneyAccountVaultConfig';
|
|
11
|
+
/**
|
|
12
|
+
* Parses one raw vault-config field into an address.
|
|
13
|
+
*
|
|
14
|
+
* `isValidHexAddress` accepts an all-lowercase address or a valid ERC-55
|
|
15
|
+
* checksum, which is what ethers accepts when it encodes the calldata. The
|
|
16
|
+
* address is deliberately not normalised, so a checksummed address passes
|
|
17
|
+
* through unchanged.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The raw field value.
|
|
20
|
+
* @returns The address, or `undefined` if it is missing or malformed.
|
|
21
|
+
*/
|
|
22
|
+
const parseAddress = (value) => (0, utils_1.isStrictHexString)(value) && (0, utils_1.isValidHexAddress)(value) ? value : undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Parses the raw `moneyAccountVaultConfig` remote feature flag into a config
|
|
25
|
+
* whose chain id and addresses are known-good `Hex`.
|
|
26
|
+
*
|
|
27
|
+
* @param raw - The raw remote feature flag value.
|
|
28
|
+
* @returns The parsed vault config, or `undefined` if any field is missing or
|
|
29
|
+
* malformed.
|
|
30
|
+
*/
|
|
31
|
+
const parseMoneyAccountVaultConfig = (raw) => {
|
|
32
|
+
if (!(0, utils_1.isObject)(raw)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const { chainId } = raw;
|
|
36
|
+
if (!(0, utils_1.isStrictHexString)(chainId)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const boringVault = parseAddress(raw.boringVault);
|
|
40
|
+
const tellerAddress = parseAddress(raw.tellerAddress);
|
|
41
|
+
const accountantAddress = parseAddress(raw.accountantAddress);
|
|
42
|
+
const lensAddress = parseAddress(raw.lensAddress);
|
|
43
|
+
const underlyingToken = parseAddress(raw.underlyingToken);
|
|
44
|
+
if (!boringVault ||
|
|
45
|
+
!tellerAddress ||
|
|
46
|
+
!accountantAddress ||
|
|
47
|
+
!lensAddress ||
|
|
48
|
+
!underlyingToken) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
chainId,
|
|
53
|
+
boringVault,
|
|
54
|
+
tellerAddress,
|
|
55
|
+
accountantAddress,
|
|
56
|
+
lensAddress,
|
|
57
|
+
underlyingToken,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.parseMoneyAccountVaultConfig = parseMoneyAccountVaultConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Reads and parses the Money Account vault config out of the remote feature
|
|
63
|
+
* flags.
|
|
64
|
+
*
|
|
65
|
+
* @param remoteFeatureFlags - The remote feature flags.
|
|
66
|
+
* @returns The parsed vault config, or `undefined` when the flag is unserved
|
|
67
|
+
* or malformed.
|
|
68
|
+
*/
|
|
69
|
+
function getMoneyAccountVaultConfig(remoteFeatureFlags) {
|
|
70
|
+
return (0, exports.parseMoneyAccountVaultConfig)(remoteFeatureFlags?.[exports.MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME]);
|
|
71
|
+
}
|
|
72
|
+
exports.getMoneyAccountVaultConfig = getMoneyAccountVaultConfig;
|
|
73
|
+
/**
|
|
74
|
+
* Compares vault configs field by field. Any difference means the vault the
|
|
75
|
+
* config points at has changed and consumers keyed on it (bootstraps, caches)
|
|
76
|
+
* must re-run.
|
|
77
|
+
*
|
|
78
|
+
* @param a - One vault config.
|
|
79
|
+
* @param b - The other vault config.
|
|
80
|
+
* @returns Whether the configs are equal.
|
|
81
|
+
*/
|
|
82
|
+
function areMoneyAccountVaultConfigsEqual(a, b) {
|
|
83
|
+
return (a.chainId === b.chainId &&
|
|
84
|
+
a.boringVault === b.boringVault &&
|
|
85
|
+
a.tellerAddress === b.tellerAddress &&
|
|
86
|
+
a.accountantAddress === b.accountantAddress &&
|
|
87
|
+
a.lensAddress === b.lensAddress &&
|
|
88
|
+
a.underlyingToken === b.underlyingToken);
|
|
89
|
+
}
|
|
90
|
+
exports.areMoneyAccountVaultConfigsEqual = areMoneyAccountVaultConfigsEqual;
|
|
91
|
+
//# sourceMappingURL=vault-config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-config.cjs","sourceRoot":"","sources":["../src/vault-config.ts"],"names":[],"mappings":";;;AAAA,2CAIyB;AAGzB;;;;GAIG;AACU,QAAA,oCAAoC,GAAG,yBAAyB,CAAC;AAe9E;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,KAAc,EAAmB,EAAE,CACvD,IAAA,yBAAiB,EAAC,KAAK,CAAC,IAAI,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAE3E;;;;;;;GAOG;AACI,MAAM,4BAA4B,GAAG,CAC1C,GAAY,EACyB,EAAE;IACvC,IAAI,CAAC,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IACxB,IAAI,CAAC,IAAA,yBAAiB,EAAC,OAAO,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtD,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAE1D,IACE,CAAC,WAAW;QACZ,CAAC,aAAa;QACd,CAAC,iBAAiB;QAClB,CAAC,WAAW;QACZ,CAAC,eAAe,EAChB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO;QACP,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,4BAA4B,gCAoCvC;AAEF;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACxC,kBAAuD;IAEvD,OAAO,IAAA,oCAA4B,EACjC,kBAAkB,EAAE,CAAC,4CAAoC,CAAC,CAC3D,CAAC;AACJ,CAAC;AAND,gEAMC;AAED;;;;;;;;GAQG;AACH,SAAgB,gCAAgC,CAC9C,CAA0B,EAC1B,CAA0B;IAE1B,OAAO,CACL,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;QACnC,CAAC,CAAC,iBAAiB,KAAK,CAAC,CAAC,iBAAiB;QAC3C,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,eAAe,KAAK,CAAC,CAAC,eAAe,CACxC,CAAC;AACJ,CAAC;AAZD,4EAYC","sourcesContent":["import {\n isObject,\n isStrictHexString,\n isValidHexAddress,\n} from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * The LaunchDarkly flag carrying the Money Account vault contracts. The same\n * flag `@metamask/money-account-balance-service` reads, so the parsed chain id\n * here is the chain the balance service talks to.\n */\nexport const MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = 'moneyAccountVaultConfig';\n\n/**\n * The Money Account vault contracts served via remote feature flags, with the\n * chain id and every address validated as known-good `Hex`.\n */\nexport type MoneyAccountVaultConfig = {\n chainId: Hex;\n boringVault: Hex;\n tellerAddress: Hex;\n accountantAddress: Hex;\n lensAddress: Hex;\n underlyingToken: Hex;\n};\n\n/**\n * Parses one raw vault-config field into an address.\n *\n * `isValidHexAddress` accepts an all-lowercase address or a valid ERC-55\n * checksum, which is what ethers accepts when it encodes the calldata. The\n * address is deliberately not normalised, so a checksummed address passes\n * through unchanged.\n *\n * @param value - The raw field value.\n * @returns The address, or `undefined` if it is missing or malformed.\n */\nconst parseAddress = (value: unknown): Hex | undefined =>\n isStrictHexString(value) && isValidHexAddress(value) ? value : undefined;\n\n/**\n * Parses the raw `moneyAccountVaultConfig` remote feature flag into a config\n * whose chain id and addresses are known-good `Hex`.\n *\n * @param raw - The raw remote feature flag value.\n * @returns The parsed vault config, or `undefined` if any field is missing or\n * malformed.\n */\nexport const parseMoneyAccountVaultConfig = (\n raw: unknown,\n): MoneyAccountVaultConfig | undefined => {\n if (!isObject(raw)) {\n return undefined;\n }\n\n const { chainId } = raw;\n if (!isStrictHexString(chainId)) {\n return undefined;\n }\n\n const boringVault = parseAddress(raw.boringVault);\n const tellerAddress = parseAddress(raw.tellerAddress);\n const accountantAddress = parseAddress(raw.accountantAddress);\n const lensAddress = parseAddress(raw.lensAddress);\n const underlyingToken = parseAddress(raw.underlyingToken);\n\n if (\n !boringVault ||\n !tellerAddress ||\n !accountantAddress ||\n !lensAddress ||\n !underlyingToken\n ) {\n return undefined;\n }\n\n return {\n chainId,\n boringVault,\n tellerAddress,\n accountantAddress,\n lensAddress,\n underlyingToken,\n };\n};\n\n/**\n * Reads and parses the Money Account vault config out of the remote feature\n * flags.\n *\n * @param remoteFeatureFlags - The remote feature flags.\n * @returns The parsed vault config, or `undefined` when the flag is unserved\n * or malformed.\n */\nexport function getMoneyAccountVaultConfig(\n remoteFeatureFlags: Record<string, unknown> | undefined,\n): MoneyAccountVaultConfig | undefined {\n return parseMoneyAccountVaultConfig(\n remoteFeatureFlags?.[MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME],\n );\n}\n\n/**\n * Compares vault configs field by field. Any difference means the vault the\n * config points at has changed and consumers keyed on it (bootstraps, caches)\n * must re-run.\n *\n * @param a - One vault config.\n * @param b - The other vault config.\n * @returns Whether the configs are equal.\n */\nexport function areMoneyAccountVaultConfigsEqual(\n a: MoneyAccountVaultConfig,\n b: MoneyAccountVaultConfig,\n): boolean {\n return (\n a.chainId === b.chainId &&\n a.boringVault === b.boringVault &&\n a.tellerAddress === b.tellerAddress &&\n a.accountantAddress === b.accountantAddress &&\n a.lensAddress === b.lensAddress &&\n a.underlyingToken === b.underlyingToken\n );\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* The LaunchDarkly flag carrying the Money Account vault contracts. The same
|
|
4
|
+
* flag `@metamask/money-account-balance-service` reads, so the parsed chain id
|
|
5
|
+
* here is the chain the balance service talks to.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = "moneyAccountVaultConfig";
|
|
8
|
+
/**
|
|
9
|
+
* The Money Account vault contracts served via remote feature flags, with the
|
|
10
|
+
* chain id and every address validated as known-good `Hex`.
|
|
11
|
+
*/
|
|
12
|
+
export type MoneyAccountVaultConfig = {
|
|
13
|
+
chainId: Hex;
|
|
14
|
+
boringVault: Hex;
|
|
15
|
+
tellerAddress: Hex;
|
|
16
|
+
accountantAddress: Hex;
|
|
17
|
+
lensAddress: Hex;
|
|
18
|
+
underlyingToken: Hex;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parses the raw `moneyAccountVaultConfig` remote feature flag into a config
|
|
22
|
+
* whose chain id and addresses are known-good `Hex`.
|
|
23
|
+
*
|
|
24
|
+
* @param raw - The raw remote feature flag value.
|
|
25
|
+
* @returns The parsed vault config, or `undefined` if any field is missing or
|
|
26
|
+
* malformed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const parseMoneyAccountVaultConfig: (raw: unknown) => MoneyAccountVaultConfig | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Reads and parses the Money Account vault config out of the remote feature
|
|
31
|
+
* flags.
|
|
32
|
+
*
|
|
33
|
+
* @param remoteFeatureFlags - The remote feature flags.
|
|
34
|
+
* @returns The parsed vault config, or `undefined` when the flag is unserved
|
|
35
|
+
* or malformed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMoneyAccountVaultConfig(remoteFeatureFlags: Record<string, unknown> | undefined): MoneyAccountVaultConfig | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Compares vault configs field by field. Any difference means the vault the
|
|
40
|
+
* config points at has changed and consumers keyed on it (bootstraps, caches)
|
|
41
|
+
* must re-run.
|
|
42
|
+
*
|
|
43
|
+
* @param a - One vault config.
|
|
44
|
+
* @param b - The other vault config.
|
|
45
|
+
* @returns Whether the configs are equal.
|
|
46
|
+
*/
|
|
47
|
+
export declare function areMoneyAccountVaultConfigsEqual(a: MoneyAccountVaultConfig, b: MoneyAccountVaultConfig): boolean;
|
|
48
|
+
//# sourceMappingURL=vault-config.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-config.d.cts","sourceRoot":"","sources":["../src/vault-config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,4BAA4B,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,GAAG,CAAC;IACjB,aAAa,EAAE,GAAG,CAAC;IACnB,iBAAiB,EAAE,GAAG,CAAC;IACvB,WAAW,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC;AAgBF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,QAClC,OAAO,KACX,uBAAuB,GAAG,SAkC5B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,uBAAuB,GAAG,SAAS,CAIrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,CAAC,EAAE,uBAAuB,EAC1B,CAAC,EAAE,uBAAuB,GACzB,OAAO,CAST"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* The LaunchDarkly flag carrying the Money Account vault contracts. The same
|
|
4
|
+
* flag `@metamask/money-account-balance-service` reads, so the parsed chain id
|
|
5
|
+
* here is the chain the balance service talks to.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = "moneyAccountVaultConfig";
|
|
8
|
+
/**
|
|
9
|
+
* The Money Account vault contracts served via remote feature flags, with the
|
|
10
|
+
* chain id and every address validated as known-good `Hex`.
|
|
11
|
+
*/
|
|
12
|
+
export type MoneyAccountVaultConfig = {
|
|
13
|
+
chainId: Hex;
|
|
14
|
+
boringVault: Hex;
|
|
15
|
+
tellerAddress: Hex;
|
|
16
|
+
accountantAddress: Hex;
|
|
17
|
+
lensAddress: Hex;
|
|
18
|
+
underlyingToken: Hex;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parses the raw `moneyAccountVaultConfig` remote feature flag into a config
|
|
22
|
+
* whose chain id and addresses are known-good `Hex`.
|
|
23
|
+
*
|
|
24
|
+
* @param raw - The raw remote feature flag value.
|
|
25
|
+
* @returns The parsed vault config, or `undefined` if any field is missing or
|
|
26
|
+
* malformed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const parseMoneyAccountVaultConfig: (raw: unknown) => MoneyAccountVaultConfig | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Reads and parses the Money Account vault config out of the remote feature
|
|
31
|
+
* flags.
|
|
32
|
+
*
|
|
33
|
+
* @param remoteFeatureFlags - The remote feature flags.
|
|
34
|
+
* @returns The parsed vault config, or `undefined` when the flag is unserved
|
|
35
|
+
* or malformed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMoneyAccountVaultConfig(remoteFeatureFlags: Record<string, unknown> | undefined): MoneyAccountVaultConfig | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Compares vault configs field by field. Any difference means the vault the
|
|
40
|
+
* config points at has changed and consumers keyed on it (bootstraps, caches)
|
|
41
|
+
* must re-run.
|
|
42
|
+
*
|
|
43
|
+
* @param a - One vault config.
|
|
44
|
+
* @param b - The other vault config.
|
|
45
|
+
* @returns Whether the configs are equal.
|
|
46
|
+
*/
|
|
47
|
+
export declare function areMoneyAccountVaultConfigsEqual(a: MoneyAccountVaultConfig, b: MoneyAccountVaultConfig): boolean;
|
|
48
|
+
//# sourceMappingURL=vault-config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-config.d.mts","sourceRoot":"","sources":["../src/vault-config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,4BAA4B,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,GAAG,CAAC;IACjB,aAAa,EAAE,GAAG,CAAC;IACnB,iBAAiB,EAAE,GAAG,CAAC;IACvB,WAAW,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC;AAgBF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,QAClC,OAAO,KACX,uBAAuB,GAAG,SAkC5B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,uBAAuB,GAAG,SAAS,CAIrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,CAAC,EAAE,uBAAuB,EAC1B,CAAC,EAAE,uBAAuB,GACzB,OAAO,CAST"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isObject, isStrictHexString, isValidHexAddress } from "@metamask/utils";
|
|
2
|
+
/**
|
|
3
|
+
* The LaunchDarkly flag carrying the Money Account vault contracts. The same
|
|
4
|
+
* flag `@metamask/money-account-balance-service` reads, so the parsed chain id
|
|
5
|
+
* here is the chain the balance service talks to.
|
|
6
|
+
*/
|
|
7
|
+
export const MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = 'moneyAccountVaultConfig';
|
|
8
|
+
/**
|
|
9
|
+
* Parses one raw vault-config field into an address.
|
|
10
|
+
*
|
|
11
|
+
* `isValidHexAddress` accepts an all-lowercase address or a valid ERC-55
|
|
12
|
+
* checksum, which is what ethers accepts when it encodes the calldata. The
|
|
13
|
+
* address is deliberately not normalised, so a checksummed address passes
|
|
14
|
+
* through unchanged.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The raw field value.
|
|
17
|
+
* @returns The address, or `undefined` if it is missing or malformed.
|
|
18
|
+
*/
|
|
19
|
+
const parseAddress = (value) => isStrictHexString(value) && isValidHexAddress(value) ? value : undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Parses the raw `moneyAccountVaultConfig` remote feature flag into a config
|
|
22
|
+
* whose chain id and addresses are known-good `Hex`.
|
|
23
|
+
*
|
|
24
|
+
* @param raw - The raw remote feature flag value.
|
|
25
|
+
* @returns The parsed vault config, or `undefined` if any field is missing or
|
|
26
|
+
* malformed.
|
|
27
|
+
*/
|
|
28
|
+
export const parseMoneyAccountVaultConfig = (raw) => {
|
|
29
|
+
if (!isObject(raw)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const { chainId } = raw;
|
|
33
|
+
if (!isStrictHexString(chainId)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const boringVault = parseAddress(raw.boringVault);
|
|
37
|
+
const tellerAddress = parseAddress(raw.tellerAddress);
|
|
38
|
+
const accountantAddress = parseAddress(raw.accountantAddress);
|
|
39
|
+
const lensAddress = parseAddress(raw.lensAddress);
|
|
40
|
+
const underlyingToken = parseAddress(raw.underlyingToken);
|
|
41
|
+
if (!boringVault ||
|
|
42
|
+
!tellerAddress ||
|
|
43
|
+
!accountantAddress ||
|
|
44
|
+
!lensAddress ||
|
|
45
|
+
!underlyingToken) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
chainId,
|
|
50
|
+
boringVault,
|
|
51
|
+
tellerAddress,
|
|
52
|
+
accountantAddress,
|
|
53
|
+
lensAddress,
|
|
54
|
+
underlyingToken,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Reads and parses the Money Account vault config out of the remote feature
|
|
59
|
+
* flags.
|
|
60
|
+
*
|
|
61
|
+
* @param remoteFeatureFlags - The remote feature flags.
|
|
62
|
+
* @returns The parsed vault config, or `undefined` when the flag is unserved
|
|
63
|
+
* or malformed.
|
|
64
|
+
*/
|
|
65
|
+
export function getMoneyAccountVaultConfig(remoteFeatureFlags) {
|
|
66
|
+
return parseMoneyAccountVaultConfig(remoteFeatureFlags?.[MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compares vault configs field by field. Any difference means the vault the
|
|
70
|
+
* config points at has changed and consumers keyed on it (bootstraps, caches)
|
|
71
|
+
* must re-run.
|
|
72
|
+
*
|
|
73
|
+
* @param a - One vault config.
|
|
74
|
+
* @param b - The other vault config.
|
|
75
|
+
* @returns Whether the configs are equal.
|
|
76
|
+
*/
|
|
77
|
+
export function areMoneyAccountVaultConfigsEqual(a, b) {
|
|
78
|
+
return (a.chainId === b.chainId &&
|
|
79
|
+
a.boringVault === b.boringVault &&
|
|
80
|
+
a.tellerAddress === b.tellerAddress &&
|
|
81
|
+
a.accountantAddress === b.accountantAddress &&
|
|
82
|
+
a.lensAddress === b.lensAddress &&
|
|
83
|
+
a.underlyingToken === b.underlyingToken);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=vault-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-config.mjs","sourceRoot":"","sources":["../src/vault-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EAClB,wBAAwB;AAGzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,yBAAyB,CAAC;AAe9E;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,KAAc,EAAmB,EAAE,CACvD,iBAAiB,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,GAAY,EACyB,EAAE;IACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IACxB,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtD,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAE1D,IACE,CAAC,WAAW;QACZ,CAAC,aAAa;QACd,CAAC,iBAAiB;QAClB,CAAC,WAAW;QACZ,CAAC,eAAe,EAChB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO;QACP,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,kBAAuD;IAEvD,OAAO,4BAA4B,CACjC,kBAAkB,EAAE,CAAC,oCAAoC,CAAC,CAC3D,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gCAAgC,CAC9C,CAA0B,EAC1B,CAA0B;IAE1B,OAAO,CACL,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;QACnC,CAAC,CAAC,iBAAiB,KAAK,CAAC,CAAC,iBAAiB;QAC3C,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,eAAe,KAAK,CAAC,CAAC,eAAe,CACxC,CAAC;AACJ,CAAC","sourcesContent":["import {\n isObject,\n isStrictHexString,\n isValidHexAddress,\n} from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * The LaunchDarkly flag carrying the Money Account vault contracts. The same\n * flag `@metamask/money-account-balance-service` reads, so the parsed chain id\n * here is the chain the balance service talks to.\n */\nexport const MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME = 'moneyAccountVaultConfig';\n\n/**\n * The Money Account vault contracts served via remote feature flags, with the\n * chain id and every address validated as known-good `Hex`.\n */\nexport type MoneyAccountVaultConfig = {\n chainId: Hex;\n boringVault: Hex;\n tellerAddress: Hex;\n accountantAddress: Hex;\n lensAddress: Hex;\n underlyingToken: Hex;\n};\n\n/**\n * Parses one raw vault-config field into an address.\n *\n * `isValidHexAddress` accepts an all-lowercase address or a valid ERC-55\n * checksum, which is what ethers accepts when it encodes the calldata. The\n * address is deliberately not normalised, so a checksummed address passes\n * through unchanged.\n *\n * @param value - The raw field value.\n * @returns The address, or `undefined` if it is missing or malformed.\n */\nconst parseAddress = (value: unknown): Hex | undefined =>\n isStrictHexString(value) && isValidHexAddress(value) ? value : undefined;\n\n/**\n * Parses the raw `moneyAccountVaultConfig` remote feature flag into a config\n * whose chain id and addresses are known-good `Hex`.\n *\n * @param raw - The raw remote feature flag value.\n * @returns The parsed vault config, or `undefined` if any field is missing or\n * malformed.\n */\nexport const parseMoneyAccountVaultConfig = (\n raw: unknown,\n): MoneyAccountVaultConfig | undefined => {\n if (!isObject(raw)) {\n return undefined;\n }\n\n const { chainId } = raw;\n if (!isStrictHexString(chainId)) {\n return undefined;\n }\n\n const boringVault = parseAddress(raw.boringVault);\n const tellerAddress = parseAddress(raw.tellerAddress);\n const accountantAddress = parseAddress(raw.accountantAddress);\n const lensAddress = parseAddress(raw.lensAddress);\n const underlyingToken = parseAddress(raw.underlyingToken);\n\n if (\n !boringVault ||\n !tellerAddress ||\n !accountantAddress ||\n !lensAddress ||\n !underlyingToken\n ) {\n return undefined;\n }\n\n return {\n chainId,\n boringVault,\n tellerAddress,\n accountantAddress,\n lensAddress,\n underlyingToken,\n };\n};\n\n/**\n * Reads and parses the Money Account vault config out of the remote feature\n * flags.\n *\n * @param remoteFeatureFlags - The remote feature flags.\n * @returns The parsed vault config, or `undefined` when the flag is unserved\n * or malformed.\n */\nexport function getMoneyAccountVaultConfig(\n remoteFeatureFlags: Record<string, unknown> | undefined,\n): MoneyAccountVaultConfig | undefined {\n return parseMoneyAccountVaultConfig(\n remoteFeatureFlags?.[MONEY_ACCOUNT_VAULT_CONFIG_FLAG_NAME],\n );\n}\n\n/**\n * Compares vault configs field by field. Any difference means the vault the\n * config points at has changed and consumers keyed on it (bootstraps, caches)\n * must re-run.\n *\n * @param a - One vault config.\n * @param b - The other vault config.\n * @returns Whether the configs are equal.\n */\nexport function areMoneyAccountVaultConfigsEqual(\n a: MoneyAccountVaultConfig,\n b: MoneyAccountVaultConfig,\n): boolean {\n return (\n a.chainId === b.chainId &&\n a.boringVault === b.boringVault &&\n a.tellerAddress === b.tellerAddress &&\n a.accountantAddress === b.accountantAddress &&\n a.lensAddress === b.lensAddress &&\n a.underlyingToken === b.underlyingToken\n );\n}\n"]}
|
package/package.json
CHANGED