@lucid-evolution/provider 0.1.20 → 0.1.22
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 +76 -46
- package/dist/index.js +76 -46
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,7 @@ var import_utils = require("@lucid-evolution/utils");
|
|
|
48
48
|
// package.json
|
|
49
49
|
var package_default = {
|
|
50
50
|
name: "@lucid-evolution/provider",
|
|
51
|
-
version: "0.1.
|
|
51
|
+
version: "0.1.22",
|
|
52
52
|
description: "",
|
|
53
53
|
main: "./dist/index.js",
|
|
54
54
|
types: "./dist/index.d.ts",
|
|
@@ -83,7 +83,8 @@ var package_default = {
|
|
|
83
83
|
"@effect/schema": "^0.67.16",
|
|
84
84
|
"@lucid-evolution/core-types": "workspace:*",
|
|
85
85
|
"@lucid-evolution/core-utils": "workspace:*",
|
|
86
|
-
"@lucid-evolution/utils": "workspace:*"
|
|
86
|
+
"@lucid-evolution/utils": "workspace:*",
|
|
87
|
+
effect: "^3.1.2"
|
|
87
88
|
},
|
|
88
89
|
devDependencies: {
|
|
89
90
|
"@types/node": "^20.12.8",
|
|
@@ -876,7 +877,7 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
876
877
|
min_utxo_value: S.String,
|
|
877
878
|
min_pool_cost: S.String,
|
|
878
879
|
nonce: S.String,
|
|
879
|
-
block_hash: S.String,
|
|
880
|
+
block_hash: S.NullOr(S.String),
|
|
880
881
|
cost_models: S.Struct({
|
|
881
882
|
PlutusV1: S.Array(S.Number),
|
|
882
883
|
PlutusV2: S.Array(S.Number)
|
|
@@ -920,7 +921,7 @@ var KoiosUTxOSchema = S.Struct({
|
|
|
920
921
|
value: S.NullOr(S.Object)
|
|
921
922
|
})
|
|
922
923
|
),
|
|
923
|
-
asset_list: S.Array(KoiosAssetSchema)
|
|
924
|
+
asset_list: S.NullOr(S.Array(KoiosAssetSchema))
|
|
924
925
|
});
|
|
925
926
|
var KoiosAddressInfoSchema = S.Array(
|
|
926
927
|
S.NullishOr(
|
|
@@ -958,7 +959,7 @@ var KoiosInputOutputSchema = S.Struct({
|
|
|
958
959
|
value: S.NullOr(S.Object)
|
|
959
960
|
})
|
|
960
961
|
),
|
|
961
|
-
asset_list: S.Array(KoiosAssetSchema)
|
|
962
|
+
asset_list: S.Union(S.Array(KoiosAssetSchema), S.String)
|
|
962
963
|
});
|
|
963
964
|
var KoiosTxInfoSchema = S.Struct({
|
|
964
965
|
tx_hash: S.String,
|
|
@@ -1011,7 +1012,7 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
1011
1012
|
S.Array(
|
|
1012
1013
|
S.Struct({
|
|
1013
1014
|
address: S.String,
|
|
1014
|
-
|
|
1015
|
+
spends_input: S.NullOr(
|
|
1015
1016
|
S.Struct({
|
|
1016
1017
|
tx_hash: S.String,
|
|
1017
1018
|
tx_index: S.Number
|
|
@@ -1023,17 +1024,21 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
1023
1024
|
valid_contract: S.Boolean,
|
|
1024
1025
|
input: S.Struct({
|
|
1025
1026
|
redeemer: S.Struct({
|
|
1026
|
-
purpose: S.Literal("spend", "mint", "cert", "reward")
|
|
1027
|
+
purpose: S.Literal("spend", "mint", "cert", "reward"),
|
|
1028
|
+
fee: S.String,
|
|
1029
|
+
unit: S.Struct({
|
|
1030
|
+
steps: S.String,
|
|
1031
|
+
mem: S.String
|
|
1032
|
+
}),
|
|
1033
|
+
datum: S.Struct({
|
|
1034
|
+
hash: S.NullOr(S.String),
|
|
1035
|
+
value: S.NullOr(S.Object)
|
|
1036
|
+
})
|
|
1037
|
+
}),
|
|
1038
|
+
datum: S.Struct({
|
|
1039
|
+
hash: S.NullOr(S.String),
|
|
1040
|
+
value: S.NullOr(S.Object)
|
|
1027
1041
|
})
|
|
1028
|
-
}),
|
|
1029
|
-
fee: S.String,
|
|
1030
|
-
unit: S.Struct({
|
|
1031
|
-
steps: S.String,
|
|
1032
|
-
mem: S.String
|
|
1033
|
-
}),
|
|
1034
|
-
datum: S.Struct({
|
|
1035
|
-
hash: S.NullOr(S.String),
|
|
1036
|
-
value: S.NullOr(S.Object)
|
|
1037
1042
|
})
|
|
1038
1043
|
})
|
|
1039
1044
|
)
|
|
@@ -1041,6 +1046,8 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
1041
1046
|
});
|
|
1042
1047
|
|
|
1043
1048
|
// src/koios/koios.ts
|
|
1049
|
+
var import_effect = require("effect");
|
|
1050
|
+
var import_schema2 = require("@effect/schema");
|
|
1044
1051
|
var Koios = class {
|
|
1045
1052
|
baseUrl;
|
|
1046
1053
|
constructor(baseUrl) {
|
|
@@ -1171,7 +1178,8 @@ var Koios = class {
|
|
|
1171
1178
|
datum_hash: koiosInputOutput.datum_hash,
|
|
1172
1179
|
inline_datum: koiosInputOutput.inline_datum,
|
|
1173
1180
|
reference_script: koiosInputOutput.reference_script,
|
|
1174
|
-
asset_list:
|
|
1181
|
+
//NOTE: Koios api returns collateral_output like asset_list: "[]", instead of asset_list: []
|
|
1182
|
+
asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
|
|
1175
1183
|
},
|
|
1176
1184
|
koiosInputOutput.payment_addr.bech32
|
|
1177
1185
|
)
|
|
@@ -1219,27 +1227,48 @@ var Koios = class {
|
|
|
1219
1227
|
throw new Error("No Datum Found by Datum Hash");
|
|
1220
1228
|
}
|
|
1221
1229
|
}
|
|
1222
|
-
awaitTx(txHash, checkInterval =
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1230
|
+
awaitTx(txHash, checkInterval = 2e4) {
|
|
1231
|
+
const body = {
|
|
1232
|
+
_tx_hashes: [txHash]
|
|
1233
|
+
};
|
|
1234
|
+
const request = {
|
|
1235
|
+
headers: {
|
|
1236
|
+
Accept: "application/json",
|
|
1237
|
+
"Content-Type": "application/json"
|
|
1238
|
+
},
|
|
1239
|
+
method: "POST",
|
|
1240
|
+
body: JSON.stringify(body)
|
|
1241
|
+
};
|
|
1242
|
+
const program = (0, import_effect.pipe)(
|
|
1243
|
+
import_effect.Effect.tryPromise({
|
|
1244
|
+
//TODO: use tx_status api
|
|
1245
|
+
try: () => fetch(`${this.baseUrl}/tx_info`, request),
|
|
1246
|
+
catch: (error) => new Error(String(error))
|
|
1247
|
+
}),
|
|
1248
|
+
import_effect.Effect.flatMap(
|
|
1249
|
+
(response) => !response.ok ? import_effect.Effect.fail(new Error(`${response.status} ${response.statusText}`)) : import_effect.Effect.succeed(response)
|
|
1250
|
+
),
|
|
1251
|
+
import_effect.Effect.flatMap(
|
|
1252
|
+
(response) => import_effect.Effect.tryPromise({
|
|
1253
|
+
try: () => response.json(),
|
|
1254
|
+
catch: (error) => new Error(String(error))
|
|
1255
|
+
})
|
|
1256
|
+
),
|
|
1257
|
+
import_effect.Effect.flatMap(
|
|
1258
|
+
(json) => S2.decodeUnknown(S2.Array(KoiosTxInfoSchema), { errors: "first" })(json)
|
|
1259
|
+
),
|
|
1260
|
+
import_effect.Effect.catchTag(
|
|
1261
|
+
"ParseError",
|
|
1262
|
+
(e) => import_effect.Effect.fail(import_schema2.ArrayFormatter.formatErrorSync(e))
|
|
1263
|
+
),
|
|
1264
|
+
import_effect.Effect.repeat({
|
|
1265
|
+
schedule: import_effect.Schedule.exponential(checkInterval),
|
|
1266
|
+
until: (result) => result.length > 0
|
|
1267
|
+
}),
|
|
1268
|
+
import_effect.Effect.orDie,
|
|
1269
|
+
import_effect.Effect.as(true)
|
|
1270
|
+
);
|
|
1271
|
+
return import_effect.Effect.runPromise(program);
|
|
1243
1272
|
}
|
|
1244
1273
|
async submitTx(tx) {
|
|
1245
1274
|
const result = await fetch(`${this.baseUrl}/submittx`, {
|
|
@@ -1250,11 +1279,10 @@ var Koios = class {
|
|
|
1250
1279
|
method: "POST",
|
|
1251
1280
|
body: (0, import_core_utils3.fromHex)(tx)
|
|
1252
1281
|
}).then((res) => res.json());
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
throw new Error("Could not submit transaction.");
|
|
1282
|
+
const TxHashSchema = S2.String;
|
|
1283
|
+
const isTxHash = S2.is(TxHashSchema);
|
|
1284
|
+
if (!isTxHash(result)) {
|
|
1285
|
+
throw new Error(JSON.stringify(result));
|
|
1258
1286
|
}
|
|
1259
1287
|
return result;
|
|
1260
1288
|
}
|
|
@@ -1264,9 +1292,11 @@ var toUTxO = (koiosUTxO, address) => ({
|
|
|
1264
1292
|
outputIndex: koiosUTxO.tx_index,
|
|
1265
1293
|
assets: (() => {
|
|
1266
1294
|
const a = {};
|
|
1267
|
-
koiosUTxO.asset_list
|
|
1268
|
-
|
|
1269
|
-
|
|
1295
|
+
if (koiosUTxO.asset_list) {
|
|
1296
|
+
koiosUTxO.asset_list.forEach((am) => {
|
|
1297
|
+
a[am.policy_id + am.asset_name] = BigInt(am.quantity);
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1270
1300
|
a["lovelace"] = BigInt(koiosUTxO.value);
|
|
1271
1301
|
return a;
|
|
1272
1302
|
})(),
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { applyDoubleCborEncoding } from "@lucid-evolution/utils";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@lucid-evolution/provider",
|
|
11
|
-
version: "0.1.
|
|
11
|
+
version: "0.1.22",
|
|
12
12
|
description: "",
|
|
13
13
|
main: "./dist/index.js",
|
|
14
14
|
types: "./dist/index.d.ts",
|
|
@@ -43,7 +43,8 @@ var package_default = {
|
|
|
43
43
|
"@effect/schema": "^0.67.16",
|
|
44
44
|
"@lucid-evolution/core-types": "workspace:*",
|
|
45
45
|
"@lucid-evolution/core-utils": "workspace:*",
|
|
46
|
-
"@lucid-evolution/utils": "workspace:*"
|
|
46
|
+
"@lucid-evolution/utils": "workspace:*",
|
|
47
|
+
effect: "^3.1.2"
|
|
47
48
|
},
|
|
48
49
|
devDependencies: {
|
|
49
50
|
"@types/node": "^20.12.8",
|
|
@@ -836,7 +837,7 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
836
837
|
min_utxo_value: S.String,
|
|
837
838
|
min_pool_cost: S.String,
|
|
838
839
|
nonce: S.String,
|
|
839
|
-
block_hash: S.String,
|
|
840
|
+
block_hash: S.NullOr(S.String),
|
|
840
841
|
cost_models: S.Struct({
|
|
841
842
|
PlutusV1: S.Array(S.Number),
|
|
842
843
|
PlutusV2: S.Array(S.Number)
|
|
@@ -880,7 +881,7 @@ var KoiosUTxOSchema = S.Struct({
|
|
|
880
881
|
value: S.NullOr(S.Object)
|
|
881
882
|
})
|
|
882
883
|
),
|
|
883
|
-
asset_list: S.Array(KoiosAssetSchema)
|
|
884
|
+
asset_list: S.NullOr(S.Array(KoiosAssetSchema))
|
|
884
885
|
});
|
|
885
886
|
var KoiosAddressInfoSchema = S.Array(
|
|
886
887
|
S.NullishOr(
|
|
@@ -918,7 +919,7 @@ var KoiosInputOutputSchema = S.Struct({
|
|
|
918
919
|
value: S.NullOr(S.Object)
|
|
919
920
|
})
|
|
920
921
|
),
|
|
921
|
-
asset_list: S.Array(KoiosAssetSchema)
|
|
922
|
+
asset_list: S.Union(S.Array(KoiosAssetSchema), S.String)
|
|
922
923
|
});
|
|
923
924
|
var KoiosTxInfoSchema = S.Struct({
|
|
924
925
|
tx_hash: S.String,
|
|
@@ -971,7 +972,7 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
971
972
|
S.Array(
|
|
972
973
|
S.Struct({
|
|
973
974
|
address: S.String,
|
|
974
|
-
|
|
975
|
+
spends_input: S.NullOr(
|
|
975
976
|
S.Struct({
|
|
976
977
|
tx_hash: S.String,
|
|
977
978
|
tx_index: S.Number
|
|
@@ -983,17 +984,21 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
983
984
|
valid_contract: S.Boolean,
|
|
984
985
|
input: S.Struct({
|
|
985
986
|
redeemer: S.Struct({
|
|
986
|
-
purpose: S.Literal("spend", "mint", "cert", "reward")
|
|
987
|
+
purpose: S.Literal("spend", "mint", "cert", "reward"),
|
|
988
|
+
fee: S.String,
|
|
989
|
+
unit: S.Struct({
|
|
990
|
+
steps: S.String,
|
|
991
|
+
mem: S.String
|
|
992
|
+
}),
|
|
993
|
+
datum: S.Struct({
|
|
994
|
+
hash: S.NullOr(S.String),
|
|
995
|
+
value: S.NullOr(S.Object)
|
|
996
|
+
})
|
|
997
|
+
}),
|
|
998
|
+
datum: S.Struct({
|
|
999
|
+
hash: S.NullOr(S.String),
|
|
1000
|
+
value: S.NullOr(S.Object)
|
|
987
1001
|
})
|
|
988
|
-
}),
|
|
989
|
-
fee: S.String,
|
|
990
|
-
unit: S.Struct({
|
|
991
|
-
steps: S.String,
|
|
992
|
-
mem: S.String
|
|
993
|
-
}),
|
|
994
|
-
datum: S.Struct({
|
|
995
|
-
hash: S.NullOr(S.String),
|
|
996
|
-
value: S.NullOr(S.Object)
|
|
997
1002
|
})
|
|
998
1003
|
})
|
|
999
1004
|
)
|
|
@@ -1001,6 +1006,8 @@ var KoiosTxInfoSchema = S.Struct({
|
|
|
1001
1006
|
});
|
|
1002
1007
|
|
|
1003
1008
|
// src/koios/koios.ts
|
|
1009
|
+
import { Effect, pipe, Schedule } from "effect";
|
|
1010
|
+
import { ArrayFormatter } from "@effect/schema";
|
|
1004
1011
|
var Koios = class {
|
|
1005
1012
|
baseUrl;
|
|
1006
1013
|
constructor(baseUrl) {
|
|
@@ -1131,7 +1138,8 @@ var Koios = class {
|
|
|
1131
1138
|
datum_hash: koiosInputOutput.datum_hash,
|
|
1132
1139
|
inline_datum: koiosInputOutput.inline_datum,
|
|
1133
1140
|
reference_script: koiosInputOutput.reference_script,
|
|
1134
|
-
asset_list:
|
|
1141
|
+
//NOTE: Koios api returns collateral_output like asset_list: "[]", instead of asset_list: []
|
|
1142
|
+
asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
|
|
1135
1143
|
},
|
|
1136
1144
|
koiosInputOutput.payment_addr.bech32
|
|
1137
1145
|
)
|
|
@@ -1179,27 +1187,48 @@ var Koios = class {
|
|
|
1179
1187
|
throw new Error("No Datum Found by Datum Hash");
|
|
1180
1188
|
}
|
|
1181
1189
|
}
|
|
1182
|
-
awaitTx(txHash, checkInterval =
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1190
|
+
awaitTx(txHash, checkInterval = 2e4) {
|
|
1191
|
+
const body = {
|
|
1192
|
+
_tx_hashes: [txHash]
|
|
1193
|
+
};
|
|
1194
|
+
const request = {
|
|
1195
|
+
headers: {
|
|
1196
|
+
Accept: "application/json",
|
|
1197
|
+
"Content-Type": "application/json"
|
|
1198
|
+
},
|
|
1199
|
+
method: "POST",
|
|
1200
|
+
body: JSON.stringify(body)
|
|
1201
|
+
};
|
|
1202
|
+
const program = pipe(
|
|
1203
|
+
Effect.tryPromise({
|
|
1204
|
+
//TODO: use tx_status api
|
|
1205
|
+
try: () => fetch(`${this.baseUrl}/tx_info`, request),
|
|
1206
|
+
catch: (error) => new Error(String(error))
|
|
1207
|
+
}),
|
|
1208
|
+
Effect.flatMap(
|
|
1209
|
+
(response) => !response.ok ? Effect.fail(new Error(`${response.status} ${response.statusText}`)) : Effect.succeed(response)
|
|
1210
|
+
),
|
|
1211
|
+
Effect.flatMap(
|
|
1212
|
+
(response) => Effect.tryPromise({
|
|
1213
|
+
try: () => response.json(),
|
|
1214
|
+
catch: (error) => new Error(String(error))
|
|
1215
|
+
})
|
|
1216
|
+
),
|
|
1217
|
+
Effect.flatMap(
|
|
1218
|
+
(json) => S2.decodeUnknown(S2.Array(KoiosTxInfoSchema), { errors: "first" })(json)
|
|
1219
|
+
),
|
|
1220
|
+
Effect.catchTag(
|
|
1221
|
+
"ParseError",
|
|
1222
|
+
(e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
|
|
1223
|
+
),
|
|
1224
|
+
Effect.repeat({
|
|
1225
|
+
schedule: Schedule.exponential(checkInterval),
|
|
1226
|
+
until: (result) => result.length > 0
|
|
1227
|
+
}),
|
|
1228
|
+
Effect.orDie,
|
|
1229
|
+
Effect.as(true)
|
|
1230
|
+
);
|
|
1231
|
+
return Effect.runPromise(program);
|
|
1203
1232
|
}
|
|
1204
1233
|
async submitTx(tx) {
|
|
1205
1234
|
const result = await fetch(`${this.baseUrl}/submittx`, {
|
|
@@ -1210,11 +1239,10 @@ var Koios = class {
|
|
|
1210
1239
|
method: "POST",
|
|
1211
1240
|
body: fromHex3(tx)
|
|
1212
1241
|
}).then((res) => res.json());
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
throw new Error("Could not submit transaction.");
|
|
1242
|
+
const TxHashSchema = S2.String;
|
|
1243
|
+
const isTxHash = S2.is(TxHashSchema);
|
|
1244
|
+
if (!isTxHash(result)) {
|
|
1245
|
+
throw new Error(JSON.stringify(result));
|
|
1218
1246
|
}
|
|
1219
1247
|
return result;
|
|
1220
1248
|
}
|
|
@@ -1224,9 +1252,11 @@ var toUTxO = (koiosUTxO, address) => ({
|
|
|
1224
1252
|
outputIndex: koiosUTxO.tx_index,
|
|
1225
1253
|
assets: (() => {
|
|
1226
1254
|
const a = {};
|
|
1227
|
-
koiosUTxO.asset_list
|
|
1228
|
-
|
|
1229
|
-
|
|
1255
|
+
if (koiosUTxO.asset_list) {
|
|
1256
|
+
koiosUTxO.asset_list.forEach((am) => {
|
|
1257
|
+
a[am.policy_id + am.asset_name] = BigInt(am.quantity);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1230
1260
|
a["lovelace"] = BigInt(koiosUTxO.value);
|
|
1231
1261
|
return a;
|
|
1232
1262
|
})(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"@dcspark/cardano-multiplatform-lib-browser": "^5.3.0",
|
|
29
29
|
"@dcspark/cardano-multiplatform-lib-nodejs": "^5.3.0",
|
|
30
30
|
"@effect/schema": "^0.67.16",
|
|
31
|
+
"effect": "^3.1.2",
|
|
31
32
|
"@lucid-evolution/core-types": "0.1.6",
|
|
32
|
-
"@lucid-evolution/utils": "0.1.
|
|
33
|
-
"@lucid-evolution/
|
|
33
|
+
"@lucid-evolution/core-utils": "0.1.6",
|
|
34
|
+
"@lucid-evolution/utils": "0.1.15"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/node": "^20.12.8",
|