@metamask/ramps-controller 20.2.0 → 20.3.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 +14 -1
- package/dist/NeoBankService-method-action-types.cjs +7 -0
- package/dist/NeoBankService-method-action-types.cjs.map +1 -0
- package/dist/NeoBankService-method-action-types.d.cts +126 -0
- package/dist/NeoBankService-method-action-types.d.cts.map +1 -0
- package/dist/NeoBankService-method-action-types.d.mts +126 -0
- package/dist/NeoBankService-method-action-types.d.mts.map +1 -0
- package/dist/NeoBankService-method-action-types.mjs +6 -0
- package/dist/NeoBankService-method-action-types.mjs.map +1 -0
- package/dist/NeoBankService.cjs +387 -0
- package/dist/NeoBankService.cjs.map +1 -0
- package/dist/NeoBankService.d.cts +191 -0
- package/dist/NeoBankService.d.cts.map +1 -0
- package/dist/NeoBankService.d.mts +191 -0
- package/dist/NeoBankService.d.mts.map +1 -0
- package/dist/NeoBankService.mjs +379 -0
- package/dist/NeoBankService.mjs.map +1 -0
- package/dist/RampsController-method-action-types.cjs.map +1 -1
- package/dist/RampsController-method-action-types.d.cts +91 -1
- package/dist/RampsController-method-action-types.d.cts.map +1 -1
- package/dist/RampsController-method-action-types.d.mts +91 -1
- package/dist/RampsController-method-action-types.d.mts.map +1 -1
- package/dist/RampsController-method-action-types.mjs.map +1 -1
- package/dist/RampsController.cjs +372 -2
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +152 -5
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +152 -5
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +371 -1
- package/dist/RampsController.mjs.map +1 -1
- package/dist/autoramp-types.cjs +3 -0
- package/dist/autoramp-types.cjs.map +1 -0
- package/dist/autoramp-types.d.cts +22 -0
- package/dist/autoramp-types.d.cts.map +1 -0
- package/dist/autoramp-types.d.mts +22 -0
- package/dist/autoramp-types.d.mts.map +1 -0
- package/dist/autoramp-types.mjs +2 -0
- package/dist/autoramp-types.mjs.map +1 -0
- package/dist/autorampAccount.cjs +155 -0
- package/dist/autorampAccount.cjs.map +1 -0
- package/dist/autorampAccount.d.cts +126 -0
- package/dist/autorampAccount.d.cts.map +1 -0
- package/dist/autorampAccount.d.mts +126 -0
- package/dist/autorampAccount.d.mts.map +1 -0
- package/dist/autorampAccount.mjs +147 -0
- package/dist/autorampAccount.mjs.map +1 -0
- package/dist/index.cjs +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +12 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/ownership-message.cjs +26 -0
- package/dist/ownership-message.cjs.map +1 -0
- package/dist/ownership-message.d.cts +22 -0
- package/dist/ownership-message.d.cts.map +1 -0
- package/dist/ownership-message.d.mts +22 -0
- package/dist/ownership-message.d.mts.map +1 -0
- package/dist/ownership-message.mjs +22 -0
- package/dist/ownership-message.mjs.map +1 -0
- package/dist/wallet-registration-machine.cjs +144 -0
- package/dist/wallet-registration-machine.cjs.map +1 -0
- package/dist/wallet-registration-machine.d.cts +81 -0
- package/dist/wallet-registration-machine.d.cts.map +1 -0
- package/dist/wallet-registration-machine.d.mts +81 -0
- package/dist/wallet-registration-machine.d.mts.map +1 -0
- package/dist/wallet-registration-machine.mjs +139 -0
- package/dist/wallet-registration-machine.mjs.map +1 -0
- package/dist/wallet-registration-service.cjs +351 -0
- package/dist/wallet-registration-service.cjs.map +1 -0
- package/dist/wallet-registration-service.d.cts +144 -0
- package/dist/wallet-registration-service.d.cts.map +1 -0
- package/dist/wallet-registration-service.d.mts +144 -0
- package/dist/wallet-registration-service.d.mts.map +1 -0
- package/dist/wallet-registration-service.mjs +344 -0
- package/dist/wallet-registration-service.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoramp-types.cjs","sourceRoot":"","sources":["../src/autoramp-types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Non-PII deposit readiness summary from a neo-bank autoramp response.\n * Full deposit rail details (IBAN, etc.) should be re-fetched when needed.\n */\nexport type AutorampDepositRailsSummary = {\n /** Source currency code when known (e.g. EUR). */\n currency?: string;\n /** True when the autoramp is approved and deposit details may be shared. */\n ready: boolean;\n};\n\n/**\n * Minimal remote snapshot from `GET /neobank/autoramps/{id}` (or a push payload).\n * Identity fields may be omitted on partial proxy responses.\n */\nexport type AutorampRemoteSnapshot = {\n id: string;\n customerId?: string;\n walletAddress?: string;\n status: string;\n depositRailsSummary?: AutorampDepositRailsSummary;\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-PII deposit readiness summary from a neo-bank autoramp response.
|
|
3
|
+
* Full deposit rail details (IBAN, etc.) should be re-fetched when needed.
|
|
4
|
+
*/
|
|
5
|
+
export type AutorampDepositRailsSummary = {
|
|
6
|
+
/** Source currency code when known (e.g. EUR). */
|
|
7
|
+
currency?: string;
|
|
8
|
+
/** True when the autoramp is approved and deposit details may be shared. */
|
|
9
|
+
ready: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Minimal remote snapshot from `GET /neobank/autoramps/{id}` (or a push payload).
|
|
13
|
+
* Identity fields may be omitted on partial proxy responses.
|
|
14
|
+
*/
|
|
15
|
+
export type AutorampRemoteSnapshot = {
|
|
16
|
+
id: string;
|
|
17
|
+
customerId?: string;
|
|
18
|
+
walletAddress?: string;
|
|
19
|
+
status: string;
|
|
20
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=autoramp-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoramp-types.d.cts","sourceRoot":"","sources":["../src/autoramp-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-PII deposit readiness summary from a neo-bank autoramp response.
|
|
3
|
+
* Full deposit rail details (IBAN, etc.) should be re-fetched when needed.
|
|
4
|
+
*/
|
|
5
|
+
export type AutorampDepositRailsSummary = {
|
|
6
|
+
/** Source currency code when known (e.g. EUR). */
|
|
7
|
+
currency?: string;
|
|
8
|
+
/** True when the autoramp is approved and deposit details may be shared. */
|
|
9
|
+
ready: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Minimal remote snapshot from `GET /neobank/autoramps/{id}` (or a push payload).
|
|
13
|
+
* Identity fields may be omitted on partial proxy responses.
|
|
14
|
+
*/
|
|
15
|
+
export type AutorampRemoteSnapshot = {
|
|
16
|
+
id: string;
|
|
17
|
+
customerId?: string;
|
|
18
|
+
walletAddress?: string;
|
|
19
|
+
status: string;
|
|
20
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=autoramp-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoramp-types.d.mts","sourceRoot":"","sources":["../src/autoramp-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoramp-types.mjs","sourceRoot":"","sources":["../src/autoramp-types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Non-PII deposit readiness summary from a neo-bank autoramp response.\n * Full deposit rail details (IBAN, etc.) should be re-fetched when needed.\n */\nexport type AutorampDepositRailsSummary = {\n /** Source currency code when known (e.g. EUR). */\n currency?: string;\n /** True when the autoramp is approved and deposit details may be shared. */\n ready: boolean;\n};\n\n/**\n * Minimal remote snapshot from `GET /neobank/autoramps/{id}` (or a push payload).\n * Identity fields may be omitted on partial proxy responses.\n */\nexport type AutorampRemoteSnapshot = {\n id: string;\n customerId?: string;\n walletAddress?: string;\n status: string;\n depositRailsSummary?: AutorampDepositRailsSummary;\n};\n"]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local + remote models for MoonPay Enterprise autoramp accounts.
|
|
4
|
+
* Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.markAutorampNotified = exports.applyAutorampRemoteStatus = exports.createAutorampAccount = exports.normalizeAutorampStatus = exports.isTerminalAutorampStatus = exports.NOTABLE_AUTORAMP_STATUSES = exports.TERMINAL_AUTORAMP_STATUSES = exports.AutorampStatus = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Autoramp lifecycle statuses from MoonPay Enterprise.
|
|
10
|
+
*
|
|
11
|
+
* @see https://dev.enterprise.moonpay.com/autoramp-status
|
|
12
|
+
*/
|
|
13
|
+
var AutorampStatus;
|
|
14
|
+
(function (AutorampStatus) {
|
|
15
|
+
AutorampStatus["Created"] = "Created";
|
|
16
|
+
AutorampStatus["Authorized"] = "Authorized";
|
|
17
|
+
AutorampStatus["EditPending"] = "EditPending";
|
|
18
|
+
AutorampStatus["DepositAccountAdded"] = "DepositAccountAdded";
|
|
19
|
+
AutorampStatus["Approved"] = "Approved";
|
|
20
|
+
AutorampStatus["Rejected"] = "Rejected";
|
|
21
|
+
AutorampStatus["Cancelled"] = "Cancelled";
|
|
22
|
+
})(AutorampStatus || (exports.AutorampStatus = AutorampStatus = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Terminal autoramp statuses — no further lifecycle progress expected.
|
|
25
|
+
*/
|
|
26
|
+
exports.TERMINAL_AUTORAMP_STATUSES = new Set([
|
|
27
|
+
AutorampStatus.Rejected,
|
|
28
|
+
AutorampStatus.Cancelled,
|
|
29
|
+
]);
|
|
30
|
+
/**
|
|
31
|
+
* Statuses that commonly warrant user-visible transition UX (toast / banner).
|
|
32
|
+
*/
|
|
33
|
+
exports.NOTABLE_AUTORAMP_STATUSES = new Set([
|
|
34
|
+
AutorampStatus.Approved,
|
|
35
|
+
AutorampStatus.Rejected,
|
|
36
|
+
AutorampStatus.Cancelled,
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Whether an autoramp status is terminal.
|
|
40
|
+
*
|
|
41
|
+
* @param status - Status to test.
|
|
42
|
+
* @returns Whether the status is terminal.
|
|
43
|
+
*/
|
|
44
|
+
function isTerminalAutorampStatus(status) {
|
|
45
|
+
return exports.TERMINAL_AUTORAMP_STATUSES.has(status);
|
|
46
|
+
}
|
|
47
|
+
exports.isTerminalAutorampStatus = isTerminalAutorampStatus;
|
|
48
|
+
/**
|
|
49
|
+
* Normalize a remote status string into {@link AutorampStatus}.
|
|
50
|
+
* Unknown values fall back to {@link AutorampStatus.Created}.
|
|
51
|
+
*
|
|
52
|
+
* @param status - Remote status string.
|
|
53
|
+
* @returns A known {@link AutorampStatus}.
|
|
54
|
+
*/
|
|
55
|
+
function normalizeAutorampStatus(status) {
|
|
56
|
+
if (Object.values(AutorampStatus).includes(status)) {
|
|
57
|
+
return status;
|
|
58
|
+
}
|
|
59
|
+
return AutorampStatus.Created;
|
|
60
|
+
}
|
|
61
|
+
exports.normalizeAutorampStatus = normalizeAutorampStatus;
|
|
62
|
+
/**
|
|
63
|
+
* Build a new local autoramp account from create/response fields.
|
|
64
|
+
*
|
|
65
|
+
* @param input - Required identity + status fields.
|
|
66
|
+
* @param input.id - MoonPay autoramp id.
|
|
67
|
+
* @param input.customerId - MoonPay customer id.
|
|
68
|
+
* @param input.walletAddress - Destination wallet address.
|
|
69
|
+
* @param input.status - Optional remote status (defaults to Authorized).
|
|
70
|
+
* @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
|
|
71
|
+
* @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
|
|
72
|
+
* @returns A new {@link AutorampAccount}.
|
|
73
|
+
*/
|
|
74
|
+
function createAutorampAccount(input) {
|
|
75
|
+
const status = normalizeAutorampStatus(input.status ?? AutorampStatus.Authorized);
|
|
76
|
+
return {
|
|
77
|
+
id: input.id,
|
|
78
|
+
customerId: input.customerId,
|
|
79
|
+
walletAddress: input.walletAddress,
|
|
80
|
+
status,
|
|
81
|
+
lastSeenStatus: status,
|
|
82
|
+
updatedAt: input.updatedAt ?? Date.now(),
|
|
83
|
+
depositRailsSummary: input.depositRailsSummary,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.createAutorampAccount = createAutorampAccount;
|
|
87
|
+
/**
|
|
88
|
+
* Apply a remote autoramp snapshot onto a local account for transition detection.
|
|
89
|
+
* Pure helper — shared by refresh-on-load and websocket push paths.
|
|
90
|
+
*
|
|
91
|
+
* @param local - Current local account (or null when first upserting from remote).
|
|
92
|
+
* @param remote - Remote snapshot (MoonPay GET or push).
|
|
93
|
+
* @returns Updated account plus change / notify flags.
|
|
94
|
+
*/
|
|
95
|
+
function applyAutorampRemoteStatus(local, remote) {
|
|
96
|
+
const remoteStatus = normalizeAutorampStatus(remote.status);
|
|
97
|
+
if (!local) {
|
|
98
|
+
const account = createAutorampAccount({
|
|
99
|
+
id: remote.id,
|
|
100
|
+
customerId: remote.customerId ?? '',
|
|
101
|
+
walletAddress: remote.walletAddress ?? '',
|
|
102
|
+
status: remoteStatus,
|
|
103
|
+
depositRailsSummary: remote.depositRailsSummary,
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
account,
|
|
107
|
+
previousStatus: remoteStatus,
|
|
108
|
+
statusChanged: false,
|
|
109
|
+
shouldNotify: false,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const previousStatus = local.status;
|
|
113
|
+
const statusChanged = previousStatus !== remoteStatus;
|
|
114
|
+
const shouldNotify = statusChanged &&
|
|
115
|
+
local.notifiedForStatus !== remoteStatus &&
|
|
116
|
+
exports.NOTABLE_AUTORAMP_STATUSES.has(remoteStatus);
|
|
117
|
+
const account = {
|
|
118
|
+
...local,
|
|
119
|
+
id: remote.id,
|
|
120
|
+
// A blank remote identity field means "not supplied", not "cleared": the
|
|
121
|
+
// proxy omits or empties these on partial status pushes, so keep the local
|
|
122
|
+
// value rather than wiping it.
|
|
123
|
+
customerId: remote.customerId !== undefined && remote.customerId.length > 0
|
|
124
|
+
? remote.customerId
|
|
125
|
+
: local.customerId,
|
|
126
|
+
walletAddress: remote.walletAddress !== undefined && remote.walletAddress.length > 0
|
|
127
|
+
? remote.walletAddress
|
|
128
|
+
: local.walletAddress,
|
|
129
|
+
status: remoteStatus,
|
|
130
|
+
lastSeenStatus: previousStatus,
|
|
131
|
+
updatedAt: Date.now(),
|
|
132
|
+
depositRailsSummary: remote.depositRailsSummary ?? local.depositRailsSummary,
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
account,
|
|
136
|
+
previousStatus,
|
|
137
|
+
statusChanged,
|
|
138
|
+
shouldNotify,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.applyAutorampRemoteStatus = applyAutorampRemoteStatus;
|
|
142
|
+
/**
|
|
143
|
+
* Mark that the UI has notified for the account's current status.
|
|
144
|
+
*
|
|
145
|
+
* @param account - Account to update.
|
|
146
|
+
* @returns Account with `notifiedForStatus` set to current status.
|
|
147
|
+
*/
|
|
148
|
+
function markAutorampNotified(account) {
|
|
149
|
+
return {
|
|
150
|
+
...account,
|
|
151
|
+
notifiedForStatus: account.status,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
exports.markAutorampNotified = markAutorampNotified;
|
|
155
|
+
//# sourceMappingURL=autorampAccount.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autorampAccount.cjs","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Local + remote models for MoonPay Enterprise autoramp accounts.\n * Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.\n */\n\nimport type {\n AutorampDepositRailsSummary,\n AutorampRemoteSnapshot,\n} from './autoramp-types.js';\n\nexport type {\n AutorampDepositRailsSummary,\n AutorampRemoteSnapshot,\n} from './autoramp-types.js';\n\n/**\n * Autoramp lifecycle statuses from MoonPay Enterprise.\n *\n * @see https://dev.enterprise.moonpay.com/autoramp-status\n */\nexport enum AutorampStatus {\n Created = 'Created',\n Authorized = 'Authorized',\n EditPending = 'EditPending',\n DepositAccountAdded = 'DepositAccountAdded',\n Approved = 'Approved',\n Rejected = 'Rejected',\n Cancelled = 'Cancelled',\n}\n\n/**\n * Local controller representation of an autoramp account.\n */\nexport type AutorampAccount = {\n /** MoonPay autoramp id. */\n id: string;\n /** MoonPay customer id. */\n customerId: string;\n /** Destination wallet address associated with this autoramp. */\n walletAddress: string;\n /** Latest status from MoonPay (source of truth after refresh). */\n status: AutorampStatus;\n /**\n * Status observed before the most recent remote apply.\n * Used for transition UX / analytics (e.g. Authorized → Approved).\n */\n lastSeenStatus: AutorampStatus;\n /**\n * Last status for which the UI already showed a notification.\n * Prevents duplicate toasts across refresh and push.\n */\n notifiedForStatus?: AutorampStatus;\n /** Epoch ms of the last local update from remote or push. */\n updatedAt: number;\n /** Optional non-PII deposit readiness cache. */\n depositRailsSummary?: AutorampDepositRailsSummary;\n};\n\n/**\n * Controller-facing payload for creating an autoramp.\n *\n * Mirrors the MoonPay `POST /api/autoramps` body that\n * {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:\n * `RampsController.createAutoramp` injects the vendor customer id resolved from\n * Profile Sync, so callers never supply (or need to know) it.\n */\nexport type CreateAutorampRequest = Record<string, unknown>;\n\n/**\n * Result of applying a remote autoramp snapshot onto local state.\n */\nexport type ApplyAutorampRemoteStatusResult = {\n account: AutorampAccount;\n previousStatus: AutorampStatus;\n statusChanged: boolean;\n /** True when status changed and UI has not yet notified for the new status. */\n shouldNotify: boolean;\n};\n\n/**\n * Terminal autoramp statuses — no further lifecycle progress expected.\n */\nexport const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus> = new Set([\n AutorampStatus.Rejected,\n AutorampStatus.Cancelled,\n]);\n\n/**\n * Statuses that commonly warrant user-visible transition UX (toast / banner).\n */\nexport const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus> = new Set([\n AutorampStatus.Approved,\n AutorampStatus.Rejected,\n AutorampStatus.Cancelled,\n]);\n\n/**\n * Whether an autoramp status is terminal.\n *\n * @param status - Status to test.\n * @returns Whether the status is terminal.\n */\nexport function isTerminalAutorampStatus(status: AutorampStatus): boolean {\n return TERMINAL_AUTORAMP_STATUSES.has(status);\n}\n\n/**\n * Normalize a remote status string into {@link AutorampStatus}.\n * Unknown values fall back to {@link AutorampStatus.Created}.\n *\n * @param status - Remote status string.\n * @returns A known {@link AutorampStatus}.\n */\nexport function normalizeAutorampStatus(\n status: AutorampStatus | string,\n): AutorampStatus {\n if (Object.values(AutorampStatus).includes(status as AutorampStatus)) {\n return status as AutorampStatus;\n }\n return AutorampStatus.Created;\n}\n\n/**\n * Build a new local autoramp account from create/response fields.\n *\n * @param input - Required identity + status fields.\n * @param input.id - MoonPay autoramp id.\n * @param input.customerId - MoonPay customer id.\n * @param input.walletAddress - Destination wallet address.\n * @param input.status - Optional remote status (defaults to Authorized).\n * @param input.depositRailsSummary - Optional non-PII deposit readiness cache.\n * @param input.updatedAt - Optional epoch ms timestamp (defaults to now).\n * @returns A new {@link AutorampAccount}.\n */\nexport function createAutorampAccount(input: {\n id: string;\n customerId: string;\n walletAddress: string;\n status?: AutorampStatus | string;\n depositRailsSummary?: AutorampDepositRailsSummary;\n updatedAt?: number;\n}): AutorampAccount {\n const status = normalizeAutorampStatus(\n input.status ?? AutorampStatus.Authorized,\n );\n return {\n id: input.id,\n customerId: input.customerId,\n walletAddress: input.walletAddress,\n status,\n lastSeenStatus: status,\n updatedAt: input.updatedAt ?? Date.now(),\n depositRailsSummary: input.depositRailsSummary,\n };\n}\n\n/**\n * Apply a remote autoramp snapshot onto a local account for transition detection.\n * Pure helper — shared by refresh-on-load and websocket push paths.\n *\n * @param local - Current local account (or null when first upserting from remote).\n * @param remote - Remote snapshot (MoonPay GET or push).\n * @returns Updated account plus change / notify flags.\n */\nexport function applyAutorampRemoteStatus(\n local: AutorampAccount | null,\n remote: AutorampRemoteSnapshot,\n): ApplyAutorampRemoteStatusResult {\n const remoteStatus = normalizeAutorampStatus(remote.status);\n\n if (!local) {\n const account = createAutorampAccount({\n id: remote.id,\n customerId: remote.customerId ?? '',\n walletAddress: remote.walletAddress ?? '',\n status: remoteStatus,\n depositRailsSummary: remote.depositRailsSummary,\n });\n return {\n account,\n previousStatus: remoteStatus,\n statusChanged: false,\n shouldNotify: false,\n };\n }\n\n const previousStatus = local.status;\n const statusChanged = previousStatus !== remoteStatus;\n const shouldNotify =\n statusChanged &&\n local.notifiedForStatus !== remoteStatus &&\n NOTABLE_AUTORAMP_STATUSES.has(remoteStatus);\n\n const account: AutorampAccount = {\n ...local,\n id: remote.id,\n // A blank remote identity field means \"not supplied\", not \"cleared\": the\n // proxy omits or empties these on partial status pushes, so keep the local\n // value rather than wiping it.\n customerId:\n remote.customerId !== undefined && remote.customerId.length > 0\n ? remote.customerId\n : local.customerId,\n walletAddress:\n remote.walletAddress !== undefined && remote.walletAddress.length > 0\n ? remote.walletAddress\n : local.walletAddress,\n status: remoteStatus,\n lastSeenStatus: previousStatus,\n updatedAt: Date.now(),\n depositRailsSummary:\n remote.depositRailsSummary ?? local.depositRailsSummary,\n };\n\n return {\n account,\n previousStatus,\n statusChanged,\n shouldNotify,\n };\n}\n\n/**\n * Mark that the UI has notified for the account's current status.\n *\n * @param account - Account to update.\n * @returns Account with `notifiedForStatus` set to current status.\n */\nexport function markAutorampNotified(\n account: AutorampAccount,\n): AutorampAccount {\n return {\n ...account,\n notifiedForStatus: account.status,\n };\n}\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local + remote models for MoonPay Enterprise autoramp accounts.
|
|
3
|
+
* Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
|
|
4
|
+
*/
|
|
5
|
+
import type { AutorampDepositRailsSummary, AutorampRemoteSnapshot } from "./autoramp-types.cjs";
|
|
6
|
+
export type { AutorampDepositRailsSummary, AutorampRemoteSnapshot, } from "./autoramp-types.cjs";
|
|
7
|
+
/**
|
|
8
|
+
* Autoramp lifecycle statuses from MoonPay Enterprise.
|
|
9
|
+
*
|
|
10
|
+
* @see https://dev.enterprise.moonpay.com/autoramp-status
|
|
11
|
+
*/
|
|
12
|
+
export declare enum AutorampStatus {
|
|
13
|
+
Created = "Created",
|
|
14
|
+
Authorized = "Authorized",
|
|
15
|
+
EditPending = "EditPending",
|
|
16
|
+
DepositAccountAdded = "DepositAccountAdded",
|
|
17
|
+
Approved = "Approved",
|
|
18
|
+
Rejected = "Rejected",
|
|
19
|
+
Cancelled = "Cancelled"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Local controller representation of an autoramp account.
|
|
23
|
+
*/
|
|
24
|
+
export type AutorampAccount = {
|
|
25
|
+
/** MoonPay autoramp id. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** MoonPay customer id. */
|
|
28
|
+
customerId: string;
|
|
29
|
+
/** Destination wallet address associated with this autoramp. */
|
|
30
|
+
walletAddress: string;
|
|
31
|
+
/** Latest status from MoonPay (source of truth after refresh). */
|
|
32
|
+
status: AutorampStatus;
|
|
33
|
+
/**
|
|
34
|
+
* Status observed before the most recent remote apply.
|
|
35
|
+
* Used for transition UX / analytics (e.g. Authorized → Approved).
|
|
36
|
+
*/
|
|
37
|
+
lastSeenStatus: AutorampStatus;
|
|
38
|
+
/**
|
|
39
|
+
* Last status for which the UI already showed a notification.
|
|
40
|
+
* Prevents duplicate toasts across refresh and push.
|
|
41
|
+
*/
|
|
42
|
+
notifiedForStatus?: AutorampStatus;
|
|
43
|
+
/** Epoch ms of the last local update from remote or push. */
|
|
44
|
+
updatedAt: number;
|
|
45
|
+
/** Optional non-PII deposit readiness cache. */
|
|
46
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Controller-facing payload for creating an autoramp.
|
|
50
|
+
*
|
|
51
|
+
* Mirrors the MoonPay `POST /api/autoramps` body that
|
|
52
|
+
* {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:
|
|
53
|
+
* `RampsController.createAutoramp` injects the vendor customer id resolved from
|
|
54
|
+
* Profile Sync, so callers never supply (or need to know) it.
|
|
55
|
+
*/
|
|
56
|
+
export type CreateAutorampRequest = Record<string, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* Result of applying a remote autoramp snapshot onto local state.
|
|
59
|
+
*/
|
|
60
|
+
export type ApplyAutorampRemoteStatusResult = {
|
|
61
|
+
account: AutorampAccount;
|
|
62
|
+
previousStatus: AutorampStatus;
|
|
63
|
+
statusChanged: boolean;
|
|
64
|
+
/** True when status changed and UI has not yet notified for the new status. */
|
|
65
|
+
shouldNotify: boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Terminal autoramp statuses — no further lifecycle progress expected.
|
|
69
|
+
*/
|
|
70
|
+
export declare const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
|
|
71
|
+
/**
|
|
72
|
+
* Statuses that commonly warrant user-visible transition UX (toast / banner).
|
|
73
|
+
*/
|
|
74
|
+
export declare const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
|
|
75
|
+
/**
|
|
76
|
+
* Whether an autoramp status is terminal.
|
|
77
|
+
*
|
|
78
|
+
* @param status - Status to test.
|
|
79
|
+
* @returns Whether the status is terminal.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isTerminalAutorampStatus(status: AutorampStatus): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Normalize a remote status string into {@link AutorampStatus}.
|
|
84
|
+
* Unknown values fall back to {@link AutorampStatus.Created}.
|
|
85
|
+
*
|
|
86
|
+
* @param status - Remote status string.
|
|
87
|
+
* @returns A known {@link AutorampStatus}.
|
|
88
|
+
*/
|
|
89
|
+
export declare function normalizeAutorampStatus(status: AutorampStatus | string): AutorampStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Build a new local autoramp account from create/response fields.
|
|
92
|
+
*
|
|
93
|
+
* @param input - Required identity + status fields.
|
|
94
|
+
* @param input.id - MoonPay autoramp id.
|
|
95
|
+
* @param input.customerId - MoonPay customer id.
|
|
96
|
+
* @param input.walletAddress - Destination wallet address.
|
|
97
|
+
* @param input.status - Optional remote status (defaults to Authorized).
|
|
98
|
+
* @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
|
|
99
|
+
* @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
|
|
100
|
+
* @returns A new {@link AutorampAccount}.
|
|
101
|
+
*/
|
|
102
|
+
export declare function createAutorampAccount(input: {
|
|
103
|
+
id: string;
|
|
104
|
+
customerId: string;
|
|
105
|
+
walletAddress: string;
|
|
106
|
+
status?: AutorampStatus | string;
|
|
107
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
108
|
+
updatedAt?: number;
|
|
109
|
+
}): AutorampAccount;
|
|
110
|
+
/**
|
|
111
|
+
* Apply a remote autoramp snapshot onto a local account for transition detection.
|
|
112
|
+
* Pure helper — shared by refresh-on-load and websocket push paths.
|
|
113
|
+
*
|
|
114
|
+
* @param local - Current local account (or null when first upserting from remote).
|
|
115
|
+
* @param remote - Remote snapshot (MoonPay GET or push).
|
|
116
|
+
* @returns Updated account plus change / notify flags.
|
|
117
|
+
*/
|
|
118
|
+
export declare function applyAutorampRemoteStatus(local: AutorampAccount | null, remote: AutorampRemoteSnapshot): ApplyAutorampRemoteStatusResult;
|
|
119
|
+
/**
|
|
120
|
+
* Mark that the UI has notified for the account's current status.
|
|
121
|
+
*
|
|
122
|
+
* @param account - Account to update.
|
|
123
|
+
* @returns Account with `notifiedForStatus` set to current status.
|
|
124
|
+
*/
|
|
125
|
+
export declare function markAutorampNotified(account: AutorampAccount): AutorampAccount;
|
|
126
|
+
//# sourceMappingURL=autorampAccount.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autorampAccount.d.cts","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACvB,6BAA4B;AAE7B,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,GACvB,6BAA4B;AAE7B;;;;GAIG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,mBAAmB,wBAAwB;IAC3C,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,cAAc,CAGjE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAIhE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,GAAG,MAAM,GAC9B,cAAc,CAKhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,CAalB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,+BAA+B,CAqDjC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,GACvB,eAAe,CAKjB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local + remote models for MoonPay Enterprise autoramp accounts.
|
|
3
|
+
* Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
|
|
4
|
+
*/
|
|
5
|
+
import type { AutorampDepositRailsSummary, AutorampRemoteSnapshot } from "./autoramp-types.mjs";
|
|
6
|
+
export type { AutorampDepositRailsSummary, AutorampRemoteSnapshot, } from "./autoramp-types.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* Autoramp lifecycle statuses from MoonPay Enterprise.
|
|
9
|
+
*
|
|
10
|
+
* @see https://dev.enterprise.moonpay.com/autoramp-status
|
|
11
|
+
*/
|
|
12
|
+
export declare enum AutorampStatus {
|
|
13
|
+
Created = "Created",
|
|
14
|
+
Authorized = "Authorized",
|
|
15
|
+
EditPending = "EditPending",
|
|
16
|
+
DepositAccountAdded = "DepositAccountAdded",
|
|
17
|
+
Approved = "Approved",
|
|
18
|
+
Rejected = "Rejected",
|
|
19
|
+
Cancelled = "Cancelled"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Local controller representation of an autoramp account.
|
|
23
|
+
*/
|
|
24
|
+
export type AutorampAccount = {
|
|
25
|
+
/** MoonPay autoramp id. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** MoonPay customer id. */
|
|
28
|
+
customerId: string;
|
|
29
|
+
/** Destination wallet address associated with this autoramp. */
|
|
30
|
+
walletAddress: string;
|
|
31
|
+
/** Latest status from MoonPay (source of truth after refresh). */
|
|
32
|
+
status: AutorampStatus;
|
|
33
|
+
/**
|
|
34
|
+
* Status observed before the most recent remote apply.
|
|
35
|
+
* Used for transition UX / analytics (e.g. Authorized → Approved).
|
|
36
|
+
*/
|
|
37
|
+
lastSeenStatus: AutorampStatus;
|
|
38
|
+
/**
|
|
39
|
+
* Last status for which the UI already showed a notification.
|
|
40
|
+
* Prevents duplicate toasts across refresh and push.
|
|
41
|
+
*/
|
|
42
|
+
notifiedForStatus?: AutorampStatus;
|
|
43
|
+
/** Epoch ms of the last local update from remote or push. */
|
|
44
|
+
updatedAt: number;
|
|
45
|
+
/** Optional non-PII deposit readiness cache. */
|
|
46
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Controller-facing payload for creating an autoramp.
|
|
50
|
+
*
|
|
51
|
+
* Mirrors the MoonPay `POST /api/autoramps` body that
|
|
52
|
+
* {@link NeoBankService.createAutoramp} forwards opaquely, minus `customer_id`:
|
|
53
|
+
* `RampsController.createAutoramp` injects the vendor customer id resolved from
|
|
54
|
+
* Profile Sync, so callers never supply (or need to know) it.
|
|
55
|
+
*/
|
|
56
|
+
export type CreateAutorampRequest = Record<string, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* Result of applying a remote autoramp snapshot onto local state.
|
|
59
|
+
*/
|
|
60
|
+
export type ApplyAutorampRemoteStatusResult = {
|
|
61
|
+
account: AutorampAccount;
|
|
62
|
+
previousStatus: AutorampStatus;
|
|
63
|
+
statusChanged: boolean;
|
|
64
|
+
/** True when status changed and UI has not yet notified for the new status. */
|
|
65
|
+
shouldNotify: boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Terminal autoramp statuses — no further lifecycle progress expected.
|
|
69
|
+
*/
|
|
70
|
+
export declare const TERMINAL_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
|
|
71
|
+
/**
|
|
72
|
+
* Statuses that commonly warrant user-visible transition UX (toast / banner).
|
|
73
|
+
*/
|
|
74
|
+
export declare const NOTABLE_AUTORAMP_STATUSES: ReadonlySet<AutorampStatus>;
|
|
75
|
+
/**
|
|
76
|
+
* Whether an autoramp status is terminal.
|
|
77
|
+
*
|
|
78
|
+
* @param status - Status to test.
|
|
79
|
+
* @returns Whether the status is terminal.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isTerminalAutorampStatus(status: AutorampStatus): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Normalize a remote status string into {@link AutorampStatus}.
|
|
84
|
+
* Unknown values fall back to {@link AutorampStatus.Created}.
|
|
85
|
+
*
|
|
86
|
+
* @param status - Remote status string.
|
|
87
|
+
* @returns A known {@link AutorampStatus}.
|
|
88
|
+
*/
|
|
89
|
+
export declare function normalizeAutorampStatus(status: AutorampStatus | string): AutorampStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Build a new local autoramp account from create/response fields.
|
|
92
|
+
*
|
|
93
|
+
* @param input - Required identity + status fields.
|
|
94
|
+
* @param input.id - MoonPay autoramp id.
|
|
95
|
+
* @param input.customerId - MoonPay customer id.
|
|
96
|
+
* @param input.walletAddress - Destination wallet address.
|
|
97
|
+
* @param input.status - Optional remote status (defaults to Authorized).
|
|
98
|
+
* @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
|
|
99
|
+
* @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
|
|
100
|
+
* @returns A new {@link AutorampAccount}.
|
|
101
|
+
*/
|
|
102
|
+
export declare function createAutorampAccount(input: {
|
|
103
|
+
id: string;
|
|
104
|
+
customerId: string;
|
|
105
|
+
walletAddress: string;
|
|
106
|
+
status?: AutorampStatus | string;
|
|
107
|
+
depositRailsSummary?: AutorampDepositRailsSummary;
|
|
108
|
+
updatedAt?: number;
|
|
109
|
+
}): AutorampAccount;
|
|
110
|
+
/**
|
|
111
|
+
* Apply a remote autoramp snapshot onto a local account for transition detection.
|
|
112
|
+
* Pure helper — shared by refresh-on-load and websocket push paths.
|
|
113
|
+
*
|
|
114
|
+
* @param local - Current local account (or null when first upserting from remote).
|
|
115
|
+
* @param remote - Remote snapshot (MoonPay GET or push).
|
|
116
|
+
* @returns Updated account plus change / notify flags.
|
|
117
|
+
*/
|
|
118
|
+
export declare function applyAutorampRemoteStatus(local: AutorampAccount | null, remote: AutorampRemoteSnapshot): ApplyAutorampRemoteStatusResult;
|
|
119
|
+
/**
|
|
120
|
+
* Mark that the UI has notified for the account's current status.
|
|
121
|
+
*
|
|
122
|
+
* @param account - Account to update.
|
|
123
|
+
* @returns Account with `notifiedForStatus` set to current status.
|
|
124
|
+
*/
|
|
125
|
+
export declare function markAutorampNotified(account: AutorampAccount): AutorampAccount;
|
|
126
|
+
//# sourceMappingURL=autorampAccount.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autorampAccount.d.mts","sourceRoot":"","sources":["../src/autorampAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACvB,6BAA4B;AAE7B,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,GACvB,6BAA4B;AAE7B;;;;GAIG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,mBAAmB,wBAAwB;IAC3C,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,cAAc,CAGjE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAIhE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,GAAG,MAAM,GAC9B,cAAc,CAKhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,CAalB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,+BAA+B,CAqDjC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,GACvB,eAAe,CAKjB"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local + remote models for MoonPay Enterprise autoramp accounts.
|
|
3
|
+
* Separate from {@link RampsOrder}: autoramps are standing routes; orders are payments.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Autoramp lifecycle statuses from MoonPay Enterprise.
|
|
7
|
+
*
|
|
8
|
+
* @see https://dev.enterprise.moonpay.com/autoramp-status
|
|
9
|
+
*/
|
|
10
|
+
export var AutorampStatus;
|
|
11
|
+
(function (AutorampStatus) {
|
|
12
|
+
AutorampStatus["Created"] = "Created";
|
|
13
|
+
AutorampStatus["Authorized"] = "Authorized";
|
|
14
|
+
AutorampStatus["EditPending"] = "EditPending";
|
|
15
|
+
AutorampStatus["DepositAccountAdded"] = "DepositAccountAdded";
|
|
16
|
+
AutorampStatus["Approved"] = "Approved";
|
|
17
|
+
AutorampStatus["Rejected"] = "Rejected";
|
|
18
|
+
AutorampStatus["Cancelled"] = "Cancelled";
|
|
19
|
+
})(AutorampStatus || (AutorampStatus = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Terminal autoramp statuses — no further lifecycle progress expected.
|
|
22
|
+
*/
|
|
23
|
+
export const TERMINAL_AUTORAMP_STATUSES = new Set([
|
|
24
|
+
AutorampStatus.Rejected,
|
|
25
|
+
AutorampStatus.Cancelled,
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* Statuses that commonly warrant user-visible transition UX (toast / banner).
|
|
29
|
+
*/
|
|
30
|
+
export const NOTABLE_AUTORAMP_STATUSES = new Set([
|
|
31
|
+
AutorampStatus.Approved,
|
|
32
|
+
AutorampStatus.Rejected,
|
|
33
|
+
AutorampStatus.Cancelled,
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Whether an autoramp status is terminal.
|
|
37
|
+
*
|
|
38
|
+
* @param status - Status to test.
|
|
39
|
+
* @returns Whether the status is terminal.
|
|
40
|
+
*/
|
|
41
|
+
export function isTerminalAutorampStatus(status) {
|
|
42
|
+
return TERMINAL_AUTORAMP_STATUSES.has(status);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a remote status string into {@link AutorampStatus}.
|
|
46
|
+
* Unknown values fall back to {@link AutorampStatus.Created}.
|
|
47
|
+
*
|
|
48
|
+
* @param status - Remote status string.
|
|
49
|
+
* @returns A known {@link AutorampStatus}.
|
|
50
|
+
*/
|
|
51
|
+
export function normalizeAutorampStatus(status) {
|
|
52
|
+
if (Object.values(AutorampStatus).includes(status)) {
|
|
53
|
+
return status;
|
|
54
|
+
}
|
|
55
|
+
return AutorampStatus.Created;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Build a new local autoramp account from create/response fields.
|
|
59
|
+
*
|
|
60
|
+
* @param input - Required identity + status fields.
|
|
61
|
+
* @param input.id - MoonPay autoramp id.
|
|
62
|
+
* @param input.customerId - MoonPay customer id.
|
|
63
|
+
* @param input.walletAddress - Destination wallet address.
|
|
64
|
+
* @param input.status - Optional remote status (defaults to Authorized).
|
|
65
|
+
* @param input.depositRailsSummary - Optional non-PII deposit readiness cache.
|
|
66
|
+
* @param input.updatedAt - Optional epoch ms timestamp (defaults to now).
|
|
67
|
+
* @returns A new {@link AutorampAccount}.
|
|
68
|
+
*/
|
|
69
|
+
export function createAutorampAccount(input) {
|
|
70
|
+
const status = normalizeAutorampStatus(input.status ?? AutorampStatus.Authorized);
|
|
71
|
+
return {
|
|
72
|
+
id: input.id,
|
|
73
|
+
customerId: input.customerId,
|
|
74
|
+
walletAddress: input.walletAddress,
|
|
75
|
+
status,
|
|
76
|
+
lastSeenStatus: status,
|
|
77
|
+
updatedAt: input.updatedAt ?? Date.now(),
|
|
78
|
+
depositRailsSummary: input.depositRailsSummary,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Apply a remote autoramp snapshot onto a local account for transition detection.
|
|
83
|
+
* Pure helper — shared by refresh-on-load and websocket push paths.
|
|
84
|
+
*
|
|
85
|
+
* @param local - Current local account (or null when first upserting from remote).
|
|
86
|
+
* @param remote - Remote snapshot (MoonPay GET or push).
|
|
87
|
+
* @returns Updated account plus change / notify flags.
|
|
88
|
+
*/
|
|
89
|
+
export function applyAutorampRemoteStatus(local, remote) {
|
|
90
|
+
const remoteStatus = normalizeAutorampStatus(remote.status);
|
|
91
|
+
if (!local) {
|
|
92
|
+
const account = createAutorampAccount({
|
|
93
|
+
id: remote.id,
|
|
94
|
+
customerId: remote.customerId ?? '',
|
|
95
|
+
walletAddress: remote.walletAddress ?? '',
|
|
96
|
+
status: remoteStatus,
|
|
97
|
+
depositRailsSummary: remote.depositRailsSummary,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
account,
|
|
101
|
+
previousStatus: remoteStatus,
|
|
102
|
+
statusChanged: false,
|
|
103
|
+
shouldNotify: false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const previousStatus = local.status;
|
|
107
|
+
const statusChanged = previousStatus !== remoteStatus;
|
|
108
|
+
const shouldNotify = statusChanged &&
|
|
109
|
+
local.notifiedForStatus !== remoteStatus &&
|
|
110
|
+
NOTABLE_AUTORAMP_STATUSES.has(remoteStatus);
|
|
111
|
+
const account = {
|
|
112
|
+
...local,
|
|
113
|
+
id: remote.id,
|
|
114
|
+
// A blank remote identity field means "not supplied", not "cleared": the
|
|
115
|
+
// proxy omits or empties these on partial status pushes, so keep the local
|
|
116
|
+
// value rather than wiping it.
|
|
117
|
+
customerId: remote.customerId !== undefined && remote.customerId.length > 0
|
|
118
|
+
? remote.customerId
|
|
119
|
+
: local.customerId,
|
|
120
|
+
walletAddress: remote.walletAddress !== undefined && remote.walletAddress.length > 0
|
|
121
|
+
? remote.walletAddress
|
|
122
|
+
: local.walletAddress,
|
|
123
|
+
status: remoteStatus,
|
|
124
|
+
lastSeenStatus: previousStatus,
|
|
125
|
+
updatedAt: Date.now(),
|
|
126
|
+
depositRailsSummary: remote.depositRailsSummary ?? local.depositRailsSummary,
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
account,
|
|
130
|
+
previousStatus,
|
|
131
|
+
statusChanged,
|
|
132
|
+
shouldNotify,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Mark that the UI has notified for the account's current status.
|
|
137
|
+
*
|
|
138
|
+
* @param account - Account to update.
|
|
139
|
+
* @returns Account with `notifiedForStatus` set to current status.
|
|
140
|
+
*/
|
|
141
|
+
export function markAutorampNotified(account) {
|
|
142
|
+
return {
|
|
143
|
+
...account,
|
|
144
|
+
notifiedForStatus: account.status,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=autorampAccount.mjs.map
|