forked from LBRYCommunity/lbry-sdk
simplifying
This commit is contained in:
parent
67a0d3e926
commit
97e6e1684e
2 changed files with 11 additions and 21 deletions
|
@ -3696,7 +3696,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
COLLECTION_DOC = """
|
||||
Create, update, list, resolve, and abandon collections.
|
||||
"""
|
||||
#| --claims = < claims >
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
async def jsonrpc_collection_create(
|
||||
self, name, bid, claims, allow_duplicate_name=False,
|
||||
|
@ -3993,8 +3993,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
return await self.jsonrpc_stream_abandon(*args, **kwargs)
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
def jsonrpc_collection_list(self, resolve_claims=0, resolve=False,
|
||||
account_id=None, wallet_id=None, page=None, page_size=None):
|
||||
def jsonrpc_collection_list(
|
||||
self, resolve_claims=0, resolve=False, account_id=None,
|
||||
wallet_id=None, page=None, page_size=None):
|
||||
"""
|
||||
List my collection claims.
|
||||
|
||||
|
@ -4015,23 +4016,12 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
|
||||
if account_id:
|
||||
account = wallet.get_account_or_error(account_id)
|
||||
collections = partial(
|
||||
self.ledger.get_collections,
|
||||
wallet=wallet,
|
||||
accounts=[account],
|
||||
resolve=resolve)
|
||||
collections = account.get_collections
|
||||
collection_count = account.get_collection_count
|
||||
else:
|
||||
collections = partial(
|
||||
self.ledger.get_collections,
|
||||
wallet=wallet,
|
||||
accounts=wallet.accounts,
|
||||
resolve=resolve)
|
||||
collection_count = partial(
|
||||
self.ledger.get_collection_count,
|
||||
wallet=wallet,
|
||||
accounts=wallet.accounts)
|
||||
return paginate_rows(collections, collection_count, page, page_size, resolve_claims=resolve_claims)
|
||||
collections = partial(self.ledger.get_collections, wallet=wallet, accounts=wallet.accounts)
|
||||
collection_count = partial(self.ledger.get_collection_count, wallet=wallet, accounts=wallet.accounts)
|
||||
return paginate_rows(collections, collection_count, page, page_size, resolve=resolve, resolve_claims=resolve_claims)
|
||||
|
||||
async def jsonrpc_collection_resolve(
|
||||
self, claim_id=None, url=None, wallet_id=None, page=1, page_size=DEFAULT_PAGE_SIZE):
|
||||
|
|
|
@ -2029,10 +2029,10 @@ class CollectionCommands(CommandTestCase):
|
|||
await self.collection_update(claim_id, clear_claims=True, claims=claim_ids[:2])
|
||||
collections = await self.out(self.daemon.jsonrpc_collection_list())
|
||||
self.assertEquals(len(collections['items']), 2)
|
||||
self.assertNotIn('canonical_url', collections['items'][0])
|
||||
|
||||
# resolve flag resolves collection claim
|
||||
resolved_collections_tx = await self.out(self.daemon.jsonrpc_collection_list(resolve=True))
|
||||
self.assertIn('canonical_url', resolved_collections_tx[0])
|
||||
resolved_collections = await self.out(self.daemon.jsonrpc_collection_list(resolve=True))
|
||||
self.assertIn('canonical_url', resolved_collections['items'][0])
|
||||
|
||||
await self.collection_abandon(claim_id)
|
||||
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1)
|
||||
|
|
Loading…
Reference in a new issue