clutch-hub-sdk-js 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/CLAUDE.md +3 -4
- package/README.md +0 -5
- package/dist/sdk.d.ts +1 -6
- package/dist/sdk.js +0 -21
- package/dist/types.d.ts +0 -7
- package/package.json +1 -1
- package/src/sdk.ts +0 -26
- package/src/types.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [4.0.0](https://github.com/clutchprotocol/clutch-hub-sdk-js/compare/v3.0.0...v4.0.0) (2026-09-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ⚠ BREAKING CHANGES
|
|
5
|
+
|
|
6
|
+
* `requestFaucet` is removed from `ClutchHubSdk` and the
|
|
7
|
+
`FaucetResponse` type is no longer exported. There is no replacement — the
|
|
8
|
+
server endpoint is gone; CLT is obtained by depositing USDT.
|
|
9
|
+
|
|
10
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* remove requestFaucet ([a8186f5](https://github.com/clutchprotocol/clutch-hub-sdk-js/commit/a8186f555588f781a8c7a1e905e724b343ae2948))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Reverts
|
|
18
|
+
|
|
19
|
+
* the 4.0.0 release commit that npm rejected ([ba16f76](https://github.com/clutchprotocol/clutch-hub-sdk-js/commit/ba16f76e6e49b9153dcd0c5e954e926c9f0f0dee))
|
|
20
|
+
* the 4.0.0 release commit, which npm rejected ([fd456d9](https://github.com/clutchprotocol/clutch-hub-sdk-js/commit/fd456d98c2f70a3f8d86da82eaaa84289919a0d6))
|
|
21
|
+
* the orphaned 4.0.0 release commit ([9d49388](https://github.com/clutchprotocol/clutch-hub-sdk-js/commit/9d49388b45c67ef030dd2d78775b815228c9253e))
|
|
22
|
+
|
|
1
23
|
## [3.0.0](https://github.com/clutchprotocol/clutch-hub-sdk-js/compare/v2.0.1...v3.0.0) (2026-07-30)
|
|
2
24
|
|
|
3
25
|
|
package/CLAUDE.md
CHANGED
|
@@ -10,13 +10,13 @@ Only four source files — the SDK is deliberately small:
|
|
|
10
10
|
|
|
11
11
|
- `src/sdk.ts` — everything important: `ClutchHubSdk` class, JWT auth caching, signing/hashing,
|
|
12
12
|
RLP encoding (`encodeFunctionCall`), all GraphQL queries/mutations/subscriptions inline as
|
|
13
|
-
template strings
|
|
13
|
+
template strings. Also exports `stripHexPrefix`, `normalizeTxHashForRlp`,
|
|
14
14
|
`UnsignedTransaction`.
|
|
15
15
|
- `src/subscriptions.ts` — `hubGraphqlWsUrl()` (HTTP base URL → `ws(s)://…/graphql/ws`),
|
|
16
16
|
`createHubSubscriptionClient()` (graphql-ws client: `lazy: false`, infinite retry, 10s keepAlive),
|
|
17
17
|
shared GraphQL field-selection constants (`RIDE_REQUEST_GQL_FIELDS` etc.), `SubscriptionHandlers<T>`.
|
|
18
18
|
- `src/types.ts` — arg/result interfaces (`RideRequestArgs`, `AvailableActiveTrip`, `MapBounds`,
|
|
19
|
-
`Signature`,
|
|
19
|
+
`Signature`, …).
|
|
20
20
|
- `src/index.ts` — barrel re-exports. New public symbols must be reachable from here.
|
|
21
21
|
|
|
22
22
|
There is no test suite. `test_rlp_fix.{js,mjs}` are ad-hoc manual scripts run against `dist/` after
|
|
@@ -68,8 +68,7 @@ legacy JSON-string quoting); empty referrer encodes as `''`.
|
|
|
68
68
|
`subscribeAccountBalance`. All multiplex over **one shared graphql-ws socket per
|
|
69
69
|
(hub URL, publicKey)**, refcounted in a module-global map; the last dispose closes the socket.
|
|
70
70
|
Always call the returned dispose function or sockets/refcounts leak.
|
|
71
|
-
- **Misc**: `
|
|
72
|
-
`{ ok: false, error }` instead of throwing; `getGraphqlWsUrl()`.
|
|
71
|
+
- **Misc**: `getGraphqlWsUrl()`.
|
|
73
72
|
|
|
74
73
|
## Adding a New Transaction Type
|
|
75
74
|
|
package/README.md
CHANGED
|
@@ -27,9 +27,6 @@ import { ClutchHubSdk } from 'clutch-hub-sdk-js';
|
|
|
27
27
|
// proof-of-key-ownership challenge (the key stays local, it is never sent).
|
|
28
28
|
const sdk = new ClutchHubSdk('http://localhost:3000', publicKey, privateKey);
|
|
29
29
|
|
|
30
|
-
// Fund test wallet
|
|
31
|
-
await sdk.requestFaucet(publicKey);
|
|
32
|
-
|
|
33
30
|
// Create, sign, and submit a ride request
|
|
34
31
|
const unsigned = await sdk.createUnsignedRideRequest({
|
|
35
32
|
pickup: { latitude: 35.7, longitude: 51.4 },
|
|
@@ -45,7 +42,6 @@ await sdk.submitTransaction(signed.rawTransaction);
|
|
|
45
42
|
- Client-side signing (private keys never sent to server)
|
|
46
43
|
- Full ride lifecycle: request, offer, accept, pay, cancel
|
|
47
44
|
- GraphQL queries and WebSocket subscriptions
|
|
48
|
-
- Testnet faucet helper
|
|
49
45
|
- TypeScript types
|
|
50
46
|
|
|
51
47
|
## API methods
|
|
@@ -56,7 +52,6 @@ await sdk.submitTransaction(signed.rawTransaction);
|
|
|
56
52
|
| Write | `createUnsignedRide*`, `signTransaction`, `submitTransaction` |
|
|
57
53
|
| Read | `listRideRequests`, `listRideOffers`, `listActiveTrips`, `getAccountBalance`, … |
|
|
58
54
|
| Live | `subscribeRideRequests`, `subscribeRideOffers`, `subscribeActiveTrips`, … |
|
|
59
|
-
| Faucet | `requestFaucet(recipientAddress)` |
|
|
60
55
|
|
|
61
56
|
Full reference: https://docs.clutchprotocol.io/clutch-hub-sdk-js/api-reference
|
|
62
57
|
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { type SubscriptionHandlers } from './subscriptions.js';
|
|
3
|
-
import { AvailableRideRequest, AvailableRideOffer, AvailableActiveTrip, AvailableCompletedTrip, AvailableRecentTrip, BurnArgs,
|
|
3
|
+
import { AvailableRideRequest, AvailableRideOffer, AvailableActiveTrip, AvailableCompletedTrip, AvailableRecentTrip, BurnArgs, MapBounds, RideRequestArgs, RideOfferArgs, RideAcceptanceArgs, RidePayArgs, RideCancelArgs, RideRequestCancelArgs, Signature } from './types.js';
|
|
4
4
|
/** Strip 0x/0X prefix - hex parsers (e.g. @noble/secp256k1) do not accept it. Exported for consumers. */
|
|
5
5
|
export declare function stripHexPrefix(hex: string): string;
|
|
6
6
|
/**
|
|
@@ -275,11 +275,6 @@ export declare class ClutchHubSdk {
|
|
|
275
275
|
subscribeAccountBalance(options: {
|
|
276
276
|
publicKey?: string;
|
|
277
277
|
} | undefined, handlers: SubscriptionHandlers<bigint>): () => void;
|
|
278
|
-
/**
|
|
279
|
-
* Request test CLT from the Hub API faucet (POST /faucet). Requires `faucet_enabled` and a funded
|
|
280
|
-
* `faucet_private_key` on the server. No GraphQL auth token required for this HTTP endpoint.
|
|
281
|
-
*/
|
|
282
|
-
requestFaucet(recipientAddress: string): Promise<FaucetResponse>;
|
|
283
278
|
/**
|
|
284
279
|
* Builds the nested array representing the function call for RLP encoding.
|
|
285
280
|
*/
|
package/dist/sdk.js
CHANGED
|
@@ -868,27 +868,6 @@ export class ClutchHubSdk {
|
|
|
868
868
|
release();
|
|
869
869
|
};
|
|
870
870
|
}
|
|
871
|
-
/**
|
|
872
|
-
* Request test CLT from the Hub API faucet (POST /faucet). Requires `faucet_enabled` and a funded
|
|
873
|
-
* `faucet_private_key` on the server. No GraphQL auth token required for this HTTP endpoint.
|
|
874
|
-
*/
|
|
875
|
-
async requestFaucet(recipientAddress) {
|
|
876
|
-
try {
|
|
877
|
-
const res = await this.apiClient.post('/faucet', { address: recipientAddress });
|
|
878
|
-
return {
|
|
879
|
-
ok: true,
|
|
880
|
-
amount_clt: res.data.amount_clt,
|
|
881
|
-
node: res.data.node,
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
catch (err) {
|
|
885
|
-
const ax = err;
|
|
886
|
-
const msg = typeof ax.response?.data?.error === 'string'
|
|
887
|
-
? ax.response.data.error
|
|
888
|
-
: ax.message ?? 'Faucet request failed';
|
|
889
|
-
return { ok: false, error: String(msg) };
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
871
|
/**
|
|
893
872
|
* Builds the nested array representing the function call for RLP encoding.
|
|
894
873
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -47,13 +47,6 @@ export interface ChainInfo {
|
|
|
47
47
|
totalSupply: bigint;
|
|
48
48
|
mintAuthority: string;
|
|
49
49
|
}
|
|
50
|
-
/** Response from POST /faucet when the Hub API faucet is enabled (test networks). */
|
|
51
|
-
export interface FaucetResponse {
|
|
52
|
-
ok: boolean;
|
|
53
|
-
amount_clt?: number;
|
|
54
|
-
node?: unknown;
|
|
55
|
-
error?: string;
|
|
56
|
-
}
|
|
57
50
|
/** Map viewport bounds for filtering ride requests by pickup location. */
|
|
58
51
|
export interface MapBounds {
|
|
59
52
|
minLat: number;
|
package/package.json
CHANGED
package/src/sdk.ts
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
AvailableCompletedTrip,
|
|
21
21
|
AvailableRecentTrip,
|
|
22
22
|
BurnArgs,
|
|
23
|
-
FaucetResponse,
|
|
24
23
|
MapBounds,
|
|
25
24
|
RideRequestArgs,
|
|
26
25
|
RideOfferArgs,
|
|
@@ -1155,31 +1154,6 @@ export class ClutchHubSdk {
|
|
|
1155
1154
|
};
|
|
1156
1155
|
}
|
|
1157
1156
|
|
|
1158
|
-
/**
|
|
1159
|
-
* Request test CLT from the Hub API faucet (POST /faucet). Requires `faucet_enabled` and a funded
|
|
1160
|
-
* `faucet_private_key` on the server. No GraphQL auth token required for this HTTP endpoint.
|
|
1161
|
-
*/
|
|
1162
|
-
public async requestFaucet(recipientAddress: string): Promise<FaucetResponse> {
|
|
1163
|
-
try {
|
|
1164
|
-
const res = await this.apiClient.post<{ ok: boolean; amount_clt: number; node: unknown }>(
|
|
1165
|
-
'/faucet',
|
|
1166
|
-
{ address: recipientAddress }
|
|
1167
|
-
);
|
|
1168
|
-
return {
|
|
1169
|
-
ok: true,
|
|
1170
|
-
amount_clt: res.data.amount_clt,
|
|
1171
|
-
node: res.data.node,
|
|
1172
|
-
};
|
|
1173
|
-
} catch (err: unknown) {
|
|
1174
|
-
const ax = err as { response?: { data?: { error?: string } }; message?: string };
|
|
1175
|
-
const msg =
|
|
1176
|
-
typeof ax.response?.data?.error === 'string'
|
|
1177
|
-
? ax.response.data.error
|
|
1178
|
-
: ax.message ?? 'Faucet request failed';
|
|
1179
|
-
return { ok: false, error: String(msg) };
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
1157
|
/**
|
|
1184
1158
|
* Builds the nested array representing the function call for RLP encoding.
|
|
1185
1159
|
*/
|
package/src/types.ts
CHANGED
|
@@ -57,14 +57,6 @@ export interface ChainInfo {
|
|
|
57
57
|
mintAuthority: string;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/** Response from POST /faucet when the Hub API faucet is enabled (test networks). */
|
|
61
|
-
export interface FaucetResponse {
|
|
62
|
-
ok: boolean;
|
|
63
|
-
amount_clt?: number;
|
|
64
|
-
node?: unknown;
|
|
65
|
-
error?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
60
|
/** Map viewport bounds for filtering ride requests by pickup location. */
|
|
69
61
|
export interface MapBounds {
|
|
70
62
|
minLat: number;
|