@quantovainc/qcore 0.1.19 → 0.1.20

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 (2) hide show
  1. package/package.json +1 -1
  2. package/shared.js +9 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantovainc/qcore",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Quantova's post quantum client core for JavaScript. Signs with ML-DSA-65 and builds Q1 addresses.",
5
5
  "scripts": {
6
6
  "build": "RUSTFLAGS=\"--remap-path-prefix=$HOME/quantova-stack=/qcore --remap-path-prefix=$HOME/.cargo=/cargo --remap-path-prefix=$HOME/.rustup=/rustup\" wasm-pack build --target bundler --out-dir pkg && RUSTFLAGS=\"--remap-path-prefix=$HOME/quantova-stack=/qcore --remap-path-prefix=$HOME/.cargo=/cargo --remap-path-prefix=$HOME/.rustup=/rustup\" wasm-pack build --target nodejs --out-dir pkg-node",
package/shared.js CHANGED
@@ -188,13 +188,15 @@ function makeClient(core) {
188
188
  _signingChainId(info) {
189
189
  const name = info && info.chain_id;
190
190
  if (!name) throw new Error('the gateway did not report a chain id to bind the signature to');
191
+ const id = BigInt(core.chainIdFromName(name));
191
192
  const configured = this.network && this.network.chainId;
192
193
  if (configured && name !== configured) {
193
194
  throw new Error(`the gateway reports chain ${name} but this client is configured for ${configured}; refusing to sign a transaction that would be valid on a network you did not choose`);
194
- } else if (!configured && !this.acknowledgeMainnet && this._isMainnetId(BigInt(core.chainIdFromName(name)))) {
195
- throw new Error(`the gateway reports the mainnet chain ${name} but this client did not choose a network; refusing to sign a mainnet transaction without acknowledgeMainnet`);
196
195
  }
197
- return BigInt(core.chainIdFromName(name));
196
+ if (!this.acknowledgeMainnet && this._isMainnetId(id)) {
197
+ throw new Error(`the gateway reports the mainnet chain ${name}; refusing to sign a mainnet transaction without acknowledgeMainnet`);
198
+ }
199
+ return id;
198
200
  }
199
201
 
200
202
  _isMainnetId(id) {
@@ -320,7 +322,7 @@ function makeClient(core) {
320
322
  if (BigInt(fee) > ceiling) {
321
323
  throw new Error(`the gateway fee ${fee} is above the maximum you allowed ${maxFeeQuon}, refusing to sign`);
322
324
  }
323
- const signer = core.orderSigner(ownerSeedHex, BigInt(ownerIndex));
325
+ const signer = core.orderSigner(ownerSeedHex, accountIndex(ownerIndex));
324
326
  const nonce = await this.contractNonce(contract, signer);
325
327
  const order = JSON.parse(core.buildTypedOrderCall(
326
328
  chainId,
@@ -331,14 +333,14 @@ function makeClient(core) {
331
333
  BigInt(orderSpec.regionOff || 0),
332
334
  JSON.stringify(orderSpec.fields || []),
333
335
  ownerSeedHex,
334
- BigInt(ownerIndex),
336
+ accountIndex(ownerIndex),
335
337
  nonce,
336
338
  ));
337
- const from = core.address(callerSeedHex, BigInt(callerIndex));
339
+ const from = core.address(callerSeedHex, accountIndex(callerIndex));
338
340
  const acct = await this.account(from);
339
341
  if (!acct || acct.nonce == null) throw new Error('the gateway did not report a nonce');
340
342
  const signed = JSON.parse(
341
- core.sign_call(callerSeedHex, BigInt(callerIndex), contract, order.call_args, BigInt(acct.nonce), BigInt(meterLimit), String(fee), chainId)
343
+ core.sign_call(callerSeedHex, accountIndex(callerIndex), contract, order.call_args, BigInt(acct.nonce), BigInt(meterLimit), String(fee), chainId)
342
344
  );
343
345
  const outcome = await this.submit(signed.tx_hex);
344
346
  return { order, signed, outcome };