Commit ccf6e45a authored by imtase's avatar imtase
Browse files

feat(custom-json): add typed social builders refs #2

parent 0740903b
Loading
Loading
Loading
Loading
+90 −0
Original line number Diff line number Diff line
@@ -2766,6 +2766,79 @@ declare module 'dblurt/helpers/blockchain' {
	    getOperationsStream(options?: BlockchainStreamOptions | number): NodeJS.ReadableStream;
	}

}
declare module 'dblurt/social' {
	import { CustomJsonOperation } from 'dblurt/chain/operation';
	export type CustomJsonPayload = unknown;
	export interface CustomJsonBuilderOptions<TPayload = CustomJsonPayload> {
	    /** Account signing with posting authority. */
	    account: string;
	    /** Custom JSON protocol id, for example `follow`, `reblog`, `community`, or `notify`. */
	    id: string;
	    /** JSON payload before stringification. */
	    payload: TPayload;
	    /** Optional active/owner authorities for non-posting custom JSON conventions. Defaults to none. */
	    required_auths?: string[];
	    /** Override posting authorities. Defaults to `[account]`. */
	    required_posting_auths?: string[];
	}
	export type FollowWhat = 'blog' | 'ignore';
	export type FollowJsonPayload = ['follow', {
	    follower: string;
	    following: string;
	    what: FollowWhat[];
	}];
	export type ReblogJsonPayload = ['reblog', {
	    account: string;
	    author: string;
	    permlink: string;
	    delete?: 'delete';
	}];
	export type CommunitySubscriptionAction = 'subscribe' | 'unsubscribe';
	export type CommunitySubscriptionJsonPayload = [CommunitySubscriptionAction, {
	    community: string;
	}];
	export type ReadNotificationJsonPayload = ['setLastRead', {
	    date: string;
	}];
	export interface FollowOperationOptions {
	    follower: string;
	    following: string;
	}
	export interface ReblogOperationOptions {
	    account: string;
	    author: string;
	    permlink: string;
	}
	export interface CommunitySubscriptionOperationOptions {
	    account: string;
	    community: string;
	}
	export interface ReadNotificationOperationOptions {
	    account: string;
	    date: string;
	}
	/** Build a typed `custom_json` operation from an unstringified payload. */
	export function buildCustomJsonOperation<TPayload = CustomJsonPayload>(options: CustomJsonBuilderOptions<TPayload>): CustomJsonOperation;
	/** Build a `follow` custom_json operation using posting authority. */
	export function buildFollowOperation(options: FollowOperationOptions): CustomJsonOperation;
	/** Build an `unfollow` custom_json operation using the empty follow-list convention. */
	export function buildUnfollowOperation(options: FollowOperationOptions): CustomJsonOperation;
	/** Build a mute operation using the follow/ignore convention. */
	export function buildMuteOperation(options: FollowOperationOptions): CustomJsonOperation;
	/** Build an unmute operation using the empty follow-list convention. */
	export function buildUnmuteOperation(options: FollowOperationOptions): CustomJsonOperation;
	/** Build a reblog custom_json operation. */
	export function buildReblogOperation(options: ReblogOperationOptions): CustomJsonOperation;
	/** Build an undo-reblog custom_json operation. */
	export function buildUndoReblogOperation(options: ReblogOperationOptions): CustomJsonOperation;
	/** Build a community subscribe custom_json operation. */
	export function buildCommunitySubscribeOperation(options: CommunitySubscriptionOperationOptions): CustomJsonOperation;
	/** Build a community unsubscribe custom_json operation. */
	export function buildCommunityUnsubscribeOperation(options: CommunitySubscriptionOperationOptions): CustomJsonOperation;
	/** Build a notification read-marker custom_json operation. */
	export function buildReadNotificationOperation(options: ReadNotificationOperationOptions): CustomJsonOperation;

}
declare module 'dblurt/chain/nexus' {
	/**
@@ -3274,6 +3347,18 @@ declare module 'dblurt/helpers/broadcast' {
	     * @param key The Posting, Active or Owner private key of the account.
	     **/
	    reblurt(account: string, author: string, permlink: string, undo: boolean | undefined, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a reblog custom_json operation. */
	    reblog(account: string, author: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast an undo-reblog custom_json operation. */
	    undoReblog(account: string, author: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a follow custom_json operation. */
	    follow(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast an unfollow custom_json operation. */
	    unfollow(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a mute custom_json operation using the follow/ignore convention. */
	    mute(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast an unmute custom_json operation using the empty follow-list convention. */
	    unmute(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a read notification to the network. */
	    readNotification(account: string, date: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a signed transaction to the network. */
@@ -3380,6 +3465,10 @@ declare module 'dblurt/helpers/broadcast' {
	     * @param key The Posting, Active or Owner private key of the account.
	     **/
	    nexusSubscription(community: string, action: 'subscribe' | 'unsubscribe', account: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a community subscribe custom_json operation. */
	    communitySubscribe(account: string, community: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /** Broadcast a community unsubscribe custom_json operation. */
	    communityUnsubscribe(account: string, community: string, key: PrivateKey): Promise<TransactionConfirmation>;
	    /**
	     * Stickies a post to the top of the community homepage (Mods or higher). If multiple posts are stickied, the newest ones are shown first.
	     * @param authority The account submitting the custom_json operation.
@@ -4614,6 +4703,7 @@ declare module 'dblurt' {
	export * from 'dblurt/transports/rpc_transport';
	export * from 'dblurt/crypto';
	export * from 'dblurt/authority';
	export * from 'dblurt/social';

}
declare module 'dblurt/index-browser' {
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+516 B (105 KiB)

File changed.

No diff preview for this file type.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@
    --dark-hl-13: #4EC9B0;
    --light-hl-14: #0451A5;
    --dark-hl-14: #9CDCFE;
    --light-hl-15: #008000;
    --dark-hl-15: #6A9955;
    --light-code-background: #FFFFFF;
    --dark-code-background: #1E1E1E;
}
@@ -49,6 +51,7 @@
    --hl-12: var(--light-hl-12);
    --hl-13: var(--light-hl-13);
    --hl-14: var(--light-hl-14);
    --hl-15: var(--light-hl-15);
    --code-background: var(--light-code-background);
} }

@@ -68,6 +71,7 @@
    --hl-12: var(--dark-hl-12);
    --hl-13: var(--dark-hl-13);
    --hl-14: var(--dark-hl-14);
    --hl-15: var(--dark-hl-15);
    --code-background: var(--dark-code-background);
} }

@@ -87,6 +91,7 @@
    --hl-12: var(--light-hl-12);
    --hl-13: var(--light-hl-13);
    --hl-14: var(--light-hl-14);
    --hl-15: var(--light-hl-15);
    --code-background: var(--light-code-background);
}

@@ -106,6 +111,7 @@
    --hl-12: var(--dark-hl-12);
    --hl-13: var(--dark-hl-13);
    --hl-14: var(--dark-hl-14);
    --hl-15: var(--dark-hl-15);
    --code-background: var(--dark-code-background);
}

@@ -124,4 +130,5 @@
.hl-12 { color: var(--hl-12); }
.hl-13 { color: var(--hl-13); }
.hl-14 { color: var(--hl-14); }
.hl-15 { color: var(--hl-15); }
pre, code { background: var(--code-background); }
Loading