@metamask-previews/chomp-api-service 0.0.0-preview-08b3d87
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 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/chomp-api-service-method-action-types.cjs +7 -0
- package/dist/chomp-api-service-method-action-types.cjs.map +1 -0
- package/dist/chomp-api-service-method-action-types.d.cts +59 -0
- package/dist/chomp-api-service-method-action-types.d.cts.map +1 -0
- package/dist/chomp-api-service-method-action-types.d.mts +59 -0
- package/dist/chomp-api-service-method-action-types.d.mts.map +1 -0
- package/dist/chomp-api-service-method-action-types.mjs +6 -0
- package/dist/chomp-api-service-method-action-types.mjs.map +1 -0
- package/dist/chomp-api-service.cjs +315 -0
- package/dist/chomp-api-service.cjs.map +1 -0
- package/dist/chomp-api-service.d.cts +139 -0
- package/dist/chomp-api-service.d.cts.map +1 -0
- package/dist/chomp-api-service.d.mts +139 -0
- package/dist/chomp-api-service.d.mts.map +1 -0
- package/dist/chomp-api-service.mjs +311 -0
- package/dist/chomp-api-service.mjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +98 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +98 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +77 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `ChompApiService` ([#8413](https://github.com/MetaMask/core/pull/8413))
|
|
13
|
+
|
|
14
|
+
[Unreleased]: https://github.com/MetaMask/core/
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/chomp-api-service`
|
|
2
|
+
|
|
3
|
+
Chomp API data service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/chomp-api-service`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/chomp-api-service`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.cjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service';\n\n/**\n * Associates an address with a CHOMP profile via POST /v1/auth/address.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade via POST /v1/account-upgrade.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.\n */\nexport type ChompApiServiceGetUpgradeAction = {\n type: `ChompApiService:getUpgrade`;\n handler: ChompApiService['getUpgrade'];\n};\n\n/**\n * Verifies a delegation via POST /v1/intent/verify-delegation.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\n};\n\n/**\n * Submits intents via POST /v1/intent.\n */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\n};\n\n/**\n * Fetches intents by address via GET /v1/intent/account/:address.\n */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Creates a withdrawal for card spend flows.\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradeAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction;\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { ChompApiService } from "./chomp-api-service.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Associates an address with a CHOMP profile via POST /v1/auth/address.
|
|
8
|
+
*/
|
|
9
|
+
export type ChompApiServiceAssociateAddressAction = {
|
|
10
|
+
type: `ChompApiService:associateAddress`;
|
|
11
|
+
handler: ChompApiService['associateAddress'];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates an account upgrade via POST /v1/account-upgrade.
|
|
15
|
+
*/
|
|
16
|
+
export type ChompApiServiceCreateUpgradeAction = {
|
|
17
|
+
type: `ChompApiService:createUpgrade`;
|
|
18
|
+
handler: ChompApiService['createUpgrade'];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.
|
|
22
|
+
*/
|
|
23
|
+
export type ChompApiServiceGetUpgradeAction = {
|
|
24
|
+
type: `ChompApiService:getUpgrade`;
|
|
25
|
+
handler: ChompApiService['getUpgrade'];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Verifies a delegation via POST /v1/intent/verify-delegation.
|
|
29
|
+
*/
|
|
30
|
+
export type ChompApiServiceVerifyDelegationAction = {
|
|
31
|
+
type: `ChompApiService:verifyDelegation`;
|
|
32
|
+
handler: ChompApiService['verifyDelegation'];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Submits intents via POST /v1/intent.
|
|
36
|
+
*/
|
|
37
|
+
export type ChompApiServiceCreateIntentsAction = {
|
|
38
|
+
type: `ChompApiService:createIntents`;
|
|
39
|
+
handler: ChompApiService['createIntents'];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Fetches intents by address via GET /v1/intent/account/:address.
|
|
43
|
+
*/
|
|
44
|
+
export type ChompApiServiceGetIntentsByAddressAction = {
|
|
45
|
+
type: `ChompApiService:getIntentsByAddress`;
|
|
46
|
+
handler: ChompApiService['getIntentsByAddress'];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates a withdrawal for card spend flows.
|
|
50
|
+
*/
|
|
51
|
+
export type ChompApiServiceCreateWithdrawalAction = {
|
|
52
|
+
type: `ChompApiService:createWithdrawal`;
|
|
53
|
+
handler: ChompApiService['createWithdrawal'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Union of all ChompApiService action types.
|
|
57
|
+
*/
|
|
58
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction;
|
|
59
|
+
//# sourceMappingURL=chomp-api-service-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { ChompApiService } from "./chomp-api-service.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Associates an address with a CHOMP profile via POST /v1/auth/address.
|
|
8
|
+
*/
|
|
9
|
+
export type ChompApiServiceAssociateAddressAction = {
|
|
10
|
+
type: `ChompApiService:associateAddress`;
|
|
11
|
+
handler: ChompApiService['associateAddress'];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates an account upgrade via POST /v1/account-upgrade.
|
|
15
|
+
*/
|
|
16
|
+
export type ChompApiServiceCreateUpgradeAction = {
|
|
17
|
+
type: `ChompApiService:createUpgrade`;
|
|
18
|
+
handler: ChompApiService['createUpgrade'];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.
|
|
22
|
+
*/
|
|
23
|
+
export type ChompApiServiceGetUpgradeAction = {
|
|
24
|
+
type: `ChompApiService:getUpgrade`;
|
|
25
|
+
handler: ChompApiService['getUpgrade'];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Verifies a delegation via POST /v1/intent/verify-delegation.
|
|
29
|
+
*/
|
|
30
|
+
export type ChompApiServiceVerifyDelegationAction = {
|
|
31
|
+
type: `ChompApiService:verifyDelegation`;
|
|
32
|
+
handler: ChompApiService['verifyDelegation'];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Submits intents via POST /v1/intent.
|
|
36
|
+
*/
|
|
37
|
+
export type ChompApiServiceCreateIntentsAction = {
|
|
38
|
+
type: `ChompApiService:createIntents`;
|
|
39
|
+
handler: ChompApiService['createIntents'];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Fetches intents by address via GET /v1/intent/account/:address.
|
|
43
|
+
*/
|
|
44
|
+
export type ChompApiServiceGetIntentsByAddressAction = {
|
|
45
|
+
type: `ChompApiService:getIntentsByAddress`;
|
|
46
|
+
handler: ChompApiService['getIntentsByAddress'];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates a withdrawal for card spend flows.
|
|
50
|
+
*/
|
|
51
|
+
export type ChompApiServiceCreateWithdrawalAction = {
|
|
52
|
+
type: `ChompApiService:createWithdrawal`;
|
|
53
|
+
handler: ChompApiService['createWithdrawal'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Union of all ChompApiService action types.
|
|
57
|
+
*/
|
|
58
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction;
|
|
59
|
+
//# sourceMappingURL=chomp-api-service-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.mts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.mjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service';\n\n/**\n * Associates an address with a CHOMP profile via POST /v1/auth/address.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade via POST /v1/account-upgrade.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.\n */\nexport type ChompApiServiceGetUpgradeAction = {\n type: `ChompApiService:getUpgrade`;\n handler: ChompApiService['getUpgrade'];\n};\n\n/**\n * Verifies a delegation via POST /v1/intent/verify-delegation.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\n};\n\n/**\n * Submits intents via POST /v1/intent.\n */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\n};\n\n/**\n * Fetches intents by address via GET /v1/intent/account/:address.\n */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Creates a withdrawal for card spend flows.\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradeAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction;\n"]}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ChompApiService_instances, _ChompApiService_baseUrl, _ChompApiService_authHeaders;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ChompApiService = exports.serviceName = void 0;
|
|
16
|
+
const base_data_service_1 = require("@metamask/base-data-service");
|
|
17
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
18
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
19
|
+
const utils_1 = require("@metamask/utils");
|
|
20
|
+
// === GENERAL ===
|
|
21
|
+
/**
|
|
22
|
+
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
23
|
+
* actions and events.
|
|
24
|
+
*/
|
|
25
|
+
exports.serviceName = 'ChompApiService';
|
|
26
|
+
// === MESSENGER ===
|
|
27
|
+
/**
|
|
28
|
+
* All of the methods within {@link ChompApiService} that are exposed via the
|
|
29
|
+
* messenger.
|
|
30
|
+
*/
|
|
31
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
32
|
+
'associateAddress',
|
|
33
|
+
'createUpgrade',
|
|
34
|
+
'getUpgrade',
|
|
35
|
+
'verifyDelegation',
|
|
36
|
+
'createIntents',
|
|
37
|
+
'getIntentsByAddress',
|
|
38
|
+
'createWithdrawal',
|
|
39
|
+
];
|
|
40
|
+
// === RESPONSE VALIDATION ===
|
|
41
|
+
const HexStringStruct = (0, superstruct_1.define)('Hex string', (value) => (0, utils_1.isStrictHexString)(value));
|
|
42
|
+
const AssociateAddressResponseStruct = (0, superstruct_1.type)({
|
|
43
|
+
profileId: (0, superstruct_1.string)(),
|
|
44
|
+
address: (0, superstruct_1.string)(),
|
|
45
|
+
status: (0, superstruct_1.string)(),
|
|
46
|
+
});
|
|
47
|
+
const UpgradeResponseStruct = (0, superstruct_1.type)({
|
|
48
|
+
signerAddress: (0, superstruct_1.string)(),
|
|
49
|
+
status: (0, superstruct_1.string)(),
|
|
50
|
+
createdAt: (0, superstruct_1.string)(),
|
|
51
|
+
});
|
|
52
|
+
const VerifyDelegationResponseStruct = (0, superstruct_1.type)({
|
|
53
|
+
valid: (0, superstruct_1.boolean)(),
|
|
54
|
+
delegationHash: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
55
|
+
errors: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
|
|
56
|
+
});
|
|
57
|
+
const SendIntentResponseArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
|
|
58
|
+
delegationHash: (0, superstruct_1.string)(),
|
|
59
|
+
metadata: (0, superstruct_1.type)({
|
|
60
|
+
allowance: HexStringStruct,
|
|
61
|
+
tokenSymbol: (0, superstruct_1.string)(),
|
|
62
|
+
tokenAddress: HexStringStruct,
|
|
63
|
+
type: (0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal']),
|
|
64
|
+
}),
|
|
65
|
+
createdAt: (0, superstruct_1.string)(),
|
|
66
|
+
}));
|
|
67
|
+
const IntentEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
|
|
68
|
+
account: HexStringStruct,
|
|
69
|
+
delegationHash: HexStringStruct,
|
|
70
|
+
chainId: HexStringStruct,
|
|
71
|
+
status: (0, superstruct_1.enums)(['active', 'revoked']),
|
|
72
|
+
metadata: (0, superstruct_1.type)({
|
|
73
|
+
allowance: HexStringStruct,
|
|
74
|
+
tokenAddress: HexStringStruct,
|
|
75
|
+
tokenSymbol: (0, superstruct_1.string)(),
|
|
76
|
+
type: (0, superstruct_1.enums)(['deposit', 'withdraw']),
|
|
77
|
+
}),
|
|
78
|
+
}));
|
|
79
|
+
const CreateWithdrawalResponseStruct = (0, superstruct_1.type)({
|
|
80
|
+
success: (0, superstruct_1.literal)(true),
|
|
81
|
+
});
|
|
82
|
+
// === SERVICE DEFINITION ===
|
|
83
|
+
/**
|
|
84
|
+
* This service is responsible for communicating with the CHOMP API.
|
|
85
|
+
*
|
|
86
|
+
* All requests are authenticated via JWT Bearer tokens obtained from the
|
|
87
|
+
* {@link AuthenticationControllerGetBearerTokenAction} messenger action.
|
|
88
|
+
*/
|
|
89
|
+
class ChompApiService extends base_data_service_1.BaseDataService {
|
|
90
|
+
/**
|
|
91
|
+
* Constructs a new ChompApiService.
|
|
92
|
+
*
|
|
93
|
+
* @param args - The constructor arguments.
|
|
94
|
+
* @param args.messenger - The messenger suited for this service.
|
|
95
|
+
* @param args.baseUrl - The base URL of the CHOMP API.
|
|
96
|
+
* @param args.queryClientConfig - Configuration for the underlying TanStack
|
|
97
|
+
* Query client.
|
|
98
|
+
* @param args.policyOptions - Options to pass to `createServicePolicy`.
|
|
99
|
+
*/
|
|
100
|
+
constructor({ messenger, baseUrl, queryClientConfig = {}, policyOptions = {}, }) {
|
|
101
|
+
super({
|
|
102
|
+
name: exports.serviceName,
|
|
103
|
+
messenger,
|
|
104
|
+
queryClientConfig,
|
|
105
|
+
policyOptions,
|
|
106
|
+
});
|
|
107
|
+
_ChompApiService_instances.add(this);
|
|
108
|
+
_ChompApiService_baseUrl.set(this, void 0);
|
|
109
|
+
__classPrivateFieldSet(this, _ChompApiService_baseUrl, baseUrl, "f");
|
|
110
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Associates an address with a CHOMP profile.
|
|
114
|
+
*
|
|
115
|
+
* POST /v1/auth/address
|
|
116
|
+
*
|
|
117
|
+
* @param request - The association request containing signature, timestamp,
|
|
118
|
+
* and address.
|
|
119
|
+
* @returns The profile association result. Returns on both 201 and 409.
|
|
120
|
+
*/
|
|
121
|
+
async associateAddress(request) {
|
|
122
|
+
const jsonResponse = await this.fetchQuery({
|
|
123
|
+
queryKey: [`${this.name}:associateAddress`, request],
|
|
124
|
+
staleTime: 0,
|
|
125
|
+
queryFn: async () => {
|
|
126
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
127
|
+
const response = await fetch(new URL('/v1/auth/address', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
headers,
|
|
130
|
+
body: JSON.stringify(request),
|
|
131
|
+
});
|
|
132
|
+
if (!response.ok && response.status !== 409) {
|
|
133
|
+
throw new controller_utils_1.HttpError(response.status, `POST /v1/auth/address failed with status '${response.status}'`);
|
|
134
|
+
}
|
|
135
|
+
return response.json();
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return (0, superstruct_1.create)(jsonResponse, AssociateAddressResponseStruct);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Creates an account upgrade request.
|
|
142
|
+
*
|
|
143
|
+
* POST /v1/account-upgrade
|
|
144
|
+
*
|
|
145
|
+
* @param request - The upgrade request containing signature components and
|
|
146
|
+
* chain details.
|
|
147
|
+
* @returns The upgrade result.
|
|
148
|
+
*/
|
|
149
|
+
async createUpgrade(request) {
|
|
150
|
+
const jsonResponse = await this.fetchQuery({
|
|
151
|
+
queryKey: [`${this.name}:createUpgrade`, request],
|
|
152
|
+
staleTime: 0,
|
|
153
|
+
queryFn: async () => {
|
|
154
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
155
|
+
const response = await fetch(new URL('/v1/account-upgrade', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers,
|
|
158
|
+
body: JSON.stringify(request),
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw new controller_utils_1.HttpError(response.status, `POST /v1/account-upgrade failed with status '${response.status}'`);
|
|
162
|
+
}
|
|
163
|
+
return response.json();
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return (0, superstruct_1.create)(jsonResponse, UpgradeResponseStruct);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Fetches the upgrade record for a given address.
|
|
170
|
+
*
|
|
171
|
+
* GET /v1/account-upgrade/:address
|
|
172
|
+
*
|
|
173
|
+
* @param address - The address to look up.
|
|
174
|
+
* @returns The upgrade record, or null if not found.
|
|
175
|
+
*/
|
|
176
|
+
async getUpgrade(address) {
|
|
177
|
+
const jsonResponse = await this.fetchQuery({
|
|
178
|
+
queryKey: [`${this.name}:getUpgrade`, address],
|
|
179
|
+
queryFn: async () => {
|
|
180
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
181
|
+
const response = await fetch(new URL(`/v1/account-upgrade/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
|
|
182
|
+
if (response.status === 404) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (!response.ok) {
|
|
186
|
+
throw new controller_utils_1.HttpError(response.status, `Get upgrade request failed with status '${response.status}'`);
|
|
187
|
+
}
|
|
188
|
+
return response.json();
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
if (jsonResponse === null) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
return (0, superstruct_1.create)(jsonResponse, UpgradeResponseStruct);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Verifies a delegation signature.
|
|
198
|
+
*
|
|
199
|
+
* POST /v1/intent/verify-delegation
|
|
200
|
+
*
|
|
201
|
+
* @param request - The delegation verification request.
|
|
202
|
+
* @returns The verification result including validity and optional errors.
|
|
203
|
+
*/
|
|
204
|
+
async verifyDelegation(request) {
|
|
205
|
+
const jsonResponse = await this.fetchQuery({
|
|
206
|
+
queryKey: [`${this.name}:verifyDelegation`, request],
|
|
207
|
+
staleTime: 0,
|
|
208
|
+
queryFn: async () => {
|
|
209
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
210
|
+
const response = await fetch(new URL('/v1/intent/verify-delegation', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
|
|
211
|
+
method: 'POST',
|
|
212
|
+
headers,
|
|
213
|
+
body: JSON.stringify(request),
|
|
214
|
+
});
|
|
215
|
+
if (!response.ok) {
|
|
216
|
+
throw new controller_utils_1.HttpError(response.status, `POST /v1/intent/verify-delegation failed with status '${response.status}'`);
|
|
217
|
+
}
|
|
218
|
+
return response.json();
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
return (0, superstruct_1.create)(jsonResponse, VerifyDelegationResponseStruct);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Submits one or more intents to the CHOMP API.
|
|
225
|
+
*
|
|
226
|
+
* POST /v1/intent
|
|
227
|
+
*
|
|
228
|
+
* @param intents - The array of intents to submit.
|
|
229
|
+
* @returns The array of intent responses.
|
|
230
|
+
*/
|
|
231
|
+
async createIntents(intents) {
|
|
232
|
+
const jsonResponse = await this.fetchQuery({
|
|
233
|
+
queryKey: [`${this.name}:createIntents`, intents],
|
|
234
|
+
staleTime: 0,
|
|
235
|
+
queryFn: async () => {
|
|
236
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
237
|
+
const response = await fetch(new URL('/v1/intent', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
headers,
|
|
240
|
+
body: JSON.stringify(intents),
|
|
241
|
+
});
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
throw new controller_utils_1.HttpError(response.status, `POST /v1/intent failed with status '${response.status}'`);
|
|
244
|
+
}
|
|
245
|
+
return response.json();
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
return (0, superstruct_1.create)(jsonResponse, SendIntentResponseArrayStruct);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Fetches intents associated with a given address.
|
|
252
|
+
*
|
|
253
|
+
* GET /v1/intent/account/:address
|
|
254
|
+
*
|
|
255
|
+
* @param address - The address to look up intents for.
|
|
256
|
+
* @returns The array of intents for the address.
|
|
257
|
+
*/
|
|
258
|
+
async getIntentsByAddress(address) {
|
|
259
|
+
const jsonResponse = await this.fetchQuery({
|
|
260
|
+
queryKey: [`${this.name}:getIntentsByAddress`, address],
|
|
261
|
+
queryFn: async () => {
|
|
262
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
263
|
+
const response = await fetch(new URL(`/v1/intent/account/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
|
|
264
|
+
if (!response.ok) {
|
|
265
|
+
throw new controller_utils_1.HttpError(response.status, `Get intents request failed with status '${response.status}'`);
|
|
266
|
+
}
|
|
267
|
+
return response.json();
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
return (0, superstruct_1.create)(jsonResponse, IntentEntryArrayStruct);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Creates a withdrawal for card spend flows.
|
|
274
|
+
*
|
|
275
|
+
* POST /v1/withdrawal
|
|
276
|
+
*
|
|
277
|
+
* @param request - The withdrawal request containing chainId, amount
|
|
278
|
+
* (decimal or hex string), and account address.
|
|
279
|
+
* @returns The withdrawal result.
|
|
280
|
+
*/
|
|
281
|
+
async createWithdrawal(request) {
|
|
282
|
+
const jsonResponse = await this.fetchQuery({
|
|
283
|
+
queryKey: [`${this.name}:createWithdrawal`, request],
|
|
284
|
+
staleTime: 0,
|
|
285
|
+
queryFn: async () => {
|
|
286
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
287
|
+
const response = await fetch(new URL('/v1/withdrawal', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), {
|
|
288
|
+
method: 'POST',
|
|
289
|
+
headers,
|
|
290
|
+
body: JSON.stringify(request),
|
|
291
|
+
});
|
|
292
|
+
if (!response.ok) {
|
|
293
|
+
throw new controller_utils_1.HttpError(response.status, `POST /v1/withdrawal failed with status '${response.status}'`);
|
|
294
|
+
}
|
|
295
|
+
return response.json();
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
return (0, superstruct_1.create)(jsonResponse, CreateWithdrawalResponseStruct);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.ChompApiService = ChompApiService;
|
|
302
|
+
_ChompApiService_baseUrl = new WeakMap(), _ChompApiService_instances = new WeakSet(), _ChompApiService_authHeaders =
|
|
303
|
+
/**
|
|
304
|
+
* Builds the standard headers for an authenticated CHOMP API request.
|
|
305
|
+
*
|
|
306
|
+
* @returns Headers including Authorization and Content-Type.
|
|
307
|
+
*/
|
|
308
|
+
async function _ChompApiService_authHeaders() {
|
|
309
|
+
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
310
|
+
return {
|
|
311
|
+
Authorization: `Bearer ${token}`,
|
|
312
|
+
'Content-Type': 'application/json',
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
//# sourceMappingURL=chomp-api-service.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chomp-api-service.cjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA8D;AAO9D,iEAAuD;AAGvD,uDAU+B;AAC/B,2CAAoD;AAkBpD,kBAAkB;AAElB;;;GAGG;AACU,QAAA,WAAW,GAAG,iBAAiB,CAAC;AAE7C,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,kBAAkB;IAClB,eAAe;IACf,YAAY;IACZ,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,kBAAkB;CACV,CAAC;AAuDX,8BAA8B;AAE9B,MAAM,eAAe,GAAG,IAAA,oBAAM,EAAS,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7D,IAAA,yBAAiB,EAAC,KAAK,CAAC,CACzB,CAAC;AAEF,MAAM,8BAA8B,GAAG,IAAA,kBAAI,EAAC;IAC1C,SAAS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AAa,MAAjB,IAAI,CAAe,CAAC;gBAC1C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,uBAAA,IAAI,gCAAS,CAAC,EAAE;oBACrE,MAAM,EAAE,MAAM;oBACd,OAAO;oBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;iBAC9B,CAAC,CAAC;gBAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,4BAAS,CACjB,QAAQ,CAAC,MAAM,EACf,2CAA2C,QAAQ,CAAC,MAAM,GAAG,CAC9D,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,IAAA,oBAAM,EAAC,YAAY,EAAE,8BAA8B,CAAC,CAAC;IAC9D,CAAC;CACF;AAjUD,0CAiUC;;AAvRC;;;;GAIG;AACH,KAAK;IACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACrC,yCAAyC,CAC1C,CAAC;IACF,OAAO;QACL,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport {\n array,\n boolean,\n create,\n define,\n enums,\n literal,\n optional,\n string,\n type,\n} from '@metamask/superstruct';\nimport { isStrictHexString } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n UpgradeResponse,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentRequest,\n SendIntentResponse,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ChompApiService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'ChompApiService';\n\n// === MESSENGER ===\n\n/**\n * All of the methods within {@link ChompApiService} that are exposed via the\n * messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = [\n 'associateAddress',\n 'createUpgrade',\n 'getUpgrade',\n 'verifyDelegation',\n 'createIntents',\n 'getIntentsByAddress',\n 'createWithdrawal',\n] as const;\n\n/**\n * Invalidates cached queries for {@link ChompApiService}.\n */\nexport type ChompApiServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceActions =\n | ChompApiServiceMethodActions\n | ChompApiServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link ChompApiService} calls.\n */\ntype AllowedActions = AuthenticationControllerGetBearerTokenAction;\n\n/**\n * Published when {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/**\n * Published when a key within {@link ChompApiService}'s cache is updated.\n */\nexport type ChompApiServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link ChompApiService} exposes to other consumers.\n */\nexport type ChompApiServiceEvents =\n | ChompApiServiceCacheUpdatedEvent\n | ChompApiServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link ChompApiService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ChompApiService}.\n */\nexport type ChompApiServiceMessenger = Messenger<\n typeof serviceName,\n ChompApiServiceActions | AllowedActions,\n ChompApiServiceEvents | AllowedEvents\n>;\n\n// === RESPONSE VALIDATION ===\n\nconst HexStringStruct = define<string>('Hex string', (value) =>\n isStrictHexString(value),\n);\n\nconst AssociateAddressResponseStruct = type({\n profileId: string(),\n address: string(),\n status: string(),\n});\n\nconst UpgradeResponseStruct = type({\n signerAddress: string(),\n status: string(),\n createdAt: string(),\n});\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(string()),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: string(),\n metadata: type({\n allowance: HexStringStruct,\n tokenSymbol: string(),\n tokenAddress: HexStringStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: HexStringStruct,\n delegationHash: HexStringStruct,\n chainId: HexStringStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: HexStringStruct,\n tokenAddress: HexStringStruct,\n tokenSymbol: string(),\n type: enums(['deposit', 'withdraw']),\n }),\n }),\n);\n\nconst CreateWithdrawalResponseStruct = type({\n success: literal(true),\n});\n\n// === SERVICE DEFINITION ===\n\n/**\n * This service is responsible for communicating with the CHOMP API.\n *\n * All requests are authenticated via JWT Bearer tokens obtained from the\n * {@link AuthenticationControllerGetBearerTokenAction} messenger action.\n */\nexport class ChompApiService extends BaseDataService<\n typeof serviceName,\n ChompApiServiceMessenger\n> {\n readonly #baseUrl: string;\n\n /**\n * Constructs a new ChompApiService.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.baseUrl - The base URL of the CHOMP API.\n * @param args.queryClientConfig - Configuration for the underlying TanStack\n * Query client.\n * @param args.policyOptions - Options to pass to `createServicePolicy`.\n */\n constructor({\n messenger,\n baseUrl,\n queryClientConfig = {},\n policyOptions = {},\n }: {\n messenger: ChompApiServiceMessenger;\n baseUrl: string;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Builds the standard headers for an authenticated CHOMP API request.\n *\n * @returns Headers including Authorization and Content-Type.\n */\n async #authHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n };\n }\n\n /**\n * Associates an address with a CHOMP profile.\n *\n * POST /v1/auth/address\n *\n * @param request - The association request containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n request: AssociateAddressRequest,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/auth/address', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok && response.status !== 409) {\n throw new HttpError(\n response.status,\n `POST /v1/auth/address failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, AssociateAddressResponseStruct);\n }\n\n /**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param request - The upgrade request containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(request: CreateUpgradeRequest): Promise<UpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/account-upgrade', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/account-upgrade failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Fetches the upgrade record for a given address.\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade record, or null if not found.\n */\n async getUpgrade(address: string): Promise<UpgradeResponse | null> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrade`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/account-upgrade/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get upgrade request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n if (jsonResponse === null) {\n return null;\n }\n\n return create(jsonResponse, UpgradeResponseStruct);\n }\n\n /**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param request - The delegation verification request.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n request: VerifyDelegationRequest,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL('/v1/intent/verify-delegation', this.#baseUrl),\n {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent/verify-delegation failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, VerifyDelegationResponseStruct);\n }\n\n /**\n * Submits one or more intents to the CHOMP API.\n *\n * POST /v1/intent\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\n async createIntents(\n intents: SendIntentRequest[],\n ): Promise<SendIntentResponse[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createIntents`, intents],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/intent', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(intents),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/intent failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(\n jsonResponse,\n SendIntentResponseArrayStruct,\n ) as SendIntentResponse[];\n }\n\n /**\n * Fetches intents associated with a given address.\n *\n * GET /v1/intent/account/:address\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address.\n */\n async getIntentsByAddress(address: string): Promise<IntentEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getIntentsByAddress`, address],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(\n new URL(`/v1/intent/account/${address}`, this.#baseUrl),\n { headers },\n );\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Get intents request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, IntentEntryArrayStruct) as IntentEntry[];\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param request - The withdrawal request containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n request: CreateWithdrawalRequest,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, request],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const response = await fetch(new URL('/v1/withdrawal', this.#baseUrl), {\n method: 'POST',\n headers,\n body: JSON.stringify(request),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `POST /v1/withdrawal failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, CreateWithdrawalResponseStruct);\n }\n}\n"]}
|