diff --git a/packages/paima-sdk/paima-crypto/package.json b/packages/paima-sdk/paima-crypto/package.json index 10158624..91af1a8d 100644 --- a/packages/paima-sdk/paima-crypto/package.json +++ b/packages/paima-sdk/paima-crypto/package.json @@ -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" } } diff --git a/packages/paima-sdk/paima-crypto/src/mina.ts b/packages/paima-sdk/paima-crypto/src/mina.ts index 3be2fe40..9b7285c9 100644 --- a/packages/paima-sdk/paima-crypto/src/mina.ts +++ b/packages/paima-sdk/paima-crypto/src/mina.ts @@ -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 => { - // 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,