UNPKG

iso-filecoin

Version:

Isomorphic filecoin abstractions for RPC, signatures, address, token and wallet

82 lines 2.43 kB
export namespace SIGNATURE_TYPE { let SECP256K1: 1; let BLS: 2; } export const SIGNATURE_CODE: { readonly 1: "SECP256K1"; readonly 2: "BLS"; }; export namespace Schemas { let lotusSignature: z.ZodObject<{ Type: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>]>; Data: z.ZodString; }, "strip", z.ZodTypeAny, { Type: 2 | 1; Data: string; }, { Type: 2 | 1; Data: string; }>; let signature: z.ZodObject<{ type: z.ZodEnum<["SECP256K1", "BLS"]>; data: z.ZodEffects<z.ZodType<BufferSource, z.ZodTypeDef, BufferSource>, Uint8Array<ArrayBufferLike>, BufferSource>; }, "strip", z.ZodTypeAny, { type: "SECP256K1" | "BLS"; data: Uint8Array<ArrayBufferLike>; }, { type: "SECP256K1" | "BLS"; data: BufferSource; }>; } /** * @typedef {keyof typeof SIGNATURE_TYPE} SignatureType * @typedef {(typeof SIGNATURE_TYPE)[SignatureType]} SignatureCode * @typedef {z.infer<typeof Schemas.lotusSignature>} LotusSignature * @typedef {z.infer<typeof Schemas.signature>} SignatureObj */ /** * Signature Class */ export class Signature { /** * * @param {LotusSignature} json */ static fromLotus(json: LotusSignature): Signature; /** * Signature from Lotus-style hex encoded string * * Lotus adds 0x01 or 0x02 to the signature depending on the type. * * @param {string} str - Hex encoded signature */ static fromLotusHex(str: string): Signature; /** * * @param {SignatureObj} sig */ constructor(sig: SignatureObj); type: "SECP256K1" | "BLS"; data: Uint8Array<ArrayBufferLike>; get code(): 2 | 1; /** * Encodes the signature as a JSON object in the Lotus RPC format. * * @returns {LotusSignature} */ toLotus(): LotusSignature; /** * Encodes the signature as a Lotus-style hex encoded string * * Lotus adds 0x01 or 0x02 to the signature depending on the type. * * @returns {string} Hex encoded signature */ toLotusHex(): string; } export type SignatureType = keyof typeof SIGNATURE_TYPE; export type SignatureCode = (typeof SIGNATURE_TYPE)[SignatureType]; export type LotusSignature = z.infer<typeof Schemas.lotusSignature>; export type SignatureObj = z.infer<typeof Schemas.signature>; import { z } from 'zod'; //# sourceMappingURL=signature.d.ts.map