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,263 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v7.34.0
5
+ // source: sentinel/node/v3/node.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import { Timestamp } from "../../../google/protobuf/timestamp";
10
+ import { messageTypeRegistry } from "../../../typeRegistry";
11
+ import { Price } from "../../types/v1/price";
12
+ import { Status, statusFromJSON, statusToJSON } from "../../types/v1/status";
13
+
14
+ export const protobufPackage = "sentinel.node.v3";
15
+
16
+ export interface Node {
17
+ $type: "sentinel.node.v3.Node";
18
+ address: string;
19
+ gigabytePrices: Price[];
20
+ hourlyPrices: Price[];
21
+ remoteAddrs: string[];
22
+ inactiveAt: Date | undefined;
23
+ status: Status;
24
+ statusAt: Date | undefined;
25
+ }
26
+
27
+ function createBaseNode(): Node {
28
+ return {
29
+ $type: "sentinel.node.v3.Node",
30
+ address: "",
31
+ gigabytePrices: [],
32
+ hourlyPrices: [],
33
+ remoteAddrs: [],
34
+ inactiveAt: undefined,
35
+ status: 0,
36
+ statusAt: undefined,
37
+ };
38
+ }
39
+
40
+ export const Node: MessageFns<Node, "sentinel.node.v3.Node"> = {
41
+ $type: "sentinel.node.v3.Node" as const,
42
+
43
+ encode(message: Node, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
44
+ if (message.address !== "") {
45
+ writer.uint32(10).string(message.address);
46
+ }
47
+ for (const v of message.gigabytePrices) {
48
+ Price.encode(v!, writer.uint32(18).fork()).join();
49
+ }
50
+ for (const v of message.hourlyPrices) {
51
+ Price.encode(v!, writer.uint32(26).fork()).join();
52
+ }
53
+ for (const v of message.remoteAddrs) {
54
+ writer.uint32(34).string(v!);
55
+ }
56
+ if (message.inactiveAt !== undefined) {
57
+ Timestamp.encode(toTimestamp(message.inactiveAt), writer.uint32(42).fork()).join();
58
+ }
59
+ if (message.status !== 0) {
60
+ writer.uint32(48).int32(message.status);
61
+ }
62
+ if (message.statusAt !== undefined) {
63
+ Timestamp.encode(toTimestamp(message.statusAt), writer.uint32(58).fork()).join();
64
+ }
65
+ return writer;
66
+ },
67
+
68
+ decode(input: BinaryReader | Uint8Array, length?: number): Node {
69
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
70
+ const end = length === undefined ? reader.len : reader.pos + length;
71
+ const message = createBaseNode();
72
+ while (reader.pos < end) {
73
+ const tag = reader.uint32();
74
+ switch (tag >>> 3) {
75
+ case 1: {
76
+ if (tag !== 10) {
77
+ break;
78
+ }
79
+
80
+ message.address = reader.string();
81
+ continue;
82
+ }
83
+ case 2: {
84
+ if (tag !== 18) {
85
+ break;
86
+ }
87
+
88
+ message.gigabytePrices.push(Price.decode(reader, reader.uint32()));
89
+ continue;
90
+ }
91
+ case 3: {
92
+ if (tag !== 26) {
93
+ break;
94
+ }
95
+
96
+ message.hourlyPrices.push(Price.decode(reader, reader.uint32()));
97
+ continue;
98
+ }
99
+ case 4: {
100
+ if (tag !== 34) {
101
+ break;
102
+ }
103
+
104
+ message.remoteAddrs.push(reader.string());
105
+ continue;
106
+ }
107
+ case 5: {
108
+ if (tag !== 42) {
109
+ break;
110
+ }
111
+
112
+ message.inactiveAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
113
+ continue;
114
+ }
115
+ case 6: {
116
+ if (tag !== 48) {
117
+ break;
118
+ }
119
+
120
+ message.status = reader.int32() as any;
121
+ continue;
122
+ }
123
+ case 7: {
124
+ if (tag !== 58) {
125
+ break;
126
+ }
127
+
128
+ message.statusAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
129
+ continue;
130
+ }
131
+ }
132
+ if ((tag & 7) === 4 || tag === 0) {
133
+ break;
134
+ }
135
+ reader.skip(tag & 7);
136
+ }
137
+ return message;
138
+ },
139
+
140
+ fromJSON(object: any): Node {
141
+ return {
142
+ $type: Node.$type,
143
+ address: isSet(object.address) ? globalThis.String(object.address) : "",
144
+ gigabytePrices: globalThis.Array.isArray(object?.gigabytePrices)
145
+ ? object.gigabytePrices.map((e: any) => Price.fromJSON(e))
146
+ : globalThis.Array.isArray(object?.gigabyte_prices)
147
+ ? object.gigabyte_prices.map((e: any) => Price.fromJSON(e))
148
+ : [],
149
+ hourlyPrices: globalThis.Array.isArray(object?.hourlyPrices)
150
+ ? object.hourlyPrices.map((e: any) => Price.fromJSON(e))
151
+ : globalThis.Array.isArray(object?.hourly_prices)
152
+ ? object.hourly_prices.map((e: any) => Price.fromJSON(e))
153
+ : [],
154
+ remoteAddrs: globalThis.Array.isArray(object?.remoteAddrs)
155
+ ? object.remoteAddrs.map((e: any) => globalThis.String(e))
156
+ : globalThis.Array.isArray(object?.remote_addrs)
157
+ ? object.remote_addrs.map((e: any) => globalThis.String(e))
158
+ : [],
159
+ inactiveAt: isSet(object.inactiveAt)
160
+ ? fromJsonTimestamp(object.inactiveAt)
161
+ : isSet(object.inactive_at)
162
+ ? fromJsonTimestamp(object.inactive_at)
163
+ : undefined,
164
+ status: isSet(object.status) ? statusFromJSON(object.status) : 0,
165
+ statusAt: isSet(object.statusAt)
166
+ ? fromJsonTimestamp(object.statusAt)
167
+ : isSet(object.status_at)
168
+ ? fromJsonTimestamp(object.status_at)
169
+ : undefined,
170
+ };
171
+ },
172
+
173
+ toJSON(message: Node): unknown {
174
+ const obj: any = {};
175
+ if (message.address !== "") {
176
+ obj.address = message.address;
177
+ }
178
+ if (message.gigabytePrices?.length) {
179
+ obj.gigabytePrices = message.gigabytePrices.map((e) => Price.toJSON(e));
180
+ }
181
+ if (message.hourlyPrices?.length) {
182
+ obj.hourlyPrices = message.hourlyPrices.map((e) => Price.toJSON(e));
183
+ }
184
+ if (message.remoteAddrs?.length) {
185
+ obj.remoteAddrs = message.remoteAddrs;
186
+ }
187
+ if (message.inactiveAt !== undefined) {
188
+ obj.inactiveAt = message.inactiveAt.toISOString();
189
+ }
190
+ if (message.status !== 0) {
191
+ obj.status = statusToJSON(message.status);
192
+ }
193
+ if (message.statusAt !== undefined) {
194
+ obj.statusAt = message.statusAt.toISOString();
195
+ }
196
+ return obj;
197
+ },
198
+
199
+ create<I extends Exact<DeepPartial<Node>, I>>(base?: I): Node {
200
+ return Node.fromPartial(base ?? ({} as any));
201
+ },
202
+ fromPartial<I extends Exact<DeepPartial<Node>, I>>(object: I): Node {
203
+ const message = createBaseNode();
204
+ message.address = object.address ?? "";
205
+ message.gigabytePrices = object.gigabytePrices?.map((e) => Price.fromPartial(e)) || [];
206
+ message.hourlyPrices = object.hourlyPrices?.map((e) => Price.fromPartial(e)) || [];
207
+ message.remoteAddrs = object.remoteAddrs?.map((e) => e) || [];
208
+ message.inactiveAt = object.inactiveAt ?? undefined;
209
+ message.status = object.status ?? 0;
210
+ message.statusAt = object.statusAt ?? undefined;
211
+ return message;
212
+ },
213
+ };
214
+
215
+ messageTypeRegistry.set(Node.$type, Node);
216
+
217
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
218
+
219
+ export type DeepPartial<T> = T extends Builtin ? T
220
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
221
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
222
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
223
+ : Partial<T>;
224
+
225
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
226
+ export type Exact<P, I extends P> = P extends Builtin ? P
227
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
228
+
229
+ function toTimestamp(date: Date): Timestamp {
230
+ const seconds = Math.trunc(date.getTime() / 1_000);
231
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
232
+ return { $type: "google.protobuf.Timestamp", seconds, nanos };
233
+ }
234
+
235
+ function fromTimestamp(t: Timestamp): Date {
236
+ let millis = (t.seconds || 0) * 1_000;
237
+ millis += (t.nanos || 0) / 1_000_000;
238
+ return new globalThis.Date(millis);
239
+ }
240
+
241
+ function fromJsonTimestamp(o: any): Date {
242
+ if (o instanceof globalThis.Date) {
243
+ return o;
244
+ } else if (typeof o === "string") {
245
+ return new globalThis.Date(o);
246
+ } else {
247
+ return fromTimestamp(Timestamp.fromJSON(o));
248
+ }
249
+ }
250
+
251
+ function isSet(value: any): boolean {
252
+ return value !== null && value !== undefined;
253
+ }
254
+
255
+ export interface MessageFns<T, V extends string> {
256
+ readonly $type: V;
257
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
258
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
259
+ fromJSON(object: any): T;
260
+ toJSON(message: T): unknown;
261
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
262
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
263
+ }
@@ -0,0 +1,183 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v7.34.0
5
+ // source: sentinel/node/v3/params.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import { Coin } from "../../../cosmos/base/v1beta1/coin";
10
+ import { Duration } from "../../../google/protobuf/duration";
11
+ import { messageTypeRegistry } from "../../../typeRegistry";
12
+ import { Price } from "../../types/v1/price";
13
+
14
+ export const protobufPackage = "sentinel.node.v3";
15
+
16
+ export interface Params {
17
+ $type: "sentinel.node.v3.Params";
18
+ deposit: Coin | undefined;
19
+ minGigabytePrices: Price[];
20
+ minHourlyPrices: Price[];
21
+ statusTimeout: Duration | undefined;
22
+ }
23
+
24
+ function createBaseParams(): Params {
25
+ return {
26
+ $type: "sentinel.node.v3.Params",
27
+ deposit: undefined,
28
+ minGigabytePrices: [],
29
+ minHourlyPrices: [],
30
+ statusTimeout: undefined,
31
+ };
32
+ }
33
+
34
+ export const Params: MessageFns<Params, "sentinel.node.v3.Params"> = {
35
+ $type: "sentinel.node.v3.Params" as const,
36
+
37
+ encode(message: Params, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
38
+ if (message.deposit !== undefined) {
39
+ Coin.encode(message.deposit, writer.uint32(10).fork()).join();
40
+ }
41
+ for (const v of message.minGigabytePrices) {
42
+ Price.encode(v!, writer.uint32(18).fork()).join();
43
+ }
44
+ for (const v of message.minHourlyPrices) {
45
+ Price.encode(v!, writer.uint32(26).fork()).join();
46
+ }
47
+ if (message.statusTimeout !== undefined) {
48
+ Duration.encode(message.statusTimeout, writer.uint32(34).fork()).join();
49
+ }
50
+ return writer;
51
+ },
52
+
53
+ decode(input: BinaryReader | Uint8Array, length?: number): Params {
54
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
55
+ const end = length === undefined ? reader.len : reader.pos + length;
56
+ const message = createBaseParams();
57
+ while (reader.pos < end) {
58
+ const tag = reader.uint32();
59
+ switch (tag >>> 3) {
60
+ case 1: {
61
+ if (tag !== 10) {
62
+ break;
63
+ }
64
+
65
+ message.deposit = Coin.decode(reader, reader.uint32());
66
+ continue;
67
+ }
68
+ case 2: {
69
+ if (tag !== 18) {
70
+ break;
71
+ }
72
+
73
+ message.minGigabytePrices.push(Price.decode(reader, reader.uint32()));
74
+ continue;
75
+ }
76
+ case 3: {
77
+ if (tag !== 26) {
78
+ break;
79
+ }
80
+
81
+ message.minHourlyPrices.push(Price.decode(reader, reader.uint32()));
82
+ continue;
83
+ }
84
+ case 4: {
85
+ if (tag !== 34) {
86
+ break;
87
+ }
88
+
89
+ message.statusTimeout = Duration.decode(reader, reader.uint32());
90
+ continue;
91
+ }
92
+ }
93
+ if ((tag & 7) === 4 || tag === 0) {
94
+ break;
95
+ }
96
+ reader.skip(tag & 7);
97
+ }
98
+ return message;
99
+ },
100
+
101
+ fromJSON(object: any): Params {
102
+ return {
103
+ $type: Params.$type,
104
+ deposit: isSet(object.deposit) ? Coin.fromJSON(object.deposit) : undefined,
105
+ minGigabytePrices: globalThis.Array.isArray(object?.minGigabytePrices)
106
+ ? object.minGigabytePrices.map((e: any) => Price.fromJSON(e))
107
+ : globalThis.Array.isArray(object?.min_gigabyte_prices)
108
+ ? object.min_gigabyte_prices.map((e: any) => Price.fromJSON(e))
109
+ : [],
110
+ minHourlyPrices: globalThis.Array.isArray(object?.minHourlyPrices)
111
+ ? object.minHourlyPrices.map((e: any) => Price.fromJSON(e))
112
+ : globalThis.Array.isArray(object?.min_hourly_prices)
113
+ ? object.min_hourly_prices.map((e: any) => Price.fromJSON(e))
114
+ : [],
115
+ statusTimeout: isSet(object.statusTimeout)
116
+ ? Duration.fromJSON(object.statusTimeout)
117
+ : isSet(object.status_timeout)
118
+ ? Duration.fromJSON(object.status_timeout)
119
+ : undefined,
120
+ };
121
+ },
122
+
123
+ toJSON(message: Params): unknown {
124
+ const obj: any = {};
125
+ if (message.deposit !== undefined) {
126
+ obj.deposit = Coin.toJSON(message.deposit);
127
+ }
128
+ if (message.minGigabytePrices?.length) {
129
+ obj.minGigabytePrices = message.minGigabytePrices.map((e) => Price.toJSON(e));
130
+ }
131
+ if (message.minHourlyPrices?.length) {
132
+ obj.minHourlyPrices = message.minHourlyPrices.map((e) => Price.toJSON(e));
133
+ }
134
+ if (message.statusTimeout !== undefined) {
135
+ obj.statusTimeout = Duration.toJSON(message.statusTimeout);
136
+ }
137
+ return obj;
138
+ },
139
+
140
+ create<I extends Exact<DeepPartial<Params>, I>>(base?: I): Params {
141
+ return Params.fromPartial(base ?? ({} as any));
142
+ },
143
+ fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
144
+ const message = createBaseParams();
145
+ message.deposit = (object.deposit !== undefined && object.deposit !== null)
146
+ ? Coin.fromPartial(object.deposit)
147
+ : undefined;
148
+ message.minGigabytePrices = object.minGigabytePrices?.map((e) => Price.fromPartial(e)) || [];
149
+ message.minHourlyPrices = object.minHourlyPrices?.map((e) => Price.fromPartial(e)) || [];
150
+ message.statusTimeout = (object.statusTimeout !== undefined && object.statusTimeout !== null)
151
+ ? Duration.fromPartial(object.statusTimeout)
152
+ : undefined;
153
+ return message;
154
+ },
155
+ };
156
+
157
+ messageTypeRegistry.set(Params.$type, Params);
158
+
159
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
160
+
161
+ export type DeepPartial<T> = T extends Builtin ? T
162
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
163
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
164
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
165
+ : Partial<T>;
166
+
167
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
168
+ export type Exact<P, I extends P> = P extends Builtin ? P
169
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
170
+
171
+ function isSet(value: any): boolean {
172
+ return value !== null && value !== undefined;
173
+ }
174
+
175
+ export interface MessageFns<T, V extends string> {
176
+ readonly $type: V;
177
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
178
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
179
+ fromJSON(object: any): T;
180
+ toJSON(message: T): unknown;
181
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
182
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
183
+ }