UNPKG

@firefly-exchange/library-sui

Version:

Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui

63 lines (62 loc) 2.77 kB
import { SignatureScheme } from "@mysten/sui/cryptography"; import { Signer as BaseSigner } from "@mysten/sui/cryptography"; import { KmsSigner } from "../classes"; export declare const SignaturePayloadStruct: import("@mysten/sui/bcs").BcsType<{ target: string; receiver: string; amount: string; expiry: string; nonce: string; type: number; }, { target: any; receiver: any; amount: string | number | bigint; expiry: string | number | bigint; nonce: string | number | bigint; type: number; }>; export declare const SignatureStruct: import("@mysten/sui/bcs").BcsType<{ sig: number[]; pk: number[]; scheme: number; }, { sig: Iterable<number> & { length: number; }; pk: Iterable<number> & { length: number; }; scheme: number; }>; export declare class Signer { /** * Provided a payload for generating reward or funds claim signature, serializes it and returns its sha 256 hash to be signed * @param data signature payload to be signed * @returns sha256 hash of serialized data payload provided as input */ static getPayloadHash(data: typeof SignaturePayloadStruct.$inferType): Uint8Array; /** * Uses the provided signer key pair to generate signature for the users to use and claim rewards or funds * @param signer KeyPair of the signer. The signer must be the operator/controller of the rewards pool or claims_manager of the vault * @param payload The payload to be signed * @returns serialized signature that can be provided to user to perform on-chain `claim_rewards` call. */ static sign(signer: BaseSigner, payload: typeof SignaturePayloadStruct.$inferType): Promise<string>; /** * Uses the provided signer key pair to generate signature for the users to use and claim rewards or funds * @param signer KeyPair of the signer. The signer must be the operator/controller of the rewards pool or claims_manager of the vault * @param payload The payload to be signed * @returns serialized signature that can be provided to user to perform on-chain `claim_rewards` call. */ static signUsingKMS(signer: KmsSigner, payload: typeof SignaturePayloadStruct.$inferType): Promise<string>; /** * Given an array of data bytes and serialized signature returns true if the signature is valid * @param signature bcs serialized signature (returned by `Signer.sign` method) * @param data data bytes array * @param payload * @returns True if signature is valid */ static verify(signature: string, payload: typeof SignaturePayloadStruct.$inferType): boolean; static getSuiAddressFromPublicKey(publicKey: string | Uint8Array, scheme: SignatureScheme): string; }