Skip to content

Commit ea6a2f2

Browse files
authored
feat: add crypto payment method error (#6720)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> - Add `CryptoPaymentMethodError` error response to `SubscriptionCryptoPaymentMethod` - Make `rawTransaction` in `UpdatePaymentMethodCryptoRequest` optional for top up case ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 09bb112 commit ea6a2f2

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/subscription-controller/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `CryptoPaymentMethodError` error response to `SubscriptionCryptoPaymentMethod` ([#6720](https://github.com/MetaMask/core/pull/6720))
13+
14+
### Changed
15+
16+
- Make `rawTransaction` in `UpdatePaymentMethodCryptoRequest` optional for top up case ([#6720](https://github.com/MetaMask/core/pull/6720))
17+
1018
## [0.2.0]
1119

1220
### Changed

packages/subscription-controller/src/types.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ export const SUBSCRIPTION_STATUSES = {
4141
export type SubscriptionStatus =
4242
(typeof SUBSCRIPTION_STATUSES)[keyof typeof SUBSCRIPTION_STATUSES];
4343

44+
export const CRYPTO_PAYMENT_METHOD_ERRORS = {
45+
APPROVAL_TRANSACTION_TOO_OLD: 'approval_transaction_too_old',
46+
APPROVAL_TRANSACTION_REVERTED: 'approval_transaction_reverted',
47+
APPROVAL_TRANSACTION_MAX_VERIFICATION_ATTEMPTS_REACHED:
48+
'approval_transaction_max_verification_attempts_reached',
49+
INSUFFICIENT_BALANCE: 'insufficient_balance',
50+
INSUFFICIENT_ALLOWANCE: 'insufficient_allowance',
51+
} as const;
52+
53+
export type CryptoPaymentMethodError =
54+
(typeof CRYPTO_PAYMENT_METHOD_ERRORS)[keyof typeof CRYPTO_PAYMENT_METHOD_ERRORS];
55+
4456
/** only usd for now */
4557
export type Currency = 'usd';
4658

@@ -86,6 +98,7 @@ export type SubscriptionCryptoPaymentMethod = {
8698
payerAddress: Hex;
8799
chainId: Hex;
88100
tokenSymbol: string;
101+
error?: CryptoPaymentMethodError;
89102
};
90103
};
91104

@@ -258,7 +271,11 @@ export type UpdatePaymentMethodCryptoRequest = {
258271
chainId: Hex;
259272
payerAddress: Hex;
260273
tokenSymbol: string;
261-
rawTransaction: Hex;
274+
/**
275+
* The raw transaction to pay for the subscription
276+
* Can be empty if retry after topping up balance
277+
*/
278+
rawTransaction?: Hex;
262279
recurringInterval: RecurringInterval;
263280
billingCycles: number;
264281
};

0 commit comments

Comments
 (0)