@indigo-labs/indigo-sdk 0.3.8 → 0.3.9

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.js CHANGED
@@ -245,6 +245,10 @@ __export(index_exports, {
245
245
  parseIAssetDatumOrThrow: () => parseIAssetDatumOrThrow,
246
246
  parseInterestCollectionDatum: () => parseInterestCollectionDatum,
247
247
  parseInterestOracleDatum: () => parseInterestOracleDatum,
248
+ parsePollManager: () => parsePollManager,
249
+ parsePollManagerOrThrow: () => parsePollManagerOrThrow,
250
+ parsePollShard: () => parsePollShard,
251
+ parsePollShardOrThrow: () => parsePollShardOrThrow,
248
252
  parsePriceOracleDatum: () => parsePriceOracleDatum,
249
253
  parsePythStateDatum: () => parsePythStateDatum,
250
254
  parseRobDatum: () => parseRobDatum,
@@ -265,6 +269,7 @@ __export(index_exports, {
265
269
  parseStakingPosition: () => parseStakingPosition,
266
270
  parseStakingPositionOrThrow: () => parseStakingPositionOrThrow,
267
271
  partitionEpochToScaleToSums: () => partitionEpochToScaleToSums,
272
+ pollPassQuorum: () => pollPassQuorum,
268
273
  processSpRequest: () => processSpRequest,
269
274
  rationalAdd: () => rationalAdd,
270
275
  rationalCeil: () => rationalCeil,
@@ -301,6 +306,9 @@ __export(index_exports, {
301
306
  serialiseInterestCollectionDatum: () => serialiseInterestCollectionDatum,
302
307
  serialiseInterestCollectionRedeemer: () => serialiseInterestCollectionRedeemer,
303
308
  serialiseInterestOracleDatum: () => serialiseInterestOracleDatum,
309
+ serialisePollDatum: () => serialisePollDatum,
310
+ serialisePollManagerRedeemer: () => serialisePollManagerRedeemer,
311
+ serialisePollShardRedeemer: () => serialisePollShardRedeemer,
304
312
  serialisePriceOracleDatum: () => serialisePriceOracleDatum,
305
313
  serialisePriceOracleRedeemer: () => serialisePriceOracleRedeemer,
306
314
  serialisePythFeedParams: () => serialisePythFeedParams,
@@ -5363,25 +5371,185 @@ var mkPollShardValidatorFromSP = (params) => {
5363
5371
  };
5364
5372
  };
5365
5373
 
5374
+ // src/contracts/poll/types-poll-new.ts
5375
+ var import_evolution15 = require("@evolution-sdk/evolution");
5376
+ var import_cardano_offchain_common14 = require("@3rd-eye-labs/cardano-offchain-common");
5377
+ var import_fp_ts13 = require("fp-ts");
5378
+ var import_ts_pattern15 = require("ts-pattern");
5379
+ var PollStatusSchema = import_evolution15.TSchema.Struct({
5380
+ yesVotes: import_evolution15.TSchema.Integer,
5381
+ noVotes: import_evolution15.TSchema.Integer
5382
+ });
5383
+ var PollManagerContentSchema = import_evolution15.TSchema.Struct({
5384
+ pollId: import_evolution15.TSchema.Integer,
5385
+ pollOwner: import_evolution15.TSchema.ByteArray,
5386
+ content: ProposalContentSchema,
5387
+ treasuryWithdrawal: import_evolution15.TSchema.NullOr(TreasuryWithdrawalSchema),
5388
+ status: PollStatusSchema,
5389
+ votingEndTime: import_evolution15.TSchema.Integer,
5390
+ createdShardsCount: import_evolution15.TSchema.Integer,
5391
+ talliedShardsCount: import_evolution15.TSchema.Integer,
5392
+ totalShardsCount: import_evolution15.TSchema.Integer,
5393
+ proposingEndTime: import_evolution15.TSchema.Integer,
5394
+ expirationTime: import_evolution15.TSchema.Integer,
5395
+ protocolVersion: import_evolution15.TSchema.Integer,
5396
+ minimumQuorum: import_evolution15.TSchema.Integer
5397
+ });
5398
+ var PollShardContentSchema = import_evolution15.TSchema.Struct({
5399
+ pollId: import_evolution15.TSchema.Integer,
5400
+ status: PollStatusSchema,
5401
+ votingEndTime: import_evolution15.TSchema.Integer,
5402
+ managerAddress: import_cardano_offchain_common14.AddressSchema
5403
+ });
5404
+ var PollDatumSchema = import_evolution15.TSchema.Union(
5405
+ import_evolution15.TSchema.Struct(
5406
+ {
5407
+ PollManager: PollManagerContentSchema
5408
+ },
5409
+ { flatInUnion: true }
5410
+ ),
5411
+ import_evolution15.TSchema.Struct({ PollShard: PollShardContentSchema }, { flatInUnion: true })
5412
+ );
5413
+ var VoteOptionSchema = import_evolution15.TSchema.Union(
5414
+ import_evolution15.TSchema.Literal("Yes", { flatInUnion: true }),
5415
+ import_evolution15.TSchema.Literal("No", { flatInUnion: true })
5416
+ );
5417
+ var PollShardRedeemerSchema = import_evolution15.TSchema.Union(
5418
+ import_evolution15.TSchema.Struct({ Vote: VoteOptionSchema }, { flatInUnion: true }),
5419
+ import_evolution15.TSchema.Struct(
5420
+ {
5421
+ MergeShards: import_evolution15.TSchema.Struct(
5422
+ {
5423
+ currentTime: import_evolution15.TSchema.Integer,
5424
+ pollManagerRef: import_cardano_offchain_common14.OutputReferenceSchema
5425
+ },
5426
+ { flatFields: true }
5427
+ )
5428
+ },
5429
+ { flatInUnion: true }
5430
+ )
5431
+ );
5432
+ var PollManagerRedeemerSchema = import_evolution15.TSchema.Union(
5433
+ import_evolution15.TSchema.Struct(
5434
+ {
5435
+ EndPoll: import_evolution15.TSchema.Struct(
5436
+ { currentTime: import_evolution15.TSchema.Integer },
5437
+ { flatFields: true }
5438
+ )
5439
+ },
5440
+ { flatInUnion: true }
5441
+ ),
5442
+ import_evolution15.TSchema.Struct(
5443
+ {
5444
+ CreateShards: import_evolution15.TSchema.Struct(
5445
+ { currentTime: import_evolution15.TSchema.Integer },
5446
+ { flatFields: true }
5447
+ )
5448
+ },
5449
+ { flatInUnion: true }
5450
+ ),
5451
+ import_evolution15.TSchema.Struct(
5452
+ {
5453
+ MergeShardsManager: import_evolution15.TSchema.Struct(
5454
+ { currentTime: import_evolution15.TSchema.Integer },
5455
+ { flatFields: true }
5456
+ )
5457
+ },
5458
+ { flatInUnion: true }
5459
+ )
5460
+ );
5461
+ function serialisePollManagerRedeemer(r) {
5462
+ return import_evolution15.Data.withSchema(PollManagerRedeemerSchema).toCBORHex(r);
5463
+ }
5464
+ function serialisePollShardRedeemer(r) {
5465
+ return import_evolution15.Data.withSchema(PollShardRedeemerSchema).toCBORHex(r);
5466
+ }
5467
+ function parsePollManager(datum) {
5468
+ try {
5469
+ return (0, import_ts_pattern15.match)(
5470
+ import_evolution15.Data.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5471
+ datum
5472
+ )
5473
+ ).with({ PollManager: import_ts_pattern15.P.select() }, (res) => import_fp_ts13.option.some(res)).otherwise(() => import_fp_ts13.option.none);
5474
+ } catch (_) {
5475
+ return import_fp_ts13.option.none;
5476
+ }
5477
+ }
5478
+ function parsePollManagerOrThrow(datum) {
5479
+ return import_fp_ts13.function.pipe(
5480
+ parsePollManager(datum),
5481
+ import_fp_ts13.option.match(() => {
5482
+ throw new Error("Expected a poll manager datum.");
5483
+ }, import_fp_ts13.function.identity)
5484
+ );
5485
+ }
5486
+ function parsePollShard(datum) {
5487
+ try {
5488
+ return (0, import_ts_pattern15.match)(
5489
+ import_evolution15.Data.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5490
+ datum
5491
+ )
5492
+ ).with({ PollShard: import_ts_pattern15.P.select() }, (res) => import_fp_ts13.option.some(res)).otherwise(() => import_fp_ts13.option.none);
5493
+ } catch (_) {
5494
+ return import_fp_ts13.option.none;
5495
+ }
5496
+ }
5497
+ function parsePollShardOrThrow(datum) {
5498
+ return import_fp_ts13.function.pipe(
5499
+ parsePollShard(datum),
5500
+ import_fp_ts13.option.match(() => {
5501
+ throw new Error("Expected a poll shard datum.");
5502
+ }, import_fp_ts13.function.identity)
5503
+ );
5504
+ }
5505
+ function serialisePollDatum(d) {
5506
+ return import_evolution15.Data.withSchema(PollDatumSchema).toCBORHex(d);
5507
+ }
5508
+
5509
+ // src/contracts/poll/helpers.ts
5510
+ function q(pollStatus, e) {
5511
+ if (pollStatus.yesVotes + pollStatus.noVotes === 0n)
5512
+ return { getOnChainInt: 0n };
5513
+ else {
5514
+ const q2 = ocdDiv(
5515
+ { getOnChainInt: pollStatus.yesVotes },
5516
+ { getOnChainInt: BigInt(Math.floor(Math.sqrt(Number(e)))) }
5517
+ ).getOnChainInt - ocdDiv(
5518
+ { getOnChainInt: pollStatus.noVotes },
5519
+ {
5520
+ getOnChainInt: BigInt(
5521
+ Math.floor(
5522
+ Math.sqrt(Number(pollStatus.yesVotes + pollStatus.noVotes))
5523
+ )
5524
+ )
5525
+ }
5526
+ ).getOnChainInt;
5527
+ return { getOnChainInt: BigInt(q2) };
5528
+ }
5529
+ }
5530
+ function pollPassQuorum(pollStatus, electorate, minQuorum) {
5531
+ return pollStatus.yesVotes + pollStatus.noVotes >= minQuorum && q(pollStatus, electorate).getOnChainInt > 50000n;
5532
+ }
5533
+
5366
5534
  // src/contracts/collector/transactions.ts
5367
5535
  var import_lucid22 = require("@lucid-evolution/lucid");
5368
5536
 
5369
5537
  // src/contracts/collector/types-new.ts
5370
- var import_evolution15 = require("@evolution-sdk/evolution");
5371
- var CollectorRedeemerSchema = import_evolution15.TSchema.Union(
5372
- import_evolution15.TSchema.Literal("Collect", { flatInUnion: true }),
5373
- import_evolution15.TSchema.Literal("DistributeToStakers", { flatInUnion: true }),
5374
- import_evolution15.TSchema.Literal("UpgradeVersion", { flatInUnion: true })
5538
+ var import_evolution16 = require("@evolution-sdk/evolution");
5539
+ var CollectorRedeemerSchema = import_evolution16.TSchema.Union(
5540
+ import_evolution16.TSchema.Literal("Collect", { flatInUnion: true }),
5541
+ import_evolution16.TSchema.Literal("DistributeToStakers", { flatInUnion: true }),
5542
+ import_evolution16.TSchema.Literal("UpgradeVersion", { flatInUnion: true })
5375
5543
  );
5376
5544
  function serialiseCollectorRedeemer(r) {
5377
- return import_evolution15.Data.withSchema(
5545
+ return import_evolution16.Data.withSchema(
5378
5546
  CollectorRedeemerSchema,
5379
5547
  DEFAULT_SCHEMA_OPTIONS
5380
5548
  ).toCBORHex(r);
5381
5549
  }
5382
5550
 
5383
5551
  // src/contracts/collector/transactions.ts
5384
- var import_cardano_offchain_common14 = require("@3rd-eye-labs/cardano-offchain-common");
5552
+ var import_cardano_offchain_common15 = require("@3rd-eye-labs/cardano-offchain-common");
5385
5553
  async function collectorFeeTx(fee, lucid, params, tx, collectorOref) {
5386
5554
  const collectorUtxo = matchSingle(
5387
5555
  await lucid.utxosByOutRef([collectorOref]),
@@ -5396,7 +5564,7 @@ async function collectorFeeTx(fee, lucid, params, tx, collectorOref) {
5396
5564
  tx.collectFrom([collectorUtxo], serialiseCollectorRedeemer("Collect")).pay.ToContract(
5397
5565
  collectorUtxo.address,
5398
5566
  { kind: "inline", value: import_lucid22.Data.void() },
5399
- (0, import_lucid22.addAssets)(collectorUtxo.assets, (0, import_cardano_offchain_common14.mkLovelacesOf)(fee))
5567
+ (0, import_lucid22.addAssets)(collectorUtxo.assets, (0, import_cardano_offchain_common15.mkLovelacesOf)(fee))
5400
5568
  ).readFrom([collectorRefScriptUtxo]);
5401
5569
  return collectorRefScriptUtxo;
5402
5570
  }
@@ -5410,95 +5578,95 @@ var import_fp_ts15 = require("fp-ts");
5410
5578
  var import_ts_pattern17 = require("ts-pattern");
5411
5579
 
5412
5580
  // src/contracts/staking/types-new.ts
5413
- var import_evolution16 = require("@evolution-sdk/evolution");
5414
- var import_fp_ts13 = require("fp-ts");
5415
- var import_ts_pattern15 = require("ts-pattern");
5416
- var StakingPosLockedAmtSchema = import_evolution16.TSchema.Array(
5417
- import_evolution16.TSchema.Tuple([
5418
- import_evolution16.TSchema.Integer,
5419
- import_evolution16.TSchema.Struct({
5420
- voteAmt: import_evolution16.TSchema.Integer,
5421
- votingEnd: import_evolution16.TSchema.Integer
5581
+ var import_evolution17 = require("@evolution-sdk/evolution");
5582
+ var import_fp_ts14 = require("fp-ts");
5583
+ var import_ts_pattern16 = require("ts-pattern");
5584
+ var StakingPosLockedAmtSchema = import_evolution17.TSchema.Array(
5585
+ import_evolution17.TSchema.Tuple([
5586
+ import_evolution17.TSchema.Integer,
5587
+ import_evolution17.TSchema.Struct({
5588
+ voteAmt: import_evolution17.TSchema.Integer,
5589
+ votingEnd: import_evolution17.TSchema.Integer
5422
5590
  })
5423
5591
  ])
5424
5592
  );
5425
- var RewardSnapshotSchema = import_evolution16.TSchema.Struct({
5426
- snapshotAda: import_evolution16.TSchema.Integer
5593
+ var RewardSnapshotSchema = import_evolution17.TSchema.Struct({
5594
+ snapshotAda: import_evolution17.TSchema.Integer
5427
5595
  });
5428
- var StakingPositionSchema = import_evolution16.TSchema.Struct({
5429
- owner: import_evolution16.TSchema.ByteArray,
5596
+ var StakingPositionSchema = import_evolution17.TSchema.Struct({
5597
+ owner: import_evolution17.TSchema.ByteArray,
5430
5598
  lockedAmount: StakingPosLockedAmtSchema,
5431
5599
  positionSnapshot: RewardSnapshotSchema
5432
5600
  });
5433
- var StakingManagerSchema = import_evolution16.TSchema.Struct({
5434
- totalStake: import_evolution16.TSchema.Integer,
5601
+ var StakingManagerSchema = import_evolution17.TSchema.Struct({
5602
+ totalStake: import_evolution17.TSchema.Integer,
5435
5603
  managerSnapshot: RewardSnapshotSchema
5436
5604
  });
5437
- var StakingDatumSchema = import_evolution16.TSchema.Union(
5605
+ var StakingDatumSchema = import_evolution17.TSchema.Union(
5438
5606
  StakingManagerSchema,
5439
5607
  StakingPositionSchema
5440
5608
  );
5441
- var StakingRedeemerSchema = import_evolution16.TSchema.Union(
5442
- import_evolution16.TSchema.Struct(
5609
+ var StakingRedeemerSchema = import_evolution17.TSchema.Union(
5610
+ import_evolution17.TSchema.Struct(
5443
5611
  {
5444
- CreateStakingPosition: import_evolution16.TSchema.Struct(
5445
- { creatorPkh: import_evolution16.TSchema.ByteArray },
5612
+ CreateStakingPosition: import_evolution17.TSchema.Struct(
5613
+ { creatorPkh: import_evolution17.TSchema.ByteArray },
5446
5614
  { flatFields: true }
5447
5615
  )
5448
5616
  },
5449
5617
  { flatInUnion: true }
5450
5618
  ),
5451
- import_evolution16.TSchema.Literal("UpdateTotalStake", { flatInUnion: true }),
5452
- import_evolution16.TSchema.Literal("Distribute", { flatInUnion: true }),
5453
- import_evolution16.TSchema.Struct(
5619
+ import_evolution17.TSchema.Literal("UpdateTotalStake", { flatInUnion: true }),
5620
+ import_evolution17.TSchema.Literal("Distribute", { flatInUnion: true }),
5621
+ import_evolution17.TSchema.Struct(
5454
5622
  {
5455
- AdjustStakedAmount: import_evolution16.TSchema.Struct(
5456
- { adjustAmount: import_evolution16.TSchema.Integer },
5623
+ AdjustStakedAmount: import_evolution17.TSchema.Struct(
5624
+ { adjustAmount: import_evolution17.TSchema.Integer },
5457
5625
  { flatFields: true }
5458
5626
  )
5459
5627
  },
5460
5628
  { flatInUnion: true }
5461
5629
  ),
5462
- import_evolution16.TSchema.Literal("Unstake", { flatInUnion: true }),
5463
- import_evolution16.TSchema.Literal("Lock", { flatInUnion: true }),
5464
- import_evolution16.TSchema.Literal("UpgradeVersion", { flatInUnion: true })
5630
+ import_evolution17.TSchema.Literal("Unstake", { flatInUnion: true }),
5631
+ import_evolution17.TSchema.Literal("Lock", { flatInUnion: true }),
5632
+ import_evolution17.TSchema.Literal("UpgradeVersion", { flatInUnion: true })
5465
5633
  );
5466
5634
  function serialiseStakingRedeemer(r) {
5467
- return import_evolution16.Data.withSchema(
5635
+ return import_evolution17.Data.withSchema(
5468
5636
  StakingRedeemerSchema,
5469
5637
  DEFAULT_SCHEMA_OPTIONS
5470
5638
  ).toCBORHex(r);
5471
5639
  }
5472
5640
  function parseStakingPosition(datum) {
5473
5641
  try {
5474
- return (0, import_ts_pattern15.match)(
5475
- import_evolution16.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5642
+ return (0, import_ts_pattern16.match)(
5643
+ import_evolution17.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5476
5644
  datum
5477
5645
  )
5478
- ).with({ owner: import_ts_pattern15.P.any }, (res) => import_fp_ts13.option.some(res)).otherwise(() => import_fp_ts13.option.none);
5646
+ ).with({ owner: import_ts_pattern16.P.any }, (res) => import_fp_ts14.option.some(res)).otherwise(() => import_fp_ts14.option.none);
5479
5647
  } catch (_) {
5480
- return import_fp_ts13.option.none;
5648
+ return import_fp_ts14.option.none;
5481
5649
  }
5482
5650
  }
5483
5651
  function parseStakingPositionOrThrow(datum) {
5484
- return import_fp_ts13.function.pipe(
5652
+ return import_fp_ts14.function.pipe(
5485
5653
  parseStakingPosition(datum),
5486
- import_fp_ts13.option.match(() => {
5654
+ import_fp_ts14.option.match(() => {
5487
5655
  throw new Error("Expected a StakingPosition datum.");
5488
- }, import_fp_ts13.function.identity)
5656
+ }, import_fp_ts14.function.identity)
5489
5657
  );
5490
5658
  }
5491
5659
  function parseStakingManagerDatum(datum) {
5492
- return (0, import_ts_pattern15.match)(
5493
- import_evolution16.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5660
+ return (0, import_ts_pattern16.match)(
5661
+ import_evolution17.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5494
5662
  datum
5495
5663
  )
5496
- ).with({ totalStake: import_ts_pattern15.P.any }, (res) => res).otherwise(() => {
5664
+ ).with({ totalStake: import_ts_pattern16.P.any }, (res) => res).otherwise(() => {
5497
5665
  throw new Error("Expected a StakingPosition datum.");
5498
5666
  });
5499
5667
  }
5500
5668
  function serialiseStakingDatum(d) {
5501
- return import_evolution16.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex(
5669
+ return import_evolution17.Data.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex(
5502
5670
  d
5503
5671
  );
5504
5672
  }
@@ -5613,182 +5781,22 @@ function calculateAdaReward(currentSnapshotAda, oldSnapshotAda, existingIndyAmou
5613
5781
  return (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / rewardSnapshotPrecision;
5614
5782
  }
5615
5783
 
5616
- // src/contracts/poll/helpers.ts
5617
- function q(pollStatus, e) {
5618
- if (pollStatus.yesVotes + pollStatus.noVotes === 0n)
5619
- return { getOnChainInt: 0n };
5620
- else {
5621
- const q2 = ocdDiv(
5622
- { getOnChainInt: pollStatus.yesVotes },
5623
- { getOnChainInt: BigInt(Math.floor(Math.sqrt(Number(e)))) }
5624
- ).getOnChainInt - ocdDiv(
5625
- { getOnChainInt: pollStatus.noVotes },
5626
- {
5627
- getOnChainInt: BigInt(
5628
- Math.floor(
5629
- Math.sqrt(Number(pollStatus.yesVotes + pollStatus.noVotes))
5630
- )
5631
- )
5632
- }
5633
- ).getOnChainInt;
5634
- return { getOnChainInt: BigInt(q2) };
5635
- }
5636
- }
5637
- function pollPassQuorum(pollStatus, electorate, minQuorum) {
5638
- return pollStatus.yesVotes + pollStatus.noVotes >= minQuorum && q(pollStatus, electorate).getOnChainInt > 50000n;
5639
- }
5640
-
5641
5784
  // src/contracts/version-registry/types-new.ts
5642
- var import_evolution17 = require("@evolution-sdk/evolution");
5643
- var VersionRecordDatumSchema = import_evolution17.TSchema.Struct({
5644
- upgradeId: import_evolution17.TSchema.Integer,
5785
+ var import_evolution18 = require("@evolution-sdk/evolution");
5786
+ var VersionRecordDatumSchema = import_evolution18.TSchema.Struct({
5787
+ upgradeId: import_evolution18.TSchema.Integer,
5645
5788
  /// Underlying representation of the following mapping: ValidatorHash -> UpgradePath
5646
- upgradePaths: import_evolution17.TSchema.Array(
5647
- import_evolution17.TSchema.Tuple([import_evolution17.TSchema.ByteArray, import_evolution17.TSchema.ByteArray])
5789
+ upgradePaths: import_evolution18.TSchema.Array(
5790
+ import_evolution18.TSchema.Tuple([import_evolution18.TSchema.ByteArray, import_evolution18.TSchema.ByteArray])
5648
5791
  )
5649
5792
  });
5650
5793
  function serialiseVersionRecordDatum(d) {
5651
- return import_evolution17.Data.withSchema(
5794
+ return import_evolution18.Data.withSchema(
5652
5795
  VersionRecordDatumSchema,
5653
5796
  DEFAULT_SCHEMA_OPTIONS
5654
5797
  ).toCBORHex(d);
5655
5798
  }
5656
5799
 
5657
- // src/contracts/poll/types-poll-new.ts
5658
- var import_evolution18 = require("@evolution-sdk/evolution");
5659
- var import_cardano_offchain_common15 = require("@3rd-eye-labs/cardano-offchain-common");
5660
- var import_fp_ts14 = require("fp-ts");
5661
- var import_ts_pattern16 = require("ts-pattern");
5662
- var PollStatusSchema = import_evolution18.TSchema.Struct({
5663
- yesVotes: import_evolution18.TSchema.Integer,
5664
- noVotes: import_evolution18.TSchema.Integer
5665
- });
5666
- var PollManagerContentSchema = import_evolution18.TSchema.Struct({
5667
- pollId: import_evolution18.TSchema.Integer,
5668
- pollOwner: import_evolution18.TSchema.ByteArray,
5669
- content: ProposalContentSchema,
5670
- treasuryWithdrawal: import_evolution18.TSchema.NullOr(TreasuryWithdrawalSchema),
5671
- status: PollStatusSchema,
5672
- votingEndTime: import_evolution18.TSchema.Integer,
5673
- createdShardsCount: import_evolution18.TSchema.Integer,
5674
- talliedShardsCount: import_evolution18.TSchema.Integer,
5675
- totalShardsCount: import_evolution18.TSchema.Integer,
5676
- proposingEndTime: import_evolution18.TSchema.Integer,
5677
- expirationTime: import_evolution18.TSchema.Integer,
5678
- protocolVersion: import_evolution18.TSchema.Integer,
5679
- minimumQuorum: import_evolution18.TSchema.Integer
5680
- });
5681
- var PollShardContentSchema = import_evolution18.TSchema.Struct({
5682
- pollId: import_evolution18.TSchema.Integer,
5683
- status: PollStatusSchema,
5684
- votingEndTime: import_evolution18.TSchema.Integer,
5685
- managerAddress: import_cardano_offchain_common15.AddressSchema
5686
- });
5687
- var PollDatumSchema = import_evolution18.TSchema.Union(
5688
- import_evolution18.TSchema.Struct(
5689
- {
5690
- PollManager: PollManagerContentSchema
5691
- },
5692
- { flatInUnion: true }
5693
- ),
5694
- import_evolution18.TSchema.Struct({ PollShard: PollShardContentSchema }, { flatInUnion: true })
5695
- );
5696
- var VoteOptionSchema = import_evolution18.TSchema.Union(
5697
- import_evolution18.TSchema.Literal("Yes", { flatInUnion: true }),
5698
- import_evolution18.TSchema.Literal("No", { flatInUnion: true })
5699
- );
5700
- var PollShardRedeemerSchema = import_evolution18.TSchema.Union(
5701
- import_evolution18.TSchema.Struct({ Vote: VoteOptionSchema }, { flatInUnion: true }),
5702
- import_evolution18.TSchema.Struct(
5703
- {
5704
- MergeShards: import_evolution18.TSchema.Struct(
5705
- {
5706
- currentTime: import_evolution18.TSchema.Integer,
5707
- pollManagerRef: import_cardano_offchain_common15.OutputReferenceSchema
5708
- },
5709
- { flatFields: true }
5710
- )
5711
- },
5712
- { flatInUnion: true }
5713
- )
5714
- );
5715
- var PollManagerRedeemerSchema = import_evolution18.TSchema.Union(
5716
- import_evolution18.TSchema.Struct(
5717
- {
5718
- EndPoll: import_evolution18.TSchema.Struct(
5719
- { currentTime: import_evolution18.TSchema.Integer },
5720
- { flatFields: true }
5721
- )
5722
- },
5723
- { flatInUnion: true }
5724
- ),
5725
- import_evolution18.TSchema.Struct(
5726
- {
5727
- CreateShards: import_evolution18.TSchema.Struct(
5728
- { currentTime: import_evolution18.TSchema.Integer },
5729
- { flatFields: true }
5730
- )
5731
- },
5732
- { flatInUnion: true }
5733
- ),
5734
- import_evolution18.TSchema.Struct(
5735
- {
5736
- MergeShardsManager: import_evolution18.TSchema.Struct(
5737
- { currentTime: import_evolution18.TSchema.Integer },
5738
- { flatFields: true }
5739
- )
5740
- },
5741
- { flatInUnion: true }
5742
- )
5743
- );
5744
- function serialisePollManagerRedeemer(r) {
5745
- return import_evolution18.Data.withSchema(PollManagerRedeemerSchema).toCBORHex(r);
5746
- }
5747
- function serialisePollShardRedeemer(r) {
5748
- return import_evolution18.Data.withSchema(PollShardRedeemerSchema).toCBORHex(r);
5749
- }
5750
- function parsePollManager(datum) {
5751
- try {
5752
- return (0, import_ts_pattern16.match)(
5753
- import_evolution18.Data.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5754
- datum
5755
- )
5756
- ).with({ PollManager: import_ts_pattern16.P.select() }, (res) => import_fp_ts14.option.some(res)).otherwise(() => import_fp_ts14.option.none);
5757
- } catch (_) {
5758
- return import_fp_ts14.option.none;
5759
- }
5760
- }
5761
- function parsePollManagerOrThrow(datum) {
5762
- return import_fp_ts14.function.pipe(
5763
- parsePollManager(datum),
5764
- import_fp_ts14.option.match(() => {
5765
- throw new Error("Expected a poll manager datum.");
5766
- }, import_fp_ts14.function.identity)
5767
- );
5768
- }
5769
- function parsePollShard(datum) {
5770
- try {
5771
- return (0, import_ts_pattern16.match)(
5772
- import_evolution18.Data.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5773
- datum
5774
- )
5775
- ).with({ PollShard: import_ts_pattern16.P.select() }, (res) => import_fp_ts14.option.some(res)).otherwise(() => import_fp_ts14.option.none);
5776
- } catch (_) {
5777
- return import_fp_ts14.option.none;
5778
- }
5779
- }
5780
- function parsePollShardOrThrow(datum) {
5781
- return import_fp_ts14.function.pipe(
5782
- parsePollShard(datum),
5783
- import_fp_ts14.option.match(() => {
5784
- throw new Error("Expected a poll shard datum.");
5785
- }, import_fp_ts14.function.identity)
5786
- );
5787
- }
5788
- function serialisePollDatum(d) {
5789
- return import_evolution18.Data.withSchema(PollDatumSchema).toCBORHex(d);
5790
- }
5791
-
5792
5800
  // src/contracts/gov/transactions.ts
5793
5801
  var import_cardano_offchain_common17 = require("@3rd-eye-labs/cardano-offchain-common");
5794
5802
  async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lucid, currentSlot, govOref, allIAssetOrefs) {
@@ -5906,7 +5914,9 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
5906
5914
  )
5907
5915
  )
5908
5916
  )
5909
- ).validFrom(Number(currentTime) - ONE_SECOND).validTo(Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND).addSigner(ownAddr),
5917
+ ).validFrom(Number(currentTime) - ONE_SECOND).validTo(
5918
+ Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND
5919
+ ).addSigner(ownAddr),
5910
5920
  newPollId
5911
5921
  ];
5912
5922
  }
@@ -6915,7 +6925,9 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6915
6925
  );
6916
6926
  }).otherwise(() => {
6917
6927
  });
6918
- tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo]).validFrom(Number(currentTime) - ONE_SECOND).validTo(Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND).collectFrom([executeUtxo], import_lucid26.Data.void()).mintAssets(
6928
+ tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo]).validFrom(Number(currentTime) - ONE_SECOND).validTo(
6929
+ Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND
6930
+ ).collectFrom([executeUtxo], import_lucid26.Data.void()).mintAssets(
6919
6931
  (0, import_cardano_offchain_common16.mkAssetsOf)(fromSystemParamsAsset(sysParams.govParams.upgradeToken), -1n),
6920
6932
  import_lucid26.Data.void()
6921
6933
  ).addSigner(ownAddr).setMinFee(922932n);
@@ -10928,6 +10940,10 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
10928
10940
  parseIAssetDatumOrThrow,
10929
10941
  parseInterestCollectionDatum,
10930
10942
  parseInterestOracleDatum,
10943
+ parsePollManager,
10944
+ parsePollManagerOrThrow,
10945
+ parsePollShard,
10946
+ parsePollShardOrThrow,
10931
10947
  parsePriceOracleDatum,
10932
10948
  parsePythStateDatum,
10933
10949
  parseRobDatum,
@@ -10948,6 +10964,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
10948
10964
  parseStakingPosition,
10949
10965
  parseStakingPositionOrThrow,
10950
10966
  partitionEpochToScaleToSums,
10967
+ pollPassQuorum,
10951
10968
  processSpRequest,
10952
10969
  rationalAdd,
10953
10970
  rationalCeil,
@@ -10984,6 +11001,9 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
10984
11001
  serialiseInterestCollectionDatum,
10985
11002
  serialiseInterestCollectionRedeemer,
10986
11003
  serialiseInterestOracleDatum,
11004
+ serialisePollDatum,
11005
+ serialisePollManagerRedeemer,
11006
+ serialisePollShardRedeemer,
10987
11007
  serialisePriceOracleDatum,
10988
11008
  serialisePriceOracleRedeemer,
10989
11009
  serialisePythFeedParams,