blue-js-sdk 2.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.
Files changed (215) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/LICENSE +21 -0
  3. package/README.md +75 -0
  4. package/ai-path/ADMIN-ELEVATION.md +116 -0
  5. package/ai-path/AI-MANIFESTO.md +185 -0
  6. package/ai-path/BREAKING.md +74 -0
  7. package/ai-path/CHECKLIST.md +619 -0
  8. package/ai-path/CONNECTION-STEPS.md +724 -0
  9. package/ai-path/DECISION-TREE.md +378 -0
  10. package/ai-path/DEPENDENCIES.md +459 -0
  11. package/ai-path/E2E-FLOW.md +1555 -0
  12. package/ai-path/FAILURES.md +403 -0
  13. package/ai-path/GUIDE.md +1217 -0
  14. package/ai-path/README.md +558 -0
  15. package/ai-path/SPLIT-TUNNEL.md +266 -0
  16. package/ai-path/cli.js +535 -0
  17. package/ai-path/connect.js +884 -0
  18. package/ai-path/discover.js +178 -0
  19. package/ai-path/environment.js +266 -0
  20. package/ai-path/errors.js +86 -0
  21. package/ai-path/examples/autonomous-agent.mjs +220 -0
  22. package/ai-path/examples/multi-region.mjs +174 -0
  23. package/ai-path/examples/one-shot.mjs +31 -0
  24. package/ai-path/index.js +60 -0
  25. package/ai-path/pricing.js +136 -0
  26. package/ai-path/recommend.js +413 -0
  27. package/ai-path/run-admin.vbs +25 -0
  28. package/ai-path/setup.js +291 -0
  29. package/ai-path/wallet.js +137 -0
  30. package/app-helpers.js +363 -0
  31. package/app-settings.js +95 -0
  32. package/app-types.js +267 -0
  33. package/audit.js +847 -0
  34. package/batch.js +293 -0
  35. package/bin/setup.js +376 -0
  36. package/chain/authz.js +109 -0
  37. package/chain/broadcast.js +472 -0
  38. package/chain/client.js +160 -0
  39. package/chain/fee-grants.js +305 -0
  40. package/chain/index.js +891 -0
  41. package/chain/lcd.js +313 -0
  42. package/chain/queries.js +547 -0
  43. package/chain/rpc.js +408 -0
  44. package/chain/wallet.js +141 -0
  45. package/cli/config.js +143 -0
  46. package/cli/index.js +463 -0
  47. package/cli/output.js +182 -0
  48. package/cli.js +491 -0
  49. package/client/index.js +251 -0
  50. package/client.js +271 -0
  51. package/config/index.js +255 -0
  52. package/connection/connect.js +849 -0
  53. package/connection/disconnect.js +180 -0
  54. package/connection/discovery.js +321 -0
  55. package/connection/index.js +76 -0
  56. package/connection/proxy.js +148 -0
  57. package/connection/resilience.js +428 -0
  58. package/connection/security.js +232 -0
  59. package/connection/state.js +369 -0
  60. package/connection/tunnel.js +691 -0
  61. package/consumer.js +132 -0
  62. package/cosmjs-setup.js +1884 -0
  63. package/defaults.js +366 -0
  64. package/disk-cache.js +107 -0
  65. package/dist/client.d.ts +108 -0
  66. package/dist/client.d.ts.map +1 -0
  67. package/dist/client.js +400 -0
  68. package/dist/client.js.map +1 -0
  69. package/dist/index.d.ts +8 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +8 -0
  72. package/dist/index.js.map +1 -0
  73. package/errors/index.js +112 -0
  74. package/errors.js +218 -0
  75. package/examples/README.md +64 -0
  76. package/examples/connect-direct.mjs +106 -0
  77. package/examples/connect-plan.mjs +125 -0
  78. package/examples/error-handling.mjs +109 -0
  79. package/examples/query-nodes.mjs +94 -0
  80. package/examples/wallet-basics.mjs +61 -0
  81. package/generated/amino/amino.ts +9 -0
  82. package/generated/cosmos/base/v1beta1/coin.ts +365 -0
  83. package/generated/cosmos_proto/cosmos.ts +323 -0
  84. package/generated/gogoproto/gogo.ts +9 -0
  85. package/generated/google/protobuf/descriptor.ts +7601 -0
  86. package/generated/google/protobuf/duration.ts +208 -0
  87. package/generated/google/protobuf/timestamp.ts +238 -0
  88. package/generated/sentinel/lease/v1/events.ts +924 -0
  89. package/generated/sentinel/lease/v1/lease.ts +292 -0
  90. package/generated/sentinel/lease/v1/msg.ts +949 -0
  91. package/generated/sentinel/lease/v1/params.ts +164 -0
  92. package/generated/sentinel/node/v3/events.ts +881 -0
  93. package/generated/sentinel/node/v3/msg.ts +1002 -0
  94. package/generated/sentinel/node/v3/node.ts +263 -0
  95. package/generated/sentinel/node/v3/params.ts +183 -0
  96. package/generated/sentinel/plan/v3/events.ts +675 -0
  97. package/generated/sentinel/plan/v3/msg.ts +1191 -0
  98. package/generated/sentinel/plan/v3/plan.ts +283 -0
  99. package/generated/sentinel/provider/v2/events.ts +171 -0
  100. package/generated/sentinel/provider/v2/msg.ts +480 -0
  101. package/generated/sentinel/provider/v2/params.ts +131 -0
  102. package/generated/sentinel/provider/v2/provider.ts +246 -0
  103. package/generated/sentinel/session/v3/events.ts +480 -0
  104. package/generated/sentinel/session/v3/msg.ts +616 -0
  105. package/generated/sentinel/session/v3/params.ts +260 -0
  106. package/generated/sentinel/session/v3/proof.ts +180 -0
  107. package/generated/sentinel/session/v3/session.ts +384 -0
  108. package/generated/sentinel/subscription/v3/events.ts +1181 -0
  109. package/generated/sentinel/subscription/v3/msg.ts +1305 -0
  110. package/generated/sentinel/subscription/v3/params.ts +167 -0
  111. package/generated/sentinel/subscription/v3/subscription.ts +315 -0
  112. package/generated/sentinel/types/v1/bandwidth.ts +124 -0
  113. package/generated/sentinel/types/v1/price.ts +149 -0
  114. package/generated/sentinel/types/v1/renewal.ts +87 -0
  115. package/generated/sentinel/types/v1/status.ts +54 -0
  116. package/generated/typeRegistry.ts +27 -0
  117. package/index.js +486 -0
  118. package/node-connect.js +3015 -0
  119. package/operator.js +134 -0
  120. package/package.json +113 -0
  121. package/plan-operations.js +199 -0
  122. package/preflight.js +352 -0
  123. package/pricing/index.js +262 -0
  124. package/proto/amino/amino.proto +84 -0
  125. package/proto/cosmos/base/v1beta1/coin.proto +61 -0
  126. package/proto/cosmos_proto/cosmos.proto +112 -0
  127. package/proto/gogoproto/gogo.proto +145 -0
  128. package/proto/google/api/annotations.proto +31 -0
  129. package/proto/google/api/http.proto +370 -0
  130. package/proto/google/protobuf/any.proto +106 -0
  131. package/proto/google/protobuf/duration.proto +115 -0
  132. package/proto/google/protobuf/timestamp.proto +145 -0
  133. package/proto/sentinel/lease/v1/events.proto +52 -0
  134. package/proto/sentinel/lease/v1/genesis.proto +15 -0
  135. package/proto/sentinel/lease/v1/lease.proto +25 -0
  136. package/proto/sentinel/lease/v1/msg.proto +62 -0
  137. package/proto/sentinel/lease/v1/params.proto +17 -0
  138. package/proto/sentinel/node/v3/events.proto +50 -0
  139. package/proto/sentinel/node/v3/genesis.proto +15 -0
  140. package/proto/sentinel/node/v3/msg.proto +63 -0
  141. package/proto/sentinel/node/v3/node.proto +27 -0
  142. package/proto/sentinel/node/v3/params.proto +21 -0
  143. package/proto/sentinel/node/v3/querier.proto +63 -0
  144. package/proto/sentinel/plan/v3/events.proto +41 -0
  145. package/proto/sentinel/plan/v3/genesis.proto +21 -0
  146. package/proto/sentinel/plan/v3/msg.proto +83 -0
  147. package/proto/sentinel/plan/v3/plan.proto +32 -0
  148. package/proto/sentinel/plan/v3/querier.proto +53 -0
  149. package/proto/sentinel/provider/v2/events.proto +16 -0
  150. package/proto/sentinel/provider/v2/genesis.proto +15 -0
  151. package/proto/sentinel/provider/v2/msg.proto +35 -0
  152. package/proto/sentinel/provider/v2/params.proto +17 -0
  153. package/proto/sentinel/provider/v2/provider.proto +24 -0
  154. package/proto/sentinel/provider/v3/genesis.proto +15 -0
  155. package/proto/sentinel/provider/v3/params.proto +13 -0
  156. package/proto/sentinel/session/v3/events.proto +30 -0
  157. package/proto/sentinel/session/v3/genesis.proto +15 -0
  158. package/proto/sentinel/session/v3/msg.proto +50 -0
  159. package/proto/sentinel/session/v3/params.proto +25 -0
  160. package/proto/sentinel/session/v3/proof.proto +25 -0
  161. package/proto/sentinel/session/v3/querier.proto +100 -0
  162. package/proto/sentinel/session/v3/session.proto +50 -0
  163. package/proto/sentinel/subscription/v2/allocation.proto +21 -0
  164. package/proto/sentinel/subscription/v2/payout.proto +22 -0
  165. package/proto/sentinel/subscription/v3/events.proto +65 -0
  166. package/proto/sentinel/subscription/v3/genesis.proto +17 -0
  167. package/proto/sentinel/subscription/v3/msg.proto +83 -0
  168. package/proto/sentinel/subscription/v3/params.proto +21 -0
  169. package/proto/sentinel/subscription/v3/subscription.proto +33 -0
  170. package/proto/sentinel/types/v1/bandwidth.proto +19 -0
  171. package/proto/sentinel/types/v1/price.proto +21 -0
  172. package/proto/sentinel/types/v1/renewal.proto +21 -0
  173. package/proto/sentinel/types/v1/status.proto +16 -0
  174. package/protocol/encoding.js +341 -0
  175. package/protocol/events.js +361 -0
  176. package/protocol/handshake.js +297 -0
  177. package/protocol/index.js +15 -0
  178. package/protocol/messages.js +346 -0
  179. package/protocol/plans.js +199 -0
  180. package/protocol/v2ray.js +268 -0
  181. package/protocol/v3.js +723 -0
  182. package/protocol/wireguard.js +125 -0
  183. package/security/index.js +132 -0
  184. package/session-manager.js +329 -0
  185. package/session-tracker.js +80 -0
  186. package/setup.js +376 -0
  187. package/speedtest/index.js +528 -0
  188. package/speedtest.js +567 -0
  189. package/src/client.ts +502 -0
  190. package/src/index.ts +20 -0
  191. package/state/index.js +347 -0
  192. package/state.js +516 -0
  193. package/test-all-chain-ops.js +493 -0
  194. package/test-all-logic.js +199 -0
  195. package/test-all-msg-types.js +292 -0
  196. package/test-every-connection.js +208 -0
  197. package/test-feegrant-connect.js +98 -0
  198. package/test-logic.js +148 -0
  199. package/test-mainnet.js +176 -0
  200. package/test-plan-lifecycle.js +335 -0
  201. package/tls-trust.js +132 -0
  202. package/tsconfig.build.json +20 -0
  203. package/tsconfig.json +34 -0
  204. package/types/chain.d.ts +746 -0
  205. package/types/connection.d.ts +425 -0
  206. package/types/errors.d.ts +174 -0
  207. package/types/index.d.ts +1380 -0
  208. package/types/nodes.d.ts +187 -0
  209. package/types/pricing.d.ts +156 -0
  210. package/types/protocol.d.ts +332 -0
  211. package/types/session.d.ts +236 -0
  212. package/types/settings.d.ts +192 -0
  213. package/v3protocol.js +1053 -0
  214. package/wallet/index.js +153 -0
  215. package/wireguard.js +307 -0
@@ -0,0 +1,746 @@
1
+ /**
2
+ * Sentinel SDK — Chain Types
3
+ *
4
+ * Types for wallet management, chain queries, transaction broadcasting,
5
+ * fee grants, authz, and all Sentinel + Cosmos message types.
6
+ *
7
+ * Chain: sentinelhub-2 (v12.0.0, Cosmos SDK 0.47.17)
8
+ * Denom: udvpn (micro), display: P2P
9
+ */
10
+
11
+ import type { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
12
+ import type { SigningStargateClient, DeliverTxResponse } from '@cosmjs/stargate';
13
+ import type { StdFee } from '@cosmjs/amino';
14
+
15
+ // ─── Wallet ────────────────────────────────────────────────────────────────
16
+
17
+ /** Result from createWallet(). Contains the wallet and first account. */
18
+ export interface WalletResult {
19
+ /** CosmJS DirectSecp256k1HdWallet instance */
20
+ wallet: DirectSecp256k1HdWallet;
21
+ /** First account derived from the mnemonic */
22
+ account: {
23
+ /** Bech32 address with "sent" prefix (e.g. sent1abc...) */
24
+ address: string;
25
+ /** Signing algorithm (always "secp256k1") */
26
+ algo: string;
27
+ /** Compressed public key bytes */
28
+ pubkey: Uint8Array;
29
+ };
30
+ }
31
+
32
+ /** Result from generateWallet(). Includes the random mnemonic. */
33
+ export interface GenerateWalletResult {
34
+ /** BIP39 mnemonic phrase (24 words by default) */
35
+ mnemonic: string;
36
+ /** CosmJS wallet instance */
37
+ wallet: DirectSecp256k1HdWallet;
38
+ /** First account */
39
+ account: { address: string };
40
+ }
41
+
42
+ /** Wallet balance in both micro-denom and whole tokens. */
43
+ export interface WalletBalance {
44
+ /** Balance in micro-denom (1 P2P = 1,000,000 udvpn) */
45
+ udvpn: number;
46
+ /** Balance in whole tokens (human-readable) */
47
+ dvpn: number;
48
+ }
49
+
50
+ // ─── Broadcasting ──────────────────────────────────────────────────────────
51
+
52
+ /**
53
+ * Safe broadcaster with automatic sequence management.
54
+ * Prevents "account sequence mismatch" errors on rapid TX submission.
55
+ */
56
+ export interface SafeBroadcaster {
57
+ /** Broadcast messages with automatic retry on sequence mismatch */
58
+ safeBroadcast: (msgs: EncodedMsg[], memo?: string) => Promise<DeliverTxResponse>;
59
+ /** Get the underlying SigningStargateClient */
60
+ getClient: () => Promise<SigningStargateClient>;
61
+ /** Force-reconnect the RPC client (e.g. after endpoint switch) */
62
+ resetClient: () => Promise<SigningStargateClient>;
63
+ }
64
+
65
+ /** Parsed TX response for quick success/fail checks. */
66
+ export interface TxResponseSummary {
67
+ /** Whether the TX succeeded (code === 0) */
68
+ ok: boolean;
69
+ /** Transaction hash */
70
+ txHash: string;
71
+ /** Gas actually consumed */
72
+ gasUsed: number;
73
+ /** Gas limit that was set */
74
+ gasWanted: number;
75
+ }
76
+
77
+ // ─── Encoded Messages ──────────────────────────────────────────────────────
78
+
79
+ /** A CosmJS-compatible encoded message ready for broadcast. */
80
+ export interface EncodedMsg {
81
+ /** Protobuf type URL (e.g. '/sentinel.session.v3.MsgStartSessionRequest') */
82
+ typeUrl: string;
83
+ /** Encoded message value (Uint8Array for raw protobuf, object for amino) */
84
+ value: Uint8Array | Record<string, unknown>;
85
+ }
86
+
87
+ // ─── Chain Message Type URLs ───────────────────────────────────────────────
88
+
89
+ /**
90
+ * All 15 Sentinel + 5 Cosmos message type URL strings.
91
+ * Use with broadcast() and buildRegistry().
92
+ */
93
+ export const MSG_TYPES: {
94
+ readonly START_SESSION: string;
95
+ readonly END_SESSION: string;
96
+ readonly START_SUBSCRIPTION: string;
97
+ readonly SUB_START_SESSION: string;
98
+ readonly PLAN_START_SESSION: string;
99
+ readonly CREATE_PLAN: string;
100
+ readonly UPDATE_PLAN_STATUS: string;
101
+ readonly LINK_NODE: string;
102
+ readonly UNLINK_NODE: string;
103
+ readonly REGISTER_PROVIDER: string;
104
+ readonly UPDATE_PROVIDER: string;
105
+ readonly UPDATE_PROVIDER_STATUS: string;
106
+ readonly START_LEASE: string;
107
+ readonly END_LEASE: string;
108
+ readonly GRANT_FEE_ALLOWANCE: string;
109
+ readonly REVOKE_FEE_ALLOWANCE: string;
110
+ readonly AUTHZ_GRANT: string;
111
+ readonly AUTHZ_REVOKE: string;
112
+ readonly AUTHZ_EXEC: string;
113
+ };
114
+
115
+ // ─── LCD Query Helpers ─────────────────────────────────────────────────────
116
+
117
+ /** Options for lcdQuery(). */
118
+ export interface LcdQueryOptions {
119
+ /** LCD endpoint URL (default: cascading fallback) */
120
+ lcdUrl?: string;
121
+ /** Request timeout in ms (default: 15000) */
122
+ timeout?: number;
123
+ }
124
+
125
+ /** Options for lcdQueryAll() auto-pagination. */
126
+ export interface LcdQueryAllOptions extends LcdQueryOptions {
127
+ /** Items per page (default: 100) */
128
+ limit?: number;
129
+ /** JSON key containing the items array in the response */
130
+ dataKey?: string;
131
+ }
132
+
133
+ /** Result from lcdQueryAll(). */
134
+ export interface PaginatedResult<T = unknown> {
135
+ /** All fetched items across all pages */
136
+ items: T[];
137
+ /**
138
+ * Total count from chain (may be null or wrong -- Sentinel LCD pagination is unreliable).
139
+ * Do NOT trust this for display. Use items.length instead.
140
+ */
141
+ total: number | null;
142
+ }
143
+
144
+ /** Options for lcdPaginatedSafe(). Handles Sentinel's broken pagination. */
145
+ export interface LcdPaginatedSafeOptions {
146
+ /** Items per page (default: 100) */
147
+ limit?: number;
148
+ /** Fallback limit for single large request when pagination breaks (default: 5000) */
149
+ fallbackLimit?: number;
150
+ }
151
+
152
+ // ─── Chain Data Types ──────────────────────────────────────────────────────
153
+
154
+ /** Reusable price entry (denom + sdk.Dec values). Used across nodes, plans, subscriptions. */
155
+ export interface PriceEntry {
156
+ /** Token denomination (e.g. 'udvpn') */
157
+ denom: string;
158
+ /**
159
+ * Base value as sdk.Dec string (e.g. '0.003000000000000000').
160
+ * This is the per-byte or per-second rate.
161
+ */
162
+ base_value: string;
163
+ /**
164
+ * Quote value as string (e.g. '40152030').
165
+ * This is the total cost per GB or per hour in micro-denom.
166
+ */
167
+ quote_value: string;
168
+ }
169
+
170
+ /** Raw node from LCD. Note: remote_addrs is an ARRAY (v3), NOT a string. */
171
+ export interface ChainNode {
172
+ /** sentnode1... bech32 address */
173
+ address: string;
174
+ /** Array of remote URLs (v3 uses array, v2 used single string) */
175
+ remote_addrs: string[];
176
+ /** Legacy field -- some nodes still include this */
177
+ remote_url?: string;
178
+ /** Per-GB pricing entries */
179
+ gigabyte_prices: PriceEntry[];
180
+ /** Per-hour pricing entries */
181
+ hourly_prices: PriceEntry[];
182
+ /** Status integer: 1 = active, 2 = inactive */
183
+ status: number;
184
+ }
185
+
186
+ /** Raw subscription from LCD. */
187
+ export interface Subscription {
188
+ /** Subscription ID (numeric string) */
189
+ id: string;
190
+ /** Subscriber's sent1... address */
191
+ acc_address: string;
192
+ /** Plan ID if this is a plan subscription (numeric string, "0" if direct) */
193
+ plan_id: string;
194
+ /** Price paid for this subscription (null for plan subscriptions) */
195
+ price: PriceEntry | null;
196
+ /** Renewal price policy (numeric string) */
197
+ renewal_price_policy: string;
198
+ /** Status string (e.g. 'STATUS_ACTIVE') */
199
+ status: string;
200
+ /** When the subscription started (ISO timestamp) */
201
+ start_at: string;
202
+ /** When the status last changed */
203
+ status_at: string;
204
+ /** When the subscription becomes inactive */
205
+ inactive_at: string;
206
+ }
207
+
208
+ /**
209
+ * Raw session from LCD. Data is nested under base_session (v3 format).
210
+ * Use flattenSession() to get a flat object where session.id works directly.
211
+ */
212
+ export interface ChainSession {
213
+ /** Protobuf type discriminator */
214
+ '@type': string;
215
+ base_session: {
216
+ /** Session ID (numeric string) */
217
+ id: string;
218
+ /** User's sent1... address */
219
+ acc_address: string;
220
+ /** Connected node's sentnode1... address */
221
+ node_address: string;
222
+ /** Bytes downloaded (numeric string) */
223
+ download_bytes: string;
224
+ /** Bytes uploaded (numeric string) */
225
+ upload_bytes: string;
226
+ /** Maximum bytes allowed (numeric string, "0" for hourly sessions) */
227
+ max_bytes: string;
228
+ /** Current session duration (e.g. "557817.72s") */
229
+ duration: string;
230
+ /** Maximum duration (e.g. "3600s" for hourly, "0s" for GB-based) */
231
+ max_duration: string;
232
+ /** Session status string */
233
+ status: string;
234
+ /** When the session started */
235
+ start_at: string;
236
+ /** When status last changed */
237
+ status_at: string;
238
+ /** When the session becomes inactive */
239
+ inactive_at: string;
240
+ };
241
+ /** Price paid for this session */
242
+ price?: PriceEntry;
243
+ /** Subscription ID if started via subscription */
244
+ subscription_id?: string;
245
+ }
246
+
247
+ /**
248
+ * Flattened session -- base_session fields promoted to top level.
249
+ * Created by flattenSession() to prevent the #1 footgun (session.id being undefined).
250
+ */
251
+ export interface FlatSession {
252
+ id: string;
253
+ acc_address: string;
254
+ node_address: string;
255
+ download_bytes: string;
256
+ upload_bytes: string;
257
+ max_bytes: string;
258
+ duration: string;
259
+ max_duration: string;
260
+ status: string;
261
+ start_at: string;
262
+ status_at: string;
263
+ inactive_at: string;
264
+ price?: PriceEntry;
265
+ subscription_id?: string;
266
+ '@type'?: string;
267
+ /** The original nested ChainSession object */
268
+ _raw: ChainSession;
269
+ }
270
+
271
+ /** Provider details from LCD (v2 -- providers are NOT yet on v3). */
272
+ export interface Provider {
273
+ /** sentprov1... bech32 address */
274
+ address: string;
275
+ /** Provider display name */
276
+ name: string;
277
+ /** Identity (e.g. Keybase ID) */
278
+ identity: string;
279
+ /** Provider website URL */
280
+ website: string;
281
+ /** Provider description */
282
+ description: string;
283
+ /** Status integer: 1 = active, 2 = inactive */
284
+ status: number;
285
+ }
286
+
287
+ /**
288
+ * Fee grant allowance from LCD.
289
+ * Complex nested @type structure -- the SDK handles parsing for you.
290
+ */
291
+ export interface FeeGrantAllowance {
292
+ /** Granter's sent1... address (who pays gas) */
293
+ granter: string;
294
+ /** Grantee's sent1... address (who gets free gas) */
295
+ grantee: string;
296
+ allowance: {
297
+ '@type': string;
298
+ /** Direct spend limit (BasicAllowance) */
299
+ spend_limit?: Array<{ denom: string; amount: string }>;
300
+ /** Grant expiration ISO timestamp */
301
+ expiration?: string;
302
+ /** Nested basic allowance (AllowedMsgAllowance wraps BasicAllowance) */
303
+ basic?: {
304
+ spend_limit?: Array<{ denom: string; amount: string }>;
305
+ expiration?: string;
306
+ };
307
+ /** Double-nested allowance (PeriodicAllowance wraps AllowedMsgAllowance) */
308
+ allowance?: {
309
+ '@type'?: string;
310
+ spend_limit?: Array<{ denom: string; amount: string }>;
311
+ expiration?: string;
312
+ basic?: {
313
+ spend_limit?: Array<{ denom: string; amount: string }>;
314
+ expiration?: string;
315
+ };
316
+ };
317
+ };
318
+ }
319
+
320
+ /** Plan metadata from discoverPlans(). */
321
+ export interface DiscoveredPlan {
322
+ /** Plan ID */
323
+ id: number;
324
+ /** Number of active subscribers */
325
+ subscribers: number;
326
+ /** Number of linked nodes */
327
+ nodeCount: number;
328
+ /** Plan price (null if free or not configured) */
329
+ price: PriceEntry | null;
330
+ /** Whether the plan has any linked nodes */
331
+ hasNodes: boolean;
332
+ }
333
+
334
+ // ─── Fee Grant Options ─────────────────────────────────────────────────────
335
+
336
+ /** Options for building fee grant messages. */
337
+ export interface FeeGrantOptions {
338
+ /**
339
+ * Maximum spend in udvpn (number) or array of {denom, amount} Coins.
340
+ * If not set, the grant is unlimited.
341
+ */
342
+ spendLimit?: number | Array<{ denom: string; amount: string }>;
343
+ /** Grant expiration date. After this, grantee must pay their own gas. */
344
+ expiration?: Date | string;
345
+ /** Restrict grant to specific message types (type URLs). If set, only these TXs are free. */
346
+ allowedMessages?: string[];
347
+ }
348
+
349
+ /** Information about an expiring fee grant. */
350
+ export interface ExpiringGrant {
351
+ /** Granter's sent1... address */
352
+ granter: string;
353
+ /** Grantee's sent1... address */
354
+ grantee: string;
355
+ /** Expiration date (null if no expiration set) */
356
+ expiresAt: Date | null;
357
+ /** Days until expiration (null if no expiration) */
358
+ daysLeft: number | null;
359
+ }
360
+
361
+ // ─── Plan Subscriber Helpers ───────────────────────────────────────────────
362
+
363
+ /** Subscription info from queryPlanSubscribers(). */
364
+ export interface PlanSubscriber {
365
+ /** Subscriber's sent1... address */
366
+ address: string;
367
+ /** Subscription status integer */
368
+ status: number;
369
+ /** Subscription ID */
370
+ id: string;
371
+ [key: string]: unknown;
372
+ }
373
+
374
+ /** Plan stats from getPlanStats(). */
375
+ export interface PlanStats {
376
+ /** Number of non-owner subscribers */
377
+ subscriberCount: number;
378
+ /** Total on chain (may be inaccurate due to LCD bugs) */
379
+ totalOnChain: number | null;
380
+ /** Whether the plan owner is also subscribed */
381
+ ownerSubscribed: boolean;
382
+ }
383
+
384
+ // ─── Message Encoder Params ────────────────────────────────────────────────
385
+
386
+ /** Parameters for encodeMsgStartSession(). */
387
+ export interface MsgStartSessionParams {
388
+ /** Sender's sent1... address */
389
+ from: string;
390
+ /** Target node's sentnode1... address */
391
+ node_address: string;
392
+ /** Gigabytes to purchase (default: 1). Set to 0 when using hours. */
393
+ gigabytes?: number;
394
+ /** Hours to purchase. When > 0, uses hourly pricing. */
395
+ hours?: number;
396
+ /** Maximum acceptable price. If node price exceeds this, TX fails on-chain. */
397
+ max_price?: PriceEntry;
398
+ }
399
+
400
+ /** Parameters for encodeMsgEndSession(). */
401
+ export interface MsgEndSessionParams {
402
+ /** Sender's sent1... address (must be session owner) */
403
+ from: string;
404
+ /** Session ID to end */
405
+ id: number | bigint;
406
+ /** Optional rating for the node (not yet implemented on chain) */
407
+ rating?: number;
408
+ }
409
+
410
+ /** Parameters for encodeMsgStartSubscription(). */
411
+ export interface MsgStartSubscriptionParams {
412
+ /** Subscriber's sent1... address */
413
+ from: string;
414
+ /** Plan ID to subscribe to */
415
+ id: number | bigint;
416
+ /** Payment denomination (default: 'udvpn') */
417
+ denom?: string;
418
+ /** Renewal price policy (default: 0) */
419
+ renewalPricePolicy?: number;
420
+ }
421
+
422
+ /** Parameters for encodeMsgSubStartSession(). */
423
+ export interface MsgSubStartSessionParams {
424
+ /** Subscriber's sent1... address */
425
+ from: string;
426
+ /** Subscription ID */
427
+ id: number | bigint;
428
+ /** Target node's sentnode1... address */
429
+ nodeAddress: string;
430
+ }
431
+
432
+ /** Parameters for encodeMsgCancelSubscription(). */
433
+ export interface MsgCancelSubscriptionParams {
434
+ /** Subscriber's sent1... address */
435
+ from: string;
436
+ /** Subscription ID to cancel */
437
+ id: number | bigint;
438
+ }
439
+
440
+ /** Parameters for encodeMsgRenewSubscription(). */
441
+ export interface MsgRenewSubscriptionParams {
442
+ /** Subscriber's sent1... address */
443
+ from: string;
444
+ /** Subscription ID to renew */
445
+ id: number | bigint;
446
+ /** Payment denomination (default: 'udvpn') */
447
+ denom?: string;
448
+ }
449
+
450
+ /** Parameters for encodeMsgShareSubscription(). */
451
+ export interface MsgShareSubscriptionParams {
452
+ /** Sharer's sent1... address */
453
+ from: string;
454
+ /** Subscription ID */
455
+ id: number | bigint;
456
+ /** Recipient's sent1... address */
457
+ accAddress: string;
458
+ /** Bytes to share */
459
+ bytes: string | number;
460
+ }
461
+
462
+ /** Parameters for encodeMsgUpdateSubscription(). */
463
+ export interface MsgUpdateSubscriptionParams {
464
+ /** Subscriber's sent1... address */
465
+ from: string;
466
+ /** Subscription ID */
467
+ id: number | bigint;
468
+ /** New renewal price policy */
469
+ renewalPricePolicy: number;
470
+ }
471
+
472
+ /** Parameters for encodeMsgUpdateSession(). */
473
+ export interface MsgUpdateSessionParams {
474
+ /** Session owner's sent1... address */
475
+ from: string;
476
+ /** Session ID */
477
+ id: number | bigint;
478
+ /** Updated download bytes */
479
+ downloadBytes: string | number;
480
+ /** Updated upload bytes */
481
+ uploadBytes: string | number;
482
+ }
483
+
484
+ /** Parameters for encodeMsgRegisterNode(). */
485
+ export interface MsgRegisterNodeParams {
486
+ /** Node operator's sent1... address */
487
+ from: string;
488
+ /** Per-GB pricing entries */
489
+ gigabytePrices?: PriceEntry[];
490
+ /** Per-hour pricing entries */
491
+ hourlyPrices?: PriceEntry[];
492
+ /** Remote addresses (URLs) the node is reachable at */
493
+ remoteAddrs?: string[];
494
+ }
495
+
496
+ /** Parameters for encodeMsgUpdateNodeDetails(). */
497
+ export interface MsgUpdateNodeDetailsParams {
498
+ /** Node operator's sent1... address */
499
+ from: string;
500
+ /** Updated per-GB pricing */
501
+ gigabytePrices?: PriceEntry[];
502
+ /** Updated per-hour pricing */
503
+ hourlyPrices?: PriceEntry[];
504
+ /** Updated remote addresses */
505
+ remoteAddrs?: string[];
506
+ }
507
+
508
+ /** Parameters for encodeMsgUpdateNodeStatus(). */
509
+ export interface MsgUpdateNodeStatusParams {
510
+ /** Node operator's sent1... address */
511
+ from: string;
512
+ /** New status: 1 = active, 2 = inactive */
513
+ status: number;
514
+ }
515
+
516
+ /** Parameters for encodeMsgUpdatePlanDetails(). */
517
+ export interface MsgUpdatePlanDetailsParams {
518
+ /** Plan owner's sent1... address */
519
+ from: string;
520
+ /** Plan ID */
521
+ id: number | bigint;
522
+ /** New bytes allowance (string) */
523
+ bytes?: string;
524
+ /** New duration in seconds or {seconds, nanos} */
525
+ duration?: number | { seconds: number; nanos?: number };
526
+ /** New prices */
527
+ prices?: PriceEntry[];
528
+ }
529
+
530
+ /** Parameters for encodeMsgRegisterProvider(). */
531
+ export interface MsgRegisterProviderParams {
532
+ /** Provider's sent1... address */
533
+ from: string;
534
+ /** Display name */
535
+ name: string;
536
+ /** Identity (e.g. Keybase ID) */
537
+ identity?: string;
538
+ /** Website URL */
539
+ website?: string;
540
+ /** Description */
541
+ description?: string;
542
+ }
543
+
544
+ /** Parameters for encodeMsgUpdateProviderDetails(). */
545
+ export interface MsgUpdateProviderDetailsParams {
546
+ /** Provider's sent1... address */
547
+ from: string;
548
+ /** Updated name */
549
+ name?: string;
550
+ /** Updated identity */
551
+ identity?: string;
552
+ /** Updated website */
553
+ website?: string;
554
+ /** Updated description */
555
+ description?: string;
556
+ }
557
+
558
+ /** Parameters for encodeMsgUpdateProviderStatus(). */
559
+ export interface MsgUpdateProviderStatusParams {
560
+ /** Provider's sent1... address */
561
+ from: string;
562
+ /** New status: 1 = active, 2 = inactive */
563
+ status: number;
564
+ }
565
+
566
+ /** Parameters for encodeMsgCreatePlan(). */
567
+ export interface MsgCreatePlanParams {
568
+ /** Plan owner's sent1... address */
569
+ from: string;
570
+ /** Bytes allowance per subscription (string) */
571
+ bytes?: string;
572
+ /** Duration per subscription (seconds or {seconds, nanos}) */
573
+ duration?: number | { seconds: number; nanos?: number };
574
+ /** Subscription price entries */
575
+ prices?: PriceEntry[];
576
+ /** Whether the plan is private (invite-only) */
577
+ isPrivate?: boolean;
578
+ }
579
+
580
+ /** Parameters for encodeMsgUpdatePlanStatus(). */
581
+ export interface MsgUpdatePlanStatusParams {
582
+ /** Plan owner's sent1... address */
583
+ from: string;
584
+ /** Plan ID */
585
+ id: number | bigint;
586
+ /** New status: 1 = active, 2 = inactive */
587
+ status: number;
588
+ }
589
+
590
+ /** Parameters for encodeMsgLinkNode(). */
591
+ export interface MsgLinkNodeParams {
592
+ /** Plan owner's sent1... address */
593
+ from: string;
594
+ /** Plan ID */
595
+ id: number | bigint;
596
+ /** sentnode1... address of the node to link */
597
+ nodeAddress: string;
598
+ }
599
+
600
+ /** Parameters for encodeMsgUnlinkNode(). */
601
+ export interface MsgUnlinkNodeParams {
602
+ /** Plan owner's sent1... address */
603
+ from: string;
604
+ /** Plan ID */
605
+ id: number | bigint;
606
+ /** sentnode1... address of the node to unlink */
607
+ nodeAddress: string;
608
+ }
609
+
610
+ /** Parameters for encodeMsgPlanStartSession(). */
611
+ export interface MsgPlanStartSessionParams {
612
+ /** Subscriber's sent1... address */
613
+ from: string;
614
+ /** Plan ID */
615
+ id: number | bigint;
616
+ /** Payment denomination (default: 'udvpn') */
617
+ denom?: string;
618
+ /** Renewal price policy */
619
+ renewalPricePolicy?: number;
620
+ /** Target node for the session */
621
+ nodeAddress?: string;
622
+ }
623
+
624
+ /** Parameters for encodeMsgStartLease(). */
625
+ export interface MsgStartLeaseParams {
626
+ /** Lessee's sent1... address */
627
+ from: string;
628
+ /** Node to lease from (sentnode1...) */
629
+ nodeAddress: string;
630
+ /** Lease duration in hours */
631
+ hours: number;
632
+ /** Maximum acceptable price */
633
+ maxPrice?: PriceEntry;
634
+ /** Renewal price policy */
635
+ renewalPricePolicy?: number;
636
+ }
637
+
638
+ /** Parameters for encodeMsgEndLease(). */
639
+ export interface MsgEndLeaseParams {
640
+ /** Lease holder's sent1... address */
641
+ from: string;
642
+ /** Lease ID */
643
+ id: number | bigint;
644
+ }
645
+
646
+ // ─── Batch Operations ──────────────────────────────────────────────────────
647
+
648
+ /** Node configuration for buildBatchStartSession(). */
649
+ export interface BatchStartSessionNode {
650
+ /** sentnode1... address */
651
+ nodeAddress: string;
652
+ /** GB to purchase (default: 1) */
653
+ gigabytes?: number;
654
+ /** Max acceptable price (required for batch to protect against price changes) */
655
+ maxPrice: PriceEntry;
656
+ }
657
+
658
+ /** Recipient for buildBatchSend(). */
659
+ export interface BatchSendRecipient {
660
+ /** Recipient's sent1... address */
661
+ address: string;
662
+ /** Amount in micro-denom (udvpn) */
663
+ amountUdvpn: number | string;
664
+ }
665
+
666
+ /** Gas fee estimate from estimateBatchFee(). */
667
+ export interface BatchFeeEstimate {
668
+ /** Estimated gas units */
669
+ gas: number;
670
+ /** Estimated fee in micro-denom */
671
+ amount: number;
672
+ /** CosmJS-compatible StdFee object ready for broadcast */
673
+ fee: { amount: Array<{ denom: string; amount: string }>; gas: string };
674
+ }
675
+
676
+ /** Result from subscribeToPlan(). */
677
+ export interface SubscribeToPlanResult {
678
+ /** New subscription ID */
679
+ subscriptionId: bigint;
680
+ /** Transaction hash */
681
+ txHash: string;
682
+ }
683
+
684
+ /** Parsed chain duration from parseChainDuration(). */
685
+ export interface ParsedDuration {
686
+ /** Total seconds */
687
+ seconds: number;
688
+ /** Hours component */
689
+ hours: number;
690
+ /** Minutes component */
691
+ minutes: number;
692
+ /** Human-readable string (e.g. "6d 10h 57m") */
693
+ formatted: string;
694
+ }
695
+
696
+ // ─── Session Cost Estimation ───────────────────────────────────────────────
697
+
698
+ /** Result from estimateSessionCost(). */
699
+ export interface SessionCostEstimate {
700
+ /** Cost in micro-denom for the session itself */
701
+ udvpn: number;
702
+ /** Cost in whole P2P tokens */
703
+ dvpn: number;
704
+ /** Estimated gas cost in micro-denom */
705
+ gasUdvpn: number;
706
+ /** Total cost (session + gas) in micro-denom */
707
+ totalUdvpn: number;
708
+ /** Which pricing mode was selected */
709
+ mode: 'gigabyte' | 'hourly';
710
+ /** Per-hour cost in micro-denom (null if node has no hourly pricing) */
711
+ hourlyUdvpn: number | null;
712
+ /** Per-GB cost in micro-denom (null if node has no GB pricing) */
713
+ gigabyteUdvpn: number | null;
714
+ }
715
+
716
+ // ─── Endpoint Types ────────────────────────────────────────────────────────
717
+
718
+ /** RPC or LCD endpoint descriptor. */
719
+ export interface Endpoint {
720
+ /** Full URL (e.g. 'https://lcd.sentinel.co') */
721
+ url: string;
722
+ /** Human-readable name (e.g. 'Sentinel Official') */
723
+ name: string;
724
+ /** ISO date when this endpoint was last verified reachable */
725
+ verified: string;
726
+ }
727
+
728
+ /** Result from tryWithFallback(). */
729
+ export interface FallbackResult<T> {
730
+ /** The operation result from the first successful endpoint */
731
+ result: T;
732
+ /** URL of the endpoint that succeeded */
733
+ endpoint: string;
734
+ /** Name of the endpoint that succeeded */
735
+ endpointName: string;
736
+ }
737
+
738
+ /** Endpoint health check result (from checkEndpointHealth). */
739
+ export interface EndpointHealth {
740
+ /** Endpoint URL */
741
+ url: string;
742
+ /** Endpoint name */
743
+ name: string;
744
+ /** Round-trip latency in ms (null if unreachable) */
745
+ latencyMs: number | null;
746
+ }