@lucid-evolution/provider 0.1.95 → 0.1.97
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 +69 -38
- package/dist/index.js +69 -38
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -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.97",
|
|
56
56
|
description: "",
|
|
57
57
|
main: "./dist/index.js",
|
|
58
58
|
types: "./dist/index.d.ts",
|
|
@@ -111,8 +111,8 @@ var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
|
|
|
111
111
|
{
|
|
112
112
|
address: utxo.address,
|
|
113
113
|
value: {
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
ada: { lovelace: Number(utxo.assets["lovelace"]) },
|
|
115
|
+
...fromAssets(utxo.assets)
|
|
116
116
|
},
|
|
117
117
|
datumHash: utxo.datumHash,
|
|
118
118
|
datum: utxo.datum,
|
|
@@ -133,14 +133,16 @@ var toTxOutScript = (scriptRef) => {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
var fromAssets = (assets) => (0, import_effect.pipe)(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
var fromAssets = (assets) => (0, import_effect.pipe)(import_effect.Record.remove(assets, "lovelace"), (nativeAssets) => {
|
|
137
|
+
const result = {};
|
|
138
|
+
for (const [unit, amount] of Object.entries(nativeAssets)) {
|
|
139
|
+
const policyId = unit.slice(0, 56);
|
|
140
|
+
const assetName = unit.slice(56);
|
|
141
|
+
result[policyId] ??= {};
|
|
142
|
+
result[policyId][assetName] = Number(amount);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
});
|
|
144
146
|
var fromLegacyRedeemerTag = (redeemerTag) => {
|
|
145
147
|
switch (redeemerTag) {
|
|
146
148
|
case "certificate":
|
|
@@ -174,6 +176,8 @@ var Blockfrost = class {
|
|
|
174
176
|
headers: { project_id: this.projectId, lucid }
|
|
175
177
|
}).then((res) => res.json());
|
|
176
178
|
return {
|
|
179
|
+
protocolMajorVersion: parseInt(result.protocol_major_ver),
|
|
180
|
+
protocolMinorVersion: parseInt(result.protocol_minor_ver),
|
|
177
181
|
minFeeA: parseInt(result.min_fee_a),
|
|
178
182
|
minFeeB: parseInt(result.min_fee_b),
|
|
179
183
|
maxTxSize: parseInt(result.max_tx_size),
|
|
@@ -404,29 +408,33 @@ var Blockfrost = class {
|
|
|
404
408
|
return utxos;
|
|
405
409
|
}
|
|
406
410
|
async evaluateTx(tx, additionalUTxOs) {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
411
|
+
const evaluate = async (utxos) => {
|
|
412
|
+
const payload = {
|
|
413
|
+
cbor: tx,
|
|
414
|
+
...utxos?.length ? { additionalUtxoSet: toAditionalUTXOs(utxos) } : {}
|
|
415
|
+
};
|
|
416
|
+
const res = await fetch(`${this.url}/utils/txs/evaluate/utxos`, {
|
|
417
|
+
method: "POST",
|
|
418
|
+
headers: {
|
|
419
|
+
"Content-Type": "application/json",
|
|
420
|
+
project_id: this.projectId,
|
|
421
|
+
lucid
|
|
422
|
+
},
|
|
423
|
+
body: JSON.stringify(payload)
|
|
424
|
+
}).then((res2) => res2.json());
|
|
425
|
+
if (!res || res.fault) {
|
|
426
|
+
const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}. Transaction: ${tx}`;
|
|
427
|
+
throw new Error(message);
|
|
428
|
+
}
|
|
429
|
+
const blockfrostRedeemer2 = res;
|
|
430
|
+
if (!("EvaluationResult" in blockfrostRedeemer2.result)) {
|
|
431
|
+
throw new Error(
|
|
432
|
+
`EvaluateTransaction fails: ${JSON.stringify(blockfrostRedeemer2.result)}`
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
return blockfrostRedeemer2;
|
|
410
436
|
};
|
|
411
|
-
const
|
|
412
|
-
method: "POST",
|
|
413
|
-
headers: {
|
|
414
|
-
"Content-Type": "application/json",
|
|
415
|
-
project_id: this.projectId,
|
|
416
|
-
lucid
|
|
417
|
-
},
|
|
418
|
-
body: JSON.stringify(payload)
|
|
419
|
-
}).then((res2) => res2.json());
|
|
420
|
-
if (!res || res.fault) {
|
|
421
|
-
const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}. Transaction: ${tx}`;
|
|
422
|
-
throw new Error(message);
|
|
423
|
-
}
|
|
424
|
-
const blockfrostRedeemer = res;
|
|
425
|
-
if (!("EvaluationResult" in blockfrostRedeemer.result)) {
|
|
426
|
-
throw new Error(
|
|
427
|
-
`EvaluateTransaction fails: ${JSON.stringify(blockfrostRedeemer.result)}`
|
|
428
|
-
);
|
|
429
|
-
}
|
|
437
|
+
const blockfrostRedeemer = additionalUTxOs?.length ? await evaluate().catch(() => evaluate(additionalUTxOs)) : await evaluate();
|
|
430
438
|
const evalRedeemers = [];
|
|
431
439
|
Object.entries(blockfrostRedeemer.result.EvaluationResult).forEach(
|
|
432
440
|
([redeemerPointer, data]) => {
|
|
@@ -519,6 +527,28 @@ var TupleNumberFromString = import_effect2.Schema.compose(
|
|
|
519
527
|
import_effect2.Schema.split("/"),
|
|
520
528
|
import_effect2.Schema.Array(import_effect2.Schema.NumberFromString)
|
|
521
529
|
);
|
|
530
|
+
var MaxReferenceScriptsSizeSchema = import_effect2.Schema.Struct({
|
|
531
|
+
bytes: import_effect2.Schema.Number
|
|
532
|
+
});
|
|
533
|
+
function normalizeProtocolParameters(value) {
|
|
534
|
+
const legacy = value.maxReferenceScriptsSize;
|
|
535
|
+
const current = value.maxReferenceScriptsSizePerTransaction;
|
|
536
|
+
if (legacy === void 0 && current === void 0) {
|
|
537
|
+
return value;
|
|
538
|
+
}
|
|
539
|
+
const decode = import_effect2.Schema.decodeUnknownSync(MaxReferenceScriptsSizeSchema);
|
|
540
|
+
const legacyValue = legacy === void 0 ? void 0 : decode(legacy);
|
|
541
|
+
const currentValue = current === void 0 ? void 0 : decode(current);
|
|
542
|
+
if (legacyValue !== void 0 && currentValue !== void 0 && legacyValue.bytes !== currentValue.bytes) {
|
|
543
|
+
throw new Error(
|
|
544
|
+
"Conflicting Ogmios protocol parameters: maxReferenceScriptsSize and maxReferenceScriptsSizePerTransaction differ"
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
...value,
|
|
549
|
+
maxReferenceScriptsSize: legacyValue ?? currentValue
|
|
550
|
+
};
|
|
551
|
+
}
|
|
522
552
|
var ProtocolParametersSchema = import_effect2.Schema.Struct({
|
|
523
553
|
minFeeCoefficient: import_effect2.Schema.Number,
|
|
524
554
|
minFeeReferenceScripts: import_effect2.Schema.Struct({
|
|
@@ -526,9 +556,7 @@ var ProtocolParametersSchema = import_effect2.Schema.Struct({
|
|
|
526
556
|
range: import_effect2.Schema.Number,
|
|
527
557
|
multiplier: import_effect2.Schema.Number
|
|
528
558
|
}),
|
|
529
|
-
maxReferenceScriptsSize:
|
|
530
|
-
bytes: import_effect2.Schema.Number
|
|
531
|
-
}),
|
|
559
|
+
maxReferenceScriptsSize: MaxReferenceScriptsSizeSchema,
|
|
532
560
|
stakePoolVotingThresholds: import_effect2.Schema.Struct({
|
|
533
561
|
noConfidence: TupleNumberFromString,
|
|
534
562
|
constitutionalCommittee: import_effect2.Schema.Struct({
|
|
@@ -842,7 +870,7 @@ var Kupmios = class {
|
|
|
842
870
|
id: null
|
|
843
871
|
};
|
|
844
872
|
const schema = JSONRPCResponseSchema(
|
|
845
|
-
|
|
873
|
+
import_effect5.Schema.Record({ key: import_effect5.Schema.String, value: import_effect5.Schema.Unknown })
|
|
846
874
|
);
|
|
847
875
|
const response = await (0, import_effect6.pipe)(
|
|
848
876
|
makePostAsJson(
|
|
@@ -857,7 +885,10 @@ var Kupmios = class {
|
|
|
857
885
|
import_effect6.Effect.runPromise
|
|
858
886
|
);
|
|
859
887
|
const result = getJSONRPCResult(response);
|
|
860
|
-
|
|
888
|
+
const protocolParameters = import_effect5.Schema.decodeUnknownSync(
|
|
889
|
+
ProtocolParametersSchema
|
|
890
|
+
)(normalizeProtocolParameters(result));
|
|
891
|
+
return toProtocolParameters(protocolParameters);
|
|
861
892
|
}
|
|
862
893
|
async getTreasury() {
|
|
863
894
|
const data = {
|
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.97",
|
|
15
15
|
description: "",
|
|
16
16
|
main: "./dist/index.js",
|
|
17
17
|
types: "./dist/index.d.ts",
|
|
@@ -70,8 +70,8 @@ var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
|
|
|
70
70
|
{
|
|
71
71
|
address: utxo.address,
|
|
72
72
|
value: {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
ada: { lovelace: Number(utxo.assets["lovelace"]) },
|
|
74
|
+
...fromAssets(utxo.assets)
|
|
75
75
|
},
|
|
76
76
|
datumHash: utxo.datumHash,
|
|
77
77
|
datum: utxo.datum,
|
|
@@ -92,14 +92,16 @@ var toTxOutScript = (scriptRef) => {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
var fromAssets = (assets) => pipe(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
var fromAssets = (assets) => pipe(Record.remove(assets, "lovelace"), (nativeAssets) => {
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const [unit, amount] of Object.entries(nativeAssets)) {
|
|
98
|
+
const policyId = unit.slice(0, 56);
|
|
99
|
+
const assetName = unit.slice(56);
|
|
100
|
+
result[policyId] ??= {};
|
|
101
|
+
result[policyId][assetName] = Number(amount);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
});
|
|
103
105
|
var fromLegacyRedeemerTag = (redeemerTag) => {
|
|
104
106
|
switch (redeemerTag) {
|
|
105
107
|
case "certificate":
|
|
@@ -133,6 +135,8 @@ var Blockfrost = class {
|
|
|
133
135
|
headers: { project_id: this.projectId, lucid }
|
|
134
136
|
}).then((res) => res.json());
|
|
135
137
|
return {
|
|
138
|
+
protocolMajorVersion: parseInt(result.protocol_major_ver),
|
|
139
|
+
protocolMinorVersion: parseInt(result.protocol_minor_ver),
|
|
136
140
|
minFeeA: parseInt(result.min_fee_a),
|
|
137
141
|
minFeeB: parseInt(result.min_fee_b),
|
|
138
142
|
maxTxSize: parseInt(result.max_tx_size),
|
|
@@ -363,29 +367,33 @@ var Blockfrost = class {
|
|
|
363
367
|
return utxos;
|
|
364
368
|
}
|
|
365
369
|
async evaluateTx(tx, additionalUTxOs) {
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
370
|
+
const evaluate = async (utxos) => {
|
|
371
|
+
const payload = {
|
|
372
|
+
cbor: tx,
|
|
373
|
+
...utxos?.length ? { additionalUtxoSet: toAditionalUTXOs(utxos) } : {}
|
|
374
|
+
};
|
|
375
|
+
const res = await fetch(`${this.url}/utils/txs/evaluate/utxos`, {
|
|
376
|
+
method: "POST",
|
|
377
|
+
headers: {
|
|
378
|
+
"Content-Type": "application/json",
|
|
379
|
+
project_id: this.projectId,
|
|
380
|
+
lucid
|
|
381
|
+
},
|
|
382
|
+
body: JSON.stringify(payload)
|
|
383
|
+
}).then((res2) => res2.json());
|
|
384
|
+
if (!res || res.fault) {
|
|
385
|
+
const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}. Transaction: ${tx}`;
|
|
386
|
+
throw new Error(message);
|
|
387
|
+
}
|
|
388
|
+
const blockfrostRedeemer2 = res;
|
|
389
|
+
if (!("EvaluationResult" in blockfrostRedeemer2.result)) {
|
|
390
|
+
throw new Error(
|
|
391
|
+
`EvaluateTransaction fails: ${JSON.stringify(blockfrostRedeemer2.result)}`
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
return blockfrostRedeemer2;
|
|
369
395
|
};
|
|
370
|
-
const
|
|
371
|
-
method: "POST",
|
|
372
|
-
headers: {
|
|
373
|
-
"Content-Type": "application/json",
|
|
374
|
-
project_id: this.projectId,
|
|
375
|
-
lucid
|
|
376
|
-
},
|
|
377
|
-
body: JSON.stringify(payload)
|
|
378
|
-
}).then((res2) => res2.json());
|
|
379
|
-
if (!res || res.fault) {
|
|
380
|
-
const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}. Transaction: ${tx}`;
|
|
381
|
-
throw new Error(message);
|
|
382
|
-
}
|
|
383
|
-
const blockfrostRedeemer = res;
|
|
384
|
-
if (!("EvaluationResult" in blockfrostRedeemer.result)) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
`EvaluateTransaction fails: ${JSON.stringify(blockfrostRedeemer.result)}`
|
|
387
|
-
);
|
|
388
|
-
}
|
|
396
|
+
const blockfrostRedeemer = additionalUTxOs?.length ? await evaluate().catch(() => evaluate(additionalUTxOs)) : await evaluate();
|
|
389
397
|
const evalRedeemers = [];
|
|
390
398
|
Object.entries(blockfrostRedeemer.result.EvaluationResult).forEach(
|
|
391
399
|
([redeemerPointer, data]) => {
|
|
@@ -478,6 +486,28 @@ var TupleNumberFromString = S.compose(
|
|
|
478
486
|
S.split("/"),
|
|
479
487
|
S.Array(S.NumberFromString)
|
|
480
488
|
);
|
|
489
|
+
var MaxReferenceScriptsSizeSchema = S.Struct({
|
|
490
|
+
bytes: S.Number
|
|
491
|
+
});
|
|
492
|
+
function normalizeProtocolParameters(value) {
|
|
493
|
+
const legacy = value.maxReferenceScriptsSize;
|
|
494
|
+
const current = value.maxReferenceScriptsSizePerTransaction;
|
|
495
|
+
if (legacy === void 0 && current === void 0) {
|
|
496
|
+
return value;
|
|
497
|
+
}
|
|
498
|
+
const decode = S.decodeUnknownSync(MaxReferenceScriptsSizeSchema);
|
|
499
|
+
const legacyValue = legacy === void 0 ? void 0 : decode(legacy);
|
|
500
|
+
const currentValue = current === void 0 ? void 0 : decode(current);
|
|
501
|
+
if (legacyValue !== void 0 && currentValue !== void 0 && legacyValue.bytes !== currentValue.bytes) {
|
|
502
|
+
throw new Error(
|
|
503
|
+
"Conflicting Ogmios protocol parameters: maxReferenceScriptsSize and maxReferenceScriptsSizePerTransaction differ"
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
...value,
|
|
508
|
+
maxReferenceScriptsSize: legacyValue ?? currentValue
|
|
509
|
+
};
|
|
510
|
+
}
|
|
481
511
|
var ProtocolParametersSchema = S.Struct({
|
|
482
512
|
minFeeCoefficient: S.Number,
|
|
483
513
|
minFeeReferenceScripts: S.Struct({
|
|
@@ -485,9 +515,7 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
485
515
|
range: S.Number,
|
|
486
516
|
multiplier: S.Number
|
|
487
517
|
}),
|
|
488
|
-
maxReferenceScriptsSize:
|
|
489
|
-
bytes: S.Number
|
|
490
|
-
}),
|
|
518
|
+
maxReferenceScriptsSize: MaxReferenceScriptsSizeSchema,
|
|
491
519
|
stakePoolVotingThresholds: S.Struct({
|
|
492
520
|
noConfidence: TupleNumberFromString,
|
|
493
521
|
constitutionalCommittee: S.Struct({
|
|
@@ -806,7 +834,7 @@ var Kupmios = class {
|
|
|
806
834
|
id: null
|
|
807
835
|
};
|
|
808
836
|
const schema = JSONRPCResponseSchema(
|
|
809
|
-
|
|
837
|
+
S3.Record({ key: S3.String, value: S3.Unknown })
|
|
810
838
|
);
|
|
811
839
|
const response = await pipe3(
|
|
812
840
|
makePostAsJson(
|
|
@@ -821,7 +849,10 @@ var Kupmios = class {
|
|
|
821
849
|
Effect2.runPromise
|
|
822
850
|
);
|
|
823
851
|
const result = getJSONRPCResult(response);
|
|
824
|
-
|
|
852
|
+
const protocolParameters = S3.decodeUnknownSync(
|
|
853
|
+
ProtocolParametersSchema
|
|
854
|
+
)(normalizeProtocolParameters(result));
|
|
855
|
+
return toProtocolParameters(protocolParameters);
|
|
825
856
|
}
|
|
826
857
|
async getTreasury() {
|
|
827
858
|
const data = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.97",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@effect/platform": "^0.71.3",
|
|
31
31
|
"@effect/schema": "^0.68.26",
|
|
32
32
|
"effect": "^3.11.7",
|
|
33
|
-
"@lucid-evolution/core-types": "0.2.
|
|
33
|
+
"@lucid-evolution/core-types": "0.2.2",
|
|
34
34
|
"@lucid-evolution/core-utils": "0.1.16",
|
|
35
|
-
"@lucid-evolution/utils": "0.1.
|
|
36
|
-
"@lucid-evolution/wallet": "0.1.
|
|
35
|
+
"@lucid-evolution/utils": "0.1.71",
|
|
36
|
+
"@lucid-evolution/wallet": "0.1.77"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.12.8",
|