Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid-singleton";
import { MinaLedgerJS, Networks, TxType } from "../src/";
import { MinaLedgerJS, Networks, TxType, isValidAddress } from "../src/";

const getAppVersion = async (instance: any) => {
const version = await instance.getAppVersion();
Expand Down Expand Up @@ -42,13 +42,17 @@ const getDelegation = async (instance: any) => {
});
console.log(signature);
};
const validateAddress = () => {
const isValid = isValidAddress("B62qr9pMrhSwBA6txJ8kD3f9GZ3VQPoUaFnKhEosdJmnZXXKj6qhkGF");
console.log(isValid);
}

(async () => {

console.log(`
console.log(`

>> mina-ledger-js usage example on Node:

`)

const transport = await TransportNodeHid.create();
Expand All @@ -58,4 +62,5 @@ const getDelegation = async (instance: any) => {
await getAddress(instance);
await getDelegation(instance);
await getSignature(instance);
validateAddress();
})();
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { MinaLedgerJS } from "./lib";
export { isValidAddress } from "./utils";
export * from "./types";
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Validate a Mina address.
*/
export const isValidAddress = (address: string): boolean => {
const regex = new RegExp("^B62q[i-s][A-HJ-NP-Za-km-z1-9]{50}$");

return regex.test(address);
};