kalvora.js 0.0.1-alpha.4 → 0.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project are documented here. The format follows
5
5
  [Semantic Versioning](https://semver.org/). While the version is `0.0.x`, any
6
6
  release may change APIs; pin an exact version.
7
7
 
8
+ ## [0.0.2-alpha.0] — prerelease
9
+
10
+ ### Added
11
+
12
+ - Import `kalvora.js/native` for native Kalvora queries, governance builders
13
+ and wallet operations through ESM without installing the Solana bridge.
14
+ The native and root entry points export the same SDK `VERSION`.
15
+ - Pinned Git installs generate the protobuf bindings and build the SDK during
16
+ `prepare`. The npm tarball contains the compiled entry points.
17
+
18
+ ### Changed
19
+
20
+ - **Breaking installation change for root ESM consumers.** Install
21
+ `@solana/web3.js@^1.98.4` and `@solana/spl-token@^0.4.14` alongside
22
+ `kalvora.js`. Both packages are optional peers. Native and wallet ESM
23
+ consumers can omit them. If either peer is already installed, its version
24
+ must satisfy the declared range.
25
+ - Text proposals preserve leading and trailing whitespace in the Markdown
26
+ body through signing and serialization.
27
+
8
28
  ## [0.0.1-alpha.4] — npm prerelease
9
29
 
10
30
  This npm package includes the SDK changes since npm `0.0.1-alpha.3`. Earlier
package/README.md CHANGED
@@ -56,12 +56,32 @@ or any signer you write.
56
56
  ## Install
57
57
 
58
58
  ```bash
59
- npm install kalvora.js
59
+ npm install --save-exact kalvora.js@0.0.2-alpha.0
60
60
  ```
61
61
 
62
- Use Node.js 20.19 or later for the SDK toolchain. Falcon signing requires a cryptographically secure random source in the target runtime. The Solana
63
- bridge helpers use the optional dependencies `@solana/web3.js` and
64
- `@solana/spl-token`; everything else works without them.
62
+ Use Node.js 20.19 or later for the SDK toolchain. Falcon signing requires a
63
+ cryptographically secure random source in the target runtime. The full ESM
64
+ root eagerly loads the Solana bridge. Its bridge dependencies are optional peers
65
+ and are **not installed automatically**. Use `kalvora.js/native` for native
66
+ queries and governance operations, or `kalvora.js/wallet` for keys only. Neither
67
+ entry requires the Solana packages.
68
+
69
+ Optional peers still impose package-wide version constraints when present. This
70
+ also applies to consumers importing only `/native` or `/wallet`: existing
71
+ `@solana/web3.js` must satisfy `^1.98.4`, and existing `@solana/spl-token` must
72
+ satisfy `^0.4.14`. Incompatible pinned versions can cause npm `ERESOLVE` before
73
+ any SDK code runs. This installation constraint is intentional on the alpha
74
+ development line; consumers without Solana packages need not add them.
75
+
76
+ Before using the full root ESM API or the bridge examples, install the peers:
77
+
78
+ ```bash
79
+ npm install --save-exact kalvora.js@0.0.2-alpha.0 "@solana/web3.js@^1.98.4" "@solana/spl-token@^0.4.14"
80
+ ```
81
+
82
+ Existing root ESM consumers upgrading from automatic optional dependencies must
83
+ add these two dependencies explicitly. The CommonJS bundle still contains bridge
84
+ code; use the narrow ESM entries to avoid loading it.
65
85
 
66
86
  ## Quick start
67
87
 
@@ -96,6 +116,27 @@ The wallet-only entry point exports `FalconKey` for offline key generation and r
96
116
 
97
117
  Historical Ed25519 and Ed448 backups use the [older HD derivation scheme](./docs/guides/hd-derivation.md). Generate and register a fresh Falcon address for the new genesis. See [wallet creation and backup](./src/wallet-creation/README.md).
98
118
 
119
+ ### Native entry: `kalvora.js/native`
120
+
121
+ `kalvora.js/native` is ESM-only and exports the existing native client,
122
+ governance proposal/vote builders, proposal submission, stage-fee arithmetic,
123
+ serialization, address and contract validation, RPC errors, enums, and their
124
+ types and SDK `VERSION`. For transaction construction, pass the selected network’s current finalized block-zero hash from the authenticated indexer to `pinNetwork` and use `client.grpcConfig` for the builder.
125
+ It also exposes `UniversalFeeCalculator` for callers supplying explicit native
126
+ fee metadata.
127
+
128
+ ```typescript
129
+ import { KalvoraClient, pinNetwork, buildVoteTXN, serializeTransaction } from 'kalvora.js/native';
130
+ import type { GRPCConfig, ProposalConstructionContext } from 'kalvora.js/native';
131
+ ```
132
+
133
+ An ordinary consumer install supports this entry without Solana packages or
134
+ `--omit=optional`. Building the full SDK from source, including its Git `prepare`
135
+ step, installs the bridge packages as development dependencies for its build and
136
+ tests; they are not propagated to consumers. The root exports and CommonJS
137
+ bundle retain their bridge code. This packaging boundary does not remediate
138
+ advisories in bridge consumers or remove code from the full CommonJS bundle.
139
+
99
140
  ## Querying the network
100
141
 
101
142
  `KalvoraClient` bundles the query clients behind one endpoint configuration:
@@ -216,8 +257,9 @@ function carries TSDoc. Generate the API reference with `npm run docs`
216
257
  |---|---|---|
217
258
  | `kalvora.js` | The full SDK: client, queries, wallets, signing, every transaction builder, adapters, use cases, raw protobuf bindings (`proto`) | ESM, CommonJS, React Native, types |
218
259
  | `kalvora.js/wallet` | Offline Falcon keys, address selection, signing, backup and restore, plus historical Ed mnemonic and HD derivation tools | ESM, types |
260
+ | `kalvora.js/native` | Native client and governance operations, encoding, validation and fee calculation; no optional Solana bridge import | ESM, types |
219
261
 
220
- Every public API is exported from one of these two entry points; deep imports
262
+ Every public API is exported from one of these entry points; deep imports
221
263
  into `dist/` are not supported.
222
264
 
223
265
  ## Stability
package/dist/README.md CHANGED
@@ -56,12 +56,32 @@ or any signer you write.
56
56
  ## Install
57
57
 
58
58
  ```bash
59
- npm install kalvora.js
59
+ npm install --save-exact kalvora.js@0.0.2-alpha.0
60
60
  ```
61
61
 
62
- Use Node.js 20.19 or later for the SDK toolchain. Falcon signing requires a cryptographically secure random source in the target runtime. The Solana
63
- bridge helpers use the optional dependencies `@solana/web3.js` and
64
- `@solana/spl-token`; everything else works without them.
62
+ Use Node.js 20.19 or later for the SDK toolchain. Falcon signing requires a
63
+ cryptographically secure random source in the target runtime. The full ESM
64
+ root eagerly loads the Solana bridge. Its bridge dependencies are optional peers
65
+ and are **not installed automatically**. Use `kalvora.js/native` for native
66
+ queries and governance operations, or `kalvora.js/wallet` for keys only. Neither
67
+ entry requires the Solana packages.
68
+
69
+ Optional peers still impose package-wide version constraints when present. This
70
+ also applies to consumers importing only `/native` or `/wallet`: existing
71
+ `@solana/web3.js` must satisfy `^1.98.4`, and existing `@solana/spl-token` must
72
+ satisfy `^0.4.14`. Incompatible pinned versions can cause npm `ERESOLVE` before
73
+ any SDK code runs. This installation constraint is intentional on the alpha
74
+ development line; consumers without Solana packages need not add them.
75
+
76
+ Before using the full root ESM API or the bridge examples, install the peers:
77
+
78
+ ```bash
79
+ npm install --save-exact kalvora.js@0.0.2-alpha.0 "@solana/web3.js@^1.98.4" "@solana/spl-token@^0.4.14"
80
+ ```
81
+
82
+ Existing root ESM consumers upgrading from automatic optional dependencies must
83
+ add these two dependencies explicitly. The CommonJS bundle still contains bridge
84
+ code; use the narrow ESM entries to avoid loading it.
65
85
 
66
86
  ## Quick start
67
87
 
@@ -96,6 +116,27 @@ The wallet-only entry point exports `FalconKey` for offline key generation and r
96
116
 
97
117
  Historical Ed25519 and Ed448 backups use the [older HD derivation scheme](./docs/guides/hd-derivation.md). Generate and register a fresh Falcon address for the new genesis. See [wallet creation and backup](./src/wallet-creation/README.md).
98
118
 
119
+ ### Native entry: `kalvora.js/native`
120
+
121
+ `kalvora.js/native` is ESM-only and exports the existing native client,
122
+ governance proposal/vote builders, proposal submission, stage-fee arithmetic,
123
+ serialization, address and contract validation, RPC errors, enums, and their
124
+ types and SDK `VERSION`. For transaction construction, pass the selected network’s current finalized block-zero hash from the authenticated indexer to `pinNetwork` and use `client.grpcConfig` for the builder.
125
+ It also exposes `UniversalFeeCalculator` for callers supplying explicit native
126
+ fee metadata.
127
+
128
+ ```typescript
129
+ import { KalvoraClient, pinNetwork, buildVoteTXN, serializeTransaction } from 'kalvora.js/native';
130
+ import type { GRPCConfig, ProposalConstructionContext } from 'kalvora.js/native';
131
+ ```
132
+
133
+ An ordinary consumer install supports this entry without Solana packages or
134
+ `--omit=optional`. Building the full SDK from source, including its Git `prepare`
135
+ step, installs the bridge packages as development dependencies for its build and
136
+ tests; they are not propagated to consumers. The root exports and CommonJS
137
+ bundle retain their bridge code. This packaging boundary does not remediate
138
+ advisories in bridge consumers or remove code from the full CommonJS bundle.
139
+
99
140
  ## Querying the network
100
141
 
101
142
  `KalvoraClient` bundles the query clients behind one endpoint configuration:
@@ -216,8 +257,9 @@ function carries TSDoc. Generate the API reference with `npm run docs`
216
257
  |---|---|---|
217
258
  | `kalvora.js` | The full SDK: client, queries, wallets, signing, every transaction builder, adapters, use cases, raw protobuf bindings (`proto`) | ESM, CommonJS, React Native, types |
218
259
  | `kalvora.js/wallet` | Offline Falcon keys, address selection, signing, backup and restore, plus historical Ed mnemonic and HD derivation tools | ESM, types |
260
+ | `kalvora.js/native` | Native client and governance operations, encoding, validation and fee calculation; no optional Solana bridge import | ESM, types |
219
261
 
220
- Every public API is exported from one of these two entry points; deep imports
262
+ Every public API is exported from one of these entry points; deep imports
221
263
  into `dist/` are not supported.
222
264
 
223
265
  ## Stability
package/dist/index.cjs CHANGED
@@ -19261,20 +19261,20 @@ var init_token_config = __esm({
19261
19261
 
19262
19262
  // dist/src/shared/utils/amount-utils.js
19263
19263
  function toDecimal(amount) {
19264
- if (amount instanceof decimal_default) {
19264
+ if (amount instanceof Decimal) {
19265
19265
  return amount;
19266
19266
  }
19267
19267
  if (typeof amount === "bigint") {
19268
- return new decimal_default(amount.toString());
19268
+ return new Decimal(amount.toString());
19269
19269
  }
19270
19270
  if (typeof amount === "string") {
19271
19271
  if (!/^-?\d+(\.\d+)?$/.test(amount)) {
19272
19272
  throw new Error(`Invalid amount string: ${amount}`);
19273
19273
  }
19274
- return new decimal_default(amount);
19274
+ return new Decimal(amount);
19275
19275
  }
19276
19276
  if (typeof amount === "number") {
19277
- return new decimal_default(amount.toString());
19277
+ return new Decimal(amount.toString());
19278
19278
  }
19279
19279
  throw new Error(`Invalid amount type: ${typeof amount}`);
19280
19280
  }
@@ -19284,10 +19284,10 @@ var init_amount_utils = __esm({
19284
19284
  init_decimal();
19285
19285
  init_constants3();
19286
19286
  init_token_config();
19287
- decimal_default.set({
19287
+ Decimal.set({
19288
19288
  precision: 50,
19289
19289
  // High precision for blockchain calculations
19290
- rounding: decimal_default.ROUND_DOWN,
19290
+ rounding: Decimal.ROUND_DOWN,
19291
19291
  // Always round down for blockchain safety
19292
19292
  toExpNeg: -50,
19293
19293
  // Support very small numbers
@@ -19778,10 +19778,10 @@ function calculateContractFee(protoObject, contractFeeId, contractFee, contractF
19778
19778
  throw new Error(`${label} must fit in uint256`);
19779
19779
  let transactionAmount = fee.toString();
19780
19780
  if (overestimatePercent > 0) {
19781
- const FeeDecimal = decimal_default.clone({ precision: 100 });
19781
+ const FeeDecimal = Decimal.clone({ precision: 100 });
19782
19782
  const overestimateMultiplier = new FeeDecimal(100).add(overestimatePercent).div(100);
19783
19783
  const overestimatedFeeDecimal = new FeeDecimal(transactionAmount).mul(overestimateMultiplier);
19784
- transactionAmount = overestimatedFeeDecimal.toFixed(0, decimal_default.ROUND_DOWN);
19784
+ transactionAmount = overestimatedFeeDecimal.toFixed(0, Decimal.ROUND_DOWN);
19785
19785
  }
19786
19786
  if (BigInt(transactionAmount) >= limit) {
19787
19787
  throw new Error(`${label} cap must fit in uint256`);
@@ -19834,7 +19834,7 @@ function calculateGasFee(gasFeeInUsd, baseFeeId, tokenInfoMap, multiplier) {
19834
19834
  const denomination = BigInt(tokenInfo.denomination);
19835
19835
  if (!rate || !denomination || rate >= 1n << 256n || denomination >= 1n << 256n)
19836
19836
  throw new Error("Invalid gas conversion rate or denomination");
19837
- const [whole, fraction = ""] = new decimal_default(gasFeeInUsd).toFixed().split(".");
19837
+ const [whole, fraction = ""] = new Decimal(gasFeeInUsd).toFixed().split(".");
19838
19838
  const numerator = BigInt(`${whole}${fraction}`) * 10n ** 18n * BigInt(feeMultiplier) * denomination;
19839
19839
  const denominator = rate * 10n ** BigInt(fraction.length);
19840
19840
  const parts = (numerator + denominator - 1n) / denominator;
@@ -19899,7 +19899,7 @@ async function calculateNetworkFee(protoObject, transactionType, baseFeeId = KAL
19899
19899
  const gas = gasFeeInUsd ? BigInt(calculateGasFee(gasFeeInUsd, baseFeeId, tokenInfoMap, feeMultiplier)) : 0n;
19900
19900
  if (!Number.isFinite(overestimatePercent) || overestimatePercent < 0)
19901
19901
  throw new Error("Invalid fee overestimate");
19902
- const FeeDecimal = decimal_default.clone({ precision: 100 });
19902
+ const FeeDecimal = Decimal.clone({ precision: 100 });
19903
19903
  const buffer = new FeeDecimal(100).add(overestimatePercent).div(100);
19904
19904
  base2.feeId = baseFeeId;
19905
19905
  base2.feeAmount = "1";
@@ -20025,7 +20025,7 @@ var init_universal_fee_calculator = __esm({
20025
20025
  init_unified_amount_conversion();
20026
20026
  init_exchange_rate_service();
20027
20027
  init_proof_layout();
20028
- ONE_DOLLAR = new decimal_default(10).pow(18);
20028
+ ONE_DOLLAR = new Decimal(10).pow(18);
20029
20029
  UniversalFeeCalculator = class {
20030
20030
  /**
20031
20031
  * Unified fee calculation method
@@ -20403,17 +20403,17 @@ var init_validation = __esm({
20403
20403
  }
20404
20404
  let decimalAmount;
20405
20405
  try {
20406
- if (amount instanceof decimal_default) {
20406
+ if (amount instanceof Decimal) {
20407
20407
  decimalAmount = amount;
20408
20408
  } else if (typeof amount === "string") {
20409
20409
  if (!/^-?\d+(\.\d+)?$/.test(amount)) {
20410
20410
  throw new Error("Invalid number format");
20411
20411
  }
20412
- decimalAmount = new decimal_default(amount);
20412
+ decimalAmount = new Decimal(amount);
20413
20413
  } else if (typeof amount === "number") {
20414
- decimalAmount = new decimal_default(amount.toString());
20414
+ decimalAmount = new Decimal(amount.toString());
20415
20415
  } else if (typeof amount === "bigint") {
20416
- decimalAmount = new decimal_default(amount.toString());
20416
+ decimalAmount = new Decimal(amount.toString());
20417
20417
  } else {
20418
20418
  throw new Error(`Invalid amount type: ${typeof amount}`);
20419
20419
  }
@@ -20451,7 +20451,7 @@ var init_validation = __esm({
20451
20451
  };
20452
20452
  }
20453
20453
  if (options.minAmount !== void 0) {
20454
- const minDecimal = new decimal_default(options.minAmount.toString());
20454
+ const minDecimal = new Decimal(options.minAmount.toString());
20455
20455
  if (decimalAmount.lt(minDecimal)) {
20456
20456
  const error = createValidationError(`Amount ${decimalAmount.toString()} is less than minimum ${minDecimal.toString()}`, createErrorContext(context, "validation", {
20457
20457
  amount: decimalAmount.toString(),
@@ -20468,7 +20468,7 @@ var init_validation = __esm({
20468
20468
  }
20469
20469
  }
20470
20470
  if (options.maxAmount !== void 0) {
20471
- const maxDecimal = new decimal_default(options.maxAmount.toString());
20471
+ const maxDecimal = new Decimal(options.maxAmount.toString());
20472
20472
  if (decimalAmount.gt(maxDecimal)) {
20473
20473
  const error = createValidationError(`Amount ${decimalAmount.toString()} is greater than maximum ${maxDecimal.toString()}`, createErrorContext(context, "validation", {
20474
20474
  amount: decimalAmount.toString(),
@@ -77182,7 +77182,7 @@ function validateFeePercentages(inputTransfers) {
77182
77182
  }
77183
77183
  }
77184
77184
  function scaledShare(value) {
77185
- const scaled = new decimal_default(value).mul(1e6);
77185
+ const scaled = new Decimal(value).mul(1e6);
77186
77186
  if (!scaled.isInteger() || scaled.isNegative() || scaled.gt(1e8))
77187
77187
  throw new Error("Invalid fee percentage");
77188
77188
  return scaled.toNumber();
@@ -77191,7 +77191,7 @@ async function processUnsignedInputs(inputs, contractID, tokenInfoMap, grpcConfi
77191
77191
  const publicKeys = [];
77192
77192
  const inputTransfers = [];
77193
77193
  const addresses = [];
77194
- const nonceDecimals = inputs.map((input) => new decimal_default(String(input.nonce ?? 0)));
77194
+ const nonceDecimals = inputs.map((input) => new Decimal(String(input.nonce ?? 0)));
77195
77195
  const missing = [];
77196
77196
  let isAllowance = false;
77197
77197
  const allInputsHaveNonces = inputs.every((input) => input.nonce !== void 0);
@@ -78654,7 +78654,7 @@ function validatePublicKeyLength(publicKeyIdentifier) {
78654
78654
  }
78655
78655
  }
78656
78656
  function validateText(value, field, maximumUtf8Bytes, allowLineBreaks) {
78657
- if (typeof value !== "string" || value.length === 0 || value !== value.trim() || value.normalize("NFC") !== value || !isWellFormedUnicode(value) || /\p{Cf}|\p{Zl}|\p{Zp}/u.test(value) || CONTROL_CHARACTER_PATTERN.test(value) || !allowLineBreaks && /[\t\n\r]/u.test(value) || new TextEncoder().encode(value).length > maximumUtf8Bytes) {
78657
+ if (typeof value !== "string" || value.trim().length === 0 || !allowLineBreaks && value !== value.trim() || value.normalize("NFC") !== value || !isWellFormedUnicode(value) || /\p{Cf}|\p{Zl}|\p{Zp}/u.test(value) || CONTROL_CHARACTER_PATTERN.test(value) || !allowLineBreaks && /[\t\n\r]/u.test(value) || new TextEncoder().encode(value).length > maximumUtf8Bytes) {
78658
78658
  throw new RangeError(`${field} must be non-empty canonical UTF-8 text of at most ${maximumUtf8Bytes} bytes`);
78659
78659
  }
78660
78660
  return value;
@@ -78664,7 +78664,7 @@ function isWellFormedUnicode(value) {
78664
78664
  const unit = value.charCodeAt(index);
78665
78665
  if (unit >= 55296 && unit <= 56319) {
78666
78666
  const next = value.charCodeAt(index + 1);
78667
- if (next < 56320 || next > 57343)
78667
+ if (index + 1 >= value.length || next < 56320 || next > 57343)
78668
78668
  return false;
78669
78669
  index += 1;
78670
78670
  } else if (unit >= 56320 && unit <= 57343) {
@@ -84349,7 +84349,11 @@ init_testing_defaults();
84349
84349
  init_unified_amount_conversion();
84350
84350
  init_validation();
84351
84351
  init_byte_utils();
84352
- var VERSION = "0.0.1-alpha.4";
84352
+
84353
+ // dist/src/version.js
84354
+ var VERSION = "0.0.2-alpha.0";
84355
+
84356
+ // dist/index.js
84353
84357
  var DESCRIPTION = "Kalvora JavaScript SDK";
84354
84358
  // Annotate the CommonJS export names for ESM import in node:
84355
84359
  0 && (module.exports = {