shogun-relay-sdk 1.2.2 → 1.2.4
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/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/modules/bridge.js +2 -1
- package/dist/modules/ipfs.d.ts +14 -0
- package/dist/modules/ipfs.js +28 -0
- package/dist/types.d.ts +0 -83
- package/dist/types.js +0 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { DealsModule } from "./modules/deals";
|
|
|
7
7
|
import { RegistryModule } from "./modules/registry";
|
|
8
8
|
import { UploadsModule } from "./modules/uploads";
|
|
9
9
|
import { BridgeModule } from "./modules/bridge";
|
|
10
|
-
import { OracleModule } from "./modules/oracle";
|
|
11
10
|
export * from "./types";
|
|
12
11
|
export declare class ShogunRelaySDK {
|
|
13
12
|
private client;
|
|
@@ -19,7 +18,6 @@ export declare class ShogunRelaySDK {
|
|
|
19
18
|
registry: RegistryModule;
|
|
20
19
|
uploads: UploadsModule;
|
|
21
20
|
bridge: BridgeModule;
|
|
22
|
-
oracle: OracleModule;
|
|
23
21
|
constructor(config: ApiClientConfig);
|
|
24
22
|
setToken(token: string): void;
|
|
25
23
|
}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,6 @@ const deals_1 = require("./modules/deals");
|
|
|
24
24
|
const registry_1 = require("./modules/registry");
|
|
25
25
|
const uploads_1 = require("./modules/uploads");
|
|
26
26
|
const bridge_1 = require("./modules/bridge");
|
|
27
|
-
const oracle_1 = require("./modules/oracle");
|
|
28
27
|
// Export types
|
|
29
28
|
__exportStar(require("./types"), exports);
|
|
30
29
|
class ShogunRelaySDK {
|
|
@@ -38,7 +37,6 @@ class ShogunRelaySDK {
|
|
|
38
37
|
this.registry = new registry_1.RegistryModule(this.client);
|
|
39
38
|
this.uploads = new uploads_1.UploadsModule(this.client);
|
|
40
39
|
this.bridge = new bridge_1.BridgeModule(this.client);
|
|
41
|
-
this.oracle = new oracle_1.OracleModule(this.client);
|
|
42
40
|
}
|
|
43
41
|
setToken(token) {
|
|
44
42
|
this.client.setToken(token);
|
package/dist/modules/bridge.js
CHANGED
|
@@ -189,7 +189,8 @@ class BridgeModule {
|
|
|
189
189
|
* @returns Transaction details
|
|
190
190
|
*/
|
|
191
191
|
async getTransaction(txHash) {
|
|
192
|
-
|
|
192
|
+
// URL-encode the txHash to handle special characters (e.g., / and + in base64 hashes)
|
|
193
|
+
return this.client.get(`/api/v1/bridge/transaction/${encodeURIComponent(txHash)}`);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
exports.BridgeModule = BridgeModule;
|
package/dist/modules/ipfs.d.ts
CHANGED
|
@@ -4,6 +4,20 @@ export declare class IpfsModule {
|
|
|
4
4
|
constructor(client: ApiClient);
|
|
5
5
|
getStatus(): Promise<any>;
|
|
6
6
|
uploadFile(fileBuffer: Buffer, filename: string, contentType: string, userAddress?: string): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Upload multiple files as a directory to IPFS
|
|
9
|
+
* Maintains directory structure using relative paths
|
|
10
|
+
*
|
|
11
|
+
* @param files Array of file objects with buffer, filename, path, and contentType
|
|
12
|
+
* @param userAddress Optional user address for authentication
|
|
13
|
+
* @returns Promise with directory CID and file information
|
|
14
|
+
*/
|
|
15
|
+
uploadDirectory(files: Array<{
|
|
16
|
+
buffer: Buffer;
|
|
17
|
+
filename: string;
|
|
18
|
+
path: string;
|
|
19
|
+
contentType?: string;
|
|
20
|
+
}>, userAddress?: string): Promise<any>;
|
|
7
21
|
cat(cid: string): Promise<Buffer>;
|
|
8
22
|
pinAdd(cid: string): Promise<any>;
|
|
9
23
|
pinRm(cid: string): Promise<any>;
|
package/dist/modules/ipfs.js
CHANGED
|
@@ -26,6 +26,34 @@ class IpfsModule {
|
|
|
26
26
|
headers: headers,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Upload multiple files as a directory to IPFS
|
|
31
|
+
* Maintains directory structure using relative paths
|
|
32
|
+
*
|
|
33
|
+
* @param files Array of file objects with buffer, filename, path, and contentType
|
|
34
|
+
* @param userAddress Optional user address for authentication
|
|
35
|
+
* @returns Promise with directory CID and file information
|
|
36
|
+
*/
|
|
37
|
+
async uploadDirectory(files, userAddress) {
|
|
38
|
+
if (!files || files.length === 0) {
|
|
39
|
+
throw new Error("At least one file is required for directory upload");
|
|
40
|
+
}
|
|
41
|
+
const form = new form_data_1.default();
|
|
42
|
+
// Add all files to FormData maintaining directory structure
|
|
43
|
+
files.forEach((file) => {
|
|
44
|
+
form.append("files", file.buffer, {
|
|
45
|
+
filename: file.path, // Use path to maintain directory structure
|
|
46
|
+
contentType: file.contentType || "application/octet-stream",
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
const headers = form.getHeaders();
|
|
50
|
+
if (userAddress) {
|
|
51
|
+
headers["x-user-address"] = userAddress;
|
|
52
|
+
}
|
|
53
|
+
return this.client.post("/api/v1/ipfs/upload-directory", form, {
|
|
54
|
+
headers: headers,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
29
57
|
async cat(cid) {
|
|
30
58
|
return this.client.get(`/api/v1/ipfs/cat/${cid}`, {
|
|
31
59
|
responseType: "arraybuffer",
|
package/dist/types.d.ts
CHANGED
|
@@ -241,86 +241,3 @@ export interface RelaysListResponse {
|
|
|
241
241
|
}>;
|
|
242
242
|
error?: string;
|
|
243
243
|
}
|
|
244
|
-
/**
|
|
245
|
-
* Supported data types for feed payloads
|
|
246
|
-
*/
|
|
247
|
-
export declare enum DataType {
|
|
248
|
-
PRICE = 0,
|
|
249
|
-
STRING = 1,
|
|
250
|
-
JSON = 2,
|
|
251
|
-
BYTES = 3,
|
|
252
|
-
CUSTOM = 4
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Oracle Data Feed
|
|
256
|
-
*/
|
|
257
|
-
export interface OracleFeed {
|
|
258
|
-
feedId: string;
|
|
259
|
-
name: string;
|
|
260
|
-
priceUSDC: number;
|
|
261
|
-
dataType: DataType;
|
|
262
|
-
dataTypeName: string;
|
|
263
|
-
active: boolean;
|
|
264
|
-
schema: string;
|
|
265
|
-
updateFreqSecs: number;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Validated Oracle Packet
|
|
269
|
-
*/
|
|
270
|
-
export interface OraclePacket {
|
|
271
|
-
feedId: string;
|
|
272
|
-
deadline: number;
|
|
273
|
-
payload: string;
|
|
274
|
-
signature: {
|
|
275
|
-
v: number;
|
|
276
|
-
r: string;
|
|
277
|
-
s: string;
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Global Oracle Stats
|
|
282
|
-
*/
|
|
283
|
-
export interface OracleGlobalStats {
|
|
284
|
-
totalAccesses: number;
|
|
285
|
-
totalRevenueUSDC: number;
|
|
286
|
-
lastAccess?: string;
|
|
287
|
-
accessesByFeed: Record<string, number>;
|
|
288
|
-
revenueByFeed: Record<string, number>;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Oracle Feeds Response
|
|
292
|
-
*/
|
|
293
|
-
export interface OracleFeedsResponse {
|
|
294
|
-
success: boolean;
|
|
295
|
-
feeds: OracleFeed[];
|
|
296
|
-
relay?: string;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Oracle Data Response
|
|
300
|
-
*/
|
|
301
|
-
export interface OracleDataResponse {
|
|
302
|
-
success: boolean;
|
|
303
|
-
packet?: OraclePacket;
|
|
304
|
-
data?: {
|
|
305
|
-
feedId: string;
|
|
306
|
-
feedName: string;
|
|
307
|
-
value: any;
|
|
308
|
-
timestamp: number;
|
|
309
|
-
};
|
|
310
|
-
paymentRequired?: boolean;
|
|
311
|
-
priceUSDC?: number;
|
|
312
|
-
error?: string;
|
|
313
|
-
paymentDetails?: {
|
|
314
|
-
required: boolean;
|
|
315
|
-
amountUSDC: number;
|
|
316
|
-
tiers: any[];
|
|
317
|
-
x402: any;
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Oracle Global Stats Response
|
|
322
|
-
*/
|
|
323
|
-
export interface OracleGlobalStatsResponse {
|
|
324
|
-
success: boolean;
|
|
325
|
-
stats: OracleGlobalStats;
|
|
326
|
-
}
|
package/dist/types.js
CHANGED
|
@@ -3,15 +3,3 @@
|
|
|
3
3
|
* Type definitions for Shogun Relay SDK
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DataType = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Supported data types for feed payloads
|
|
9
|
-
*/
|
|
10
|
-
var DataType;
|
|
11
|
-
(function (DataType) {
|
|
12
|
-
DataType[DataType["PRICE"] = 0] = "PRICE";
|
|
13
|
-
DataType[DataType["STRING"] = 1] = "STRING";
|
|
14
|
-
DataType[DataType["JSON"] = 2] = "JSON";
|
|
15
|
-
DataType[DataType["BYTES"] = 3] = "BYTES";
|
|
16
|
-
DataType[DataType["CUSTOM"] = 4] = "CUSTOM";
|
|
17
|
-
})(DataType || (exports.DataType = DataType = {}));
|
package/package.json
CHANGED