@metamask-previews/chomp-api-service 2.0.0-preview-d23d9dc44 → 2.0.0-preview-7cef09c77

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 CHANGED
@@ -9,7 +9,6 @@ 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))
13
12
  - Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
14
13
 
15
14
  ## [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.\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"]}
1
+ {"version":3,"file":"chomp-api-service-method-action-types.cjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service';\n\n/**\n * Associates an address with a CHOMP profile via POST /v1/auth/address.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade via POST /v1/account-upgrade.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.\n */\nexport type ChompApiServiceGetUpgradeAction = {\n type: `ChompApiService:getUpgrade`;\n handler: ChompApiService['getUpgrade'];\n};\n\n/**\n * Verifies a delegation via POST /v1/intent/verify-delegation.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\n};\n\n/**\n * Submits intents via POST /v1/intent.\n */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\n};\n\n/**\n * Fetches intents by address via GET /v1/intent/account/:address.\n */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Submits a withdrawal request via POST /v1/withdrawal\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\n};\n\n/**\n * Retrieves service details via GET /v1/chomp.\n */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradeAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
@@ -4,102 +4,56 @@
4
4
  */
5
5
  import type { ChompApiService } from "./chomp-api-service.cjs";
6
6
  /**
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.
7
+ * Associates an address with a CHOMP profile via POST /v1/auth/address.
14
8
  */
15
9
  export type ChompApiServiceAssociateAddressAction = {
16
10
  type: `ChompApiService:associateAddress`;
17
11
  handler: ChompApiService['associateAddress'];
18
12
  };
19
13
  /**
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.
14
+ * Creates an account upgrade via POST /v1/account-upgrade.
27
15
  */
28
16
  export type ChompApiServiceCreateUpgradeAction = {
29
17
  type: `ChompApiService:createUpgrade`;
30
18
  handler: ChompApiService['createUpgrade'];
31
19
  };
32
20
  /**
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.
21
+ * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.
40
22
  */
41
- export type ChompApiServiceGetUpgradesAction = {
42
- type: `ChompApiService:getUpgrades`;
43
- handler: ChompApiService['getUpgrades'];
23
+ export type ChompApiServiceGetUpgradeAction = {
24
+ type: `ChompApiService:getUpgrade`;
25
+ handler: ChompApiService['getUpgrade'];
44
26
  };
45
27
  /**
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.
28
+ * Verifies a delegation via POST /v1/intent/verify-delegation.
52
29
  */
53
30
  export type ChompApiServiceVerifyDelegationAction = {
54
31
  type: `ChompApiService:verifyDelegation`;
55
32
  handler: ChompApiService['verifyDelegation'];
56
33
  };
57
34
  /**
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.
35
+ * Submits intents via POST /v1/intent.
64
36
  */
65
37
  export type ChompApiServiceCreateIntentsAction = {
66
38
  type: `ChompApiService:createIntents`;
67
39
  handler: ChompApiService['createIntents'];
68
40
  };
69
41
  /**
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.
42
+ * Fetches intents by address via GET /v1/intent/account/:address.
76
43
  */
77
44
  export type ChompApiServiceGetIntentsByAddressAction = {
78
45
  type: `ChompApiService:getIntentsByAddress`;
79
46
  handler: ChompApiService['getIntentsByAddress'];
80
47
  };
81
48
  /**
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.
49
+ * Submits a withdrawal request via POST /v1/withdrawal
89
50
  */
90
51
  export type ChompApiServiceCreateWithdrawalAction = {
91
52
  type: `ChompApiService:createWithdrawal`;
92
53
  handler: ChompApiService['createWithdrawal'];
93
54
  };
94
55
  /**
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.
56
+ * Retrieves service details via GET /v1/chomp.
103
57
  */
104
58
  export type ChompApiServiceGetServiceDetailsAction = {
105
59
  type: `ChompApiService:getServiceDetails`;
@@ -108,5 +62,5 @@ export type ChompApiServiceGetServiceDetailsAction = {
108
62
  /**
109
63
  * Union of all ChompApiService action types.
110
64
  */
111
- export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
65
+ export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
112
66
  //# sourceMappingURL=chomp-api-service-method-action-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"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;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
1
+ {"version":3,"file":"chomp-api-service-method-action-types.d.cts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
@@ -4,102 +4,56 @@
4
4
  */
5
5
  import type { ChompApiService } from "./chomp-api-service.mjs";
6
6
  /**
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.
7
+ * Associates an address with a CHOMP profile via POST /v1/auth/address.
14
8
  */
15
9
  export type ChompApiServiceAssociateAddressAction = {
16
10
  type: `ChompApiService:associateAddress`;
17
11
  handler: ChompApiService['associateAddress'];
18
12
  };
19
13
  /**
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.
14
+ * Creates an account upgrade via POST /v1/account-upgrade.
27
15
  */
28
16
  export type ChompApiServiceCreateUpgradeAction = {
29
17
  type: `ChompApiService:createUpgrade`;
30
18
  handler: ChompApiService['createUpgrade'];
31
19
  };
32
20
  /**
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.
21
+ * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.
40
22
  */
41
- export type ChompApiServiceGetUpgradesAction = {
42
- type: `ChompApiService:getUpgrades`;
43
- handler: ChompApiService['getUpgrades'];
23
+ export type ChompApiServiceGetUpgradeAction = {
24
+ type: `ChompApiService:getUpgrade`;
25
+ handler: ChompApiService['getUpgrade'];
44
26
  };
45
27
  /**
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.
28
+ * Verifies a delegation via POST /v1/intent/verify-delegation.
52
29
  */
53
30
  export type ChompApiServiceVerifyDelegationAction = {
54
31
  type: `ChompApiService:verifyDelegation`;
55
32
  handler: ChompApiService['verifyDelegation'];
56
33
  };
57
34
  /**
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.
35
+ * Submits intents via POST /v1/intent.
64
36
  */
65
37
  export type ChompApiServiceCreateIntentsAction = {
66
38
  type: `ChompApiService:createIntents`;
67
39
  handler: ChompApiService['createIntents'];
68
40
  };
69
41
  /**
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.
42
+ * Fetches intents by address via GET /v1/intent/account/:address.
76
43
  */
77
44
  export type ChompApiServiceGetIntentsByAddressAction = {
78
45
  type: `ChompApiService:getIntentsByAddress`;
79
46
  handler: ChompApiService['getIntentsByAddress'];
80
47
  };
81
48
  /**
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.
49
+ * Submits a withdrawal request via POST /v1/withdrawal
89
50
  */
90
51
  export type ChompApiServiceCreateWithdrawalAction = {
91
52
  type: `ChompApiService:createWithdrawal`;
92
53
  handler: ChompApiService['createWithdrawal'];
93
54
  };
94
55
  /**
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.
56
+ * Retrieves service details via GET /v1/chomp.
103
57
  */
104
58
  export type ChompApiServiceGetServiceDetailsAction = {
105
59
  type: `ChompApiService:getServiceDetails`;
@@ -108,5 +62,5 @@ export type ChompApiServiceGetServiceDetailsAction = {
108
62
  /**
109
63
  * Union of all ChompApiService action types.
110
64
  */
111
- export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
65
+ export type ChompApiServiceMethodActions = ChompApiServiceAssociateAddressAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradeAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction;
112
66
  //# sourceMappingURL=chomp-api-service-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chomp-api-service-method-action-types.d.mts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
1
+ {"version":3,"file":"chomp-api-service-method-action-types.d.mts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gCAA4B;AAE3D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,CAAC"}
@@ -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.\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"]}
1
+ {"version":3,"file":"chomp-api-service-method-action-types.mjs","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service';\n\n/**\n * Associates an address with a CHOMP profile via POST /v1/auth/address.\n */\nexport type ChompApiServiceAssociateAddressAction = {\n type: `ChompApiService:associateAddress`;\n handler: ChompApiService['associateAddress'];\n};\n\n/**\n * Creates an account upgrade via POST /v1/account-upgrade.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches the upgrade record for an address via GET /v1/account-upgrade/:address.\n */\nexport type ChompApiServiceGetUpgradeAction = {\n type: `ChompApiService:getUpgrade`;\n handler: ChompApiService['getUpgrade'];\n};\n\n/**\n * Verifies a delegation via POST /v1/intent/verify-delegation.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\n};\n\n/**\n * Submits intents via POST /v1/intent.\n */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\n};\n\n/**\n * Fetches intents by address via GET /v1/intent/account/:address.\n */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Submits a withdrawal request via POST /v1/withdrawal\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\n};\n\n/**\n * Retrieves service details via GET /v1/chomp.\n */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceAssociateAddressAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradeAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction;\n"]}
@@ -31,7 +31,7 @@ exports.serviceName = 'ChompApiService';
31
31
  const MESSENGER_EXPOSED_METHODS = [
32
32
  'associateAddress',
33
33
  'createUpgrade',
34
- 'getUpgrades',
34
+ 'getUpgrade',
35
35
  'verifyDelegation',
36
36
  'createIntents',
37
37
  'getIntentsByAddress',
@@ -40,36 +40,15 @@ const MESSENGER_EXPOSED_METHODS = [
40
40
  ];
41
41
  // === RESPONSE VALIDATION ===
42
42
  const AssociateAddressResponseStruct = (0, superstruct_1.type)({
43
- profileId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
43
+ profileId: (0, superstruct_1.string)(),
44
44
  address: utils_1.StrictHexStruct,
45
- status: (0, superstruct_1.enums)(['active', 'created']),
45
+ status: (0, superstruct_1.string)(),
46
46
  });
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)({
47
+ const UpgradeResponseStruct = (0, superstruct_1.type)({
58
48
  signerAddress: utils_1.StrictHexStruct,
59
- address: utils_1.StrictHexStruct,
60
- chainId: utils_1.StrictHexStruct,
61
- nonce: utils_1.StrictHexStruct,
62
- status: AccountUpgradeStatusStruct,
49
+ status: (0, superstruct_1.string)(),
63
50
  createdAt: (0, superstruct_1.string)(),
64
51
  });
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
- }));
73
52
  const VerifyDelegationResponseStruct = (0, superstruct_1.type)({
74
53
  valid: (0, superstruct_1.boolean)(),
75
54
  delegationHash: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
@@ -94,7 +73,7 @@ const IntentEntryArrayStruct = (0, superstruct_1.array)((0, superstruct_1.type)(
94
73
  allowance: utils_1.StrictHexStruct,
95
74
  tokenAddress: utils_1.StrictHexStruct,
96
75
  tokenSymbol: (0, superstruct_1.string)(),
97
- type: (0, superstruct_1.enums)(['cash-deposit', 'cash-withdrawal']),
76
+ type: (0, superstruct_1.enums)(['deposit', 'withdraw']),
98
77
  }),
99
78
  }));
100
79
  const CreateWithdrawalResponseStruct = (0, superstruct_1.type)({
@@ -201,30 +180,35 @@ class ChompApiService extends base_data_service_1.BaseDataService {
201
180
  return response.json();
202
181
  },
203
182
  });
204
- return (0, superstruct_1.create)(jsonResponse, CreateUpgradeResponseStruct);
183
+ return (0, superstruct_1.create)(jsonResponse, UpgradeResponseStruct);
205
184
  }
206
185
  /**
207
- * Fetches all EIP-7702 upgrade authorizations for a given address (one per
208
- * chain).
186
+ * Fetches the upgrade record for a given address.
209
187
  *
210
188
  * GET /v1/account-upgrade/:address
211
189
  *
212
190
  * @param address - The address to look up.
213
- * @returns The upgrade entries; empty array if none exist.
191
+ * @returns The upgrade record, or null if not found.
214
192
  */
215
- async getUpgrades(address) {
193
+ async getUpgrade(address) {
216
194
  const jsonResponse = await this.fetchQuery({
217
- queryKey: [`${this.name}:getUpgrades`, address],
195
+ queryKey: [`${this.name}:getUpgrade`, address],
218
196
  queryFn: async () => {
219
197
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
220
198
  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
+ }
221
202
  if (!response.ok) {
222
- throw new controller_utils_1.HttpError(response.status, `Get upgrades request failed with status '${response.status}'`);
203
+ throw new controller_utils_1.HttpError(response.status, `Get upgrade request failed with status '${response.status}'`);
223
204
  }
224
205
  return response.json();
225
206
  },
226
207
  });
227
- return (0, superstruct_1.create)(jsonResponse, UpgradeEntryArrayStruct);
208
+ if (jsonResponse === null) {
209
+ return null;
210
+ }
211
+ return (0, superstruct_1.create)(jsonResponse, UpgradeResponseStruct);
228
212
  }
229
213
  /**
230
214
  * 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;AAoBlD,kBAAkB;AAElB;;;GAGG;AACU,QAAA,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,IAAA,kBAAI,EAAC;IAC1C,SAAS,EAAE,IAAA,sBA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M,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"]}
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,C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atedEvent,\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"]}
@@ -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, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from "./types.cjs";
8
+ import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, UpgradeResponse, 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,17 +90,16 @@ 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<CreateUpgradeResponse>;
93
+ createUpgrade(params: CreateUpgradeParams): Promise<UpgradeResponse>;
94
94
  /**
95
- * Fetches all EIP-7702 upgrade authorizations for a given address (one per
96
- * chain).
95
+ * Fetches the upgrade record for a given address.
97
96
  *
98
97
  * GET /v1/account-upgrade/:address
99
98
  *
100
99
  * @param address - The address to look up.
101
- * @returns The upgrade entries; empty array if none exist.
100
+ * @returns The upgrade record, or null if not found.
102
101
  */
103
- getUpgrades(address: Hex): Promise<UpgradeEntry[]>;
102
+ getUpgrade(address: Hex): Promise<UpgradeResponse | null>;
104
103
  /**
105
104
  * Verifies a delegation signature.
106
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"chomp-api-service.d.cts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,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@@ -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, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from "./types.mjs";
8
+ import type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, UpgradeResponse, 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,17 +90,16 @@ 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<CreateUpgradeResponse>;
93
+ createUpgrade(params: CreateUpgradeParams): Promise<UpgradeResponse>;
94
94
  /**
95
- * Fetches all EIP-7702 upgrade authorizations for a given address (one per
96
- * chain).
95
+ * Fetches the upgrade record for a given address.
97
96
  *
98
97
  * GET /v1/account-upgrade/:address
99
98
  *
100
99
  * @param address - The address to look up.
101
- * @returns The upgrade entries; empty array if none exist.
100
+ * @returns The upgrade record, or null if not found.
102
101
  */
103
- getUpgrades(address: Hex): Promise<UpgradeEntry[]>;
102
+ getUpgrade(address: Hex): Promise<UpgradeResponse | null>;
104
103
  /**
105
104
  * Verifies a delegation signature.
106
105
  *
@@ -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;AAC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AE,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
- 'getUpgrades',
31
+ 'getUpgrade',
32
32
  'verifyDelegation',
33
33
  'createIntents',
34
34
  'getIntentsByAddress',
@@ -37,36 +37,15 @@ const MESSENGER_EXPOSED_METHODS = [
37
37
  ];
38
38
  // === RESPONSE VALIDATION ===
39
39
  const AssociateAddressResponseStruct = type({
40
- profileId: optional(string()),
40
+ profileId: string(),
41
41
  address: StrictHexStruct,
42
- status: enums(['active', 'created']),
42
+ status: string(),
43
43
  });
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({
44
+ const UpgradeResponseStruct = type({
55
45
  signerAddress: StrictHexStruct,
56
- address: StrictHexStruct,
57
- chainId: StrictHexStruct,
58
- nonce: StrictHexStruct,
59
- status: AccountUpgradeStatusStruct,
46
+ status: string(),
60
47
  createdAt: string(),
61
48
  });
62
- const UpgradeEntryArrayStruct = array(type({
63
- signerAddress: StrictHexStruct,
64
- chainId: StrictHexStruct,
65
- nonce: StrictHexStruct,
66
- authorization: AuthorizationDataStruct,
67
- status: AccountUpgradeStatusStruct,
68
- createdAt: string(),
69
- }));
70
49
  const VerifyDelegationResponseStruct = type({
71
50
  valid: boolean(),
72
51
  delegationHash: optional(StrictHexStruct),
@@ -91,7 +70,7 @@ const IntentEntryArrayStruct = array(type({
91
70
  allowance: StrictHexStruct,
92
71
  tokenAddress: StrictHexStruct,
93
72
  tokenSymbol: string(),
94
- type: enums(['cash-deposit', 'cash-withdrawal']),
73
+ type: enums(['deposit', 'withdraw']),
95
74
  }),
96
75
  }));
97
76
  const CreateWithdrawalResponseStruct = type({
@@ -198,30 +177,35 @@ export class ChompApiService extends BaseDataService {
198
177
  return response.json();
199
178
  },
200
179
  });
201
- return create(jsonResponse, CreateUpgradeResponseStruct);
180
+ return create(jsonResponse, UpgradeResponseStruct);
202
181
  }
203
182
  /**
204
- * Fetches all EIP-7702 upgrade authorizations for a given address (one per
205
- * chain).
183
+ * Fetches the upgrade record for a given address.
206
184
  *
207
185
  * GET /v1/account-upgrade/:address
208
186
  *
209
187
  * @param address - The address to look up.
210
- * @returns The upgrade entries; empty array if none exist.
188
+ * @returns The upgrade record, or null if not found.
211
189
  */
212
- async getUpgrades(address) {
190
+ async getUpgrade(address) {
213
191
  const jsonResponse = await this.fetchQuery({
214
- queryKey: [`${this.name}:getUpgrades`, address],
192
+ queryKey: [`${this.name}:getUpgrade`, address],
215
193
  queryFn: async () => {
216
194
  const headers = await __classPrivateFieldGet(this, _ChompApiService_instances, "m", _ChompApiService_authHeaders).call(this);
217
195
  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
+ }
218
199
  if (!response.ok) {
219
- throw new HttpError(response.status, `Get upgrades request failed with status '${response.status}'`);
200
+ throw new HttpError(response.status, `Get upgrade request failed with status '${response.status}'`);
220
201
  }
221
202
  return response.json();
222
203
  },
223
204
  });
224
- return create(jsonResponse, UpgradeEntryArrayStruct);
205
+ if (jsonResponse === null) {
206
+ return null;
207
+ }
208
+ return create(jsonResponse, UpgradeResponseStruct);
225
209
  }
226
210
  /**
227
211
  * 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,m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,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"]}
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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AAK,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,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;;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 +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 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"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAA7C,oHAAA,eAAe,OAAA","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\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, 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";
3
+ export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.cjs";
4
+ export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from "./types.cjs";
5
5
  //# sourceMappingURL=index.d.cts.map
@@ -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,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"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,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, 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";
3
+ export type { ChompApiServiceAssociateAddressAction, ChompApiServiceCreateUpgradeAction, ChompApiServiceGetUpgradeAction, ChompApiServiceVerifyDelegationAction, ChompApiServiceCreateIntentsAction, ChompApiServiceGetIntentsByAddressAction, ChompApiServiceCreateWithdrawalAction, ChompApiServiceGetServiceDetailsAction, } from "./chomp-api-service-method-action-types.mjs";
4
+ export type { AssociateAddressParams, AssociateAddressResponse, CreateUpgradeParams, CreateWithdrawalParams, CreateWithdrawalResponse, DelegationCaveat, UpgradeResponse, IntentEntry, IntentMetadataParams, IntentMetadataResponse, SendIntentParams, SendIntentResponse, ServiceDetailsChain, ServiceDetailsProtocol, ServiceDetailsResponse, ServiceDetailsSupportedToken, SignedDelegation, VerifyDelegationParams, VerifyDelegationResponse, } from "./types.mjs";
5
5
  //# sourceMappingURL=index.d.mts.map
@@ -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,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"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B;AACtD,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,gCAA4B;AAC7B,YAAY,EACV,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,qCAAqC,EACrC,sCAAsC,GACvC,oDAAgD;AACjD,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,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"}
@@ -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 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"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAA4B","sourcesContent":["export { ChompApiService } from './chomp-api-service';\nexport type {\n ChompApiServiceMessenger,\n ChompApiServiceActions,\n ChompApiServiceEvents,\n ChompApiServiceInvalidateQueriesAction,\n ChompApiServiceCacheUpdatedEvent,\n ChompApiServiceGranularCacheUpdatedEvent,\n} from './chomp-api-service';\nexport type {\n ChompApiServiceAssociateAddressAction,\n ChompApiServiceCreateUpgradeAction,\n ChompApiServiceGetUpgradeAction,\n ChompApiServiceVerifyDelegationAction,\n ChompApiServiceCreateIntentsAction,\n ChompApiServiceGetIntentsByAddressAction,\n ChompApiServiceCreateWithdrawalAction,\n ChompApiServiceGetServiceDetailsAction,\n} from './chomp-api-service-method-action-types';\nexport type {\n AssociateAddressParams,\n AssociateAddressResponse,\n CreateUpgradeParams,\n CreateWithdrawalParams,\n CreateWithdrawalResponse,\n DelegationCaveat,\n UpgradeResponse,\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"]}
@@ -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\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"]}
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: string;\n address: Hex;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: Hex;\n status: string;\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 *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: 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,49 +48,14 @@ 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
- */
58
51
  export type AssociateAddressResponse = {
59
- profileId?: string;
52
+ profileId: string;
60
53
  address: Hex;
61
- status: 'active' | 'created';
54
+ status: string;
62
55
  };
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 = {
56
+ export type UpgradeResponse = {
89
57
  signerAddress: Hex;
90
- chainId: Hex;
91
- nonce: Hex;
92
- authorization: AuthorizationData;
93
- status: AccountUpgradeStatus;
58
+ status: string;
94
59
  createdAt: string;
95
60
  };
96
61
  export type VerifyDelegationResponse = {
@@ -111,6 +76,9 @@ export type SendIntentResponse = {
111
76
  };
112
77
  /**
113
78
  * 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'.
114
82
  */
115
83
  export type IntentEntry = {
116
84
  account: Hex;
@@ -121,7 +89,7 @@ export type IntentEntry = {
121
89
  allowance: Hex;
122
90
  tokenAddress: Hex;
123
91
  tokenSymbol: string;
124
- type: 'cash-deposit' | 'cash-withdrawal';
92
+ type: 'deposit' | 'withdraw';
125
93
  };
126
94
  };
127
95
  export type CreateWithdrawalResponse = {
@@ -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,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,EAAE,GAAG,CAAC;IACP,CAAC,EAAE,GAAG,CAAC;IACP,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,K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AAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;CAC1C,CAAC"}
package/dist/types.d.mts CHANGED
@@ -48,49 +48,14 @@ 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
- */
58
51
  export type AssociateAddressResponse = {
59
- profileId?: string;
52
+ profileId: string;
60
53
  address: Hex;
61
- status: 'active' | 'created';
54
+ status: string;
62
55
  };
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 = {
56
+ export type UpgradeResponse = {
89
57
  signerAddress: Hex;
90
- chainId: Hex;
91
- nonce: Hex;
92
- authorization: AuthorizationData;
93
- status: AccountUpgradeStatus;
58
+ status: string;
94
59
  createdAt: string;
95
60
  };
96
61
  export type VerifyDelegationResponse = {
@@ -111,6 +76,9 @@ export type SendIntentResponse = {
111
76
  };
112
77
  /**
113
78
  * 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'.
114
82
  */
115
83
  export type IntentEntry = {
116
84
  account: Hex;
@@ -121,7 +89,7 @@ export type IntentEntry = {
121
89
  allowance: Hex;
122
90
  tokenAddress: Hex;
123
91
  tokenSymbol: string;
124
- type: 'cash-deposit' | 'cash-withdrawal';
92
+ type: 'deposit' | 'withdraw';
125
93
  };
126
94
  };
127
95
  export type CreateWithdrawalResponse = {
@@ -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;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,EAAE,GAAG,CAAC;IACP,CAAC,EAAE,GAAG,CAAC;IACP,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,S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.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"]}
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\nexport type AssociateAddressResponse = {\n profileId: string;\n address: Hex;\n status: string;\n};\n\nexport type UpgradeResponse = {\n signerAddress: Hex;\n status: string;\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 *\n * Note: the metadata `type` uses 'deposit' | 'withdraw' here, whereas the\n * create-intent endpoint uses 'cash-deposit' | 'cash-withdrawal'.\n */\nexport type IntentEntry = {\n account: Hex;\n delegationHash: Hex;\n chainId: Hex;\n status: 'active' | 'revoked';\n metadata: {\n allowance: Hex;\n tokenAddress: Hex;\n tokenSymbol: string;\n type: 'deposit' | 'withdraw';\n };\n};\n\nexport type CreateWithdrawalResponse = {\n success: true;\n};\n\n// === SERVICE DETAILS TYPES ===\n\nexport type ServiceDetailsSupportedToken = {\n tokenAddress: 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/chomp-api-service",
3
- "version": "2.0.0-preview-d23d9dc44",
3
+ "version": "2.0.0-preview-7cef09c77",
4
4
  "description": "Data service for the Chomp API",
5
5
  "keywords": [
6
6
  "Ethereum",