import { Buffer } from 'buffer/index.js'; import { Cursor } from './deserializationHelpers.js'; import { Cbor, TokenId } from './plt/index.js'; import { AccountTransactionInput, ContractAddress, InitContractInput, UpdateContractInput, UpdateCredentialKeysInput, UpdateCredentialKeysPayload, UpdateCredentialsInput } from './pub/types.js'; import { AccountTransactionHeader, AccountTransactionPayload, AccountTransactionType, BakerKeysWithProofs, Base58String, ConfigureBakerPayload, ConfigureDelegationPayload, DelegationTarget, DeployModulePayload, HexString, InitContractPayload, OpenStatus, RegisterDataPayload, SimpleTransferPayload, SimpleTransferWithMemoPayload, TokenUpdatePayload, UpdateContractPayload, UpdateCredentialsPayload, UrlString } from './types.js'; export interface AccountTransactionHandler { /** * Serializes the payload to a buffer. * This does NOT include the serialized transaction type. To have this included, use {@linkcode serializeAccountTransactionPayload} instead. * * @param payload - The payload to serialize. * @returns The serialized payload. * @throws If serializing the type was not possible. */ serialize: (payload: Payload) => Buffer; /** * Deserializes the serialized payload into the payload type. * @param serializedPayload - The serialized payload to be deserialized. * @returns The deserialized payload. * @throws If deserializing the type was not possible. */ deserialize: (serializedPayload: Cursor) => Payload; /** * Gets the base energy cost for the given payload. * @param input - The transction input for which to get the base energy cost. * @returns The base energy cost for the payload. */ getBaseEnergyCost: (input: Input) => bigint; /** * Converts the payload into JSON format. * @param payload - The payload to be converted into JSON. * @returns The payload in JSON format. */ toJSON: (payload: Payload | Input) => JSONPayload; /** * Converts a JSON-serialized payload into the payload type. * @param json - The JSON to be converted back into the payload. * @returns The payload obtained from the JSON. */ fromJSON: (json: JSONPayload) => Payload | Input; } export interface SimpleTransferPayloadJSON { toAddress: Base58String; amount: string; } /** * @deprecated use `Transaction.transfer` and `Payload.transfer` APIs instead. */ export declare class SimpleTransferHandler implements AccountTransactionHandler { getBaseEnergyCost(): bigint; serialize(transfer: SimpleTransferPayload): Buffer; deserialize(serializedPayload: Cursor): SimpleTransferPayload; toJSON(transfer: SimpleTransferPayload): SimpleTransferPayloadJSON; fromJSON(json: SimpleTransferPayloadJSON): SimpleTransferPayload; } export interface SimpleTransferWithMemoPayloadJSON extends SimpleTransferPayloadJSON { memo: HexString; } /** * @deprecated use `Transaction.transfer` and `Payload.transfer` APIs instead. */ export declare class SimpleTransferWithMemoHandler implements AccountTransactionHandler { getBaseEnergyCost(): bigint; serialize(transfer: SimpleTransferWithMemoPayload): Buffer; deserialize(serializedPayload: Cursor): SimpleTransferWithMemoPayload; toJSON(transfer: SimpleTransferWithMemoPayload): SimpleTransferWithMemoPayloadJSON; fromJSON(json: SimpleTransferWithMemoPayloadJSON): SimpleTransferWithMemoPayload; } export interface DeployModulePayloadJSON { source: HexString; version?: number; } /** * @deprecated use `Transaction.deployModule` and `Payload.deployModule` APIs instead. */ export declare class DeployModuleHandler implements AccountTransactionHandler { getBaseEnergyCost(payload: DeployModulePayload): bigint; serialize(payload: DeployModulePayload): Buffer; deserialize(serializePayload: Cursor): DeployModulePayload; toJSON(payload: DeployModulePayload): DeployModulePayloadJSON; fromJSON(json: DeployModulePayloadJSON): DeployModulePayload; } export interface InitContractPayloadJSON { amount: string; moduleRef: HexString; initName: string; param: HexString; } export interface InitContractInputJSON { amount: string; moduleRef: HexString; initName: string; param: HexString; maxContractExecutionEnergy: bigint; } /** * @deprecated use `Transaction.initContract` and `Payload.initContract` APIs instead. */ export declare class InitContractHandler implements AccountTransactionHandler { getBaseEnergyCost(payload: InitContractInput): bigint; serialize(payload: InitContractPayload): Buffer; deserialize(serializePayload: Cursor): InitContractPayload; toJSON(payload: InitContractPayload): InitContractPayloadJSON; toJSON(payload: InitContractInput): InitContractInputJSON; fromJSON(json: InitContractInputJSON): InitContractInput; fromJSON(json: InitContractPayloadJSON): InitContractPayload; } export interface UpdateContractPayloadJSON { amount: string; address: ContractAddress.SchemaValue; receiveName: string; message: HexString; } export interface UpdateContractInputJSON { amount: string; address: ContractAddress.SchemaValue; receiveName: string; message: HexString; maxContractExecutionEnergy: bigint; } export type TransactionMetadata = Pick; /** * @deprecated use `Transaction.updateContract` and `Payload.updateContract` APIs instead. */ export declare class UpdateContractHandler implements AccountTransactionHandler { getBaseEnergyCost(payload: UpdateContractInput): bigint; serialize(payload: UpdateContractPayload): Buffer; deserialize(serializedPayload: Cursor): UpdateContractPayload; toJSON(payload: UpdateContractPayload): UpdateContractPayloadJSON; toJSON(payload: UpdateContractInput): UpdateContractInputJSON; fromJSON(json: UpdateContractInputJSON): UpdateContractInput; fromJSON(json: UpdateContractPayloadJSON): UpdateContractPayload; } /** * {@linkcode UpdateCredentialsPayload} is already JSON serializable. */ export type UpdateCredentialsPayloadJSON = UpdateCredentialsPayload; /** * {@linkcode UpdateCredentialsInput} is already JSON serializable. */ export type UpdateCredentialsInputJSON = UpdateCredentialsInput; /** * @deprecated use `Transaction.updateCredentials` and `Payload.updateCredentials` APIs instead. */ export declare class UpdateCredentialsHandler implements AccountTransactionHandler { getBaseEnergyCost(payload: UpdateCredentialsInput): bigint; serialize(updateCredentials: UpdateCredentialsPayload): Buffer; deserialize(serializedPayload: Cursor): UpdateCredentialsPayload; toJSON(updateCredentials: UpdateCredentialsPayload): UpdateCredentialsPayload; toJSON(updateCredentials: UpdateCredentialsInput): UpdateCredentialsInput; fromJSON(json: UpdateCredentialsInputJSON): UpdateCredentialsInput; fromJSON(json: UpdateCredentialsPayloadJSON): UpdateCredentialsPayload; } export interface RegisterDataPayloadJSON { data: HexString; } /** * @deprecated use `Transaction.registerData` and `Payload.registerData` APIs instead. */ export declare class RegisterDataHandler implements AccountTransactionHandler { getBaseEnergyCost(): bigint; serialize(payload: RegisterDataPayload): Buffer; deserialize(serializedPayload: Cursor): RegisterDataPayload; toJSON(payload: RegisterDataPayload): RegisterDataPayloadJSON; fromJSON(json: RegisterDataPayloadJSON): RegisterDataPayload; } export interface ConfigureBakerPayloadJSON { stake?: string; restakeEarnings?: boolean; openForDelegation?: OpenStatus; keys?: BakerKeysWithProofs; metadataUrl?: UrlString; transactionFeeCommission?: number; bakingRewardCommission?: number; finalizationRewardCommission?: number; } /** * @deprecated use `Transaction.configureValidator` and `Payload.configureValidator` APIs instead. */ export declare class ConfigureBakerHandler implements AccountTransactionHandler { HAS_CAPITAL: number; HAS_RESTAKE_EARNINGS: number; HAS_OPEN_FOR_DELEGATION: number; HAS_KEYS_WITH_PROOF: number; HAS_METADATA_URL: number; HAS_TRANSACTION_FEE_COMMISSION: number; HAS_BAKING_REWARD_COMMISSION: number; HAS_FINALIZATION_REWARD_COMMISSION: number; HAS_SUSPENDED: number; ALLOWED_BITS: number; VALIDATION_MASK: number; getBaseEnergyCost(payload: ConfigureBakerPayload): bigint; serialize(payload: ConfigureBakerPayload): Buffer; deserialize(serializedPayload: Cursor): ConfigureBakerPayload; toJSON(payload: ConfigureBakerPayload): ConfigureBakerPayloadJSON; fromJSON(json: ConfigureBakerPayloadJSON): ConfigureBakerPayload; } export interface ConfigureDelegationPayloadJSON { stake?: string; restakeEarnings?: boolean; delegationTarget?: DelegationTarget; } /** * @deprecated use `Transaction.configureDelegation` and `Payload.configureDelegation` APIs instead. */ export declare class ConfigureDelegationHandler implements AccountTransactionHandler { ALLOWED_BITS: number; VALIDATION_MASK: number; HAS_DELEGATION_TARGET: number; HAS_RESTAKE_EARNINGS: number; HAS_CAPITAL: number; getBaseEnergyCost(): bigint; serialize(payload: ConfigureDelegationPayload): Buffer; deserialize(serializedPayload: Cursor): ConfigureDelegationPayload; toJSON(payload: ConfigureDelegationPayload): ConfigureDelegationPayloadJSON; fromJSON(json: ConfigureDelegationPayloadJSON): ConfigureDelegationPayload; } export type TokenUpdatePayloadJSON = { tokenId: TokenId.JSON; operations: Cbor.JSON; }; /** * @deprecated use `Transaction.tokenUpdate` and `Payload.tokenUpdate` APIs instead. */ export declare class TokenUpdateHandler implements AccountTransactionHandler { serialize(payload: TokenUpdatePayload): Buffer; deserialize(serializedPayload: Cursor): TokenUpdatePayload; getBaseEnergyCost(payload: TokenUpdatePayload): bigint; toJSON(payload: TokenUpdatePayload): TokenUpdatePayloadJSON; fromJSON(json: TokenUpdatePayloadJSON): TokenUpdatePayload; } export type UpdateCredentialKeysPayloadJSON = { credId: string; keys: string; }; export declare class UpdateCredentialKeysHandler implements AccountTransactionHandler { getBaseEnergyCost(payload: UpdateCredentialKeysInput): bigint; serialize(payload: UpdateCredentialKeysPayload): Buffer; deserialize(serializedPayload: Cursor): UpdateCredentialKeysPayload; toJSON(payload: UpdateCredentialKeysPayload): UpdateCredentialKeysPayloadJSON; fromJSON(json: UpdateCredentialKeysPayloadJSON): UpdateCredentialKeysPayload; } export type AccountTransactionPayloadJSON = SimpleTransferPayloadJSON | SimpleTransferWithMemoPayloadJSON | DeployModulePayloadJSON | InitContractPayloadJSON | UpdateContractPayloadJSON | UpdateCredentialsPayload | RegisterDataPayloadJSON | ConfigureDelegationPayloadJSON | ConfigureBakerPayloadJSON | TokenUpdatePayloadJSON | UpdateCredentialKeysPayloadJSON; /** * @deprecated use `Transaction` and `Payload` APIs instead. */ export declare function getAccountTransactionHandler(type: AccountTransactionType.Transfer): SimpleTransferHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.TransferWithMemo): SimpleTransferWithMemoHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.UpdateCredentials): UpdateCredentialsHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.DeployModule): DeployModuleHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.InitContract): InitContractHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.Update): UpdateContractHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.RegisterData): RegisterDataHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.ConfigureDelegation): ConfigureDelegationHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.ConfigureBaker): ConfigureBakerHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.TokenUpdate): TokenUpdateHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType.UpdateCredentialKeys): UpdateCredentialKeysHandler; export declare function getAccountTransactionHandler(type: AccountTransactionType): AccountTransactionHandler;