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,94 @@
1
+ /**
2
+ * query-nodes.mjs — Browse the Sentinel dVPN node network
3
+ *
4
+ * Query online nodes, filter by country/protocol/price, and display a formatted table.
5
+ * No wallet or tokens needed — this is read-only chain data.
6
+ *
7
+ * Usage:
8
+ * node query-nodes.mjs
9
+ * node query-nodes.mjs --country germany
10
+ * node query-nodes.mjs --protocol wireguard
11
+ * node query-nodes.mjs --country US --max-price 0.1
12
+ */
13
+
14
+ import {
15
+ queryOnlineNodes,
16
+ filterNodes,
17
+ formatPriceP2P,
18
+ countryNameToCode,
19
+ getFlagEmoji,
20
+ groupNodesByCountry,
21
+ } from 'sentinel-dvpn-sdk';
22
+
23
+ // Parse CLI flags
24
+ const args = process.argv.slice(2);
25
+ const flag = (name) => args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : null;
26
+ const countryArg = flag('country');
27
+ const protocolArg = flag('protocol'); // 'wireguard' or 'v2ray'
28
+ const maxPriceArg = flag('max-price'); // max P2P per GB (e.g. 0.1)
29
+
30
+ async function main() {
31
+ // 1. Query online nodes (probes each node for status — takes 5-15s)
32
+ console.log('Scanning Sentinel network...');
33
+ const nodes = await queryOnlineNodes({ maxNodes: 100 });
34
+ console.log(`Found ${nodes.length} online nodes\n`);
35
+
36
+ // 2. Apply filters
37
+ let filtered = nodes;
38
+ if (countryArg || protocolArg || maxPriceArg) {
39
+ filtered = filterNodes(nodes, {
40
+ country: countryArg || undefined,
41
+ serviceType: protocolArg || undefined,
42
+ maxPriceDvpn: maxPriceArg ? parseFloat(maxPriceArg) : undefined,
43
+ });
44
+ console.log(`After filters: ${filtered.length} nodes\n`);
45
+ }
46
+
47
+ // 3. Display as table
48
+ console.log(
49
+ 'Address'.padEnd(20),
50
+ 'Country'.padEnd(16),
51
+ 'Proto'.padEnd(6),
52
+ 'Price/GB'.padEnd(12),
53
+ 'Price/Hr'.padEnd(12),
54
+ 'Peers'.padEnd(6),
55
+ 'Score',
56
+ );
57
+ console.log('-'.repeat(90));
58
+
59
+ for (const node of filtered.slice(0, 30)) {
60
+ const code = countryNameToCode(node.country);
61
+ const emoji = code ? getFlagEmoji(code) : ' ';
62
+ const gbPrice = node.gigabytePrices?.find(p => p.denom === 'udvpn');
63
+ const hrPrice = node.hourlyPrices?.find(p => p.denom === 'udvpn');
64
+
65
+ console.log(
66
+ node.address.slice(0, 18).padEnd(20),
67
+ `${emoji} ${(node.country || '?').slice(0, 12)}`.padEnd(16),
68
+ (node.serviceType === 'wireguard' ? 'WG' : 'V2').padEnd(6),
69
+ (gbPrice ? `${formatPriceP2P(gbPrice.quote_value || gbPrice.base_value)} P2P` : 'N/A').padEnd(12),
70
+ (hrPrice ? `${formatPriceP2P(hrPrice.quote_value || hrPrice.base_value)} P2P` : 'N/A').padEnd(12),
71
+ String(node.peers || 0).padEnd(6),
72
+ String(node.qualityScore ?? '?'),
73
+ );
74
+ }
75
+
76
+ // 4. Country summary
77
+ console.log('\n--- Nodes by Country ---');
78
+ const groups = groupNodesByCountry(
79
+ filtered.map((n) => ({
80
+ ...n,
81
+ countryCode: countryNameToCode(n.country),
82
+ flagEmoji: getFlagEmoji(countryNameToCode(n.country) || ''),
83
+ online: true,
84
+ })),
85
+ );
86
+ for (const g of groups.slice(0, 15)) {
87
+ console.log(` ${g.flagEmoji || ' '} ${(g.country || '?').padEnd(20)} ${g.onlineCount} nodes`);
88
+ }
89
+ }
90
+
91
+ main().catch((err) => {
92
+ console.error(`Error: ${err.message}`);
93
+ process.exit(1);
94
+ });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * wallet-basics.mjs — Create a Sentinel wallet and check balance
3
+ *
4
+ * Demonstrates wallet generation, import from mnemonic, and balance queries.
5
+ * The Sentinel chain uses 'sent' prefix addresses and 'udvpn' (micro P2P) denomination.
6
+ * 1 P2P = 1,000,000 udvpn.
7
+ *
8
+ * Usage:
9
+ * node wallet-basics.mjs # Generate new wallet
10
+ * MNEMONIC="word1 word2 ..." node wallet-basics.mjs # Import existing wallet
11
+ */
12
+
13
+ import {
14
+ generateWallet,
15
+ createWallet,
16
+ createClient,
17
+ getBalance,
18
+ formatP2P,
19
+ isMnemonicValid,
20
+ DENOM,
21
+ CHAIN_ID,
22
+ } from 'sentinel-dvpn-sdk';
23
+
24
+ async function main() {
25
+ console.log(`Chain: ${CHAIN_ID} | Denom: ${DENOM}\n`);
26
+
27
+ if (process.env.MNEMONIC) {
28
+ // --- Import existing wallet ---
29
+ const mnemonic = process.env.MNEMONIC;
30
+
31
+ if (!isMnemonicValid(mnemonic)) {
32
+ console.error('Invalid mnemonic. Must be 12 or 24 BIP39 words.');
33
+ process.exit(1);
34
+ }
35
+
36
+ const { account } = await createWallet(mnemonic);
37
+ console.log('Imported wallet:');
38
+ console.log(` Address: ${account.address}`);
39
+
40
+ // Query on-chain balance
41
+ const client = await createClient(mnemonic);
42
+ const balance = await getBalance(client, account.address);
43
+ console.log(` Balance: ${formatP2P(balance.udvpn)} (${balance.udvpn} udvpn)`);
44
+ } else {
45
+ // --- Generate new wallet ---
46
+ console.log('No MNEMONIC set — generating a new wallet.\n');
47
+
48
+ const { mnemonic, account } = await generateWallet();
49
+ console.log('New wallet generated:');
50
+ console.log(` Address: ${account.address}`);
51
+ console.log(` Mnemonic: ${mnemonic}`);
52
+ console.log(` Balance: ${formatP2P(0)} (new wallet, unfunded)`);
53
+ console.log('\nSave your mnemonic securely. Fund this address with P2P tokens to use dVPN.');
54
+ console.log('You can get P2P tokens from exchanges or the Sentinel community.');
55
+ }
56
+ }
57
+
58
+ main().catch((err) => {
59
+ console.error(`Error: ${err.message}`);
60
+ process.exit(1);
61
+ });
@@ -0,0 +1,9 @@
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: amino/amino.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "amino";
@@ -0,0 +1,365 @@
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: cosmos/base/v1beta1/coin.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import { messageTypeRegistry } from "../../../typeRegistry";
10
+
11
+ export const protobufPackage = "cosmos.base.v1beta1";
12
+
13
+ /**
14
+ * Coin defines a token with a denomination and an amount.
15
+ *
16
+ * NOTE: The amount field is an Int which implements the custom method
17
+ * signatures required by gogoproto.
18
+ */
19
+ export interface Coin {
20
+ $type: "cosmos.base.v1beta1.Coin";
21
+ denom: string;
22
+ amount: string;
23
+ }
24
+
25
+ /**
26
+ * DecCoin defines a token with a denomination and a decimal amount.
27
+ *
28
+ * NOTE: The amount field is a Dec which implements the custom method
29
+ * signatures required by gogoproto.
30
+ */
31
+ export interface DecCoin {
32
+ $type: "cosmos.base.v1beta1.DecCoin";
33
+ denom: string;
34
+ amount: string;
35
+ }
36
+
37
+ /**
38
+ * IntProto defines a Protobuf wrapper around an Int object.
39
+ * Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
40
+ */
41
+ export interface IntProto {
42
+ $type: "cosmos.base.v1beta1.IntProto";
43
+ int: string;
44
+ }
45
+
46
+ /**
47
+ * DecProto defines a Protobuf wrapper around a Dec object.
48
+ * Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
49
+ */
50
+ export interface DecProto {
51
+ $type: "cosmos.base.v1beta1.DecProto";
52
+ dec: string;
53
+ }
54
+
55
+ function createBaseCoin(): Coin {
56
+ return { $type: "cosmos.base.v1beta1.Coin", denom: "", amount: "" };
57
+ }
58
+
59
+ export const Coin: MessageFns<Coin, "cosmos.base.v1beta1.Coin"> = {
60
+ $type: "cosmos.base.v1beta1.Coin" as const,
61
+
62
+ encode(message: Coin, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
63
+ if (message.denom !== "") {
64
+ writer.uint32(10).string(message.denom);
65
+ }
66
+ if (message.amount !== "") {
67
+ writer.uint32(18).string(message.amount);
68
+ }
69
+ return writer;
70
+ },
71
+
72
+ decode(input: BinaryReader | Uint8Array, length?: number): Coin {
73
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
74
+ const end = length === undefined ? reader.len : reader.pos + length;
75
+ const message = createBaseCoin();
76
+ while (reader.pos < end) {
77
+ const tag = reader.uint32();
78
+ switch (tag >>> 3) {
79
+ case 1: {
80
+ if (tag !== 10) {
81
+ break;
82
+ }
83
+
84
+ message.denom = reader.string();
85
+ continue;
86
+ }
87
+ case 2: {
88
+ if (tag !== 18) {
89
+ break;
90
+ }
91
+
92
+ message.amount = reader.string();
93
+ continue;
94
+ }
95
+ }
96
+ if ((tag & 7) === 4 || tag === 0) {
97
+ break;
98
+ }
99
+ reader.skip(tag & 7);
100
+ }
101
+ return message;
102
+ },
103
+
104
+ fromJSON(object: any): Coin {
105
+ return {
106
+ $type: Coin.$type,
107
+ denom: isSet(object.denom) ? globalThis.String(object.denom) : "",
108
+ amount: isSet(object.amount) ? globalThis.String(object.amount) : "",
109
+ };
110
+ },
111
+
112
+ toJSON(message: Coin): unknown {
113
+ const obj: any = {};
114
+ if (message.denom !== "") {
115
+ obj.denom = message.denom;
116
+ }
117
+ if (message.amount !== "") {
118
+ obj.amount = message.amount;
119
+ }
120
+ return obj;
121
+ },
122
+
123
+ create<I extends Exact<DeepPartial<Coin>, I>>(base?: I): Coin {
124
+ return Coin.fromPartial(base ?? ({} as any));
125
+ },
126
+ fromPartial<I extends Exact<DeepPartial<Coin>, I>>(object: I): Coin {
127
+ const message = createBaseCoin();
128
+ message.denom = object.denom ?? "";
129
+ message.amount = object.amount ?? "";
130
+ return message;
131
+ },
132
+ };
133
+
134
+ messageTypeRegistry.set(Coin.$type, Coin);
135
+
136
+ function createBaseDecCoin(): DecCoin {
137
+ return { $type: "cosmos.base.v1beta1.DecCoin", denom: "", amount: "" };
138
+ }
139
+
140
+ export const DecCoin: MessageFns<DecCoin, "cosmos.base.v1beta1.DecCoin"> = {
141
+ $type: "cosmos.base.v1beta1.DecCoin" as const,
142
+
143
+ encode(message: DecCoin, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
144
+ if (message.denom !== "") {
145
+ writer.uint32(10).string(message.denom);
146
+ }
147
+ if (message.amount !== "") {
148
+ writer.uint32(18).string(message.amount);
149
+ }
150
+ return writer;
151
+ },
152
+
153
+ decode(input: BinaryReader | Uint8Array, length?: number): DecCoin {
154
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
155
+ const end = length === undefined ? reader.len : reader.pos + length;
156
+ const message = createBaseDecCoin();
157
+ while (reader.pos < end) {
158
+ const tag = reader.uint32();
159
+ switch (tag >>> 3) {
160
+ case 1: {
161
+ if (tag !== 10) {
162
+ break;
163
+ }
164
+
165
+ message.denom = reader.string();
166
+ continue;
167
+ }
168
+ case 2: {
169
+ if (tag !== 18) {
170
+ break;
171
+ }
172
+
173
+ message.amount = reader.string();
174
+ continue;
175
+ }
176
+ }
177
+ if ((tag & 7) === 4 || tag === 0) {
178
+ break;
179
+ }
180
+ reader.skip(tag & 7);
181
+ }
182
+ return message;
183
+ },
184
+
185
+ fromJSON(object: any): DecCoin {
186
+ return {
187
+ $type: DecCoin.$type,
188
+ denom: isSet(object.denom) ? globalThis.String(object.denom) : "",
189
+ amount: isSet(object.amount) ? globalThis.String(object.amount) : "",
190
+ };
191
+ },
192
+
193
+ toJSON(message: DecCoin): unknown {
194
+ const obj: any = {};
195
+ if (message.denom !== "") {
196
+ obj.denom = message.denom;
197
+ }
198
+ if (message.amount !== "") {
199
+ obj.amount = message.amount;
200
+ }
201
+ return obj;
202
+ },
203
+
204
+ create<I extends Exact<DeepPartial<DecCoin>, I>>(base?: I): DecCoin {
205
+ return DecCoin.fromPartial(base ?? ({} as any));
206
+ },
207
+ fromPartial<I extends Exact<DeepPartial<DecCoin>, I>>(object: I): DecCoin {
208
+ const message = createBaseDecCoin();
209
+ message.denom = object.denom ?? "";
210
+ message.amount = object.amount ?? "";
211
+ return message;
212
+ },
213
+ };
214
+
215
+ messageTypeRegistry.set(DecCoin.$type, DecCoin);
216
+
217
+ function createBaseIntProto(): IntProto {
218
+ return { $type: "cosmos.base.v1beta1.IntProto", int: "" };
219
+ }
220
+
221
+ export const IntProto: MessageFns<IntProto, "cosmos.base.v1beta1.IntProto"> = {
222
+ $type: "cosmos.base.v1beta1.IntProto" as const,
223
+
224
+ encode(message: IntProto, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
225
+ if (message.int !== "") {
226
+ writer.uint32(10).string(message.int);
227
+ }
228
+ return writer;
229
+ },
230
+
231
+ decode(input: BinaryReader | Uint8Array, length?: number): IntProto {
232
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
233
+ const end = length === undefined ? reader.len : reader.pos + length;
234
+ const message = createBaseIntProto();
235
+ while (reader.pos < end) {
236
+ const tag = reader.uint32();
237
+ switch (tag >>> 3) {
238
+ case 1: {
239
+ if (tag !== 10) {
240
+ break;
241
+ }
242
+
243
+ message.int = reader.string();
244
+ continue;
245
+ }
246
+ }
247
+ if ((tag & 7) === 4 || tag === 0) {
248
+ break;
249
+ }
250
+ reader.skip(tag & 7);
251
+ }
252
+ return message;
253
+ },
254
+
255
+ fromJSON(object: any): IntProto {
256
+ return { $type: IntProto.$type, int: isSet(object.int) ? globalThis.String(object.int) : "" };
257
+ },
258
+
259
+ toJSON(message: IntProto): unknown {
260
+ const obj: any = {};
261
+ if (message.int !== "") {
262
+ obj.int = message.int;
263
+ }
264
+ return obj;
265
+ },
266
+
267
+ create<I extends Exact<DeepPartial<IntProto>, I>>(base?: I): IntProto {
268
+ return IntProto.fromPartial(base ?? ({} as any));
269
+ },
270
+ fromPartial<I extends Exact<DeepPartial<IntProto>, I>>(object: I): IntProto {
271
+ const message = createBaseIntProto();
272
+ message.int = object.int ?? "";
273
+ return message;
274
+ },
275
+ };
276
+
277
+ messageTypeRegistry.set(IntProto.$type, IntProto);
278
+
279
+ function createBaseDecProto(): DecProto {
280
+ return { $type: "cosmos.base.v1beta1.DecProto", dec: "" };
281
+ }
282
+
283
+ export const DecProto: MessageFns<DecProto, "cosmos.base.v1beta1.DecProto"> = {
284
+ $type: "cosmos.base.v1beta1.DecProto" as const,
285
+
286
+ encode(message: DecProto, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
287
+ if (message.dec !== "") {
288
+ writer.uint32(10).string(message.dec);
289
+ }
290
+ return writer;
291
+ },
292
+
293
+ decode(input: BinaryReader | Uint8Array, length?: number): DecProto {
294
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
295
+ const end = length === undefined ? reader.len : reader.pos + length;
296
+ const message = createBaseDecProto();
297
+ while (reader.pos < end) {
298
+ const tag = reader.uint32();
299
+ switch (tag >>> 3) {
300
+ case 1: {
301
+ if (tag !== 10) {
302
+ break;
303
+ }
304
+
305
+ message.dec = reader.string();
306
+ continue;
307
+ }
308
+ }
309
+ if ((tag & 7) === 4 || tag === 0) {
310
+ break;
311
+ }
312
+ reader.skip(tag & 7);
313
+ }
314
+ return message;
315
+ },
316
+
317
+ fromJSON(object: any): DecProto {
318
+ return { $type: DecProto.$type, dec: isSet(object.dec) ? globalThis.String(object.dec) : "" };
319
+ },
320
+
321
+ toJSON(message: DecProto): unknown {
322
+ const obj: any = {};
323
+ if (message.dec !== "") {
324
+ obj.dec = message.dec;
325
+ }
326
+ return obj;
327
+ },
328
+
329
+ create<I extends Exact<DeepPartial<DecProto>, I>>(base?: I): DecProto {
330
+ return DecProto.fromPartial(base ?? ({} as any));
331
+ },
332
+ fromPartial<I extends Exact<DeepPartial<DecProto>, I>>(object: I): DecProto {
333
+ const message = createBaseDecProto();
334
+ message.dec = object.dec ?? "";
335
+ return message;
336
+ },
337
+ };
338
+
339
+ messageTypeRegistry.set(DecProto.$type, DecProto);
340
+
341
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
342
+
343
+ export type DeepPartial<T> = T extends Builtin ? T
344
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
345
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
346
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
347
+ : Partial<T>;
348
+
349
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
350
+ export type Exact<P, I extends P> = P extends Builtin ? P
351
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
352
+
353
+ function isSet(value: any): boolean {
354
+ return value !== null && value !== undefined;
355
+ }
356
+
357
+ export interface MessageFns<T, V extends string> {
358
+ readonly $type: V;
359
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
360
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
361
+ fromJSON(object: any): T;
362
+ toJSON(message: T): unknown;
363
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
364
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
365
+ }