Add docs to LBRY module

This commit is contained in:
Snazzah 2021-06-25 11:32:10 -05:00
parent 8aa15b5bf4
commit 864d840144
No known key found for this signature in database
GPG key ID: 5E71D54F3D86282E
3 changed files with 217 additions and 5 deletions

View file

@ -41,65 +41,107 @@ export default class LBRYModule<T extends DexareClient<CurateConfig>> extends De
if (params && Object.keys(params).length) payload.params = params; if (params && Object.keys(params).length) payload.params = params;
const response = await needle('post', this.config.sdkURL, payload); const response = await needle('post', this.config.sdkURL, payload);
const body = response.body; const body: LBRY.JSONRPCResponse<any> | LBRY.LBRYErrorResponse = response.body;
if ('code' in body && 'message' in body) throw new LBRYError(response); if ('code' in body && 'message' in body) throw new LBRYError(response);
return body.result; return body.result;
} }
/* #region account */ /* #region account */
/**
* Return the balance of an account
*/
accountBalance(options?: LBRY.AccountBalanceArguments): Promise<LBRY.Balance> { accountBalance(options?: LBRY.AccountBalanceArguments): Promise<LBRY.Balance> {
return this.post('account_balance', options); return this.post('account_balance', options);
} }
/**
* Create a new account.
* Specify --single_key if you want to use the same address for all transactions (not recommended).
*/
accountCreate(options: LBRY.AccountCreateArguments): Promise<LBRY.Account> { accountCreate(options: LBRY.AccountCreateArguments): Promise<LBRY.Account> {
return this.post('account_create', options); return this.post('account_create', options);
} }
/**
* Transfer some amount (or --everything) to an account from another account (can be the same account).
* Amounts are interpreted as LBC.
* You can also spread the transfer across a number of --outputs (cannot be used together with --everything).
*/
accountFund(options: LBRY.AccountFundArguments): Promise<LBRY.Transaction> { accountFund(options: LBRY.AccountFundArguments): Promise<LBRY.Transaction> {
return this.post('account_fund', options); return this.post('account_fund', options);
} }
/**
* List details of all of the accounts or a specific account.
*/
accountList(options?: LBRY.AccountListArguments): Promise<LBRY.PaginatingResult<LBRY.Account>> { accountList(options?: LBRY.AccountListArguments): Promise<LBRY.PaginatingResult<LBRY.Account>> {
return this.post('account_list', options); return this.post('account_list', options);
} }
/**
* Remove an existing account.
*/
accountRemove(options: LBRY.AccountRemoveArguments): Promise<LBRY.Account> { accountRemove(options: LBRY.AccountRemoveArguments): Promise<LBRY.Account> {
return this.post('account_remove', options); return this.post('account_remove', options);
} }
/* #endregion */ /* #endregion */
/* #region address */ /* #region address */
/**
* List account addresses or details of single address.
*/
addressList(options?: LBRY.AddressListArguments): Promise<LBRY.PaginatingResult<LBRY.Address>> { addressList(options?: LBRY.AddressListArguments): Promise<LBRY.PaginatingResult<LBRY.Address>> {
return this.post('address_list', options); return this.post('address_list', options);
} }
/* #endregion */ /* #endregion */
/* #region support */ /* #region support */
/**
* Abandon supports, including tips, of a specific claim, optionally keeping some amount as supports.
*/
supportAbandon(options: LBRY.SupportAbandonArguments): Promise<LBRY.Transaction> { supportAbandon(options: LBRY.SupportAbandonArguments): Promise<LBRY.Transaction> {
return this.post('support_abandon', options); return this.post('support_abandon', options);
} }
/**
* Create a support or a tip for name claim.
*/
supportCreate(options: LBRY.SupportCreateArguments): Promise<LBRY.Transaction> { supportCreate(options: LBRY.SupportCreateArguments): Promise<LBRY.Transaction> {
return this.post('support_create', options); return this.post('support_create', options);
} }
/**
* List staked supports and sent/received tips.
*/
supportList(options?: LBRY.SupportListArguments): Promise<LBRY.PaginatingResult<LBRY.Support>> { supportList(options?: LBRY.SupportListArguments): Promise<LBRY.PaginatingResult<LBRY.Support>> {
return this.post('support_list', options); return this.post('support_list', options);
} }
/* #endregion */ /* #endregion */
/* #region wallet */ /* #region wallet */
/**
* Return the balance of a wallet.
*/
walletBalance(options?: LBRY.WalletBalanceArguments): Promise<LBRY.Balance> { walletBalance(options?: LBRY.WalletBalanceArguments): Promise<LBRY.Balance> {
return this.post('wallet_balance', options); return this.post('wallet_balance', options);
} }
/**
* Send the same number of credits to multiple addresses using all accounts
* in wallet to fund the transaction and the default account to receive any change.
*/
walletSend(options: LBRY.WalletSendArguments): Promise<LBRY.Transaction> { walletSend(options: LBRY.WalletSendArguments): Promise<LBRY.Transaction> {
return this.post('wallet_send', options); return this.post('wallet_send', options);
} }
/* #endregion */ /* #endregion */
/* #region claim */ /* #region claim */
/**
* Search for stream and channel claims on the blockchain.
* Arguments marked with "supports equality constraints" allow prepending the value with an equality constraint such as '>', '>=', '<' and '<='
* would limit results to only claims above 400k block height.
*/
claimSearch( claimSearch(
options: LBRY.ClaimSearchArguments options: LBRY.ClaimSearchArguments
): Promise<LBRY.SearchPaginatingResult<LBRY.SearchableClaim>> { ): Promise<LBRY.SearchPaginatingResult<LBRY.SearchableClaim>> {

View file

@ -125,165 +125,334 @@ export interface Address {
pubkey: string; pubkey: string;
used_times: number; used_times: number;
} }
/** trending groups of the content */
export enum TrendingGroup {
/** not trending globally or locally */
NONE = 1,
/** trending globally but not independently */
GLOBALLY,
/** not trending globally but is trending independently (locally) */
INDEPENDENTLY,
/** trending globally and independently */
BOTH
}
type SearchOrderBy =
| 'name'
| 'height'
| 'release_time'
| 'publish_time'
| 'amount'
| 'effective_amount'
| 'support_amount'
| 'trending_group'
| 'trending_mixed'
| 'trending_local'
| 'trending_global'
| 'activation_height'
| '^name'
| '^height'
| '^release_time'
| '^publish_time'
| '^amount'
| '^effective_amount'
| '^support_amount'
| '^trending_group'
| '^trending_mixed'
| '^trending_local'
| '^trending_global'
| '^activation_height';
/* #endregion */ /* #endregion */
/* #region arguments */ /* #region arguments */
export interface PaginatingArguments { export interface PaginatingArguments {
/** page to return during paginating */
page?: number; page?: number;
/** number of items on page during pagination */
page_size?: number; page_size?: number;
} }
export interface NoTotalsPaginatingArguments extends PaginatingArguments { export interface NoTotalsPaginatingArguments extends PaginatingArguments {
/** do not calculate the total number of pages and items in result set (significant performance boost) */
no_totals?: boolean; no_totals?: boolean;
} }
export interface BlockingArguments { export interface BlockingArguments {
/** do not broadcast the transaction */
preview?: boolean; preview?: boolean;
/** wait until transaction is in mempool */
blocking?: boolean; blocking?: boolean;
} }
/** @see https://lbry.tech/api/sdk#account_balance */
export interface AccountBalanceArguments { export interface AccountBalanceArguments {
/** If provided only the balance for this account will be given. Otherwise default account. */
account_id?: string; account_id?: string;
/** balance for specific wallet */
wallet_id?: string; wallet_id?: string;
/** Only include transactions with this many confirmed blocks. */
confirmations?: number; confirmations?: number;
} }
/** @see https://lbry.tech/api/sdk#account_create */
export interface AccountCreateArguments { export interface AccountCreateArguments {
/** name of the account to create */
account_name: string; account_name: string;
/** create single key account, default is multi-key */
single_key?: boolean; single_key?: boolean;
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
} }
/** @see https://lbry.tech/api/sdk#account_fund */
export interface AccountFundArguments { export interface AccountFundArguments {
/** send to this account */
to_account?: string; to_account?: string;
/** spend from this account */
from_account?: string; from_account?: string;
/** the amount to transfer lbc */
amount: decimal; amount: decimal;
/** transfer everything (excluding claims)
* @default false */
everything?: boolean; everything?: boolean;
/** split payment across many outputs
* @default 1 */
outputs?: number; outputs?: number;
/** limit operation to specific wallet */
wallet_id?: string; wallet_id?: string;
/** actually broadcast the transaction
* @default false */
broadcast?: boolean; broadcast?: boolean;
} }
/** @see https://lbry.tech/api/sdk#account_list */
export interface AccountListArguments extends PaginatingArguments { export interface AccountListArguments extends PaginatingArguments {
/** If provided only the balance for this account will be given */
account_id?: string; account_id?: string;
/** accounts in specific wallet */
wallet_id?: string; wallet_id?: string;
/** required confirmations
* @default 0 */
confirmations?: number; confirmations?: number;
/** include claims, requires than a LBC account is specified
* @default false */
include_claims?: boolean; include_claims?: boolean;
/** show the seed for the account */
show_seed?: boolean; show_seed?: boolean;
} }
/** @see https://lbry.tech/api/sdk#account_remove */
export interface AccountRemoveArguments { export interface AccountRemoveArguments {
/** id of the account to remove */
account_id: string; account_id: string;
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
} }
/** @see https://lbry.tech/api/sdk#address_list */
export interface AddressListArguments extends PaginatingArguments { export interface AddressListArguments extends PaginatingArguments {
/** just show details for single address */
address?: string; address?: string;
/** id of the account to use */
account_id?: string; account_id?: string;
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
} }
/** @see https://lbry.tech/api/sdk#support_abandon */
export interface SupportAbandonArguments extends BlockingArguments { export interface SupportAbandonArguments extends BlockingArguments {
/** claim_id of the support to abandon */
claim_id?: string; claim_id?: string;
/** txid of the claim to abandon */
txid?: string; txid?: string;
/** nout of the claim to abandon */
nout?: number; nout?: number;
/** amount of lbc to keep as support */
keep?: decimal; keep?: decimal;
/** amount of lbc to keep as support */
account_id?: string; account_id?: string;
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
} }
/** @see https://lbry.tech/api/sdk#support_create */
export interface SupportCreateArguments extends BlockingArguments { export interface SupportCreateArguments extends BlockingArguments {
/** claim_id of the claim to support */
claim_id: string; claim_id: string;
/** amount of support */
amount: decimal; amount: decimal;
/** send support to claim owner
* @default false */
tip?: boolean; tip?: boolean;
/** claim id of the supporters identity channel */
channel_id?: string; channel_id?: string;
/** name of the supporters identity channel */
channel_name?: string; channel_name?: string;
/** one or more account ids for accounts to look in for channel certificates, defaults to all accounts */
channel_account_id?: string; channel_account_id?: string;
/** account to use for holding the transaction */
account_id?: string; account_id?: string;
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
/** ids of accounts to fund this transaction */
funding_account_ids?: string[]; funding_account_ids?: string[];
} }
/** @see https://lbry.tech/api/sdk#support_list */
export interface SupportListArguments extends NoTotalsPaginatingArguments { export interface SupportListArguments extends NoTotalsPaginatingArguments {
/** claim name */
name?: string | string[]; name?: string | string[];
/** claim id */
claim_id?: string | string[]; claim_id?: string | string[];
/** only show received (tips) */
recieved?: boolean; recieved?: boolean;
/** only show sent (tips) */
sent?: boolean; sent?: boolean;
/** only show my staked supports */
staked?: boolean; staked?: boolean;
/** show abandoned supports */
is_spent?: boolean; is_spent?: boolean;
/** id of the account to query */
account_id?: string; account_id?: string;
/** restrict results to specific wallet */
wallet_id?: string; wallet_id?: string;
} }
/** @see https://lbry.tech/api/sdk#wallet_balance */
export interface WalletBalanceArguments { export interface WalletBalanceArguments {
/** balance for specific wallet */
wallet_id?: string; wallet_id?: string;
/** Only include transactions with this many confirmed blocks. */
confirmations?: number; confirmations?: number;
} }
/** @see https://lbry.tech/api/sdk#wallet_send */
export interface WalletSendArguments extends BlockingArguments { export interface WalletSendArguments extends BlockingArguments {
// undocumented // undocumented
amount: decimal; amount: decimal;
addresses: string | string[]; addresses: string | string[];
/** restrict operation to specific wallet */
wallet_id?: string; wallet_id?: string;
/** account where change will go */
change_account_id?: string; change_account_id?: string;
/** accounts to fund the transaction */
funding_account_ids?: string; funding_account_ids?: string;
} }
/** @see https://lbry.tech/api/sdk#claim_search */
export interface ClaimSearchArguments extends NoTotalsPaginatingArguments { export interface ClaimSearchArguments extends NoTotalsPaginatingArguments {
/** claim name (normalized) */
name?: string; name?: string;
/** full text search */
text?: string; text?: string;
/** full or partial claim id */
claim_id?: string; claim_id?: string;
/** list of full claim ids */
claim_ids?: string[]; claim_ids?: string[];
/** transaction id */
txid?: string; txid?: string;
/** position in the transaction */
nout?: string; nout?: string;
/** claims signed by this channel (argument is a URL which automatically gets resolved) */
channel?: string; channel?: string;
/** claims signed by any of these channels (arguments must be claim ids of the channels) */
channel_ids?: string[]; channel_ids?: string[];
/** exclude claims signed by any of these channels (arguments must be claim ids of the channels) */
not_channel_ids?: string[]; not_channel_ids?: string[];
/** claims with a channel signature (valid or invalid) */
has_channel_signature?: boolean; has_channel_signature?: boolean;
/** claims with a valid channel signature or no signature */
valid_channel_signature?: boolean; valid_channel_signature?: boolean;
/** claims with invalid channel signature or no signature */
invalid_channel_signature?: boolean; invalid_channel_signature?: boolean;
/** only return up to the specified number of claims per channel */
limit_claims_per_channel?: number; limit_claims_per_channel?: number;
/** winning claims of their respective name */
is_controlling?: boolean; is_controlling?: boolean;
/** only return channels having this public key id */
public_key_id?: string; public_key_id?: string;
/** last updated block height (supports equality constraints) */
height?: number | string; height?: number | string;
/** last updated timestamp (supports equality constraints) */
timestamp?: number | string; timestamp?: number | string;
/** created at block height (supports equality constraints) */
creation_height?: number | string; creation_height?: number | string;
/** created at timestamp (supports equality constraints) */
creation_timestamp?: number | string; creation_timestamp?: number | string;
/** height at which claim starts competing for name (supports equality constraints) */
activation_height?: number | string; activation_height?: number | string;
/** height at which claim will expire (supports equality constraints) */
expiration_height?: number | string; expiration_height?: number | string;
/** limit to claims self-described as having been released to the public on or after this UTC timestamp,
* when claim does not provide a release time the publish time is used instead (supports equality constraints) */
release_time?: number | string; release_time?: number | string;
/** limit by claim value (supports equality constraints) */
amount?: number | string; amount?: number | string;
/** limit by supports and tips received (supports equality constraints) */
support_amount?: number | string; support_amount?: number | string;
/** limit by total value (initial claim value plus all tips and supports received),
* this amount is blank until claim has reached activation height (supports equality constraints) */
effective_amount?: number | string; effective_amount?: number | string;
trending_group?: number | string; /** trending groups of the content (supports equality constraints) */
trending_group?: TrendingGroup | string;
/** trending amount taken from the global or local value depending on the trending group:
* 4 - global value, 3 - local value, 2 - global value, 1 - local value (supports equality constraints) */
trending_mixed?: number | string; trending_mixed?: number | string;
/** trending value calculated relative only to the individual contents past history (supports equality constraints) */
trending_local?: number | string; trending_local?: number | string;
/** trending value calculated relative to all trending content globally (supports equality constraints) */
trending_global?: number | string; trending_global?: number | string;
/** all reposts of the specified original claim id */
reposted_claim_id?: string; reposted_claim_id?: string;
/** claims reposted this many times (supports equality constraints) */
reposted?: number | string; reposted?: number | string;
/** the type of claims to filter */
claim_type?: 'channel' | 'stream' | 'repost' | 'collection'; claim_type?: 'channel' | 'stream' | 'repost' | 'collection';
/** the type of stream types to filter */
stream_types?: string[]; stream_types?: string[];
/** the media type to filter */
media_types?: string[]; media_types?: string[];
/** specify fee currency */
fee_currency?: string; fee_currency?: string;
fee_amount?: string; /** content download fee (supports equality constraints) */
fee_amount?: decimal;
/** duration of video or audio in seconds (supports equality constraints) */
duration?: number | string; duration?: number | string;
/** find claims containing any of the tags */
any_tags?: string[]; any_tags?: string[];
/** find claims containing every tag */
all_tags?: string[]; all_tags?: string[];
/** find claims not containing any of these tags */
not_tags?: string[]; not_tags?: string[];
/** find claims containing any of the languages */
any_languages?: string[]; any_languages?: string[];
/** find claims containing every language */
all_languages?: string[]; all_languages?: string[];
/** find claims not containing any of these languages */
not_languages?: string[]; not_languages?: string[];
/** find claims containing any of the locations */
any_locations?: string[]; any_locations?: string[];
/** find claims containing every location */
all_locations?: string[]; all_locations?: string[];
/** find claims not containing any of these locations */
not_locations?: string[]; not_locations?: string[];
order_by?: string[]; /** field to order by, default is descending order, to do an ascending order prepend ^ to the field name */
order_by?: SearchOrderBy[];
/** wallet to check for claim purchase receipts */
wallet_id?: string; wallet_id?: string;
/** lookup and include a receipt if this wallet has purchased the claim */
include_purchase_receipt?: boolean; include_purchase_receipt?: boolean;
/** lookup and include a boolean indicating if claim being resolved is yours */
include_is_my_output?: boolean; include_is_my_output?: boolean;
/** removes duplicated content from search by picking either the original claim or the oldest matching repost */
remove_duplicates?: boolean; remove_duplicates?: boolean;
/** find claims containing a source field */
has_source?: boolean; has_source?: boolean;
/** find claims not containing a source field */
has_no_source?: boolean; has_no_source?: boolean;
/** URL of the new SDK server (EXPERIMENTAL) */
new_sdk_server?: string; new_sdk_server?: string;
} }
/* #endregion */ /* #endregion */

View file

@ -268,7 +268,8 @@ export default class LBRYXModule<T extends DexareClient<CurateConfig>> extends D
const groups = query.match(SHORT_URL)!.groups!; const groups = query.match(SHORT_URL)!.groups!;
const options: LBRY.ClaimSearchArguments = { const options: LBRY.ClaimSearchArguments = {
channel: groups.channel, channel: groups.channel,
page_size: 1000 page_size: 1000,
no_totals: false
}; };
if (groups.video) options.text = groups.video; if (groups.video) options.text = groups.video;