@lucid-evolution/provider 0.1.95 → 0.1.96
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 +41 -33
- package/dist/index.js +41 -33
- 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.96",
|
|
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]) => {
|
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.96",
|
|
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]) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.96",
|
|
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.1",
|
|
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.70",
|
|
36
|
+
"@lucid-evolution/wallet": "0.1.76"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.12.8",
|