@metamask-previews/chomp-api-service 0.0.0-preview-7bb388270 → 0.0.0-preview-debd7ebcd
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 +1 -0
- package/dist/chomp-api-service-method-action-types.cjs.map +1 -1
- package/dist/chomp-api-service-method-action-types.d.cts +8 -1
- package/dist/chomp-api-service-method-action-types.d.cts.map +1 -1
- package/dist/chomp-api-service-method-action-types.d.mts +8 -1
- package/dist/chomp-api-service-method-action-types.d.mts.map +1 -1
- package/dist/chomp-api-service-method-action-types.mjs.map +1 -1
- package/dist/chomp-api-service.cjs +49 -0
- package/dist/chomp-api-service.cjs.map +1 -1
- package/dist/chomp-api-service.d.cts +12 -1
- package/dist/chomp-api-service.d.cts.map +1 -1
- package/dist/chomp-api-service.d.mts +12 -1
- package/dist/chomp-api-service.d.mts.map +1 -1
- package/dist/chomp-api-service.mjs +50 -1
- package/dist/chomp-api-service.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +19 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +19 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,5 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
12
|
- Add `ChompApiService` ([#8413](https://github.com/MetaMask/core/pull/8413))
|
|
13
|
+
- Add `getServiceDetails` method to retrieve delegation redeemer addresses and DeFi contract details for auto-deposit functionality
|
|
13
14
|
|
|
14
15
|
[Unreleased]: https://github.com/MetaMask/core/
|
|
@@ -1 +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"]}
|
|
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 * Retrieves service details via GET /v1/chomp.\n */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\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 | ChompApiServiceGetServiceDetailsAction;\n"]}
|
|
@@ -52,8 +52,15 @@ export type ChompApiServiceCreateWithdrawalAction = {
|
|
|
52
52
|
type: `ChompApiService:createWithdrawal`;
|
|
53
53
|
handler: ChompApiService['createWithdrawal'];
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves service details via GET /v1/chomp.
|
|
57
|
+
*/
|
|
58
|
+
export type ChompApiServiceGetServiceDetailsAction = {
|
|
59
|
+
type: `ChompApiService:getServiceDetails`;
|
|
60
|
+
handler: ChompApiService['getServiceDetails'];
|
|
61
|
+
};
|
|
55
62
|
/**
|
|
56
63
|
* Union of all ChompApiService action types.
|
|
57
64
|
*/
|
|
58
|
-
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction;
|
|
65
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
|
|
59
66
|
//# sourceMappingURL=chomp-api-service-method-action-types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts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CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
|
|
@@ -52,8 +52,15 @@ export type ChompApiServiceCreateWithdrawalAction = {
|
|
|
52
52
|
type: `ChompApiService:createWithdrawal`;
|
|
53
53
|
handler: ChompApiService['createWithdrawal'];
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves service details via GET /v1/chomp.
|
|
57
|
+
*/
|
|
58
|
+
export type ChompApiServiceGetServiceDetailsAction = {
|
|
59
|
+
type: `ChompApiService:getServiceDetails`;
|
|
60
|
+
handler: ChompApiService['getServiceDetails'];
|
|
61
|
+
};
|
|
55
62
|
/**
|
|
56
63
|
* Union of all ChompApiService action types.
|
|
57
64
|
*/
|
|
58
|
-
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction;
|
|
65
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
|
|
59
66
|
//# sourceMappingURL=chomp-api-service-method-action-types.d.mts.map
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.mts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAA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GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
|
|
@@ -1 +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"]}
|
|
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 * Retrieves service details via GET /v1/chomp.\n */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\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 | ChompApiServiceGetServiceDetailsAction;\n"]}
|
|
@@ -36,6 +36,7 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
36
36
|
'createIntents',
|
|
37
37
|
'getIntentsByAddress',
|
|
38
38
|
'createWithdrawal',
|
|
39
|
+
'getServiceDetails',
|
|
39
40
|
];
|
|
40
41
|
// === RESPONSE VALIDATION ===
|
|
41
42
|
const HexStringStruct = (0, superstruct_1.define)('Hex string', (value) => (0, utils_1.isStrictHexString)(value));
|
|
@@ -79,6 +80,23 @@ const IntentEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)(
|
|
|
79
80
|
const CreateWithdrawalResponseStruct = (0, superstruct_1.type)({
|
|
80
81
|
success: (0, superstruct_1.literal)(true),
|
|
81
82
|
});
|
|
83
|
+
const ServiceDetailsProtocolStruct = (0, superstruct_1.type)({
|
|
84
|
+
supportedTokens: (0, superstruct_1.array)((0, superstruct_1.type)({
|
|
85
|
+
tokenAddress: (0, superstruct_1.string)(),
|
|
86
|
+
tokenDecimals: (0, superstruct_1.number)(),
|
|
87
|
+
})),
|
|
88
|
+
adapterAddress: (0, superstruct_1.string)(),
|
|
89
|
+
intentTypes: (0, superstruct_1.array)((0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal'])),
|
|
90
|
+
});
|
|
91
|
+
const ServiceDetailsResponseStruct = (0, superstruct_1.type)({
|
|
92
|
+
auth: (0, superstruct_1.type)({
|
|
93
|
+
message: (0, superstruct_1.string)(),
|
|
94
|
+
}),
|
|
95
|
+
chains: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.type)({
|
|
96
|
+
autoDepositDelegate: (0, superstruct_1.string)(),
|
|
97
|
+
protocol: (0, superstruct_1.record)((0, superstruct_1.string)(), ServiceDetailsProtocolStruct),
|
|
98
|
+
})),
|
|
99
|
+
});
|
|
82
100
|
// === SERVICE DEFINITION ===
|
|
83
101
|
/**
|
|
84
102
|
* This service is responsible for communicating with the CHOMP API.
|
|
@@ -297,6 +315,37 @@ class ChompApiService extends base_data_service_1.BaseDataService {
|
|
|
297
315
|
});
|
|
298
316
|
return (0, superstruct_1.create)(jsonResponse, CreateWithdrawalResponseStruct);
|
|
299
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
320
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
321
|
+
*
|
|
322
|
+
* GET /v1/chomp
|
|
323
|
+
*
|
|
324
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
325
|
+
* details for.
|
|
326
|
+
* @returns The service details for the requested chains.
|
|
327
|
+
*/
|
|
328
|
+
async getServiceDetails(chainIds) {
|
|
329
|
+
for (const chainId of chainIds) {
|
|
330
|
+
if (!(0, utils_1.isStrictHexString)(chainId)) {
|
|
331
|
+
throw new Error(`Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const jsonResponse = await this.fetchQuery({
|
|
335
|
+
queryKey: [`${this.name}:getServiceDetails`, chainIds],
|
|
336
|
+
queryFn: async () => {
|
|
337
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
338
|
+
const url = new URL('/v1/chomp', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f"));
|
|
339
|
+
url.searchParams.set('chainId', chainIds.join(','));
|
|
340
|
+
const response = await fetch(url, { headers });
|
|
341
|
+
if (!response.ok) {
|
|
342
|
+
throw new controller_utils_1.HttpError(response.status, `GET /v1/chomp failed with status '${response.status}'`);
|
|
343
|
+
}
|
|
344
|
+
return response.json();
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
return (0, superstruct_1.create)(jsonResponse, ServiceDetailsResponseStruct);
|
|
348
|
+
}
|
|
300
349
|
}
|
|
301
350
|
exports.ChompApiService = ChompApiService;
|
|
302
351
|
_ChompApiService_baseUrl = new WeakMap(), _ChompApiService_instances = new WeakSet(), _ChompApiService_authHeaders =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.cjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA8D;AAO9D,iEAAuD;AAEvD,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;AA0DX,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,EAAE,IAAA,oBAAM,GAAE;IACnB,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,MAAM,EAAE,IAAA,oBAAM,GAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,IAAA,kBAAI,EAAC;IACjC,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB,MAAM,E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AAC,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 {\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 = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\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 * `AuthenticationController:getBearerToken` 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"]}
|
|
1
|
+
{"version":3,"file":"chomp-api-service.cjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA8D;AAO9D,iEAAuD;AAEvD,uDAY+B;AAC/B,2CAAoD;AAmBpD,kBAAkB;AAElB;;;GAGG;AACU,QAAA,WAAW,GAAG,iBAAiB,CAAC;A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,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,4BAAS,CACjB,QAAQ,CAAC,MAAM,EACf,qCAAqC,QAAQ,CAAC,MAAM,GAAG,CACxD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,IAAA,oBAAM,EACX,YAAY,EACZ,4BAA4B,CACH,CAAC;IAC9B,CAAC;CACF;AA7WD,0CA6WC;;AAnUC;;;;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 {\n array,\n boolean,\n create,\n define,\n enums,\n literal,\n number,\n optional,\n record,\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 ServiceDetailsResponse,\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 'getServiceDetails',\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 = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\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\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: string(),\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: string(),\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n string(),\n type({\n autoDepositDelegate: string(),\n protocol: record(string(), ServiceDetailsProtocolStruct),\n }),\n ),\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 * `AuthenticationController:getBearerToken` 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 /**\n * Retrieves service details including delegation redeemer addresses and DeFi\n * contract details for signing delegations for auto-deposit functionality.\n *\n * GET /v1/chomp\n *\n * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve\n * details for.\n * @returns The service details for the requested chains.\n */\n async getServiceDetails(chainIds: string[]): Promise<ServiceDetailsResponse> {\n for (const chainId of chainIds) {\n if (!isStrictHexString(chainId)) {\n throw new Error(\n `Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`,\n );\n }\n }\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getServiceDetails`, chainIds],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const url = new URL('/v1/chomp', this.#baseUrl);\n url.searchParams.set('chainId', chainIds.join(','));\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `GET /v1/chomp failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(\n jsonResponse,\n ServiceDetailsResponseStruct,\n ) as ServiceDetailsResponse;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import type { CreateServicePolicyOptions } from "@metamask/controller-utils";
|
|
|
4
4
|
import type { Messenger } from "@metamask/messenger";
|
|
5
5
|
import type { QueryClientConfig } from "@tanstack/query-core";
|
|
6
6
|
import type { ChompApiServiceMethodActions } from "./chomp-api-service-method-action-types.cjs";
|
|
7
|
-
import type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, UpgradeResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, IntentEntry, SendIntentRequest, SendIntentResponse, VerifyDelegationRequest, VerifyDelegationResponse } from "./types.cjs";
|
|
7
|
+
import type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, UpgradeResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, IntentEntry, SendIntentRequest, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationRequest, VerifyDelegationResponse } from "./types.cjs";
|
|
8
8
|
/**
|
|
9
9
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
10
10
|
* actions and events.
|
|
@@ -136,6 +136,17 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
136
136
|
* @returns The withdrawal result.
|
|
137
137
|
*/
|
|
138
138
|
createWithdrawal(request: CreateWithdrawalRequest): Promise<CreateWithdrawalResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
141
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
142
|
+
*
|
|
143
|
+
* GET /v1/chomp
|
|
144
|
+
*
|
|
145
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
146
|
+
* details for.
|
|
147
|
+
* @returns The service details for the requested chains.
|
|
148
|
+
*/
|
|
149
|
+
getServiceDetails(chainIds: string[]): Promise<ServiceDetailsResponse>;
|
|
139
150
|
}
|
|
140
151
|
export {};
|
|
141
152
|
//# sourceMappingURL=chomp-api-service.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.d.cts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"chomp-api-service.d.cts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;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ACT,OAAO,EACP,iBAAsB,EACtB,aAAkB,GACnB,EAAE;QACD,SAAS,EAAE,wBAAwB,CAAC;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;QACtC,aAAa,CAAC,EAAE,0BAA0B,CAAC;KAC5C;IA+BD;;;;;;;;OAQG;IACG,gBAAgB,CACpB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IA6BpC;;;;;;;;OAQG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IA6B5E;;;;;;;OAOG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAgClE;;;;;;;OAOG;IACG,gBAAgB,CACpB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IA6BpC;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,iBAAiB,EAAE,GAC3B,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA6BhC;;;;;;;OAOG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAwBlE;;;;;;;;OAQG;IACG,gBAAgB,CACpB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IA0BpC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAiC7E"}
|
|
@@ -4,7 +4,7 @@ import type { CreateServicePolicyOptions } from "@metamask/controller-utils";
|
|
|
4
4
|
import type { Messenger } from "@metamask/messenger";
|
|
5
5
|
import type { QueryClientConfig } from "@tanstack/query-core";
|
|
6
6
|
import type { ChompApiServiceMethodActions } from "./chomp-api-service-method-action-types.mjs";
|
|
7
|
-
import type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, UpgradeResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, IntentEntry, SendIntentRequest, SendIntentResponse, VerifyDelegationRequest, VerifyDelegationResponse } from "./types.mjs";
|
|
7
|
+
import type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, UpgradeResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, IntentEntry, SendIntentRequest, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationRequest, VerifyDelegationResponse } from "./types.mjs";
|
|
8
8
|
/**
|
|
9
9
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
10
10
|
* actions and events.
|
|
@@ -136,6 +136,17 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
136
136
|
* @returns The withdrawal result.
|
|
137
137
|
*/
|
|
138
138
|
createWithdrawal(request: CreateWithdrawalRequest): Promise<CreateWithdrawalResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
141
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
142
|
+
*
|
|
143
|
+
* GET /v1/chomp
|
|
144
|
+
*
|
|
145
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
146
|
+
* details for.
|
|
147
|
+
* @returns The service details for the requested chains.
|
|
148
|
+
*/
|
|
149
|
+
getServiceDetails(chainIds: string[]): Promise<ServiceDetailsResponse>;
|
|
139
150
|
}
|
|
140
151
|
export {};
|
|
141
152
|
//# sourceMappingURL=chomp-api-service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.d.mts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK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AC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAiC7E"}
|
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _ChompApiService_instances, _ChompApiService_baseUrl, _ChompApiService_authHeaders;
|
|
13
13
|
import { BaseDataService } from "@metamask/base-data-service";
|
|
14
14
|
import { HttpError } from "@metamask/controller-utils";
|
|
15
|
-
import { array, boolean, create, define, enums, literal, optional, string, type } from "@metamask/superstruct";
|
|
15
|
+
import { array, boolean, create, define, enums, literal, number, optional, record, string, type } from "@metamask/superstruct";
|
|
16
16
|
import { isStrictHexString } from "@metamask/utils";
|
|
17
17
|
// === GENERAL ===
|
|
18
18
|
/**
|
|
@@ -33,6 +33,7 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
33
33
|
'createIntents',
|
|
34
34
|
'getIntentsByAddress',
|
|
35
35
|
'createWithdrawal',
|
|
36
|
+
'getServiceDetails',
|
|
36
37
|
];
|
|
37
38
|
// === RESPONSE VALIDATION ===
|
|
38
39
|
const HexStringStruct = define('Hex string', (value) => isStrictHexString(value));
|
|
@@ -76,6 +77,23 @@ const IntentEntryArrayStruct = array(type({
|
|
|
76
77
|
const CreateWithdrawalResponseStruct = type({
|
|
77
78
|
success: literal(true),
|
|
78
79
|
});
|
|
80
|
+
const ServiceDetailsProtocolStruct = type({
|
|
81
|
+
supportedTokens: array(type({
|
|
82
|
+
tokenAddress: string(),
|
|
83
|
+
tokenDecimals: number(),
|
|
84
|
+
})),
|
|
85
|
+
adapterAddress: string(),
|
|
86
|
+
intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),
|
|
87
|
+
});
|
|
88
|
+
const ServiceDetailsResponseStruct = type({
|
|
89
|
+
auth: type({
|
|
90
|
+
message: string(),
|
|
91
|
+
}),
|
|
92
|
+
chains: record(string(), type({
|
|
93
|
+
autoDepositDelegate: string(),
|
|
94
|
+
protocol: record(string(), ServiceDetailsProtocolStruct),
|
|
95
|
+
})),
|
|
96
|
+
});
|
|
79
97
|
// === SERVICE DEFINITION ===
|
|
80
98
|
/**
|
|
81
99
|
* This service is responsible for communicating with the CHOMP API.
|
|
@@ -294,6 +312,37 @@ export class ChompApiService extends BaseDataService {
|
|
|
294
312
|
});
|
|
295
313
|
return create(jsonResponse, CreateWithdrawalResponseStruct);
|
|
296
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
317
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
318
|
+
*
|
|
319
|
+
* GET /v1/chomp
|
|
320
|
+
*
|
|
321
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
322
|
+
* details for.
|
|
323
|
+
* @returns The service details for the requested chains.
|
|
324
|
+
*/
|
|
325
|
+
async getServiceDetails(chainIds) {
|
|
326
|
+
for (const chainId of chainIds) {
|
|
327
|
+
if (!isStrictHexString(chainId)) {
|
|
328
|
+
throw new Error(`Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const jsonResponse = await this.fetchQuery({
|
|
332
|
+
queryKey: [`${this.name}:getServiceDetails`, chainIds],
|
|
333
|
+
queryFn: async () => {
|
|
334
|
+
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
335
|
+
const url = new URL('/v1/chomp', __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f"));
|
|
336
|
+
url.searchParams.set('chainId', chainIds.join(','));
|
|
337
|
+
const response = await fetch(url, { headers });
|
|
338
|
+
if (!response.ok) {
|
|
339
|
+
throw new HttpError(response.status, `GET /v1/chomp failed with status '${response.status}'`);
|
|
340
|
+
}
|
|
341
|
+
return response.json();
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
return create(jsonResponse, ServiceDetailsResponseStruct);
|
|
345
|
+
}
|
|
297
346
|
}
|
|
298
347
|
_ChompApiService_baseUrl = new WeakMap(), _ChompApiService_instances = new WeakSet(), _ChompApiService_authHeaders =
|
|
299
348
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.mjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,mCAAmC;AAEvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAI,EACL,8BAA8B;AAC/B,OAAO,EAAE,iBAAiB,EAAE,wBAAwB;AAkBpD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,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;AA0DX,8BAA8B;AAE9B,MAAM,eAAe,GAAG,MAAM,CAAS,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7D,iBAAiB,CAAC,KAAK,CAAC,CACzB,CAAC;AAEF,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,EAAE;IACnB,OAAO,EAAE,MAAM,EAAE;IACjB,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,MAAM,EAAE;IACvB,MAAM,EAAE,MAAM,EAAE;IAChB,SAAS,EAAE,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,KAAK,EAAE,OAAO,EAAE;IAChB,cAAc,EAAE,QAAQ,C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H,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 {\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 = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\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 * `AuthenticationController:getBearerToken` 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"]}
|
|
1
|
+
{"version":3,"file":"chomp-api-service.mjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAO9D,OAAO,EAAE,SAAS,EAAE,mCAAmC;AAEvD,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACL,8BAA8B;AAC/B,OAAO,EAAE,iBAAiB,EAAE,wBAAwB;AAmBpD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,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;IAClB,mBAAmB;CACX,CAAC;AA0DX,8BAA8B;AAE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AAM,IAAI,KAAK,CACb,4DAA4D,OAAO,GAAG,CACvE,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;YACzC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,oBAAoB,EAAE,QAAQ,CAAC;YACtD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,gEAAa,MAAjB,IAAI,CAAe,CAAC;gBAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,uBAAA,IAAI,gCAAS,CAAC,CAAC;gBAChD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBAE/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,qCAAqC,QAAQ,CAAC,MAAM,GAAG,CACxD,CAAC;gBACJ,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CACX,YAAY,EACZ,4BAA4B,CACH,CAAC;IAC9B,CAAC;CACF;;AAnUC;;;;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 {\n array,\n boolean,\n create,\n define,\n enums,\n literal,\n number,\n optional,\n record,\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 ServiceDetailsResponse,\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 'getServiceDetails',\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 = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\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\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: string(),\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: string(),\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n string(),\n type({\n autoDepositDelegate: string(),\n protocol: record(string(), ServiceDetailsProtocolStruct),\n }),\n ),\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 * `AuthenticationController:getBearerToken` 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 /**\n * Retrieves service details including delegation redeemer addresses and DeFi\n * contract details for signing delegations for auto-deposit functionality.\n *\n * GET /v1/chomp\n *\n * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve\n * details for.\n * @returns The service details for the requested chains.\n */\n async getServiceDetails(chainIds: string[]): Promise<ServiceDetailsResponse> {\n for (const chainId of chainIds) {\n if (!isStrictHexString(chainId)) {\n throw new Error(\n `Invalid chainId: expected a 0x-prefixed hex string, got '${chainId}'`,\n );\n }\n }\n\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getServiceDetails`, chainIds],\n queryFn: async () => {\n const headers = await this.#authHeaders();\n const url = new URL('/v1/chomp', this.#baseUrl);\n url.searchParams.set('chainId', chainIds.join(','));\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `GET /v1/chomp failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(\n jsonResponse,\n ServiceDetailsResponseStruct,\n ) as ServiceDetailsResponse;\n }\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAA7C,oHAAA,eAAe,OAAA","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAA7C,oHAAA,eAAe,OAAA","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChompApiService } from "./chomp-api-service.cjs";
|
|
2
2
|
export type { ChompApiServiceMessenger, ChompApiServiceActions, ChompApiServiceEvents, ChompApiServiceInvalidateQueriesAction, ChompApiServiceCacheUpdatedEvent, ChompApiServiceGranularCacheUpdatedEvent, } from "./chomp-api-service.cjs";
|
|
3
|
-
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, } from "./chomp-api-service-method-action-types.cjs";
|
|
4
|
-
export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.cjs";
|
|
3
|
+
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.cjs";
|
|
4
|
+
export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.cjs";
|
|
5
5
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,oBAAgB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChompApiService } from "./chomp-api-service.mjs";
|
|
2
2
|
export type { ChompApiServiceMessenger, ChompApiServiceActions, ChompApiServiceEvents, ChompApiServiceInvalidateQueriesAction, ChompApiServiceCacheUpdatedEvent, ChompApiServiceGranularCacheUpdatedEvent, } from "./chomp-api-service.mjs";
|
|
3
|
-
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, } from "./chomp-api-service-method-action-types.mjs";
|
|
4
|
-
export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.mjs";
|
|
3
|
+
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.mjs";
|
|
4
|
+
export type { AssociateAddressRequest, AssociateAddressResponse, CreateUpgradeRequest, CreateWithdrawalRequest, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataRequest, IntentMetadataResponse, SendIntentRequest, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationRequest, VerifyDelegationResponse, } from "./types.mjs";
|
|
5
5
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,oBAAgB"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressRequest,\n AssociateAddressResponse,\n CreateUpgradeRequest,\n CreateWithdrawalRequest,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\n IntentEntry,\n IntentMetadataRequest,\n IntentMetadataResponse,\n SendIntentRequest,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationRequest,\n VerifyDelegationResponse,\n} from './types';\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === REQUEST TYPES ===\n\nexport type AssociateAddressRequest = {\n signature: string;\n timestamp: string;\n address: string;\n};\n\nexport type CreateUpgradeRequest = {\n r: string;\n s: string;\n v: number;\n yParity: number;\n address: string;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationRequest = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataRequest = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentRequest = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataRequest;\n};\n\nexport type CreateWithdrawalRequest = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: string;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: string;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: string;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: string;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === REQUEST TYPES ===\n\nexport type AssociateAddressRequest = {\n signature: string;\n timestamp: string;\n address: string;\n};\n\nexport type CreateUpgradeRequest = {\n r: string;\n s: string;\n v: number;\n yParity: number;\n address: string;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationRequest = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataRequest = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentRequest = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataRequest;\n};\n\nexport type CreateWithdrawalRequest = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: string;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: string;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: string;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: string;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: string;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: string;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: string;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<string, ServiceDetailsChain>;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -95,4 +95,23 @@ export type IntentEntry = {
|
|
|
95
95
|
export type CreateWithdrawalResponse = {
|
|
96
96
|
success: true;
|
|
97
97
|
};
|
|
98
|
+
export type ServiceDetailsSupportedToken = {
|
|
99
|
+
tokenAddress: string;
|
|
100
|
+
tokenDecimals: number;
|
|
101
|
+
};
|
|
102
|
+
export type ServiceDetailsProtocol = {
|
|
103
|
+
supportedTokens: ServiceDetailsSupportedToken[];
|
|
104
|
+
adapterAddress: string;
|
|
105
|
+
intentTypes: ('cash-deposit' | 'cash-withdrawal')[];
|
|
106
|
+
};
|
|
107
|
+
export type ServiceDetailsChain = {
|
|
108
|
+
autoDepositDelegate: string;
|
|
109
|
+
protocol: Record<string, ServiceDetailsProtocol>;
|
|
110
|
+
};
|
|
111
|
+
export type ServiceDetailsResponse = {
|
|
112
|
+
auth: {
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
chains: Record<string, ServiceDetailsChain>;
|
|
116
|
+
};
|
|
98
117
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,GAAG,CAAC;CAChB,CAA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AAe,EAAE,4BAA4B,EAAE,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC7C,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -95,4 +95,23 @@ export type IntentEntry = {
|
|
|
95
95
|
export type CreateWithdrawalResponse = {
|
|
96
96
|
success: true;
|
|
97
97
|
};
|
|
98
|
+
export type ServiceDetailsSupportedToken = {
|
|
99
|
+
tokenAddress: string;
|
|
100
|
+
tokenDecimals: number;
|
|
101
|
+
};
|
|
102
|
+
export type ServiceDetailsProtocol = {
|
|
103
|
+
supportedTokens: ServiceDetailsSupportedToken[];
|
|
104
|
+
adapterAddress: string;
|
|
105
|
+
intentTypes: ('cash-deposit' | 'cash-withdrawal')[];
|
|
106
|
+
};
|
|
107
|
+
export type ServiceDetailsChain = {
|
|
108
|
+
autoDepositDelegate: string;
|
|
109
|
+
protocol: Record<string, ServiceDetailsProtocol>;
|
|
110
|
+
};
|
|
111
|
+
export type ServiceDetailsResponse = {
|
|
112
|
+
auth: {
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
chains: Record<string, ServiceDetailsChain>;
|
|
116
|
+
};
|
|
98
117
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":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GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE;QACR,SAAS,EAAE,GAAG,CAAC;QACf,YAAY,EAAE,GAAG,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,IAAI,CAAC;CACf,CAAC;AAIF,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,EAAE,4BAA4B,EAAE,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC7C,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === REQUEST TYPES ===\n\nexport type AssociateAddressRequest = {\n signature: string;\n timestamp: string;\n address: string;\n};\n\nexport type CreateUpgradeRequest = {\n r: string;\n s: string;\n v: number;\n yParity: number;\n address: string;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationRequest = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataRequest = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentRequest = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataRequest;\n};\n\nexport type CreateWithdrawalRequest = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: string;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: string;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: string;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: string;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n// === COMMON TYPES ===\n\nexport type DelegationCaveat = {\n enforcer: Hex;\n terms: Hex;\n args: Hex;\n};\n\nexport type SignedDelegation = {\n delegate: Hex;\n delegator: Hex;\n authority: Hex;\n caveats: DelegationCaveat[];\n salt: Hex;\n signature: Hex;\n};\n\n// === REQUEST TYPES ===\n\nexport type AssociateAddressRequest = {\n signature: string;\n timestamp: string;\n address: string;\n};\n\nexport type CreateUpgradeRequest = {\n r: string;\n s: string;\n v: number;\n yParity: number;\n address: string;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationRequest = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataRequest = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentRequest = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataRequest;\n};\n\nexport type CreateWithdrawalRequest = {\n chainId: Hex;\n /** Decimal integer or 0x-prefixed hex string representing the amount. */\n amount: string;\n account: Hex;\n};\n\n// === RESPONSE TYPES ===\n\nexport type AssociateAddressResponse = {\n profileId: string;\n address: string;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: string;\n status: string;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: string;\n errors?: string[];\n};\n\nexport type IntentMetadataResponse = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentResponse = {\n delegationHash: string;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\n *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: string;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: string;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: string;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<string, ServiceDetailsChain>;\n};\n"]}
|