@coolwallet/sol
Version:
Coolwallet Solana sdk
28 lines (27 loc) • 1.71 kB
TypeScript
import * as types from '../config/types';
import { ComputeBudgetInstruction } from '../config/types';
export declare const isBase58Format: (value?: string) => boolean;
export declare function toBase58(publicKey: types.Address): string;
export declare function toBase58Buffer(publicKey: types.Address): Buffer;
export declare function toPublicKey(publicKey: string | Buffer): string;
export declare function pubKeyToAddress(publicKey: string): string;
/**
* CW-21334 Fixed user's publicKey just matches the base58 encoding, resulting in repeated decoding.
*
* The user's Solana address (base58 encoded) is:
* 5XZiuCyozesbRJsSdoJQCTHQRnTGDfSms5bV1ybLn9yg
*
* After converting it to Hex:
* fc238b62abd32cd576f1d5568d3b6b5cb2fbc57b419cc2b4cd8a2814973919a7
* This hex conform to the Base58 format (without 0, O, i, I, +, /), causing base58.decode to be executed again, resulting in an incorrect publicKey.
*
* How to fix it:
* Adjust base58 verification method. A 32-byte public key can only be base58 encoded using 43 or 44 characters.
*/
export declare const formHex: (address: string | Buffer | undefined) => string;
export declare const numberToStringHex: (value: number | number[], pad: number) => string;
export declare const encodeLength: (bytes: number[], len: number) => void;
export declare function toReverseUintBuffer(numberOrString: number | string, byteSize: number): Buffer;
export declare function toUintBuffer(numberOrString: number | string, byteSize: number): Buffer;
export declare function computeBudgetEncode(type: ComputeBudgetInstruction, amount: number | string): Buffer;
export declare function splDataEncode(amount: number | string, tokenDecimals: number | string): Buffer;