Skip to content

Commit 246ddd9

Browse files
committed
fix: no shim for fetch
1 parent d8e9bd1 commit 246ddd9

File tree

9 files changed

+34
-53
lines changed

9 files changed

+34
-53
lines changed

build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ await dnt.build({
2222
skipSourceOutput: true,
2323
shims: {
2424
webSocket: true,
25-
undici: true,
25+
undici: false,
2626
crypto: true,
2727
},
2828
package: {

dist/esm/_dnt.shims.d.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
2-
export { fetch, File, FormData, Headers, Request, Response, type BodyInit, type HeadersInit, type RequestInit, type ResponseInit } from "undici";
32
export { default as WebSocket } from "ws";
4-
export declare const dntGlobalThis: Omit<typeof globalThis, "crypto" | "fetch" | "File" | "FormData" | "Headers" | "Request" | "Response" | "WebSocket"> & {
3+
export declare const dntGlobalThis: Omit<typeof globalThis, "crypto" | "WebSocket"> & {
54
crypto: any;
6-
fetch: any;
7-
File: any;
8-
FormData: any;
9-
Headers: any;
10-
Request: any;
11-
Response: any;
125
WebSocket: any;
136
};

dist/esm/_dnt.shims.js

-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { crypto } from "@deno/shim-crypto";
22
export { crypto } from "@deno/shim-crypto";
3-
import { fetch, File, FormData, Headers, Request, Response } from "undici";
4-
export { fetch, File, FormData, Headers, Request, Response } from "undici";
53
import { default as WebSocket } from "ws";
64
export { default as WebSocket } from "ws";
75
const dntGlobals = {
86
crypto,
9-
fetch,
10-
File,
11-
FormData,
12-
Headers,
13-
Request,
14-
Response,
157
WebSocket,
168
};
179
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);

dist/esm/src/core/libs/cardano_multiplatform_lib/pkg/cardano_multiplatform_lib.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as dntShim from "../../../../../_dnt.shims.js";
1+
"use strict";
22
let imports = {};
33
imports['__wbindgen_placeholder__'] = module.exports;
44
let wasm;
@@ -26466,14 +26466,14 @@ module.exports.__wbg_headers_ab5251d2727ac41e = function (arg0) {
2646626466
};
2646726467
module.exports.__wbg_newwithstrandinit_c45f0dc6da26fd03 = function () {
2646826468
return handleError(function (arg0, arg1, arg2) {
26469-
const ret = new dntShim.Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
26469+
const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
2647026470
return addHeapObject(ret);
2647126471
}, arguments);
2647226472
};
2647326473
module.exports.__wbg_instanceof_Response_fb3a4df648c1859b = function (arg0) {
2647426474
let result;
2647526475
try {
26476-
result = getObject(arg0) instanceof dntShim.Response;
26476+
result = getObject(arg0) instanceof Response;
2647726477
}
2647826478
catch {
2647926479
result = false;

dist/esm/src/lucid/tx.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dntShim from "../../_dnt.shims.js";
21
import { C } from "../core/mod.js";
32
import { Data } from "../mod.js";
43
import { assetsToValue, fromHex, networkToId, toHex, toScriptRef, utxoToCore, valueToAssets, chunk, } from "../utils/mod.js";
@@ -476,7 +475,7 @@ async function createPoolRegistration(poolParams, lucid) {
476475
throw new Error("Only key hashes allowed for pool owners.");
477476
});
478477
const metadata = poolParams.metadataUrl
479-
? await dntShim.fetch(poolParams.metadataUrl).then((res) => res.arrayBuffer())
478+
? await fetch(poolParams.metadataUrl).then((res) => res.arrayBuffer())
480479
: null;
481480
const metadataHash = metadata
482481
? C.PoolMetadataHash.from_bytes(C.hash_blake2b256(new Uint8Array(metadata)))

dist/esm/src/provider/blockfrost.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dntShim from "../../_dnt.shims.js";
21
import { C } from "../core/mod.js";
32
import { applyDoubleCborEncoding, fromHex, toHex } from "../utils/mod.js";
43
import packageJson from "../../package.js";
@@ -10,7 +9,7 @@ export class Blockfrost {
109
this.projectId = projectId || "";
1110
}
1211
async getProtocolParameters() {
13-
const result = await dntShim.fetch(`${this.url}/epochs/latest/parameters`, {
12+
const result = await fetch(`${this.url}/epochs/latest/parameters`, {
1413
headers: { project_id: this.projectId, lucid },
1514
}).then((res) => res.json());
1615
return {
@@ -42,7 +41,7 @@ export class Blockfrost {
4241
let result = [];
4342
let page = 1;
4443
while (true) {
45-
const pageResult = await dntShim.fetch(`${this.url}/addresses/${queryPredicate}/utxos?page=${page}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
44+
const pageResult = await fetch(`${this.url}/addresses/${queryPredicate}/utxos?page=${page}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
4645
if (pageResult.error) {
4746
if (pageResult.status_code === 404) {
4847
return [];
@@ -70,7 +69,7 @@ export class Blockfrost {
7069
let result = [];
7170
let page = 1;
7271
while (true) {
73-
const pageResult = await dntShim.fetch(`${this.url}/addresses/${queryPredicate}/utxos/${unit}?page=${page}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
72+
const pageResult = await fetch(`${this.url}/addresses/${queryPredicate}/utxos/${unit}?page=${page}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
7473
if (pageResult.error) {
7574
if (pageResult.status_code === 404) {
7675
return [];
@@ -87,7 +86,7 @@ export class Blockfrost {
8786
return this.blockfrostUtxosToUtxos(result);
8887
}
8988
async getUtxoByUnit(unit) {
90-
const addresses = await dntShim.fetch(`${this.url}/assets/${unit}/addresses?count=2`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
89+
const addresses = await fetch(`${this.url}/assets/${unit}/addresses?count=2`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
9190
if (!addresses || addresses.error) {
9291
throw new Error("Unit not found.");
9392
}
@@ -105,7 +104,7 @@ export class Blockfrost {
105104
// TODO: Make sure old already spent UTxOs are not retrievable.
106105
const queryHashes = [...new Set(outRefs.map((outRef) => outRef.txHash))];
107106
const utxos = await Promise.all(queryHashes.map(async (txHash) => {
108-
const result = await dntShim.fetch(`${this.url}/txs/${txHash}/utxos`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
107+
const result = await fetch(`${this.url}/txs/${txHash}/utxos`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
109108
if (!result || result.error) {
110109
return [];
111110
}
@@ -120,7 +119,7 @@ export class Blockfrost {
120119
return utxos.reduce((acc, utxos) => acc.concat(utxos), []).filter((utxo) => outRefs.some((outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex));
121120
}
122121
async getDelegation(rewardAddress) {
123-
const result = await dntShim.fetch(`${this.url}/accounts/${rewardAddress}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
122+
const result = await fetch(`${this.url}/accounts/${rewardAddress}`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
124123
if (!result || result.error) {
125124
return { poolId: null, rewards: 0n };
126125
}
@@ -130,7 +129,7 @@ export class Blockfrost {
130129
};
131130
}
132131
async getDatum(datumHash) {
133-
const datum = await dntShim.fetch(`${this.url}/scripts/datum/${datumHash}/cbor`, {
132+
const datum = await fetch(`${this.url}/scripts/datum/${datumHash}/cbor`, {
134133
headers: { project_id: this.projectId, lucid },
135134
})
136135
.then((res) => res.json())
@@ -143,7 +142,7 @@ export class Blockfrost {
143142
awaitTx(txHash, checkInterval = 3000) {
144143
return new Promise((res) => {
145144
const confirmation = setInterval(async () => {
146-
const isConfirmed = await dntShim.fetch(`${this.url}/txs/${txHash}`, {
145+
const isConfirmed = await fetch(`${this.url}/txs/${txHash}`, {
147146
headers: { project_id: this.projectId, lucid },
148147
}).then((res) => res.json());
149148
if (isConfirmed && !isConfirmed.error) {
@@ -155,7 +154,7 @@ export class Blockfrost {
155154
});
156155
}
157156
async submitTx(tx) {
158-
const result = await dntShim.fetch(`${this.url}/tx/submit`, {
157+
const result = await fetch(`${this.url}/tx/submit`, {
159158
method: "POST",
160159
headers: {
161160
"Content-Type": "application/cbor",
@@ -182,14 +181,14 @@ export class Blockfrost {
182181
datum: r.inline_datum || undefined,
183182
scriptRef: r.reference_script_hash
184183
? (await (async () => {
185-
const { type, } = await dntShim.fetch(`${this.url}/scripts/${r.reference_script_hash}`, {
184+
const { type, } = await fetch(`${this.url}/scripts/${r.reference_script_hash}`, {
186185
headers: { project_id: this.projectId, lucid },
187186
}).then((res) => res.json());
188187
// TODO: support native scripts
189188
if (type === "Native" || type === "native") {
190189
throw new Error("Native script ref not implemented!");
191190
}
192-
const { cbor: script } = await dntShim.fetch(`${this.url}/scripts/${r.reference_script_hash}/cbor`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
191+
const { cbor: script } = await fetch(`${this.url}/scripts/${r.reference_script_hash}/cbor`, { headers: { project_id: this.projectId, lucid } }).then((res) => res.json());
193192
return {
194193
type: type === "plutusV1" ? "PlutusV1" : "PlutusV2",
195194
script: applyDoubleCborEncoding(script),

dist/esm/src/provider/kupmios.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class Kupmios {
5858
const queryPredicate = isAddress
5959
? addressOrCredential
6060
: addressOrCredential.hash;
61-
const result = await dntShim.fetch(`${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent`)
61+
const result = await fetch(`${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent`)
6262
.then((res) => res.json());
6363
return this.kupmiosUtxosToUtxos(result);
6464
}
@@ -68,13 +68,13 @@ export class Kupmios {
6868
? addressOrCredential
6969
: addressOrCredential.hash;
7070
const { policyId, assetName } = fromUnit(unit);
71-
const result = await dntShim.fetch(`${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent&policy_id=${policyId}${assetName ? `&asset_name=${assetName}` : ""}`)
71+
const result = await fetch(`${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent&policy_id=${policyId}${assetName ? `&asset_name=${assetName}` : ""}`)
7272
.then((res) => res.json());
7373
return this.kupmiosUtxosToUtxos(result);
7474
}
7575
async getUtxoByUnit(unit) {
7676
const { policyId, assetName } = fromUnit(unit);
77-
const result = await dntShim.fetch(`${this.kupoUrl}/matches/${policyId}.${assetName ? `${assetName}` : "*"}?unspent`)
77+
const result = await fetch(`${this.kupoUrl}/matches/${policyId}.${assetName ? `${assetName}` : "*"}?unspent`)
7878
.then((res) => res.json());
7979
const utxos = await this.kupmiosUtxosToUtxos(result);
8080
if (utxos.length > 1) {
@@ -85,7 +85,7 @@ export class Kupmios {
8585
async getUtxosByOutRef(outRefs) {
8686
const queryHashes = [...new Set(outRefs.map((outRef) => outRef.txHash))];
8787
const utxos = await Promise.all(queryHashes.map(async (txHash) => {
88-
const result = await dntShim.fetch(`${this.kupoUrl}/matches/*@${txHash}?unspent`).then((res) => res.json());
88+
const result = await fetch(`${this.kupoUrl}/matches/*@${txHash}?unspent`).then((res) => res.json());
8989
return this.kupmiosUtxosToUtxos(result);
9090
}));
9191
return utxos.reduce((acc, utxos) => acc.concat(utxos), []).filter((utxo) => outRefs.some((outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex));
@@ -112,7 +112,7 @@ export class Kupmios {
112112
});
113113
}
114114
async getDatum(datumHash) {
115-
const result = await dntShim.fetch(`${this.kupoUrl}/datums/${datumHash}`).then((res) => res.json());
115+
const result = await fetch(`${this.kupoUrl}/datums/${datumHash}`).then((res) => res.json());
116116
if (!result || !result.datum) {
117117
throw new Error(`No datum found for datum hash: ${datumHash}`);
118118
}
@@ -121,7 +121,7 @@ export class Kupmios {
121121
awaitTx(txHash, checkInterval = 3000) {
122122
return new Promise((res) => {
123123
const confirmation = setInterval(async () => {
124-
const isConfirmed = await dntShim.fetch(`${this.kupoUrl}/matches/*@${txHash}?unspent`).then((res) => res.json());
124+
const isConfirmed = await fetch(`${this.kupoUrl}/matches/*@${txHash}?unspent`).then((res) => res.json());
125125
if (isConfirmed && isConfirmed.length > 0) {
126126
clearInterval(confirmation);
127127
await new Promise((res) => setTimeout(() => res(1), 1000));
@@ -170,7 +170,7 @@ export class Kupmios {
170170
: null,
171171
scriptRef: utxo.script_hash &&
172172
(await (async () => {
173-
const { script, language, } = await dntShim.fetch(`${this.kupoUrl}/scripts/${utxo.script_hash}`).then((res) => res.json());
173+
const { script, language, } = await fetch(`${this.kupoUrl}/scripts/${utxo.script_hash}`).then((res) => res.json());
174174
if (language === "native") {
175175
return { type: "Native", script };
176176
}

dist/esm/src/provider/maestro.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dntShim from "../../_dnt.shims.js";
21
import { C } from "../core/mod.js";
32
import { applyDoubleCborEncoding, fromHex } from "../utils/mod.js";
43
import packageJson from "../../package.js";
@@ -12,7 +11,7 @@ export class Maestro {
1211
this.turboSubmit = turboSubmit;
1312
}
1413
async getProtocolParameters() {
15-
const timestampedResult = await dntShim.fetch(`${this.url}/protocol-params`, {
14+
const timestampedResult = await fetch(`${this.url}/protocol-params`, {
1615
headers: this.commonHeaders(),
1716
}).then((res) => res.json());
1817
const result = timestampedResult.data;
@@ -68,7 +67,7 @@ export class Maestro {
6867
count: "100",
6968
...(unit && { asset: unit }),
7069
});
71-
const result = await this.getAllPagesData(async (qry) => await dntShim.fetch(qry, { headers: this.commonHeaders() }), `${this.url}${queryPredicate}/utxos`, qparams, "Location: getUtxosInternal. Error: Could not fetch UTxOs from Maestro");
70+
const result = await this.getAllPagesData(async (qry) => await fetch(qry, { headers: this.commonHeaders() }), `${this.url}${queryPredicate}/utxos`, qparams, "Location: getUtxosInternal. Error: Could not fetch UTxOs from Maestro");
7271
return result.map(this.maestroUtxoToUtxo);
7372
}
7473
getUtxos(addressOrCredential) {
@@ -78,7 +77,7 @@ export class Maestro {
7877
return this.getUtxosInternal(addressOrCredential, unit);
7978
}
8079
async getUtxoByUnit(unit) {
81-
const timestampedAddressesResponse = await dntShim.fetch(`${this.url}/assets/${unit}/addresses?count=2`, { headers: this.commonHeaders() });
80+
const timestampedAddressesResponse = await fetch(`${this.url}/assets/${unit}/addresses?count=2`, { headers: this.commonHeaders() });
8281
const timestampedAddresses = await timestampedAddressesResponse.json();
8382
if (!timestampedAddressesResponse.ok) {
8483
if (timestampedAddresses.message) {
@@ -104,7 +103,7 @@ export class Maestro {
104103
async getUtxosByOutRef(outRefs) {
105104
const qry = `${this.url}/transactions/outputs`;
106105
const body = JSON.stringify(outRefs.map(({ txHash, outputIndex }) => `${txHash}#${outputIndex}`));
107-
const utxos = await this.getAllPagesData(async (qry) => await dntShim.fetch(qry, {
106+
const utxos = await this.getAllPagesData(async (qry) => await fetch(qry, {
108107
method: "POST",
109108
headers: {
110109
"Content-Type": "application/json",
@@ -115,7 +114,7 @@ export class Maestro {
115114
return utxos.map(this.maestroUtxoToUtxo);
116115
}
117116
async getDelegation(rewardAddress) {
118-
const timestampedResultResponse = await dntShim.fetch(`${this.url}/accounts/${rewardAddress}`, { headers: this.commonHeaders() });
117+
const timestampedResultResponse = await fetch(`${this.url}/accounts/${rewardAddress}`, { headers: this.commonHeaders() });
119118
if (!timestampedResultResponse.ok) {
120119
return { poolId: null, rewards: 0n };
121120
}
@@ -127,7 +126,7 @@ export class Maestro {
127126
};
128127
}
129128
async getDatum(datumHash) {
130-
const timestampedResultResponse = await dntShim.fetch(`${this.url}/datum/${datumHash}`, {
129+
const timestampedResultResponse = await fetch(`${this.url}/datum/${datumHash}`, {
131130
headers: this.commonHeaders(),
132131
});
133132
if (!timestampedResultResponse.ok) {
@@ -145,7 +144,7 @@ export class Maestro {
145144
awaitTx(txHash, checkInterval = 3000) {
146145
return new Promise((res) => {
147146
const confirmation = setInterval(async () => {
148-
const isConfirmedResponse = await dntShim.fetch(`${this.url}/transactions/${txHash}/cbor`, {
147+
const isConfirmedResponse = await fetch(`${this.url}/transactions/${txHash}/cbor`, {
149148
headers: this.commonHeaders(),
150149
});
151150
if (isConfirmedResponse.ok) {
@@ -160,7 +159,7 @@ export class Maestro {
160159
async submitTx(tx) {
161160
let queryUrl = `${this.url}/txmanager`;
162161
queryUrl += this.turboSubmit ? "/turbosubmit" : "";
163-
const response = await dntShim.fetch(queryUrl, {
162+
const response = await fetch(queryUrl, {
164163
method: "POST",
165164
headers: {
166165
"Content-Type": "application/cbor",

dist/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
"packageManager": "[email protected]+sha256.36b548120f75f26408d04ff163cd4a699916f1c4b72ebeeab0bbaf054009eb5b",
2424
"dependencies": {
2525
"@deno/shim-crypto": "^0.3.1",
26-
"undici": "^6.0.1",
27-
"ws": "^8.14.2"
26+
"ws": "^8.14.2",
27+
"undici": "^6.0.1"
2828
},
2929
"devDependencies": {
30-
"@types/node": "^20.9.0",
3130
"wasm-pack": "^0.12.1"
3231
},
3332
"_generatedBy": "[email protected]"

0 commit comments

Comments
 (0)