Skip to content
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export default [
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",

Expand Down
2 changes: 1 addition & 1 deletion packages/cosmwasm-stargate/src/cosmwasmclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class CosmWasmClient {
const account = await this.forceGetQueryClient().auth.account(searchAddress);
return account ? accountFromAny(account) : null;
} catch (error: any) {
if (/rpc error: code = NotFound/i.test(error.toString())) {
if (/rpc error: code = NotFound/i.test(String(error))) {
Copy link
Member

@webmaster128 webmaster128 Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can also use the solution from the other getAccount implementation:

    } catch (error) {
      assert(error instanceof Error);
      if (/rpc error: code = NotFound/i.test(error.toString())) {
        return null;
      }

It avoids the any type and uses unknown instead. Any preference?

return null;
}
throw error;
Expand Down
2 changes: 1 addition & 1 deletion packages/json-rpc/src/workers/dummyservice.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function handleRequest(event: MessageEvent): JsonRpcResponse {
id: requestId,
error: {
code: jsonRpcCode.invalidRequest,
message: error.toString(),
message: String(error),
},
};
return errorResponse;
Expand Down
59 changes: 32 additions & 27 deletions packages/ledger-amino/src/demo/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import TransportWebUSB from "@ledgerhq/hw-transport-webusb";

import { LedgerSigner } from "../ledgersigner";

declare const window: any;
declare const document: any;
const getElement = (id: string): HTMLInputElement => {
const e = document.getElementById(id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this compile? How does TS know document.getElementById exists here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, in ledger-amino we have DOM types due to

    "lib": ["es2020", "dom"]

assert(e instanceof HTMLInputElement, "got the wrong element!");
return e;
};

const accountNumbers = [0, 1, 2, 10];
const paths = accountNumbers.map(makeCosmoshubPath);
Expand Down Expand Up @@ -45,7 +48,7 @@ function createSignDoc(accountNumber: number, address: string): string {
return JSON.stringify(signDoc, null, 2);
}

window.updateMessage = (accountNumberInput: unknown) => {
const updateMessage = (accountNumberInput: unknown): void => {
assert(typeof accountNumberInput === "string");
const accountNumber = Uint53.fromString(accountNumberInput).toNumber();
const account = accounts[accountNumber];
Expand All @@ -54,23 +57,23 @@ window.updateMessage = (accountNumberInput: unknown) => {
}

const address = accounts[accountNumber].address;
const addressInput = document.getElementById("address");
const addressInput = getElement("address");
addressInput.value = address;
const signDocTextArea = document.getElementById("sign-doc");
const signDocTextArea = getElement("sign-doc");
signDocTextArea.textContent = createSignDoc(accountNumber, address);
};

window.setPath = (accountNumberInput: unknown) => {
const setPath = (accountNumberInput: unknown): void => {
assert(typeof accountNumberInput === "string");
const accountNumber = Uint53.fromString(accountNumberInput).toNumber();

const path = pathToString(paths[accountNumber]);
const pathInput = document.getElementById("path");
const pathInput = getElement("path");
pathInput.value = path;
};

// This must be called by the user an cannot be done on load (see "TransportWebUSBGestureRequired").
window.createSigner = async function createSigner(): Promise<LedgerSigner> {
const createSigner = async function createSigner(): Promise<LedgerSigner> {
const interactiveTimeout = 120_000;
const ledgerTransport = await TransportWebUSB.create(interactiveTimeout, interactiveTimeout);
return new LedgerSigner(ledgerTransport, {
Expand All @@ -79,16 +82,16 @@ window.createSigner = async function createSigner(): Promise<LedgerSigner> {
});
};

window.getAccounts = async function getAccounts(signer: LedgerSigner | undefined): Promise<void> {
const getAccounts = async function getAccounts(signer: LedgerSigner | undefined): Promise<void> {
if (signer === undefined) {
console.error("Please wait for transport to connect");
return;
}
const accountNumberInput1 = document.getElementById("account-number1");
const accountNumberInput2 = document.getElementById("account-number2");
const addressInput = document.getElementById("address");
const accountsDiv = document.getElementById("accounts");
const signDocTextArea = document.getElementById("sign-doc");
const accountNumberInput1 = getElement("account-number1");
const accountNumberInput2 = getElement("account-number2");
const addressInput = getElement("address");
const accountsDiv = getElement("accounts");
const signDocTextArea = getElement("sign-doc");
accountsDiv.textContent = "Loading...";

try {
Expand All @@ -101,46 +104,48 @@ window.getAccounts = async function getAccounts(signer: LedgerSigner | undefined
const accountNumber = 0;

// Show address block
accountNumberInput1.max = accounts.length - 1;
accountNumberInput1.value = accountNumber;
window.setPath(accountNumber.toString());
accountNumberInput1.max = String(accounts.length - 1);
accountNumberInput1.value = String(accountNumber);
setPath(accountNumber.toString());

// Sign block
accountNumberInput2.max = accounts.length - 1;
accountNumberInput2.value = accountNumber;
accountNumberInput2.max = String(accounts.length - 1);
accountNumberInput2.value = String(accountNumber);
const address = accounts[0].address;
addressInput.value = address;
signDocTextArea.textContent = createSignDoc(accountNumber, address);
} catch (error) {
console.error(error);
accountsDiv.textContent = error;
accountsDiv.textContent = String(error);
}
};

window.showAddress = async function showAddress(signer: LedgerSigner | undefined): Promise<void> {
const showAddress = async function showAddress(signer: LedgerSigner | undefined): Promise<void> {
if (signer === undefined) {
console.error("Please wait for transport to connect");
return;
}
const path = stringToPath(document.getElementById("path").value);
const path = stringToPath(getElement("path").value);
await signer.showAddress(path);
};

window.sign = async function sign(signer: LedgerSigner | undefined): Promise<void> {
const sign = async function sign(signer: LedgerSigner | undefined): Promise<void> {
if (signer === undefined) {
console.error("Please wait for transport to connect");
return;
}
const signatureDiv = document.getElementById("signature");
const signatureDiv = getElement("signature");
signatureDiv.textContent = "Loading...";

try {
const address = document.getElementById("address").value;
const signDocJson = document.getElementById("sign-doc").textContent;
const address = getElement("address").value;
const signDocJson = getElement("sign-doc").textContent;
const signDoc: StdSignDoc = JSON.parse(signDocJson);
const signature = await signer.signAmino(address, signDoc);
signatureDiv.textContent = JSON.stringify(signature, null, "\t");
} catch (error) {
signatureDiv.textContent = error;
signatureDiv.textContent = String(error);
}
};

Object.assign(window, { updateMessage, setPath, createSigner, getAccounts, showAddress, sign });
5 changes: 3 additions & 2 deletions packages/ledger-amino/src/ledgersigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ async function createTransport(): Promise<Transport> {
}
// HACK: Use a variable to get webpack to ignore this
const nodeJsTransportPackageName = "@ledgerhq/hw-transport-node-hid";
const { default: TransportClass } =
const TransportClass: typeof Transport = (
platform === "node"
? await import(nodeJsTransportPackageName)
: await import("@ledgerhq/hw-transport-webusb");
: await import("@ledgerhq/hw-transport-webusb")
).default;
return TransportClass.create(interactiveTimeout, interactiveTimeout);
}

Expand Down
7 changes: 6 additions & 1 deletion packages/stargate/src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export function parseRawLog(input: string | undefined): readonly Log[] {
// Cosmos SDK >= 0.50 gives us an empty string here. This should be handled like undefined.
if (!input) return [];

const logsToParse = JSON.parse(input).map(({ events }: { events: readonly unknown[] }, i: number) => ({
const parsedInput = JSON.parse(input);
if (!Array.isArray(parsedInput)) {
throw new Error("rawLog must be an array");
}

const logsToParse = parsedInput.map(({ events }: { events: readonly unknown[] }, i: number) => ({
msg_index: i,
events,
log: "",
Expand Down
7 changes: 4 additions & 3 deletions packages/stargate/src/multisignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export function makeMultisignedTx(
): TxRaw {
const addresses = Array.from(signatures.keys());
const prefix = fromBech32(addresses[0]).prefix;
const pubkeys = multisigPubkey.value.pubkeys;

const signers: boolean[] = Array(multisigPubkey.value.pubkeys.length).fill(false);
const signers = new Array<boolean>(pubkeys.length).fill(false);
const signaturesList = new Array<Uint8Array>();
for (let i = 0; i < multisigPubkey.value.pubkeys.length; i++) {
const signerAddress = pubkeyToAddress(multisigPubkey.value.pubkeys[i], prefix);
for (let i = 0; i < pubkeys.length; i++) {
const signerAddress = pubkeyToAddress(pubkeys[i], prefix);
const signature = signatures.get(signerAddress);
if (signature) {
signers[i] = true;
Expand Down
Loading