@metamask-previews/bridge-controller 81.3.3-preview-5d795901a → 81.3.3-preview-635748c9f

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 CHANGED
@@ -7,6 +7,10 @@ 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 `DiscountType.SUBSCRIPTION` (`'subscription'`) for subscription-based quote discounts. ([#10560](https://github.com/MetaMask/core/pull/10560))
13
+
10
14
  ### Changed
11
15
 
12
16
  - Bump `@ethersproject/bignumber` from `^5.7.0` to `^5.8.0` ([#10479](https://github.com/MetaMask/core/pull/10479))
@@ -9,7 +9,8 @@ export declare enum FeeType {
9
9
  export declare enum DiscountType {
10
10
  VIP = "vip",
11
11
  PROMO = "promo",
12
- DAO = "dao"
12
+ DAO = "dao",
13
+ SUBSCRIPTION = "subscription"
13
14
  }
14
15
  export declare const FeeDataSchema: import("@metamask/superstruct").Struct<{
15
16
  amount: string;
@@ -1 +1 @@
1
- {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAYnD,oBAAY,OAAO;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IAEjB,MAAM,UAAU;IAChB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIxB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;IAElC;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;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/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;IAElC;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0DtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE9C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4ExB,CAAC"}
@@ -18,6 +18,7 @@ export var DiscountType;
18
18
  DiscountType["VIP"] = "vip";
19
19
  DiscountType["PROMO"] = "promo";
20
20
  DiscountType["DAO"] = "dao";
21
+ DiscountType["SUBSCRIPTION"] = "subscription";
21
22
  })(DiscountType || (DiscountType = {}));
22
23
  export const FeeDataSchema = type({
23
24
  amount: TruthyDigitStringSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,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C,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;QAC5B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n type,\n optional,\n boolean,\n intersection,\n string,\n number,\n array,\n nullable,\n partial,\n pick,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { AmountsAndAssetSchema } from './amount-and-asset.js';\nimport { ChainIdSchema, BridgeAssetSchema } from './bridge-asset.js';\nimport { IntentSchema } from './intent.js';\nimport {\n TruthyDigitStringSchema,\n PositiveNumberStringSchema,\n FloatStringSchema,\n} from './number.js';\nimport { RefuelDataSchema, StepSchema, StepSchemaV2 } from './step.js';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n TX_FEE = 'txFee',\n NETWORK = 'network',\n RELAYER = 'relayer',\n}\n\nexport enum DiscountType {\n VIP = 'vip',\n PROMO = 'promo',\n DAO = 'dao',\n}\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n discountType: optional(nullable(string())),\n});\n\nexport const TxFeeGasLimitsSchema = type({\n maxFeePerGas: PositiveNumberStringSchema,\n maxPriorityFeePerGas: PositiveNumberStringSchema,\n});\n\nexport const GaslessPropertiesSchema = type({\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const QuoteSchema = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: optional(string()),\n feeData: type({\n [FeeType.METABRIDGE]: intersection([\n FeeDataSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n }),\n ]),\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([FeeDataSchema, TxFeeGasLimitsSchema]),\n ),\n }),\n bridgeId: string(),\n bridges: array(string()),\n // TODO require this after v2 migration\n aggregator: optional(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n walletAddress: optional(string()),\n destWalletAddress: optional(string()),\n slippage: optional(number()),\n // TODO require this after v2 migration\n protocols: optional(array(string())),\n }),\n]);\n\nexport type Quote = Infer<typeof QuoteSchema>;\n\nexport const QuoteSchemaV2 = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n src: intersection([\n AmountsAndAssetSchema,\n type({\n walletAddress: optional(string()),\n }),\n ]),\n dest: intersection([\n AmountsAndAssetSchema,\n type({\n minAmount: optional(string()),\n minAmountUsd: optional(string()),\n minAmountValueInCurrency: optional(string()),\n minAmountNormalized: optional(string()),\n walletAddress: optional(string()),\n }),\n ]),\n priceData: optional(\n partial(\n type({\n swapRate: FloatStringSchema,\n priceImpact: intersection([\n type({\n amount: optional(FloatStringSchema),\n }),\n pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n ]),\n adjustedReturn: pick(AmountsAndAssetSchema, [\n 'usd',\n 'valueInCurrency',\n ]),\n cost: pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n }),\n ),\n ),\n feeData: type({\n [FeeType.METABRIDGE]: array(\n intersection([\n AmountsAndAssetSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n discountType: optional(nullable(string())),\n }),\n ]),\n ),\n [FeeType.REFUEL]: optional(array(AmountsAndAssetSchema)),\n /**\n * The tx fees included in the quote for gasless execution\n */\n [FeeType.TX_FEE]: optional(\n array(intersection([AmountsAndAssetSchema, TxFeeGasLimitsSchema])),\n ),\n /**\n * The gas fees for the quote, excluding any provider or relayer fees\n */\n [FeeType.NETWORK]: optional(array(AmountsAndAssetSchema)),\n /**\n * The native balance that must remain in the source account.\n */\n reserve: optional(array(AmountsAndAssetSchema)),\n /**\n * The relayer or provider fees for the quote,\n */\n [FeeType.RELAYER]: optional(array(AmountsAndAssetSchema)),\n }),\n aggregator: string(),\n protocols: array(string()),\n steps: optional(array(StepSchemaV2)),\n refuel: optional(StepSchema),\n intent: optional(IntentSchema),\n slippage: optional(number()),\n }),\n]);\n"]}
1
+ {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/validators/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,GACL,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEvE,MAAM,CAAN,IAAY,OAOX;AAPD,WAAY,OAAO;IACjB,oC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C9B,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;iBAC3C,CAAC;aACH,CAAC,CACH;YACD,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACxD;;eAEG;YACH,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CACxB,KAAK,CAAC,YAAY,CAAC,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAC,CAAC,CACnE;YACD;;eAEG;YACH,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACzD;;eAEG;YACH,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC/C;;eAEG;YACH,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;SAC1D,CAAC;QACF,UAAU,EAAE,MAAM,EAAE;QACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;QAC5B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n type,\n optional,\n boolean,\n intersection,\n string,\n number,\n array,\n nullable,\n partial,\n pick,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { AmountsAndAssetSchema } from './amount-and-asset.js';\nimport { ChainIdSchema, BridgeAssetSchema } from './bridge-asset.js';\nimport { IntentSchema } from './intent.js';\nimport {\n TruthyDigitStringSchema,\n PositiveNumberStringSchema,\n FloatStringSchema,\n} from './number.js';\nimport { RefuelDataSchema, StepSchema, StepSchemaV2 } from './step.js';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n TX_FEE = 'txFee',\n NETWORK = 'network',\n RELAYER = 'relayer',\n}\n\nexport enum DiscountType {\n VIP = 'vip',\n PROMO = 'promo',\n DAO = 'dao',\n SUBSCRIPTION = 'subscription',\n}\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n discountType: optional(nullable(string())),\n});\n\nexport const TxFeeGasLimitsSchema = type({\n maxFeePerGas: PositiveNumberStringSchema,\n maxPriorityFeePerGas: PositiveNumberStringSchema,\n});\n\nexport const GaslessPropertiesSchema = type({\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const QuoteSchema = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: optional(string()),\n feeData: type({\n [FeeType.METABRIDGE]: intersection([\n FeeDataSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n }),\n ]),\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([FeeDataSchema, TxFeeGasLimitsSchema]),\n ),\n }),\n bridgeId: string(),\n bridges: array(string()),\n // TODO require this after v2 migration\n aggregator: optional(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n walletAddress: optional(string()),\n destWalletAddress: optional(string()),\n slippage: optional(number()),\n // TODO require this after v2 migration\n protocols: optional(array(string())),\n }),\n]);\n\nexport type Quote = Infer<typeof QuoteSchema>;\n\nexport const QuoteSchemaV2 = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n src: intersection([\n AmountsAndAssetSchema,\n type({\n walletAddress: optional(string()),\n }),\n ]),\n dest: intersection([\n AmountsAndAssetSchema,\n type({\n minAmount: optional(string()),\n minAmountUsd: optional(string()),\n minAmountValueInCurrency: optional(string()),\n minAmountNormalized: optional(string()),\n walletAddress: optional(string()),\n }),\n ]),\n priceData: optional(\n partial(\n type({\n swapRate: FloatStringSchema,\n priceImpact: intersection([\n type({\n amount: optional(FloatStringSchema),\n }),\n pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n ]),\n adjustedReturn: pick(AmountsAndAssetSchema, [\n 'usd',\n 'valueInCurrency',\n ]),\n cost: pick(AmountsAndAssetSchema, ['usd', 'valueInCurrency']),\n }),\n ),\n ),\n feeData: type({\n [FeeType.METABRIDGE]: array(\n intersection([\n AmountsAndAssetSchema,\n type({\n quoteBpsFee: optional(number()),\n baseBpsFee: optional(number()),\n discountType: optional(nullable(string())),\n }),\n ]),\n ),\n [FeeType.REFUEL]: optional(array(AmountsAndAssetSchema)),\n /**\n * The tx fees included in the quote for gasless execution\n */\n [FeeType.TX_FEE]: optional(\n array(intersection([AmountsAndAssetSchema, TxFeeGasLimitsSchema])),\n ),\n /**\n * The gas fees for the quote, excluding any provider or relayer fees\n */\n [FeeType.NETWORK]: optional(array(AmountsAndAssetSchema)),\n /**\n * The native balance that must remain in the source account.\n */\n reserve: optional(array(AmountsAndAssetSchema)),\n /**\n * The relayer or provider fees for the quote,\n */\n [FeeType.RELAYER]: optional(array(AmountsAndAssetSchema)),\n }),\n aggregator: string(),\n protocols: array(string()),\n steps: optional(array(StepSchemaV2)),\n refuel: optional(StepSchema),\n intent: optional(IntentSchema),\n slippage: optional(number()),\n }),\n]);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/bridge-controller",
3
- "version": "81.3.3-preview-5d795901a",
3
+ "version": "81.3.3-preview-635748c9f",
4
4
  "description": "Manages bridge-related quote fetching functionality for MetaMask",
5
5
  "keywords": [
6
6
  "Ethereum",