blue-js-sdk 2.0.3 → 2.1.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/batch.js +2 -2
- package/chain/broadcast.js +113 -3
- package/chain/queries.js +21 -0
- package/connection/connect.js +4 -4
- package/docs/CHAIN-PROTOCOL-UPGRADE-PROPOSAL.md +662 -0
- package/docs/ON-CHAIN-FUNCTIONS.md +1310 -0
- package/index.js +12 -0
- package/package.json +2 -1
- package/plan-operations.js +18 -11
- package/protocol/encoding.js +38 -24
- package/protocol/messages.js +19 -19
- package/protocol/plans.js +18 -11
- package/protocol/v3.js +11 -7
- package/test-subscription-flows.js +457 -0
- package/v3protocol.js +38 -24
- package/test-all-chain-ops.js +0 -493
- package/test-feegrant-connect.js +0 -98
- package/test-logic.js +0 -148
package/index.js
CHANGED
|
@@ -304,6 +304,18 @@ export {
|
|
|
304
304
|
rpcQueryBalance,
|
|
305
305
|
} from './chain/rpc.js';
|
|
306
306
|
|
|
307
|
+
// ─── Subscription Sharing (plan operator → user onboarding) ────────────────
|
|
308
|
+
|
|
309
|
+
export {
|
|
310
|
+
shareSubscription,
|
|
311
|
+
shareSubscriptionWithFeeGrant,
|
|
312
|
+
onboardPlanUser,
|
|
313
|
+
} from './chain/broadcast.js';
|
|
314
|
+
|
|
315
|
+
export {
|
|
316
|
+
querySubscriptionAllocations,
|
|
317
|
+
} from './chain/queries.js';
|
|
318
|
+
|
|
307
319
|
// ─── TypeScript Client (extends CosmJS SigningStargateClient) ───────────────
|
|
308
320
|
|
|
309
321
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blue-js-sdk",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Decentralized VPN SDK for the Sentinel P2P bandwidth network. WireGuard + V2Ray tunnels, Cosmos blockchain, 900+ nodes. Tested on Windows. macOS/Linux support included but untested.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"config/",
|
|
49
49
|
"errors/",
|
|
50
50
|
"examples/",
|
|
51
|
+
"docs/",
|
|
51
52
|
"ai-path/",
|
|
52
53
|
"bin/setup.js",
|
|
53
54
|
"dist/",
|
package/plan-operations.js
CHANGED
|
@@ -123,11 +123,12 @@ export function encodeMsgUpdatePlanStatus({ from, id, status }) {
|
|
|
123
123
|
* Link a leased node to a plan. Requires active lease for the node.
|
|
124
124
|
* from: sentprov prefix (provider address)
|
|
125
125
|
*/
|
|
126
|
-
export function encodeMsgLinkNode({ from, id, nodeAddress }) {
|
|
126
|
+
export function encodeMsgLinkNode({ from, id, nodeAddress, node_address }) {
|
|
127
|
+
const addr = nodeAddress || node_address;
|
|
127
128
|
return Uint8Array.from(Buffer.concat([
|
|
128
129
|
protoString(1, from),
|
|
129
130
|
protoUint64(2, id),
|
|
130
|
-
protoString(3,
|
|
131
|
+
protoString(3, addr),
|
|
131
132
|
]));
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -136,11 +137,12 @@ export function encodeMsgLinkNode({ from, id, nodeAddress }) {
|
|
|
136
137
|
* Remove a node from a plan.
|
|
137
138
|
* from: sentprov prefix (provider address)
|
|
138
139
|
*/
|
|
139
|
-
export function encodeMsgUnlinkNode({ from, id, nodeAddress }) {
|
|
140
|
+
export function encodeMsgUnlinkNode({ from, id, nodeAddress, node_address }) {
|
|
141
|
+
const addr = nodeAddress || node_address;
|
|
140
142
|
return Uint8Array.from(Buffer.concat([
|
|
141
143
|
protoString(1, from),
|
|
142
144
|
protoUint64(2, id),
|
|
143
|
-
protoString(3,
|
|
145
|
+
protoString(3, addr),
|
|
144
146
|
]));
|
|
145
147
|
}
|
|
146
148
|
|
|
@@ -149,14 +151,16 @@ export function encodeMsgUnlinkNode({ from, id, nodeAddress }) {
|
|
|
149
151
|
* Subscribes to a plan AND starts a session in one TX.
|
|
150
152
|
* from: sent prefix (account address)
|
|
151
153
|
*/
|
|
152
|
-
export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPricePolicy
|
|
154
|
+
export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPricePolicy, renewal_price_policy, nodeAddress, node_address }) {
|
|
155
|
+
const policy = renewalPricePolicy || renewal_price_policy || 0;
|
|
156
|
+
const addr = nodeAddress || node_address;
|
|
153
157
|
const parts = [
|
|
154
158
|
protoString(1, from),
|
|
155
159
|
protoUint64(2, id),
|
|
156
160
|
protoString(3, denom),
|
|
157
161
|
];
|
|
158
|
-
if (
|
|
159
|
-
if (
|
|
162
|
+
if (policy) parts.push(protoInt64(4, policy));
|
|
163
|
+
if (addr) parts.push(protoString(5, addr));
|
|
160
164
|
return Uint8Array.from(Buffer.concat(parts));
|
|
161
165
|
}
|
|
162
166
|
|
|
@@ -170,14 +174,17 @@ export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPr
|
|
|
170
174
|
* CRITICAL: maxPrice must EXACTLY match the node's hourly_prices from LCD.
|
|
171
175
|
* Any mismatch → "invalid price" error.
|
|
172
176
|
*/
|
|
173
|
-
export function encodeMsgStartLease({ from, nodeAddress, hours, maxPrice, renewalPricePolicy
|
|
177
|
+
export function encodeMsgStartLease({ from, nodeAddress, node_address, hours, maxPrice, max_price, renewalPricePolicy, renewal_price_policy }) {
|
|
178
|
+
const addr = nodeAddress || node_address;
|
|
179
|
+
const price = maxPrice || max_price;
|
|
180
|
+
const policy = renewalPricePolicy || renewal_price_policy || 0;
|
|
174
181
|
const parts = [
|
|
175
182
|
protoString(1, from),
|
|
176
|
-
protoString(2,
|
|
183
|
+
protoString(2, addr),
|
|
177
184
|
protoInt64(3, hours),
|
|
178
185
|
];
|
|
179
|
-
if (
|
|
180
|
-
if (
|
|
186
|
+
if (price) parts.push(protoEmbedded(4, encodePrice(price)));
|
|
187
|
+
if (policy) parts.push(protoInt64(5, policy));
|
|
181
188
|
return Uint8Array.from(Buffer.concat(parts));
|
|
182
189
|
}
|
|
183
190
|
|
package/protocol/encoding.js
CHANGED
|
@@ -105,13 +105,15 @@ export function encodeDuration({ seconds, nanos = 0 }) {
|
|
|
105
105
|
* 4: hours (int64, 0 if using gigabytes)
|
|
106
106
|
* 5: max_price (Price, optional) — max price user will pay per GB
|
|
107
107
|
*/
|
|
108
|
-
export function encodeMsgStartSession({ from, node_address, gigabytes = 1, hours = 0, max_price }) {
|
|
108
|
+
export function encodeMsgStartSession({ from, node_address, nodeAddress, gigabytes = 1, hours = 0, max_price, maxPrice }) {
|
|
109
|
+
const addr = node_address || nodeAddress;
|
|
110
|
+
const price = max_price || maxPrice;
|
|
109
111
|
return Uint8Array.from(Buffer.concat([
|
|
110
112
|
protoString(1, from),
|
|
111
|
-
protoString(2,
|
|
113
|
+
protoString(2, addr),
|
|
112
114
|
protoInt64(3, gigabytes),
|
|
113
115
|
hours ? protoInt64(4, hours) : Buffer.alloc(0),
|
|
114
|
-
|
|
116
|
+
price ? protoEmbedded(5, encodePrice(price)) : Buffer.alloc(0),
|
|
115
117
|
]));
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -122,13 +124,14 @@ export function encodeMsgStartSession({ from, node_address, gigabytes = 1, hours
|
|
|
122
124
|
* 3: denom (string, e.g. "udvpn")
|
|
123
125
|
* 4: renewal_price_policy (enum/int64, optional)
|
|
124
126
|
*/
|
|
125
|
-
export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalPricePolicy
|
|
127
|
+
export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalPricePolicy, renewal_price_policy }) {
|
|
128
|
+
const policy = renewalPricePolicy || renewal_price_policy || 0;
|
|
126
129
|
const parts = [
|
|
127
130
|
protoString(1, from),
|
|
128
131
|
protoInt64(2, id),
|
|
129
132
|
protoString(3, denom),
|
|
130
133
|
];
|
|
131
|
-
if (
|
|
134
|
+
if (policy) parts.push(protoInt64(4, policy));
|
|
132
135
|
return Uint8Array.from(Buffer.concat(parts));
|
|
133
136
|
}
|
|
134
137
|
|
|
@@ -138,11 +141,12 @@ export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalP
|
|
|
138
141
|
* 2: id (uint64, subscription ID)
|
|
139
142
|
* 3: node_address (string)
|
|
140
143
|
*/
|
|
141
|
-
export function encodeMsgSubStartSession({ from, id, nodeAddress }) {
|
|
144
|
+
export function encodeMsgSubStartSession({ from, id, nodeAddress, node_address }) {
|
|
145
|
+
const addr = nodeAddress || node_address;
|
|
142
146
|
return Uint8Array.from(Buffer.concat([
|
|
143
147
|
protoString(1, from),
|
|
144
148
|
protoInt64(2, id),
|
|
145
|
-
protoString(3,
|
|
149
|
+
protoString(3, addr),
|
|
146
150
|
]));
|
|
147
151
|
}
|
|
148
152
|
|
|
@@ -179,14 +183,15 @@ export function encodeMsgRenewSubscription({ from, id, denom = 'udvpn' }) {
|
|
|
179
183
|
* 1: from (string)
|
|
180
184
|
* 2: id (uint64, subscription ID)
|
|
181
185
|
* 3: acc_address (string, recipient sent1... address)
|
|
182
|
-
* 4: bytes (
|
|
186
|
+
* 4: bytes (string — cosmossdk.io/math.Int, wire type 2 = length-delimited)
|
|
183
187
|
*/
|
|
184
|
-
export function encodeMsgShareSubscription({ from, id, accAddress, bytes }) {
|
|
188
|
+
export function encodeMsgShareSubscription({ from, id, accAddress, acc_address, bytes }) {
|
|
189
|
+
const addr = accAddress || acc_address;
|
|
185
190
|
return Uint8Array.from(Buffer.concat([
|
|
186
191
|
protoString(1, from),
|
|
187
192
|
protoInt64(2, id),
|
|
188
|
-
protoString(3,
|
|
189
|
-
|
|
193
|
+
protoString(3, addr),
|
|
194
|
+
protoString(4, String(bytes)),
|
|
190
195
|
]));
|
|
191
196
|
}
|
|
192
197
|
|
|
@@ -196,11 +201,12 @@ export function encodeMsgShareSubscription({ from, id, accAddress, bytes }) {
|
|
|
196
201
|
* 2: id (uint64, subscription ID)
|
|
197
202
|
* 3: renewal_price_policy (int64)
|
|
198
203
|
*/
|
|
199
|
-
export function encodeMsgUpdateSubscription({ from, id, renewalPricePolicy }) {
|
|
204
|
+
export function encodeMsgUpdateSubscription({ from, id, renewalPricePolicy, renewal_price_policy }) {
|
|
205
|
+
const policy = renewalPricePolicy || renewal_price_policy;
|
|
200
206
|
return Uint8Array.from(Buffer.concat([
|
|
201
207
|
protoString(1, from),
|
|
202
208
|
protoInt64(2, id),
|
|
203
|
-
protoInt64(3,
|
|
209
|
+
protoInt64(3, policy),
|
|
204
210
|
]));
|
|
205
211
|
}
|
|
206
212
|
|
|
@@ -215,12 +221,14 @@ export function encodeMsgUpdateSubscription({ from, id, renewalPricePolicy }) {
|
|
|
215
221
|
* 5: duration (bytes, protobuf Duration)
|
|
216
222
|
* 6: signature (bytes)
|
|
217
223
|
*/
|
|
218
|
-
export function encodeMsgUpdateSession({ from, id, downloadBytes, uploadBytes }) {
|
|
224
|
+
export function encodeMsgUpdateSession({ from, id, downloadBytes, download_bytes, uploadBytes, upload_bytes }) {
|
|
225
|
+
const dl = downloadBytes || download_bytes;
|
|
226
|
+
const ul = uploadBytes || upload_bytes;
|
|
219
227
|
return Uint8Array.from(Buffer.concat([
|
|
220
228
|
protoString(1, from),
|
|
221
229
|
protoInt64(2, id),
|
|
222
|
-
protoInt64(3,
|
|
223
|
-
protoInt64(4,
|
|
230
|
+
protoInt64(3, dl),
|
|
231
|
+
protoInt64(4, ul),
|
|
224
232
|
]));
|
|
225
233
|
}
|
|
226
234
|
|
|
@@ -233,11 +241,14 @@ export function encodeMsgUpdateSession({ from, id, downloadBytes, uploadBytes })
|
|
|
233
241
|
* 3: hourly_prices (bytes[], Price entries)
|
|
234
242
|
* 4: remote_addrs (string[], IP:port addresses)
|
|
235
243
|
*/
|
|
236
|
-
export function encodeMsgRegisterNode({ from, gigabytePrices
|
|
244
|
+
export function encodeMsgRegisterNode({ from, gigabytePrices, gigabyte_prices, hourlyPrices, hourly_prices, remoteAddrs, remote_addrs }) {
|
|
245
|
+
const gbPrices = gigabytePrices || gigabyte_prices || [];
|
|
246
|
+
const hrPrices = hourlyPrices || hourly_prices || [];
|
|
247
|
+
const addrs = remoteAddrs || remote_addrs || [];
|
|
237
248
|
const parts = [protoString(1, from)];
|
|
238
|
-
for (const p of
|
|
239
|
-
for (const p of
|
|
240
|
-
for (const addr of
|
|
249
|
+
for (const p of gbPrices) parts.push(protoEmbedded(2, encodePrice(p)));
|
|
250
|
+
for (const p of hrPrices) parts.push(protoEmbedded(3, encodePrice(p)));
|
|
251
|
+
for (const addr of addrs) parts.push(protoString(4, addr));
|
|
241
252
|
return Uint8Array.from(Buffer.concat(parts));
|
|
242
253
|
}
|
|
243
254
|
|
|
@@ -248,11 +259,14 @@ export function encodeMsgRegisterNode({ from, gigabytePrices = [], hourlyPrices
|
|
|
248
259
|
* 3: hourly_prices (bytes[], Price entries)
|
|
249
260
|
* 4: remote_addrs (string[], IP:port addresses)
|
|
250
261
|
*/
|
|
251
|
-
export function encodeMsgUpdateNodeDetails({ from, gigabytePrices
|
|
262
|
+
export function encodeMsgUpdateNodeDetails({ from, gigabytePrices, gigabyte_prices, hourlyPrices, hourly_prices, remoteAddrs, remote_addrs }) {
|
|
263
|
+
const gbPrices = gigabytePrices || gigabyte_prices || [];
|
|
264
|
+
const hrPrices = hourlyPrices || hourly_prices || [];
|
|
265
|
+
const addrs = remoteAddrs || remote_addrs || [];
|
|
252
266
|
const parts = [protoString(1, from)];
|
|
253
|
-
for (const p of
|
|
254
|
-
for (const p of
|
|
255
|
-
for (const addr of
|
|
267
|
+
for (const p of gbPrices) parts.push(protoEmbedded(2, encodePrice(p)));
|
|
268
|
+
for (const p of hrPrices) parts.push(protoEmbedded(3, encodePrice(p)));
|
|
269
|
+
for (const addr of addrs) parts.push(protoString(4, addr));
|
|
256
270
|
return Uint8Array.from(Buffer.concat(parts));
|
|
257
271
|
}
|
|
258
272
|
|
package/protocol/messages.js
CHANGED
|
@@ -60,10 +60,10 @@ export function buildMsgStartSession({ from, nodeAddress, gigabytes = 1, hours =
|
|
|
60
60
|
typeUrl: TYPE_URLS.START_SESSION,
|
|
61
61
|
value: {
|
|
62
62
|
from,
|
|
63
|
-
|
|
63
|
+
nodeAddress,
|
|
64
64
|
gigabytes: gigabytes || 0,
|
|
65
65
|
hours: hours || 0,
|
|
66
|
-
|
|
66
|
+
maxPrice: maxPrice || undefined,
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
}
|
|
@@ -76,7 +76,7 @@ export function buildMsgStartSession({ from, nodeAddress, gigabytes = 1, hours =
|
|
|
76
76
|
export function buildMsgCancelSession({ from, id }) {
|
|
77
77
|
return {
|
|
78
78
|
typeUrl: TYPE_URLS.CANCEL_SESSION,
|
|
79
|
-
value: { from, id:
|
|
79
|
+
value: { from, id: BigInt(id) },
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -91,7 +91,7 @@ export const buildMsgEndSession = buildMsgCancelSession;
|
|
|
91
91
|
export function buildMsgUpdateSession({ from, id, downloadBytes, uploadBytes }) {
|
|
92
92
|
return {
|
|
93
93
|
typeUrl: TYPE_URLS.UPDATE_SESSION,
|
|
94
|
-
value: { from, id:
|
|
94
|
+
value: { from, id: BigInt(id), downloadBytes, uploadBytes },
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -105,7 +105,7 @@ export function buildMsgUpdateSession({ from, id, downloadBytes, uploadBytes })
|
|
|
105
105
|
export function buildMsgStartSubscription({ from, id, denom = 'udvpn', renewalPricePolicy = 0 }) {
|
|
106
106
|
return {
|
|
107
107
|
typeUrl: TYPE_URLS.START_SUBSCRIPTION,
|
|
108
|
-
value: { from, id:
|
|
108
|
+
value: { from, id: BigInt(id), denom, renewalPricePolicy },
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -117,7 +117,7 @@ export function buildMsgStartSubscription({ from, id, denom = 'udvpn', renewalPr
|
|
|
117
117
|
export function buildMsgSubStartSession({ from, id, nodeAddress }) {
|
|
118
118
|
return {
|
|
119
119
|
typeUrl: TYPE_URLS.SUB_START_SESSION,
|
|
120
|
-
value: { from, id:
|
|
120
|
+
value: { from, id: BigInt(id), nodeAddress },
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -129,7 +129,7 @@ export function buildMsgSubStartSession({ from, id, nodeAddress }) {
|
|
|
129
129
|
export function buildMsgCancelSubscription({ from, id }) {
|
|
130
130
|
return {
|
|
131
131
|
typeUrl: TYPE_URLS.CANCEL_SUBSCRIPTION,
|
|
132
|
-
value: { from, id:
|
|
132
|
+
value: { from, id: BigInt(id) },
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -141,7 +141,7 @@ export function buildMsgCancelSubscription({ from, id }) {
|
|
|
141
141
|
export function buildMsgRenewSubscription({ from, id, denom = 'udvpn' }) {
|
|
142
142
|
return {
|
|
143
143
|
typeUrl: TYPE_URLS.RENEW_SUBSCRIPTION,
|
|
144
|
-
value: { from, id:
|
|
144
|
+
value: { from, id: BigInt(id), denom },
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -153,7 +153,7 @@ export function buildMsgRenewSubscription({ from, id, denom = 'udvpn' }) {
|
|
|
153
153
|
export function buildMsgShareSubscription({ from, id, accAddress, bytes }) {
|
|
154
154
|
return {
|
|
155
155
|
typeUrl: TYPE_URLS.SHARE_SUBSCRIPTION,
|
|
156
|
-
value: { from, id:
|
|
156
|
+
value: { from, id: BigInt(id), accAddress, bytes: String(bytes) },
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -165,7 +165,7 @@ export function buildMsgShareSubscription({ from, id, accAddress, bytes }) {
|
|
|
165
165
|
export function buildMsgUpdateSubscription({ from, id, renewalPricePolicy }) {
|
|
166
166
|
return {
|
|
167
167
|
typeUrl: TYPE_URLS.UPDATE_SUBSCRIPTION,
|
|
168
|
-
value: { from, id:
|
|
168
|
+
value: { from, id: BigInt(id), renewalPricePolicy },
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -179,7 +179,7 @@ export function buildMsgUpdateSubscription({ from, id, renewalPricePolicy }) {
|
|
|
179
179
|
export function buildMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPricePolicy = 0, nodeAddress }) {
|
|
180
180
|
return {
|
|
181
181
|
typeUrl: TYPE_URLS.PLAN_START_SESSION,
|
|
182
|
-
value: { from, id:
|
|
182
|
+
value: { from, id: BigInt(id), denom, renewalPricePolicy, nodeAddress },
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -203,7 +203,7 @@ export function buildMsgCreatePlan({ from, bytes, duration, prices = [], isPriva
|
|
|
203
203
|
export function buildMsgUpdatePlanDetails({ from, id, bytes, duration, prices = [] }) {
|
|
204
204
|
return {
|
|
205
205
|
typeUrl: TYPE_URLS.UPDATE_PLAN_DETAILS,
|
|
206
|
-
value: { from, id:
|
|
206
|
+
value: { from, id: BigInt(id), bytes: bytes ? String(bytes) : undefined, duration, prices },
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -215,7 +215,7 @@ export function buildMsgUpdatePlanDetails({ from, id, bytes, duration, prices =
|
|
|
215
215
|
export function buildMsgUpdatePlanStatus({ from, id, status }) {
|
|
216
216
|
return {
|
|
217
217
|
typeUrl: TYPE_URLS.UPDATE_PLAN_STATUS,
|
|
218
|
-
value: { from, id:
|
|
218
|
+
value: { from, id: BigInt(id), status },
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
|
|
@@ -227,7 +227,7 @@ export function buildMsgUpdatePlanStatus({ from, id, status }) {
|
|
|
227
227
|
export function buildMsgLinkNode({ from, id, nodeAddress }) {
|
|
228
228
|
return {
|
|
229
229
|
typeUrl: TYPE_URLS.LINK_NODE,
|
|
230
|
-
value: { from, id:
|
|
230
|
+
value: { from, id: BigInt(id), nodeAddress },
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -239,7 +239,7 @@ export function buildMsgLinkNode({ from, id, nodeAddress }) {
|
|
|
239
239
|
export function buildMsgUnlinkNode({ from, id, nodeAddress }) {
|
|
240
240
|
return {
|
|
241
241
|
typeUrl: TYPE_URLS.UNLINK_NODE,
|
|
242
|
-
value: { from, id:
|
|
242
|
+
value: { from, id: BigInt(id), nodeAddress },
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
245
|
|
|
@@ -291,7 +291,7 @@ export function buildMsgUpdateProviderStatus({ from, status }) {
|
|
|
291
291
|
export function buildMsgStartLease({ from, nodeAddress, hours, maxPrice, renewalPricePolicy = 0 }) {
|
|
292
292
|
return {
|
|
293
293
|
typeUrl: TYPE_URLS.START_LEASE,
|
|
294
|
-
value: { from,
|
|
294
|
+
value: { from, nodeAddress, hours, maxPrice, renewalPricePolicy },
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
|
|
@@ -303,7 +303,7 @@ export function buildMsgStartLease({ from, nodeAddress, hours, maxPrice, renewal
|
|
|
303
303
|
export function buildMsgEndLease({ from, id }) {
|
|
304
304
|
return {
|
|
305
305
|
typeUrl: TYPE_URLS.END_LEASE,
|
|
306
|
-
value: { from, id:
|
|
306
|
+
value: { from, id: BigInt(id) },
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
|
|
@@ -317,7 +317,7 @@ export function buildMsgEndLease({ from, id }) {
|
|
|
317
317
|
export function buildMsgRegisterNode({ from, gigabytePrices = [], hourlyPrices = [], remoteAddrs = [] }) {
|
|
318
318
|
return {
|
|
319
319
|
typeUrl: TYPE_URLS.REGISTER_NODE,
|
|
320
|
-
value: { from,
|
|
320
|
+
value: { from, gigabytePrices, hourlyPrices, remoteAddrs },
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -329,7 +329,7 @@ export function buildMsgRegisterNode({ from, gigabytePrices = [], hourlyPrices =
|
|
|
329
329
|
export function buildMsgUpdateNodeDetails({ from, gigabytePrices = [], hourlyPrices = [], remoteAddrs = [] }) {
|
|
330
330
|
return {
|
|
331
331
|
typeUrl: TYPE_URLS.UPDATE_NODE_DETAILS,
|
|
332
|
-
value: { from,
|
|
332
|
+
value: { from, gigabytePrices, hourlyPrices, remoteAddrs },
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
335
|
|
package/protocol/plans.js
CHANGED
|
@@ -123,11 +123,12 @@ export function encodeMsgUpdatePlanStatus({ from, id, status }) {
|
|
|
123
123
|
* Link a leased node to a plan. Requires active lease for the node.
|
|
124
124
|
* from: sentprov prefix (provider address)
|
|
125
125
|
*/
|
|
126
|
-
export function encodeMsgLinkNode({ from, id, nodeAddress }) {
|
|
126
|
+
export function encodeMsgLinkNode({ from, id, nodeAddress, node_address }) {
|
|
127
|
+
const addr = nodeAddress || node_address;
|
|
127
128
|
return Uint8Array.from(Buffer.concat([
|
|
128
129
|
protoString(1, from),
|
|
129
130
|
protoUint64(2, id),
|
|
130
|
-
protoString(3,
|
|
131
|
+
protoString(3, addr),
|
|
131
132
|
]));
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -136,11 +137,12 @@ export function encodeMsgLinkNode({ from, id, nodeAddress }) {
|
|
|
136
137
|
* Remove a node from a plan.
|
|
137
138
|
* from: sentprov prefix (provider address)
|
|
138
139
|
*/
|
|
139
|
-
export function encodeMsgUnlinkNode({ from, id, nodeAddress }) {
|
|
140
|
+
export function encodeMsgUnlinkNode({ from, id, nodeAddress, node_address }) {
|
|
141
|
+
const addr = nodeAddress || node_address;
|
|
140
142
|
return Uint8Array.from(Buffer.concat([
|
|
141
143
|
protoString(1, from),
|
|
142
144
|
protoUint64(2, id),
|
|
143
|
-
protoString(3,
|
|
145
|
+
protoString(3, addr),
|
|
144
146
|
]));
|
|
145
147
|
}
|
|
146
148
|
|
|
@@ -149,14 +151,16 @@ export function encodeMsgUnlinkNode({ from, id, nodeAddress }) {
|
|
|
149
151
|
* Subscribes to a plan AND starts a session in one TX.
|
|
150
152
|
* from: sent prefix (account address)
|
|
151
153
|
*/
|
|
152
|
-
export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPricePolicy
|
|
154
|
+
export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPricePolicy, renewal_price_policy, nodeAddress, node_address }) {
|
|
155
|
+
const policy = renewalPricePolicy ?? renewal_price_policy ?? 0;
|
|
156
|
+
const addr = nodeAddress || node_address;
|
|
153
157
|
const parts = [
|
|
154
158
|
protoString(1, from),
|
|
155
159
|
protoUint64(2, id),
|
|
156
160
|
protoString(3, denom),
|
|
157
161
|
];
|
|
158
|
-
if (
|
|
159
|
-
if (
|
|
162
|
+
if (policy) parts.push(protoInt64(4, policy));
|
|
163
|
+
if (addr) parts.push(protoString(5, addr));
|
|
160
164
|
return Uint8Array.from(Buffer.concat(parts));
|
|
161
165
|
}
|
|
162
166
|
|
|
@@ -170,14 +174,17 @@ export function encodeMsgPlanStartSession({ from, id, denom = 'udvpn', renewalPr
|
|
|
170
174
|
* CRITICAL: maxPrice must EXACTLY match the node's hourly_prices from LCD.
|
|
171
175
|
* Any mismatch → "invalid price" error.
|
|
172
176
|
*/
|
|
173
|
-
export function encodeMsgStartLease({ from, nodeAddress, hours, maxPrice, renewalPricePolicy
|
|
177
|
+
export function encodeMsgStartLease({ from, nodeAddress, node_address, hours, maxPrice, max_price, renewalPricePolicy, renewal_price_policy }) {
|
|
178
|
+
const addr = nodeAddress || node_address;
|
|
179
|
+
const price = maxPrice || max_price;
|
|
180
|
+
const policy = renewalPricePolicy ?? renewal_price_policy ?? 0;
|
|
174
181
|
const parts = [
|
|
175
182
|
protoString(1, from),
|
|
176
|
-
protoString(2,
|
|
183
|
+
protoString(2, addr),
|
|
177
184
|
protoInt64(3, hours),
|
|
178
185
|
];
|
|
179
|
-
if (
|
|
180
|
-
if (
|
|
186
|
+
if (price) parts.push(protoEmbedded(4, encodePrice(price)));
|
|
187
|
+
if (policy) parts.push(protoInt64(5, policy));
|
|
181
188
|
return Uint8Array.from(Buffer.concat(parts));
|
|
182
189
|
}
|
|
183
190
|
|
package/protocol/v3.js
CHANGED
|
@@ -366,13 +366,15 @@ export function encodePrice({ denom, base_value, quote_value }) {
|
|
|
366
366
|
* 4: hours (int64, 0 if using gigabytes)
|
|
367
367
|
* 5: max_price (Price, optional) — max price user will pay per GB
|
|
368
368
|
*/
|
|
369
|
-
export function encodeMsgStartSession({ from, node_address, gigabytes = 1, hours = 0, max_price }) {
|
|
369
|
+
export function encodeMsgStartSession({ from, node_address, nodeAddress, gigabytes = 1, hours = 0, max_price, maxPrice }) {
|
|
370
|
+
const addr = node_address || nodeAddress;
|
|
371
|
+
const price = max_price || maxPrice;
|
|
370
372
|
return Uint8Array.from(Buffer.concat([
|
|
371
373
|
protoString(1, from),
|
|
372
|
-
protoString(2,
|
|
374
|
+
protoString(2, addr),
|
|
373
375
|
protoInt64(3, gigabytes),
|
|
374
376
|
hours ? protoInt64(4, hours) : Buffer.alloc(0),
|
|
375
|
-
|
|
377
|
+
price ? protoEmbedded(5, encodePrice(price)) : Buffer.alloc(0),
|
|
376
378
|
]));
|
|
377
379
|
}
|
|
378
380
|
|
|
@@ -383,13 +385,14 @@ export function encodeMsgStartSession({ from, node_address, gigabytes = 1, hours
|
|
|
383
385
|
* 3: denom (string, e.g. "udvpn")
|
|
384
386
|
* 4: renewal_price_policy (enum/int64, optional)
|
|
385
387
|
*/
|
|
386
|
-
export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalPricePolicy
|
|
388
|
+
export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalPricePolicy, renewal_price_policy }) {
|
|
389
|
+
const policy = renewalPricePolicy || renewal_price_policy || 0;
|
|
387
390
|
const parts = [
|
|
388
391
|
protoString(1, from),
|
|
389
392
|
protoInt64(2, id),
|
|
390
393
|
protoString(3, denom),
|
|
391
394
|
];
|
|
392
|
-
if (
|
|
395
|
+
if (policy) parts.push(protoInt64(4, policy));
|
|
393
396
|
return Uint8Array.from(Buffer.concat(parts));
|
|
394
397
|
}
|
|
395
398
|
|
|
@@ -399,11 +402,12 @@ export function encodeMsgStartSubscription({ from, id, denom = 'udvpn', renewalP
|
|
|
399
402
|
* 2: id (uint64, subscription ID)
|
|
400
403
|
* 3: node_address (string)
|
|
401
404
|
*/
|
|
402
|
-
export function encodeMsgSubStartSession({ from, id, nodeAddress }) {
|
|
405
|
+
export function encodeMsgSubStartSession({ from, id, nodeAddress, node_address }) {
|
|
406
|
+
const addr = nodeAddress || node_address;
|
|
403
407
|
return Uint8Array.from(Buffer.concat([
|
|
404
408
|
protoString(1, from),
|
|
405
409
|
protoInt64(2, id),
|
|
406
|
-
protoString(3,
|
|
410
|
+
protoString(3, addr),
|
|
407
411
|
]));
|
|
408
412
|
}
|
|
409
413
|
|