@healchain/sdk 0.3.0 → 0.4.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healchain/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "JavaScript SDK for HealChain — self-healing decentralized storage via Reed-Solomon erasure coding",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HealChain SDK v0.1.0
2
+ * HealChain SDK v0.4.0
3
3
  * REST API client for HealChain — self-healing decentralized storage.
4
4
  *
5
5
  * Browser (ESM) and Node.js compatible.
@@ -64,7 +64,8 @@ class HealChain {
64
64
  * @param {number} [options.pollTimeout] - Fulfillment poll timeout in ms
65
65
  * @param {number} [options.dataShards] - Default RS data shards
66
66
  * @param {number} [options.parityShards] - Default RS parity shards
67
- * @param {string} [options.network] - 'sepolia' | 'arbitrum' (for store routing)
67
+ * @param {string} [options.network] - Chain name, 'auto' (default), or specific chain
68
+ * @param {string} [options.preference] - 'cheapest' | 'fastest' | 'redundant' | '' (auto weighted)
68
69
  */
69
70
  constructor(options = {}) {
70
71
  this.apiUrl = (options.apiUrl ?? DEFAULT_API_URL).replace(/\/$/, '');
@@ -73,7 +74,8 @@ class HealChain {
73
74
  this.pollTimeout = options.pollTimeout ?? DEFAULT_POLL_TIMEOUT;
74
75
  this.dataShards = options.dataShards ?? DEFAULT_DATA_SHARDS;
75
76
  this.parityShards = options.parityShards ?? DEFAULT_PARITY_SHARDS;
76
- this.network = options.network ?? 'sepolia';
77
+ this.network = options.network ?? 'auto';
78
+ this.preference = options.preference ?? '';
77
79
  }
78
80
 
79
81
  // ── Internal fetch wrapper ──────────────────────────────────────────────────
@@ -126,7 +128,8 @@ class HealChain {
126
128
  * @param {string} [options.label='sdk upload'] - Record label
127
129
  * @param {number} [options.dataShards] - Override RS data shards
128
130
  * @param {number} [options.parityShards] - Override RS parity shards
129
- * @param {string} [options.network] - Override network for this call
131
+ * @param {string} [options.network] - Chain name or 'auto' (default)
132
+ * @param {string} [options.preference] - 'cheapest' | 'fastest' | 'redundant' | ''
130
133
  * @param {function} [options.onPending] - Called with requestId when submitted
131
134
  * @param {function} [options.onFulfilled] - Called when oracle fulfills
132
135
  *
@@ -146,11 +149,12 @@ class HealChain {
146
149
  const dataShards = options.dataShards ?? this.dataShards;
147
150
  const parityShards = options.parityShards ?? this.parityShards;
148
151
  const network = options.network ?? this.network;
152
+ const preference = options.preference ?? this.preference;
149
153
 
150
154
  // Submit store request
151
155
  const submitted = await this._fetch('/storeOnChain', {
152
156
  method: 'POST',
153
- body: JSON.stringify({ data: hex, label, network, dataShards, parityShards }),
157
+ body: JSON.stringify({ data: hex, label, network, preference, dataShards, parityShards }),
154
158
  });
155
159
 
156
160
  // Devnet returns synchronously