/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { remap as remap$ } from "../lib/primitives.js";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
import {
NetworkIdentifier,
NetworkIdentifier$inboundSchema,
NetworkIdentifier$Outbound,
NetworkIdentifier$outboundSchema,
} from "./networkidentifier.js";
/**
* Parameters is some network-specific argument for a method. It is up to the caller to determine which parameters to provide when invoking `/call`.
*/
export type ParametersT = {};
/**
* CallRequest is the input to the `/call` endpoint.
*/
export type CallRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* Method is some network-specific procedure call. This method could map to a network-specific RPC endpoint, a method in an SDK generated from a smart contract, or some hybrid of the two. The implementation must define all available methods in the Allow object. However, it is up to the caller to determine which parameters to provide when invoking `/call`.
*/
method: string;
/**
* Parameters is some network-specific argument for a method. It is up to the caller to determine which parameters to provide when invoking `/call`.
*/
parameters: ParametersT;
};
/** @internal */
export const ParametersT$inboundSchema: z.ZodType<
ParametersT,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type ParametersT$Outbound = {};
/** @internal */
export const ParametersT$outboundSchema: z.ZodType<
ParametersT$Outbound,
z.ZodTypeDef,
ParametersT
> = z.object({});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ParametersT$ {
/** @deprecated use `ParametersT$inboundSchema` instead. */
export const inboundSchema = ParametersT$inboundSchema;
/** @deprecated use `ParametersT$outboundSchema` instead. */
export const outboundSchema = ParametersT$outboundSchema;
/** @deprecated use `ParametersT$Outbound` instead. */
export type Outbound = ParametersT$Outbound;
}
export function parametersToJSON(parametersT: ParametersT): string {
return JSON.stringify(ParametersT$outboundSchema.parse(parametersT));
}
export function parametersFromJSON(
jsonString: string,
): SafeParseResult<ParametersT, SDKValidationError> {
return safeParse(
jsonString,
(x) => ParametersT$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ParametersT' from JSON`,
);
}
/** @internal */
export const CallRequest$inboundSchema: z.ZodType<
CallRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
method: z.string(),
parameters: z.lazy(() => ParametersT$inboundSchema),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
});
});
/** @internal */
export type CallRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
method: string;
parameters: ParametersT$Outbound;
};
/** @internal */
export const CallRequest$outboundSchema: z.ZodType<
CallRequest$Outbound,
z.ZodTypeDef,
CallRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
method: z.string(),
parameters: z.lazy(() => ParametersT$outboundSchema),
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace CallRequest$ {
/** @deprecated use `CallRequest$inboundSchema` instead. */
export const inboundSchema = CallRequest$inboundSchema;
/** @deprecated use `CallRequest$outboundSchema` instead. */
export const outboundSchema = CallRequest$outboundSchema;
/** @deprecated use `CallRequest$Outbound` instead. */
export type Outbound = CallRequest$Outbound;
}
export function callRequestToJSON(callRequest: CallRequest): string {
return JSON.stringify(CallRequest$outboundSchema.parse(callRequest));
}
export function callRequestFromJSON(
jsonString: string,
): SafeParseResult<CallRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => CallRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CallRequest' from JSON`,
);
}