shogun-relay-sdk 1.1.5 → 1.1.6

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/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosRequestConfig } from 'axios';
1
+ import { AxiosRequestConfig } from "axios";
2
2
  export interface ApiClientConfig {
3
3
  baseURL: string;
4
4
  token?: string;
package/dist/client.js CHANGED
@@ -12,13 +12,13 @@ class ApiClient {
12
12
  baseURL: config.baseURL,
13
13
  timeout: config.timeout || 30000,
14
14
  headers: {
15
- 'Content-Type': 'application/json',
15
+ "Content-Type": "application/json",
16
16
  },
17
17
  });
18
18
  // Add auth interceptor
19
19
  this.client.interceptors.request.use((req) => {
20
20
  if (this.config.token) {
21
- req.headers['Authorization'] = `Bearer ${this.config.token}`;
21
+ req.headers["Authorization"] = `Bearer ${this.config.token}`;
22
22
  }
23
23
  return req;
24
24
  });
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { ApiClientConfig } from './client';
2
- import { SystemModule } from './modules/system';
3
- import { IpfsModule } from './modules/ipfs';
4
- import { X402Module } from './modules/x402';
5
- import { NetworkModule } from './modules/network';
6
- import { DealsModule } from './modules/deals';
7
- import { RegistryModule } from './modules/registry';
8
- import { UploadsModule } from './modules/uploads';
9
- import { BridgeModule } from './modules/bridge';
10
- export * from './types';
1
+ import { ApiClientConfig } from "./client";
2
+ import { SystemModule } from "./modules/system";
3
+ import { IpfsModule } from "./modules/ipfs";
4
+ import { X402Module } from "./modules/x402";
5
+ import { NetworkModule } from "./modules/network";
6
+ import { DealsModule } from "./modules/deals";
7
+ import { RegistryModule } from "./modules/registry";
8
+ import { UploadsModule } from "./modules/uploads";
9
+ import { BridgeModule } from "./modules/bridge";
10
+ export * from "./types";
11
11
  export declare class ShogunRelaySDK {
12
12
  private client;
13
13
  system: SystemModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export interface PendingWithdrawal {
3
3
  user: string;
4
4
  amount: string;
@@ -47,6 +47,56 @@ export interface BatchResult {
47
47
  txHash: string;
48
48
  blockNumber: number;
49
49
  }
50
+ /**
51
+ * Balance info with verification data for client-side proof checking
52
+ */
53
+ export interface BalanceInfo {
54
+ user: string;
55
+ balance: string;
56
+ balanceEth: string;
57
+ verification: {
58
+ lastBatchId: string;
59
+ lastBatchRoot: string;
60
+ lastBatchTxHash: string | null;
61
+ lastBatchTimestamp: number;
62
+ lastWithdrawal: {
63
+ amount: string;
64
+ nonce: string;
65
+ timestamp: number;
66
+ };
67
+ merkleProof: string[];
68
+ verifiedOnChain: boolean;
69
+ } | null;
70
+ stats: {
71
+ processedDepositsCount: number;
72
+ hasVerificationData: boolean;
73
+ };
74
+ }
75
+ /**
76
+ * User batch history entry
77
+ */
78
+ export interface BatchHistoryEntry {
79
+ batchId: string;
80
+ root: string;
81
+ txHash: string | null;
82
+ timestamp: number;
83
+ finalized: boolean;
84
+ withdrawals: Array<{
85
+ amount: string;
86
+ nonce: string;
87
+ timestamp: number;
88
+ }>;
89
+ }
90
+ /**
91
+ * Processed deposit information
92
+ */
93
+ export interface ProcessedDeposit {
94
+ txHash: string;
95
+ amount: string;
96
+ amountEth: string;
97
+ blockNumber: number;
98
+ timestamp: number;
99
+ }
50
100
  export declare class BridgeModule {
51
101
  private client;
52
102
  constructor(client: ApiClient);
@@ -61,6 +111,52 @@ export declare class BridgeModule {
61
111
  balance: string;
62
112
  balanceEth: string;
63
113
  }>;
114
+ /**
115
+ * Get user's L2 balance with verification data for client-side proof checking.
116
+ * Returns the balance along with the last batch where user operations were included,
117
+ * enabling independent verification against on-chain Merkle roots.
118
+ * @param userAddress User's Ethereum address
119
+ * @returns Balance info with verification data
120
+ */
121
+ getBalanceInfo(userAddress: string): Promise<{
122
+ success: boolean;
123
+ } & BalanceInfo>;
124
+ /**
125
+ * Get batch history for a user - all batches where user has deposits or withdrawals.
126
+ * This enables users to track their complete on-chain activity.
127
+ * @param userAddress User's Ethereum address
128
+ * @returns Batch history with deposits
129
+ */
130
+ getBatchHistory(userAddress: string): Promise<{
131
+ success: boolean;
132
+ user: string;
133
+ batches: BatchHistoryEntry[];
134
+ deposits: ProcessedDeposit[];
135
+ summary: {
136
+ totalBatches: number;
137
+ totalDeposits: number;
138
+ totalWithdrawals: number;
139
+ };
140
+ }>;
141
+ /**
142
+ * Verify a Merkle proof client-side.
143
+ * This allows users to independently verify their balance without trusting the relay.
144
+ * @param proof Merkle proof array
145
+ * @param root Merkle root from batch
146
+ * @param user User address
147
+ * @param amount Withdrawal amount
148
+ * @param nonce Withdrawal nonce
149
+ * @returns True if proof is valid
150
+ */
151
+ verifyProof(proof: string[], root: string, user: string, amount: string, nonce: string): boolean;
152
+ /**
153
+ * Compute leaf hash for Merkle tree
154
+ */
155
+ private computeLeaf;
156
+ /**
157
+ * Compute keccak256 of two packed bytes32 values
158
+ */
159
+ private keccak256Packed;
64
160
  /**
65
161
  * Get the next nonce for a user (for withdrawal requests)
66
162
  * This allows clients to include the nonce in their signed message
@@ -165,7 +261,7 @@ export declare class BridgeModule {
165
261
  */
166
262
  syncDeposits(params?: {
167
263
  fromBlock?: number;
168
- toBlock?: number | 'latest';
264
+ toBlock?: number | "latest";
169
265
  user?: string;
170
266
  }): Promise<{
171
267
  success: boolean;
@@ -224,7 +320,7 @@ export declare class BridgeModule {
224
320
  success: boolean;
225
321
  user: string;
226
322
  transactions: Array<{
227
- type: 'deposit' | 'withdrawal' | 'transfer';
323
+ type: "deposit" | "withdrawal" | "transfer";
228
324
  txHash: string;
229
325
  from?: string;
230
326
  to?: string;
@@ -234,7 +330,7 @@ export declare class BridgeModule {
234
330
  blockNumber?: number;
235
331
  nonce?: string;
236
332
  batchId?: string;
237
- status: 'pending' | 'completed' | 'batched';
333
+ status: "pending" | "completed" | "batched";
238
334
  }>;
239
335
  count: number;
240
336
  summary: {
@@ -252,7 +348,7 @@ export declare class BridgeModule {
252
348
  getTransaction(txHash: string): Promise<{
253
349
  success: boolean;
254
350
  transaction?: {
255
- type: 'deposit' | 'withdrawal' | 'transfer';
351
+ type: "deposit" | "withdrawal" | "transfer";
256
352
  txHash: string;
257
353
  from?: string;
258
354
  to?: string;
@@ -261,9 +357,9 @@ export declare class BridgeModule {
261
357
  timestamp: number;
262
358
  blockNumber?: number;
263
359
  nonce?: string;
264
- status: 'pending' | 'completed' | 'batched';
360
+ status: "pending" | "completed" | "batched";
265
361
  };
266
- source?: 'deposit' | 'withdrawal' | 'transfer';
362
+ source?: "deposit" | "withdrawal" | "transfer";
267
363
  error?: string;
268
364
  }>;
269
365
  }
@@ -13,6 +13,73 @@ class BridgeModule {
13
13
  async getBalance(userAddress) {
14
14
  return this.client.get(`/api/v1/bridge/balance/${userAddress}`);
15
15
  }
16
+ /**
17
+ * Get user's L2 balance with verification data for client-side proof checking.
18
+ * Returns the balance along with the last batch where user operations were included,
19
+ * enabling independent verification against on-chain Merkle roots.
20
+ * @param userAddress User's Ethereum address
21
+ * @returns Balance info with verification data
22
+ */
23
+ async getBalanceInfo(userAddress) {
24
+ return this.client.get(`/api/v1/bridge/balance-info/${userAddress}`);
25
+ }
26
+ /**
27
+ * Get batch history for a user - all batches where user has deposits or withdrawals.
28
+ * This enables users to track their complete on-chain activity.
29
+ * @param userAddress User's Ethereum address
30
+ * @returns Batch history with deposits
31
+ */
32
+ async getBatchHistory(userAddress) {
33
+ return this.client.get(`/api/v1/bridge/batch-history/${userAddress}`);
34
+ }
35
+ /**
36
+ * Verify a Merkle proof client-side.
37
+ * This allows users to independently verify their balance without trusting the relay.
38
+ * @param proof Merkle proof array
39
+ * @param root Merkle root from batch
40
+ * @param user User address
41
+ * @param amount Withdrawal amount
42
+ * @param nonce Withdrawal nonce
43
+ * @returns True if proof is valid
44
+ */
45
+ verifyProof(proof, root, user, amount, nonce) {
46
+ // Compute leaf hash: keccak256(abi.encodePacked(user, amount, nonce))
47
+ const leaf = this.computeLeaf(user, BigInt(amount), BigInt(nonce));
48
+ // Verify proof
49
+ let computedHash = leaf;
50
+ for (const proofElement of proof) {
51
+ // Sort hashes (matches Solidity logic)
52
+ if (computedHash <= proofElement) {
53
+ computedHash = this.keccak256Packed(computedHash, proofElement);
54
+ }
55
+ else {
56
+ computedHash = this.keccak256Packed(proofElement, computedHash);
57
+ }
58
+ }
59
+ return computedHash === root;
60
+ }
61
+ /**
62
+ * Compute leaf hash for Merkle tree
63
+ */
64
+ computeLeaf(user, amount, nonce) {
65
+ // Simple browser-compatible keccak256
66
+ // Note: In production, use ethers.keccak256 or similar
67
+ const userNormalized = user.toLowerCase().replace("0x", "");
68
+ const amountHex = amount.toString(16).padStart(64, "0");
69
+ const nonceHex = nonce.toString(16).padStart(64, "0");
70
+ const packed = "0x" + userNormalized.padStart(40, "0") + amountHex + nonceHex;
71
+ // For browser use, we need to import keccak256 dynamically
72
+ // This is a placeholder - client should use ethers.keccak256
73
+ return packed; // Client should compute actual hash
74
+ }
75
+ /**
76
+ * Compute keccak256 of two packed bytes32 values
77
+ */
78
+ keccak256Packed(a, b) {
79
+ // Placeholder - client should use ethers.keccak256
80
+ const packed = a + b.replace("0x", "");
81
+ return packed; // Client should compute actual hash
82
+ }
16
83
  /**
17
84
  * Get the next nonce for a user (for withdrawal requests)
18
85
  * This allows clients to include the nonce in their signed message
@@ -28,7 +95,7 @@ class BridgeModule {
28
95
  * @returns Transfer result
29
96
  */
30
97
  async transfer(params) {
31
- return this.client.post('/api/v1/bridge/transfer', params);
98
+ return this.client.post("/api/v1/bridge/transfer", params);
32
99
  }
33
100
  /**
34
101
  * Request withdrawal from L2 (creates pending withdrawal)
@@ -36,14 +103,14 @@ class BridgeModule {
36
103
  * @returns Withdrawal result
37
104
  */
38
105
  async withdraw(params) {
39
- return this.client.post('/api/v1/bridge/withdraw', params);
106
+ return this.client.post("/api/v1/bridge/withdraw", params);
40
107
  }
41
108
  /**
42
109
  * Get all pending withdrawals (waiting for batch submission)
43
110
  * @returns List of pending withdrawals
44
111
  */
45
112
  async getPendingWithdrawals() {
46
- return this.client.get('/api/v1/bridge/pending-withdrawals');
113
+ return this.client.get("/api/v1/bridge/pending-withdrawals");
47
114
  }
48
115
  /**
49
116
  * Generate Merkle proof for a withdrawal
@@ -61,14 +128,14 @@ class BridgeModule {
61
128
  * @returns Bridge state
62
129
  */
63
130
  async getState() {
64
- return this.client.get('/api/v1/bridge/state');
131
+ return this.client.get("/api/v1/bridge/state");
65
132
  }
66
133
  /**
67
134
  * Submit a batch with Merkle root (sequencer only)
68
135
  * @returns Batch submission result
69
136
  */
70
137
  async submitBatch() {
71
- return this.client.post('/api/v1/bridge/submit-batch');
138
+ return this.client.post("/api/v1/bridge/submit-batch");
72
139
  }
73
140
  /**
74
141
  * Get deposit instructions (informational endpoint)
@@ -77,7 +144,7 @@ class BridgeModule {
77
144
  * @returns Deposit instructions
78
145
  */
79
146
  async getDepositInstructions(amount) {
80
- return this.client.post('/api/v1/bridge/deposit', { amount });
147
+ return this.client.post("/api/v1/bridge/deposit", { amount });
81
148
  }
82
149
  /**
83
150
  * Retroactively sync missed deposits from a block range
@@ -86,7 +153,7 @@ class BridgeModule {
86
153
  * @returns Sync results
87
154
  */
88
155
  async syncDeposits(params) {
89
- return this.client.post('/api/v1/bridge/sync-deposits', params || {});
156
+ return this.client.post("/api/v1/bridge/sync-deposits", params || {});
90
157
  }
91
158
  /**
92
159
  * Force process a specific deposit by transaction hash
@@ -95,7 +162,7 @@ class BridgeModule {
95
162
  * @returns Deposit processing result
96
163
  */
97
164
  async processDeposit(txHash) {
98
- return this.client.post('/api/v1/bridge/process-deposit', { txHash });
165
+ return this.client.post("/api/v1/bridge/process-deposit", { txHash });
99
166
  }
100
167
  /**
101
168
  * Reconcile user's L2 balance by recalculating from deposits, withdrawals, and L2 transfers
@@ -104,7 +171,7 @@ class BridgeModule {
104
171
  * @returns Reconciliation result
105
172
  */
106
173
  async reconcileBalance(userAddress) {
107
- return this.client.post('/api/v1/bridge/reconcile-balance', { user: userAddress });
174
+ return this.client.post("/api/v1/bridge/reconcile-balance", { user: userAddress });
108
175
  }
109
176
  /**
110
177
  * Get all transactions (deposits, withdrawals, transfers) for a user
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export declare class DealsModule {
3
3
  private client;
4
4
  constructor(client: ApiClient);
@@ -17,23 +17,23 @@ class DealsModule {
17
17
  params.durationDays = durationDays;
18
18
  if (tier)
19
19
  params.tier = tier;
20
- return this.client.get('/api/v1/deals/pricing', { params });
20
+ return this.client.get("/api/v1/deals/pricing", { params });
21
21
  }
22
22
  async uploadForDeal(fileBuffer, filename, contentType, walletAddress) {
23
23
  const form = new form_data_1.default();
24
- form.append('file', fileBuffer, {
24
+ form.append("file", fileBuffer, {
25
25
  filename: filename,
26
26
  contentType: contentType,
27
27
  });
28
- return this.client.post('/api/v1/deals/upload', form, {
28
+ return this.client.post("/api/v1/deals/upload", form, {
29
29
  headers: {
30
30
  ...form.getHeaders(),
31
- 'x-wallet-address': walletAddress,
31
+ "x-wallet-address": walletAddress,
32
32
  },
33
33
  });
34
34
  }
35
35
  async createDeal(dealParams) {
36
- return this.client.post('/api/v1/deals/create', dealParams);
36
+ return this.client.post("/api/v1/deals/create", dealParams);
37
37
  }
38
38
  async activateDeal(dealId, payment) {
39
39
  return this.client.post(`/api/v1/deals/${dealId}/activate`, { payment });
@@ -62,17 +62,17 @@ class DealsModule {
62
62
  async cancelDeal(dealId, clientAddress, reason) {
63
63
  return this.client.post(`/api/v1/deals/${dealId}/cancel`, {
64
64
  clientAddress,
65
- reason: reason || 'User requested cancellation',
65
+ reason: reason || "User requested cancellation",
66
66
  });
67
67
  }
68
68
  async getDealStats() {
69
- return this.client.get('/api/v1/deals/stats');
69
+ return this.client.get("/api/v1/deals/stats");
70
70
  }
71
71
  async getLeaderboard(limit) {
72
72
  const params = {};
73
73
  if (limit)
74
74
  params.limit = limit;
75
- return this.client.get('/api/v1/deals/leaderboard', { params });
75
+ return this.client.get("/api/v1/deals/leaderboard", { params });
76
76
  }
77
77
  }
78
78
  exports.DealsModule = DealsModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export declare class IpfsModule {
3
3
  private client;
4
4
  constructor(client: ApiClient);
@@ -10,36 +10,36 @@ class IpfsModule {
10
10
  this.client = client;
11
11
  }
12
12
  async getStatus() {
13
- return this.client.get('/api/v1/ipfs/status');
13
+ return this.client.get("/api/v1/ipfs/status");
14
14
  }
15
15
  async uploadFile(fileBuffer, filename, contentType, userAddress) {
16
16
  const form = new form_data_1.default();
17
- form.append('file', fileBuffer, {
17
+ form.append("file", fileBuffer, {
18
18
  filename: filename,
19
19
  contentType: contentType,
20
20
  });
21
21
  const headers = form.getHeaders();
22
22
  if (userAddress) {
23
- headers['x-user-address'] = userAddress;
23
+ headers["x-user-address"] = userAddress;
24
24
  }
25
- return this.client.post('/api/v1/ipfs/upload', form, {
25
+ return this.client.post("/api/v1/ipfs/upload", form, {
26
26
  headers: headers,
27
27
  });
28
28
  }
29
29
  async cat(cid) {
30
30
  return this.client.get(`/api/v1/ipfs/cat/${cid}`, {
31
- responseType: 'arraybuffer',
31
+ responseType: "arraybuffer",
32
32
  });
33
33
  }
34
34
  async pinAdd(cid) {
35
- return this.client.post('/api/v1/ipfs/pin/add', { cid });
35
+ return this.client.post("/api/v1/ipfs/pin/add", { cid });
36
36
  }
37
37
  async pinRm(cid) {
38
- return this.client.post('/api/v1/ipfs/pin/rm', { cid });
38
+ return this.client.post("/api/v1/ipfs/pin/rm", { cid });
39
39
  }
40
40
  async pinLs() {
41
41
  // Note: relay's pin/ls endpoint lists all pins and doesn't support filtering by CID
42
- return this.client.get('/api/v1/ipfs/pin/ls');
42
+ return this.client.get("/api/v1/ipfs/pin/ls");
43
43
  }
44
44
  async catJson(cid) {
45
45
  return this.client.get(`/api/v1/ipfs/cat/${cid}/json`);
@@ -48,22 +48,22 @@ class IpfsModule {
48
48
  const params = { token };
49
49
  const headers = {};
50
50
  if (userAddress) {
51
- headers['x-user-address'] = userAddress;
51
+ headers["x-user-address"] = userAddress;
52
52
  }
53
53
  return this.client.get(`/api/v1/ipfs/cat/${cid}/decrypt`, {
54
54
  params,
55
55
  headers,
56
- responseType: 'arraybuffer',
56
+ responseType: "arraybuffer",
57
57
  });
58
58
  }
59
59
  async repoGC() {
60
- return this.client.post('/api/v1/ipfs/repo/gc');
60
+ return this.client.post("/api/v1/ipfs/repo/gc");
61
61
  }
62
62
  async repoStat() {
63
- return this.client.get('/api/v1/ipfs/repo/stat');
63
+ return this.client.get("/api/v1/ipfs/repo/stat");
64
64
  }
65
65
  async getVersion() {
66
- return this.client.get('/api/v1/ipfs/version');
66
+ return this.client.get("/api/v1/ipfs/version");
67
67
  }
68
68
  }
69
69
  exports.IpfsModule = IpfsModule;
@@ -1,5 +1,5 @@
1
- import { ApiClient } from '../client';
2
- import { ReputationResponse, ReputationLeaderboardResponse, BestRelaysResponse, NetworkStatsResponse, RelayInfoResponse, RelaysListResponse } from '../types';
1
+ import { ApiClient } from "../client";
2
+ import { ReputationResponse, ReputationLeaderboardResponse, BestRelaysResponse, NetworkStatsResponse, RelayInfoResponse, RelaysListResponse } from "../types";
3
3
  export declare class NetworkModule {
4
4
  private client;
5
5
  constructor(client: ApiClient);
@@ -11,13 +11,13 @@ class NetworkModule {
11
11
  params.timeout = timeout;
12
12
  if (maxAge)
13
13
  params.maxAge = maxAge;
14
- return this.client.get('/api/v1/network/relays', { params });
14
+ return this.client.get("/api/v1/network/relays", { params });
15
15
  }
16
16
  async getRelay(host) {
17
17
  return this.client.get(`/api/v1/network/relay/${host}`);
18
18
  }
19
19
  async getStats() {
20
- return this.client.get('/api/v1/network/stats');
20
+ return this.client.get("/api/v1/network/stats");
21
21
  }
22
22
  async getProof(cid, challenge) {
23
23
  const params = {};
@@ -26,7 +26,7 @@ class NetworkModule {
26
26
  return this.client.get(`/api/v1/network/proof/${cid}`, { params });
27
27
  }
28
28
  async verifyProof(proof) {
29
- return this.client.post('/api/v1/network/verify-proof', { proof });
29
+ return this.client.post("/api/v1/network/verify-proof", { proof });
30
30
  }
31
31
  async getReputation(host) {
32
32
  return this.client.get(`/api/v1/network/reputation/${host}`);
@@ -37,7 +37,7 @@ class NetworkModule {
37
37
  params.minScore = minScore;
38
38
  if (limit)
39
39
  params.limit = limit;
40
- return this.client.get('/api/v1/network/reputation', { params });
40
+ return this.client.get("/api/v1/network/reputation", { params });
41
41
  }
42
42
  async getBestRelays(count, minScore, excludeHost) {
43
43
  const params = {};
@@ -47,25 +47,25 @@ class NetworkModule {
47
47
  params.minScore = minScore;
48
48
  if (excludeHost)
49
49
  params.exclude = excludeHost;
50
- return this.client.get('/api/v1/network/best-relays', { params });
50
+ return this.client.get("/api/v1/network/best-relays", { params });
51
51
  }
52
52
  // Note: On-chain endpoints are not available in the relay API
53
53
  // Use shogun-contracts-sdk for on-chain interactions instead
54
54
  // These methods are kept for backward compatibility but will throw an error
55
55
  async getOnChainRelays(chainId) {
56
- throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
56
+ throw new Error("On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.");
57
57
  }
58
58
  async getOnChainRelay(address, chainId) {
59
- throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
59
+ throw new Error("On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.");
60
60
  }
61
61
  async getOnChainParams(chainId) {
62
- throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
62
+ throw new Error("On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.");
63
63
  }
64
64
  async getPinRequests(maxAge) {
65
65
  const params = {};
66
66
  if (maxAge)
67
67
  params.maxAge = maxAge;
68
- return this.client.get('/api/v1/network/pin-requests', { params });
68
+ return this.client.get("/api/v1/network/pin-requests", { params });
69
69
  }
70
70
  }
71
71
  exports.NetworkModule = NetworkModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export declare class RegistryModule {
3
3
  private client;
4
4
  constructor(client: ApiClient);
@@ -6,62 +6,62 @@ class RegistryModule {
6
6
  this.client = client;
7
7
  }
8
8
  async getStatus() {
9
- return this.client.get('/api/v1/registry/status');
9
+ return this.client.get("/api/v1/registry/status");
10
10
  }
11
11
  async getBalance() {
12
- return this.client.get('/api/v1/registry/balance');
12
+ return this.client.get("/api/v1/registry/balance");
13
13
  }
14
14
  async registerRelay(endpoint, gunPubKey, stakeAmount) {
15
- return this.client.post('/api/v1/registry/register', {
15
+ return this.client.post("/api/v1/registry/register", {
16
16
  endpoint,
17
17
  gunPubKey,
18
18
  stakeAmount,
19
19
  });
20
20
  }
21
21
  async updateRelay(newEndpoint, newGunPubKey) {
22
- return this.client.post('/api/v1/registry/update', {
22
+ return this.client.post("/api/v1/registry/update", {
23
23
  newEndpoint,
24
24
  newGunPubKey,
25
25
  });
26
26
  }
27
27
  async increaseStake(amount) {
28
- return this.client.post('/api/v1/registry/stake/increase', { amount });
28
+ return this.client.post("/api/v1/registry/stake/increase", { amount });
29
29
  }
30
30
  async requestUnstake() {
31
- return this.client.post('/api/v1/registry/stake/unstake');
31
+ return this.client.post("/api/v1/registry/stake/unstake");
32
32
  }
33
33
  async withdrawStake() {
34
- return this.client.post('/api/v1/registry/stake/withdraw');
34
+ return this.client.post("/api/v1/registry/stake/withdraw");
35
35
  }
36
36
  async getDeals() {
37
- return this.client.get('/api/v1/registry/deals');
37
+ return this.client.get("/api/v1/registry/deals");
38
38
  }
39
39
  async griefMissedProof(relayAddress, dealId, evidence) {
40
- return this.client.post('/api/v1/registry/grief/missed-proof', {
40
+ return this.client.post("/api/v1/registry/grief/missed-proof", {
41
41
  relayAddress,
42
42
  dealId,
43
43
  evidence,
44
44
  });
45
45
  }
46
46
  async griefDataLoss(relayAddress, dealId, evidence) {
47
- return this.client.post('/api/v1/registry/grief/data-loss', {
47
+ return this.client.post("/api/v1/registry/grief/data-loss", {
48
48
  relayAddress,
49
49
  dealId,
50
50
  evidence,
51
51
  });
52
52
  }
53
53
  async griefDeal(dealId, slashAmount, reason) {
54
- return this.client.post('/api/v1/registry/deal/grief', {
54
+ return this.client.post("/api/v1/registry/deal/grief", {
55
55
  dealId,
56
56
  slashAmount,
57
57
  reason,
58
58
  });
59
59
  }
60
60
  async getParams() {
61
- return this.client.get('/api/v1/registry/params');
61
+ return this.client.get("/api/v1/registry/params");
62
62
  }
63
63
  async getConfig() {
64
- return this.client.get('/api/v1/registry/config');
64
+ return this.client.get("/api/v1/registry/config");
65
65
  }
66
66
  }
67
67
  exports.RegistryModule = RegistryModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export interface HealthResponse {
3
3
  success: boolean;
4
4
  message: string;
@@ -7,10 +7,10 @@ class SystemModule {
7
7
  }
8
8
  async getHealth() {
9
9
  // Use /api/v1/system/health (the correct endpoint in the relay)
10
- return this.client.get('/api/v1/system/health');
10
+ return this.client.get("/api/v1/system/health");
11
11
  }
12
12
  async getStats() {
13
- return this.client.get('/api/v1/system/stats');
13
+ return this.client.get("/api/v1/system/stats");
14
14
  }
15
15
  }
16
16
  exports.SystemModule = SystemModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export declare class UploadsModule {
3
3
  private client;
4
4
  constructor(client: ApiClient);
@@ -12,7 +12,7 @@ class UploadsModule {
12
12
  return this.client.delete(`/api/v1/user-uploads/${identifier}/${hash}`);
13
13
  }
14
14
  async getSystemHashes() {
15
- return this.client.get('/api/v1/user-uploads/system-hashes');
15
+ return this.client.get("/api/v1/user-uploads/system-hashes");
16
16
  }
17
17
  }
18
18
  exports.UploadsModule = UploadsModule;
@@ -1,4 +1,4 @@
1
- import { ApiClient } from '../client';
1
+ import { ApiClient } from "../client";
2
2
  export declare class X402Module {
3
3
  private client;
4
4
  constructor(client: ApiClient);
@@ -6,13 +6,13 @@ class X402Module {
6
6
  this.client = client;
7
7
  }
8
8
  async getTiers() {
9
- return this.client.get('/api/v1/x402/tiers');
9
+ return this.client.get("/api/v1/x402/tiers");
10
10
  }
11
11
  async getSubscription(userAddress) {
12
12
  return this.client.get(`/api/v1/x402/subscription/${userAddress}`);
13
13
  }
14
14
  async subscribe(userAddress, tier, payment) {
15
- return this.client.post('/api/v1/x402/subscribe', {
15
+ return this.client.post("/api/v1/x402/subscribe", {
16
16
  userAddress,
17
17
  tier,
18
18
  payment,
@@ -37,13 +37,13 @@ class X402Module {
37
37
  };
38
38
  if (userAddress)
39
39
  params.userAddress = userAddress;
40
- return this.client.get('/api/v1/x402/recommend', { params });
40
+ return this.client.get("/api/v1/x402/recommend", { params });
41
41
  }
42
42
  async getConfig() {
43
- return this.client.get('/api/v1/x402/config');
43
+ return this.client.get("/api/v1/x402/config");
44
44
  }
45
45
  async getRelayStorage() {
46
- return this.client.get('/api/v1/x402/relay-storage');
46
+ return this.client.get("/api/v1/x402/relay-storage");
47
47
  }
48
48
  }
49
49
  exports.X402Module = X402Module;
package/dist/types.d.ts CHANGED
@@ -32,7 +32,7 @@ export interface ReputationWeights {
32
32
  */
33
33
  export interface ReputationScore {
34
34
  total: number;
35
- tier: 'excellent' | 'good' | 'average' | 'poor' | 'unreliable';
35
+ tier: "excellent" | "good" | "average" | "poor" | "unreliable";
36
36
  breakdown: ReputationScoreBreakdown;
37
37
  weights: ReputationWeights;
38
38
  hasEnoughData: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shogun-relay-sdk",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "SDK for interacting with Shogun Relay API - HTTP client for IPFS, deals, registry, and network operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,11 @@
18
18
  "scripts": {
19
19
  "build": "tsc",
20
20
  "prepublishOnly": "npm run build",
21
- "test": "echo \"Error: no test specified\" && exit 1"
21
+ "test": "echo \"Error: no test specified\" && exit 1",
22
+ "lint": "eslint src --max-warnings 0",
23
+ "lint:fix": "eslint src --fix",
24
+ "format": "prettier --write \"src/**/*.ts\"",
25
+ "format:check": "prettier --check \"src/**/*.ts\""
22
26
  },
23
27
  "keywords": [
24
28
  "shogun",
@@ -42,8 +46,13 @@
42
46
  "form-data": "^4.0.0"
43
47
  },
44
48
  "devDependencies": {
49
+ "@eslint/js": "^9.15.0",
45
50
  "@types/node": "^20.0.0",
46
- "typescript": "^5.0.0"
51
+ "eslint": "^9.15.0",
52
+ "globals": "^15.12.0",
53
+ "prettier": "^3.7.4",
54
+ "typescript": "^5.0.0",
55
+ "typescript-eslint": "^8.15.0"
47
56
  },
48
57
  "engines": {
49
58
  "node": ">=16.0.0"