@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.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@lucid-evolution/provider",
|
|
14
|
-
version: "0.1.
|
|
14
|
+
version: "0.1.84",
|
|
15
15
|
description: "",
|
|
16
16
|
main: "./dist/index.js",
|
|
17
17
|
types: "./dist/index.d.ts",
|
|
@@ -43,13 +43,13 @@ var package_default = {
|
|
|
43
43
|
dependencies: {
|
|
44
44
|
"@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-3",
|
|
45
45
|
"@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-3",
|
|
46
|
-
"@effect/platform": "^0.
|
|
46
|
+
"@effect/platform": "^0.71.3",
|
|
47
47
|
"@effect/schema": "^0.68.26",
|
|
48
48
|
"@lucid-evolution/core-types": "workspace:*",
|
|
49
49
|
"@lucid-evolution/core-utils": "workspace:*",
|
|
50
50
|
"@lucid-evolution/utils": "workspace:*",
|
|
51
51
|
"@lucid-evolution/wallet": "workspace:*",
|
|
52
|
-
effect: "^3.
|
|
52
|
+
effect: "^3.11.7"
|
|
53
53
|
},
|
|
54
54
|
devDependencies: {
|
|
55
55
|
"@types/node": "^20.12.8",
|
|
@@ -411,26 +411,18 @@ var lucid = package_default.version;
|
|
|
411
411
|
|
|
412
412
|
// src/kupmios.ts
|
|
413
413
|
import { applyDoubleCborEncoding as applyDoubleCborEncoding2, fromUnit as fromUnit2 } from "@lucid-evolution/utils";
|
|
414
|
-
import
|
|
415
|
-
import { Effect, pipe as
|
|
416
|
-
import {
|
|
417
|
-
HttpClient,
|
|
418
|
-
HttpClientRequest,
|
|
419
|
-
HttpClientResponse
|
|
420
|
-
} from "@effect/platform";
|
|
421
|
-
import { ArrayFormatter } from "@effect/schema";
|
|
414
|
+
import { Schema as S3 } from "effect";
|
|
415
|
+
import { Effect as Effect2, pipe as pipe3, Array as _Array, Schedule, Data } from "effect";
|
|
422
416
|
|
|
423
417
|
// src/internal/ogmios.ts
|
|
424
|
-
import
|
|
418
|
+
import { Schema as S } from "effect";
|
|
425
419
|
import { applySingleCborEncoding as applySingleCborEncoding2, fromUnit } from "@lucid-evolution/utils";
|
|
426
|
-
var JSONRPCSchema = (schema) => S.
|
|
427
|
-
S.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
S.Union(S.Struct({ result: schema }), S.Struct({ error: S.Object }))
|
|
433
|
-
);
|
|
420
|
+
var JSONRPCSchema = (schema) => S.Struct({
|
|
421
|
+
jsonrpc: S.String,
|
|
422
|
+
method: S.optional(S.String),
|
|
423
|
+
id: S.NullOr(S.Number),
|
|
424
|
+
result: schema
|
|
425
|
+
}).annotations({ identifier: "JSONRPCSchema" });
|
|
434
426
|
var LovelaceAsset = S.Struct({
|
|
435
427
|
lovelace: S.Number
|
|
436
428
|
});
|
|
@@ -517,16 +509,16 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
517
509
|
collateralPercentage: S.Number,
|
|
518
510
|
maxCollateralInputs: S.Number,
|
|
519
511
|
version: S.Struct({ major: S.Number, minor: S.Number })
|
|
520
|
-
});
|
|
512
|
+
}).annotations({ identifier: "ProtocolParametersSchema" });
|
|
521
513
|
var Delegation = S.NullOr(
|
|
522
|
-
S.Record(
|
|
523
|
-
S.String,
|
|
524
|
-
S.Struct({
|
|
514
|
+
S.Record({
|
|
515
|
+
key: S.String,
|
|
516
|
+
value: S.Struct({
|
|
525
517
|
delegate: S.Struct({ id: S.String }),
|
|
526
518
|
rewards: S.Struct({ ada: S.Struct({ lovelace: S.Number }) }),
|
|
527
519
|
deposit: S.Struct({ ada: S.Struct({ lovelace: S.Number }) })
|
|
528
520
|
})
|
|
529
|
-
)
|
|
521
|
+
})
|
|
530
522
|
);
|
|
531
523
|
var RedeemerSchema = S.Struct({
|
|
532
524
|
validator: S.Struct({
|
|
@@ -544,7 +536,7 @@ var RedeemerSchema = S.Struct({
|
|
|
544
536
|
memory: S.Int,
|
|
545
537
|
cpu: S.Int
|
|
546
538
|
})
|
|
547
|
-
});
|
|
539
|
+
}).annotations({ identifier: "RedeemerSchema" });
|
|
548
540
|
var toOgmiosUTxOs = (utxos) => {
|
|
549
541
|
const toOgmiosScript = (scriptRef) => {
|
|
550
542
|
if (scriptRef) {
|
|
@@ -600,10 +592,10 @@ var toOgmiosUTxOs = (utxos) => {
|
|
|
600
592
|
};
|
|
601
593
|
|
|
602
594
|
// src/internal/kupo.ts
|
|
603
|
-
import
|
|
595
|
+
import { Schema as S2 } from "effect";
|
|
604
596
|
var ValueSchema = S2.Struct({
|
|
605
597
|
coins: S2.Number,
|
|
606
|
-
assets: S2.Record(S2.String, S2.Number)
|
|
598
|
+
assets: S2.Record({ key: S2.String, value: S2.Number })
|
|
607
599
|
});
|
|
608
600
|
var UTxOSchema = S2.Struct({
|
|
609
601
|
transaction_index: S2.Number,
|
|
@@ -633,32 +625,104 @@ var ScriptSchema = S2.NullOr(
|
|
|
633
625
|
);
|
|
634
626
|
var DatumSchema = S2.NullOr(S2.Struct({ datum: S2.String }));
|
|
635
627
|
var DelegationSchema = S2.NullOr(
|
|
636
|
-
S2.Record(
|
|
637
|
-
S2.String,
|
|
638
|
-
S2.Struct({
|
|
628
|
+
S2.Record({
|
|
629
|
+
key: S2.String,
|
|
630
|
+
value: S2.Struct({
|
|
639
631
|
delegate: S2.Struct({ id: S2.String }),
|
|
640
632
|
rewards: S2.Struct({ ada: S2.Struct({ lovelace: S2.Number }) }),
|
|
641
633
|
deposit: S2.Struct({ ada: S2.Struct({ lovelace: S2.Number }) })
|
|
642
634
|
})
|
|
635
|
+
})
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
// src/internal/HttpUtils.ts
|
|
639
|
+
import {
|
|
640
|
+
HttpClient,
|
|
641
|
+
HttpClientError,
|
|
642
|
+
HttpClientRequest,
|
|
643
|
+
HttpClientResponse
|
|
644
|
+
} from "@effect/platform";
|
|
645
|
+
import { Effect, identity, pipe as pipe2 } from "effect";
|
|
646
|
+
var filterStatusOk = (self) => self.status >= 200 && self.status < 300 ? Effect.succeed(self) : self.text.pipe(
|
|
647
|
+
Effect.flatMap(
|
|
648
|
+
(text) => Effect.fail(
|
|
649
|
+
new HttpClientError.ResponseError({
|
|
650
|
+
response: self,
|
|
651
|
+
request: self.request,
|
|
652
|
+
reason: "StatusCode",
|
|
653
|
+
description: `non 2xx status code : ${text}`
|
|
654
|
+
})
|
|
655
|
+
)
|
|
643
656
|
)
|
|
644
657
|
);
|
|
658
|
+
var makeGet = (url, schema, headers) => pipe2(
|
|
659
|
+
// Initiate a GET request to the specified URL
|
|
660
|
+
HttpClientRequest.get(url),
|
|
661
|
+
// Conditional bearer token authentication
|
|
662
|
+
headers ? HttpClientRequest.setHeaders(headers) : identity,
|
|
663
|
+
// Execute the HTTP request and retrieve the response
|
|
664
|
+
HttpClient.execute,
|
|
665
|
+
// Ensure only 2xx responses are treated as successes.
|
|
666
|
+
Effect.flatMap(filterStatusOk),
|
|
667
|
+
// Parse the response body using the provided JSON schema
|
|
668
|
+
// This validates and transforms the response to the expected type
|
|
669
|
+
Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),
|
|
670
|
+
// Ensure request is aborted if the program is interrupted
|
|
671
|
+
// Prevents resource leaks and ensures clean request termination
|
|
672
|
+
Effect.scoped
|
|
673
|
+
);
|
|
674
|
+
var makePostAsJson = (url, data, schema, headers) => pipe2(
|
|
675
|
+
// Initiate a POST request to the specified URL
|
|
676
|
+
HttpClientRequest.post(url),
|
|
677
|
+
// Conditional headers
|
|
678
|
+
headers ? HttpClientRequest.setHeaders(headers) : identity,
|
|
679
|
+
// Set the request body as Json
|
|
680
|
+
HttpClientRequest.bodyJson(data),
|
|
681
|
+
// Execute the HTTP request and retrieve the response
|
|
682
|
+
Effect.flatMap(HttpClient.execute),
|
|
683
|
+
// Ensure only 2xx responses are treated as successes.
|
|
684
|
+
Effect.flatMap(filterStatusOk),
|
|
685
|
+
// Parse the response body using the provided JSON schema
|
|
686
|
+
// This validates and transforms the response to the expected type
|
|
687
|
+
Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),
|
|
688
|
+
// Ensure request is aborted if the program is interrupted
|
|
689
|
+
// Prevents resource leaks and ensures clean request termination
|
|
690
|
+
Effect.scoped
|
|
691
|
+
);
|
|
692
|
+
var makePostAsUint8Array = (url, data, schema, headers) => pipe2(
|
|
693
|
+
// Initiate a POST request to the specified URL
|
|
694
|
+
HttpClientRequest.post(url),
|
|
695
|
+
// Conditional bearer token authentication
|
|
696
|
+
headers ? HttpClientRequest.setHeaders(headers) : identity,
|
|
697
|
+
// Set the request body as a Uint8Array with CBOR content type
|
|
698
|
+
HttpClientRequest.bodyUint8Array(data, "application/cbor"),
|
|
699
|
+
// Execute the HTTP request and retrieve the response
|
|
700
|
+
HttpClient.execute,
|
|
701
|
+
// Ensure only 2xx responses are treated as successes.
|
|
702
|
+
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
|
+
Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),
|
|
706
|
+
// Ensure request is aborted if the program is interrupted
|
|
707
|
+
// Prevents resource leaks and ensures clean request termination
|
|
708
|
+
Effect.scoped
|
|
709
|
+
);
|
|
645
710
|
|
|
646
711
|
// src/kupmios.ts
|
|
712
|
+
import { FetchHttpClient } from "@effect/platform";
|
|
647
713
|
var KupmiosError = class extends Data.TaggedError("KupmiosError") {
|
|
648
714
|
get message() {
|
|
649
|
-
return `${
|
|
715
|
+
return `${this.cause}`;
|
|
650
716
|
}
|
|
651
717
|
};
|
|
652
718
|
var Kupmios = class {
|
|
653
719
|
kupoUrl;
|
|
654
720
|
ogmiosUrl;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
* @param ogmiosUrl: http(s)://localhost:1337
|
|
658
|
-
*/
|
|
659
|
-
constructor(kupoUrl, ogmiosUrl) {
|
|
721
|
+
headers;
|
|
722
|
+
constructor(kupoUrl, ogmiosUrl, headers) {
|
|
660
723
|
this.kupoUrl = kupoUrl;
|
|
661
724
|
this.ogmiosUrl = ogmiosUrl;
|
|
725
|
+
this.headers = headers;
|
|
662
726
|
}
|
|
663
727
|
async getProtocolParameters() {
|
|
664
728
|
const data = {
|
|
@@ -668,14 +732,18 @@ var Kupmios = class {
|
|
|
668
732
|
id: null
|
|
669
733
|
};
|
|
670
734
|
const schema = JSONRPCSchema(ProtocolParametersSchema);
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
|
|
735
|
+
const { result } = await pipe3(
|
|
736
|
+
makePostAsJson(
|
|
737
|
+
this.ogmiosUrl,
|
|
738
|
+
data,
|
|
739
|
+
schema,
|
|
740
|
+
this.headers?.ogmiosHeader
|
|
674
741
|
),
|
|
675
|
-
|
|
676
|
-
|
|
742
|
+
Effect2.timeout(1e4),
|
|
743
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
744
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
745
|
+
Effect2.runPromise
|
|
677
746
|
);
|
|
678
|
-
const result = await Effect.runPromise(program);
|
|
679
747
|
return toProtocolParameters(result);
|
|
680
748
|
}
|
|
681
749
|
async getUtxos(addressOrCredential) {
|
|
@@ -683,12 +751,14 @@ var Kupmios = class {
|
|
|
683
751
|
const queryPredicate = isAddress ? addressOrCredential : addressOrCredential.hash;
|
|
684
752
|
const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent`;
|
|
685
753
|
const schema = S3.Array(UTxOSchema);
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
754
|
+
const utxos = await pipe3(
|
|
755
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
756
|
+
Effect2.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
757
|
+
Effect2.timeout(1e4),
|
|
758
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
759
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
760
|
+
Effect2.runPromise
|
|
690
761
|
);
|
|
691
|
-
const utxos = await Effect.runPromise(program);
|
|
692
762
|
return utxos;
|
|
693
763
|
}
|
|
694
764
|
async getUtxosWithUnit(addressOrCredential, unit) {
|
|
@@ -697,24 +767,28 @@ var Kupmios = class {
|
|
|
697
767
|
const { policyId, assetName } = fromUnit2(unit);
|
|
698
768
|
const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent&policy_id=${policyId}${assetName ? `&asset_name=${assetName}` : ""}`;
|
|
699
769
|
const schema = S3.Array(UTxOSchema);
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
770
|
+
const utxos = await pipe3(
|
|
771
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
772
|
+
Effect2.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
773
|
+
Effect2.timeout(1e4),
|
|
774
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
775
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
776
|
+
Effect2.runPromise
|
|
704
777
|
);
|
|
705
|
-
const utxos = await Effect.runPromise(program);
|
|
706
778
|
return utxos;
|
|
707
779
|
}
|
|
708
780
|
async getUtxoByUnit(unit) {
|
|
709
781
|
const { policyId, assetName } = fromUnit2(unit);
|
|
710
782
|
const pattern = `${this.kupoUrl}/matches/${policyId}.${assetName ? `${assetName}` : "*"}?unspent`;
|
|
711
783
|
const schema = S3.Array(UTxOSchema);
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
784
|
+
const utxos = await pipe3(
|
|
785
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
786
|
+
Effect2.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
787
|
+
Effect2.timeout(1e4),
|
|
788
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
789
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
790
|
+
Effect2.runPromise
|
|
716
791
|
);
|
|
717
|
-
const utxos = await Effect.runPromise(program);
|
|
718
792
|
if (utxos.length > 1) {
|
|
719
793
|
throw new Error("Unit needs to be an NFT or only held by one address.");
|
|
720
794
|
}
|
|
@@ -726,15 +800,18 @@ var Kupmios = class {
|
|
|
726
800
|
];
|
|
727
801
|
const mkPattern = (txHash) => `${this.kupoUrl}/matches/*@${txHash}?unspent`;
|
|
728
802
|
const schema = S3.Array(UTxOSchema);
|
|
729
|
-
const program =
|
|
803
|
+
const program = Effect2.forEach(
|
|
730
804
|
queryHashes,
|
|
731
|
-
(txHash) =>
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
805
|
+
(txHash) => pipe3(
|
|
806
|
+
makeGet(mkPattern(txHash), schema, this.headers?.kupoHeader),
|
|
807
|
+
Effect2.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
|
|
808
|
+
Effect2.timeout(1e4),
|
|
809
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause }))
|
|
735
810
|
)
|
|
736
811
|
);
|
|
737
|
-
const utxos = await
|
|
812
|
+
const utxos = await Effect2.runPromise(
|
|
813
|
+
pipe3(program, Effect2.provide(FetchHttpClient.layer))
|
|
814
|
+
);
|
|
738
815
|
return _Array.flatten(utxos).filter(
|
|
739
816
|
(utxo) => outRefs.some(
|
|
740
817
|
(outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
|
|
@@ -749,14 +826,18 @@ var Kupmios = class {
|
|
|
749
826
|
id: null
|
|
750
827
|
};
|
|
751
828
|
const schema = JSONRPCSchema(Delegation);
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
829
|
+
const { result } = await pipe3(
|
|
830
|
+
makePostAsJson(
|
|
831
|
+
this.ogmiosUrl,
|
|
832
|
+
data,
|
|
833
|
+
schema,
|
|
834
|
+
this.headers?.ogmiosHeader
|
|
755
835
|
),
|
|
756
|
-
|
|
757
|
-
|
|
836
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
837
|
+
Effect2.timeout(1e4),
|
|
838
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
839
|
+
Effect2.runPromise
|
|
758
840
|
);
|
|
759
|
-
const result = await Effect.runPromise(program);
|
|
760
841
|
const delegation = result ? Object.values(result)[0] : null;
|
|
761
842
|
return {
|
|
762
843
|
poolId: delegation?.delegate?.id || null,
|
|
@@ -766,12 +847,14 @@ var Kupmios = class {
|
|
|
766
847
|
async getDatum(datumHash) {
|
|
767
848
|
const pattern = `${this.kupoUrl}/datums/${datumHash}`;
|
|
768
849
|
const schema = DatumSchema;
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
850
|
+
const result = await pipe3(
|
|
851
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
852
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
853
|
+
Effect2.timeout(1e4),
|
|
854
|
+
Effect2.flatMap(Effect2.fromNullable),
|
|
855
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
856
|
+
Effect2.runPromise
|
|
773
857
|
);
|
|
774
|
-
const result = await Effect.runPromise(program);
|
|
775
858
|
return result.datum;
|
|
776
859
|
}
|
|
777
860
|
async awaitTx(txHash, checkInterval = 2e4) {
|
|
@@ -779,16 +862,19 @@ var Kupmios = class {
|
|
|
779
862
|
const schema = S3.Array(UTxOSchema).annotations({
|
|
780
863
|
identifier: "Array<KupmiosSchema.KupoUTxO>"
|
|
781
864
|
});
|
|
782
|
-
const
|
|
783
|
-
|
|
865
|
+
const result = await pipe3(
|
|
866
|
+
makeGet(pattern, schema, this.headers?.kupoHeader),
|
|
867
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
868
|
+
Effect2.repeat({
|
|
784
869
|
schedule: Schedule.exponential(checkInterval),
|
|
785
|
-
until: (
|
|
870
|
+
until: (result2) => result2.length > 0
|
|
786
871
|
}),
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
872
|
+
Effect2.timeout(16e4),
|
|
873
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
874
|
+
Effect2.as(true),
|
|
875
|
+
Effect2.runPromise
|
|
790
876
|
);
|
|
791
|
-
return
|
|
877
|
+
return result;
|
|
792
878
|
}
|
|
793
879
|
async submitTx(cbor) {
|
|
794
880
|
const data = {
|
|
@@ -806,14 +892,18 @@ var Kupmios = class {
|
|
|
806
892
|
})
|
|
807
893
|
})
|
|
808
894
|
);
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
895
|
+
const { result } = await pipe3(
|
|
896
|
+
makePostAsJson(
|
|
897
|
+
this.ogmiosUrl,
|
|
898
|
+
data,
|
|
899
|
+
schema,
|
|
900
|
+
this.headers?.ogmiosHeader
|
|
812
901
|
),
|
|
813
|
-
|
|
814
|
-
|
|
902
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
903
|
+
Effect2.timeout(1e4),
|
|
904
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
905
|
+
Effect2.runPromise
|
|
815
906
|
);
|
|
816
|
-
const { result } = await Effect.runPromise(program);
|
|
817
907
|
return result.transaction.id;
|
|
818
908
|
}
|
|
819
909
|
async evaluateTx(tx, additionalUTxOs) {
|
|
@@ -827,14 +917,18 @@ var Kupmios = class {
|
|
|
827
917
|
id: null
|
|
828
918
|
};
|
|
829
919
|
const schema = JSONRPCSchema(S3.Array(RedeemerSchema));
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
920
|
+
const { result } = await pipe3(
|
|
921
|
+
makePostAsJson(
|
|
922
|
+
this.ogmiosUrl,
|
|
923
|
+
data,
|
|
924
|
+
schema,
|
|
925
|
+
this.headers?.ogmiosHeader
|
|
833
926
|
),
|
|
834
|
-
|
|
835
|
-
|
|
927
|
+
Effect2.provide(FetchHttpClient.layer),
|
|
928
|
+
Effect2.timeout(1e4),
|
|
929
|
+
Effect2.catchAll((cause) => new KupmiosError({ cause })),
|
|
930
|
+
Effect2.runPromise
|
|
836
931
|
);
|
|
837
|
-
const result = await Effect.runPromise(program);
|
|
838
932
|
const evalRedeemers = result.map((item) => ({
|
|
839
933
|
ex_units: {
|
|
840
934
|
mem: item.budget.memory,
|
|
@@ -846,32 +940,33 @@ var Kupmios = class {
|
|
|
846
940
|
return evalRedeemers;
|
|
847
941
|
}
|
|
848
942
|
};
|
|
849
|
-
var getDatumEffect = (kupoUrl, datum_type, datum_hash) =>
|
|
943
|
+
var getDatumEffect = (kupoUrl, datum_type, datum_hash, kupoHeader) => Effect2.gen(function* () {
|
|
850
944
|
if (datum_type === "inline" && datum_hash) {
|
|
851
945
|
const pattern = `${kupoUrl}/datums/${datum_hash}`;
|
|
852
946
|
const schema = DatumSchema;
|
|
853
|
-
return yield*
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
947
|
+
return yield* pipe3(
|
|
948
|
+
makeGet(pattern, schema, kupoHeader),
|
|
949
|
+
Effect2.flatMap(Effect2.fromNullable),
|
|
950
|
+
Effect2.map((result) => result.datum),
|
|
951
|
+
Effect2.retry(
|
|
857
952
|
Schedule.compose(Schedule.exponential(50), Schedule.recurs(5))
|
|
858
953
|
),
|
|
859
|
-
|
|
954
|
+
Effect2.timeout(5e3)
|
|
860
955
|
);
|
|
861
956
|
} else return void 0;
|
|
862
957
|
});
|
|
863
|
-
var getScriptEffect = (kupoUrl, script_hash) =>
|
|
958
|
+
var getScriptEffect = (kupoUrl, script_hash, kupoHeader) => Effect2.gen(function* () {
|
|
864
959
|
if (script_hash) {
|
|
865
960
|
const pattern = `${kupoUrl}/scripts/${script_hash}`;
|
|
866
961
|
const schema = ScriptSchema;
|
|
867
|
-
return yield*
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
962
|
+
return yield* pipe3(
|
|
963
|
+
makeGet(pattern, schema, kupoHeader),
|
|
964
|
+
Effect2.flatMap(Effect2.fromNullable),
|
|
965
|
+
Effect2.retry(
|
|
871
966
|
Schedule.compose(Schedule.exponential(50), Schedule.recurs(5))
|
|
872
967
|
),
|
|
873
|
-
|
|
874
|
-
|
|
968
|
+
Effect2.timeout(5e3),
|
|
969
|
+
Effect2.map(({ language, script }) => {
|
|
875
970
|
switch (language) {
|
|
876
971
|
case "native":
|
|
877
972
|
return {
|
|
@@ -950,38 +1045,15 @@ var toProtocolParameters = (result) => {
|
|
|
950
1045
|
}
|
|
951
1046
|
};
|
|
952
1047
|
};
|
|
953
|
-
var
|
|
954
|
-
HttpClientRequest.post(url),
|
|
955
|
-
HttpClientRequest.jsonBody(data),
|
|
956
|
-
Effect.flatMap(HttpClient.fetch),
|
|
957
|
-
HttpClientResponse.json,
|
|
958
|
-
Effect.flatMap(S3.decodeUnknown(schema)),
|
|
959
|
-
Effect.catchTag(
|
|
960
|
-
"ParseError",
|
|
961
|
-
(e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
|
|
962
|
-
)
|
|
963
|
-
// Effect.scoped
|
|
964
|
-
);
|
|
965
|
-
var fetchKupoParse = (url, schema) => pipe2(
|
|
966
|
-
HttpClientRequest.get(url),
|
|
967
|
-
HttpClient.fetchOk,
|
|
968
|
-
HttpClientResponse.json,
|
|
969
|
-
Effect.flatMap(S3.decodeUnknown(schema, { onExcessProperty: "error" })),
|
|
970
|
-
Effect.catchTag(
|
|
971
|
-
"ParseError",
|
|
972
|
-
(e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
|
|
973
|
-
)
|
|
974
|
-
// Effect.scoped
|
|
975
|
-
);
|
|
976
|
-
var kupmiosUtxosToUtxos = (kupoURL, utxos) => Effect.forEach(
|
|
1048
|
+
var kupmiosUtxosToUtxos = (kupoURL, utxos, kupoHeader) => Effect2.forEach(
|
|
977
1049
|
utxos,
|
|
978
1050
|
(utxo) => {
|
|
979
|
-
return
|
|
980
|
-
|
|
981
|
-
getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash),
|
|
982
|
-
getScriptEffect(kupoURL, utxo.script_hash)
|
|
1051
|
+
return pipe3(
|
|
1052
|
+
Effect2.all([
|
|
1053
|
+
getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash, kupoHeader),
|
|
1054
|
+
getScriptEffect(kupoURL, utxo.script_hash, kupoHeader)
|
|
983
1055
|
]),
|
|
984
|
-
|
|
1056
|
+
Effect2.map(
|
|
985
1057
|
([datum, script]) => ({
|
|
986
1058
|
txHash: utxo.transaction_id,
|
|
987
1059
|
outputIndex: utxo.output_index,
|
|
@@ -1006,7 +1078,7 @@ import {
|
|
|
1006
1078
|
import { coreToUtxo, getAddressDetails } from "@lucid-evolution/utils";
|
|
1007
1079
|
import { fromHex as fromHex2 } from "@lucid-evolution/core-utils";
|
|
1008
1080
|
import { walletFromSeed } from "@lucid-evolution/wallet";
|
|
1009
|
-
async function
|
|
1081
|
+
async function generateEmulatorAccountFromPrivateKey(assets) {
|
|
1010
1082
|
const privateKey = CML.PrivateKey.generate_ed25519().to_bech32();
|
|
1011
1083
|
const priv = CML.PrivateKey.from_bech32(privateKey);
|
|
1012
1084
|
const pubKeyHash = priv.to_public().hash();
|
|
@@ -2079,18 +2151,12 @@ var toScriptRef = (reference_script) => {
|
|
|
2079
2151
|
var lucid2 = package_default.version;
|
|
2080
2152
|
|
|
2081
2153
|
// src/koios.ts
|
|
2082
|
-
import * as S5 from "@effect/schema/Schema";
|
|
2083
2154
|
import { fromHex as fromHex4 } from "@lucid-evolution/core-utils";
|
|
2084
2155
|
import { fromUnit as fromUnit3 } from "@lucid-evolution/utils";
|
|
2085
2156
|
|
|
2086
2157
|
// src/internal/koios.ts
|
|
2087
|
-
import {
|
|
2088
|
-
|
|
2089
|
-
HttpClientRequest as HttpClientRequest2,
|
|
2090
|
-
HttpClientResponse as HttpClientResponse2
|
|
2091
|
-
} from "@effect/platform";
|
|
2092
|
-
import * as S4 from "@effect/schema/Schema";
|
|
2093
|
-
import { Effect as Effect2, pipe as pipe3 } from "effect";
|
|
2158
|
+
import { FetchHttpClient as FetchHttpClient2 } from "@effect/platform";
|
|
2159
|
+
import { Effect as Effect3, pipe as pipe4, Schema as S4 } from "effect";
|
|
2094
2160
|
import { applyDoubleCborEncoding as applyDoubleCborEncoding4 } from "@lucid-evolution/utils";
|
|
2095
2161
|
var ProtocolParametersSchema2 = S4.Struct({
|
|
2096
2162
|
pvt_motion_no_confidence: S4.Number,
|
|
@@ -2315,27 +2381,6 @@ var AccountInfoSchema = S4.Struct({
|
|
|
2315
2381
|
var DatumInfo = S4.Struct({
|
|
2316
2382
|
bytes: S4.String
|
|
2317
2383
|
});
|
|
2318
|
-
var postWithSchemaValidation = (url, data, schema, headers = {}) => pipe3(
|
|
2319
|
-
Effect2.succeed(HttpClientRequest2.post(url)),
|
|
2320
|
-
Effect2.map(HttpClientRequest2.setHeaders(headers)),
|
|
2321
|
-
Effect2.flatMap(
|
|
2322
|
-
(req) => headers["Content-Type"] === "application/cbor" ? Effect2.succeed(
|
|
2323
|
-
HttpClientRequest2.uint8ArrayBody(
|
|
2324
|
-
data,
|
|
2325
|
-
headers["Content-Type"]
|
|
2326
|
-
)(req)
|
|
2327
|
-
) : HttpClientRequest2.jsonBody(data)(req)
|
|
2328
|
-
),
|
|
2329
|
-
Effect2.flatMap(HttpClient2.fetch),
|
|
2330
|
-
HttpClientResponse2.json,
|
|
2331
|
-
Effect2.flatMap(S4.decodeUnknown(schema))
|
|
2332
|
-
);
|
|
2333
|
-
var getWithSchemaValidation = (url, schema) => pipe3(
|
|
2334
|
-
HttpClientRequest2.get(url),
|
|
2335
|
-
HttpClient2.fetchOk,
|
|
2336
|
-
HttpClientResponse2.json,
|
|
2337
|
-
Effect2.flatMap(S4.decodeUnknown(schema))
|
|
2338
|
-
);
|
|
2339
2384
|
var toUTxO = (koiosUTxO, address) => ({
|
|
2340
2385
|
txHash: koiosUTxO.tx_hash,
|
|
2341
2386
|
outputIndex: koiosUTxO.tx_index,
|
|
@@ -2377,26 +2422,28 @@ var toScriptRef2 = (reference_script) => {
|
|
|
2377
2422
|
}
|
|
2378
2423
|
}
|
|
2379
2424
|
};
|
|
2380
|
-
var getUtxosEffect = (baseUrl, addressOrCredential) => {
|
|
2425
|
+
var getUtxosEffect = (baseUrl, addressOrCredential, headers) => {
|
|
2381
2426
|
const url = `${baseUrl}/address_info`;
|
|
2382
2427
|
const body = {
|
|
2383
2428
|
_addresses: [addressOrCredential]
|
|
2384
2429
|
};
|
|
2385
2430
|
const schema = AddressInfoSchema;
|
|
2386
|
-
const result =
|
|
2387
|
-
|
|
2388
|
-
onFalse: () =>
|
|
2389
|
-
onTrue: () =>
|
|
2431
|
+
const result = pipe4(
|
|
2432
|
+
Effect3.if(typeof addressOrCredential === "string", {
|
|
2433
|
+
onFalse: () => Effect3.fail("Credential Type is not supported in Koios yet."),
|
|
2434
|
+
onTrue: () => makePostAsJson(url, body, schema, headers)
|
|
2390
2435
|
}),
|
|
2391
|
-
|
|
2436
|
+
Effect3.map(
|
|
2392
2437
|
([result2]) => result2 ? result2.utxo_set.map((koiosUtxo) => toUTxO(koiosUtxo, result2.address)) : []
|
|
2393
|
-
)
|
|
2438
|
+
),
|
|
2439
|
+
Effect3.provide(FetchHttpClient2.layer)
|
|
2394
2440
|
);
|
|
2395
2441
|
return result;
|
|
2396
2442
|
};
|
|
2397
2443
|
|
|
2398
2444
|
// src/koios.ts
|
|
2399
|
-
import { Data as Data2, Effect as
|
|
2445
|
+
import { Data as Data2, Effect as Effect4, pipe as pipe5, Schedule as Schedule2, Schema as S5 } from "effect";
|
|
2446
|
+
import { FetchHttpClient as FetchHttpClient3 } from "@effect/platform";
|
|
2400
2447
|
var KoiosError = class extends Data2.TaggedError("KoiosError") {
|
|
2401
2448
|
get message() {
|
|
2402
2449
|
return `${this.cause}`;
|
|
@@ -2404,17 +2451,22 @@ var KoiosError = class extends Data2.TaggedError("KoiosError") {
|
|
|
2404
2451
|
};
|
|
2405
2452
|
var Koios = class {
|
|
2406
2453
|
baseUrl;
|
|
2407
|
-
|
|
2454
|
+
token;
|
|
2455
|
+
constructor(baseUrl, token) {
|
|
2408
2456
|
this.baseUrl = baseUrl;
|
|
2457
|
+
this.token = token;
|
|
2409
2458
|
}
|
|
2410
2459
|
async getProtocolParameters() {
|
|
2411
2460
|
const url = `${this.baseUrl}/epoch_params?limit=1`;
|
|
2412
2461
|
const schema = S5.Array(ProtocolParametersSchema2);
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2462
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2463
|
+
const [result] = await pipe5(
|
|
2464
|
+
makeGet(url, schema, bearerToken),
|
|
2465
|
+
// Allows for dependency injection and easier testing
|
|
2466
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2467
|
+
Effect4.timeout(1e4),
|
|
2468
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2469
|
+
Effect4.runPromise
|
|
2418
2470
|
);
|
|
2419
2471
|
return {
|
|
2420
2472
|
minFeeA: result.min_fee_a,
|
|
@@ -2456,55 +2508,64 @@ var Koios = class {
|
|
|
2456
2508
|
};
|
|
2457
2509
|
}
|
|
2458
2510
|
async getUtxos(addressOrCredential) {
|
|
2459
|
-
const
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2511
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2512
|
+
const result = await pipe5(
|
|
2513
|
+
getUtxosEffect(this.baseUrl, addressOrCredential, bearerToken),
|
|
2514
|
+
Effect4.timeout(1e4),
|
|
2515
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2516
|
+
Effect4.runPromise
|
|
2464
2517
|
);
|
|
2465
2518
|
return result;
|
|
2466
2519
|
}
|
|
2467
2520
|
async getUtxosWithUnit(addressOrCredential, unit) {
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
2521
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2522
|
+
const result = await pipe5(
|
|
2523
|
+
getUtxosEffect(this.baseUrl, addressOrCredential, bearerToken),
|
|
2524
|
+
Effect4.map(
|
|
2471
2525
|
(utxos) => utxos.filter((utxo) => {
|
|
2472
2526
|
const keys = Object.keys(utxo.assets);
|
|
2473
2527
|
return keys.length > 0 && keys.includes(unit);
|
|
2474
2528
|
})
|
|
2475
2529
|
),
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2530
|
+
Effect4.timeout(1e4),
|
|
2531
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2532
|
+
Effect4.runPromise
|
|
2479
2533
|
);
|
|
2480
2534
|
return result;
|
|
2481
2535
|
}
|
|
2482
2536
|
async getUtxoByUnit(unit) {
|
|
2483
2537
|
let { policyId, assetName } = fromUnit3(unit);
|
|
2484
2538
|
const url = `${this.baseUrl}/asset_addresses?_asset_policy=${policyId}&_asset_name=${assetName}`;
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2539
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2540
|
+
const result = await pipe5(
|
|
2541
|
+
makeGet(url, S5.Array(AssetAddressSchema), bearerToken),
|
|
2542
|
+
// Allows for dependency injection and easier testing
|
|
2543
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2544
|
+
Effect4.flatMap(
|
|
2545
|
+
(adresses) => adresses.length === 0 ? Effect4.fail("Unit not found") : Effect4.succeed(adresses)
|
|
2489
2546
|
),
|
|
2490
|
-
|
|
2491
|
-
(adresses) => adresses.length > 1 ?
|
|
2547
|
+
Effect4.flatMap(
|
|
2548
|
+
(adresses) => adresses.length > 1 ? Effect4.fail("Unit needs to be an NFT or only held by one address.") : Effect4.succeed(adresses[0])
|
|
2492
2549
|
),
|
|
2493
|
-
|
|
2494
|
-
(address) => getUtxosEffect(
|
|
2550
|
+
Effect4.flatMap(
|
|
2551
|
+
(address) => getUtxosEffect(
|
|
2552
|
+
this.baseUrl,
|
|
2553
|
+
address.payment_address,
|
|
2554
|
+
bearerToken
|
|
2555
|
+
)
|
|
2495
2556
|
),
|
|
2496
|
-
|
|
2557
|
+
Effect4.map(
|
|
2497
2558
|
(utxos) => utxos.filter((utxo) => {
|
|
2498
2559
|
const keys = Object.keys(utxo.assets);
|
|
2499
2560
|
return keys.length > 0 && keys.includes(unit);
|
|
2500
2561
|
})
|
|
2501
2562
|
),
|
|
2502
|
-
|
|
2503
|
-
(utxos) => utxos.length > 1 ?
|
|
2563
|
+
Effect4.flatMap(
|
|
2564
|
+
(utxos) => utxos.length > 1 ? Effect4.fail("Unit needs to be an NFT or only held by one address.") : Effect4.succeed(utxos[0])
|
|
2504
2565
|
),
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2566
|
+
Effect4.timeout(1e4),
|
|
2567
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2568
|
+
Effect4.runPromise
|
|
2508
2569
|
);
|
|
2509
2570
|
return result;
|
|
2510
2571
|
}
|
|
@@ -2516,11 +2577,14 @@ var Koios = class {
|
|
|
2516
2577
|
_scripts: true
|
|
2517
2578
|
};
|
|
2518
2579
|
const schema = S5.Array(TxInfoSchema);
|
|
2519
|
-
const
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2580
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2581
|
+
const [result] = await pipe5(
|
|
2582
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2583
|
+
// Allows for dependency injection and easier testing
|
|
2584
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2585
|
+
Effect4.timeout(1e4),
|
|
2586
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2587
|
+
Effect4.runPromise
|
|
2524
2588
|
);
|
|
2525
2589
|
if (result) {
|
|
2526
2590
|
const utxos = result.outputs.map(
|
|
@@ -2553,18 +2617,22 @@ var Koios = class {
|
|
|
2553
2617
|
_stake_addresses: [rewardAddress]
|
|
2554
2618
|
};
|
|
2555
2619
|
const url = `${this.baseUrl}/account_info`;
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2620
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2621
|
+
const result = await pipe5(
|
|
2622
|
+
makePostAsJson(
|
|
2558
2623
|
url,
|
|
2559
2624
|
body,
|
|
2560
|
-
S5.Array(AccountInfoSchema)
|
|
2625
|
+
S5.Array(AccountInfoSchema),
|
|
2626
|
+
bearerToken
|
|
2561
2627
|
),
|
|
2562
|
-
|
|
2563
|
-
|
|
2628
|
+
// Allows for dependency injection and easier testing
|
|
2629
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2630
|
+
Effect4.flatMap(
|
|
2631
|
+
(result2) => result2.length === 0 ? Effect4.fail("No Delegation Found by Reward Address") : Effect4.succeed(result2[0])
|
|
2564
2632
|
),
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2633
|
+
Effect4.timeout(1e4),
|
|
2634
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2635
|
+
Effect4.runPromise
|
|
2568
2636
|
);
|
|
2569
2637
|
return {
|
|
2570
2638
|
poolId: result.delegated_pool || null,
|
|
@@ -2576,14 +2644,22 @@ var Koios = class {
|
|
|
2576
2644
|
const body = {
|
|
2577
2645
|
_datum_hashes: [datumHash]
|
|
2578
2646
|
};
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2647
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2648
|
+
const result = await pipe5(
|
|
2649
|
+
makePostAsJson(
|
|
2650
|
+
url,
|
|
2651
|
+
body,
|
|
2652
|
+
S5.Array(DatumInfo),
|
|
2653
|
+
bearerToken
|
|
2583
2654
|
),
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2655
|
+
// Allows for dependency injection and easier testing
|
|
2656
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2657
|
+
Effect4.flatMap(
|
|
2658
|
+
(result2) => result2.length === 0 ? Effect4.fail("No Datum Found by Datum Hash") : Effect4.succeed(result2[0])
|
|
2659
|
+
),
|
|
2660
|
+
Effect4.timeout(1e4),
|
|
2661
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2662
|
+
Effect4.runPromise
|
|
2587
2663
|
);
|
|
2588
2664
|
return result.bytes;
|
|
2589
2665
|
}
|
|
@@ -2593,16 +2669,19 @@ var Koios = class {
|
|
|
2593
2669
|
_tx_hashes: [txHash]
|
|
2594
2670
|
};
|
|
2595
2671
|
const schema = S5.Array(TxInfoSchema);
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
|
|
2672
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2673
|
+
const result = await pipe5(
|
|
2674
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2675
|
+
Effect4.repeat({
|
|
2599
2676
|
schedule: Schedule2.exponential(checkInterval),
|
|
2600
2677
|
until: (result2) => result2.length > 0
|
|
2601
2678
|
}),
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2679
|
+
// Allows for dependency injection and easier testing
|
|
2680
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2681
|
+
Effect4.timeout(16e4),
|
|
2682
|
+
Effect4.orDie,
|
|
2683
|
+
Effect4.as(true),
|
|
2684
|
+
Effect4.runPromise
|
|
2606
2685
|
);
|
|
2607
2686
|
return result;
|
|
2608
2687
|
}
|
|
@@ -2610,13 +2689,14 @@ var Koios = class {
|
|
|
2610
2689
|
const url = `${this.baseUrl}/submittx`;
|
|
2611
2690
|
const body = fromHex4(tx);
|
|
2612
2691
|
const schema = TxHashSchema;
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2692
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2693
|
+
const result = await pipe5(
|
|
2694
|
+
makePostAsUint8Array(url, body, schema, bearerToken),
|
|
2695
|
+
// Allows for dependency injection and easier testing
|
|
2696
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2697
|
+
Effect4.timeout(1e4),
|
|
2698
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2699
|
+
Effect4.runPromise
|
|
2620
2700
|
);
|
|
2621
2701
|
return result;
|
|
2622
2702
|
}
|
|
@@ -2632,14 +2712,14 @@ var Koios = class {
|
|
|
2632
2712
|
id: null
|
|
2633
2713
|
};
|
|
2634
2714
|
const schema = JSONRPCSchema(S5.Array(RedeemerSchema));
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
),
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2715
|
+
const bearerToken = this.token ? { Authorization: `Bearer ${this.token}` } : void 0;
|
|
2716
|
+
const { result } = await pipe5(
|
|
2717
|
+
makePostAsJson(url, body, schema, bearerToken),
|
|
2718
|
+
// Allows for dependency injection and easier testing
|
|
2719
|
+
Effect4.provide(FetchHttpClient3.layer),
|
|
2720
|
+
Effect4.timeout(1e4),
|
|
2721
|
+
Effect4.catchAllCause((cause) => new KoiosError({ cause })),
|
|
2722
|
+
Effect4.runPromise
|
|
2643
2723
|
);
|
|
2644
2724
|
const evalRedeemers = result.map((item) => ({
|
|
2645
2725
|
ex_units: {
|
|
@@ -2661,5 +2741,5 @@ export {
|
|
|
2661
2741
|
KupmiosError,
|
|
2662
2742
|
Maestro,
|
|
2663
2743
|
generateEmulatorAccount,
|
|
2664
|
-
|
|
2744
|
+
generateEmulatorAccountFromPrivateKey
|
|
2665
2745
|
};
|