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,167 @@
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/subscription/v3/params.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import { Duration } from "../../../google/protobuf/duration";
10
+ import { messageTypeRegistry } from "../../../typeRegistry";
11
+
12
+ export const protobufPackage = "sentinel.subscription.v3";
13
+
14
+ export interface Params {
15
+ $type: "sentinel.subscription.v3.Params";
16
+ maxAllocations: number;
17
+ stakingShare: string;
18
+ statusTimeout: Duration | undefined;
19
+ }
20
+
21
+ function createBaseParams(): Params {
22
+ return { $type: "sentinel.subscription.v3.Params", maxAllocations: 0, stakingShare: "", statusTimeout: undefined };
23
+ }
24
+
25
+ export const Params: MessageFns<Params, "sentinel.subscription.v3.Params"> = {
26
+ $type: "sentinel.subscription.v3.Params" as const,
27
+
28
+ encode(message: Params, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
29
+ if (message.maxAllocations !== 0) {
30
+ writer.uint32(8).int64(message.maxAllocations);
31
+ }
32
+ if (message.stakingShare !== "") {
33
+ writer.uint32(18).string(message.stakingShare);
34
+ }
35
+ if (message.statusTimeout !== undefined) {
36
+ Duration.encode(message.statusTimeout, writer.uint32(26).fork()).join();
37
+ }
38
+ return writer;
39
+ },
40
+
41
+ decode(input: BinaryReader | Uint8Array, length?: number): Params {
42
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
43
+ const end = length === undefined ? reader.len : reader.pos + length;
44
+ const message = createBaseParams();
45
+ while (reader.pos < end) {
46
+ const tag = reader.uint32();
47
+ switch (tag >>> 3) {
48
+ case 1: {
49
+ if (tag !== 8) {
50
+ break;
51
+ }
52
+
53
+ message.maxAllocations = longToNumber(reader.int64());
54
+ continue;
55
+ }
56
+ case 2: {
57
+ if (tag !== 18) {
58
+ break;
59
+ }
60
+
61
+ message.stakingShare = reader.string();
62
+ continue;
63
+ }
64
+ case 3: {
65
+ if (tag !== 26) {
66
+ break;
67
+ }
68
+
69
+ message.statusTimeout = Duration.decode(reader, reader.uint32());
70
+ continue;
71
+ }
72
+ }
73
+ if ((tag & 7) === 4 || tag === 0) {
74
+ break;
75
+ }
76
+ reader.skip(tag & 7);
77
+ }
78
+ return message;
79
+ },
80
+
81
+ fromJSON(object: any): Params {
82
+ return {
83
+ $type: Params.$type,
84
+ maxAllocations: isSet(object.maxAllocations)
85
+ ? globalThis.Number(object.maxAllocations)
86
+ : isSet(object.max_allocations)
87
+ ? globalThis.Number(object.max_allocations)
88
+ : 0,
89
+ stakingShare: isSet(object.stakingShare)
90
+ ? globalThis.String(object.stakingShare)
91
+ : isSet(object.staking_share)
92
+ ? globalThis.String(object.staking_share)
93
+ : "",
94
+ statusTimeout: isSet(object.statusTimeout)
95
+ ? Duration.fromJSON(object.statusTimeout)
96
+ : isSet(object.status_timeout)
97
+ ? Duration.fromJSON(object.status_timeout)
98
+ : undefined,
99
+ };
100
+ },
101
+
102
+ toJSON(message: Params): unknown {
103
+ const obj: any = {};
104
+ if (message.maxAllocations !== 0) {
105
+ obj.maxAllocations = Math.round(message.maxAllocations);
106
+ }
107
+ if (message.stakingShare !== "") {
108
+ obj.stakingShare = message.stakingShare;
109
+ }
110
+ if (message.statusTimeout !== undefined) {
111
+ obj.statusTimeout = Duration.toJSON(message.statusTimeout);
112
+ }
113
+ return obj;
114
+ },
115
+
116
+ create<I extends Exact<DeepPartial<Params>, I>>(base?: I): Params {
117
+ return Params.fromPartial(base ?? ({} as any));
118
+ },
119
+ fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
120
+ const message = createBaseParams();
121
+ message.maxAllocations = object.maxAllocations ?? 0;
122
+ message.stakingShare = object.stakingShare ?? "";
123
+ message.statusTimeout = (object.statusTimeout !== undefined && object.statusTimeout !== null)
124
+ ? Duration.fromPartial(object.statusTimeout)
125
+ : undefined;
126
+ return message;
127
+ },
128
+ };
129
+
130
+ messageTypeRegistry.set(Params.$type, Params);
131
+
132
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
133
+
134
+ export type DeepPartial<T> = T extends Builtin ? T
135
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
136
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
137
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
138
+ : Partial<T>;
139
+
140
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
141
+ export type Exact<P, I extends P> = P extends Builtin ? P
142
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
143
+
144
+ function longToNumber(int64: { toString(): string }): number {
145
+ const num = globalThis.Number(int64.toString());
146
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
147
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
148
+ }
149
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
150
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
151
+ }
152
+ return num;
153
+ }
154
+
155
+ function isSet(value: any): boolean {
156
+ return value !== null && value !== undefined;
157
+ }
158
+
159
+ export interface MessageFns<T, V extends string> {
160
+ readonly $type: V;
161
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
162
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
163
+ fromJSON(object: any): T;
164
+ toJSON(message: T): unknown;
165
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
166
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
167
+ }
@@ -0,0 +1,315 @@
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/subscription/v3/subscription.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 { RenewalPricePolicy, renewalPricePolicyFromJSON, renewalPricePolicyToJSON } from "../../types/v1/renewal";
13
+ import { Status, statusFromJSON, statusToJSON } from "../../types/v1/status";
14
+
15
+ export const protobufPackage = "sentinel.subscription.v3";
16
+
17
+ export interface Subscription {
18
+ $type: "sentinel.subscription.v3.Subscription";
19
+ id: number;
20
+ accAddress: string;
21
+ planId: number;
22
+ price: Price | undefined;
23
+ renewalPricePolicy: RenewalPricePolicy;
24
+ status: Status;
25
+ inactiveAt: Date | undefined;
26
+ startAt: Date | undefined;
27
+ statusAt: Date | undefined;
28
+ }
29
+
30
+ function createBaseSubscription(): Subscription {
31
+ return {
32
+ $type: "sentinel.subscription.v3.Subscription",
33
+ id: 0,
34
+ accAddress: "",
35
+ planId: 0,
36
+ price: undefined,
37
+ renewalPricePolicy: 0,
38
+ status: 0,
39
+ inactiveAt: undefined,
40
+ startAt: undefined,
41
+ statusAt: undefined,
42
+ };
43
+ }
44
+
45
+ export const Subscription: MessageFns<Subscription, "sentinel.subscription.v3.Subscription"> = {
46
+ $type: "sentinel.subscription.v3.Subscription" as const,
47
+
48
+ encode(message: Subscription, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
49
+ if (message.id !== 0) {
50
+ writer.uint32(8).uint64(message.id);
51
+ }
52
+ if (message.accAddress !== "") {
53
+ writer.uint32(18).string(message.accAddress);
54
+ }
55
+ if (message.planId !== 0) {
56
+ writer.uint32(24).uint64(message.planId);
57
+ }
58
+ if (message.price !== undefined) {
59
+ Price.encode(message.price, writer.uint32(34).fork()).join();
60
+ }
61
+ if (message.renewalPricePolicy !== 0) {
62
+ writer.uint32(40).int32(message.renewalPricePolicy);
63
+ }
64
+ if (message.status !== 0) {
65
+ writer.uint32(48).int32(message.status);
66
+ }
67
+ if (message.inactiveAt !== undefined) {
68
+ Timestamp.encode(toTimestamp(message.inactiveAt), writer.uint32(58).fork()).join();
69
+ }
70
+ if (message.startAt !== undefined) {
71
+ Timestamp.encode(toTimestamp(message.startAt), writer.uint32(66).fork()).join();
72
+ }
73
+ if (message.statusAt !== undefined) {
74
+ Timestamp.encode(toTimestamp(message.statusAt), writer.uint32(74).fork()).join();
75
+ }
76
+ return writer;
77
+ },
78
+
79
+ decode(input: BinaryReader | Uint8Array, length?: number): Subscription {
80
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
81
+ const end = length === undefined ? reader.len : reader.pos + length;
82
+ const message = createBaseSubscription();
83
+ while (reader.pos < end) {
84
+ const tag = reader.uint32();
85
+ switch (tag >>> 3) {
86
+ case 1: {
87
+ if (tag !== 8) {
88
+ break;
89
+ }
90
+
91
+ message.id = longToNumber(reader.uint64());
92
+ continue;
93
+ }
94
+ case 2: {
95
+ if (tag !== 18) {
96
+ break;
97
+ }
98
+
99
+ message.accAddress = reader.string();
100
+ continue;
101
+ }
102
+ case 3: {
103
+ if (tag !== 24) {
104
+ break;
105
+ }
106
+
107
+ message.planId = longToNumber(reader.uint64());
108
+ continue;
109
+ }
110
+ case 4: {
111
+ if (tag !== 34) {
112
+ break;
113
+ }
114
+
115
+ message.price = Price.decode(reader, reader.uint32());
116
+ continue;
117
+ }
118
+ case 5: {
119
+ if (tag !== 40) {
120
+ break;
121
+ }
122
+
123
+ message.renewalPricePolicy = reader.int32() as any;
124
+ continue;
125
+ }
126
+ case 6: {
127
+ if (tag !== 48) {
128
+ break;
129
+ }
130
+
131
+ message.status = reader.int32() as any;
132
+ continue;
133
+ }
134
+ case 7: {
135
+ if (tag !== 58) {
136
+ break;
137
+ }
138
+
139
+ message.inactiveAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
140
+ continue;
141
+ }
142
+ case 8: {
143
+ if (tag !== 66) {
144
+ break;
145
+ }
146
+
147
+ message.startAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
148
+ continue;
149
+ }
150
+ case 9: {
151
+ if (tag !== 74) {
152
+ break;
153
+ }
154
+
155
+ message.statusAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
156
+ continue;
157
+ }
158
+ }
159
+ if ((tag & 7) === 4 || tag === 0) {
160
+ break;
161
+ }
162
+ reader.skip(tag & 7);
163
+ }
164
+ return message;
165
+ },
166
+
167
+ fromJSON(object: any): Subscription {
168
+ return {
169
+ $type: Subscription.$type,
170
+ id: isSet(object.id) ? globalThis.Number(object.id) : 0,
171
+ accAddress: isSet(object.accAddress)
172
+ ? globalThis.String(object.accAddress)
173
+ : isSet(object.acc_address)
174
+ ? globalThis.String(object.acc_address)
175
+ : "",
176
+ planId: isSet(object.planId)
177
+ ? globalThis.Number(object.planId)
178
+ : isSet(object.plan_id)
179
+ ? globalThis.Number(object.plan_id)
180
+ : 0,
181
+ price: isSet(object.price) ? Price.fromJSON(object.price) : undefined,
182
+ renewalPricePolicy: isSet(object.renewalPricePolicy)
183
+ ? renewalPricePolicyFromJSON(object.renewalPricePolicy)
184
+ : isSet(object.renewal_price_policy)
185
+ ? renewalPricePolicyFromJSON(object.renewal_price_policy)
186
+ : 0,
187
+ status: isSet(object.status) ? statusFromJSON(object.status) : 0,
188
+ inactiveAt: isSet(object.inactiveAt)
189
+ ? fromJsonTimestamp(object.inactiveAt)
190
+ : isSet(object.inactive_at)
191
+ ? fromJsonTimestamp(object.inactive_at)
192
+ : undefined,
193
+ startAt: isSet(object.startAt)
194
+ ? fromJsonTimestamp(object.startAt)
195
+ : isSet(object.start_at)
196
+ ? fromJsonTimestamp(object.start_at)
197
+ : undefined,
198
+ statusAt: isSet(object.statusAt)
199
+ ? fromJsonTimestamp(object.statusAt)
200
+ : isSet(object.status_at)
201
+ ? fromJsonTimestamp(object.status_at)
202
+ : undefined,
203
+ };
204
+ },
205
+
206
+ toJSON(message: Subscription): unknown {
207
+ const obj: any = {};
208
+ if (message.id !== 0) {
209
+ obj.id = Math.round(message.id);
210
+ }
211
+ if (message.accAddress !== "") {
212
+ obj.accAddress = message.accAddress;
213
+ }
214
+ if (message.planId !== 0) {
215
+ obj.planId = Math.round(message.planId);
216
+ }
217
+ if (message.price !== undefined) {
218
+ obj.price = Price.toJSON(message.price);
219
+ }
220
+ if (message.renewalPricePolicy !== 0) {
221
+ obj.renewalPricePolicy = renewalPricePolicyToJSON(message.renewalPricePolicy);
222
+ }
223
+ if (message.status !== 0) {
224
+ obj.status = statusToJSON(message.status);
225
+ }
226
+ if (message.inactiveAt !== undefined) {
227
+ obj.inactiveAt = message.inactiveAt.toISOString();
228
+ }
229
+ if (message.startAt !== undefined) {
230
+ obj.startAt = message.startAt.toISOString();
231
+ }
232
+ if (message.statusAt !== undefined) {
233
+ obj.statusAt = message.statusAt.toISOString();
234
+ }
235
+ return obj;
236
+ },
237
+
238
+ create<I extends Exact<DeepPartial<Subscription>, I>>(base?: I): Subscription {
239
+ return Subscription.fromPartial(base ?? ({} as any));
240
+ },
241
+ fromPartial<I extends Exact<DeepPartial<Subscription>, I>>(object: I): Subscription {
242
+ const message = createBaseSubscription();
243
+ message.id = object.id ?? 0;
244
+ message.accAddress = object.accAddress ?? "";
245
+ message.planId = object.planId ?? 0;
246
+ message.price = (object.price !== undefined && object.price !== null) ? Price.fromPartial(object.price) : undefined;
247
+ message.renewalPricePolicy = object.renewalPricePolicy ?? 0;
248
+ message.status = object.status ?? 0;
249
+ message.inactiveAt = object.inactiveAt ?? undefined;
250
+ message.startAt = object.startAt ?? undefined;
251
+ message.statusAt = object.statusAt ?? undefined;
252
+ return message;
253
+ },
254
+ };
255
+
256
+ messageTypeRegistry.set(Subscription.$type, Subscription);
257
+
258
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
259
+
260
+ export type DeepPartial<T> = T extends Builtin ? T
261
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
262
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
263
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
264
+ : Partial<T>;
265
+
266
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
267
+ export type Exact<P, I extends P> = P extends Builtin ? P
268
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
269
+
270
+ function toTimestamp(date: Date): Timestamp {
271
+ const seconds = Math.trunc(date.getTime() / 1_000);
272
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
273
+ return { $type: "google.protobuf.Timestamp", seconds, nanos };
274
+ }
275
+
276
+ function fromTimestamp(t: Timestamp): Date {
277
+ let millis = (t.seconds || 0) * 1_000;
278
+ millis += (t.nanos || 0) / 1_000_000;
279
+ return new globalThis.Date(millis);
280
+ }
281
+
282
+ function fromJsonTimestamp(o: any): Date {
283
+ if (o instanceof globalThis.Date) {
284
+ return o;
285
+ } else if (typeof o === "string") {
286
+ return new globalThis.Date(o);
287
+ } else {
288
+ return fromTimestamp(Timestamp.fromJSON(o));
289
+ }
290
+ }
291
+
292
+ function longToNumber(int64: { toString(): string }): number {
293
+ const num = globalThis.Number(int64.toString());
294
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
295
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
296
+ }
297
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
298
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
299
+ }
300
+ return num;
301
+ }
302
+
303
+ function isSet(value: any): boolean {
304
+ return value !== null && value !== undefined;
305
+ }
306
+
307
+ export interface MessageFns<T, V extends string> {
308
+ readonly $type: V;
309
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
310
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
311
+ fromJSON(object: any): T;
312
+ toJSON(message: T): unknown;
313
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
314
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
315
+ }
@@ -0,0 +1,124 @@
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/types/v1/bandwidth.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import { messageTypeRegistry } from "../../../typeRegistry";
10
+
11
+ export const protobufPackage = "sentinel.types.v1";
12
+
13
+ export interface Bandwidth {
14
+ $type: "sentinel.types.v1.Bandwidth";
15
+ upload: string;
16
+ download: string;
17
+ }
18
+
19
+ function createBaseBandwidth(): Bandwidth {
20
+ return { $type: "sentinel.types.v1.Bandwidth", upload: "", download: "" };
21
+ }
22
+
23
+ export const Bandwidth: MessageFns<Bandwidth, "sentinel.types.v1.Bandwidth"> = {
24
+ $type: "sentinel.types.v1.Bandwidth" as const,
25
+
26
+ encode(message: Bandwidth, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
27
+ if (message.upload !== "") {
28
+ writer.uint32(10).string(message.upload);
29
+ }
30
+ if (message.download !== "") {
31
+ writer.uint32(18).string(message.download);
32
+ }
33
+ return writer;
34
+ },
35
+
36
+ decode(input: BinaryReader | Uint8Array, length?: number): Bandwidth {
37
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
38
+ const end = length === undefined ? reader.len : reader.pos + length;
39
+ const message = createBaseBandwidth();
40
+ while (reader.pos < end) {
41
+ const tag = reader.uint32();
42
+ switch (tag >>> 3) {
43
+ case 1: {
44
+ if (tag !== 10) {
45
+ break;
46
+ }
47
+
48
+ message.upload = reader.string();
49
+ continue;
50
+ }
51
+ case 2: {
52
+ if (tag !== 18) {
53
+ break;
54
+ }
55
+
56
+ message.download = reader.string();
57
+ continue;
58
+ }
59
+ }
60
+ if ((tag & 7) === 4 || tag === 0) {
61
+ break;
62
+ }
63
+ reader.skip(tag & 7);
64
+ }
65
+ return message;
66
+ },
67
+
68
+ fromJSON(object: any): Bandwidth {
69
+ return {
70
+ $type: Bandwidth.$type,
71
+ upload: isSet(object.upload) ? globalThis.String(object.upload) : "",
72
+ download: isSet(object.download) ? globalThis.String(object.download) : "",
73
+ };
74
+ },
75
+
76
+ toJSON(message: Bandwidth): unknown {
77
+ const obj: any = {};
78
+ if (message.upload !== "") {
79
+ obj.upload = message.upload;
80
+ }
81
+ if (message.download !== "") {
82
+ obj.download = message.download;
83
+ }
84
+ return obj;
85
+ },
86
+
87
+ create<I extends Exact<DeepPartial<Bandwidth>, I>>(base?: I): Bandwidth {
88
+ return Bandwidth.fromPartial(base ?? ({} as any));
89
+ },
90
+ fromPartial<I extends Exact<DeepPartial<Bandwidth>, I>>(object: I): Bandwidth {
91
+ const message = createBaseBandwidth();
92
+ message.upload = object.upload ?? "";
93
+ message.download = object.download ?? "";
94
+ return message;
95
+ },
96
+ };
97
+
98
+ messageTypeRegistry.set(Bandwidth.$type, Bandwidth);
99
+
100
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
101
+
102
+ export type DeepPartial<T> = T extends Builtin ? T
103
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
104
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
105
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
106
+ : Partial<T>;
107
+
108
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
109
+ export type Exact<P, I extends P> = P extends Builtin ? P
110
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
111
+
112
+ function isSet(value: any): boolean {
113
+ return value !== null && value !== undefined;
114
+ }
115
+
116
+ export interface MessageFns<T, V extends string> {
117
+ readonly $type: V;
118
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
119
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
120
+ fromJSON(object: any): T;
121
+ toJSON(message: T): unknown;
122
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
123
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
124
+ }