@lucid-evolution/provider 0.1.6 → 0.1.8

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/dist/index.cjs CHANGED
@@ -45,7 +45,7 @@ var import_utils = require("@lucid-evolution/utils");
45
45
  // package.json
46
46
  var package_default = {
47
47
  name: "@lucid-evolution/provider",
48
- version: "0.1.6",
48
+ version: "0.1.8",
49
49
  description: "",
50
50
  main: "./dist/index.js",
51
51
  types: "./dist/index.d.ts",
@@ -359,9 +359,7 @@ var Kupmios = class {
359
359
  this.ogmiosUrl = ogmiosUrl;
360
360
  }
361
361
  async getProtocolParameters() {
362
- const client = await this.ogmiosWsp("Query", {
363
- query: "currentProtocolParameters"
364
- });
362
+ const client = await this.ogmiosWsp("queryLedgerState/protocolParameters");
365
363
  return new Promise((res, rej) => {
366
364
  client.addEventListener(
367
365
  "message",
@@ -369,27 +367,30 @@ var Kupmios = class {
369
367
  try {
370
368
  const { result } = JSON.parse(msg.data);
371
369
  const costModels = {};
372
- Object.keys(result.costModels).forEach((v) => {
370
+ Object.keys(result.plutusCostModels).forEach((v) => {
373
371
  const version = v.split(":")[1].toUpperCase();
374
372
  const plutusVersion = "Plutus" + version;
375
- costModels[plutusVersion] = result.costModels[v];
373
+ costModels[plutusVersion] = result.plutusCostModels[v];
376
374
  });
377
- const [memNum, memDenom] = result.prices.memory.split("/");
378
- const [stepsNum, stepsDenom] = result.prices.steps.split("/");
375
+ const [memNum, memDenom] = result.scriptExecutionPrices.memory.split("/");
376
+ const [stepsNum, stepsDenom] = result.scriptExecutionPrices.cpu.split("/");
379
377
  res({
380
378
  minFeeA: parseInt(result.minFeeCoefficient),
381
- minFeeB: parseInt(result.minFeeConstant),
379
+ minFeeB: parseInt(result.minFeeConstant.ada.lovelace),
382
380
  maxTxSize: parseInt(result.maxTxSize),
383
381
  maxValSize: parseInt(result.maxValueSize),
384
- keyDeposit: BigInt(result.stakeKeyDeposit),
385
- poolDeposit: BigInt(result.poolDeposit),
382
+ keyDeposit: BigInt(result.stakeCredentialDeposit.ada.lovelace),
383
+ poolDeposit: BigInt(result.stakePoolDeposit.ada.lovelace),
386
384
  priceMem: parseInt(memNum) / parseInt(memDenom),
387
385
  priceStep: parseInt(stepsNum) / parseInt(stepsDenom),
388
386
  maxTxExMem: BigInt(result.maxExecutionUnitsPerTransaction.memory),
389
- maxTxExSteps: BigInt(
390
- result.maxExecutionUnitsPerTransaction.steps
391
- ),
392
- coinsPerUtxoByte: BigInt(result.coinsPerUtxoByte),
387
+ maxTxExSteps: BigInt(result.maxExecutionUnitsPerTransaction.cpu),
388
+ // NOTE: coinsPerUtxoByte is now called utxoCostPerByte:
389
+ // https://github.com/IntersectMBO/cardano-node/pull/4141
390
+ // Ogmios v6.x calls it minUtxoDepositCoefficient according to the following
391
+ // documentation from its protocol parameters data model:
392
+ // https://github.com/CardanoSolutions/ogmios/blob/master/architectural-decisions/accepted/017-api-version-6-major-rewrite.md#protocol-parameters
393
+ coinsPerUtxoByte: BigInt(result.minUtxoDepositCoefficient),
393
394
  collateralPercentage: parseInt(result.collateralPercentage),
394
395
  maxCollateralInputs: parseInt(result.maxCollateralInputs),
395
396
  costModels
@@ -448,9 +449,10 @@ var Kupmios = class {
448
449
  );
449
450
  }
450
451
  async getDelegation(rewardAddress) {
451
- const client = await this.ogmiosWsp("Query", {
452
- query: { delegationsAndRewards: [rewardAddress] }
453
- });
452
+ const client = await this.ogmiosWsp(
453
+ "queryLedgerState/rewardAccountSummaries",
454
+ { keys: [rewardAddress] }
455
+ );
454
456
  return new Promise((res, rej) => {
455
457
  client.addEventListener(
456
458
  "message",
@@ -459,8 +461,8 @@ var Kupmios = class {
459
461
  const { result } = JSON.parse(msg.data);
460
462
  const delegation = result ? Object.values(result)[0] : {};
461
463
  res({
462
- poolId: delegation?.delegate || null,
463
- rewards: BigInt(delegation?.rewards || 0)
464
+ poolId: delegation?.delegate?.id || null,
465
+ rewards: BigInt(delegation?.rewards?.ada?.lovelace || 0)
464
466
  });
465
467
  client.close();
466
468
  } catch (e) {
@@ -555,18 +557,17 @@ var Kupmios = class {
555
557
  })
556
558
  );
557
559
  }
558
- async ogmiosWsp(methodname, args) {
560
+ async ogmiosWsp(method, params = {}, id) {
559
561
  const client = new WebSocket(this.ogmiosUrl);
560
562
  await new Promise((res) => {
561
563
  client.addEventListener("open", () => res(1), { once: true });
562
564
  });
563
565
  client.send(
564
566
  JSON.stringify({
565
- type: "jsonwsp/request",
566
- version: "1.0",
567
- servicename: "ogmios",
568
- methodname,
569
- args
567
+ jsonrpc: "2.0",
568
+ method,
569
+ params,
570
+ id
570
571
  })
571
572
  );
572
573
  return client;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { applyDoubleCborEncoding } from "@lucid-evolution/utils";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@lucid-evolution/provider",
9
- version: "0.1.6",
9
+ version: "0.1.8",
10
10
  description: "",
11
11
  main: "./dist/index.js",
12
12
  types: "./dist/index.d.ts",
@@ -320,9 +320,7 @@ var Kupmios = class {
320
320
  this.ogmiosUrl = ogmiosUrl;
321
321
  }
322
322
  async getProtocolParameters() {
323
- const client = await this.ogmiosWsp("Query", {
324
- query: "currentProtocolParameters"
325
- });
323
+ const client = await this.ogmiosWsp("queryLedgerState/protocolParameters");
326
324
  return new Promise((res, rej) => {
327
325
  client.addEventListener(
328
326
  "message",
@@ -330,27 +328,30 @@ var Kupmios = class {
330
328
  try {
331
329
  const { result } = JSON.parse(msg.data);
332
330
  const costModels = {};
333
- Object.keys(result.costModels).forEach((v) => {
331
+ Object.keys(result.plutusCostModels).forEach((v) => {
334
332
  const version = v.split(":")[1].toUpperCase();
335
333
  const plutusVersion = "Plutus" + version;
336
- costModels[plutusVersion] = result.costModels[v];
334
+ costModels[plutusVersion] = result.plutusCostModels[v];
337
335
  });
338
- const [memNum, memDenom] = result.prices.memory.split("/");
339
- const [stepsNum, stepsDenom] = result.prices.steps.split("/");
336
+ const [memNum, memDenom] = result.scriptExecutionPrices.memory.split("/");
337
+ const [stepsNum, stepsDenom] = result.scriptExecutionPrices.cpu.split("/");
340
338
  res({
341
339
  minFeeA: parseInt(result.minFeeCoefficient),
342
- minFeeB: parseInt(result.minFeeConstant),
340
+ minFeeB: parseInt(result.minFeeConstant.ada.lovelace),
343
341
  maxTxSize: parseInt(result.maxTxSize),
344
342
  maxValSize: parseInt(result.maxValueSize),
345
- keyDeposit: BigInt(result.stakeKeyDeposit),
346
- poolDeposit: BigInt(result.poolDeposit),
343
+ keyDeposit: BigInt(result.stakeCredentialDeposit.ada.lovelace),
344
+ poolDeposit: BigInt(result.stakePoolDeposit.ada.lovelace),
347
345
  priceMem: parseInt(memNum) / parseInt(memDenom),
348
346
  priceStep: parseInt(stepsNum) / parseInt(stepsDenom),
349
347
  maxTxExMem: BigInt(result.maxExecutionUnitsPerTransaction.memory),
350
- maxTxExSteps: BigInt(
351
- result.maxExecutionUnitsPerTransaction.steps
352
- ),
353
- coinsPerUtxoByte: BigInt(result.coinsPerUtxoByte),
348
+ maxTxExSteps: BigInt(result.maxExecutionUnitsPerTransaction.cpu),
349
+ // NOTE: coinsPerUtxoByte is now called utxoCostPerByte:
350
+ // https://github.com/IntersectMBO/cardano-node/pull/4141
351
+ // Ogmios v6.x calls it minUtxoDepositCoefficient according to the following
352
+ // documentation from its protocol parameters data model:
353
+ // https://github.com/CardanoSolutions/ogmios/blob/master/architectural-decisions/accepted/017-api-version-6-major-rewrite.md#protocol-parameters
354
+ coinsPerUtxoByte: BigInt(result.minUtxoDepositCoefficient),
354
355
  collateralPercentage: parseInt(result.collateralPercentage),
355
356
  maxCollateralInputs: parseInt(result.maxCollateralInputs),
356
357
  costModels
@@ -409,9 +410,10 @@ var Kupmios = class {
409
410
  );
410
411
  }
411
412
  async getDelegation(rewardAddress) {
412
- const client = await this.ogmiosWsp("Query", {
413
- query: { delegationsAndRewards: [rewardAddress] }
414
- });
413
+ const client = await this.ogmiosWsp(
414
+ "queryLedgerState/rewardAccountSummaries",
415
+ { keys: [rewardAddress] }
416
+ );
415
417
  return new Promise((res, rej) => {
416
418
  client.addEventListener(
417
419
  "message",
@@ -420,8 +422,8 @@ var Kupmios = class {
420
422
  const { result } = JSON.parse(msg.data);
421
423
  const delegation = result ? Object.values(result)[0] : {};
422
424
  res({
423
- poolId: delegation?.delegate || null,
424
- rewards: BigInt(delegation?.rewards || 0)
425
+ poolId: delegation?.delegate?.id || null,
426
+ rewards: BigInt(delegation?.rewards?.ada?.lovelace || 0)
425
427
  });
426
428
  client.close();
427
429
  } catch (e) {
@@ -516,18 +518,17 @@ var Kupmios = class {
516
518
  })
517
519
  );
518
520
  }
519
- async ogmiosWsp(methodname, args) {
521
+ async ogmiosWsp(method, params = {}, id) {
520
522
  const client = new WebSocket(this.ogmiosUrl);
521
523
  await new Promise((res) => {
522
524
  client.addEventListener("open", () => res(1), { once: true });
523
525
  });
524
526
  client.send(
525
527
  JSON.stringify({
526
- type: "jsonwsp/request",
527
- version: "1.0",
528
- servicename: "ogmios",
529
- methodname,
530
- args
528
+ jsonrpc: "2.0",
529
+ method,
530
+ params,
531
+ id
531
532
  })
532
533
  );
533
534
  return client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/provider",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",