Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Static Method to Account Class for Key Validation #931

Merged
merged 8 commits into from
Jan 11, 2025
Merged
Changes from 4 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
14 changes: 14 additions & 0 deletions packages/neon-core/src/wallet/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ export class Account implements NeonObject<AccountJSON> {
});
}

public static validateKey(str: string): string | void {
digimbyte marked this conversation as resolved.
Show resolved Hide resolved
digimbyte marked this conversation as resolved.
Show resolved Hide resolved
switch (true) {
case isPrivateKey(str): return "PrivateKey";
case isPublicKey(str, false): return "PublicKey_Decoded";
digimbyte marked this conversation as resolved.
Show resolved Hide resolved
case isPublicKey(str, true): return "PublicKey_Encoded"
case isScriptHash(str): return "ScriptHash"
case isAddress(str): "Address"
digimbyte marked this conversation as resolved.
Show resolved Hide resolved
case isWIF(str): return "WIF";
case isNEP2(str): return "NEP2"
default:
return;
}
}

public isDefault: boolean;
public lock: boolean;
public contract: {
Expand Down