@indigo-labs/indigo-sdk 0.3.28 → 0.4.1

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.
@@ -76,7 +76,7 @@ import { benchmarkAndAwaitTx } from '../utils/benchmark-utils';
76
76
  import {
77
77
  findAllTreasuryUtxos,
78
78
  findAllTreasuryUtxosWithNonAdaAsset,
79
- } from '../treasury/treasury-queries';
79
+ } from '../../src/contracts/treasury/queries';
80
80
  import {
81
81
  createIndyUtxoAtTreasury,
82
82
  createUtxoAtTreasury,
@@ -97,10 +97,10 @@ import {
97
97
  import {
98
98
  findAllCollateralAssetsOfIAsset,
99
99
  findAllIAssets,
100
- findCollateralAssetNew,
101
100
  findIAsset,
102
101
  } from '../queries/iasset-queries';
103
102
  import { startPriceOracleTx } from '../../src/contracts/price-oracle/transactions';
103
+ import { findCollateralAsset as findCollateralAssetNew } from '../../src/contracts/iasset/queries';
104
104
  import { rationalFromInt, rationalZero } from '../../src/types/rational';
105
105
  import { expectScriptFailure } from '../utils/asserts';
106
106
  import { MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET } from '../../src/contracts/iasset/helpers';
@@ -2072,9 +2072,9 @@ describe('Gov', () => {
2072
2072
  );
2073
2073
 
2074
2074
  const res = await findCollateralAssetNew(
2075
- context,
2075
+ context.lucid,
2076
2076
  sysParams,
2077
- iusdAssetInfo.iassetTokenNameAscii,
2077
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2078
2078
  collateralAsset1,
2079
2079
  );
2080
2080
 
@@ -2256,9 +2256,9 @@ describe('Gov', () => {
2256
2256
  );
2257
2257
 
2258
2258
  const res = await findCollateralAssetNew(
2259
- context,
2259
+ context.lucid,
2260
2260
  sysParams,
2261
- iusdAssetInfo.iassetTokenNameAscii,
2261
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2262
2262
  collateralAsset2,
2263
2263
  );
2264
2264
 
@@ -2451,15 +2451,15 @@ describe('Gov', () => {
2451
2451
  );
2452
2452
 
2453
2453
  const newCollateralAsset = await findCollateralAssetNew(
2454
- context,
2454
+ context.lucid,
2455
2455
  sysParams,
2456
- iusdAssetInfo.iassetTokenNameAscii,
2456
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2457
2457
  collateralAsset2,
2458
2458
  );
2459
2459
  const collateralAssetFirst = await findCollateralAssetNew(
2460
- context,
2460
+ context.lucid,
2461
2461
  sysParams,
2462
- iusdAssetInfo.iassetTokenNameAscii,
2462
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2463
2463
  collateralAsset1,
2464
2464
  );
2465
2465
 
@@ -2659,15 +2659,15 @@ describe('Gov', () => {
2659
2659
  );
2660
2660
 
2661
2661
  const newCollateralAsset = await findCollateralAssetNew(
2662
- context,
2662
+ context.lucid,
2663
2663
  sysParams,
2664
- iusdAssetInfo.iassetTokenNameAscii,
2664
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2665
2665
  collateralAsset2,
2666
2666
  );
2667
2667
  const collateralAssetFirst = await findCollateralAssetNew(
2668
- context,
2668
+ context.lucid,
2669
2669
  sysParams,
2670
- iusdAssetInfo.iassetTokenNameAscii,
2670
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
2671
2671
  collateralAsset1,
2672
2672
  );
2673
2673
 
@@ -4085,9 +4085,9 @@ describe('Gov', () => {
4085
4085
  null,
4086
4086
  (
4087
4087
  await findCollateralAssetNew(
4088
- context,
4088
+ context.lucid,
4089
4089
  sysParams,
4090
- iusdAssetInfo.iassetTokenNameAscii,
4090
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
4091
4091
  iusdAssetInfo.collateralAssets[0].collateralAsset,
4092
4092
  )
4093
4093
  ).utxo,
@@ -4236,9 +4236,9 @@ describe('Gov', () => {
4236
4236
  null,
4237
4237
  (
4238
4238
  await findCollateralAssetNew(
4239
- context,
4239
+ context.lucid,
4240
4240
  sysParams,
4241
- iusdAssetInfo.iassetTokenNameAscii,
4241
+ fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
4242
4242
  iusdAssetInfo.collateralAssets[0].collateralAsset,
4243
4243
  )
4244
4244
  ).utxo,
@@ -12,7 +12,7 @@ import {
12
12
  findAdminInterestCollectors,
13
13
  findAllInterestCollectors,
14
14
  findRandomNonAdminInterestCollector,
15
- } from './interest-collector-queries';
15
+ } from '../../src/contracts/interest-collection/queries';
16
16
  import { benchmarkAndAwaitTx } from '../utils/benchmark-utils';
17
17
  import {
18
18
  batchCollectInterest,
@@ -60,10 +60,7 @@ describe('Interest Collection', () => {
60
60
  test<IndigoTestContext>('Collect Interest - Cannot collect without interacting with a CDP', async (context: IndigoTestContext) => {
61
61
  const interestCollectionUtxo = await findRandomNonAdminInterestCollector(
62
62
  context.lucid,
63
- context.systemParams.validatorHashes.interestCollectionHash,
64
- fromSystemParamsAsset(
65
- context.systemParams.interestCollectionParams.multisigUtxoNft,
66
- ),
63
+ context.systemParams,
67
64
  );
68
65
 
69
66
  await expectScriptFailure(
@@ -82,10 +79,7 @@ describe('Interest Collection', () => {
82
79
  test<IndigoTestContext>('Collect Interest - Cannot collect from interest admin', async (context: IndigoTestContext) => {
83
80
  const adminInterestCollectorUtxo = await findAdminInterestCollectors(
84
81
  context.lucid,
85
- context.systemParams.validatorHashes.interestCollectionHash,
86
- fromSystemParamsAsset(
87
- context.systemParams.interestCollectionParams.multisigUtxoNft,
88
- ),
82
+ context.systemParams,
89
83
  );
90
84
 
91
85
  const [iAssetConfig] = context.assetConfigs;
@@ -160,7 +154,7 @@ describe('Interest Collection', () => {
160
154
 
161
155
  const interestCollectors = await findAllInterestCollectors(
162
156
  context.lucid,
163
- context.systemParams.validatorHashes.interestCollectionHash,
157
+ context.systemParams,
164
158
  );
165
159
 
166
160
  const interestCollectorsUtxos = interestCollectors.filter(
@@ -225,10 +219,7 @@ describe('Interest Collection', () => {
225
219
 
226
220
  const interestCollectionUtxo = await findRandomNonAdminInterestCollector(
227
221
  context.lucid,
228
- context.systemParams.validatorHashes.interestCollectionHash,
229
- fromSystemParamsAsset(
230
- context.systemParams.interestCollectionParams.multisigUtxoNft,
231
- ),
222
+ context.systemParams,
232
223
  );
233
224
 
234
225
  context.lucid.selectWallet.fromSeed(context.users.user.seedPhrase);
@@ -447,20 +438,14 @@ describe('Interest Collection', () => {
447
438
 
448
439
  const interestDistributeUtxo = matchSingle(
449
440
  (
450
- await findAllInterestCollectors(
451
- context.lucid,
452
- context.systemParams.validatorHashes.interestCollectionHash,
453
- )
441
+ await findAllInterestCollectors(context.lucid, context.systemParams)
454
442
  ).filter((utxo) => assetClassValueOf(utxo.assets, EXAMPLE_TOKEN_1)),
455
443
  (_) => new Error('Expected a single interest distribute UTXO'),
456
444
  );
457
445
 
458
446
  const interestAdminUtxo = await findAdminInterestCollector(
459
447
  context.lucid,
460
- context.systemParams.validatorHashes.interestCollectionHash,
461
- fromSystemParamsAsset(
462
- context.systemParams.interestCollectionParams.multisigUtxoNft,
463
- ),
448
+ context.systemParams,
464
449
  );
465
450
 
466
451
  await benchmarkAndAwaitTx(
@@ -491,18 +476,12 @@ describe('Interest Collection', () => {
491
476
  context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
492
477
 
493
478
  const interestDistributeUtxos = (
494
- await findAllInterestCollectors(
495
- context.lucid,
496
- context.systemParams.validatorHashes.interestCollectionHash,
497
- )
479
+ await findAllInterestCollectors(context.lucid, context.systemParams)
498
480
  ).filter((utxo) => assetClassValueOf(utxo.assets, EXAMPLE_TOKEN_1));
499
481
 
500
482
  const interestAdminUtxo = await findAdminInterestCollector(
501
483
  context.lucid,
502
- context.systemParams.validatorHashes.interestCollectionHash,
503
- fromSystemParamsAsset(
504
- context.systemParams.interestCollectionParams.multisigUtxoNft,
505
- ),
484
+ context.systemParams,
506
485
  );
507
486
 
508
487
  await benchmarkAndAwaitTx(
@@ -532,20 +511,14 @@ describe('Interest Collection', () => {
532
511
 
533
512
  const interestDistributeUtxo = matchSingle(
534
513
  (
535
- await findAllInterestCollectors(
536
- context.lucid,
537
- context.systemParams.validatorHashes.interestCollectionHash,
538
- )
514
+ await findAllInterestCollectors(context.lucid, context.systemParams)
539
515
  ).filter((utxo) => assetClassValueOf(utxo.assets, EXAMPLE_TOKEN_1)),
540
516
  (_) => new Error('Expected a single interest distribute UTXO'),
541
517
  );
542
518
 
543
519
  const interestAdminUtxo = await findAdminInterestCollector(
544
520
  context.lucid,
545
- context.systemParams.validatorHashes.interestCollectionHash,
546
- fromSystemParamsAsset(
547
- context.systemParams.interestCollectionParams.multisigUtxoNft,
548
- ),
521
+ context.systemParams,
549
522
  );
550
523
 
551
524
  await expectScriptFailure(
@@ -565,10 +538,7 @@ describe('Interest Collection', () => {
565
538
  test<IndigoTestContext>('Update Permissions', async (context: IndigoTestContext) => {
566
539
  const interestAdminUtxo = await findAdminInterestCollector(
567
540
  context.lucid,
568
- context.systemParams.validatorHashes.interestCollectionHash,
569
- fromSystemParamsAsset(
570
- context.systemParams.interestCollectionParams.multisigUtxoNft,
571
- ),
541
+ context.systemParams,
572
542
  );
573
543
 
574
544
  const govUtxo = await findGov(
@@ -607,10 +577,7 @@ describe('Interest Collection', () => {
607
577
  test<IndigoTestContext>('Update Permissions - all of multiple signers', async (context: IndigoTestContext) => {
608
578
  const interestAdminUtxo = await findAdminInterestCollector(
609
579
  context.lucid,
610
- context.systemParams.validatorHashes.interestCollectionHash,
611
- fromSystemParamsAsset(
612
- context.systemParams.interestCollectionParams.multisigUtxoNft,
613
- ),
580
+ context.systemParams,
614
581
  );
615
582
 
616
583
  const govUtxo = await findGov(
@@ -665,10 +632,7 @@ describe('Interest Collection', () => {
665
632
  test<IndigoTestContext>('Update Permissions - some of multiple signers', async (context: IndigoTestContext) => {
666
633
  const interestAdminUtxo = await findAdminInterestCollector(
667
634
  context.lucid,
668
- context.systemParams.validatorHashes.interestCollectionHash,
669
- fromSystemParamsAsset(
670
- context.systemParams.interestCollectionParams.multisigUtxoNft,
671
- ),
635
+ context.systemParams,
672
636
  );
673
637
 
674
638
  const govUtxo = await findGov(
@@ -728,10 +692,7 @@ describe('Interest Collection', () => {
728
692
  test<IndigoTestContext>('Update Permissions - nested multisig', async (context: IndigoTestContext) => {
729
693
  const interestAdminUtxo = await findAdminInterestCollector(
730
694
  context.lucid,
731
- context.systemParams.validatorHashes.interestCollectionHash,
732
- fromSystemParamsAsset(
733
- context.systemParams.interestCollectionParams.multisigUtxoNft,
734
- ),
695
+ context.systemParams,
735
696
  );
736
697
 
737
698
  const govUtxo = await findGov(
@@ -798,10 +759,7 @@ describe('Interest Collection', () => {
798
759
  test<IndigoTestContext>('Update Permissions - Fail when new admin is not signed', async (context: IndigoTestContext) => {
799
760
  const interestAdminUtxo = await findAdminInterestCollector(
800
761
  context.lucid,
801
- context.systemParams.validatorHashes.interestCollectionHash,
802
- fromSystemParamsAsset(
803
- context.systemParams.interestCollectionParams.multisigUtxoNft,
804
- ),
762
+ context.systemParams,
805
763
  );
806
764
 
807
765
  const govUtxo = await findGov(
@@ -834,10 +792,7 @@ describe('Interest Collection', () => {
834
792
  test<IndigoTestContext>('Update Permissions - Fail when not enough signers of new admin', async (context: IndigoTestContext) => {
835
793
  const interestAdminUtxo = await findAdminInterestCollector(
836
794
  context.lucid,
837
- context.systemParams.validatorHashes.interestCollectionHash,
838
- fromSystemParamsAsset(
839
- context.systemParams.interestCollectionParams.multisigUtxoNft,
840
- ),
795
+ context.systemParams,
841
796
  );
842
797
 
843
798
  const govUtxo = await findGov(
@@ -6,7 +6,7 @@ import {
6
6
  toText,
7
7
  } from '@lucid-evolution/lucid';
8
8
  import { createScriptAddress } from '../../src/utils/lucid-utils';
9
- import { fromSystemParamsAsset, matchSingle, SystemParams } from '../../src';
9
+ import { matchSingle, SystemParams } from '../../src';
10
10
  import { option as O, array as A, function as F } from 'fp-ts';
11
11
  import {
12
12
  AssetClass,
@@ -19,7 +19,6 @@ import {
19
19
  parseCollateralAssetDatum,
20
20
  parseIAssetDatum,
21
21
  } from '../../src/contracts/iasset/types';
22
- import { LucidContext } from '../test-helpers';
23
22
 
24
23
  // TODO: replace with the new variant defined below
25
24
  export async function findIAsset(
@@ -56,44 +55,6 @@ export async function findIAsset(
56
55
  );
57
56
  }
58
57
 
59
- export async function findIAssetNew(
60
- context: LucidContext,
61
- sysParams: SystemParams,
62
- // Ascii encoded
63
- iassetName: string,
64
- ): Promise<IAssetOutput> {
65
- const iassetUtxos = await context.lucid.utxosAtWithUnit(
66
- createScriptAddress(
67
- context.lucid.config().network!,
68
- sysParams.validatorHashes.iassetHash,
69
- ),
70
- assetClassToUnit(
71
- fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
72
- ),
73
- );
74
-
75
- return matchSingle(
76
- F.pipe(
77
- iassetUtxos.map((utxo) =>
78
- F.pipe(
79
- O.fromNullable(utxo.datum),
80
- O.flatMap(parseIAssetDatum),
81
- O.flatMap((datum) => {
82
- if (toHex(datum.assetName) === fromText(iassetName)) {
83
- return O.some({ utxo, datum: datum });
84
- } else {
85
- return O.none;
86
- }
87
- }),
88
- ),
89
- ),
90
- A.compact,
91
- ),
92
- (res) =>
93
- new Error('Expected a single IAsset UTXO.: ' + JSON.stringify(res)),
94
- );
95
- }
96
-
97
58
  export async function findAllIAssets(
98
59
  lucid: LucidEvolution,
99
60
  iassetScriptHash: ScriptHash,
@@ -160,50 +121,6 @@ export async function findCollateralAsset(
160
121
  );
161
122
  }
162
123
 
163
- export async function findCollateralAssetNew(
164
- context: LucidContext,
165
- sysParams: SystemParams,
166
- // Ascii encoded
167
- iassetName: string,
168
- collateralAsset: AssetClass,
169
- ): Promise<CollateralAssetOutput> {
170
- const collateralAssetUtxos = await context.lucid.utxosAtWithUnit(
171
- createScriptAddress(
172
- context.lucid.config().network!,
173
- sysParams.validatorHashes.iassetHash,
174
- ),
175
- assetClassToUnit(
176
- fromSystemParamsAsset(sysParams.cdpParams.collateralAssetAuthToken),
177
- ),
178
- );
179
-
180
- return matchSingle(
181
- F.pipe(
182
- collateralAssetUtxos.map((utxo) =>
183
- F.pipe(
184
- O.fromNullable(utxo.datum),
185
- O.flatMap(parseCollateralAssetDatum),
186
- O.flatMap((datum) => {
187
- if (
188
- isSameAssetClass(datum.collateralAsset, collateralAsset) &&
189
- fromText(iassetName) === toHex(datum.iasset)
190
- ) {
191
- return O.some({ utxo, datum: datum });
192
- } else {
193
- return O.none;
194
- }
195
- }),
196
- ),
197
- ),
198
- A.compact,
199
- ),
200
- (res) =>
201
- new Error(
202
- 'Expected a single Collateral Asset UTXO.: ' + JSON.stringify(res),
203
- ),
204
- );
205
- }
206
-
207
124
  export async function findAllCollateralAssetsOfIAsset(
208
125
  lucid: LucidEvolution,
209
126
  iassetScriptHash: ScriptHash,