@lucid-evolution/provider 0.1.82 → 0.1.84
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 +612 -529
- package/dist/index.d.cts +67 -11
- package/dist/index.d.ts +67 -11
- package/dist/index.js +328 -248
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
KupmiosError: () => KupmiosError,
|
|
39
39
|
Maestro: () => Maestro,
|
|
40
40
|
generateEmulatorAccount: () => generateEmulatorAccount,
|
|
41
|
-
|
|
41
|
+
generateEmulatorAccountFromPrivateKey: () => generateEmulatorAccountFromPrivateKey
|
|
42
42
|
});
|
|
43
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
44
|
|
|
@@ -52,7 +52,7 @@ var import_utils2 = require("@lucid-evolution/utils");
|
|
|
52
52
|
// package.json
|
|
53
53
|
var package_default = {
|
|
54
54
|
name: "@lucid-evolution/provider",
|
|
55
|
-
version: "0.1.
|
|
55
|
+
version: "0.1.84",
|
|
56
56
|
description: "",
|
|
57
57
|
main: "./dist/index.js",
|
|
58
58
|
types: "./dist/index.d.ts",
|
|
@@ -84,13 +84,13 @@ var package_default = {
|
|
|
84
84
|
dependencies: {
|
|
85
85
|
"@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-3",
|
|
86
86
|
"@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-3",
|
|
87
|
-
"@effect/platform": "^0.
|
|
87
|
+
"@effect/platform": "^0.71.3",
|
|
88
88
|
"@effect/schema": "^0.68.26",
|
|
89
89
|
"@lucid-evolution/core-types": "workspace:*",
|
|
90
90
|
"@lucid-evolution/core-utils": "workspace:*",
|
|
91
91
|
"@lucid-evolution/utils": "workspace:*",
|
|
92
92
|
"@lucid-evolution/wallet": "workspace:*",
|
|
93
|
-
effect: "^3.
|
|
93
|
+
effect: "^3.11.7"
|
|
94
94
|
},
|
|
95
95
|
devDependencies: {
|
|
96
96
|
"@types/node": "^20.12.8",
|
|
@@ -452,59 +452,55 @@ var lucid = package_default.version;
|
|
|
452
452
|
|
|
453
453
|
// src/kupmios.ts
|
|
454
454
|
var import_utils4 = require("@lucid-evolution/utils");
|
|
455
|
-
var
|
|
456
|
-
var
|
|
457
|
-
var import_platform = require("@effect/platform");
|
|
458
|
-
var import_schema = require("@effect/schema");
|
|
455
|
+
var import_effect5 = require("effect");
|
|
456
|
+
var import_effect6 = require("effect");
|
|
459
457
|
|
|
460
458
|
// src/internal/ogmios.ts
|
|
461
|
-
var
|
|
459
|
+
var import_effect2 = require("effect");
|
|
462
460
|
var import_utils3 = require("@lucid-evolution/utils");
|
|
463
|
-
var JSONRPCSchema = (schema) =>
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
var LovelaceAsset = S.Struct({
|
|
472
|
-
lovelace: S.Number
|
|
461
|
+
var JSONRPCSchema = (schema) => import_effect2.Schema.Struct({
|
|
462
|
+
jsonrpc: import_effect2.Schema.String,
|
|
463
|
+
method: import_effect2.Schema.optional(import_effect2.Schema.String),
|
|
464
|
+
id: import_effect2.Schema.NullOr(import_effect2.Schema.Number),
|
|
465
|
+
result: schema
|
|
466
|
+
}).annotations({ identifier: "JSONRPCSchema" });
|
|
467
|
+
var LovelaceAsset = import_effect2.Schema.Struct({
|
|
468
|
+
lovelace: import_effect2.Schema.Number
|
|
473
469
|
});
|
|
474
|
-
var TupleNumberFromString =
|
|
475
|
-
|
|
476
|
-
|
|
470
|
+
var TupleNumberFromString = import_effect2.Schema.compose(
|
|
471
|
+
import_effect2.Schema.split("/"),
|
|
472
|
+
import_effect2.Schema.Array(import_effect2.Schema.NumberFromString)
|
|
477
473
|
);
|
|
478
|
-
var ProtocolParametersSchema =
|
|
479
|
-
minFeeCoefficient:
|
|
480
|
-
minFeeReferenceScripts:
|
|
481
|
-
base:
|
|
482
|
-
range:
|
|
483
|
-
multiplier:
|
|
474
|
+
var ProtocolParametersSchema = import_effect2.Schema.Struct({
|
|
475
|
+
minFeeCoefficient: import_effect2.Schema.Number,
|
|
476
|
+
minFeeReferenceScripts: import_effect2.Schema.Struct({
|
|
477
|
+
base: import_effect2.Schema.Number,
|
|
478
|
+
range: import_effect2.Schema.Number,
|
|
479
|
+
multiplier: import_effect2.Schema.Number
|
|
484
480
|
}),
|
|
485
|
-
maxReferenceScriptsSize:
|
|
486
|
-
bytes:
|
|
481
|
+
maxReferenceScriptsSize: import_effect2.Schema.Struct({
|
|
482
|
+
bytes: import_effect2.Schema.Number
|
|
487
483
|
}),
|
|
488
|
-
stakePoolVotingThresholds:
|
|
484
|
+
stakePoolVotingThresholds: import_effect2.Schema.Struct({
|
|
489
485
|
noConfidence: TupleNumberFromString,
|
|
490
|
-
constitutionalCommittee:
|
|
486
|
+
constitutionalCommittee: import_effect2.Schema.Struct({
|
|
491
487
|
default: TupleNumberFromString,
|
|
492
488
|
stateOfNoConfidence: TupleNumberFromString
|
|
493
489
|
}),
|
|
494
490
|
hardForkInitiation: TupleNumberFromString,
|
|
495
|
-
protocolParametersUpdate:
|
|
491
|
+
protocolParametersUpdate: import_effect2.Schema.Struct({
|
|
496
492
|
security: TupleNumberFromString
|
|
497
493
|
})
|
|
498
494
|
}),
|
|
499
|
-
delegateRepresentativeVotingThresholds:
|
|
495
|
+
delegateRepresentativeVotingThresholds: import_effect2.Schema.Struct({
|
|
500
496
|
noConfidence: TupleNumberFromString,
|
|
501
|
-
constitutionalCommittee:
|
|
497
|
+
constitutionalCommittee: import_effect2.Schema.Struct({
|
|
502
498
|
default: TupleNumberFromString,
|
|
503
499
|
stateOfNoConfidence: TupleNumberFromString
|
|
504
500
|
}),
|
|
505
501
|
constitution: TupleNumberFromString,
|
|
506
502
|
hardForkInitiation: TupleNumberFromString,
|
|
507
|
-
protocolParametersUpdate:
|
|
503
|
+
protocolParametersUpdate: import_effect2.Schema.Struct({
|
|
508
504
|
network: TupleNumberFromString,
|
|
509
505
|
economic: TupleNumberFromString,
|
|
510
506
|
technical: TupleNumberFromString,
|
|
@@ -512,62 +508,62 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
512
508
|
}),
|
|
513
509
|
treasuryWithdrawals: TupleNumberFromString
|
|
514
510
|
}),
|
|
515
|
-
constitutionalCommitteeMinSize:
|
|
516
|
-
constitutionalCommitteeMaxTermLength:
|
|
517
|
-
governanceActionLifetime:
|
|
518
|
-
governanceActionDeposit:
|
|
511
|
+
constitutionalCommitteeMinSize: import_effect2.Schema.optional(import_effect2.Schema.Number),
|
|
512
|
+
constitutionalCommitteeMaxTermLength: import_effect2.Schema.Number,
|
|
513
|
+
governanceActionLifetime: import_effect2.Schema.Number,
|
|
514
|
+
governanceActionDeposit: import_effect2.Schema.Struct({
|
|
519
515
|
ada: LovelaceAsset
|
|
520
516
|
}),
|
|
521
|
-
delegateRepresentativeDeposit:
|
|
517
|
+
delegateRepresentativeDeposit: import_effect2.Schema.Struct({
|
|
522
518
|
ada: LovelaceAsset
|
|
523
519
|
}),
|
|
524
|
-
delegateRepresentativeMaxIdleTime:
|
|
525
|
-
minFeeConstant:
|
|
526
|
-
maxBlockBodySize:
|
|
527
|
-
maxBlockHeaderSize:
|
|
528
|
-
maxTransactionSize:
|
|
529
|
-
stakeCredentialDeposit:
|
|
530
|
-
stakePoolDeposit:
|
|
531
|
-
stakePoolRetirementEpochBound:
|
|
532
|
-
desiredNumberOfStakePools:
|
|
520
|
+
delegateRepresentativeMaxIdleTime: import_effect2.Schema.Number,
|
|
521
|
+
minFeeConstant: import_effect2.Schema.Struct({ ada: LovelaceAsset }),
|
|
522
|
+
maxBlockBodySize: import_effect2.Schema.Struct({ bytes: import_effect2.Schema.Number }),
|
|
523
|
+
maxBlockHeaderSize: import_effect2.Schema.Struct({ bytes: import_effect2.Schema.Number }),
|
|
524
|
+
maxTransactionSize: import_effect2.Schema.Struct({ bytes: import_effect2.Schema.Number }),
|
|
525
|
+
stakeCredentialDeposit: import_effect2.Schema.Struct({ ada: LovelaceAsset }),
|
|
526
|
+
stakePoolDeposit: import_effect2.Schema.Struct({ ada: LovelaceAsset }),
|
|
527
|
+
stakePoolRetirementEpochBound: import_effect2.Schema.Number,
|
|
528
|
+
desiredNumberOfStakePools: import_effect2.Schema.Number,
|
|
533
529
|
stakePoolPledgeInfluence: TupleNumberFromString,
|
|
534
530
|
monetaryExpansion: TupleNumberFromString,
|
|
535
531
|
treasuryExpansion: TupleNumberFromString,
|
|
536
|
-
minStakePoolCost:
|
|
537
|
-
minUtxoDepositConstant:
|
|
538
|
-
minUtxoDepositCoefficient:
|
|
539
|
-
plutusCostModels:
|
|
540
|
-
"plutus:v1":
|
|
541
|
-
"plutus:v2":
|
|
542
|
-
"plutus:v3":
|
|
532
|
+
minStakePoolCost: import_effect2.Schema.Struct({ ada: LovelaceAsset }),
|
|
533
|
+
minUtxoDepositConstant: import_effect2.Schema.Struct({ ada: LovelaceAsset }),
|
|
534
|
+
minUtxoDepositCoefficient: import_effect2.Schema.Number,
|
|
535
|
+
plutusCostModels: import_effect2.Schema.Struct({
|
|
536
|
+
"plutus:v1": import_effect2.Schema.Array(import_effect2.Schema.Number),
|
|
537
|
+
"plutus:v2": import_effect2.Schema.Array(import_effect2.Schema.Number),
|
|
538
|
+
"plutus:v3": import_effect2.Schema.Array(import_effect2.Schema.Number)
|
|
543
539
|
}),
|
|
544
|
-
scriptExecutionPrices:
|
|
540
|
+
scriptExecutionPrices: import_effect2.Schema.Struct({
|
|
545
541
|
memory: TupleNumberFromString,
|
|
546
542
|
cpu: TupleNumberFromString
|
|
547
543
|
}),
|
|
548
|
-
maxExecutionUnitsPerTransaction:
|
|
549
|
-
memory:
|
|
550
|
-
cpu:
|
|
544
|
+
maxExecutionUnitsPerTransaction: import_effect2.Schema.Struct({
|
|
545
|
+
memory: import_effect2.Schema.Number,
|
|
546
|
+
cpu: import_effect2.Schema.Number
|
|
551
547
|
}),
|
|
552
|
-
maxExecutionUnitsPerBlock:
|
|
553
|
-
maxValueSize:
|
|
554
|
-
collateralPercentage:
|
|
555
|
-
maxCollateralInputs:
|
|
556
|
-
version:
|
|
557
|
-
});
|
|
558
|
-
var Delegation =
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
delegate:
|
|
563
|
-
rewards:
|
|
564
|
-
deposit:
|
|
548
|
+
maxExecutionUnitsPerBlock: import_effect2.Schema.Struct({ memory: import_effect2.Schema.Number, cpu: import_effect2.Schema.Number }),
|
|
549
|
+
maxValueSize: import_effect2.Schema.Struct({ bytes: import_effect2.Schema.Number }),
|
|
550
|
+
collateralPercentage: import_effect2.Schema.Number,
|
|
551
|
+
maxCollateralInputs: import_effect2.Schema.Number,
|
|
552
|
+
version: import_effect2.Schema.Struct({ major: import_effect2.Schema.Number, minor: import_effect2.Schema.Number })
|
|
553
|
+
}).annotations({ identifier: "ProtocolParametersSchema" });
|
|
554
|
+
var Delegation = import_effect2.Schema.NullOr(
|
|
555
|
+
import_effect2.Schema.Record({
|
|
556
|
+
key: import_effect2.Schema.String,
|
|
557
|
+
value: import_effect2.Schema.Struct({
|
|
558
|
+
delegate: import_effect2.Schema.Struct({ id: import_effect2.Schema.String }),
|
|
559
|
+
rewards: import_effect2.Schema.Struct({ ada: import_effect2.Schema.Struct({ lovelace: import_effect2.Schema.Number }) }),
|
|
560
|
+
deposit: import_effect2.Schema.Struct({ ada: import_effect2.Schema.Struct({ lovelace: import_effect2.Schema.Number }) })
|
|
565
561
|
})
|
|
566
|
-
)
|
|
562
|
+
})
|
|
567
563
|
);
|
|
568
|
-
var RedeemerSchema =
|
|
569
|
-
validator:
|
|
570
|
-
purpose:
|
|
564
|
+
var RedeemerSchema = import_effect2.Schema.Struct({
|
|
565
|
+
validator: import_effect2.Schema.Struct({
|
|
566
|
+
purpose: import_effect2.Schema.Literal(
|
|
571
567
|
"spend",
|
|
572
568
|
"mint",
|
|
573
569
|
"publish",
|
|
@@ -575,13 +571,13 @@ var RedeemerSchema = S.Struct({
|
|
|
575
571
|
"vote",
|
|
576
572
|
"propose"
|
|
577
573
|
),
|
|
578
|
-
index:
|
|
574
|
+
index: import_effect2.Schema.Int
|
|
579
575
|
}),
|
|
580
|
-
budget:
|
|
581
|
-
memory:
|
|
582
|
-
cpu:
|
|
576
|
+
budget: import_effect2.Schema.Struct({
|
|
577
|
+
memory: import_effect2.Schema.Int,
|
|
578
|
+
cpu: import_effect2.Schema.Int
|
|
583
579
|
})
|
|
584
|
-
});
|
|
580
|
+
}).annotations({ identifier: "RedeemerSchema" });
|
|
585
581
|
var toOgmiosUTxOs = (utxos) => {
|
|
586
582
|
const toOgmiosScript = (scriptRef) => {
|
|
587
583
|
if (scriptRef) {
|
|
@@ -637,65 +633,132 @@ var toOgmiosUTxOs = (utxos) => {
|
|
|
637
633
|
};
|
|
638
634
|
|
|
639
635
|
// src/internal/kupo.ts
|
|
640
|
-
var
|
|
641
|
-
var ValueSchema =
|
|
642
|
-
coins:
|
|
643
|
-
assets:
|
|
636
|
+
var import_effect3 = require("effect");
|
|
637
|
+
var ValueSchema = import_effect3.Schema.Struct({
|
|
638
|
+
coins: import_effect3.Schema.Number,
|
|
639
|
+
assets: import_effect3.Schema.Record({ key: import_effect3.Schema.String, value: import_effect3.Schema.Number })
|
|
644
640
|
});
|
|
645
|
-
var UTxOSchema =
|
|
646
|
-
transaction_index:
|
|
647
|
-
transaction_id:
|
|
648
|
-
output_index:
|
|
649
|
-
address:
|
|
641
|
+
var UTxOSchema = import_effect3.Schema.Struct({
|
|
642
|
+
transaction_index: import_effect3.Schema.Number,
|
|
643
|
+
transaction_id: import_effect3.Schema.String,
|
|
644
|
+
output_index: import_effect3.Schema.Number,
|
|
645
|
+
address: import_effect3.Schema.String,
|
|
650
646
|
value: ValueSchema,
|
|
651
|
-
datum_hash:
|
|
652
|
-
datum_type:
|
|
653
|
-
script_hash:
|
|
654
|
-
created_at:
|
|
655
|
-
slot_no:
|
|
656
|
-
header_hash:
|
|
647
|
+
datum_hash: import_effect3.Schema.NullOr(import_effect3.Schema.String),
|
|
648
|
+
datum_type: import_effect3.Schema.optional(import_effect3.Schema.Literal("hash", "inline")),
|
|
649
|
+
script_hash: import_effect3.Schema.NullOr(import_effect3.Schema.String),
|
|
650
|
+
created_at: import_effect3.Schema.Struct({
|
|
651
|
+
slot_no: import_effect3.Schema.Number,
|
|
652
|
+
header_hash: import_effect3.Schema.String
|
|
657
653
|
}),
|
|
658
|
-
spent_at:
|
|
659
|
-
|
|
660
|
-
slot_no:
|
|
661
|
-
header_hash:
|
|
654
|
+
spent_at: import_effect3.Schema.NullOr(
|
|
655
|
+
import_effect3.Schema.Struct({
|
|
656
|
+
slot_no: import_effect3.Schema.Number,
|
|
657
|
+
header_hash: import_effect3.Schema.String
|
|
662
658
|
})
|
|
663
659
|
)
|
|
664
660
|
});
|
|
665
|
-
var ScriptSchema =
|
|
666
|
-
|
|
667
|
-
language:
|
|
668
|
-
script:
|
|
661
|
+
var ScriptSchema = import_effect3.Schema.NullOr(
|
|
662
|
+
import_effect3.Schema.Struct({
|
|
663
|
+
language: import_effect3.Schema.Literal("native", "plutus:v1", "plutus:v2", "plutus:v3"),
|
|
664
|
+
script: import_effect3.Schema.String
|
|
669
665
|
})
|
|
670
666
|
);
|
|
671
|
-
var DatumSchema =
|
|
672
|
-
var DelegationSchema =
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
delegate:
|
|
677
|
-
rewards:
|
|
678
|
-
deposit:
|
|
667
|
+
var DatumSchema = import_effect3.Schema.NullOr(import_effect3.Schema.Struct({ datum: import_effect3.Schema.String }));
|
|
668
|
+
var DelegationSchema = import_effect3.Schema.NullOr(
|
|
669
|
+
import_effect3.Schema.Record({
|
|
670
|
+
key: import_effect3.Schema.String,
|
|
671
|
+
value: import_effect3.Schema.Struct({
|
|
672
|
+
delegate: import_effect3.Schema.Struct({ id: import_effect3.Schema.String }),
|
|
673
|
+
rewards: import_effect3.Schema.Struct({ ada: import_effect3.Schema.Struct({ lovelace: import_effect3.Schema.Number }) }),
|
|
674
|
+
deposit: import_effect3.Schema.Struct({ ada: import_effect3.Schema.Struct({ lovelace: import_effect3.Schema.Number }) })
|
|
679
675
|
})
|
|
676
|
+
})
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
// src/internal/HttpUtils.ts
|
|
680
|
+
var import_platform = require("@effect/platform");
|
|
681
|
+
var import_effect4 = require("effect");
|
|
682
|
+
var filterStatusOk = (self) => self.status >= 200 && self.status < 300 ? import_effect4.Effect.succeed(self) : self.text.pipe(
|
|
683
|
+
import_effect4.Effect.flatMap(
|
|
684
|
+
(text) => import_effect4.Effect.fail(
|
|
685
|
+
new import_platform.HttpClientError.ResponseError({
|
|
686
|
+
response: self,
|
|
687
|
+
request: self.request,
|
|
688
|
+
reason: "StatusCode",
|
|
689
|
+
description: `non 2xx status code : ${text}`
|
|
690
|
+
})
|
|
691
|
+
)
|
|
680
692
|
)
|
|
681
693
|
);
|
|
694
|
+
var makeGet = (url, schema, headers) => (0, import_effect4.pipe)(
|
|
695
|
+
// Initiate a GET request to the specified URL
|
|
696
|
+
import_platform.HttpClientRequest.get(url),
|
|
697
|
+
// Conditional bearer token authentication
|
|
698
|
+
headers ? import_platform.HttpClientRequest.setHeaders(headers) : import_effect4.identity,
|
|
699
|
+
// Execute the HTTP request and retrieve the response
|
|
700
|
+
import_platform.HttpClient.execute,
|
|
701
|
+
// Ensure only 2xx responses are treated as successes.
|
|
702
|
+
import_effect4.Effect.flatMap(filterStatusOk),
|
|
703
|
+
// Parse the response body using the provided JSON schema
|
|
704
|
+
// This validates and transforms the response to the expected type
|
|
705
|
+
import_effect4.Effect.flatMap(import_platform.HttpClientResponse.schemaBodyJson(schema)),
|
|
706
|
+
// Ensure request is aborted if the program is interrupted
|
|
707
|
+
// Prevents resource leaks and ensures clean request termination
|
|
708
|
+
import_effect4.Effect.scoped
|
|
709
|
+
);
|
|
710
|
+
var makePostAsJson = (url, data, schema, headers) => (0, import_effect4.pipe)(
|
|
711
|
+
// Initiate a POST request to the specified URL
|
|
712
|
+
import_platform.HttpClientRequest.post(url),
|
|
713
|
+
// Conditional headers
|
|
714
|
+
headers ? import_platform.HttpClientRequest.setHeaders(headers) : import_effect4.identity,
|
|
715
|
+
// Set the request body as Json
|
|
716
|
+
import_platform.HttpClientRequest.bodyJson(data),
|
|
717
|
+
// Execute the HTTP request and retrieve the response
|
|
718
|
+
import_effect4.Effect.flatMap(import_platform.HttpClient.execute),
|
|
719
|
+
// Ensure only 2xx responses are treated as successes.
|
|
720
|
+
import_effect4.Effect.flatMap(filterStatusOk),
|
|
721
|
+
// Parse the response body using the provided JSON schema
|
|
722
|
+
// This validates and transforms the response to the expected type
|
|
723
|
+
import_effect4.Effect.flatMap(import_platform.HttpClientResponse.schemaBodyJson(schema)),
|
|
724
|
+
// Ensure request is aborted if the program is interrupted
|
|
725
|
+
// Prevents resource leaks and ensures clean request termination
|
|
726
|
+
import_effect4.Effect.scoped
|
|
727
|
+
);
|
|
728
|
+
var makePostAsUint8Array = (url, data, schema, headers) => (0, import_effect4.pipe)(
|
|
729
|
+
// Initiate a POST request to the specified URL
|
|
730
|
+
import_platform.HttpClientRequest.post(url),
|
|
731
|
+
// Conditional bearer token authentication
|
|
732
|
+
headers ? import_platform.HttpClientRequest.setHeaders(headers) : import_effect4.identity,
|
|
733
|
+
// Set the request body as a Uint8Array with CBOR content type
|
|
734
|
+
import_platform.HttpClientRequest.bodyUint8Array(data, "application/cbor"),
|
|
735
|
+
// Execute the HTTP request and retrieve the response
|
|
736
|
+
import_platform.HttpClient.execute,
|
|
737
|
+
// Ensure only 2xx responses are treated as successes.
|
|
738
|
+
import_effect4.Effect.flatMap(filterStatusOk),
|
|
739
|
+
// Parse the response body using the provided JSON schema
|
|
740
|
+
// This validates and transforms the response to the expected type
|
|
741
|
+
import_effect4.Effect.flatMap(import_platform.HttpClientResponse.schemaBodyJson(schema)),
|
|
742
|
+
// Ensure request is aborted if the program is interrupted
|
|
743
|
+
// Prevents resource leaks and ensures clean request termination
|
|
744
|
+
import_effect4.Effect.scoped
|
|
745
|
+
);
|
|
682
746
|
|
|
683
747
|
// src/kupmios.ts
|
|
684
|
-
var
|
|
748
|
+
var import_platform2 = require("@effect/platform");
|
|
749
|
+
var KupmiosError = class extends import_effect6.Data.TaggedError("KupmiosError") {
|
|
685
750
|
get message() {
|
|
686
|
-
return `${
|
|
751
|
+
return `${this.cause}`;
|
|
687
752
|
}
|
|
688
753
|
};
|
|
689
754
|
var Kupmios = class {
|
|
690
755
|
kupoUrl;
|
|
691
756
|
ogmiosUrl;
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
* @param ogmiosUrl: http(s)://localhost:1337
|
|
695
|
-
*/
|
|
696
|
-
constructor(kupoUrl, ogmiosUrl) {
|
|
757
|
+
headers;
|
|
758
|
+
constructor(kupoUrl, ogmiosUrl, headers) {
|
|
697
759
|
this.kupoUrl = kupoUrl;
|
|
698
760
|
this.ogmiosUrl = ogmiosUrl;
|
|
761
|
+
this.headers = headers;
|
|
699
762
|
}
|
|
700
763
|
async getProtocolParameters() {
|
|
701
764
|
const data = {
|
|
@@ -705,27 +768,33 @@ var Kupmios = class {
|
|
|
705
768
|
id: null
|
|
706
769
|
};
|
|
707
770
|
const schema = JSONRPCSchema(ProtocolParametersSchema);
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
771
|
+
const { result } = await (0, import_effect6.pipe)(
|
|
772
|
+
makePostAsJson(
|
|
773
|
+
this.ogmiosUrl,
|
|
774
|
+
data,
|
|
775
|
+
schema,
|
|
776
|
+
this.headers?.ogmiosHeader
|
|
711
777
|
),
|
|
712
|
-
|
|
713
|
-
|
|
778
|
+
import_effect6.Effect.timeout(1e4),
|
|
779
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
780
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
781
|
+
import_effect6.Effect.runPromise
|
|
714
782
|
);
|
|
715
|
-
const result = await import_effect2.Effect.runPromise(program);
|
|
716
783
|
return toProtocolParameters(result);
|
|
717
784
|
}
|
|
718
785
|
async getUtxos(addressOrCredential) {
|
|
719
786
|
const isAddress = typeof addressOrCredential === "string";
|
|
720
787
|
const queryPredicate = isAddress ? addressOrCredential : addressOrCredential.hash;
|
|
721
788
|
const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent`;
|
|
722
|
-
const schema =
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
789
|
+
const schema = import_effect5.Schema.Array(UTxOSchema);
|
|
790
|
+
const utxos = await (0, import_effect6.pipe)(
|
|
791
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
792
|
+
import_effect6.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
793
|
+
import_effect6.Effect.timeout(1e4),
|
|
794
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
795
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
796
|
+
import_effect6.Effect.runPromise
|
|
727
797
|
);
|
|
728
|
-
const utxos = await import_effect2.Effect.runPromise(program);
|
|
729
798
|
return utxos;
|
|
730
799
|
}
|
|
731
800
|
async getUtxosWithUnit(addressOrCredential, unit) {
|
|
@@ -733,25 +802,29 @@ var Kupmios = class {
|
|
|
733
802
|
const queryPredicate = isAddress ? addressOrCredential : addressOrCredential.hash;
|
|
734
803
|
const { policyId, assetName } = (0, import_utils4.fromUnit)(unit);
|
|
735
804
|
const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent&policy_id=${policyId}${assetName ? `&asset_name=${assetName}` : ""}`;
|
|
736
|
-
const schema =
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
805
|
+
const schema = import_effect5.Schema.Array(UTxOSchema);
|
|
806
|
+
const utxos = await (0, import_effect6.pipe)(
|
|
807
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
808
|
+
import_effect6.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
809
|
+
import_effect6.Effect.timeout(1e4),
|
|
810
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
811
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
812
|
+
import_effect6.Effect.runPromise
|
|
741
813
|
);
|
|
742
|
-
const utxos = await import_effect2.Effect.runPromise(program);
|
|
743
814
|
return utxos;
|
|
744
815
|
}
|
|
745
816
|
async getUtxoByUnit(unit) {
|
|
746
817
|
const { policyId, assetName } = (0, import_utils4.fromUnit)(unit);
|
|
747
818
|
const pattern = `${this.kupoUrl}/matches/${policyId}.${assetName ? `${assetName}` : "*"}?unspent`;
|
|
748
|
-
const schema =
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
819
|
+
const schema = import_effect5.Schema.Array(UTxOSchema);
|
|
820
|
+
const utxos = await (0, import_effect6.pipe)(
|
|
821
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
822
|
+
import_effect6.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
823
|
+
import_effect6.Effect.timeout(1e4),
|
|
824
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
825
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
826
|
+
import_effect6.Effect.runPromise
|
|
753
827
|
);
|
|
754
|
-
const utxos = await import_effect2.Effect.runPromise(program);
|
|
755
828
|
if (utxos.length > 1) {
|
|
756
829
|
throw new Error("Unit needs to be an NFT or only held by one address.");
|
|
757
830
|
}
|
|
@@ -762,17 +835,20 @@ var Kupmios = class {
|
|
|
762
835
|
...new Set(outRefs.map((outRef) => outRef.txHash))
|
|
763
836
|
];
|
|
764
837
|
const mkPattern = (txHash) => `${this.kupoUrl}/matches/*@${txHash}?unspent`;
|
|
765
|
-
const schema =
|
|
766
|
-
const program =
|
|
838
|
+
const schema = import_effect5.Schema.Array(UTxOSchema);
|
|
839
|
+
const program = import_effect6.Effect.forEach(
|
|
767
840
|
queryHashes,
|
|
768
|
-
(txHash) =>
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
841
|
+
(txHash) => (0, import_effect6.pipe)(
|
|
842
|
+
makeGet(mkPattern(txHash), schema, this.headers?.kupoHeader),
|
|
843
|
+
import_effect6.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
844
|
+
import_effect6.Effect.timeout(1e4),
|
|
845
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause }))
|
|
772
846
|
)
|
|
773
847
|
);
|
|
774
|
-
const utxos = await
|
|
775
|
-
|
|
848
|
+
const utxos = await import_effect6.Effect.runPromise(
|
|
849
|
+
(0, import_effect6.pipe)(program, import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer))
|
|
850
|
+
);
|
|
851
|
+
return import_effect6.Array.flatten(utxos).filter(
|
|
776
852
|
(utxo) => outRefs.some(
|
|
777
853
|
(outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
|
|
778
854
|
)
|
|
@@ -786,14 +862,18 @@ var Kupmios = class {
|
|
|
786
862
|
id: null
|
|
787
863
|
};
|
|
788
864
|
const schema = JSONRPCSchema(Delegation);
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
|
|
865
|
+
const { result } = await (0, import_effect6.pipe)(
|
|
866
|
+
makePostAsJson(
|
|
867
|
+
this.ogmiosUrl,
|
|
868
|
+
data,
|
|
869
|
+
schema,
|
|
870
|
+
this.headers?.ogmiosHeader
|
|
792
871
|
),
|
|
793
|
-
|
|
794
|
-
|
|
872
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
873
|
+
import_effect6.Effect.timeout(1e4),
|
|
874
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
875
|
+
import_effect6.Effect.runPromise
|
|
795
876
|
);
|
|
796
|
-
const result = await import_effect2.Effect.runPromise(program);
|
|
797
877
|
const delegation = result ? Object.values(result)[0] : null;
|
|
798
878
|
return {
|
|
799
879
|
poolId: delegation?.delegate?.id || null,
|
|
@@ -803,29 +883,34 @@ var Kupmios = class {
|
|
|
803
883
|
async getDatum(datumHash) {
|
|
804
884
|
const pattern = `${this.kupoUrl}/datums/${datumHash}`;
|
|
805
885
|
const schema = DatumSchema;
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
886
|
+
const result = await (0, import_effect6.pipe)(
|
|
887
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
888
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
889
|
+
import_effect6.Effect.timeout(1e4),
|
|
890
|
+
import_effect6.Effect.flatMap(import_effect6.Effect.fromNullable),
|
|
891
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
892
|
+
import_effect6.Effect.runPromise
|
|
810
893
|
);
|
|
811
|
-
const result = await import_effect2.Effect.runPromise(program);
|
|
812
894
|
return result.datum;
|
|
813
895
|
}
|
|
814
896
|
async awaitTx(txHash, checkInterval = 2e4) {
|
|
815
897
|
const pattern = `${this.kupoUrl}/matches/*@${txHash}`;
|
|
816
|
-
const schema =
|
|
898
|
+
const schema = import_effect5.Schema.Array(UTxOSchema).annotations({
|
|
817
899
|
identifier: "Array<KupmiosSchema.KupoUTxO>"
|
|
818
900
|
});
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
901
|
+
const result = await (0, import_effect6.pipe)(
|
|
902
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
903
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
904
|
+
import_effect6.Effect.repeat({
|
|
905
|
+
schedule: import_effect6.Schedule.exponential(checkInterval),
|
|
906
|
+
until: (result2) => result2.length > 0
|
|
823
907
|
}),
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
908
|
+
import_effect6.Effect.timeout(16e4),
|
|
909
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
910
|
+
import_effect6.Effect.as(true),
|
|
911
|
+
import_effect6.Effect.runPromise
|
|
827
912
|
);
|
|
828
|
-
return
|
|
913
|
+
return result;
|
|
829
914
|
}
|
|
830
915
|
async submitTx(cbor) {
|
|
831
916
|
const data = {
|
|
@@ -837,20 +922,24 @@ var Kupmios = class {
|
|
|
837
922
|
id: null
|
|
838
923
|
};
|
|
839
924
|
const schema = JSONRPCSchema(
|
|
840
|
-
|
|
841
|
-
transaction:
|
|
842
|
-
id:
|
|
925
|
+
import_effect5.Schema.Struct({
|
|
926
|
+
transaction: import_effect5.Schema.Struct({
|
|
927
|
+
id: import_effect5.Schema.String
|
|
843
928
|
})
|
|
844
929
|
})
|
|
845
930
|
);
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
931
|
+
const { result } = await (0, import_effect6.pipe)(
|
|
932
|
+
makePostAsJson(
|
|
933
|
+
this.ogmiosUrl,
|
|
934
|
+
data,
|
|
935
|
+
schema,
|
|
936
|
+
this.headers?.ogmiosHeader
|
|
849
937
|
),
|
|
850
|
-
|
|
851
|
-
|
|
938
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
939
|
+
import_effect6.Effect.timeout(1e4),
|
|
940
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
941
|
+
import_effect6.Effect.runPromise
|
|
852
942
|
);
|
|
853
|
-
const { result } = await import_effect2.Effect.runPromise(program);
|
|
854
943
|
return result.transaction.id;
|
|
855
944
|
}
|
|
856
945
|
async evaluateTx(tx, additionalUTxOs) {
|
|
@@ -863,15 +952,19 @@ var Kupmios = class {
|
|
|
863
952
|
},
|
|
864
953
|
id: null
|
|
865
954
|
};
|
|
866
|
-
const schema = JSONRPCSchema(
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
955
|
+
const schema = JSONRPCSchema(import_effect5.Schema.Array(RedeemerSchema));
|
|
956
|
+
const { result } = await (0, import_effect6.pipe)(
|
|
957
|
+
makePostAsJson(
|
|
958
|
+
this.ogmiosUrl,
|
|
959
|
+
data,
|
|
960
|
+
schema,
|
|
961
|
+
this.headers?.ogmiosHeader
|
|
870
962
|
),
|
|
871
|
-
|
|
872
|
-
|
|
963
|
+
import_effect6.Effect.provide(import_platform2.FetchHttpClient.layer),
|
|
964
|
+
import_effect6.Effect.timeout(1e4),
|
|
965
|
+
import_effect6.Effect.catchAll((cause) => new KupmiosError({ cause })),
|
|
966
|
+
import_effect6.Effect.runPromise
|
|
873
967
|
);
|
|
874
|
-
const result = await import_effect2.Effect.runPromise(program);
|
|
875
968
|
const evalRedeemers = result.map((item) => ({
|
|
876
969
|
ex_units: {
|
|
877
970
|
mem: item.budget.memory,
|
|
@@ -883,32 +976,33 @@ var Kupmios = class {
|
|
|
883
976
|
return evalRedeemers;
|
|
884
977
|
}
|
|
885
978
|
};
|
|
886
|
-
var getDatumEffect = (kupoUrl, datum_type, datum_hash) =>
|
|
979
|
+
var getDatumEffect = (kupoUrl, datum_type, datum_hash, kupoHeader) => import_effect6.Effect.gen(function* () {
|
|
887
980
|
if (datum_type === "inline" && datum_hash) {
|
|
888
981
|
const pattern = `${kupoUrl}/datums/${datum_hash}`;
|
|
889
982
|
const schema = DatumSchema;
|
|
890
|
-
return yield*
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
983
|
+
return yield* (0, import_effect6.pipe)(
|
|
984
|
+
makeGet(pattern, schema, kupoHeader),
|
|
985
|
+
import_effect6.Effect.flatMap(import_effect6.Effect.fromNullable),
|
|
986
|
+
import_effect6.Effect.map((result) => result.datum),
|
|
987
|
+
import_effect6.Effect.retry(
|
|
988
|
+
import_effect6.Schedule.compose(import_effect6.Schedule.exponential(50), import_effect6.Schedule.recurs(5))
|
|
895
989
|
),
|
|
896
|
-
|
|
990
|
+
import_effect6.Effect.timeout(5e3)
|
|
897
991
|
);
|
|
898
992
|
} else return void 0;
|
|
899
993
|
});
|
|
900
|
-
var getScriptEffect = (kupoUrl, script_hash) =>
|
|
994
|
+
var getScriptEffect = (kupoUrl, script_hash, kupoHeader) => import_effect6.Effect.gen(function* () {
|
|
901
995
|
if (script_hash) {
|
|
902
996
|
const pattern = `${kupoUrl}/scripts/${script_hash}`;
|
|
903
997
|
const schema = ScriptSchema;
|
|
904
|
-
return yield* (0,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
998
|
+
return yield* (0, import_effect6.pipe)(
|
|
999
|
+
makeGet(pattern, schema, kupoHeader),
|
|
1000
|
+
import_effect6.Effect.flatMap(import_effect6.Effect.fromNullable),
|
|
1001
|
+
import_effect6.Effect.retry(
|
|
1002
|
+
import_effect6.Schedule.compose(import_effect6.Schedule.exponential(50), import_effect6.Schedule.recurs(5))
|
|
909
1003
|
),
|
|
910
|
-
|
|
911
|
-
|
|
1004
|
+
import_effect6.Effect.timeout(5e3),
|
|
1005
|
+
import_effect6.Effect.map(({ language, script }) => {
|
|
912
1006
|
switch (language) {
|
|
913
1007
|
case "native":
|
|
914
1008
|
return {
|
|
@@ -987,38 +1081,15 @@ var toProtocolParameters = (result) => {
|
|
|
987
1081
|
}
|
|
988
1082
|
};
|
|
989
1083
|
};
|
|
990
|
-
var
|
|
991
|
-
import_platform.HttpClientRequest.post(url),
|
|
992
|
-
import_platform.HttpClientRequest.jsonBody(data),
|
|
993
|
-
import_effect2.Effect.flatMap(import_platform.HttpClient.fetch),
|
|
994
|
-
import_platform.HttpClientResponse.json,
|
|
995
|
-
import_effect2.Effect.flatMap(S3.decodeUnknown(schema)),
|
|
996
|
-
import_effect2.Effect.catchTag(
|
|
997
|
-
"ParseError",
|
|
998
|
-
(e) => import_effect2.Effect.fail(import_schema.ArrayFormatter.formatErrorSync(e))
|
|
999
|
-
)
|
|
1000
|
-
// Effect.scoped
|
|
1001
|
-
);
|
|
1002
|
-
var fetchKupoParse = (url, schema) => (0, import_effect2.pipe)(
|
|
1003
|
-
import_platform.HttpClientRequest.get(url),
|
|
1004
|
-
import_platform.HttpClient.fetchOk,
|
|
1005
|
-
import_platform.HttpClientResponse.json,
|
|
1006
|
-
import_effect2.Effect.flatMap(S3.decodeUnknown(schema, { onExcessProperty: "error" })),
|
|
1007
|
-
import_effect2.Effect.catchTag(
|
|
1008
|
-
"ParseError",
|
|
1009
|
-
(e) => import_effect2.Effect.fail(import_schema.ArrayFormatter.formatErrorSync(e))
|
|
1010
|
-
)
|
|
1011
|
-
// Effect.scoped
|
|
1012
|
-
);
|
|
1013
|
-
var kupmiosUtxosToUtxos = (kupoURL, utxos) => import_effect2.Effect.forEach(
|
|
1084
|
+
var kupmiosUtxosToUtxos = (kupoURL, utxos, kupoHeader) => import_effect6.Effect.forEach(
|
|
1014
1085
|
utxos,
|
|
1015
1086
|
(utxo) => {
|
|
1016
|
-
return (0,
|
|
1017
|
-
|
|
1018
|
-
getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash),
|
|
1019
|
-
getScriptEffect(kupoURL, utxo.script_hash)
|
|
1087
|
+
return (0, import_effect6.pipe)(
|
|
1088
|
+
import_effect6.Effect.all([
|
|
1089
|
+
getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash, kupoHeader),
|
|
1090
|
+
getScriptEffect(kupoURL, utxo.script_hash, kupoHeader)
|
|
1020
1091
|
]),
|
|
1021
|
-
|
|
1092
|
+
import_effect6.Effect.map(
|
|
1022
1093
|
([datum, script]) => ({
|
|
1023
1094
|
txHash: utxo.transaction_id,
|
|
1024
1095
|
outputIndex: utxo.output_index,
|
|
@@ -1039,7 +1110,7 @@ var import_utils5 = require("@lucid-evolution/utils");
|
|
|
1039
1110
|
var import_utils6 = require("@lucid-evolution/utils");
|
|
1040
1111
|
var import_core_utils2 = require("@lucid-evolution/core-utils");
|
|
1041
1112
|
var import_wallet = require("@lucid-evolution/wallet");
|
|
1042
|
-
async function
|
|
1113
|
+
async function generateEmulatorAccountFromPrivateKey(assets) {
|
|
1043
1114
|
const privateKey = CML.PrivateKey.generate_ed25519().to_bech32();
|
|
1044
1115
|
const priv = CML.PrivateKey.from_bech32(privateKey);
|
|
1045
1116
|
const pubKeyHash = priv.to_public().hash();
|
|
@@ -2108,213 +2179,211 @@ var toScriptRef = (reference_script) => {
|
|
|
2108
2179
|
var lucid2 = package_default.version;
|
|
2109
2180
|
|
|
2110
2181
|
// src/koios.ts
|
|
2111
|
-
var S5 = __toESM(require("@effect/schema/Schema"), 1);
|
|
2112
2182
|
var import_core_utils4 = require("@lucid-evolution/core-utils");
|
|
2113
2183
|
var import_utils9 = require("@lucid-evolution/utils");
|
|
2114
2184
|
|
|
2115
2185
|
// src/internal/koios.ts
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2118
|
-
var import_effect3 = require("effect");
|
|
2186
|
+
var import_platform3 = require("@effect/platform");
|
|
2187
|
+
var import_effect7 = require("effect");
|
|
2119
2188
|
var import_utils8 = require("@lucid-evolution/utils");
|
|
2120
|
-
var ProtocolParametersSchema2 =
|
|
2121
|
-
pvt_motion_no_confidence:
|
|
2122
|
-
pvt_committee_normal:
|
|
2123
|
-
pvt_committee_no_confidence:
|
|
2124
|
-
pvt_hard_fork_initiation:
|
|
2125
|
-
pvtpp_security_group:
|
|
2126
|
-
dvt_motion_no_confidence:
|
|
2127
|
-
dvt_committee_normal:
|
|
2128
|
-
dvt_committee_no_confidence:
|
|
2129
|
-
dvt_update_to_constitution:
|
|
2130
|
-
dvt_hard_fork_initiation:
|
|
2131
|
-
dvt_p_p_network_group:
|
|
2132
|
-
dvt_p_p_economic_group:
|
|
2133
|
-
dvt_p_p_technical_group:
|
|
2134
|
-
dvt_p_p_gov_group:
|
|
2135
|
-
dvt_treasury_withdrawal:
|
|
2136
|
-
committee_min_size:
|
|
2137
|
-
committee_max_term_length:
|
|
2138
|
-
gov_action_lifetime:
|
|
2139
|
-
gov_action_deposit:
|
|
2140
|
-
drep_deposit:
|
|
2141
|
-
drep_activity:
|
|
2142
|
-
min_fee_ref_script_cost_per_byte:
|
|
2143
|
-
epoch_no:
|
|
2144
|
-
min_fee_a:
|
|
2145
|
-
min_fee_b:
|
|
2146
|
-
max_block_size:
|
|
2147
|
-
max_tx_size:
|
|
2148
|
-
max_bh_size:
|
|
2149
|
-
key_deposit:
|
|
2150
|
-
pool_deposit:
|
|
2151
|
-
max_epoch:
|
|
2152
|
-
optimal_pool_count:
|
|
2153
|
-
influence:
|
|
2154
|
-
monetary_expand_rate:
|
|
2155
|
-
treasury_growth_rate:
|
|
2156
|
-
decentralisation:
|
|
2157
|
-
extra_entropy:
|
|
2158
|
-
protocol_major:
|
|
2159
|
-
protocol_minor:
|
|
2160
|
-
min_utxo_value:
|
|
2161
|
-
min_pool_cost:
|
|
2162
|
-
nonce:
|
|
2163
|
-
block_hash:
|
|
2164
|
-
cost_models:
|
|
2165
|
-
PlutusV1:
|
|
2166
|
-
PlutusV2:
|
|
2167
|
-
PlutusV3:
|
|
2189
|
+
var ProtocolParametersSchema2 = import_effect7.Schema.Struct({
|
|
2190
|
+
pvt_motion_no_confidence: import_effect7.Schema.Number,
|
|
2191
|
+
pvt_committee_normal: import_effect7.Schema.Number,
|
|
2192
|
+
pvt_committee_no_confidence: import_effect7.Schema.Number,
|
|
2193
|
+
pvt_hard_fork_initiation: import_effect7.Schema.Number,
|
|
2194
|
+
pvtpp_security_group: import_effect7.Schema.Number,
|
|
2195
|
+
dvt_motion_no_confidence: import_effect7.Schema.Number,
|
|
2196
|
+
dvt_committee_normal: import_effect7.Schema.Number,
|
|
2197
|
+
dvt_committee_no_confidence: import_effect7.Schema.Number,
|
|
2198
|
+
dvt_update_to_constitution: import_effect7.Schema.Number,
|
|
2199
|
+
dvt_hard_fork_initiation: import_effect7.Schema.Number,
|
|
2200
|
+
dvt_p_p_network_group: import_effect7.Schema.Number,
|
|
2201
|
+
dvt_p_p_economic_group: import_effect7.Schema.Number,
|
|
2202
|
+
dvt_p_p_technical_group: import_effect7.Schema.Number,
|
|
2203
|
+
dvt_p_p_gov_group: import_effect7.Schema.Number,
|
|
2204
|
+
dvt_treasury_withdrawal: import_effect7.Schema.Number,
|
|
2205
|
+
committee_min_size: import_effect7.Schema.Number,
|
|
2206
|
+
committee_max_term_length: import_effect7.Schema.Number,
|
|
2207
|
+
gov_action_lifetime: import_effect7.Schema.Number,
|
|
2208
|
+
gov_action_deposit: import_effect7.Schema.NumberFromString,
|
|
2209
|
+
drep_deposit: import_effect7.Schema.NumberFromString,
|
|
2210
|
+
drep_activity: import_effect7.Schema.Number,
|
|
2211
|
+
min_fee_ref_script_cost_per_byte: import_effect7.Schema.Number,
|
|
2212
|
+
epoch_no: import_effect7.Schema.Number,
|
|
2213
|
+
min_fee_a: import_effect7.Schema.Number,
|
|
2214
|
+
min_fee_b: import_effect7.Schema.Number,
|
|
2215
|
+
max_block_size: import_effect7.Schema.Number,
|
|
2216
|
+
max_tx_size: import_effect7.Schema.Number,
|
|
2217
|
+
max_bh_size: import_effect7.Schema.Number,
|
|
2218
|
+
key_deposit: import_effect7.Schema.BigInt,
|
|
2219
|
+
pool_deposit: import_effect7.Schema.BigInt,
|
|
2220
|
+
max_epoch: import_effect7.Schema.Number,
|
|
2221
|
+
optimal_pool_count: import_effect7.Schema.Number,
|
|
2222
|
+
influence: import_effect7.Schema.Number,
|
|
2223
|
+
monetary_expand_rate: import_effect7.Schema.Number,
|
|
2224
|
+
treasury_growth_rate: import_effect7.Schema.Number,
|
|
2225
|
+
decentralisation: import_effect7.Schema.Number,
|
|
2226
|
+
extra_entropy: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2227
|
+
protocol_major: import_effect7.Schema.Number,
|
|
2228
|
+
protocol_minor: import_effect7.Schema.Number,
|
|
2229
|
+
min_utxo_value: import_effect7.Schema.String,
|
|
2230
|
+
min_pool_cost: import_effect7.Schema.String,
|
|
2231
|
+
nonce: import_effect7.Schema.String,
|
|
2232
|
+
block_hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2233
|
+
cost_models: import_effect7.Schema.Struct({
|
|
2234
|
+
PlutusV1: import_effect7.Schema.Array(import_effect7.Schema.Number),
|
|
2235
|
+
PlutusV2: import_effect7.Schema.Array(import_effect7.Schema.Number),
|
|
2236
|
+
PlutusV3: import_effect7.Schema.Array(import_effect7.Schema.Number)
|
|
2168
2237
|
}),
|
|
2169
|
-
price_mem:
|
|
2170
|
-
price_step:
|
|
2171
|
-
max_tx_ex_mem:
|
|
2172
|
-
max_tx_ex_steps:
|
|
2173
|
-
max_block_ex_mem:
|
|
2174
|
-
max_block_ex_steps:
|
|
2175
|
-
max_val_size:
|
|
2176
|
-
collateral_percent:
|
|
2177
|
-
max_collateral_inputs:
|
|
2178
|
-
coins_per_utxo_size:
|
|
2238
|
+
price_mem: import_effect7.Schema.Number,
|
|
2239
|
+
price_step: import_effect7.Schema.Number,
|
|
2240
|
+
max_tx_ex_mem: import_effect7.Schema.BigIntFromNumber,
|
|
2241
|
+
max_tx_ex_steps: import_effect7.Schema.BigIntFromNumber,
|
|
2242
|
+
max_block_ex_mem: import_effect7.Schema.Number,
|
|
2243
|
+
max_block_ex_steps: import_effect7.Schema.Number,
|
|
2244
|
+
max_val_size: import_effect7.Schema.Number,
|
|
2245
|
+
collateral_percent: import_effect7.Schema.Number,
|
|
2246
|
+
max_collateral_inputs: import_effect7.Schema.Number,
|
|
2247
|
+
coins_per_utxo_size: import_effect7.Schema.BigInt
|
|
2179
2248
|
});
|
|
2180
|
-
var AssetSchema =
|
|
2181
|
-
policy_id:
|
|
2182
|
-
asset_name:
|
|
2183
|
-
fingerprint:
|
|
2184
|
-
decimals:
|
|
2185
|
-
quantity:
|
|
2249
|
+
var AssetSchema = import_effect7.Schema.Struct({
|
|
2250
|
+
policy_id: import_effect7.Schema.String,
|
|
2251
|
+
asset_name: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2252
|
+
fingerprint: import_effect7.Schema.String,
|
|
2253
|
+
decimals: import_effect7.Schema.Number,
|
|
2254
|
+
quantity: import_effect7.Schema.String
|
|
2186
2255
|
});
|
|
2187
|
-
var ReferenceScriptSchema =
|
|
2188
|
-
hash:
|
|
2189
|
-
size:
|
|
2190
|
-
type:
|
|
2191
|
-
bytes:
|
|
2192
|
-
value:
|
|
2256
|
+
var ReferenceScriptSchema = import_effect7.Schema.Struct({
|
|
2257
|
+
hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2258
|
+
size: import_effect7.Schema.NullOr(import_effect7.Schema.Number),
|
|
2259
|
+
type: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2260
|
+
bytes: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2261
|
+
value: import_effect7.Schema.NullOr(import_effect7.Schema.Object)
|
|
2193
2262
|
});
|
|
2194
|
-
var UTxOSchema2 =
|
|
2195
|
-
tx_hash:
|
|
2196
|
-
tx_index:
|
|
2197
|
-
block_time:
|
|
2198
|
-
block_height:
|
|
2199
|
-
value:
|
|
2200
|
-
datum_hash:
|
|
2201
|
-
inline_datum:
|
|
2202
|
-
|
|
2203
|
-
bytes:
|
|
2204
|
-
value:
|
|
2263
|
+
var UTxOSchema2 = import_effect7.Schema.Struct({
|
|
2264
|
+
tx_hash: import_effect7.Schema.String,
|
|
2265
|
+
tx_index: import_effect7.Schema.Number,
|
|
2266
|
+
block_time: import_effect7.Schema.Number,
|
|
2267
|
+
block_height: import_effect7.Schema.NullOr(import_effect7.Schema.Number),
|
|
2268
|
+
value: import_effect7.Schema.String,
|
|
2269
|
+
datum_hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2270
|
+
inline_datum: import_effect7.Schema.NullOr(
|
|
2271
|
+
import_effect7.Schema.Struct({
|
|
2272
|
+
bytes: import_effect7.Schema.String,
|
|
2273
|
+
value: import_effect7.Schema.Object
|
|
2205
2274
|
})
|
|
2206
2275
|
),
|
|
2207
|
-
reference_script:
|
|
2208
|
-
asset_list:
|
|
2276
|
+
reference_script: import_effect7.Schema.NullOr(ReferenceScriptSchema),
|
|
2277
|
+
asset_list: import_effect7.Schema.NullOr(import_effect7.Schema.Array(AssetSchema))
|
|
2209
2278
|
});
|
|
2210
|
-
var AddressInfoSchema =
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
address:
|
|
2214
|
-
balance:
|
|
2215
|
-
stake_address:
|
|
2216
|
-
script_address:
|
|
2217
|
-
utxo_set:
|
|
2279
|
+
var AddressInfoSchema = import_effect7.Schema.Array(
|
|
2280
|
+
import_effect7.Schema.NullishOr(
|
|
2281
|
+
import_effect7.Schema.Struct({
|
|
2282
|
+
address: import_effect7.Schema.String,
|
|
2283
|
+
balance: import_effect7.Schema.String,
|
|
2284
|
+
stake_address: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2285
|
+
script_address: import_effect7.Schema.Boolean,
|
|
2286
|
+
utxo_set: import_effect7.Schema.Array(UTxOSchema2)
|
|
2218
2287
|
})
|
|
2219
2288
|
)
|
|
2220
2289
|
);
|
|
2221
|
-
var InputOutputSchema =
|
|
2222
|
-
payment_addr:
|
|
2223
|
-
bech32:
|
|
2224
|
-
cred:
|
|
2290
|
+
var InputOutputSchema = import_effect7.Schema.Struct({
|
|
2291
|
+
payment_addr: import_effect7.Schema.Struct({
|
|
2292
|
+
bech32: import_effect7.Schema.String,
|
|
2293
|
+
cred: import_effect7.Schema.String
|
|
2225
2294
|
}),
|
|
2226
|
-
stake_addr:
|
|
2227
|
-
tx_hash:
|
|
2228
|
-
tx_index:
|
|
2229
|
-
value:
|
|
2230
|
-
datum_hash:
|
|
2231
|
-
inline_datum:
|
|
2232
|
-
|
|
2233
|
-
bytes:
|
|
2234
|
-
value:
|
|
2295
|
+
stake_addr: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2296
|
+
tx_hash: import_effect7.Schema.String,
|
|
2297
|
+
tx_index: import_effect7.Schema.Number,
|
|
2298
|
+
value: import_effect7.Schema.String,
|
|
2299
|
+
datum_hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2300
|
+
inline_datum: import_effect7.Schema.NullOr(
|
|
2301
|
+
import_effect7.Schema.Struct({
|
|
2302
|
+
bytes: import_effect7.Schema.String,
|
|
2303
|
+
value: import_effect7.Schema.Object
|
|
2235
2304
|
})
|
|
2236
2305
|
),
|
|
2237
|
-
reference_script:
|
|
2238
|
-
asset_list:
|
|
2306
|
+
reference_script: import_effect7.Schema.NullOr(ReferenceScriptSchema),
|
|
2307
|
+
asset_list: import_effect7.Schema.Array(AssetSchema)
|
|
2239
2308
|
});
|
|
2240
|
-
var TxInfoSchema =
|
|
2241
|
-
tx_hash:
|
|
2242
|
-
block_hash:
|
|
2243
|
-
block_height:
|
|
2244
|
-
epoch_no:
|
|
2245
|
-
epoch_slot:
|
|
2246
|
-
absolute_slot:
|
|
2247
|
-
tx_timestamp:
|
|
2248
|
-
tx_block_index:
|
|
2249
|
-
tx_size:
|
|
2250
|
-
total_output:
|
|
2251
|
-
fee:
|
|
2252
|
-
treasury_donation:
|
|
2253
|
-
deposit:
|
|
2254
|
-
invalid_before:
|
|
2255
|
-
invalid_after:
|
|
2256
|
-
collateral_inputs:
|
|
2257
|
-
collateral_output:
|
|
2258
|
-
reference_inputs:
|
|
2259
|
-
inputs:
|
|
2260
|
-
outputs:
|
|
2261
|
-
withdrawals:
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
amount:
|
|
2265
|
-
stake_addr:
|
|
2309
|
+
var TxInfoSchema = import_effect7.Schema.Struct({
|
|
2310
|
+
tx_hash: import_effect7.Schema.String,
|
|
2311
|
+
block_hash: import_effect7.Schema.String,
|
|
2312
|
+
block_height: import_effect7.Schema.Number,
|
|
2313
|
+
epoch_no: import_effect7.Schema.Number,
|
|
2314
|
+
epoch_slot: import_effect7.Schema.Number,
|
|
2315
|
+
absolute_slot: import_effect7.Schema.Number,
|
|
2316
|
+
tx_timestamp: import_effect7.Schema.Number,
|
|
2317
|
+
tx_block_index: import_effect7.Schema.Number,
|
|
2318
|
+
tx_size: import_effect7.Schema.Number,
|
|
2319
|
+
total_output: import_effect7.Schema.String,
|
|
2320
|
+
fee: import_effect7.Schema.String,
|
|
2321
|
+
treasury_donation: import_effect7.Schema.String,
|
|
2322
|
+
deposit: import_effect7.Schema.String,
|
|
2323
|
+
invalid_before: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2324
|
+
invalid_after: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2325
|
+
collateral_inputs: import_effect7.Schema.NullOr(import_effect7.Schema.Array(InputOutputSchema)),
|
|
2326
|
+
collateral_output: import_effect7.Schema.NullOr(InputOutputSchema),
|
|
2327
|
+
reference_inputs: import_effect7.Schema.NullOr(import_effect7.Schema.Array(InputOutputSchema)),
|
|
2328
|
+
inputs: import_effect7.Schema.Array(InputOutputSchema),
|
|
2329
|
+
outputs: import_effect7.Schema.Array(InputOutputSchema),
|
|
2330
|
+
withdrawals: import_effect7.Schema.NullOr(
|
|
2331
|
+
import_effect7.Schema.Array(
|
|
2332
|
+
import_effect7.Schema.Struct({
|
|
2333
|
+
amount: import_effect7.Schema.String,
|
|
2334
|
+
stake_addr: import_effect7.Schema.String
|
|
2266
2335
|
})
|
|
2267
2336
|
)
|
|
2268
2337
|
),
|
|
2269
|
-
assets_minted:
|
|
2270
|
-
metadata:
|
|
2271
|
-
certificates:
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
index:
|
|
2275
|
-
type:
|
|
2276
|
-
info:
|
|
2338
|
+
assets_minted: import_effect7.Schema.NullOr(import_effect7.Schema.Array(AssetSchema)),
|
|
2339
|
+
metadata: import_effect7.Schema.NullOr(import_effect7.Schema.Object),
|
|
2340
|
+
certificates: import_effect7.Schema.NullOr(
|
|
2341
|
+
import_effect7.Schema.Array(
|
|
2342
|
+
import_effect7.Schema.Struct({
|
|
2343
|
+
index: import_effect7.Schema.Number,
|
|
2344
|
+
type: import_effect7.Schema.String,
|
|
2345
|
+
info: import_effect7.Schema.NullOr(import_effect7.Schema.Object)
|
|
2277
2346
|
})
|
|
2278
2347
|
)
|
|
2279
2348
|
),
|
|
2280
|
-
native_scripts:
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
script_hash:
|
|
2284
|
-
script_json:
|
|
2349
|
+
native_scripts: import_effect7.Schema.NullOr(
|
|
2350
|
+
import_effect7.Schema.Array(
|
|
2351
|
+
import_effect7.Schema.Struct({
|
|
2352
|
+
script_hash: import_effect7.Schema.String,
|
|
2353
|
+
script_json: import_effect7.Schema.Object
|
|
2285
2354
|
})
|
|
2286
2355
|
)
|
|
2287
2356
|
),
|
|
2288
|
-
plutus_contracts:
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
address:
|
|
2292
|
-
spends_input:
|
|
2293
|
-
|
|
2294
|
-
tx_hash:
|
|
2295
|
-
tx_index:
|
|
2357
|
+
plutus_contracts: import_effect7.Schema.NullOr(
|
|
2358
|
+
import_effect7.Schema.Array(
|
|
2359
|
+
import_effect7.Schema.Struct({
|
|
2360
|
+
address: import_effect7.Schema.String,
|
|
2361
|
+
spends_input: import_effect7.Schema.NullOr(
|
|
2362
|
+
import_effect7.Schema.Struct({
|
|
2363
|
+
tx_hash: import_effect7.Schema.String,
|
|
2364
|
+
tx_index: import_effect7.Schema.Number
|
|
2296
2365
|
})
|
|
2297
2366
|
),
|
|
2298
|
-
script_hash:
|
|
2299
|
-
bytecode:
|
|
2300
|
-
size:
|
|
2301
|
-
valid_contract:
|
|
2302
|
-
input:
|
|
2303
|
-
redeemer:
|
|
2304
|
-
purpose:
|
|
2305
|
-
fee:
|
|
2306
|
-
unit:
|
|
2307
|
-
steps:
|
|
2308
|
-
mem:
|
|
2367
|
+
script_hash: import_effect7.Schema.String,
|
|
2368
|
+
bytecode: import_effect7.Schema.String,
|
|
2369
|
+
size: import_effect7.Schema.Number,
|
|
2370
|
+
valid_contract: import_effect7.Schema.Boolean,
|
|
2371
|
+
input: import_effect7.Schema.Struct({
|
|
2372
|
+
redeemer: import_effect7.Schema.Struct({
|
|
2373
|
+
purpose: import_effect7.Schema.Literal("spend", "mint", "cert", "reward"),
|
|
2374
|
+
fee: import_effect7.Schema.String,
|
|
2375
|
+
unit: import_effect7.Schema.Struct({
|
|
2376
|
+
steps: import_effect7.Schema.String,
|
|
2377
|
+
mem: import_effect7.Schema.String
|
|
2309
2378
|
}),
|
|
2310
|
-
datum:
|
|
2311
|
-
hash:
|
|
2312
|
-
value:
|
|
2379
|
+
datum: import_effect7.Schema.Struct({
|
|
2380
|
+
hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2381
|
+
value: import_effect7.Schema.NullOr(import_effect7.Schema.Object)
|
|
2313
2382
|
})
|
|
2314
2383
|
}),
|
|
2315
|
-
datum:
|
|
2316
|
-
hash:
|
|
2317
|
-
value:
|
|
2384
|
+
datum: import_effect7.Schema.Struct({
|
|
2385
|
+
hash: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2386
|
+
value: import_effect7.Schema.NullOr(import_effect7.Schema.Object)
|
|
2318
2387
|
})
|
|
2319
2388
|
})
|
|
2320
2389
|
})
|
|
@@ -2322,45 +2391,24 @@ var TxInfoSchema = S4.Struct({
|
|
|
2322
2391
|
),
|
|
2323
2392
|
//TODO: add S.Struct
|
|
2324
2393
|
// https://preprod.koios.rest/#post-/tx_info
|
|
2325
|
-
voting_procedures:
|
|
2394
|
+
voting_procedures: import_effect7.Schema.Array(import_effect7.Schema.Object),
|
|
2326
2395
|
//TODO: add S.Struct
|
|
2327
2396
|
// https://preprod.koios.rest/#post-/tx_info
|
|
2328
|
-
proposal_procedures:
|
|
2397
|
+
proposal_procedures: import_effect7.Schema.Object
|
|
2329
2398
|
});
|
|
2330
|
-
var TxHashSchema =
|
|
2331
|
-
var AssetAddressSchema =
|
|
2332
|
-
payment_address:
|
|
2333
|
-
stake_address:
|
|
2334
|
-
quantity:
|
|
2399
|
+
var TxHashSchema = import_effect7.Schema.String;
|
|
2400
|
+
var AssetAddressSchema = import_effect7.Schema.Struct({
|
|
2401
|
+
payment_address: import_effect7.Schema.String,
|
|
2402
|
+
stake_address: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2403
|
+
quantity: import_effect7.Schema.String
|
|
2335
2404
|
});
|
|
2336
|
-
var AccountInfoSchema =
|
|
2337
|
-
delegated_pool:
|
|
2338
|
-
rewards_available:
|
|
2405
|
+
var AccountInfoSchema = import_effect7.Schema.Struct({
|
|
2406
|
+
delegated_pool: import_effect7.Schema.NullOr(import_effect7.Schema.String),
|
|
2407
|
+
rewards_available: import_effect7.Schema.NumberFromString
|
|
2339
2408
|
});
|
|
2340
|
-
var DatumInfo =
|
|
2341
|
-
bytes:
|
|
2409
|
+
var DatumInfo = import_effect7.Schema.Struct({
|
|
2410
|
+
bytes: import_effect7.Schema.String
|
|
2342
2411
|
});
|
|
2343
|
-
var postWithSchemaValidation = (url, data, schema, headers = {}) => (0, import_effect3.pipe)(
|
|
2344
|
-
import_effect3.Effect.succeed(import_platform2.HttpClientRequest.post(url)),
|
|
2345
|
-
import_effect3.Effect.map(import_platform2.HttpClientRequest.setHeaders(headers)),
|
|
2346
|
-
import_effect3.Effect.flatMap(
|
|
2347
|
-
(req) => headers["Content-Type"] === "application/cbor" ? import_effect3.Effect.succeed(
|
|
2348
|
-
import_platform2.HttpClientRequest.uint8ArrayBody(
|
|
2349
|
-
data,
|
|
2350
|
-
headers["Content-Type"]
|
|
2351
|
-
)(req)
|
|
2352
|
-
) : import_platform2.HttpClientRequest.jsonBody(data)(req)
|
|
2353
|
-
),
|
|
2354
|
-
import_effect3.Effect.flatMap(import_platform2.HttpClient.fetch),
|
|
2355
|
-
import_platform2.HttpClientResponse.json,
|
|
2356
|
-
import_effect3.Effect.flatMap(S4.decodeUnknown(schema))
|
|
2357
|
-
);
|
|
2358
|
-
var getWithSchemaValidation = (url, schema) => (0, import_effect3.pipe)(
|
|
2359
|
-
import_platform2.HttpClientRequest.get(url),
|
|
2360
|
-
import_platform2.HttpClient.fetchOk,
|
|
2361
|
-
import_platform2.HttpClientResponse.json,
|
|
2362
|
-
import_effect3.Effect.flatMap(S4.decodeUnknown(schema))
|
|
2363
|
-
);
|
|
2364
2412
|
var toUTxO = (koiosUTxO, address) => ({
|
|
2365
2413
|
txHash: koiosUTxO.tx_hash,
|
|
2366
2414
|
outputIndex: koiosUTxO.tx_index,
|
|
@@ -2402,44 +2450,51 @@ var toScriptRef2 = (reference_script) => {
|
|
|
2402
2450
|
}
|
|
2403
2451
|
}
|
|
2404
2452
|
};
|
|
2405
|
-
var getUtxosEffect = (baseUrl, addressOrCredential) => {
|
|
2453
|
+
var getUtxosEffect = (baseUrl, addressOrCredential, headers) => {
|
|
2406
2454
|
const url = `${baseUrl}/address_info`;
|
|
2407
2455
|
const body = {
|
|
2408
2456
|
_addresses: [addressOrCredential]
|
|
2409
2457
|
};
|
|
2410
2458
|
const schema = AddressInfoSchema;
|
|
2411
|
-
const result = (0,
|
|
2412
|
-
|
|
2413
|
-
onFalse: () =>
|
|
2414
|
-
onTrue: () =>
|
|
2459
|
+
const result = (0, import_effect7.pipe)(
|
|
2460
|
+
import_effect7.Effect.if(typeof addressOrCredential === "string", {
|
|
2461
|
+
onFalse: () => import_effect7.Effect.fail("Credential Type is not supported in Koios yet."),
|
|
2462
|
+
onTrue: () => makePostAsJson(url, body, schema, headers)
|
|
2415
2463
|
}),
|
|
2416
|
-
|
|
2464
|
+
import_effect7.Effect.map(
|
|
2417
2465
|
([result2]) => result2 ? result2.utxo_set.map((koiosUtxo) => toUTxO(koiosUtxo, result2.address)) : []
|
|
2418
|
-
)
|
|
2466
|
+
),
|
|
2467
|
+
import_effect7.Effect.provide(import_platform3.FetchHttpClient.layer)
|
|
2419
2468
|
);
|
|
2420
2469
|
return result;
|
|
2421
2470
|
};
|
|
2422
2471
|
|
|
2423
2472
|
// src/koios.ts
|
|
2424
|
-
var
|
|
2425
|
-
var
|
|
2473
|
+
var import_effect8 = require("effect");
|
|
2474
|
+
var import_platform4 = require("@effect/platform");
|
|
2475
|
+
var KoiosError = class extends import_effect8.Data.TaggedError("KoiosError") {
|
|
2426
2476
|
get message() {
|
|
2427
2477
|
return `${this.cause}`;
|
|
2428
2478
|
}
|
|
2429
2479
|
};
|
|
2430
2480
|
var Koios = class {
|
|
2431
2481
|
baseUrl;
|
|
2432
|
-
|
|
2482
|
+
token;
|
|
2483
|
+
constructor(baseUrl, token) {
|
|
2433
2484
|
this.baseUrl = baseUrl;
|
|
2485
|
+
this.token = token;
|
|
2434
2486
|
}
|
|
2435
2487
|
async getProtocolParameters() {
|
|
2436
2488
|
const url = `${this.baseUrl}/epoch_params?limit=1`;
|
|
2437
|
-
const schema =
|
|
2438
|
-
const
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2489
|
+
const schema = import_effect8.Schema.Array(ProtocolParametersSchema2);
|
|
2490
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2491
|
+
const [result] = await (0, import_effect8.pipe)(
|
|
2492
|
+
makeGet(url, schema, bearerToken),
|
|
2493
|
+
// Allows for dependency injection and easier testing
|
|
2494
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2495
|
+
import_effect8.Effect.timeout(1e4),
|
|
2496
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2497
|
+
import_effect8.Effect.runPromise
|
|
2443
2498
|
);
|
|
2444
2499
|
return {
|
|
2445
2500
|
minFeeA: result.min_fee_a,
|
|
@@ -2481,55 +2536,64 @@ var Koios = class {
|
|
|
2481
2536
|
};
|
|
2482
2537
|
}
|
|
2483
2538
|
async getUtxos(addressOrCredential) {
|
|
2484
|
-
const
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2539
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2540
|
+
const result = await (0, import_effect8.pipe)(
|
|
2541
|
+
getUtxosEffect(this.baseUrl, addressOrCredential, bearerToken),
|
|
2542
|
+
import_effect8.Effect.timeout(1e4),
|
|
2543
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2544
|
+
import_effect8.Effect.runPromise
|
|
2489
2545
|
);
|
|
2490
2546
|
return result;
|
|
2491
2547
|
}
|
|
2492
2548
|
async getUtxosWithUnit(addressOrCredential, unit) {
|
|
2493
|
-
const
|
|
2494
|
-
|
|
2495
|
-
|
|
2549
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2550
|
+
const result = await (0, import_effect8.pipe)(
|
|
2551
|
+
getUtxosEffect(this.baseUrl, addressOrCredential, bearerToken),
|
|
2552
|
+
import_effect8.Effect.map(
|
|
2496
2553
|
(utxos) => utxos.filter((utxo) => {
|
|
2497
2554
|
const keys = Object.keys(utxo.assets);
|
|
2498
2555
|
return keys.length > 0 && keys.includes(unit);
|
|
2499
2556
|
})
|
|
2500
2557
|
),
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2558
|
+
import_effect8.Effect.timeout(1e4),
|
|
2559
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2560
|
+
import_effect8.Effect.runPromise
|
|
2504
2561
|
);
|
|
2505
2562
|
return result;
|
|
2506
2563
|
}
|
|
2507
2564
|
async getUtxoByUnit(unit) {
|
|
2508
2565
|
let { policyId, assetName } = (0, import_utils9.fromUnit)(unit);
|
|
2509
2566
|
const url = `${this.baseUrl}/asset_addresses?_asset_policy=${policyId}&_asset_name=${assetName}`;
|
|
2510
|
-
const
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2567
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2568
|
+
const result = await (0, import_effect8.pipe)(
|
|
2569
|
+
makeGet(url, import_effect8.Schema.Array(AssetAddressSchema), bearerToken),
|
|
2570
|
+
// Allows for dependency injection and easier testing
|
|
2571
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2572
|
+
import_effect8.Effect.flatMap(
|
|
2573
|
+
(adresses) => adresses.length === 0 ? import_effect8.Effect.fail("Unit not found") : import_effect8.Effect.succeed(adresses)
|
|
2514
2574
|
),
|
|
2515
|
-
|
|
2516
|
-
(adresses) => adresses.length > 1 ?
|
|
2575
|
+
import_effect8.Effect.flatMap(
|
|
2576
|
+
(adresses) => adresses.length > 1 ? import_effect8.Effect.fail("Unit needs to be an NFT or only held by one address.") : import_effect8.Effect.succeed(adresses[0])
|
|
2517
2577
|
),
|
|
2518
|
-
|
|
2519
|
-
(address) => getUtxosEffect(
|
|
2578
|
+
import_effect8.Effect.flatMap(
|
|
2579
|
+
(address) => getUtxosEffect(
|
|
2580
|
+
this.baseUrl,
|
|
2581
|
+
address.payment_address,
|
|
2582
|
+
bearerToken
|
|
2583
|
+
)
|
|
2520
2584
|
),
|
|
2521
|
-
|
|
2585
|
+
import_effect8.Effect.map(
|
|
2522
2586
|
(utxos) => utxos.filter((utxo) => {
|
|
2523
2587
|
const keys = Object.keys(utxo.assets);
|
|
2524
2588
|
return keys.length > 0 && keys.includes(unit);
|
|
2525
2589
|
})
|
|
2526
2590
|
),
|
|
2527
|
-
|
|
2528
|
-
(utxos) => utxos.length > 1 ?
|
|
2591
|
+
import_effect8.Effect.flatMap(
|
|
2592
|
+
(utxos) => utxos.length > 1 ? import_effect8.Effect.fail("Unit needs to be an NFT or only held by one address.") : import_effect8.Effect.succeed(utxos[0])
|
|
2529
2593
|
),
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2594
|
+
import_effect8.Effect.timeout(1e4),
|
|
2595
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2596
|
+
import_effect8.Effect.runPromise
|
|
2533
2597
|
);
|
|
2534
2598
|
return result;
|
|
2535
2599
|
}
|
|
@@ -2540,12 +2604,15 @@ var Koios = class {
|
|
|
2540
2604
|
_assets: true,
|
|
2541
2605
|
_scripts: true
|
|
2542
2606
|
};
|
|
2543
|
-
const schema =
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2607
|
+
const schema = import_effect8.Schema.Array(TxInfoSchema);
|
|
2608
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2609
|
+
const [result] = await (0, import_effect8.pipe)(
|
|
2610
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2611
|
+
// Allows for dependency injection and easier testing
|
|
2612
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2613
|
+
import_effect8.Effect.timeout(1e4),
|
|
2614
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2615
|
+
import_effect8.Effect.runPromise
|
|
2549
2616
|
);
|
|
2550
2617
|
if (result) {
|
|
2551
2618
|
const utxos = result.outputs.map(
|
|
@@ -2578,18 +2645,22 @@ var Koios = class {
|
|
|
2578
2645
|
_stake_addresses: [rewardAddress]
|
|
2579
2646
|
};
|
|
2580
2647
|
const url = `${this.baseUrl}/account_info`;
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2648
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2649
|
+
const result = await (0, import_effect8.pipe)(
|
|
2650
|
+
makePostAsJson(
|
|
2583
2651
|
url,
|
|
2584
2652
|
body,
|
|
2585
|
-
|
|
2653
|
+
import_effect8.Schema.Array(AccountInfoSchema),
|
|
2654
|
+
bearerToken
|
|
2586
2655
|
),
|
|
2587
|
-
|
|
2588
|
-
|
|
2656
|
+
// Allows for dependency injection and easier testing
|
|
2657
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2658
|
+
import_effect8.Effect.flatMap(
|
|
2659
|
+
(result2) => result2.length === 0 ? import_effect8.Effect.fail("No Delegation Found by Reward Address") : import_effect8.Effect.succeed(result2[0])
|
|
2589
2660
|
),
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2661
|
+
import_effect8.Effect.timeout(1e4),
|
|
2662
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2663
|
+
import_effect8.Effect.runPromise
|
|
2593
2664
|
);
|
|
2594
2665
|
return {
|
|
2595
2666
|
poolId: result.delegated_pool || null,
|
|
@@ -2601,14 +2672,22 @@ var Koios = class {
|
|
|
2601
2672
|
const body = {
|
|
2602
2673
|
_datum_hashes: [datumHash]
|
|
2603
2674
|
};
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2675
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2676
|
+
const result = await (0, import_effect8.pipe)(
|
|
2677
|
+
makePostAsJson(
|
|
2678
|
+
url,
|
|
2679
|
+
body,
|
|
2680
|
+
import_effect8.Schema.Array(DatumInfo),
|
|
2681
|
+
bearerToken
|
|
2608
2682
|
),
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2683
|
+
// Allows for dependency injection and easier testing
|
|
2684
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2685
|
+
import_effect8.Effect.flatMap(
|
|
2686
|
+
(result2) => result2.length === 0 ? import_effect8.Effect.fail("No Datum Found by Datum Hash") : import_effect8.Effect.succeed(result2[0])
|
|
2687
|
+
),
|
|
2688
|
+
import_effect8.Effect.timeout(1e4),
|
|
2689
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2690
|
+
import_effect8.Effect.runPromise
|
|
2612
2691
|
);
|
|
2613
2692
|
return result.bytes;
|
|
2614
2693
|
}
|
|
@@ -2617,17 +2696,20 @@ var Koios = class {
|
|
|
2617
2696
|
const body = {
|
|
2618
2697
|
_tx_hashes: [txHash]
|
|
2619
2698
|
};
|
|
2620
|
-
const schema =
|
|
2621
|
-
const
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2699
|
+
const schema = import_effect8.Schema.Array(TxInfoSchema);
|
|
2700
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2701
|
+
const result = await (0, import_effect8.pipe)(
|
|
2702
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2703
|
+
import_effect8.Effect.repeat({
|
|
2704
|
+
schedule: import_effect8.Schedule.exponential(checkInterval),
|
|
2625
2705
|
until: (result2) => result2.length > 0
|
|
2626
2706
|
}),
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2707
|
+
// Allows for dependency injection and easier testing
|
|
2708
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2709
|
+
import_effect8.Effect.timeout(16e4),
|
|
2710
|
+
import_effect8.Effect.orDie,
|
|
2711
|
+
import_effect8.Effect.as(true),
|
|
2712
|
+
import_effect8.Effect.runPromise
|
|
2631
2713
|
);
|
|
2632
2714
|
return result;
|
|
2633
2715
|
}
|
|
@@ -2635,13 +2717,14 @@ var Koios = class {
|
|
|
2635
2717
|
const url = `${this.baseUrl}/submittx`;
|
|
2636
2718
|
const body = (0, import_core_utils4.fromHex)(tx);
|
|
2637
2719
|
const schema = TxHashSchema;
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2720
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2721
|
+
const result = await (0, import_effect8.pipe)(
|
|
2722
|
+
makePostAsUint8Array(url, body, schema, bearerToken),
|
|
2723
|
+
// Allows for dependency injection and easier testing
|
|
2724
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2725
|
+
import_effect8.Effect.timeout(1e4),
|
|
2726
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2727
|
+
import_effect8.Effect.runPromise
|
|
2645
2728
|
);
|
|
2646
2729
|
return result;
|
|
2647
2730
|
}
|
|
@@ -2656,15 +2739,15 @@ var Koios = class {
|
|
|
2656
2739
|
},
|
|
2657
2740
|
id: null
|
|
2658
2741
|
};
|
|
2659
|
-
const schema = JSONRPCSchema(
|
|
2660
|
-
const
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
),
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2742
|
+
const schema = JSONRPCSchema(import_effect8.Schema.Array(RedeemerSchema));
|
|
2743
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2744
|
+
const { result } = await (0, import_effect8.pipe)(
|
|
2745
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2746
|
+
// Allows for dependency injection and easier testing
|
|
2747
|
+
import_effect8.Effect.provide(import_platform4.FetchHttpClient.layer),
|
|
2748
|
+
import_effect8.Effect.timeout(1e4),
|
|
2749
|
+
import_effect8.Effect.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2750
|
+
import_effect8.Effect.runPromise
|
|
2668
2751
|
);
|
|
2669
2752
|
const evalRedeemers = result.map((item) => ({
|
|
2670
2753
|
ex_units: {
|
|
@@ -2687,5 +2770,5 @@ var Koios = class {
|
|
|
2687
2770
|
KupmiosError,
|
|
2688
2771
|
Maestro,
|
|
2689
2772
|
generateEmulatorAccount,
|
|
2690
|
-
|
|
2773
|
+
generateEmulatorAccountFromPrivateKey
|
|
2691
2774
|
});
|