@metamask-previews/chomp-api-service 2.0.0-preview-ae9b6b322 → 2.0.0-preview-d23d9dc44
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 +58 -12
- package/dist/chomp-api-service-method-action-types.d.cts.map +1 -1
- package/dist/chomp-api-service-method-action-types.d.mts +58 -12
- 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 +35 -19
- package/dist/chomp-api-service.cjs.map +1 -1
- package/dist/chomp-api-service.d.cts +6 -5
- package/dist/chomp-api-service.d.cts.map +1 -1
- package/dist/chomp-api-service.d.mts +6 -5
- package/dist/chomp-api-service.d.mts.map +1 -1
- package/dist/chomp-api-service.mjs +35 -19
- 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 +40 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +40 -8
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
+
- **BREAKING:** update types and methods of chomp-api-service to properly reflect the API ([#8635](https://github.com/MetaMask/core/pull/8635))
|
|
12
13
|
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
|
|
13
14
|
|
|
14
15
|
## [2.0.0]
|
|
@@ -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
|
|
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.\n *\n * POST /v1/auth/address\n *\n * @param params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\nexport type ChompApiServiceGetUpgradesAction = {\n type: `ChompApiService:getUpgrades`;\n handler: ChompApiService['getUpgrades'];\n};\n\n/**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\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 */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\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 */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\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 */\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 | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
|
|
@@ -4,56 +4,102 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ChompApiService } from "./chomp-api-service.cjs";
|
|
6
6
|
/**
|
|
7
|
-
* Associates an address with a CHOMP profile
|
|
7
|
+
* Associates an address with a CHOMP profile.
|
|
8
|
+
*
|
|
9
|
+
* POST /v1/auth/address
|
|
10
|
+
*
|
|
11
|
+
* @param params - The association params containing signature, timestamp,
|
|
12
|
+
* and address.
|
|
13
|
+
* @returns The profile association result. Returns on both 201 and 409.
|
|
8
14
|
*/
|
|
9
15
|
export type ChompApiServiceAssociateAddressAction = {
|
|
10
16
|
type: `ChompApiService:associateAddress`;
|
|
11
17
|
handler: ChompApiService['associateAddress'];
|
|
12
18
|
};
|
|
13
19
|
/**
|
|
14
|
-
* Creates an account upgrade
|
|
20
|
+
* Creates an account upgrade request.
|
|
21
|
+
*
|
|
22
|
+
* POST /v1/account-upgrade
|
|
23
|
+
*
|
|
24
|
+
* @param params - The upgrade params containing signature components and
|
|
25
|
+
* chain details.
|
|
26
|
+
* @returns The upgrade result.
|
|
15
27
|
*/
|
|
16
28
|
export type ChompApiServiceCreateUpgradeAction = {
|
|
17
29
|
type: `ChompApiService:createUpgrade`;
|
|
18
30
|
handler: ChompApiService['createUpgrade'];
|
|
19
31
|
};
|
|
20
32
|
/**
|
|
21
|
-
* Fetches
|
|
33
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
34
|
+
* chain).
|
|
35
|
+
*
|
|
36
|
+
* GET /v1/account-upgrade/:address
|
|
37
|
+
*
|
|
38
|
+
* @param address - The address to look up.
|
|
39
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
22
40
|
*/
|
|
23
|
-
export type
|
|
24
|
-
type: `ChompApiService:
|
|
25
|
-
handler: ChompApiService['
|
|
41
|
+
export type ChompApiServiceGetUpgradesAction = {
|
|
42
|
+
type: `ChompApiService:getUpgrades`;
|
|
43
|
+
handler: ChompApiService['getUpgrades'];
|
|
26
44
|
};
|
|
27
45
|
/**
|
|
28
|
-
* Verifies a delegation
|
|
46
|
+
* Verifies a delegation signature.
|
|
47
|
+
*
|
|
48
|
+
* POST /v1/intent/verify-delegation
|
|
49
|
+
*
|
|
50
|
+
* @param params - The delegation verification params.
|
|
51
|
+
* @returns The verification result including validity and optional errors.
|
|
29
52
|
*/
|
|
30
53
|
export type ChompApiServiceVerifyDelegationAction = {
|
|
31
54
|
type: `ChompApiService:verifyDelegation`;
|
|
32
55
|
handler: ChompApiService['verifyDelegation'];
|
|
33
56
|
};
|
|
34
57
|
/**
|
|
35
|
-
* Submits intents
|
|
58
|
+
* Submits one or more intents to the CHOMP API.
|
|
59
|
+
*
|
|
60
|
+
* POST /v1/intent
|
|
61
|
+
*
|
|
62
|
+
* @param intents - The array of intents to submit.
|
|
63
|
+
* @returns The array of intent responses.
|
|
36
64
|
*/
|
|
37
65
|
export type ChompApiServiceCreateIntentsAction = {
|
|
38
66
|
type: `ChompApiService:createIntents`;
|
|
39
67
|
handler: ChompApiService['createIntents'];
|
|
40
68
|
};
|
|
41
69
|
/**
|
|
42
|
-
* Fetches intents
|
|
70
|
+
* Fetches intents associated with a given address.
|
|
71
|
+
*
|
|
72
|
+
* GET /v1/intent/account/:address
|
|
73
|
+
*
|
|
74
|
+
* @param address - The address to look up intents for.
|
|
75
|
+
* @returns The array of intents for the address.
|
|
43
76
|
*/
|
|
44
77
|
export type ChompApiServiceGetIntentsByAddressAction = {
|
|
45
78
|
type: `ChompApiService:getIntentsByAddress`;
|
|
46
79
|
handler: ChompApiService['getIntentsByAddress'];
|
|
47
80
|
};
|
|
48
81
|
/**
|
|
49
|
-
*
|
|
82
|
+
* Creates a withdrawal for card spend flows.
|
|
83
|
+
*
|
|
84
|
+
* POST /v1/withdrawal
|
|
85
|
+
*
|
|
86
|
+
* @param params - The withdrawal params containing chainId, amount
|
|
87
|
+
* (decimal or hex string), and account address.
|
|
88
|
+
* @returns The withdrawal result.
|
|
50
89
|
*/
|
|
51
90
|
export type ChompApiServiceCreateWithdrawalAction = {
|
|
52
91
|
type: `ChompApiService:createWithdrawal`;
|
|
53
92
|
handler: ChompApiService['createWithdrawal'];
|
|
54
93
|
};
|
|
55
94
|
/**
|
|
56
|
-
* Retrieves service details
|
|
95
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
96
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
97
|
+
*
|
|
98
|
+
* GET /v1/chomp
|
|
99
|
+
*
|
|
100
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
101
|
+
* details for.
|
|
102
|
+
* @returns The service details for the requested chains.
|
|
57
103
|
*/
|
|
58
104
|
export type ChompApiServiceGetServiceDetailsAction = {
|
|
59
105
|
type: `ChompApiService:getServiceDetails`;
|
|
@@ -62,5 +108,5 @@ export type ChompApiServiceGetServiceDetailsAction = {
|
|
|
62
108
|
/**
|
|
63
109
|
* Union of all ChompApiService action types.
|
|
64
110
|
*/
|
|
65
|
-
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction |
|
|
111
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
|
|
66
112
|
//# 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"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC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/
|
|
5
5
|
import type { ChompApiService } from "./chomp-api-service.mjs";
|
|
6
6
|
/**
|
|
7
|
-
* Associates an address with a CHOMP profile
|
|
7
|
+
* Associates an address with a CHOMP profile.
|
|
8
|
+
*
|
|
9
|
+
* POST /v1/auth/address
|
|
10
|
+
*
|
|
11
|
+
* @param params - The association params containing signature, timestamp,
|
|
12
|
+
* and address.
|
|
13
|
+
* @returns The profile association result. Returns on both 201 and 409.
|
|
8
14
|
*/
|
|
9
15
|
export type ChompApiServiceAssociateAddressAction = {
|
|
10
16
|
type: `ChompApiService:associateAddress`;
|
|
11
17
|
handler: ChompApiService['associateAddress'];
|
|
12
18
|
};
|
|
13
19
|
/**
|
|
14
|
-
* Creates an account upgrade
|
|
20
|
+
* Creates an account upgrade request.
|
|
21
|
+
*
|
|
22
|
+
* POST /v1/account-upgrade
|
|
23
|
+
*
|
|
24
|
+
* @param params - The upgrade params containing signature components and
|
|
25
|
+
* chain details.
|
|
26
|
+
* @returns The upgrade result.
|
|
15
27
|
*/
|
|
16
28
|
export type ChompApiServiceCreateUpgradeAction = {
|
|
17
29
|
type: `ChompApiService:createUpgrade`;
|
|
18
30
|
handler: ChompApiService['createUpgrade'];
|
|
19
31
|
};
|
|
20
32
|
/**
|
|
21
|
-
* Fetches
|
|
33
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
34
|
+
* chain).
|
|
35
|
+
*
|
|
36
|
+
* GET /v1/account-upgrade/:address
|
|
37
|
+
*
|
|
38
|
+
* @param address - The address to look up.
|
|
39
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
22
40
|
*/
|
|
23
|
-
export type
|
|
24
|
-
type: `ChompApiService:
|
|
25
|
-
handler: ChompApiService['
|
|
41
|
+
export type ChompApiServiceGetUpgradesAction = {
|
|
42
|
+
type: `ChompApiService:getUpgrades`;
|
|
43
|
+
handler: ChompApiService['getUpgrades'];
|
|
26
44
|
};
|
|
27
45
|
/**
|
|
28
|
-
* Verifies a delegation
|
|
46
|
+
* Verifies a delegation signature.
|
|
47
|
+
*
|
|
48
|
+
* POST /v1/intent/verify-delegation
|
|
49
|
+
*
|
|
50
|
+
* @param params - The delegation verification params.
|
|
51
|
+
* @returns The verification result including validity and optional errors.
|
|
29
52
|
*/
|
|
30
53
|
export type ChompApiServiceVerifyDelegationAction = {
|
|
31
54
|
type: `ChompApiService:verifyDelegation`;
|
|
32
55
|
handler: ChompApiService['verifyDelegation'];
|
|
33
56
|
};
|
|
34
57
|
/**
|
|
35
|
-
* Submits intents
|
|
58
|
+
* Submits one or more intents to the CHOMP API.
|
|
59
|
+
*
|
|
60
|
+
* POST /v1/intent
|
|
61
|
+
*
|
|
62
|
+
* @param intents - The array of intents to submit.
|
|
63
|
+
* @returns The array of intent responses.
|
|
36
64
|
*/
|
|
37
65
|
export type ChompApiServiceCreateIntentsAction = {
|
|
38
66
|
type: `ChompApiService:createIntents`;
|
|
39
67
|
handler: ChompApiService['createIntents'];
|
|
40
68
|
};
|
|
41
69
|
/**
|
|
42
|
-
* Fetches intents
|
|
70
|
+
* Fetches intents associated with a given address.
|
|
71
|
+
*
|
|
72
|
+
* GET /v1/intent/account/:address
|
|
73
|
+
*
|
|
74
|
+
* @param address - The address to look up intents for.
|
|
75
|
+
* @returns The array of intents for the address.
|
|
43
76
|
*/
|
|
44
77
|
export type ChompApiServiceGetIntentsByAddressAction = {
|
|
45
78
|
type: `ChompApiService:getIntentsByAddress`;
|
|
46
79
|
handler: ChompApiService['getIntentsByAddress'];
|
|
47
80
|
};
|
|
48
81
|
/**
|
|
49
|
-
*
|
|
82
|
+
* Creates a withdrawal for card spend flows.
|
|
83
|
+
*
|
|
84
|
+
* POST /v1/withdrawal
|
|
85
|
+
*
|
|
86
|
+
* @param params - The withdrawal params containing chainId, amount
|
|
87
|
+
* (decimal or hex string), and account address.
|
|
88
|
+
* @returns The withdrawal result.
|
|
50
89
|
*/
|
|
51
90
|
export type ChompApiServiceCreateWithdrawalAction = {
|
|
52
91
|
type: `ChompApiService:createWithdrawal`;
|
|
53
92
|
handler: ChompApiService['createWithdrawal'];
|
|
54
93
|
};
|
|
55
94
|
/**
|
|
56
|
-
* Retrieves service details
|
|
95
|
+
* Retrieves service details including delegation redeemer addresses and DeFi
|
|
96
|
+
* contract details for signing delegations for auto-deposit functionality.
|
|
97
|
+
*
|
|
98
|
+
* GET /v1/chomp
|
|
99
|
+
*
|
|
100
|
+
* @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve
|
|
101
|
+
* details for.
|
|
102
|
+
* @returns The service details for the requested chains.
|
|
57
103
|
*/
|
|
58
104
|
export type ChompApiServiceGetServiceDetailsAction = {
|
|
59
105
|
type: `ChompApiService:getServiceDetails`;
|
|
@@ -62,5 +108,5 @@ export type ChompApiServiceGetServiceDetailsAction = {
|
|
|
62
108
|
/**
|
|
63
109
|
* Union of all ChompApiService action types.
|
|
64
110
|
*/
|
|
65
|
-
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction |
|
|
111
|
+
export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
|
|
66
112
|
//# 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
|
|
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,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CAAqC,GACrC,kCAAkC,GAClC,gCAAgC,GAChC,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
|
|
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.\n *\n * POST /v1/auth/address\n *\n * @param params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\nexport type ChompApiServiceGetUpgradesAction = {\n type: `ChompApiService:getUpgrades`;\n handler: ChompApiService['getUpgrades'];\n};\n\n/**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\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 */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\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 */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\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 */\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 | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
|
|
@@ -31,7 +31,7 @@ exports.serviceName = 'ChompApiService';
|
|
|
31
31
|
const MESSENGER_EXPOSED_METHODS = [
|
|
32
32
|
'associateAddress',
|
|
33
33
|
'createUpgrade',
|
|
34
|
-
'
|
|
34
|
+
'getUpgrades',
|
|
35
35
|
'verifyDelegation',
|
|
36
36
|
'createIntents',
|
|
37
37
|
'getIntentsByAddress',
|
|
@@ -40,15 +40,36 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
40
40
|
];
|
|
41
41
|
// === RESPONSE VALIDATION ===
|
|
42
42
|
const AssociateAddressResponseStruct = (0, superstruct_1.type)({
|
|
43
|
-
profileId: (0, superstruct_1.string)(),
|
|
43
|
+
profileId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
44
44
|
address: utils_1.StrictHexStruct,
|
|
45
|
-
status: (0, superstruct_1.
|
|
45
|
+
status: (0, superstruct_1.enums)(['active', 'created']),
|
|
46
46
|
});
|
|
47
|
-
const
|
|
47
|
+
const AccountUpgradeStatusStruct = (0, superstruct_1.enums)(['pending', 'upgraded']);
|
|
48
|
+
const AuthorizationDataStruct = (0, superstruct_1.type)({
|
|
49
|
+
r: utils_1.StrictHexStruct,
|
|
50
|
+
s: utils_1.StrictHexStruct,
|
|
51
|
+
v: (0, superstruct_1.number)(),
|
|
52
|
+
yParity: (0, superstruct_1.number)(),
|
|
53
|
+
address: utils_1.StrictHexStruct,
|
|
54
|
+
chainId: utils_1.StrictHexStruct,
|
|
55
|
+
nonce: utils_1.StrictHexStruct,
|
|
56
|
+
});
|
|
57
|
+
const CreateUpgradeResponseStruct = (0, superstruct_1.type)({
|
|
48
58
|
signerAddress: utils_1.StrictHexStruct,
|
|
49
|
-
|
|
59
|
+
address: utils_1.StrictHexStruct,
|
|
60
|
+
chainId: utils_1.StrictHexStruct,
|
|
61
|
+
nonce: utils_1.StrictHexStruct,
|
|
62
|
+
status: AccountUpgradeStatusStruct,
|
|
50
63
|
createdAt: (0, superstruct_1.string)(),
|
|
51
64
|
});
|
|
65
|
+
const UpgradeEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)({
|
|
66
|
+
signerAddress: utils_1.StrictHexStruct,
|
|
67
|
+
chainId: utils_1.StrictHexStruct,
|
|
68
|
+
nonce: utils_1.StrictHexStruct,
|
|
69
|
+
authorization: AuthorizationDataStruct,
|
|
70
|
+
status: AccountUpgradeStatusStruct,
|
|
71
|
+
createdAt: (0, superstruct_1.string)(),
|
|
72
|
+
}));
|
|
52
73
|
const VerifyDelegationResponseStruct = (0, superstruct_1.type)({
|
|
53
74
|
valid: (0, superstruct_1.boolean)(),
|
|
54
75
|
delegationHash: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
|
|
@@ -73,7 +94,7 @@ const IntentEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)(
|
|
|
73
94
|
allowance: utils_1.StrictHexStruct,
|
|
74
95
|
tokenAddress: utils_1.StrictHexStruct,
|
|
75
96
|
tokenSymbol: (0, superstruct_1.string)(),
|
|
76
|
-
type: (0, superstruct_1.enums)(['deposit', '
|
|
97
|
+
type: (0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal']),
|
|
77
98
|
}),
|
|
78
99
|
}));
|
|
79
100
|
const CreateWithdrawalResponseStruct = (0, superstruct_1.type)({
|
|
@@ -180,35 +201,30 @@ class ChompApiService extends base_data_service_1.BaseDataService {
|
|
|
180
201
|
return response.json();
|
|
181
202
|
},
|
|
182
203
|
});
|
|
183
|
-
return (0, superstruct_1.create)(jsonResponse,
|
|
204
|
+
return (0, superstruct_1.create)(jsonResponse, CreateUpgradeResponseStruct);
|
|
184
205
|
}
|
|
185
206
|
/**
|
|
186
|
-
* Fetches
|
|
207
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
208
|
+
* chain).
|
|
187
209
|
*
|
|
188
210
|
* GET /v1/account-upgrade/:address
|
|
189
211
|
*
|
|
190
212
|
* @param address - The address to look up.
|
|
191
|
-
* @returns The upgrade
|
|
213
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
192
214
|
*/
|
|
193
|
-
async
|
|
215
|
+
async getUpgrades(address) {
|
|
194
216
|
const jsonResponse = await this.fetchQuery({
|
|
195
|
-
queryKey: [`${this.name}:
|
|
217
|
+
queryKey: [`${this.name}:getUpgrades`, address],
|
|
196
218
|
queryFn: async () => {
|
|
197
219
|
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
198
220
|
const response = await fetch(new URL(`/v1/account-upgrade/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
|
|
199
|
-
if (response.status === 404) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
221
|
if (!response.ok) {
|
|
203
|
-
throw new controller_utils_1.HttpError(response.status, `Get
|
|
222
|
+
throw new controller_utils_1.HttpError(response.status, `Get upgrades request failed with status '${response.status}'`);
|
|
204
223
|
}
|
|
205
224
|
return response.json();
|
|
206
225
|
},
|
|
207
226
|
});
|
|
208
|
-
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
return (0, superstruct_1.create)(jsonResponse, UpgradeResponseStruct);
|
|
227
|
+
return (0, superstruct_1.create)(jsonResponse, UpgradeEntryArrayStruct);
|
|
212
228
|
}
|
|
213
229
|
/**
|
|
214
230
|
* Verifies a delegation signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.cjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA8D;AAO9D,iEAAuD;AAEvD,uDAW+B;AAE/B,2CAAkD;AAmBlD,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;IAClB,mBAAmB;CACX,CAAC;AA0DX,8BAA8B;AAE9B,MAAM,8BAA8B,GAAG,IAAA,kBA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;OASG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAe;QACrC,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,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,EAAC,YAAY,EAAE,4BAA4B,CAAC,CAAC;IAC5D,CAAC;CACF;AA/VD,0CA+VC;;AArTC;;;;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 enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n UpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\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 AssociateAddressResponseStruct = type({\n profileId: string(),\n address: StrictHexStruct,\n status: string(),\n});\n\nconst UpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n status: string(),\n createdAt: string(),\n});\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(StrictHexStruct),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n metadata: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: StrictHexStruct,\n delegationHash: StrictHexStruct,\n chainId: StrictHexStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: StrictHexStruct,\n tokenAddress: StrictHexStruct,\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: StrictHexStruct,\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: StrictHexStruct,\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\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 params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n params: AssociateAddressParams,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, params],\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(params),\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 params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(params: CreateUpgradeParams): Promise<UpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, params],\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(params),\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: Hex): 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 params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n params: VerifyDelegationParams,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, params],\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(params),\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: SendIntentParams[],\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(jsonResponse, SendIntentResponseArrayStruct);\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: Hex): 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);\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n params: CreateWithdrawalParams,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, params],\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(params),\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: Hex[]): Promise<ServiceDetailsResponse> {\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(jsonResponse, ServiceDetailsResponseStruct);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chomp-api-service.cjs","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA8D;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AG,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,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,EAAC,YAAY,EAAE,4BAA4B,CAAC,CAAC;IAC5D,CAAC;CACF;AA1VD,0CA0VC;;AAhTC;;;;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 enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n UpgradeEntry,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\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 'getUpgrades',\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 AssociateAddressResponseStruct = type({\n profileId: optional(string()),\n address: StrictHexStruct,\n status: enums(['active', 'created']),\n});\n\nconst AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);\n\nconst AuthorizationDataStruct = type({\n r: StrictHexStruct,\n s: StrictHexStruct,\n v: number(),\n yParity: number(),\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n});\n\nconst CreateUpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n});\n\nconst UpgradeEntryArrayStruct = array(\n type({\n signerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n authorization: AuthorizationDataStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n }),\n);\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(StrictHexStruct),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n metadata: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: StrictHexStruct,\n delegationHash: StrictHexStruct,\n chainId: StrictHexStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: StrictHexStruct,\n tokenAddress: StrictHexStruct,\n tokenSymbol: string(),\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n }),\n);\n\nconst CreateWithdrawalResponseStruct = type({\n success: literal(true),\n});\n\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: StrictHexStruct,\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: StrictHexStruct,\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\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 params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n params: AssociateAddressParams,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, params],\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(params),\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 params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(\n params: CreateUpgradeParams,\n ): Promise<CreateUpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, params],\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(params),\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, CreateUpgradeResponseStruct);\n }\n\n /**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\n async getUpgrades(address: Hex): Promise<UpgradeEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrades`, 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.ok) {\n throw new HttpError(\n response.status,\n `Get upgrades request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeEntryArrayStruct);\n }\n\n /**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n params: VerifyDelegationParams,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, params],\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(params),\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: SendIntentParams[],\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(jsonResponse, SendIntentResponseArrayStruct);\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: Hex): 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);\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n params: CreateWithdrawalParams,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, params],\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(params),\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: Hex[]): Promise<ServiceDetailsResponse> {\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(jsonResponse, ServiceDetailsResponseStruct);\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import type { Messenger } from "@metamask/messenger";
|
|
|
5
5
|
import type { Hex } from "@metamask/utils";
|
|
6
6
|
import type { QueryClientConfig } from "@tanstack/query-core";
|
|
7
7
|
import type { ChompApiServiceMethodActions } from "./chomp-api-service-method-action-types.cjs";
|
|
8
|
-
import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams,
|
|
8
|
+
import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from "./types.cjs";
|
|
9
9
|
/**
|
|
10
10
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
11
11
|
* actions and events.
|
|
@@ -90,16 +90,17 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
90
90
|
* chain details.
|
|
91
91
|
* @returns The upgrade result.
|
|
92
92
|
*/
|
|
93
|
-
createUpgrade(params: CreateUpgradeParams): Promise<
|
|
93
|
+
createUpgrade(params: CreateUpgradeParams): Promise<CreateUpgradeResponse>;
|
|
94
94
|
/**
|
|
95
|
-
* Fetches
|
|
95
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
96
|
+
* chain).
|
|
96
97
|
*
|
|
97
98
|
* GET /v1/account-upgrade/:address
|
|
98
99
|
*
|
|
99
100
|
* @param address - The address to look up.
|
|
100
|
-
* @returns The upgrade
|
|
101
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
+
getUpgrades(address: Hex): Promise<UpgradeEntry[]>;
|
|
103
104
|
/**
|
|
104
105
|
* Verifies a delegation signature.
|
|
105
106
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.d.cts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe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wBxD;;;;;;;OAOG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IA6BpC;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA0BhC;;;;;;;OAOG;IACG,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAwB/D;;;;;;;;OAQG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IA0BpC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAsB1E"}
|
|
@@ -5,7 +5,7 @@ import type { Messenger } from "@metamask/messenger";
|
|
|
5
5
|
import type { Hex } from "@metamask/utils";
|
|
6
6
|
import type { QueryClientConfig } from "@tanstack/query-core";
|
|
7
7
|
import type { ChompApiServiceMethodActions } from "./chomp-api-service-method-action-types.mjs";
|
|
8
|
-
import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams,
|
|
8
|
+
import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from "./types.mjs";
|
|
9
9
|
/**
|
|
10
10
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
11
11
|
* actions and events.
|
|
@@ -90,16 +90,17 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
90
90
|
* chain details.
|
|
91
91
|
* @returns The upgrade result.
|
|
92
92
|
*/
|
|
93
|
-
createUpgrade(params: CreateUpgradeParams): Promise<
|
|
93
|
+
createUpgrade(params: CreateUpgradeParams): Promise<CreateUpgradeResponse>;
|
|
94
94
|
/**
|
|
95
|
-
* Fetches
|
|
95
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
96
|
+
* chain).
|
|
96
97
|
*
|
|
97
98
|
* GET /v1/account-upgrade/:address
|
|
98
99
|
*
|
|
99
100
|
* @param address - The address to look up.
|
|
100
|
-
* @returns The upgrade
|
|
101
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
+
getUpgrades(address: Hex): Promise<UpgradeEntry[]>;
|
|
103
104
|
/**
|
|
104
105
|
* Verifies a delegation signature.
|
|
105
106
|
*
|
|
@@ -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,EAAE,SAAS,EAAE,4BAA4B;AAarD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B;AAE9D,OAAO,KAAK,EAAE,4BAA4B,EAAE,oDAAgD;AAC5F,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,
|
|
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,EAAE,SAAS,EAAE,4BAA4B;AAarD,OAAO,KAAK,EAAE,GAAG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;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,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,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IA6BpC;;;;;;;;OAQG;IACG,aAAa,CACjB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IA6BjC;;;;;;;;OAQG;IACG,WAAW,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAwBxD;;;;;;;OAOG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IA6BpC;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA0BhC;;;;;;;OAOG;IACG,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAwB/D;;;;;;;;OAQG;IACG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IA0BpC;;;;;;;;;OASG;IACG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAsB1E"}
|
|
@@ -28,7 +28,7 @@ export const serviceName = 'ChompApiService';
|
|
|
28
28
|
const MESSENGER_EXPOSED_METHODS = [
|
|
29
29
|
'associateAddress',
|
|
30
30
|
'createUpgrade',
|
|
31
|
-
'
|
|
31
|
+
'getUpgrades',
|
|
32
32
|
'verifyDelegation',
|
|
33
33
|
'createIntents',
|
|
34
34
|
'getIntentsByAddress',
|
|
@@ -37,15 +37,36 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
37
37
|
];
|
|
38
38
|
// === RESPONSE VALIDATION ===
|
|
39
39
|
const AssociateAddressResponseStruct = type({
|
|
40
|
-
profileId: string(),
|
|
40
|
+
profileId: optional(string()),
|
|
41
41
|
address: StrictHexStruct,
|
|
42
|
-
status:
|
|
42
|
+
status: enums(['active', 'created']),
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);
|
|
45
|
+
const AuthorizationDataStruct = type({
|
|
46
|
+
r: StrictHexStruct,
|
|
47
|
+
s: StrictHexStruct,
|
|
48
|
+
v: number(),
|
|
49
|
+
yParity: number(),
|
|
50
|
+
address: StrictHexStruct,
|
|
51
|
+
chainId: StrictHexStruct,
|
|
52
|
+
nonce: StrictHexStruct,
|
|
53
|
+
});
|
|
54
|
+
const CreateUpgradeResponseStruct = type({
|
|
45
55
|
signerAddress: StrictHexStruct,
|
|
46
|
-
|
|
56
|
+
address: StrictHexStruct,
|
|
57
|
+
chainId: StrictHexStruct,
|
|
58
|
+
nonce: StrictHexStruct,
|
|
59
|
+
status: AccountUpgradeStatusStruct,
|
|
47
60
|
createdAt: string(),
|
|
48
61
|
});
|
|
62
|
+
const UpgradeEntryArrayStruct = array(type({
|
|
63
|
+
signerAddress: StrictHexStruct,
|
|
64
|
+
chainId: StrictHexStruct,
|
|
65
|
+
nonce: StrictHexStruct,
|
|
66
|
+
authorization: AuthorizationDataStruct,
|
|
67
|
+
status: AccountUpgradeStatusStruct,
|
|
68
|
+
createdAt: string(),
|
|
69
|
+
}));
|
|
49
70
|
const VerifyDelegationResponseStruct = type({
|
|
50
71
|
valid: boolean(),
|
|
51
72
|
delegationHash: optional(StrictHexStruct),
|
|
@@ -70,7 +91,7 @@ const IntentEntryArrayStruct = array(type({
|
|
|
70
91
|
allowance: StrictHexStruct,
|
|
71
92
|
tokenAddress: StrictHexStruct,
|
|
72
93
|
tokenSymbol: string(),
|
|
73
|
-
type: enums(['deposit', '
|
|
94
|
+
type: enums(['cash-deposit', 'cash-withdrawal']),
|
|
74
95
|
}),
|
|
75
96
|
}));
|
|
76
97
|
const CreateWithdrawalResponseStruct = type({
|
|
@@ -177,35 +198,30 @@ export class ChompApiService extends BaseDataService {
|
|
|
177
198
|
return response.json();
|
|
178
199
|
},
|
|
179
200
|
});
|
|
180
|
-
return create(jsonResponse,
|
|
201
|
+
return create(jsonResponse, CreateUpgradeResponseStruct);
|
|
181
202
|
}
|
|
182
203
|
/**
|
|
183
|
-
* Fetches
|
|
204
|
+
* Fetches all EIP-7702 upgrade authorizations for a given address (one per
|
|
205
|
+
* chain).
|
|
184
206
|
*
|
|
185
207
|
* GET /v1/account-upgrade/:address
|
|
186
208
|
*
|
|
187
209
|
* @param address - The address to look up.
|
|
188
|
-
* @returns The upgrade
|
|
210
|
+
* @returns The upgrade entries; empty array if none exist.
|
|
189
211
|
*/
|
|
190
|
-
async
|
|
212
|
+
async getUpgrades(address) {
|
|
191
213
|
const jsonResponse = await this.fetchQuery({
|
|
192
|
-
queryKey: [`${this.name}:
|
|
214
|
+
queryKey: [`${this.name}:getUpgrades`, address],
|
|
193
215
|
queryFn: async () => {
|
|
194
216
|
const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
|
|
195
217
|
const response = await fetch(new URL(`/v1/account-upgrade/${address}`, __classPrivateFieldGet(this, _ChompApiService_baseUrl, "f")), { headers });
|
|
196
|
-
if (response.status === 404) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
218
|
if (!response.ok) {
|
|
200
|
-
throw new HttpError(response.status, `Get
|
|
219
|
+
throw new HttpError(response.status, `Get upgrades request failed with status '${response.status}'`);
|
|
201
220
|
}
|
|
202
221
|
return response.json();
|
|
203
222
|
},
|
|
204
223
|
});
|
|
205
|
-
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
return create(jsonResponse, UpgradeResponseStruct);
|
|
224
|
+
return create(jsonResponse, UpgradeEntryArrayStruct);
|
|
209
225
|
}
|
|
210
226
|
/**
|
|
211
227
|
* Verifies a delegation signature.
|
|
@@ -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,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACL,8BAA8B;AAE/B,OAAO,EAAE,eAAe,EAAE,wBAAwB;AAmBlD,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;AAE9B,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,EAAE;IACnB,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,eAAe;IAC9B,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,CAAC,eAAe,CAAC;IACzC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CA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AC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,YAAY,EAAE,4BAA4B,CAAC,CAAC;IAC5D,CAAC;CACF;;AArTC;;;;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 enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n UpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\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 AssociateAddressResponseStruct = type({\n profileId: string(),\n address: StrictHexStruct,\n status: string(),\n});\n\nconst UpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n status: string(),\n createdAt: string(),\n});\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(StrictHexStruct),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n metadata: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: StrictHexStruct,\n delegationHash: StrictHexStruct,\n chainId: StrictHexStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: StrictHexStruct,\n tokenAddress: StrictHexStruct,\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: StrictHexStruct,\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: StrictHexStruct,\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\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 params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n params: AssociateAddressParams,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, params],\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(params),\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 params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(params: CreateUpgradeParams): Promise<UpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, params],\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(params),\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: Hex): 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 params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n params: VerifyDelegationParams,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, params],\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(params),\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: SendIntentParams[],\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(jsonResponse, SendIntentResponseArrayStruct);\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: Hex): 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);\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n params: CreateWithdrawalParams,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, params],\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(params),\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: Hex[]): Promise<ServiceDetailsResponse> {\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(jsonResponse, ServiceDetailsResponseStruct);\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,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACL,8BAA8B;AAE/B,OAAO,EAAE,eAAe,EAAE,wBAAwB;AAoBlD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,kBAAkB;IAClB,eAAe;IACf,aAAa;IACb,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;CACX,CAAC;AA0DX,8BAA8B;AAE9B,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,KAAK,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;AAElE,MAAM,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AQ,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,CAAC,YAAY,EAAE,4BAA4B,CAAC,CAAC;IAC5D,CAAC;CACF;;AAhTC;;;;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 enums,\n literal,\n number,\n optional,\n record,\n string,\n type,\n} from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types';\nimport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n UpgradeEntry,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n IntentEntry,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsResponse,\n VerifyDelegationParams,\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 'getUpgrades',\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 AssociateAddressResponseStruct = type({\n profileId: optional(string()),\n address: StrictHexStruct,\n status: enums(['active', 'created']),\n});\n\nconst AccountUpgradeStatusStruct = enums(['pending', 'upgraded']);\n\nconst AuthorizationDataStruct = type({\n r: StrictHexStruct,\n s: StrictHexStruct,\n v: number(),\n yParity: number(),\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n});\n\nconst CreateUpgradeResponseStruct = type({\n signerAddress: StrictHexStruct,\n address: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n});\n\nconst UpgradeEntryArrayStruct = array(\n type({\n signerAddress: StrictHexStruct,\n chainId: StrictHexStruct,\n nonce: StrictHexStruct,\n authorization: AuthorizationDataStruct,\n status: AccountUpgradeStatusStruct,\n createdAt: string(),\n }),\n);\n\nconst VerifyDelegationResponseStruct = type({\n valid: boolean(),\n delegationHash: optional(StrictHexStruct),\n errors: optional(array(string())),\n});\n\nconst SendIntentResponseArrayStruct = array(\n type({\n delegationHash: StrictHexStruct,\n metadata: type({\n allowance: StrictHexStruct,\n tokenSymbol: string(),\n tokenAddress: StrictHexStruct,\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n createdAt: string(),\n }),\n);\n\nconst IntentEntryArrayStruct = array(\n type({\n account: StrictHexStruct,\n delegationHash: StrictHexStruct,\n chainId: StrictHexStruct,\n status: enums(['active', 'revoked']),\n metadata: type({\n allowance: StrictHexStruct,\n tokenAddress: StrictHexStruct,\n tokenSymbol: string(),\n type: enums(['cash-deposit', 'cash-withdrawal']),\n }),\n }),\n);\n\nconst CreateWithdrawalResponseStruct = type({\n success: literal(true),\n});\n\nconst ServiceDetailsProtocolStruct = type({\n supportedTokens: array(\n type({\n tokenAddress: StrictHexStruct,\n tokenDecimals: number(),\n }),\n ),\n adapterAddress: StrictHexStruct,\n intentTypes: array(enums(['cash-deposit', 'cash-withdrawal'])),\n});\n\nconst ServiceDetailsResponseStruct = type({\n auth: type({\n message: string(),\n }),\n chains: record(\n StrictHexStruct,\n type({\n autoDepositDelegate: StrictHexStruct,\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 params - The association params containing signature, timestamp,\n * and address.\n * @returns The profile association result. Returns on both 201 and 409.\n */\n async associateAddress(\n params: AssociateAddressParams,\n ): Promise<AssociateAddressResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:associateAddress`, params],\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(params),\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 params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\n async createUpgrade(\n params: CreateUpgradeParams,\n ): Promise<CreateUpgradeResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createUpgrade`, params],\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(params),\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, CreateUpgradeResponseStruct);\n }\n\n /**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\n async getUpgrades(address: Hex): Promise<UpgradeEntry[]> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:getUpgrades`, 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.ok) {\n throw new HttpError(\n response.status,\n `Get upgrades request failed with status '${response.status}'`,\n );\n }\n\n return response.json();\n },\n });\n\n return create(jsonResponse, UpgradeEntryArrayStruct);\n }\n\n /**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\n async verifyDelegation(\n params: VerifyDelegationParams,\n ): Promise<VerifyDelegationResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:verifyDelegation`, params],\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(params),\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: SendIntentParams[],\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(jsonResponse, SendIntentResponseArrayStruct);\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: Hex): 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);\n }\n\n /**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\n async createWithdrawal(\n params: CreateWithdrawalParams,\n ): Promise<CreateWithdrawalResponse> {\n const jsonResponse = await this.fetchQuery({\n queryKey: [`${this.name}:createWithdrawal`, params],\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(params),\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: Hex[]): Promise<ServiceDetailsResponse> {\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(jsonResponse, ServiceDetailsResponseStruct);\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
|
|
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 ChompApiServiceGetUpgradesAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AccountUpgradeStatus,\n AssociateAddressParams,\n AssociateAddressResponse,\n AuthorizationData,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeEntry,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationParams,\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,
|
|
4
|
-
export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat,
|
|
3
|
+
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradesAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.cjs";
|
|
4
|
+
export type { AccountUpgradeStatus, AssociateAddressParams, AssociateAddressResponse, AuthorizationData, CreateUpgradeParams, CreateUpgradeResponse, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeEntry, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, 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
|
|
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,gCAAgC,EAChC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,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,
|
|
4
|
-
export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat,
|
|
3
|
+
export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradesAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.mjs";
|
|
4
|
+
export type { AccountUpgradeStatus, AssociateAddressParams, AssociateAddressResponse, AuthorizationData, CreateUpgradeParams, CreateUpgradeResponse, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeEntry, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, 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
|
|
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,gCAAgC,EAChC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,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
|
|
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 ChompApiServiceGetUpgradesAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AccountUpgradeStatus,\n AssociateAddressParams,\n AssociateAddressResponse,\n AuthorizationData,\n CreateUpgradeParams,\n CreateUpgradeResponse,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeEntry,\n IntentEntry,\n IntentMetadataParams,\n IntentMetadataResponse,\n SendIntentParams,\n SendIntentResponse,\n ServiceDetailsChain,\n ServiceDetailsProtocol,\n ServiceDetailsResponse,\n ServiceDetailsSupportedToken,\n SignedDelegation,\n VerifyDelegationParams,\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// === PARAMS TYPES ===\n\nexport type AssociateAddressParams = {\n signature: Hex;\n timestamp: number;\n address: Hex;\n};\n\nexport type CreateUpgradeParams = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationParams = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentParams = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataParams;\n};\n\nexport type CreateWithdrawalParams = {\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
|
|
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// === PARAMS TYPES ===\n\nexport type AssociateAddressParams = {\n signature: Hex;\n timestamp: number;\n address: Hex;\n};\n\nexport type CreateUpgradeParams = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationParams = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentParams = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataParams;\n};\n\nexport type CreateWithdrawalParams = {\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\n/**\n * Returned by POST /v1/auth/address.\n *\n * `profileId` is only included when the address was newly associated\n * (`status: 'created'`). When the address was already associated with the\n * authenticated profile (`status: 'active'`), only `address` is returned.\n */\nexport type AssociateAddressResponse = {\n profileId?: string;\n address: Hex;\n status: 'active' | 'created';\n};\n\nexport type AccountUpgradeStatus = 'pending' | 'upgraded';\n\nexport type AuthorizationData = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n};\n\n/**\n * Returned by POST /v1/account-upgrade.\n */\nexport type CreateUpgradeResponse = {\n signerAddress: Hex;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\n/**\n * One entry returned by GET /v1/account-upgrade/:address. The endpoint returns\n * an array of these (one per chain).\n */\nexport type UpgradeEntry = {\n signerAddress: Hex;\n chainId: Hex;\n nonce: Hex;\n authorization: AuthorizationData;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: Hex;\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: Hex;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\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: 'cash-deposit' | 'cash-withdrawal';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: Hex;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: Hex;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: Hex;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<Hex, ServiceDetailsChain>;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -48,14 +48,49 @@ export type CreateWithdrawalParams = {
|
|
|
48
48
|
amount: string;
|
|
49
49
|
account: Hex;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Returned by POST /v1/auth/address.
|
|
53
|
+
*
|
|
54
|
+
* `profileId` is only included when the address was newly associated
|
|
55
|
+
* (`status: 'created'`). When the address was already associated with the
|
|
56
|
+
* authenticated profile (`status: 'active'`), only `address` is returned.
|
|
57
|
+
*/
|
|
51
58
|
export type AssociateAddressResponse = {
|
|
52
|
-
profileId
|
|
59
|
+
profileId?: string;
|
|
53
60
|
address: Hex;
|
|
54
|
-
status:
|
|
61
|
+
status: 'active' | 'created';
|
|
55
62
|
};
|
|
56
|
-
export type
|
|
63
|
+
export type AccountUpgradeStatus = 'pending' | 'upgraded';
|
|
64
|
+
export type AuthorizationData = {
|
|
65
|
+
r: Hex;
|
|
66
|
+
s: Hex;
|
|
67
|
+
v: number;
|
|
68
|
+
yParity: number;
|
|
69
|
+
address: Hex;
|
|
70
|
+
chainId: Hex;
|
|
71
|
+
nonce: Hex;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Returned by POST /v1/account-upgrade.
|
|
75
|
+
*/
|
|
76
|
+
export type CreateUpgradeResponse = {
|
|
77
|
+
signerAddress: Hex;
|
|
78
|
+
address: Hex;
|
|
79
|
+
chainId: Hex;
|
|
80
|
+
nonce: Hex;
|
|
81
|
+
status: AccountUpgradeStatus;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* One entry returned by GET /v1/account-upgrade/:address. The endpoint returns
|
|
86
|
+
* an array of these (one per chain).
|
|
87
|
+
*/
|
|
88
|
+
export type UpgradeEntry = {
|
|
57
89
|
signerAddress: Hex;
|
|
58
|
-
|
|
90
|
+
chainId: Hex;
|
|
91
|
+
nonce: Hex;
|
|
92
|
+
authorization: AuthorizationData;
|
|
93
|
+
status: AccountUpgradeStatus;
|
|
59
94
|
createdAt: string;
|
|
60
95
|
};
|
|
61
96
|
export type VerifyDelegationResponse = {
|
|
@@ -76,9 +111,6 @@ export type SendIntentResponse = {
|
|
|
76
111
|
};
|
|
77
112
|
/**
|
|
78
113
|
* The shape returned by GET /v1/intent/account/:address for each intent.
|
|
79
|
-
*
|
|
80
|
-
* Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the
|
|
81
|
-
* create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.
|
|
82
114
|
*/
|
|
83
115
|
export type IntentEntry = {
|
|
84
116
|
account: Hex;
|
|
@@ -89,7 +121,7 @@ export type IntentEntry = {
|
|
|
89
121
|
allowance: Hex;
|
|
90
122
|
tokenAddress: Hex;
|
|
91
123
|
tokenSymbol: string;
|
|
92
|
-
type: 'deposit' | '
|
|
124
|
+
type: 'cash-deposit' | 'cash-withdrawal';
|
|
93
125
|
};
|
|
94
126
|
};
|
|
95
127
|
export type CreateWithdrawalResponse = {
|
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,CAAC;AAIF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,GAAG,CAAC;IACf,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 export type CreateWithdrawalParams = {
|
|
|
48
48
|
amount: string;
|
|
49
49
|
account: Hex;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Returned by POST /v1/auth/address.
|
|
53
|
+
*
|
|
54
|
+
* `profileId` is only included when the address was newly associated
|
|
55
|
+
* (`status: 'created'`). When the address was already associated with the
|
|
56
|
+
* authenticated profile (`status: 'active'`), only `address` is returned.
|
|
57
|
+
*/
|
|
51
58
|
export type AssociateAddressResponse = {
|
|
52
|
-
profileId
|
|
59
|
+
profileId?: string;
|
|
53
60
|
address: Hex;
|
|
54
|
-
status:
|
|
61
|
+
status: 'active' | 'created';
|
|
55
62
|
};
|
|
56
|
-
export type
|
|
63
|
+
export type AccountUpgradeStatus = 'pending' | 'upgraded';
|
|
64
|
+
export type AuthorizationData = {
|
|
65
|
+
r: Hex;
|
|
66
|
+
s: Hex;
|
|
67
|
+
v: number;
|
|
68
|
+
yParity: number;
|
|
69
|
+
address: Hex;
|
|
70
|
+
chainId: Hex;
|
|
71
|
+
nonce: Hex;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Returned by POST /v1/account-upgrade.
|
|
75
|
+
*/
|
|
76
|
+
export type CreateUpgradeResponse = {
|
|
77
|
+
signerAddress: Hex;
|
|
78
|
+
address: Hex;
|
|
79
|
+
chainId: Hex;
|
|
80
|
+
nonce: Hex;
|
|
81
|
+
status: AccountUpgradeStatus;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* One entry returned by GET /v1/account-upgrade/:address. The endpoint returns
|
|
86
|
+
* an array of these (one per chain).
|
|
87
|
+
*/
|
|
88
|
+
export type UpgradeEntry = {
|
|
57
89
|
signerAddress: Hex;
|
|
58
|
-
|
|
90
|
+
chainId: Hex;
|
|
91
|
+
nonce: Hex;
|
|
92
|
+
authorization: AuthorizationData;
|
|
93
|
+
status: AccountUpgradeStatus;
|
|
59
94
|
createdAt: string;
|
|
60
95
|
};
|
|
61
96
|
export type VerifyDelegationResponse = {
|
|
@@ -76,9 +111,6 @@ export type SendIntentResponse = {
|
|
|
76
111
|
};
|
|
77
112
|
/**
|
|
78
113
|
* The shape returned by GET /v1/intent/account/:address for each intent.
|
|
79
|
-
*
|
|
80
|
-
* Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the
|
|
81
|
-
* create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.
|
|
82
114
|
*/
|
|
83
115
|
export type IntentEntry = {
|
|
84
116
|
account: Hex;
|
|
@@ -89,7 +121,7 @@ export type IntentEntry = {
|
|
|
89
121
|
allowance: Hex;
|
|
90
122
|
tokenAddress: Hex;
|
|
91
123
|
tokenSymbol: string;
|
|
92
|
-
type: 'deposit' | '
|
|
124
|
+
type: 'cash-deposit' | 'cash-withdrawal';
|
|
93
125
|
};
|
|
94
126
|
};
|
|
95
127
|
export type CreateWithdrawalResponse = {
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","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,CAAC;AAIF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AA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ings":"","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// === PARAMS TYPES ===\n\nexport type AssociateAddressParams = {\n signature: Hex;\n timestamp: number;\n address: Hex;\n};\n\nexport type CreateUpgradeParams = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationParams = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentParams = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataParams;\n};\n\nexport type CreateWithdrawalParams = {\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
|
|
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// === PARAMS TYPES ===\n\nexport type AssociateAddressParams = {\n signature: Hex;\n timestamp: number;\n address: Hex;\n};\n\nexport type CreateUpgradeParams = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: string;\n nonce: string;\n};\n\nexport type VerifyDelegationParams = {\n signedDelegation: SignedDelegation;\n chainId: Hex;\n};\n\nexport type IntentMetadataParams = {\n allowance: Hex;\n tokenSymbol: string;\n tokenAddress: Hex;\n type: 'cash-deposit' | 'cash-withdrawal';\n};\n\nexport type SendIntentParams = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n metadata: IntentMetadataParams;\n};\n\nexport type CreateWithdrawalParams = {\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\n/**\n * Returned by POST /v1/auth/address.\n *\n * `profileId` is only included when the address was newly associated\n * (`status: 'created'`). When the address was already associated with the\n * authenticated profile (`status: 'active'`), only `address` is returned.\n */\nexport type AssociateAddressResponse = {\n profileId?: string;\n address: Hex;\n status: 'active' | 'created';\n};\n\nexport type AccountUpgradeStatus = 'pending' | 'upgraded';\n\nexport type AuthorizationData = {\n r: Hex;\n s: Hex;\n v: number;\n yParity: number;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n};\n\n/**\n * Returned by POST /v1/account-upgrade.\n */\nexport type CreateUpgradeResponse = {\n signerAddress: Hex;\n address: Hex;\n chainId: Hex;\n nonce: Hex;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\n/**\n * One entry returned by GET /v1/account-upgrade/:address. The endpoint returns\n * an array of these (one per chain).\n */\nexport type UpgradeEntry = {\n signerAddress: Hex;\n chainId: Hex;\n nonce: Hex;\n authorization: AuthorizationData;\n status: AccountUpgradeStatus;\n createdAt: string;\n};\n\nexport type VerifyDelegationResponse = {\n valid: boolean;\n delegationHash?: Hex;\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: Hex;\n metadata: IntentMetadataResponse;\n createdAt: string;\n};\n\n/**\n * The shape returned by GET /v1/intent/account/:address for each intent.\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: 'cash-deposit' | 'cash-withdrawal';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: Hex;\n tokenDecimals: number;\n};\n\nexport type ServiceDetailsProtocol = {\n supportedTokens: ServiceDetailsSupportedToken[];\n adapterAddress: Hex;\n intentTypes: ('cash-deposit' | 'cash-withdrawal')[];\n};\n\nexport type ServiceDetailsChain = {\n autoDepositDelegate: Hex;\n protocol: Record<string, ServiceDetailsProtocol>;\n};\n\nexport type ServiceDetailsResponse = {\n auth: {\n message: string;\n };\n chains: Record<Hex, ServiceDetailsChain>;\n};\n"]}
|