Skip to content

Commit

Permalink
use base58check for mina verifyAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Apr 30, 2024
1 parent a90bb0c commit 78e1abb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/paima-sdk/paima-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@polkadot/util-crypto": "^10.4.2",
"bech32": "^2.0.0",
"@paima/utils": "2.3.0",
"mina-signer": "2.1.1"
"mina-signer": "^2.1.1",
"base58check": "^2.0.0"
}
}
14 changes: 8 additions & 6 deletions packages/paima-sdk/paima-crypto/src/mina.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { doLog } from '@paima/utils';
import type { IVerify } from './IVerify.js';
const base58check = require('base58check');

export class MinaCrypto implements IVerify {
verifyAddress = async (address: string): Promise<boolean> => {
// base58 alphabet
return await Promise.resolve(
/^[1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|J|K|L|M|N|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|m|n|o|p|q|r|s|t|u|v|w|x|y|z]/.test(
address
)
);
try {
base58check.decode(address);
} catch (e) {
return false;
}

return true;
};
verifySignature = async (
userAddress: string,
Expand Down

0 comments on commit 78e1abb

Please sign in to comment.