|
1 | 1 | import type { WalletAddress } from '@interledger/open-payments'; |
2 | 2 | import type { Tabs } from 'webextension-polyfill'; |
3 | | -import type { ErrorWithKeyLike } from './helpers'; |
| 3 | +import type { ErrorWithKeyLike, I18nInfo } from './helpers'; |
4 | 4 | import type { components as RSComponents } from '@interledger/open-payments/dist/openapi/generated/resource-server-types'; |
5 | 5 |
|
6 | 6 | export type AmountType = RSComponents['schemas']['amount']; |
@@ -145,6 +145,50 @@ export type PopupTabInfo = { |
145 | 145 | | never; // just added for code formatting |
146 | 146 | }; |
147 | 147 |
|
| 148 | +interface WalletStatusBase { |
| 149 | + intent: 'connect' | 'reconnect' | 'add_funds' | 'update_budget'; |
| 150 | + type: 'success' | 'failure' | 'cancel' | 'progress'; |
| 151 | +} |
| 152 | + |
| 153 | +interface WalletStatusSuccess extends WalletStatusBase { |
| 154 | + type: 'success'; |
| 155 | +} |
| 156 | + |
| 157 | +interface WalletStatusProgress extends WalletStatusBase { |
| 158 | + type: 'progress'; |
| 159 | + currentStep: string | I18nInfo; |
| 160 | +} |
| 161 | + |
| 162 | +export interface WalletStatusFailure extends WalletStatusBase { |
| 163 | + type: 'failure'; |
| 164 | + code: |
| 165 | + | 'grant_continuation_failed' |
| 166 | + | 'grant_hash_failed' |
| 167 | + | 'grant_invalid' |
| 168 | + | 'key_add_failed' |
| 169 | + | 'timeout' |
| 170 | + | 'unknown'; |
| 171 | + /** |
| 172 | + * - `auto`: can try to connect automatically (like timeout, bad login, server errors etc.) |
| 173 | + * - `manual`: ask user to connect manually, might need some edit to params (budget too high etc.) |
| 174 | + * - `false`/`undefined`: cannot retry |
| 175 | + */ |
| 176 | + retryPossible: 'auto' | 'manual' | false; |
| 177 | + details?: ErrorWithKeyLike | { message: string }; |
| 178 | +} |
| 179 | + |
| 180 | +interface WalletStatusCancel extends WalletStatusBase { |
| 181 | + type: 'cancel'; |
| 182 | + code: 'tab_closed' | 'grant_rejected'; |
| 183 | + retryPossible: 'auto'; |
| 184 | +} |
| 185 | + |
| 186 | +export type WalletStatus = |
| 187 | + | WalletStatusSuccess |
| 188 | + | WalletStatusFailure |
| 189 | + | WalletStatusCancel |
| 190 | + | WalletStatusProgress; |
| 191 | + |
148 | 192 | export type TransientState = Partial<{ |
149 | 193 | connect: |
150 | 194 | | null |
|
0 commit comments