review response

This commit is contained in:
jessop 2019-11-14 13:25:33 -05:00 committed by Lex Berezhny
parent 26e2865e35
commit 4d607ed276
2 changed files with 15 additions and 15 deletions

View file

@ -3272,7 +3272,7 @@ class Daemon(metaclass=JSONRPCServerType):
return self.get_est_cost_from_uri(uri) return self.get_est_cost_from_uri(uri)
COLLECTION_DOC = """ COLLECTION_DOC = """
Create, list and abandon collections. Create, update, list, resolve, and abandon collections.
""" """
@requires(WALLET_COMPONENT) @requires(WALLET_COMPONENT)
@ -3372,7 +3372,7 @@ class Daemon(metaclass=JSONRPCServerType):
) )
claim = Claim() claim = Claim()
claim.collection.update(claims=claims, **kwargs) # maybe specify claims=[] # here claim.collection.update(claims=claims, **kwargs)
tx = await Transaction.claim_create( tx = await Transaction.claim_create(
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
) )
@ -3383,10 +3383,7 @@ class Daemon(metaclass=JSONRPCServerType):
await tx.sign(funding_accounts) await tx.sign(funding_accounts)
if not preview: if not preview:
await self.broadcast_or_release(tx, blocking) await self.broadcast_or_release(tx, blocking)
await self.storage.save_claims([self._old_get_temp_claim_info( await self.analytics_manager.send_claim_action('publish')
tx, new_txo, claim_address, claim, name, dewies_to_lbc(amount)
)])
# await self.analytics_manager.send_new_channel()
else: else:
await account.ledger.release_tx(tx) await account.ledger.release_tx(tx)
@ -3394,7 +3391,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT) @requires(WALLET_COMPONENT)
async def jsonrpc_collection_update( async def jsonrpc_collection_update(
self, claim_id, bid=None, claim=None, allow_duplicate_name=False, self, claim_id, bid=None,
channel_id=None, channel_name=None, channel_account_id=None, clear_channel=False, channel_id=None, channel_name=None, channel_account_id=None, clear_channel=False,
account_id=None, wallet_id=None, claim_address=None, funding_account_ids=None, account_id=None, wallet_id=None, claim_address=None, funding_account_ids=None,
preview=False, blocking=False, replace=False, **kwargs): preview=False, blocking=False, replace=False, **kwargs):
@ -3403,7 +3400,7 @@ class Daemon(metaclass=JSONRPCServerType):
Usage: Usage:
collection_update (<claim_id> | --claim_id=<claim_id>) [--bid=<bid>] collection_update (<claim_id> | --claim_id=<claim_id>) [--bid=<bid>]
[--claims=<claims>...] [--clear_claim_ids] [--claims=<claims>...] [--clear_claims]
[--title=<title>] [--description=<description>] [--title=<title>] [--description=<description>]
[--tags=<tags>...] [--clear_tags] [--tags=<tags>...] [--clear_tags]
[--languages=<languages>...] [--clear_languages] [--languages=<languages>...] [--clear_languages]
@ -3464,7 +3461,6 @@ class Daemon(metaclass=JSONRPCServerType):
--clear_locations : (bool) clear existing locations (prior to adding new ones) --clear_locations : (bool) clear existing locations (prior to adding new ones)
--thumbnail_url=<thumbnail_url>: (str) thumbnail url --thumbnail_url=<thumbnail_url>: (str) thumbnail url
#--cover_url=<cover_url> : (str) url of cover image
--account_id=<account_id> : (str) account in which to look for collection (default: all) --account_id=<account_id> : (str) account in which to look for collection (default: all)
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet --wallet_id=<wallet_id> : (str) restrict operation to specific wallet
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction --funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
@ -3496,11 +3492,10 @@ class Daemon(metaclass=JSONRPCServerType):
raise Exception( raise Exception(
f"Can't find the collection '{claim_id}' in account(s) {account_ids}." f"Can't find the collection '{claim_id}' in account(s) {account_ids}."
) )
# Here we might have a problem of replacing a stream with a collection
old_txo = existing_collections[0] old_txo = existing_collections[0]
if not old_txo.claim.is_collection: # as we're only checking @ or not, this is not definitive if not old_txo.claim.is_collection:
raise Exception( raise Exception(
f"A claim with id '{claim_id}' was found but it is not a stream or collection." f"A claim with id '{claim_id}' was found but it is not a collection."
) )
if bid is not None: if bid is not None:
@ -3525,7 +3520,6 @@ class Daemon(metaclass=JSONRPCServerType):
claim.collection.message.source.CopyFrom( claim.collection.message.source.CopyFrom(
old_txo.claim.collection.message.source old_txo.claim.collection.message.source
) )
claim.collection.update(**kwargs) claim.collection.update(**kwargs)
else: else:
claim = Claim.from_bytes(old_txo.claim.to_bytes()) claim = Claim.from_bytes(old_txo.claim.to_bytes())
@ -4522,7 +4516,6 @@ class Daemon(metaclass=JSONRPCServerType):
raise Exception("Invalid stream name.") raise Exception("Invalid stream name.")
@staticmethod @staticmethod
# assume stream and collection have the same naming rules
def valid_collection_name_or_error(name: str): def valid_collection_name_or_error(name: str):
try: try:
if not name: if not name:

View file

@ -1297,6 +1297,10 @@ class CollectionCommands(CommandTestCase):
claim_id2 = self.get_claim_id(tx) claim_id2 = self.get_claim_id(tx)
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 2) self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 2)
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)
await self.collection_abandon(claim_id) await self.collection_abandon(claim_id)
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1) self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1)
@ -1318,4 +1322,7 @@ class CollectionCommands(CommandTestCase):
claims = await self.out(self.daemon.jsonrpc_collection_resolve(claim_id2)) claims = await self.out(self.daemon.jsonrpc_collection_resolve(claim_id2))
self.assertEqual(claims['items'][0]['name'], 'stream-one') self.assertEqual(claims['items'][0]['name'], 'stream-one')
self.assertEqual(claims['items'][1]['name'], 'stream-two') self.assertEqual(claims['items'][1]['name'], 'stream-two')
self.assertEqual(claims['items'][2]['name'], 'stream-one') self.assertEqual(claims['items'][2]['name'], 'stream-one')