@indigo-labs/indigo-sdk 0.4.2 → 0.4.4

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/package.json CHANGED
@@ -1,22 +1,10 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "tsup src/index.ts --format esm,cjs --dts --clean --tsconfig tsconfig.build.json",
10
- "type-check": "tsc --noEmit",
11
- "lint": "pnpm eslint .",
12
- "lint:fix": "npx eslint --fix .",
13
- "repack": "pnpm run build && pnpm pack",
14
- "format": "npx prettier --write src/ tests/",
15
- "format:check": "npx prettier --check src/ tests/",
16
- "test": "vitest run",
17
- "prepare": "husky",
18
- "lint-staged": "lint-staged"
19
- },
20
8
  "lint-staged": {
21
9
  "*.{js,ts,jsx,tsx}": [
22
10
  "prettier --write",
@@ -39,7 +27,6 @@
39
27
  ],
40
28
  "author": "3rd Eye Labs",
41
29
  "license": "MIT",
42
- "packageManager": "pnpm@10.33.4",
43
30
  "dependencies": {
44
31
  "@3rd-eye-labs/cardano-offchain-common": "1.4.7",
45
32
  "@evolution-sdk/evolution": "^0.3.22",
@@ -71,10 +58,15 @@
71
58
  "typescript-eslint": "^8.39.0",
72
59
  "vitest": "^4.0.14"
73
60
  },
74
- "pnpm": {
75
- "overrides": {
76
- "libsodium-wrappers-sumo": "0.8.2",
77
- "libsodium-sumo": "0.8.2"
78
- }
61
+ "scripts": {
62
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean --tsconfig tsconfig.build.json",
63
+ "type-check": "tsc --noEmit",
64
+ "lint": "pnpm eslint .",
65
+ "lint:fix": "npx eslint --fix .",
66
+ "repack": "pnpm run build && pnpm pack",
67
+ "format": "npx prettier --write src/ tests/",
68
+ "format:check": "npx prettier --check src/ tests/",
69
+ "test": "vitest run",
70
+ "lint-staged": "lint-staged"
79
71
  }
80
- }
72
+ }
package/scripts/bench.sh CHANGED
File without changes
@@ -476,7 +476,9 @@ export async function vote(
476
476
  return lucid
477
477
  .newTx()
478
478
  .validFrom(validityFrom)
479
- .validTo(validityFrom + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND)
479
+ .validTo(
480
+ validityFrom + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND,
481
+ )
480
482
  .readFrom([stakingRefScriptUtxo, pollShardRefScriptUtxo])
481
483
  .collectFrom([stakingPosUtxo], serialiseStakingRedeemer('Lock'))
482
484
  .collectFrom(
@@ -1,10 +1,10 @@
1
- import { fromText, LucidEvolution, toHex, UTxO } from '@lucid-evolution/lucid';
1
+ import { LucidEvolution, toHex, UTxO } from '@lucid-evolution/lucid';
2
2
  import {
3
- fromSystemParamsAsset,
3
+ assetClassToUnit,
4
4
  matchSingle,
5
- mkStabilityPoolAddr,
6
- SystemParams,
7
- } from '../../src';
5
+ } from '@3rd-eye-labs/cardano-offchain-common';
6
+ import { option as O, array as A, function as F } from 'fp-ts';
7
+ import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
8
8
  import {
9
9
  AccountContent,
10
10
  parseAccountDatum,
@@ -12,14 +12,16 @@ import {
12
12
  parseStabilityPoolDatum,
13
13
  SnapshotEpochToScaleToSumContent,
14
14
  StabilityPoolContent,
15
- } from '../../src/contracts/stability-pool/types-new';
16
- import { assetClassToUnit } from '@3rd-eye-labs/cardano-offchain-common';
17
- import { option as O, array as A, function as F } from 'fp-ts';
15
+ } from './types-new';
16
+ import { mkStabilityPoolAddr } from './helpers';
18
17
 
19
18
  export async function findStabilityPool(
20
19
  lucid: LucidEvolution,
21
20
  sysParams: SystemParams,
22
- asset: string,
21
+ /**
22
+ * For conversion from hex use the `fromHex` function from lucid-evolution.
23
+ */
24
+ iassetName: Uint8Array<ArrayBufferLike>,
23
25
  ): Promise<{ utxo: UTxO; datum: StabilityPoolContent }> {
24
26
  // We need to consider both with staking credential and without.
25
27
  const spUtxos = await lucid.utxosAtWithUnit(
@@ -36,7 +38,7 @@ export async function findStabilityPool(
36
38
  O.fromNullable(utxo.datum),
37
39
  O.flatMap(parseStabilityPoolDatum),
38
40
  O.flatMap((datum) => {
39
- if (toHex(datum.iasset) == fromText(asset)) {
41
+ if (toHex(datum.iasset) == toHex(iassetName)) {
40
42
  return O.some({ utxo, datum: datum });
41
43
  } else {
42
44
  return O.none;
@@ -57,7 +59,10 @@ export async function findStabilityPoolAccount(
57
59
  lucid: LucidEvolution,
58
60
  sysParams: SystemParams,
59
61
  owner: string,
60
- asset: string,
62
+ /**
63
+ * For conversion from hex use the `fromHex` function from lucid-evolution.
64
+ */
65
+ iassetName: Uint8Array<ArrayBufferLike>,
61
66
  ): Promise<{ utxo: UTxO; datum: AccountContent }> {
62
67
  // We need to consider both with staking credential and without.
63
68
  const spUtxos = await lucid.utxosAt({
@@ -73,7 +78,7 @@ export async function findStabilityPoolAccount(
73
78
  O.flatMap(parseAccountDatum),
74
79
  O.flatMap((datum) => {
75
80
  if (
76
- toHex(datum.iasset) == fromText(asset) &&
81
+ toHex(datum.iasset) == toHex(iassetName) &&
77
82
  toHex(datum.owner) == owner
78
83
  ) {
79
84
  return O.some({ utxo, datum: datum });
@@ -93,7 +98,10 @@ export async function findStabilityPoolAccount(
93
98
  export async function findE2s2sSnapshots(
94
99
  lucid: LucidEvolution,
95
100
  sysParams: SystemParams,
96
- asset: string,
101
+ /**
102
+ * For conversion from hex use the `fromHex` function from lucid-evolution.
103
+ */
104
+ iassetName: Uint8Array<ArrayBufferLike>,
97
105
  ): Promise<{ utxo: UTxO; datum: SnapshotEpochToScaleToSumContent }[]> {
98
106
  // No need to query the ones without stake cred, e2s2s will always have stake cred based on script params.
99
107
  const spUtxos = await lucid.utxosAtWithUnit(
@@ -111,7 +119,7 @@ export async function findE2s2sSnapshots(
111
119
  O.fromNullable(utxo.datum),
112
120
  O.flatMap(parseSnapshotEpochToScaleToSumDatum),
113
121
  O.flatMap((datum) => {
114
- if (toHex(datum.iasset) == fromText(asset)) {
122
+ if (toHex(datum.iasset) == toHex(iassetName)) {
115
123
  return O.some({ utxo, datum: datum });
116
124
  } else {
117
125
  return O.none;
package/src/index.ts CHANGED
@@ -13,8 +13,6 @@ export * from './contracts/gov/transactions';
13
13
  export * from './contracts/gov/types';
14
14
  export * from './contracts/gov/types-new';
15
15
  export * from './contracts/gov/scripts';
16
- export * from './contracts/stability-pool/transactions';
17
- export * from './contracts/stability-pool/scripts';
18
16
  export * from './contracts/staking/transactions';
19
17
  export * from './contracts/staking/helpers';
20
18
  export * from './contracts/staking/types-new';
@@ -37,7 +35,6 @@ export * from './contracts/treasury/transactions';
37
35
  export * from './contracts/treasury/helpers';
38
36
  export * from './contracts/treasury/scripts';
39
37
  export * from './contracts/treasury/queries';
40
- export * from './contracts/stability-pool/helpers';
41
38
  export * from './utils/time-helpers';
42
39
  export * from './contracts/cdp/scripts';
43
40
  export * from './contracts/collector/scripts';
@@ -45,8 +42,12 @@ export * from './contracts/execute/types';
45
42
  export * from './contracts/execute/types-new';
46
43
  export * from './contracts/execute/scripts';
47
44
  export * from './contracts/price-oracle/types';
45
+ export * from './contracts/stability-pool/helpers';
48
46
  export * from './contracts/stability-pool/types';
49
47
  export * from './contracts/stability-pool/types-new';
48
+ export * from './contracts/stability-pool/queries';
49
+ export * from './contracts/stability-pool/transactions';
50
+ export * from './contracts/stability-pool/scripts';
50
51
  export * from './contracts/poll/types-poll-shard';
51
52
  export * from './contracts/poll/types-poll-manager';
52
53
  export * from './contracts/poll/types-poll-new';
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Credential,
3
+ fromHex,
3
4
  fromText,
4
5
  LucidEvolution,
5
6
  ScriptHash,
@@ -12,6 +13,7 @@ import {
12
13
  adjustPriceToDecimals,
13
14
  cdpCollateralRatioPercentage,
14
15
  createScriptAddress,
16
+ findStabilityPool,
15
17
  fromSystemParamsAsset,
16
18
  matchSingle,
17
19
  SystemParams,
@@ -35,7 +37,6 @@ import {
35
37
  parseInterestOracleDatum,
36
38
  } from '../../src/contracts/interest-oracle/types-new';
37
39
  import { findCollateralAsset, findIAsset } from '../queries/iasset-queries';
38
- import { findStabilityPool } from '../queries/stability-pool-queries';
39
40
  import { findPriceOracle } from '../price-oracle/price-oracle-queries';
40
41
  import { findInterestOracle } from '../queries/interest-oracle-queries';
41
42
  import { findRandomCollector } from '../queries/collector-queries';
@@ -289,7 +290,11 @@ export async function findAllNecessaryOrefs(
289
290
  collateralAsset,
290
291
  );
291
292
 
292
- const stabilityPool = await findStabilityPool(lucid, sysParams, iasset);
293
+ const stabilityPool = await findStabilityPool(
294
+ lucid,
295
+ sysParams,
296
+ fromHex(fromText(iasset)),
297
+ );
293
298
 
294
299
  return {
295
300
  stabilityPoolUtxo: stabilityPool.utxo,