/*
* 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 {
SubAccountIdentifier,
SubAccountIdentifier$inboundSchema,
SubAccountIdentifier$Outbound,
SubAccountIdentifier$outboundSchema,
} from "./subaccountidentifier.js";
/**
* Blockchains that utilize a username model (where the address is not a derivative of a cryptographic public key) should specify the public key(s) owned by the address in metadata.
*/
export type AccountIdentifierMetadata = {};
/**
* The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).
*/
export type AccountIdentifier = {
/**
* The address may be a cryptographic public key (or some encoding of it) or a provided username.
*/
address: string;
/**
* An account may have state specific to a contract address (ERC-20 token) and/or a stake (delegated balance). The sub_account_identifier should specify which state (if applicable) an account instantiation refers to.
*/
subAccount?: SubAccountIdentifier | undefined;
/**
* Blockchains that utilize a username model (where the address is not a derivative of a cryptographic public key) should specify the public key(s) owned by the address in metadata.
*/
metadata?: AccountIdentifierMetadata | undefined;
};
/** @internal */
export const AccountIdentifierMetadata$inboundSchema: z.ZodType<
AccountIdentifierMetadata,
z.ZodTypeDef,
unknown
> = z.object({});
/** @internal */
export type AccountIdentifierMetadata$Outbound = {};
/** @internal */
export const AccountIdentifierMetadata$outboundSchema: z.ZodType<
AccountIdentifierMetadata$Outbound,
z.ZodTypeDef,
AccountIdentifierMetadata
> = 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 AccountIdentifierMetadata$ {
/** @deprecated use `AccountIdentifierMetadata$inboundSchema` instead. */
export const inboundSchema = AccountIdentifierMetadata$inboundSchema;
/** @deprecated use `AccountIdentifierMetadata$outboundSchema` instead. */
export const outboundSchema = AccountIdentifierMetadata$outboundSchema;
/** @deprecated use `AccountIdentifierMetadata$Outbound` instead. */
export type Outbound = AccountIdentifierMetadata$Outbound;
}
export function accountIdentifierMetadataToJSON(
accountIdentifierMetadata: AccountIdentifierMetadata,
): string {
return JSON.stringify(
AccountIdentifierMetadata$outboundSchema.parse(accountIdentifierMetadata),
);
}
export function accountIdentifierMetadataFromJSON(
jsonString: string,
): SafeParseResult<AccountIdentifierMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountIdentifierMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountIdentifierMetadata' from JSON`,
);
}
/** @internal */
export const AccountIdentifier$inboundSchema: z.ZodType<
AccountIdentifier,
z.ZodTypeDef,
unknown
> = z.object({
address: z.string(),
sub_account: SubAccountIdentifier$inboundSchema.optional(),
metadata: z.lazy(() => AccountIdentifierMetadata$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"sub_account": "subAccount",
});
});
/** @internal */
export type AccountIdentifier$Outbound = {
address: string;
sub_account?: SubAccountIdentifier$Outbound | undefined;
metadata?: AccountIdentifierMetadata$Outbound | undefined;
};
/** @internal */
export const AccountIdentifier$outboundSchema: z.ZodType<
AccountIdentifier$Outbound,
z.ZodTypeDef,
AccountIdentifier
> = z.object({
address: z.string(),
subAccount: SubAccountIdentifier$outboundSchema.optional(),
metadata: z.lazy(() => AccountIdentifierMetadata$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
subAccount: "sub_account",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AccountIdentifier$ {
/** @deprecated use `AccountIdentifier$inboundSchema` instead. */
export const inboundSchema = AccountIdentifier$inboundSchema;
/** @deprecated use `AccountIdentifier$outboundSchema` instead. */
export const outboundSchema = AccountIdentifier$outboundSchema;
/** @deprecated use `AccountIdentifier$Outbound` instead. */
export type Outbound = AccountIdentifier$Outbound;
}
export function accountIdentifierToJSON(
accountIdentifier: AccountIdentifier,
): string {
return JSON.stringify(
AccountIdentifier$outboundSchema.parse(accountIdentifier),
);
}
export function accountIdentifierFromJSON(
jsonString: string,
): SafeParseResult<AccountIdentifier, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountIdentifier$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountIdentifier' from JSON`,
);
}