@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.d.mts +636 -4
- package/dist/index.d.ts +636 -4
- package/dist/index.js +236 -216
- package/dist/index.mjs +231 -219
- package/package.json +1 -1
- package/src/contracts/gov/transactions.ts +14 -4
- package/src/index.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -5120,21 +5120,184 @@ var mkPollShardValidatorFromSP = (params) => {
|
|
|
5120
5120
|
};
|
|
5121
5121
|
};
|
|
5122
5122
|
|
|
5123
|
+
// src/contracts/poll/types-poll-new.ts
|
|
5124
|
+
import { TSchema as TSchema15, Data as Data25 } from "@evolution-sdk/evolution";
|
|
5125
|
+
import {
|
|
5126
|
+
AddressSchema as AddressSchema3,
|
|
5127
|
+
OutputReferenceSchema as OutputReferenceSchema5
|
|
5128
|
+
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
5129
|
+
import { option as O10, function as F12 } from "fp-ts";
|
|
5130
|
+
import { match as match14, P as P14 } from "ts-pattern";
|
|
5131
|
+
var PollStatusSchema = TSchema15.Struct({
|
|
5132
|
+
yesVotes: TSchema15.Integer,
|
|
5133
|
+
noVotes: TSchema15.Integer
|
|
5134
|
+
});
|
|
5135
|
+
var PollManagerContentSchema = TSchema15.Struct({
|
|
5136
|
+
pollId: TSchema15.Integer,
|
|
5137
|
+
pollOwner: TSchema15.ByteArray,
|
|
5138
|
+
content: ProposalContentSchema,
|
|
5139
|
+
treasuryWithdrawal: TSchema15.NullOr(TreasuryWithdrawalSchema),
|
|
5140
|
+
status: PollStatusSchema,
|
|
5141
|
+
votingEndTime: TSchema15.Integer,
|
|
5142
|
+
createdShardsCount: TSchema15.Integer,
|
|
5143
|
+
talliedShardsCount: TSchema15.Integer,
|
|
5144
|
+
totalShardsCount: TSchema15.Integer,
|
|
5145
|
+
proposingEndTime: TSchema15.Integer,
|
|
5146
|
+
expirationTime: TSchema15.Integer,
|
|
5147
|
+
protocolVersion: TSchema15.Integer,
|
|
5148
|
+
minimumQuorum: TSchema15.Integer
|
|
5149
|
+
});
|
|
5150
|
+
var PollShardContentSchema = TSchema15.Struct({
|
|
5151
|
+
pollId: TSchema15.Integer,
|
|
5152
|
+
status: PollStatusSchema,
|
|
5153
|
+
votingEndTime: TSchema15.Integer,
|
|
5154
|
+
managerAddress: AddressSchema3
|
|
5155
|
+
});
|
|
5156
|
+
var PollDatumSchema = TSchema15.Union(
|
|
5157
|
+
TSchema15.Struct(
|
|
5158
|
+
{
|
|
5159
|
+
PollManager: PollManagerContentSchema
|
|
5160
|
+
},
|
|
5161
|
+
{ flatInUnion: true }
|
|
5162
|
+
),
|
|
5163
|
+
TSchema15.Struct({ PollShard: PollShardContentSchema }, { flatInUnion: true })
|
|
5164
|
+
);
|
|
5165
|
+
var VoteOptionSchema = TSchema15.Union(
|
|
5166
|
+
TSchema15.Literal("Yes", { flatInUnion: true }),
|
|
5167
|
+
TSchema15.Literal("No", { flatInUnion: true })
|
|
5168
|
+
);
|
|
5169
|
+
var PollShardRedeemerSchema = TSchema15.Union(
|
|
5170
|
+
TSchema15.Struct({ Vote: VoteOptionSchema }, { flatInUnion: true }),
|
|
5171
|
+
TSchema15.Struct(
|
|
5172
|
+
{
|
|
5173
|
+
MergeShards: TSchema15.Struct(
|
|
5174
|
+
{
|
|
5175
|
+
currentTime: TSchema15.Integer,
|
|
5176
|
+
pollManagerRef: OutputReferenceSchema5
|
|
5177
|
+
},
|
|
5178
|
+
{ flatFields: true }
|
|
5179
|
+
)
|
|
5180
|
+
},
|
|
5181
|
+
{ flatInUnion: true }
|
|
5182
|
+
)
|
|
5183
|
+
);
|
|
5184
|
+
var PollManagerRedeemerSchema = TSchema15.Union(
|
|
5185
|
+
TSchema15.Struct(
|
|
5186
|
+
{
|
|
5187
|
+
EndPoll: TSchema15.Struct(
|
|
5188
|
+
{ currentTime: TSchema15.Integer },
|
|
5189
|
+
{ flatFields: true }
|
|
5190
|
+
)
|
|
5191
|
+
},
|
|
5192
|
+
{ flatInUnion: true }
|
|
5193
|
+
),
|
|
5194
|
+
TSchema15.Struct(
|
|
5195
|
+
{
|
|
5196
|
+
CreateShards: TSchema15.Struct(
|
|
5197
|
+
{ currentTime: TSchema15.Integer },
|
|
5198
|
+
{ flatFields: true }
|
|
5199
|
+
)
|
|
5200
|
+
},
|
|
5201
|
+
{ flatInUnion: true }
|
|
5202
|
+
),
|
|
5203
|
+
TSchema15.Struct(
|
|
5204
|
+
{
|
|
5205
|
+
MergeShardsManager: TSchema15.Struct(
|
|
5206
|
+
{ currentTime: TSchema15.Integer },
|
|
5207
|
+
{ flatFields: true }
|
|
5208
|
+
)
|
|
5209
|
+
},
|
|
5210
|
+
{ flatInUnion: true }
|
|
5211
|
+
)
|
|
5212
|
+
);
|
|
5213
|
+
function serialisePollManagerRedeemer(r) {
|
|
5214
|
+
return Data25.withSchema(PollManagerRedeemerSchema).toCBORHex(r);
|
|
5215
|
+
}
|
|
5216
|
+
function serialisePollShardRedeemer(r) {
|
|
5217
|
+
return Data25.withSchema(PollShardRedeemerSchema).toCBORHex(r);
|
|
5218
|
+
}
|
|
5219
|
+
function parsePollManager(datum) {
|
|
5220
|
+
try {
|
|
5221
|
+
return match14(
|
|
5222
|
+
Data25.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5223
|
+
datum
|
|
5224
|
+
)
|
|
5225
|
+
).with({ PollManager: P14.select() }, (res) => O10.some(res)).otherwise(() => O10.none);
|
|
5226
|
+
} catch (_) {
|
|
5227
|
+
return O10.none;
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
function parsePollManagerOrThrow(datum) {
|
|
5231
|
+
return F12.pipe(
|
|
5232
|
+
parsePollManager(datum),
|
|
5233
|
+
O10.match(() => {
|
|
5234
|
+
throw new Error("Expected a poll manager datum.");
|
|
5235
|
+
}, F12.identity)
|
|
5236
|
+
);
|
|
5237
|
+
}
|
|
5238
|
+
function parsePollShard(datum) {
|
|
5239
|
+
try {
|
|
5240
|
+
return match14(
|
|
5241
|
+
Data25.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5242
|
+
datum
|
|
5243
|
+
)
|
|
5244
|
+
).with({ PollShard: P14.select() }, (res) => O10.some(res)).otherwise(() => O10.none);
|
|
5245
|
+
} catch (_) {
|
|
5246
|
+
return O10.none;
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
function parsePollShardOrThrow(datum) {
|
|
5250
|
+
return F12.pipe(
|
|
5251
|
+
parsePollShard(datum),
|
|
5252
|
+
O10.match(() => {
|
|
5253
|
+
throw new Error("Expected a poll shard datum.");
|
|
5254
|
+
}, F12.identity)
|
|
5255
|
+
);
|
|
5256
|
+
}
|
|
5257
|
+
function serialisePollDatum(d) {
|
|
5258
|
+
return Data25.withSchema(PollDatumSchema).toCBORHex(d);
|
|
5259
|
+
}
|
|
5260
|
+
|
|
5261
|
+
// src/contracts/poll/helpers.ts
|
|
5262
|
+
function q(pollStatus, e) {
|
|
5263
|
+
if (pollStatus.yesVotes + pollStatus.noVotes === 0n)
|
|
5264
|
+
return { getOnChainInt: 0n };
|
|
5265
|
+
else {
|
|
5266
|
+
const q2 = ocdDiv(
|
|
5267
|
+
{ getOnChainInt: pollStatus.yesVotes },
|
|
5268
|
+
{ getOnChainInt: BigInt(Math.floor(Math.sqrt(Number(e)))) }
|
|
5269
|
+
).getOnChainInt - ocdDiv(
|
|
5270
|
+
{ getOnChainInt: pollStatus.noVotes },
|
|
5271
|
+
{
|
|
5272
|
+
getOnChainInt: BigInt(
|
|
5273
|
+
Math.floor(
|
|
5274
|
+
Math.sqrt(Number(pollStatus.yesVotes + pollStatus.noVotes))
|
|
5275
|
+
)
|
|
5276
|
+
)
|
|
5277
|
+
}
|
|
5278
|
+
).getOnChainInt;
|
|
5279
|
+
return { getOnChainInt: BigInt(q2) };
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
function pollPassQuorum(pollStatus, electorate, minQuorum) {
|
|
5283
|
+
return pollStatus.yesVotes + pollStatus.noVotes >= minQuorum && q(pollStatus, electorate).getOnChainInt > 50000n;
|
|
5284
|
+
}
|
|
5285
|
+
|
|
5123
5286
|
// src/contracts/collector/transactions.ts
|
|
5124
5287
|
import {
|
|
5125
5288
|
addAssets as addAssets7,
|
|
5126
|
-
Data as
|
|
5289
|
+
Data as Data27
|
|
5127
5290
|
} from "@lucid-evolution/lucid";
|
|
5128
5291
|
|
|
5129
5292
|
// src/contracts/collector/types-new.ts
|
|
5130
|
-
import { TSchema as
|
|
5131
|
-
var CollectorRedeemerSchema =
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5293
|
+
import { TSchema as TSchema16, Data as Data26 } from "@evolution-sdk/evolution";
|
|
5294
|
+
var CollectorRedeemerSchema = TSchema16.Union(
|
|
5295
|
+
TSchema16.Literal("Collect", { flatInUnion: true }),
|
|
5296
|
+
TSchema16.Literal("DistributeToStakers", { flatInUnion: true }),
|
|
5297
|
+
TSchema16.Literal("UpgradeVersion", { flatInUnion: true })
|
|
5135
5298
|
);
|
|
5136
5299
|
function serialiseCollectorRedeemer(r) {
|
|
5137
|
-
return
|
|
5300
|
+
return Data26.withSchema(
|
|
5138
5301
|
CollectorRedeemerSchema,
|
|
5139
5302
|
DEFAULT_SCHEMA_OPTIONS
|
|
5140
5303
|
).toCBORHex(r);
|
|
@@ -5155,7 +5318,7 @@ async function collectorFeeTx(fee, lucid, params, tx, collectorOref) {
|
|
|
5155
5318
|
);
|
|
5156
5319
|
tx.collectFrom([collectorUtxo], serialiseCollectorRedeemer("Collect")).pay.ToContract(
|
|
5157
5320
|
collectorUtxo.address,
|
|
5158
|
-
{ kind: "inline", value:
|
|
5321
|
+
{ kind: "inline", value: Data27.void() },
|
|
5159
5322
|
addAssets7(collectorUtxo.assets, mkLovelacesOf2(fee))
|
|
5160
5323
|
).readFrom([collectorRefScriptUtxo]);
|
|
5161
5324
|
return collectorRefScriptUtxo;
|
|
@@ -5185,95 +5348,95 @@ import { array as A8, option as O12, function as F14 } from "fp-ts";
|
|
|
5185
5348
|
import { match as match16, P as P16 } from "ts-pattern";
|
|
5186
5349
|
|
|
5187
5350
|
// src/contracts/staking/types-new.ts
|
|
5188
|
-
import { TSchema as
|
|
5189
|
-
import { option as
|
|
5190
|
-
import { match as
|
|
5191
|
-
var StakingPosLockedAmtSchema =
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
voteAmt:
|
|
5196
|
-
votingEnd:
|
|
5351
|
+
import { TSchema as TSchema17, Data as Data28 } from "@evolution-sdk/evolution";
|
|
5352
|
+
import { option as O11, function as F13 } from "fp-ts";
|
|
5353
|
+
import { match as match15, P as P15 } from "ts-pattern";
|
|
5354
|
+
var StakingPosLockedAmtSchema = TSchema17.Array(
|
|
5355
|
+
TSchema17.Tuple([
|
|
5356
|
+
TSchema17.Integer,
|
|
5357
|
+
TSchema17.Struct({
|
|
5358
|
+
voteAmt: TSchema17.Integer,
|
|
5359
|
+
votingEnd: TSchema17.Integer
|
|
5197
5360
|
})
|
|
5198
5361
|
])
|
|
5199
5362
|
);
|
|
5200
|
-
var RewardSnapshotSchema =
|
|
5201
|
-
snapshotAda:
|
|
5363
|
+
var RewardSnapshotSchema = TSchema17.Struct({
|
|
5364
|
+
snapshotAda: TSchema17.Integer
|
|
5202
5365
|
});
|
|
5203
|
-
var StakingPositionSchema =
|
|
5204
|
-
owner:
|
|
5366
|
+
var StakingPositionSchema = TSchema17.Struct({
|
|
5367
|
+
owner: TSchema17.ByteArray,
|
|
5205
5368
|
lockedAmount: StakingPosLockedAmtSchema,
|
|
5206
5369
|
positionSnapshot: RewardSnapshotSchema
|
|
5207
5370
|
});
|
|
5208
|
-
var StakingManagerSchema =
|
|
5209
|
-
totalStake:
|
|
5371
|
+
var StakingManagerSchema = TSchema17.Struct({
|
|
5372
|
+
totalStake: TSchema17.Integer,
|
|
5210
5373
|
managerSnapshot: RewardSnapshotSchema
|
|
5211
5374
|
});
|
|
5212
|
-
var StakingDatumSchema =
|
|
5375
|
+
var StakingDatumSchema = TSchema17.Union(
|
|
5213
5376
|
StakingManagerSchema,
|
|
5214
5377
|
StakingPositionSchema
|
|
5215
5378
|
);
|
|
5216
|
-
var StakingRedeemerSchema =
|
|
5217
|
-
|
|
5379
|
+
var StakingRedeemerSchema = TSchema17.Union(
|
|
5380
|
+
TSchema17.Struct(
|
|
5218
5381
|
{
|
|
5219
|
-
CreateStakingPosition:
|
|
5220
|
-
{ creatorPkh:
|
|
5382
|
+
CreateStakingPosition: TSchema17.Struct(
|
|
5383
|
+
{ creatorPkh: TSchema17.ByteArray },
|
|
5221
5384
|
{ flatFields: true }
|
|
5222
5385
|
)
|
|
5223
5386
|
},
|
|
5224
5387
|
{ flatInUnion: true }
|
|
5225
5388
|
),
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5389
|
+
TSchema17.Literal("UpdateTotalStake", { flatInUnion: true }),
|
|
5390
|
+
TSchema17.Literal("Distribute", { flatInUnion: true }),
|
|
5391
|
+
TSchema17.Struct(
|
|
5229
5392
|
{
|
|
5230
|
-
AdjustStakedAmount:
|
|
5231
|
-
{ adjustAmount:
|
|
5393
|
+
AdjustStakedAmount: TSchema17.Struct(
|
|
5394
|
+
{ adjustAmount: TSchema17.Integer },
|
|
5232
5395
|
{ flatFields: true }
|
|
5233
5396
|
)
|
|
5234
5397
|
},
|
|
5235
5398
|
{ flatInUnion: true }
|
|
5236
5399
|
),
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5400
|
+
TSchema17.Literal("Unstake", { flatInUnion: true }),
|
|
5401
|
+
TSchema17.Literal("Lock", { flatInUnion: true }),
|
|
5402
|
+
TSchema17.Literal("UpgradeVersion", { flatInUnion: true })
|
|
5240
5403
|
);
|
|
5241
5404
|
function serialiseStakingRedeemer(r) {
|
|
5242
|
-
return
|
|
5405
|
+
return Data28.withSchema(
|
|
5243
5406
|
StakingRedeemerSchema,
|
|
5244
5407
|
DEFAULT_SCHEMA_OPTIONS
|
|
5245
5408
|
).toCBORHex(r);
|
|
5246
5409
|
}
|
|
5247
5410
|
function parseStakingPosition(datum) {
|
|
5248
5411
|
try {
|
|
5249
|
-
return
|
|
5250
|
-
|
|
5412
|
+
return match15(
|
|
5413
|
+
Data28.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5251
5414
|
datum
|
|
5252
5415
|
)
|
|
5253
|
-
).with({ owner:
|
|
5416
|
+
).with({ owner: P15.any }, (res) => O11.some(res)).otherwise(() => O11.none);
|
|
5254
5417
|
} catch (_) {
|
|
5255
|
-
return
|
|
5418
|
+
return O11.none;
|
|
5256
5419
|
}
|
|
5257
5420
|
}
|
|
5258
5421
|
function parseStakingPositionOrThrow(datum) {
|
|
5259
|
-
return
|
|
5422
|
+
return F13.pipe(
|
|
5260
5423
|
parseStakingPosition(datum),
|
|
5261
|
-
|
|
5424
|
+
O11.match(() => {
|
|
5262
5425
|
throw new Error("Expected a StakingPosition datum.");
|
|
5263
|
-
},
|
|
5426
|
+
}, F13.identity)
|
|
5264
5427
|
);
|
|
5265
5428
|
}
|
|
5266
5429
|
function parseStakingManagerDatum(datum) {
|
|
5267
|
-
return
|
|
5268
|
-
|
|
5430
|
+
return match15(
|
|
5431
|
+
Data28.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5269
5432
|
datum
|
|
5270
5433
|
)
|
|
5271
|
-
).with({ totalStake:
|
|
5434
|
+
).with({ totalStake: P15.any }, (res) => res).otherwise(() => {
|
|
5272
5435
|
throw new Error("Expected a StakingPosition datum.");
|
|
5273
5436
|
});
|
|
5274
5437
|
}
|
|
5275
5438
|
function serialiseStakingDatum(d) {
|
|
5276
|
-
return
|
|
5439
|
+
return Data28.withSchema(StakingDatumSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex(
|
|
5277
5440
|
d
|
|
5278
5441
|
);
|
|
5279
5442
|
}
|
|
@@ -5395,185 +5558,22 @@ function calculateAdaReward(currentSnapshotAda, oldSnapshotAda, existingIndyAmou
|
|
|
5395
5558
|
return (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / rewardSnapshotPrecision;
|
|
5396
5559
|
}
|
|
5397
5560
|
|
|
5398
|
-
// src/contracts/poll/helpers.ts
|
|
5399
|
-
function q(pollStatus, e) {
|
|
5400
|
-
if (pollStatus.yesVotes + pollStatus.noVotes === 0n)
|
|
5401
|
-
return { getOnChainInt: 0n };
|
|
5402
|
-
else {
|
|
5403
|
-
const q2 = ocdDiv(
|
|
5404
|
-
{ getOnChainInt: pollStatus.yesVotes },
|
|
5405
|
-
{ getOnChainInt: BigInt(Math.floor(Math.sqrt(Number(e)))) }
|
|
5406
|
-
).getOnChainInt - ocdDiv(
|
|
5407
|
-
{ getOnChainInt: pollStatus.noVotes },
|
|
5408
|
-
{
|
|
5409
|
-
getOnChainInt: BigInt(
|
|
5410
|
-
Math.floor(
|
|
5411
|
-
Math.sqrt(Number(pollStatus.yesVotes + pollStatus.noVotes))
|
|
5412
|
-
)
|
|
5413
|
-
)
|
|
5414
|
-
}
|
|
5415
|
-
).getOnChainInt;
|
|
5416
|
-
return { getOnChainInt: BigInt(q2) };
|
|
5417
|
-
}
|
|
5418
|
-
}
|
|
5419
|
-
function pollPassQuorum(pollStatus, electorate, minQuorum) {
|
|
5420
|
-
return pollStatus.yesVotes + pollStatus.noVotes >= minQuorum && q(pollStatus, electorate).getOnChainInt > 50000n;
|
|
5421
|
-
}
|
|
5422
|
-
|
|
5423
5561
|
// src/contracts/version-registry/types-new.ts
|
|
5424
|
-
import { TSchema as
|
|
5425
|
-
var VersionRecordDatumSchema =
|
|
5426
|
-
upgradeId:
|
|
5562
|
+
import { TSchema as TSchema18, Data as Data29 } from "@evolution-sdk/evolution";
|
|
5563
|
+
var VersionRecordDatumSchema = TSchema18.Struct({
|
|
5564
|
+
upgradeId: TSchema18.Integer,
|
|
5427
5565
|
/// Underlying representation of the following mapping: ValidatorHash -> UpgradePath
|
|
5428
|
-
upgradePaths:
|
|
5429
|
-
|
|
5566
|
+
upgradePaths: TSchema18.Array(
|
|
5567
|
+
TSchema18.Tuple([TSchema18.ByteArray, TSchema18.ByteArray])
|
|
5430
5568
|
)
|
|
5431
5569
|
});
|
|
5432
5570
|
function serialiseVersionRecordDatum(d) {
|
|
5433
|
-
return
|
|
5571
|
+
return Data29.withSchema(
|
|
5434
5572
|
VersionRecordDatumSchema,
|
|
5435
5573
|
DEFAULT_SCHEMA_OPTIONS
|
|
5436
5574
|
).toCBORHex(d);
|
|
5437
5575
|
}
|
|
5438
5576
|
|
|
5439
|
-
// src/contracts/poll/types-poll-new.ts
|
|
5440
|
-
import { TSchema as TSchema18, Data as Data29 } from "@evolution-sdk/evolution";
|
|
5441
|
-
import {
|
|
5442
|
-
AddressSchema as AddressSchema3,
|
|
5443
|
-
OutputReferenceSchema as OutputReferenceSchema5
|
|
5444
|
-
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
5445
|
-
import { option as O11, function as F13 } from "fp-ts";
|
|
5446
|
-
import { match as match15, P as P15 } from "ts-pattern";
|
|
5447
|
-
var PollStatusSchema = TSchema18.Struct({
|
|
5448
|
-
yesVotes: TSchema18.Integer,
|
|
5449
|
-
noVotes: TSchema18.Integer
|
|
5450
|
-
});
|
|
5451
|
-
var PollManagerContentSchema = TSchema18.Struct({
|
|
5452
|
-
pollId: TSchema18.Integer,
|
|
5453
|
-
pollOwner: TSchema18.ByteArray,
|
|
5454
|
-
content: ProposalContentSchema,
|
|
5455
|
-
treasuryWithdrawal: TSchema18.NullOr(TreasuryWithdrawalSchema),
|
|
5456
|
-
status: PollStatusSchema,
|
|
5457
|
-
votingEndTime: TSchema18.Integer,
|
|
5458
|
-
createdShardsCount: TSchema18.Integer,
|
|
5459
|
-
talliedShardsCount: TSchema18.Integer,
|
|
5460
|
-
totalShardsCount: TSchema18.Integer,
|
|
5461
|
-
proposingEndTime: TSchema18.Integer,
|
|
5462
|
-
expirationTime: TSchema18.Integer,
|
|
5463
|
-
protocolVersion: TSchema18.Integer,
|
|
5464
|
-
minimumQuorum: TSchema18.Integer
|
|
5465
|
-
});
|
|
5466
|
-
var PollShardContentSchema = TSchema18.Struct({
|
|
5467
|
-
pollId: TSchema18.Integer,
|
|
5468
|
-
status: PollStatusSchema,
|
|
5469
|
-
votingEndTime: TSchema18.Integer,
|
|
5470
|
-
managerAddress: AddressSchema3
|
|
5471
|
-
});
|
|
5472
|
-
var PollDatumSchema = TSchema18.Union(
|
|
5473
|
-
TSchema18.Struct(
|
|
5474
|
-
{
|
|
5475
|
-
PollManager: PollManagerContentSchema
|
|
5476
|
-
},
|
|
5477
|
-
{ flatInUnion: true }
|
|
5478
|
-
),
|
|
5479
|
-
TSchema18.Struct({ PollShard: PollShardContentSchema }, { flatInUnion: true })
|
|
5480
|
-
);
|
|
5481
|
-
var VoteOptionSchema = TSchema18.Union(
|
|
5482
|
-
TSchema18.Literal("Yes", { flatInUnion: true }),
|
|
5483
|
-
TSchema18.Literal("No", { flatInUnion: true })
|
|
5484
|
-
);
|
|
5485
|
-
var PollShardRedeemerSchema = TSchema18.Union(
|
|
5486
|
-
TSchema18.Struct({ Vote: VoteOptionSchema }, { flatInUnion: true }),
|
|
5487
|
-
TSchema18.Struct(
|
|
5488
|
-
{
|
|
5489
|
-
MergeShards: TSchema18.Struct(
|
|
5490
|
-
{
|
|
5491
|
-
currentTime: TSchema18.Integer,
|
|
5492
|
-
pollManagerRef: OutputReferenceSchema5
|
|
5493
|
-
},
|
|
5494
|
-
{ flatFields: true }
|
|
5495
|
-
)
|
|
5496
|
-
},
|
|
5497
|
-
{ flatInUnion: true }
|
|
5498
|
-
)
|
|
5499
|
-
);
|
|
5500
|
-
var PollManagerRedeemerSchema = TSchema18.Union(
|
|
5501
|
-
TSchema18.Struct(
|
|
5502
|
-
{
|
|
5503
|
-
EndPoll: TSchema18.Struct(
|
|
5504
|
-
{ currentTime: TSchema18.Integer },
|
|
5505
|
-
{ flatFields: true }
|
|
5506
|
-
)
|
|
5507
|
-
},
|
|
5508
|
-
{ flatInUnion: true }
|
|
5509
|
-
),
|
|
5510
|
-
TSchema18.Struct(
|
|
5511
|
-
{
|
|
5512
|
-
CreateShards: TSchema18.Struct(
|
|
5513
|
-
{ currentTime: TSchema18.Integer },
|
|
5514
|
-
{ flatFields: true }
|
|
5515
|
-
)
|
|
5516
|
-
},
|
|
5517
|
-
{ flatInUnion: true }
|
|
5518
|
-
),
|
|
5519
|
-
TSchema18.Struct(
|
|
5520
|
-
{
|
|
5521
|
-
MergeShardsManager: TSchema18.Struct(
|
|
5522
|
-
{ currentTime: TSchema18.Integer },
|
|
5523
|
-
{ flatFields: true }
|
|
5524
|
-
)
|
|
5525
|
-
},
|
|
5526
|
-
{ flatInUnion: true }
|
|
5527
|
-
)
|
|
5528
|
-
);
|
|
5529
|
-
function serialisePollManagerRedeemer(r) {
|
|
5530
|
-
return Data29.withSchema(PollManagerRedeemerSchema).toCBORHex(r);
|
|
5531
|
-
}
|
|
5532
|
-
function serialisePollShardRedeemer(r) {
|
|
5533
|
-
return Data29.withSchema(PollShardRedeemerSchema).toCBORHex(r);
|
|
5534
|
-
}
|
|
5535
|
-
function parsePollManager(datum) {
|
|
5536
|
-
try {
|
|
5537
|
-
return match15(
|
|
5538
|
-
Data29.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5539
|
-
datum
|
|
5540
|
-
)
|
|
5541
|
-
).with({ PollManager: P15.select() }, (res) => O11.some(res)).otherwise(() => O11.none);
|
|
5542
|
-
} catch (_) {
|
|
5543
|
-
return O11.none;
|
|
5544
|
-
}
|
|
5545
|
-
}
|
|
5546
|
-
function parsePollManagerOrThrow(datum) {
|
|
5547
|
-
return F13.pipe(
|
|
5548
|
-
parsePollManager(datum),
|
|
5549
|
-
O11.match(() => {
|
|
5550
|
-
throw new Error("Expected a poll manager datum.");
|
|
5551
|
-
}, F13.identity)
|
|
5552
|
-
);
|
|
5553
|
-
}
|
|
5554
|
-
function parsePollShard(datum) {
|
|
5555
|
-
try {
|
|
5556
|
-
return match15(
|
|
5557
|
-
Data29.withSchema(PollDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
5558
|
-
datum
|
|
5559
|
-
)
|
|
5560
|
-
).with({ PollShard: P15.select() }, (res) => O11.some(res)).otherwise(() => O11.none);
|
|
5561
|
-
} catch (_) {
|
|
5562
|
-
return O11.none;
|
|
5563
|
-
}
|
|
5564
|
-
}
|
|
5565
|
-
function parsePollShardOrThrow(datum) {
|
|
5566
|
-
return F13.pipe(
|
|
5567
|
-
parsePollShard(datum),
|
|
5568
|
-
O11.match(() => {
|
|
5569
|
-
throw new Error("Expected a poll shard datum.");
|
|
5570
|
-
}, F13.identity)
|
|
5571
|
-
);
|
|
5572
|
-
}
|
|
5573
|
-
function serialisePollDatum(d) {
|
|
5574
|
-
return Data29.withSchema(PollDatumSchema).toCBORHex(d);
|
|
5575
|
-
}
|
|
5576
|
-
|
|
5577
5577
|
// src/contracts/gov/transactions.ts
|
|
5578
5578
|
import {
|
|
5579
5579
|
addressFromBech32,
|
|
@@ -5694,7 +5694,9 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
|
|
|
5694
5694
|
)
|
|
5695
5695
|
)
|
|
5696
5696
|
)
|
|
5697
|
-
).validFrom(Number(currentTime) - ONE_SECOND).validTo(
|
|
5697
|
+
).validFrom(Number(currentTime) - ONE_SECOND).validTo(
|
|
5698
|
+
Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND
|
|
5699
|
+
).addSigner(ownAddr),
|
|
5698
5700
|
newPollId
|
|
5699
5701
|
];
|
|
5700
5702
|
}
|
|
@@ -6703,7 +6705,9 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
|
|
|
6703
6705
|
);
|
|
6704
6706
|
}).otherwise(() => {
|
|
6705
6707
|
});
|
|
6706
|
-
tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo]).validFrom(Number(currentTime) - ONE_SECOND).validTo(
|
|
6708
|
+
tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo]).validFrom(Number(currentTime) - ONE_SECOND).validTo(
|
|
6709
|
+
Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND
|
|
6710
|
+
).collectFrom([executeUtxo], Data30.void()).mintAssets(
|
|
6707
6711
|
mkAssetsOf6(fromSystemParamsAsset(sysParams.govParams.upgradeToken), -1n),
|
|
6708
6712
|
Data30.void()
|
|
6709
6713
|
).addSigner(ownAddr).setMinFee(922932n);
|
|
@@ -10882,6 +10886,10 @@ export {
|
|
|
10882
10886
|
parseIAssetDatumOrThrow,
|
|
10883
10887
|
parseInterestCollectionDatum,
|
|
10884
10888
|
parseInterestOracleDatum,
|
|
10889
|
+
parsePollManager,
|
|
10890
|
+
parsePollManagerOrThrow,
|
|
10891
|
+
parsePollShard,
|
|
10892
|
+
parsePollShardOrThrow,
|
|
10885
10893
|
parsePriceOracleDatum,
|
|
10886
10894
|
parsePythStateDatum,
|
|
10887
10895
|
parseRobDatum,
|
|
@@ -10902,6 +10910,7 @@ export {
|
|
|
10902
10910
|
parseStakingPosition,
|
|
10903
10911
|
parseStakingPositionOrThrow,
|
|
10904
10912
|
partitionEpochToScaleToSums,
|
|
10913
|
+
pollPassQuorum,
|
|
10905
10914
|
processSpRequest,
|
|
10906
10915
|
rationalAdd,
|
|
10907
10916
|
rationalCeil,
|
|
@@ -10938,6 +10947,9 @@ export {
|
|
|
10938
10947
|
serialiseInterestCollectionDatum,
|
|
10939
10948
|
serialiseInterestCollectionRedeemer,
|
|
10940
10949
|
serialiseInterestOracleDatum,
|
|
10950
|
+
serialisePollDatum,
|
|
10951
|
+
serialisePollManagerRedeemer,
|
|
10952
|
+
serialisePollShardRedeemer,
|
|
10941
10953
|
serialisePriceOracleDatum,
|
|
10942
10954
|
serialisePriceOracleRedeemer,
|
|
10943
10955
|
serialisePythFeedParams,
|
package/package.json
CHANGED
|
@@ -252,7 +252,11 @@ export async function createProposal(
|
|
|
252
252
|
),
|
|
253
253
|
)
|
|
254
254
|
.validFrom(Number(currentTime) - ONE_SECOND)
|
|
255
|
-
.validTo(
|
|
255
|
+
.validTo(
|
|
256
|
+
Number(currentTime) +
|
|
257
|
+
Number(sysParams.govParams.gBiasTime) -
|
|
258
|
+
ONE_SECOND,
|
|
259
|
+
)
|
|
256
260
|
.addSigner(ownAddr),
|
|
257
261
|
newPollId,
|
|
258
262
|
];
|
|
@@ -321,7 +325,9 @@ export async function createShardsChunks(
|
|
|
321
325
|
.newTx()
|
|
322
326
|
.validFrom(Number(currentTime) - ONE_SECOND)
|
|
323
327
|
.validTo(
|
|
324
|
-
Number(currentTime) +
|
|
328
|
+
Number(currentTime) +
|
|
329
|
+
Number(sysParams.pollManagerParams.pBiasTime) -
|
|
330
|
+
ONE_SECOND,
|
|
325
331
|
)
|
|
326
332
|
.mintAssets(mkAssetsOf(pollNft, shardsCount), Data.void())
|
|
327
333
|
// Ref scripts
|
|
@@ -574,7 +580,9 @@ export async function mergeShards(
|
|
|
574
580
|
.newTx()
|
|
575
581
|
.validFrom(Number(currentTime) - ONE_SECOND)
|
|
576
582
|
.validTo(
|
|
577
|
-
Number(currentTime) +
|
|
583
|
+
Number(currentTime) +
|
|
584
|
+
Number(sysParams.pollManagerParams.pBiasTime) -
|
|
585
|
+
ONE_SECOND,
|
|
578
586
|
)
|
|
579
587
|
.readFrom([
|
|
580
588
|
pollShardRefScriptUtxo,
|
|
@@ -1553,7 +1561,9 @@ export async function executeProposal(
|
|
|
1553
1561
|
|
|
1554
1562
|
tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo])
|
|
1555
1563
|
.validFrom(Number(currentTime) - ONE_SECOND)
|
|
1556
|
-
.validTo(
|
|
1564
|
+
.validTo(
|
|
1565
|
+
Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND,
|
|
1566
|
+
)
|
|
1557
1567
|
.collectFrom([executeUtxo], Data.void())
|
|
1558
1568
|
.mintAssets(
|
|
1559
1569
|
mkAssetsOf(fromSystemParamsAsset(sysParams.govParams.upgradeToken), -1n),
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './contracts/cdp/scripts';
|
|
|
6
6
|
export * from './contracts/cdp-creator/types';
|
|
7
7
|
export * from './contracts/cdp-creator/scripts';
|
|
8
8
|
export * from './contracts/poll/scripts';
|
|
9
|
+
export * from './contracts/poll/types-poll-new';
|
|
10
|
+
export * from './contracts/poll/helpers';
|
|
9
11
|
export * from './contracts/collector/transactions';
|
|
10
12
|
export * from './contracts/collector/types-new';
|
|
11
13
|
export * from './contracts/gov/transactions';
|