import { Buffer } from 'buffer/index.js'; import { AccountTransactionSignature, Base58String, BlockItemSummary, HexString, InvokeContractSuccessResult } from '../types.js'; import * as AccountAddress from '../types/AccountAddress.js'; import * as ContractAddress from '../types/ContractAddress.js'; import * as ContractEvent from '../types/ContractEvent.js'; import * as EntrypointName from '../types/EntrypointName.js'; import * as Parameter from '../types/Parameter.js'; import * as Timestamp from '../types/Timestamp.js'; export declare namespace CIS3 { /** * A `permit` message containing invokation information for an entrypoint, part of the CIS3 specification. */ type PermitMessage = { /** The address of the intended contract. */ contractAddress: ContractAddress.Type; /** A nonce to prevent replay attacks. */ nonce: bigint; /** The timestamp of the message. */ timestamp: Timestamp.Type; /** The entrypoint to be invoked. */ entrypoint: EntrypointName.Type; /** The parameters to be passed to the entrypoint. */ payload: Parameter.Type; }; /** * The parameters to the `permit` function according to the CIS3 specification. */ type PermitParam = { /** The signature of the sponsoree. */ signature: AccountTransactionSignature; /** The address of the sponsoree. */ signer: AccountAddress.Type; /** The signed message to be invoked by the contract. */ message: PermitMessage; }; /** * Structure of JSON-formatted CIS3 `permit` message used for transactions. */ type PermitMessageJson = { contract_address: { index: number; subindex: number; }; nonce: number; timestamp: Timestamp.SchemaValue; entry_point: string; payload: number[]; }; /** * Structure of JSON-formatted parameter used for CIS3 `permit` transactions. */ type PermitParamJson = { signature: [number, [number, { Ed25519: [HexString]; }][]][]; signer: Base58String; message: PermitMessageJson; }; /** * The type of a CIS-3 event. * @see {@linkcode Event} */ enum EventType { Nonce = 0, Custom = 1 } /** * A CIS-3 nonce event. This event is logged every time the `permit` function is invoked. */ type NonceEvent = { /** The type of the event */ type: EventType.Nonce; /** The nonce used for the `permit` invocation */ nonce: bigint; /** The address of the sponsoree */ sponsoree: AccountAddress.Type; }; /** * A custom event outside CIS-3. */ type CustomEvent = { /** The type of the event */ type: EventType.Custom; /** The raw data of the custom event */ data: Uint8Array; }; /** * A CIS-3 event. */ type Event = NonceEvent | CustomEvent; } /** * Serialize a {@link CIS3.PermitMessage} to a buffer according to the CIS3 standard. * * @param {CIS3.PermitMessage} message - The message to serialize. * * @returns {Buffer} The serialized message. */ export declare function serializeCIS3PermitMessage(message: CIS3.PermitMessage): Buffer; /** * Serialize a `permit` payload to a buffer according to the CIS3 standard. * * @param {Parameter.Type} payload - The payload to serialize. * * @returns {Buffer} The serialized payload. * * @throws If the payload is too large. */ export declare function serializeCIS3PermitPayload(payload: Parameter.Type): Buffer; /** * Serialize a {@link CIS3.PermitParam} to a buffer according to the CIS3 standard. * * @param {CIS3.PermitParam} param - The parameter to serialize. * * @returns {Buffer} The serialized parameter. */ export declare function serializeCIS3PermitParam(param: CIS3.PermitParam): Buffer; /** * Serializes a map of account transaction signatures according to the CIS-3 standard. * If no signatures are provided, then an error is thrown. */ export declare function serializeCIS3AccountTransactionSignature(signatures: AccountTransactionSignature): Buffer; /** * Serialize the parameters for `supportsPermit` to a buffer according to the CIS3 standard. * The paramteres are a list of {@link EntrypointName}. * * @param {EntrypointName.Type[]} params - The parameters to serialize. * * @returns {Buffer} The serialized parameters. * * @throws If the list of entrypoints is too long. */ export declare function serializeCIS3SupportsPermitQueryParams(params: EntrypointName.Type[]): Buffer; /** * Deserialize a `supportsPermit` response from a buffer according to the CIS3 standard. * * @param {Buffer} cursor - The buffer to deserialize. * * @returns {boolean[]} The deserialized list of booleans indicating support for each entrypoint. */ export declare const deserializeCIS3SupportsPermitResponse: (value: string) => boolean[]; /** * Format {@link CIS3.PermitParam} as a JSON compatible object. * * @param {CIS3.PermitParam} params - The parameters to format. * * @returns {CIS3.PermitParamJson} The formatted parameters. */ export declare function formatCIS3PermitParam(params: CIS3.PermitParam): CIS3.PermitParamJson; /** * Deserializes a CIS-3 event according to the CIS-3 standard. * * @param {ContractEvent.Type} event - The event to deserialize * * @returns {CIS3.Event} The deserialized event */ export declare function deserializeCIS3Event(event: ContractEvent.Type): CIS3.Event; /** * Deserializes a successful contract invokation to a list of CIS-3 events according to the CIS-3 standard. * * @param {InvokeContractSuccessResult} result - The contract invokation result to deserialize * * @returns {CIS3.NonceEvent[]} The deserialized `nonce` events */ export declare function deserializeCIS3EventsFromInvokationResult(result: InvokeContractSuccessResult): CIS3.NonceEvent[]; /** * Deserializes all CIS-3 `nonce` events (skipping custom events) from a {@linkcode BlockItemSummary}. * * @param {BlockItemSummary} summary - The summary to deserialize * * @returns {CIS3.NonceEvent[]} The deserialized `nonce` events */ export declare function deserializeCIS3EventsFromSummary(summary: BlockItemSummary): CIS3.NonceEvent[];