@hashgraphonline/standards-sdk
Version:
The Hashgraph Online Standards SDK provides a complete implementation of the Hashgraph Consensus Standards (HCS), giving developers all the tools needed to build applications on Hedera.
520 lines • 11.9 kB
TypeScript
import { z } from 'zod';
import { AccountId, TopicId } from '@hashgraph/sdk';
/**
* HCS-20 Constants
*/
export declare const HCS20_CONSTANTS: {
readonly PROTOCOL: "hcs-20";
readonly PUBLIC_TOPIC_ID: "0.0.4350190";
readonly REGISTRY_TOPIC_ID: "0.0.4362300";
readonly MAX_NUMBER_LENGTH: 18;
readonly MAX_NAME_LENGTH: 100;
readonly MAX_METADATA_LENGTH: 100;
readonly HEDERA_ACCOUNT_REGEX: RegExp;
};
/**
* Base HCS-20 Message Schema
*/
declare const HCS20BaseMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
m?: string;
}, {
p?: "hcs-20";
m?: string;
}>;
/**
* Deploy Points Operation Schema
*/
export declare const HCS20DeployMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"deploy">;
name: z.ZodString;
tick: z.ZodEffects<z.ZodString, string, string>;
max: z.ZodString;
lim: z.ZodOptional<z.ZodString>;
metadata: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "deploy";
m?: string;
tick?: string;
max?: string;
lim?: string;
}, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "deploy";
m?: string;
tick?: string;
max?: string;
lim?: string;
}>;
/**
* Mint Points Operation Schema
*/
export declare const HCS20MintMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"mint">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
op?: "mint";
m?: string;
tick?: string;
amt?: string;
to?: string;
}, {
p?: "hcs-20";
op?: "mint";
m?: string;
tick?: string;
amt?: string;
to?: string;
}>;
/**
* Burn Points Operation Schema
*/
export declare const HCS20BurnMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"burn">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
from: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
from?: string;
op?: "burn";
m?: string;
tick?: string;
amt?: string;
}, {
p?: "hcs-20";
from?: string;
op?: "burn";
m?: string;
tick?: string;
amt?: string;
}>;
/**
* Transfer Points Operation Schema
*/
export declare const HCS20TransferMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"transfer">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
from: z.ZodString;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
from?: string;
op?: "transfer";
m?: string;
tick?: string;
amt?: string;
to?: string;
}, {
p?: "hcs-20";
from?: string;
op?: "transfer";
m?: string;
tick?: string;
amt?: string;
to?: string;
}>;
/**
* Register Topic Operation Schema
*/
export declare const HCS20RegisterMessageSchema: z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"register">;
name: z.ZodString;
metadata: z.ZodOptional<z.ZodString>;
private: z.ZodBoolean;
t_id: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "register";
m?: string;
private?: boolean;
t_id?: string;
}, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "register";
m?: string;
private?: boolean;
t_id?: string;
}>;
/**
* Union schema for all HCS-20 messages
*/
export declare const HCS20MessageSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"deploy">;
name: z.ZodString;
tick: z.ZodEffects<z.ZodString, string, string>;
max: z.ZodString;
lim: z.ZodOptional<z.ZodString>;
metadata: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "deploy";
m?: string;
tick?: string;
max?: string;
lim?: string;
}, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "deploy";
m?: string;
tick?: string;
max?: string;
lim?: string;
}>, z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"mint">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
op?: "mint";
m?: string;
tick?: string;
amt?: string;
to?: string;
}, {
p?: "hcs-20";
op?: "mint";
m?: string;
tick?: string;
amt?: string;
to?: string;
}>, z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"burn">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
from: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
from?: string;
op?: "burn";
m?: string;
tick?: string;
amt?: string;
}, {
p?: "hcs-20";
from?: string;
op?: "burn";
m?: string;
tick?: string;
amt?: string;
}>, z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"transfer">;
tick: z.ZodEffects<z.ZodString, string, string>;
amt: z.ZodString;
from: z.ZodString;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
from?: string;
op?: "transfer";
m?: string;
tick?: string;
amt?: string;
to?: string;
}, {
p?: "hcs-20";
from?: string;
op?: "transfer";
m?: string;
tick?: string;
amt?: string;
to?: string;
}>, z.ZodObject<{
p: z.ZodLiteral<"hcs-20">;
m: z.ZodOptional<z.ZodString>;
} & {
op: z.ZodLiteral<"register">;
name: z.ZodString;
metadata: z.ZodOptional<z.ZodString>;
private: z.ZodBoolean;
t_id: z.ZodString;
}, "strip", z.ZodTypeAny, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "register";
m?: string;
private?: boolean;
t_id?: string;
}, {
p?: "hcs-20";
metadata?: string;
name?: string;
op?: "register";
m?: string;
private?: boolean;
t_id?: string;
}>]>;
/**
* Inferred types from schemas
*/
export type HCS20BaseMessage = z.infer<typeof HCS20BaseMessageSchema>;
export type HCS20DeployMessage = z.infer<typeof HCS20DeployMessageSchema>;
export type HCS20MintMessage = z.infer<typeof HCS20MintMessageSchema>;
export type HCS20BurnMessage = z.infer<typeof HCS20BurnMessageSchema>;
export type HCS20TransferMessage = z.infer<typeof HCS20TransferMessageSchema>;
export type HCS20RegisterMessage = z.infer<typeof HCS20RegisterMessageSchema>;
export type HCS20Message = z.infer<typeof HCS20MessageSchema>;
export type HCS20Operation = HCS20Message['op'];
/**
* Points Configuration
*/
export interface PointsConfig {
name: string;
tick: string;
maxSupply: string;
limitPerMint?: string;
metadata?: string;
}
/**
* Points Information
*/
export interface PointsInfo extends PointsConfig {
topicId: string;
deployerAccountId: string;
currentSupply: string;
deploymentTimestamp: string;
isPrivate: boolean;
}
/**
* Points Balance
*/
export interface PointsBalance {
tick: string;
accountId: string;
balance: string;
lastUpdated: string;
}
/**
* Points Transaction
*/
export interface PointsTransaction {
id: string;
operation: HCS20Operation;
tick: string;
amount?: string;
from?: string;
to?: string;
timestamp: string;
sequenceNumber: number;
topicId: string;
transactionId: string;
memo?: string;
}
/**
* HCS-20 Client Configuration
*/
export interface HCS20ClientConfig {
mirrorNodeUrl?: string;
logger?: any;
network?: 'mainnet' | 'testnet';
registryTopicId?: string;
publicTopicId?: string;
}
/**
* Browser-specific HCS-20 Client Configuration
*/
export interface BrowserHCS20ClientConfig extends HCS20ClientConfig {
walletConnectProjectId?: string;
hwcMetadata?: {
name: string;
description: string;
icons: string[];
url: string;
};
}
/**
* SDK-specific HCS-20 Client Configuration
*/
export interface SDKHCS20ClientConfig extends HCS20ClientConfig {
operatorId: string | AccountId;
operatorKey: string;
}
/**
* Deploy Points Progress
*/
export interface DeployPointsProgress {
stage: 'creating-topic' | 'submitting-deploy' | 'confirming' | 'complete';
percentage: number;
topicId?: string;
deployTxId?: string;
error?: string;
}
/**
* Deploy Points Options
*/
export interface DeployPointsOptions extends PointsConfig {
usePrivateTopic?: boolean;
topicMemo?: string;
progressCallback?: (data: DeployPointsProgress) => void;
}
/**
* Mint Points Progress
*/
export interface MintPointsProgress {
stage: 'validating' | 'submitting' | 'confirming' | 'complete';
percentage: number;
mintTxId?: string;
error?: string;
}
/**
* Mint Points Options
*/
export interface MintPointsOptions {
tick: string;
amount: string;
to: string | AccountId;
memo?: string;
progressCallback?: (data: MintPointsProgress) => void;
}
/**
* Transfer Points Progress
*/
export interface TransferPointsProgress {
stage: 'validating-balance' | 'submitting' | 'confirming' | 'complete';
percentage: number;
transferTxId?: string;
error?: string;
}
/**
* Transfer Points Options
*/
export interface TransferPointsOptions {
tick: string;
amount: string;
from: string | AccountId;
to: string | AccountId;
memo?: string;
progressCallback?: (data: TransferPointsProgress) => void;
}
/**
* Burn Points Progress
*/
export interface BurnPointsProgress {
stage: 'validating-balance' | 'submitting' | 'confirming' | 'complete';
percentage: number;
burnTxId?: string;
error?: string;
}
/**
* Burn Points Options
*/
export interface BurnPointsOptions {
tick: string;
amount: string;
from: string | AccountId;
memo?: string;
progressCallback?: (data: BurnPointsProgress) => void;
}
/**
* Register Topic Progress
*/
export interface RegisterTopicProgress {
stage: 'validating' | 'submitting' | 'confirming' | 'complete';
percentage: number;
registerTxId?: string;
error?: string;
}
/**
* Register Topic Options
*/
export interface RegisterTopicOptions {
topicId: string | TopicId;
name: string;
metadata?: string;
isPrivate: boolean;
memo?: string;
progressCallback?: (data: RegisterTopicProgress) => void;
}
/**
* Query Points Options
*/
export interface QueryPointsOptions {
tick?: string;
accountId?: string | AccountId;
topicId?: string | TopicId;
limit?: number;
order?: 'asc' | 'desc';
}
/**
* Points Query Result
*/
export interface PointsQueryResult {
points: PointsInfo[];
balances?: PointsBalance[];
transactions?: PointsTransaction[];
totalCount: number;
hasMore: boolean;
nextCursor?: string;
}
/**
* Points State
*/
export interface PointsState {
deployedPoints: Map<string, PointsInfo>;
balances: Map<string, Map<string, PointsBalance>>;
transactions: PointsTransaction[];
lastProcessedSequence: number;
lastProcessedTimestamp: string;
}
/**
* HCS-20 Registry Entry
*/
export interface HCS20RegistryEntry {
name: string;
topicId: string;
metadata?: string;
isPrivate: boolean;
registeredAt: string;
registeredBy: string;
}
export {};
//# sourceMappingURL=types.d.ts.map