mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
[LABS-294] Add kw_only to all wallet RPC types (#20324)
Add `kw_only` to all wallet RPC types
This commit is contained in:
@@ -124,12 +124,14 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
w_type = WalletType.POOLING_WALLET
|
||||
else:
|
||||
raise ValueError(f"Invalid fingerprint: {self.fingerprint}")
|
||||
return GetWalletsResponse([WalletInfoResponse(id=uint32(1), name="", type=uint8(w_type.value), data="")])
|
||||
return GetWalletsResponse(
|
||||
wallets=[WalletInfoResponse(id=uint32(1), name="", type=uint8(w_type.value), data="")]
|
||||
)
|
||||
|
||||
async def get_transaction(self, request: GetTransaction) -> GetTransactionResponse:
|
||||
self.add_to_log("get_transaction", (request,))
|
||||
return GetTransactionResponse(
|
||||
TransactionRecord(
|
||||
transaction=TransactionRecord(
|
||||
confirmed_at_height=uint32(1),
|
||||
created_at_time=uint64(1234),
|
||||
to_puzzle_hash=bytes32([1] * 32),
|
||||
@@ -149,12 +151,12 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
memos={bytes32([3] * 32): [bytes([4] * 32)]},
|
||||
valid_times=ConditionValidTimes(),
|
||||
),
|
||||
bytes32([2] * 32),
|
||||
transaction_id=bytes32([2] * 32),
|
||||
)
|
||||
|
||||
async def get_cat_name(self, request: CATGetName) -> CATGetNameResponse:
|
||||
self.add_to_log("get_cat_name", (request.wallet_id,))
|
||||
return CATGetNameResponse(request.wallet_id, "test" + str(request.wallet_id))
|
||||
return CATGetNameResponse(wallet_id=request.wallet_id, name="test" + str(request.wallet_id))
|
||||
|
||||
async def sign_message_by_address(self, request: SignMessageByAddress) -> SignMessageByAddressResponse:
|
||||
self.add_to_log("sign_message_by_address", (request.address, request.message))
|
||||
@@ -170,7 +172,7 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
)
|
||||
)
|
||||
signing_mode = SigningMode.CHIP_0002.value
|
||||
return SignMessageByAddressResponse(pubkey, signature, signing_mode)
|
||||
return SignMessageByAddressResponse(pubkey=pubkey, signature=signature, signing_mode=signing_mode)
|
||||
|
||||
async def sign_message_by_id(self, request: SignMessageByID) -> SignMessageByIDResponse:
|
||||
self.add_to_log("sign_message_by_id", (request.id, request.message))
|
||||
@@ -186,7 +188,9 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
)
|
||||
)
|
||||
signing_mode = SigningMode.CHIP_0002.value
|
||||
return SignMessageByIDResponse(pubkey, signature, bytes32.zeros, signing_mode)
|
||||
return SignMessageByIDResponse(
|
||||
pubkey=pubkey, signature=signature, latest_coin_id=bytes32.zeros, signing_mode=signing_mode
|
||||
)
|
||||
|
||||
async def cat_asset_id_to_name(self, request: CATAssetIDToName) -> CATAssetIDToNameResponse:
|
||||
"""
|
||||
@@ -195,7 +199,7 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
self.add_to_log("cat_asset_id_to_name", (request.asset_id,))
|
||||
for i in range(256):
|
||||
if request.asset_id == get_bytes32(i):
|
||||
return CATAssetIDToNameResponse(uint32(i + 1), "test" + str(i))
|
||||
return CATAssetIDToNameResponse(wallet_id=uint32(i + 1), name="test" + str(i))
|
||||
return CATAssetIDToNameResponse(wallet_id=None, name=None)
|
||||
|
||||
async def get_nft_info(self, request: NFTGetInfo) -> NFTGetInfoResponse:
|
||||
@@ -223,7 +227,7 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
supports_did=True,
|
||||
p2_address=bytes32([8] * 32),
|
||||
)
|
||||
return NFTGetInfoResponse(nft_info)
|
||||
return NFTGetInfoResponse(nft_info=nft_info)
|
||||
|
||||
async def nft_calculate_royalties(
|
||||
self,
|
||||
@@ -246,8 +250,8 @@ class TestWalletRpcClient(TestRpcClient):
|
||||
) -> CreateNewWalletResponse:
|
||||
self.add_to_log("create_new_wallet", (request, tx_config, extra_conditions, timelock_info))
|
||||
return CreateNewWalletResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
type=(
|
||||
WalletType.NFT if request.wallet_type == CreateNewWalletType.NFT_WALLET else WalletType.DECENTRALIZED_ID
|
||||
).name,
|
||||
|
||||
@@ -131,7 +131,7 @@ def test_did_set_name(capsys: object, get_test_cli_clients: tuple[TestRpcClients
|
||||
class DidSetNameRpcClient(TestWalletRpcClient):
|
||||
async def did_set_wallet_name(self, request: DIDSetWalletName) -> DIDSetWalletNameResponse:
|
||||
self.add_to_log("did_set_wallet_name", (request.wallet_id, request.name))
|
||||
return DIDSetWalletNameResponse(request.wallet_id)
|
||||
return DIDSetWalletNameResponse(wallet_id=request.wallet_id)
|
||||
|
||||
inst_rpc_client = DidSetNameRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -239,7 +239,10 @@ def test_did_update_metadata(capsys: object, get_test_cli_clients: tuple[TestRpc
|
||||
(request.wallet_id, request.metadata, tx_config, request.push, extra_conditions, timelock_info),
|
||||
)
|
||||
return DIDUpdateMetadataResponse(
|
||||
[STD_UTX], [STD_TX], WalletSpendBundle([], G2Element()), uint32(request.wallet_id)
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
wallet_id=uint32(request.wallet_id),
|
||||
)
|
||||
|
||||
inst_rpc_client = DidUpdateMetadataRpcClient()
|
||||
@@ -282,7 +285,7 @@ def test_did_find_lost(capsys: object, get_test_cli_clients: tuple[TestRpcClient
|
||||
"find_lost_did",
|
||||
(request.coin_id, request.recovery_list_hash, request.metadata, request.num_verification),
|
||||
)
|
||||
return DIDFindLostDIDResponse(get_bytes32(2))
|
||||
return DIDFindLostDIDResponse(latest_coin_id=get_bytes32(2))
|
||||
|
||||
inst_rpc_client = DidFindLostRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -322,7 +325,9 @@ def test_did_message_spend(capsys: object, get_test_cli_clients: tuple[TestRpcCl
|
||||
self.add_to_log(
|
||||
"did_message_spend", (request.wallet_id, tx_config, extra_conditions, request.push, timelock_info)
|
||||
)
|
||||
return DIDMessageSpendResponse([STD_UTX], [STD_TX], WalletSpendBundle([], G2Element()))
|
||||
return DIDMessageSpendResponse(
|
||||
unsigned_transactions=[STD_UTX], transactions=[STD_TX], spend_bundle=WalletSpendBundle([], G2Element())
|
||||
)
|
||||
|
||||
inst_rpc_client = DidMessageSpendRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -391,10 +396,10 @@ def test_did_transfer(capsys: object, get_test_cli_clients: tuple[TestRpcClients
|
||||
),
|
||||
)
|
||||
return DIDTransferDIDResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
STD_TX,
|
||||
STD_TX.name,
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
transaction=STD_TX,
|
||||
transaction_id=STD_TX.name,
|
||||
)
|
||||
|
||||
inst_rpc_client = DidTransferRpcClient()
|
||||
|
||||
@@ -90,7 +90,9 @@ def test_nft_mint(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
|
||||
class NFTCreateRpcClient(TestWalletRpcClient):
|
||||
async def get_nft_wallet_did(self, request: NFTGetWalletDID) -> NFTGetWalletDIDResponse:
|
||||
self.add_to_log("get_nft_wallet_did", (request.wallet_id,))
|
||||
return NFTGetWalletDIDResponse("did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c")
|
||||
return NFTGetWalletDIDResponse(
|
||||
did_id="did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c"
|
||||
)
|
||||
|
||||
async def mint_nft(
|
||||
self,
|
||||
@@ -123,11 +125,11 @@ def test_nft_mint(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
|
||||
),
|
||||
)
|
||||
return NFTMintNFTResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
uint32(request.wallet_id),
|
||||
WalletSpendBundle([], G2Element()),
|
||||
bytes32.zeros.hex(),
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
wallet_id=uint32(request.wallet_id),
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
nft_id=bytes32.zeros.hex(),
|
||||
)
|
||||
|
||||
inst_rpc_client = NFTCreateRpcClient()
|
||||
@@ -215,7 +217,12 @@ def test_nft_add_uri(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
extra_conditions,
|
||||
),
|
||||
)
|
||||
return NFTAddURIResponse([STD_UTX], [STD_TX], request.wallet_id, WalletSpendBundle([], G2Element()))
|
||||
return NFTAddURIResponse(
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
inst_rpc_client = NFTAddUriRpcClient()
|
||||
nft_coin_id = get_bytes32(2).hex()
|
||||
@@ -285,10 +292,10 @@ def test_nft_transfer(capsys: object, get_test_cli_clients: tuple[TestRpcClients
|
||||
),
|
||||
)
|
||||
return NFTTransferNFTResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
request.wallet_id,
|
||||
WalletSpendBundle([], G2Element()),
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
inst_rpc_client = NFTTransferRpcClient()
|
||||
@@ -367,7 +374,7 @@ def test_nft_list(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
|
||||
p2_address=get_bytes32(8),
|
||||
)
|
||||
)
|
||||
return NFTGetNFTsResponse(request.wallet_id, nft_list)
|
||||
return NFTGetNFTsResponse(wallet_id=request.wallet_id, nft_list=nft_list)
|
||||
|
||||
inst_rpc_client = NFTListRpcClient()
|
||||
launcher_ids = [bytes32([i] * 32).hex() for i in range(50, 60)]
|
||||
@@ -422,10 +429,10 @@ def test_nft_set_did(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
),
|
||||
)
|
||||
return NFTSetNFTDIDResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
request.wallet_id,
|
||||
WalletSpendBundle([], G2Element()),
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
inst_rpc_client = NFTSetDidRpcClient()
|
||||
|
||||
@@ -41,7 +41,7 @@ def test_notifications_send(capsys: object, get_test_cli_clients: tuple[TestRpcC
|
||||
(request.target, request.message, request.amount, request.fee, request.push, timelock_info),
|
||||
)
|
||||
|
||||
return SendNotificationResponse([STD_UTX], [STD_TX], tx=STD_TX)
|
||||
return SendNotificationResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX], tx=STD_TX)
|
||||
|
||||
inst_rpc_client = NotificationsSendRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -82,7 +82,7 @@ def test_notifications_get(capsys: object, get_test_cli_clients: tuple[TestRpcCl
|
||||
async def get_notifications(self, request: GetNotifications) -> GetNotificationsResponse:
|
||||
self.add_to_log("get_notifications", (request,))
|
||||
return GetNotificationsResponse(
|
||||
[Notification(get_bytes32(1), bytes("hello", "utf8"), uint64(1000000000), uint32(50))]
|
||||
notifications=[Notification(get_bytes32(1), bytes("hello", "utf8"), uint64(1000000000), uint32(50))]
|
||||
)
|
||||
|
||||
inst_rpc_client = NotificationsGetRpcClient()
|
||||
@@ -104,7 +104,9 @@ def test_notifications_get(capsys: object, get_test_cli_clients: tuple[TestRpcCl
|
||||
"amount: 1000000000",
|
||||
]
|
||||
run_cli_command_and_assert(capsys, root_dir, command_args, assert_list)
|
||||
expected_calls: logType = {"get_notifications": [(GetNotifications([get_bytes32(1)], uint32(10), uint32(10)),)]}
|
||||
expected_calls: logType = {
|
||||
"get_notifications": [(GetNotifications(ids=[get_bytes32(1)], start=uint32(10), end=uint32(10)),)]
|
||||
}
|
||||
test_rpc_clients.wallet_rpc_client.check_log(expected_calls)
|
||||
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ def test_vcs_mint(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
|
||||
)
|
||||
|
||||
return VCMintResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
VCRecord(
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
vc_record=VCRecord(
|
||||
VerifiedCredential(
|
||||
STD_TX.removals[0],
|
||||
LineageProof(None, None, None),
|
||||
@@ -110,7 +110,7 @@ def test_vcs_get(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pat
|
||||
class VcsGetRpcClient(TestWalletRpcClient):
|
||||
async def vc_get_list(self, request: VCGetList) -> VCGetListResponse:
|
||||
self.add_to_log("vc_get_list", (request.start, request.end))
|
||||
proofs = [VCProofWithHash(get_bytes32(1), VCProofsRPC([("proof here", "")]))]
|
||||
proofs = [VCProofWithHash(hash=get_bytes32(1), proof=VCProofsRPC(key_value_pairs=[("proof here", "")]))]
|
||||
records = [
|
||||
VCRecordWithCoinID(
|
||||
VerifiedCredential(
|
||||
@@ -123,10 +123,10 @@ def test_vcs_get(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pat
|
||||
None,
|
||||
),
|
||||
uint32(0),
|
||||
bytes32.zeros,
|
||||
coin_id=bytes32.zeros,
|
||||
)
|
||||
]
|
||||
return VCGetListResponse(records, proofs)
|
||||
return VCGetListResponse(vc_records=records, proofs=proofs)
|
||||
|
||||
inst_rpc_client = VcsGetRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -166,7 +166,7 @@ def test_vcs_update_proofs(capsys: object, get_test_cli_clients: tuple[TestRpcCl
|
||||
timelock_info,
|
||||
),
|
||||
)
|
||||
return VCSpendResponse([STD_UTX], [STD_TX])
|
||||
return VCSpendResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])
|
||||
|
||||
inst_rpc_client = VcsUpdateProofsRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -241,7 +241,7 @@ def test_vcs_get_proofs_for_root(capsys: object, get_test_cli_clients: tuple[Tes
|
||||
class VcsGetProofsForRootRpcClient(TestWalletRpcClient):
|
||||
async def vc_get_proofs_for_root(self, request: VCGetProofsForRoot) -> VCGetProofsForRootResponse:
|
||||
self.add_to_log("vc_get_proofs_for_root", (request.root,))
|
||||
return VCGetProofsForRootResponse([("test_proof", "1"), ("test_proof2", "1")])
|
||||
return VCGetProofsForRootResponse(key_value_pairs=[("test_proof", "1"), ("test_proof2", "1")])
|
||||
|
||||
inst_rpc_client = VcsGetProofsForRootRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -264,7 +264,7 @@ def test_vcs_revoke(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
self.add_to_log("vc_get", (request.vc_id,))
|
||||
|
||||
return VCGetResponse(
|
||||
VCRecord(
|
||||
vc_record=VCRecord(
|
||||
VerifiedCredential(
|
||||
Coin(get_bytes32(1), get_bytes32(2), uint64(12345678)),
|
||||
LineageProof(),
|
||||
@@ -285,7 +285,7 @@ def test_vcs_revoke(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
timelock_info: ConditionValidTimes = ConditionValidTimes(),
|
||||
) -> VCRevokeResponse:
|
||||
self.add_to_log("vc_revoke", (request.vc_parent_id, tx_config, request.fee, request.push, timelock_info))
|
||||
return VCRevokeResponse([STD_UTX], [STD_TX])
|
||||
return VCRevokeResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])
|
||||
|
||||
inst_rpc_client = VcsRevokeRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -352,7 +352,7 @@ def test_vcs_approve_r_cats(capsys: object, get_test_cli_clients: tuple[TestRpcC
|
||||
timelock_info,
|
||||
),
|
||||
)
|
||||
return CRCATApprovePendingResponse([STD_UTX], [STD_TX])
|
||||
return CRCATApprovePendingResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])
|
||||
|
||||
inst_rpc_client = VcsApproveRCATSRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
|
||||
@@ -152,9 +152,9 @@ def test_get_transaction(capsys: object, get_test_cli_clients: tuple[TestRpcClie
|
||||
"get_wallets": [(GetWallets(type=None, include_data=True),)] * 3,
|
||||
"get_cat_name": [(1,)],
|
||||
"get_transaction": [
|
||||
(GetTransaction(bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
(GetTransaction(bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
(GetTransaction(bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
(GetTransaction(transaction_id=bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
(GetTransaction(transaction_id=bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
(GetTransaction(transaction_id=bytes32.from_hexstr(bytes32_hexstr)),),
|
||||
],
|
||||
}
|
||||
test_rpc_clients.wallet_rpc_client.check_log(expected_calls)
|
||||
@@ -193,7 +193,7 @@ def test_get_transactions(capsys: object, get_test_cli_clients: tuple[TestRpcCli
|
||||
)
|
||||
l_tx_rec.append(tx_rec)
|
||||
|
||||
return GetTransactionsResponse(l_tx_rec, request.wallet_id)
|
||||
return GetTransactionsResponse(transactions=l_tx_rec, wallet_id=request.wallet_id)
|
||||
|
||||
async def get_coin_records(self, request: GetCoinRecords) -> dict[str, Any]:
|
||||
self.add_to_log("get_coin_records", (request,))
|
||||
@@ -242,8 +242,30 @@ def test_get_transactions(capsys: object, get_test_cli_clients: tuple[TestRpcCli
|
||||
expected_calls: logType = {
|
||||
"get_wallets": [(GetWallets(type=None, include_data=True),)] * 2,
|
||||
"get_transactions": [
|
||||
(GetTransactions(uint32(1), uint32(2), uint32(4), SortKey.RELEVANCE.name, True, None, None, None),),
|
||||
(GetTransactions(uint32(1), uint32(2), uint32(4), SortKey.RELEVANCE.name, True, None, None, None),),
|
||||
(
|
||||
GetTransactions(
|
||||
wallet_id=uint32(1),
|
||||
start=uint32(2),
|
||||
end=uint32(4),
|
||||
sort_key=SortKey.RELEVANCE.name,
|
||||
reverse=True,
|
||||
to_address=None,
|
||||
type_filter=None,
|
||||
confirmed=None,
|
||||
),
|
||||
),
|
||||
(
|
||||
GetTransactions(
|
||||
wallet_id=uint32(1),
|
||||
start=uint32(2),
|
||||
end=uint32(4),
|
||||
sort_key=SortKey.RELEVANCE.name,
|
||||
reverse=True,
|
||||
to_address=None,
|
||||
type_filter=None,
|
||||
confirmed=None,
|
||||
),
|
||||
),
|
||||
],
|
||||
"get_coin_records": [
|
||||
(GetCoinRecords(coin_id_filter=HashFilter.include([expected_coin_id])),),
|
||||
@@ -280,12 +302,12 @@ def test_show(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
),
|
||||
]
|
||||
if request.type is not None and WalletType(request.type) is WalletType.CAT:
|
||||
return GetWalletsResponse([wallet_list[1]])
|
||||
return GetWalletsResponse(wallet_list)
|
||||
return GetWalletsResponse(wallets=[wallet_list[1]])
|
||||
return GetWalletsResponse(wallets=wallet_list)
|
||||
|
||||
async def get_height_info(self) -> GetHeightInfoResponse:
|
||||
self.add_to_log("get_height_info", ())
|
||||
return GetHeightInfoResponse(uint32(10))
|
||||
return GetHeightInfoResponse(height=uint32(10))
|
||||
|
||||
async def get_wallet_balance(self, request: GetWalletBalance) -> GetWalletBalanceResponse:
|
||||
self.add_to_log("get_wallet_balance", (request,))
|
||||
@@ -296,7 +318,7 @@ def test_show(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
else:
|
||||
amount = uint128(1)
|
||||
return GetWalletBalanceResponse(
|
||||
BalanceResponse(
|
||||
wallet_balance=BalanceResponse(
|
||||
wallet_id=request.wallet_id,
|
||||
wallet_type=uint8(0), # Doesn't matter
|
||||
confirmed_wallet_balance=amount,
|
||||
@@ -307,7 +329,9 @@ def test_show(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
|
||||
async def get_nft_wallet_did(self, request: NFTGetWalletDID) -> NFTGetWalletDIDResponse:
|
||||
self.add_to_log("get_nft_wallet_did", (request.wallet_id,))
|
||||
return NFTGetWalletDIDResponse("did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c")
|
||||
return NFTGetWalletDIDResponse(
|
||||
did_id="did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c"
|
||||
)
|
||||
|
||||
async def get_connections(
|
||||
self, node_type: NodeType | None = None
|
||||
@@ -415,7 +439,9 @@ def test_send(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
memos={get_bytes32(3): [bytes([4] * 32)]},
|
||||
valid_times=ConditionValidTimes(),
|
||||
)
|
||||
return SendTransactionResponse([STD_UTX], [STD_TX], tx_rec, name)
|
||||
return SendTransactionResponse(
|
||||
unsigned_transactions=[STD_UTX], transactions=[STD_TX], transaction=tx_rec, transaction_id=name
|
||||
)
|
||||
|
||||
async def cat_spend(
|
||||
self,
|
||||
@@ -440,7 +466,9 @@ def test_send(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
timelock_info,
|
||||
),
|
||||
)
|
||||
return CATSpendResponse([STD_UTX], [STD_TX], STD_TX, STD_TX.name)
|
||||
return CATSpendResponse(
|
||||
unsigned_transactions=[STD_UTX], transactions=[STD_TX], transaction=STD_TX, transaction_id=STD_TX.name
|
||||
)
|
||||
|
||||
inst_rpc_client = SendWalletRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -529,7 +557,10 @@ def test_send(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
|
||||
test_condition_valid_times,
|
||||
)
|
||||
],
|
||||
"get_transaction": [(GetTransaction(get_bytes32(2)),), (GetTransaction(get_bytes32(2)),)],
|
||||
"get_transaction": [
|
||||
(GetTransaction(transaction_id=get_bytes32(2)),),
|
||||
(GetTransaction(transaction_id=get_bytes32(2)),),
|
||||
],
|
||||
}
|
||||
test_rpc_clients.wallet_rpc_client.check_log(expected_calls)
|
||||
|
||||
@@ -542,8 +573,12 @@ def test_get_address(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
async def get_next_address(self, request: GetNextAddress) -> GetNextAddressResponse:
|
||||
self.add_to_log("get_next_address", (request.wallet_id, request.new_address))
|
||||
if request.new_address:
|
||||
return GetNextAddressResponse(request.wallet_id, encode_puzzle_hash(get_bytes32(3), "xch"))
|
||||
return GetNextAddressResponse(request.wallet_id, encode_puzzle_hash(get_bytes32(4), "xch"))
|
||||
return GetNextAddressResponse(
|
||||
wallet_id=request.wallet_id, address=encode_puzzle_hash(get_bytes32(3), "xch")
|
||||
)
|
||||
return GetNextAddressResponse(
|
||||
wallet_id=request.wallet_id, address=encode_puzzle_hash(get_bytes32(4), "xch")
|
||||
)
|
||||
|
||||
inst_rpc_client = GetAddressWalletRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -644,7 +679,7 @@ def test_get_derivation_index(capsys: object, get_test_cli_clients: tuple[TestRp
|
||||
class GetDerivationIndexRpcClient(TestWalletRpcClient):
|
||||
async def get_current_derivation_index(self) -> GetCurrentDerivationIndexResponse:
|
||||
self.add_to_log("get_current_derivation_index", ())
|
||||
return GetCurrentDerivationIndexResponse(uint32(520))
|
||||
return GetCurrentDerivationIndexResponse(index=uint32(520))
|
||||
|
||||
inst_rpc_client = GetDerivationIndexRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -692,7 +727,7 @@ def test_update_derivation_index(capsys: object, get_test_cli_clients: tuple[Tes
|
||||
class UpdateDerivationIndexRpcClient(TestWalletRpcClient):
|
||||
async def extend_derivation_index(self, request: ExtendDerivationIndex) -> ExtendDerivationIndexResponse:
|
||||
self.add_to_log("extend_derivation_index", (request.index,))
|
||||
return ExtendDerivationIndexResponse(request.index)
|
||||
return ExtendDerivationIndexResponse(index=request.index)
|
||||
|
||||
inst_rpc_client = UpdateDerivationIndexRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -839,7 +874,9 @@ def test_make_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
valid_times=ConditionValidTimes(),
|
||||
)
|
||||
|
||||
return CreateOfferForIDsResponse([STD_UTX], [STD_TX], created_offer, trade_offer)
|
||||
return CreateOfferForIDsResponse(
|
||||
unsigned_transactions=[STD_UTX], transactions=[STD_TX], offer=created_offer, trade_record=trade_offer
|
||||
)
|
||||
|
||||
inst_rpc_client = MakeOfferRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -886,25 +923,25 @@ def test_make_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
"nft_calculate_royalties": [
|
||||
(
|
||||
NFTCalculateRoyalties(
|
||||
[
|
||||
royalty_assets=[
|
||||
RoyaltyAsset(
|
||||
"nft1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyql4ft",
|
||||
"xch1qvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvps82kgr2",
|
||||
uint16(1000),
|
||||
asset="nft1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyql4ft",
|
||||
royalty_address="xch1qvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvps82kgr2",
|
||||
royalty_percentage=uint16(1000),
|
||||
)
|
||||
],
|
||||
[
|
||||
fungible_assets=[
|
||||
FungibleAsset(
|
||||
"XCH",
|
||||
uint64(10000000000000),
|
||||
asset="XCH",
|
||||
amount=uint64(10000000000000),
|
||||
),
|
||||
FungibleAsset(
|
||||
"test3",
|
||||
uint64(100000),
|
||||
asset="test3",
|
||||
amount=uint64(100000),
|
||||
),
|
||||
FungibleAsset(
|
||||
"test4",
|
||||
uint64(100000),
|
||||
asset="test4",
|
||||
amount=uint64(100000),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -1001,7 +1038,7 @@ def test_get_offers(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
),
|
||||
)
|
||||
records.append(trade_offer)
|
||||
return GetAllOffersResponse([], records)
|
||||
return GetAllOffersResponse(offers=[], trade_records=records)
|
||||
|
||||
inst_rpc_client = GetOffersRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
@@ -1072,10 +1109,10 @@ def test_take_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
(request.parsed_offer, tx_config, request.solver, request.fee, request.push, timelock_info),
|
||||
)
|
||||
return TakeOfferResponse(
|
||||
[STD_UTX],
|
||||
[STD_TX],
|
||||
request.parsed_offer,
|
||||
TradeRecord(
|
||||
unsigned_transactions=[STD_UTX],
|
||||
transactions=[STD_TX],
|
||||
offer=request.parsed_offer,
|
||||
trade_record=TradeRecord(
|
||||
confirmed_at_index=uint32(0),
|
||||
accepted_at_time=uint64(123456789),
|
||||
created_at_time=uint64(12345678),
|
||||
@@ -1094,9 +1131,9 @@ def test_take_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
|
||||
async def cat_asset_id_to_name(self, request: CATAssetIDToName) -> CATAssetIDToNameResponse:
|
||||
self.add_to_log("cat_asset_id_to_name", (request.asset_id,))
|
||||
if request.asset_id == cat_offered_id:
|
||||
return CATAssetIDToNameResponse(uint32(2), "offered cat")
|
||||
return CATAssetIDToNameResponse(wallet_id=uint32(2), name="offered cat")
|
||||
elif request.asset_id == cat_requested_id:
|
||||
return CATAssetIDToNameResponse(uint32(3), "requested cat")
|
||||
return CATAssetIDToNameResponse(wallet_id=uint32(3), name="requested cat")
|
||||
else:
|
||||
return CATAssetIDToNameResponse(wallet_id=None, name=None)
|
||||
|
||||
@@ -1173,8 +1210,8 @@ def test_cancel_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients
|
||||
self.add_to_log("get_offer", (request.trade_id, request.file_contents))
|
||||
offer = Offer.from_bech32(test_offer_file_bech32)
|
||||
return GetOfferResponse(
|
||||
test_offer_file_bech32,
|
||||
TradeRecord(
|
||||
offer=test_offer_file_bech32,
|
||||
trade_record=TradeRecord(
|
||||
confirmed_at_index=uint32(0),
|
||||
accepted_at_time=uint64(0),
|
||||
created_at_time=uint64(12345678),
|
||||
@@ -1200,7 +1237,7 @@ def test_cancel_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients
|
||||
self.add_to_log(
|
||||
"cancel_offer", (request.trade_id, tx_config, request.fee, request.secure, request.push, timelock_info)
|
||||
)
|
||||
return CancelOfferResponse([STD_UTX], [STD_TX])
|
||||
return CancelOfferResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])
|
||||
|
||||
inst_rpc_client = CancelOfferRpcClient()
|
||||
test_rpc_clients.wallet_rpc_client = inst_rpc_client
|
||||
|
||||
@@ -21,7 +21,8 @@ TEST_ASSET_ID_NAME_MAPPING: dict[bytes32, tuple[uint32, str]] = {
|
||||
|
||||
|
||||
async def cat_name_resolver(request: CATAssetIDToName) -> CATAssetIDToNameResponse:
|
||||
return CATAssetIDToNameResponse(*TEST_ASSET_ID_NAME_MAPPING.get(request.asset_id, (None, None)))
|
||||
wallet_id, name = TEST_ASSET_ID_NAME_MAPPING.get(request.asset_id, (None, None))
|
||||
return CATAssetIDToNameResponse(wallet_id=wallet_id, name=name)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -219,7 +219,9 @@ async def check_coin_state(wallet_node: WalletNode, coin_id: bytes32) -> bool:
|
||||
|
||||
|
||||
async def check_singleton_confirmed(dl: DataLayer, store_id: bytes32) -> bool:
|
||||
return (await dl.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton is not None
|
||||
return (
|
||||
await dl.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton is not None
|
||||
|
||||
|
||||
async def process_block_and_check_offer_validity(offer: TradingOffer, offer_setup: OfferSetup) -> bool:
|
||||
|
||||
@@ -171,7 +171,7 @@ class WalletEnvironment:
|
||||
),
|
||||
}
|
||||
balance_response: dict[str, int] = (
|
||||
await self.rpc_client.get_wallet_balance(GetWalletBalance(wallet_id))
|
||||
await self.rpc_client.get_wallet_balance(GetWalletBalance(wallet_id=wallet_id))
|
||||
).wallet_balance.to_json_dict()
|
||||
|
||||
if not expected_result.items() <= balance_response.items():
|
||||
|
||||
@@ -326,7 +326,7 @@ async def test_plotnft_cli_show_with_farmer(
|
||||
assert "Current state" not in out
|
||||
|
||||
wallet_id = await create_new_plotnft(wallet_environments)
|
||||
pw_info = (await wallet_rpc.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_info = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
await ShowPlotNFTCMD(
|
||||
context=ChiaCliContext(root_path=root_path),
|
||||
@@ -680,7 +680,7 @@ async def test_plotnft_cli_claim(
|
||||
# Create a self-pooling plotnft
|
||||
wallet_id = await create_new_plotnft(wallet_environments, self_pool=True)
|
||||
|
||||
status = (await wallet_rpc.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
async with wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(wallet_state_manager)
|
||||
bt = wallet_environments.full_node.bt
|
||||
@@ -878,7 +878,7 @@ async def test_plotnft_cli_change_payout(
|
||||
root_path = wallet_environments.environments[0].node.root_path
|
||||
|
||||
wallet_id = await create_new_plotnft(wallet_environments)
|
||||
pw_info = (await wallet_rpc.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_info = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
# This tests what happens when using None for root_path
|
||||
mocker.patch("chia.cmds.plotnft_funcs.DEFAULT_ROOT_PATH", root_path)
|
||||
|
||||
@@ -205,7 +205,7 @@ async def setup(
|
||||
|
||||
|
||||
async def verify_pool_state(wallet_rpc: WalletRpcClient, w_id: int, expected_state: PoolSingletonState) -> bool:
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(uint32(w_id)))).state
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(w_id)))).state
|
||||
return pw_status.current.state == expected_state.value
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ class TestPoolWalletRpc:
|
||||
wallet = wallet_node.wallet_state_manager.main_wallet
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET.value)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET.value)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
create_response = await client.create_new_wallet(
|
||||
CreateNewWallet(
|
||||
@@ -324,10 +324,10 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.process_transaction_records(records=create_response.transactions)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=30)
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET.value)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET.value)))
|
||||
assert len(summaries_response.wallets) == 1
|
||||
wallet_id: int = summaries_response.wallets[0].id
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
assert status.target is None
|
||||
@@ -370,7 +370,7 @@ class TestPoolWalletRpc:
|
||||
async with wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
create_response = await client.create_new_wallet(
|
||||
@@ -391,10 +391,10 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.process_transaction_records(records=create_response.transactions)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 1
|
||||
wallet_id: int = summaries_response.wallets[0].id
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
assert status.target is None
|
||||
@@ -440,7 +440,7 @@ class TestPoolWalletRpc:
|
||||
our_ph_1 = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
our_ph_2 = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
create_response_1 = await client.create_new_wallet(
|
||||
@@ -479,15 +479,15 @@ class TestPoolWalletRpc:
|
||||
|
||||
async def pw_created(check_wallet_id: int) -> bool:
|
||||
try:
|
||||
await client.pw_status(PWStatus(uint32(check_wallet_id)))
|
||||
await client.pw_status(PWStatus(wallet_id=uint32(check_wallet_id)))
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
await time_out_assert(10, pw_created, True, 2)
|
||||
await time_out_assert(10, pw_created, True, 3)
|
||||
status_2: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status_3: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(3)))).state
|
||||
status_2: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
status_3: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(3)))).state
|
||||
|
||||
if status_2.current.state == PoolSingletonState.SELF_POOLING.value:
|
||||
assert status_3.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
@@ -508,15 +508,15 @@ class TestPoolWalletRpc:
|
||||
assert len(summaries_response.wallets) == 1
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await client.pw_status(PWStatus(uint32(2)))
|
||||
await client.pw_status(PWStatus(wallet_id=uint32(2)))
|
||||
with pytest.raises(ValueError):
|
||||
await client.pw_status(PWStatus(uint32(3)))
|
||||
await client.pw_status(PWStatus(wallet_id=uint32(3)))
|
||||
|
||||
# Create some CAT wallets to increase wallet IDs
|
||||
def mempool_empty() -> bool:
|
||||
return full_node_api.full_node.mempool_manager.mempool.size() == 0
|
||||
|
||||
await client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(uint32(1)))
|
||||
await client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(wallet_id=uint32(1)))
|
||||
await full_node_api.process_all_wallet_transactions(wallet=wallet)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
@@ -538,7 +538,7 @@ class TestPoolWalletRpc:
|
||||
assert len(asset_id) > 0
|
||||
await full_node_api.process_all_wallet_transactions(wallet=wallet)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
bal_0 = (await client.get_wallet_balance(GetWalletBalance(cat_0_id))).wallet_balance
|
||||
bal_0 = (await client.get_wallet_balance(GetWalletBalance(wallet_id=cat_0_id))).wallet_balance
|
||||
assert bal_0.confirmed_wallet_balance == 20
|
||||
|
||||
# Test creation of many pool wallets. Use untrusted since that is the more complicated protocol, but don't
|
||||
@@ -570,7 +570,9 @@ class TestPoolWalletRpc:
|
||||
if i == 0:
|
||||
for some_wallet in wallet_node.wallet_state_manager.wallets.values():
|
||||
if some_wallet.type() == WalletType.POOLING_WALLET:
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(some_wallet.id()))).state
|
||||
status: PoolWalletInfo = (
|
||||
await client.pw_status(PWStatus(wallet_id=some_wallet.id()))
|
||||
).state
|
||||
auth_sk = find_authentication_sk(
|
||||
[some_wallet.wallet_state_manager.get_master_private_key()], status.current.owner_pubkey
|
||||
)
|
||||
@@ -593,7 +595,7 @@ class TestPoolWalletRpc:
|
||||
async with wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
create_response = await client.create_new_wallet(
|
||||
@@ -610,7 +612,7 @@ class TestPoolWalletRpc:
|
||||
)
|
||||
await full_node_api.process_transaction_records(records=create_response.transactions)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
async with manage_temporary_pool_plot(bt, status.p2_singleton_puzzle_hash) as pool_plot:
|
||||
@@ -626,7 +628,7 @@ class TestPoolWalletRpc:
|
||||
await add_blocks_in_batches(blocks[-3:], full_node_api.full_node)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 2 * 1_750_000_000_000
|
||||
|
||||
# Claim 2 * 1.75, and farm a new 1.75
|
||||
@@ -649,10 +651,10 @@ class TestPoolWalletRpc:
|
||||
)
|
||||
== 2
|
||||
)
|
||||
new_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
new_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
assert status.current == new_status.current
|
||||
assert status.tip_singleton_coin_id != new_status.tip_singleton_coin_id
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 1 * 1_750_000_000_000
|
||||
|
||||
# Claim another 1.75
|
||||
@@ -666,7 +668,7 @@ class TestPoolWalletRpc:
|
||||
|
||||
await full_node_api.farm_blocks_to_puzzlehash(count=2, farm_to=our_ph, guarantee_transaction_blocks=True)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 0
|
||||
|
||||
assert len(await wallet_node.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(2)) == 0
|
||||
@@ -687,7 +689,7 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.farm_blocks_to_puzzlehash(count=2, farm_to=our_ph, guarantee_transaction_blocks=True)
|
||||
|
||||
# Balance ignores non coinbase TX
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 0
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
@@ -695,7 +697,7 @@ class TestPoolWalletRpc:
|
||||
PWAbsorbRewards(wallet_id=uint32(2), fee=uint64(fee), push=True), DEFAULT_TX_CONFIG
|
||||
)
|
||||
|
||||
tx1 = (await client.get_transactions(GetTransactions(uint32(1)))).transactions
|
||||
tx1 = (await client.get_transactions(GetTransactions(wallet_id=uint32(1)))).transactions
|
||||
assert (250_000_000_000 + fee) in [tx.amount for tx in tx1]
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -710,7 +712,7 @@ class TestPoolWalletRpc:
|
||||
async with wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
main_expected_confirmed_balance = total_block_rewards
|
||||
@@ -732,10 +734,10 @@ class TestPoolWalletRpc:
|
||||
pool_expected_confirmed_balance = 0
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(uint32(1)))).wallet_balance
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(1)))).wallet_balance
|
||||
assert main_bal.confirmed_wallet_balance == main_expected_confirmed_balance
|
||||
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
|
||||
async with manage_temporary_pool_plot(bt, status.p2_singleton_puzzle_hash) as pool_plot:
|
||||
@@ -756,9 +758,9 @@ class TestPoolWalletRpc:
|
||||
pool_expected_confirmed_balance += block_count * 1_750_000_000_000
|
||||
main_expected_confirmed_balance += block_count * 250_000_000_000
|
||||
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(uint32(1)))).wallet_balance
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(1)))).wallet_balance
|
||||
assert main_bal.confirmed_wallet_balance == main_expected_confirmed_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == pool_expected_confirmed_balance
|
||||
|
||||
# Claim
|
||||
@@ -774,11 +776,11 @@ class TestPoolWalletRpc:
|
||||
pool_expected_confirmed_balance -= 1_750_000_000_000
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
new_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
new_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
assert status.current == new_status.current
|
||||
assert status.tip_singleton_coin_id != new_status.tip_singleton_coin_id
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(uint32(1)))).wallet_balance
|
||||
pool_bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
main_bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(1)))).wallet_balance
|
||||
pool_bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert pool_bal.confirmed_wallet_balance == pool_expected_confirmed_balance
|
||||
assert main_bal.confirmed_wallet_balance == main_expected_confirmed_balance # 10499999999999
|
||||
|
||||
@@ -796,7 +798,7 @@ class TestPoolWalletRpc:
|
||||
async with wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(wallet.wallet_state_manager)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
create_response = await client.create_new_wallet(
|
||||
CreateNewWallet(
|
||||
@@ -820,14 +822,14 @@ class TestPoolWalletRpc:
|
||||
|
||||
async def farming_to_pool() -> bool:
|
||||
try:
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
return status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
await time_out_assert(20, farming_to_pool)
|
||||
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
async with manage_temporary_pool_plot(bt, status.p2_singleton_puzzle_hash) as pool_plot:
|
||||
all_blocks = await full_node_api.get_all_full_blocks()
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
@@ -844,7 +846,7 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
# Pooled plots don't have balance
|
||||
main_expected_confirmed_balance += block_count * 250_000_000_000
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 0
|
||||
|
||||
# Claim block_count * 1.75
|
||||
@@ -864,16 +866,16 @@ class TestPoolWalletRpc:
|
||||
main_expected_confirmed_balance += block_count * 1_750_000_000_000
|
||||
|
||||
async def status_updated() -> bool:
|
||||
new_st: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
new_st: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
return status.current == new_st.current and status.tip_singleton_coin_id != new_st.tip_singleton_coin_id
|
||||
|
||||
await time_out_assert(20, status_updated)
|
||||
new_status = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
new_status = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 0
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal.confirmed_wallet_balance == 0
|
||||
assert len(await wallet_node.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(2)) == 0
|
||||
peak = full_node_api.full_node.blockchain.get_peak()
|
||||
@@ -913,10 +915,10 @@ class TestPoolWalletRpc:
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
await time_out_assert(20, status_updated)
|
||||
status = (await client.pw_status(PWStatus(uint32(2)))).state
|
||||
status = (await client.pw_status(PWStatus(wallet_id=uint32(2)))).state
|
||||
assert ret.fee_transaction is None
|
||||
|
||||
bal2 = (await client.get_wallet_balance(GetWalletBalance(uint32(2)))).wallet_balance
|
||||
bal2 = (await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(2)))).wallet_balance
|
||||
assert bal2.confirmed_wallet_balance == 0
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -934,7 +936,7 @@ class TestPoolWalletRpc:
|
||||
|
||||
assert wallet_node._wallet_state_manager is not None
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
create_response_1 = await client.create_new_wallet(
|
||||
@@ -972,12 +974,12 @@ class TestPoolWalletRpc:
|
||||
assert not full_node_api.txs_in_mempool(txs=create_response_1.transactions)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 2
|
||||
wallet_id: int = summaries_response.wallets[0].id
|
||||
wallet_id_2: int = summaries_response.wallets[1].id
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status_2: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id_2)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
status_2: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id_2)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
assert status_2.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
@@ -1017,8 +1019,8 @@ class TestPoolWalletRpc:
|
||||
assert join_pool_tx_2 is not None
|
||||
await full_node_api.wait_transaction_records_entered_mempool(records=[join_pool_tx_2])
|
||||
|
||||
status = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status_2 = (await client.pw_status(PWStatus(uint32(wallet_id_2)))).state
|
||||
status = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
status_2 = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id_2)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
assert status.target is not None
|
||||
@@ -1030,7 +1032,7 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.process_transaction_records(records=[join_pool_tx, join_pool_tx_2])
|
||||
|
||||
async def status_is_farming_to_pool(w_id: int) -> bool:
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(w_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(w_id)))).state
|
||||
return pw_status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
|
||||
await time_out_assert(20, status_is_farming_to_pool, True, wallet_id)
|
||||
@@ -1043,7 +1045,7 @@ class TestPoolWalletRpc:
|
||||
full_node_api, wallet_node, our_ph, _total_block_rewards, client = setup
|
||||
pool_ph = bytes32.zeros
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
@@ -1068,10 +1070,10 @@ class TestPoolWalletRpc:
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 1
|
||||
wallet_id: int = summaries_response.wallets[0].id
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
assert status.target is None
|
||||
@@ -1088,7 +1090,7 @@ class TestPoolWalletRpc:
|
||||
DEFAULT_TX_CONFIG,
|
||||
)
|
||||
|
||||
status = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
assert status.current.pool_url == ""
|
||||
@@ -1104,7 +1106,7 @@ class TestPoolWalletRpc:
|
||||
|
||||
async def status_is_farming_to_pool() -> bool:
|
||||
await full_node_api.farm_blocks_to_puzzlehash(count=1, farm_to=our_ph, guarantee_transaction_blocks=True)
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
return pw_status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
|
||||
await time_out_assert(timeout=MAX_WAIT_SECS, function=status_is_farming_to_pool)
|
||||
@@ -1121,7 +1123,7 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.farm_blocks_to_puzzlehash(count=1, farm_to=our_ph, guarantee_transaction_blocks=True)
|
||||
|
||||
async def status_is_leaving() -> bool:
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
return pw_status.current.state == PoolSingletonState.LEAVING_POOL.value
|
||||
|
||||
await time_out_assert(timeout=MAX_WAIT_SECS, function=status_is_leaving)
|
||||
@@ -1129,7 +1131,7 @@ class TestPoolWalletRpc:
|
||||
|
||||
async def status_is_self_pooling() -> bool:
|
||||
# Farm enough blocks to wait for relative_lock_height
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
log.warning(f"PW status state: {pw_status.current}")
|
||||
return pw_status.current.state == PoolSingletonState.SELF_POOLING.value
|
||||
|
||||
@@ -1170,7 +1172,7 @@ class TestPoolWalletRpc:
|
||||
wallet_state_manager: WalletStateManager = wallet_environments.environments[0].wallet_state_manager
|
||||
wallet_rpc: WalletRpcClient = wallet_environments.environments[0].rpc_client
|
||||
|
||||
summaries_response = await wallet_rpc.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await wallet_rpc.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
wallet_state_manager.config["reuse_public_key_for_change"][
|
||||
@@ -1218,7 +1220,7 @@ class TestPoolWalletRpc:
|
||||
print(f"Checking state after {total_blocks_farmed} blocks")
|
||||
|
||||
await full_node.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
if pw_status.current.state == state.value:
|
||||
return True
|
||||
return False
|
||||
@@ -1231,7 +1233,7 @@ class TestPoolWalletRpc:
|
||||
wallet_environments.environments[0].node,
|
||||
)
|
||||
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await wallet_rpc.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
assert pw_status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
assert pw_status.current.pool_url == "https://pool-b.org"
|
||||
assert pw_status.current.relative_lock_height == LOCK_HEIGHT
|
||||
@@ -1244,7 +1246,7 @@ class TestPoolWalletRpc:
|
||||
pool_b_ph = bytes32.zeros
|
||||
WAIT_SECS = 30
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 0
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
@@ -1272,21 +1274,21 @@ class TestPoolWalletRpc:
|
||||
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
|
||||
summaries_response = await client.get_wallets(GetWallets(uint16(WalletType.POOLING_WALLET)))
|
||||
summaries_response = await client.get_wallets(GetWallets(type=uint16(WalletType.POOLING_WALLET)))
|
||||
assert len(summaries_response.wallets) == 1
|
||||
wallet_id: int = summaries_response.wallets[0].id
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
|
||||
assert status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
assert status.target is None
|
||||
|
||||
async def status_is_farming_to_pool() -> bool:
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
return pw_status.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
|
||||
await time_out_assert(timeout=WAIT_SECS, function=status_is_farming_to_pool)
|
||||
|
||||
pw_info: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_info: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
assert pw_info.current.pool_url == "https://pool-a.org"
|
||||
assert pw_info.current.relative_lock_height == 5
|
||||
|
||||
@@ -1307,7 +1309,7 @@ class TestPoolWalletRpc:
|
||||
await full_node_api.farm_blocks_to_puzzlehash(count=1, farm_to=our_ph, guarantee_transaction_blocks=True)
|
||||
|
||||
async def status_is_leaving_no_blocks() -> bool:
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(uint32(wallet_id)))).state
|
||||
pw_status: PoolWalletInfo = (await client.pw_status(PWStatus(wallet_id=uint32(wallet_id)))).state
|
||||
return pw_status.current.state == PoolSingletonState.LEAVING_POOL.value
|
||||
|
||||
await time_out_assert(timeout=WAIT_SECS, function=status_is_leaving_no_blocks)
|
||||
|
||||
@@ -1509,7 +1509,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
|
||||
),
|
||||
],
|
||||
)
|
||||
await env.rpc_client.push_tx(PushTX(eve_spend))
|
||||
await env.rpc_client.push_tx(PushTX(spend_bundle=eve_spend))
|
||||
await time_out_assert_not_none(5, full_node_api.full_node.mempool_manager.get_spendbundle, eve_spend.name())
|
||||
await wallet_environments.process_pending_states(
|
||||
[
|
||||
@@ -1623,7 +1623,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non
|
||||
)
|
||||
],
|
||||
)
|
||||
await env.rpc_client.push_tx(PushTX(spend_to_wallet))
|
||||
await env.rpc_client.push_tx(PushTX(spend_bundle=spend_to_wallet))
|
||||
await time_out_assert(10, simulator.tx_id_in_mempool, True, spend_to_wallet.name())
|
||||
|
||||
await wallet_environments.process_pending_states(
|
||||
@@ -1675,7 +1675,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non
|
||||
],
|
||||
)
|
||||
signed_spend, _ = await env.wallet_state_manager.sign_bundle(new_spend.coin_spends)
|
||||
await env.rpc_client.push_tx(PushTX(signed_spend))
|
||||
await env.rpc_client.push_tx(PushTX(spend_bundle=signed_spend))
|
||||
await time_out_assert(10, simulator.tx_id_in_mempool, True, signed_spend.name())
|
||||
|
||||
await wallet_environments.process_pending_states(
|
||||
|
||||
@@ -373,7 +373,7 @@ async def test_cat_trades(
|
||||
if credential_restricted:
|
||||
await client_maker.vc_add_proofs(VCAddProofs.from_vc_proofs(proofs_maker))
|
||||
assert (
|
||||
await client_maker.vc_get_proofs_for_root(VCGetProofsForRoot(proof_root_maker))
|
||||
await client_maker.vc_get_proofs_for_root(VCGetProofsForRoot(root=proof_root_maker))
|
||||
).to_vc_proofs().key_value_pairs == proofs_maker.key_value_pairs
|
||||
get_list_reponse = await client_maker.vc_get_list(VCGetList())
|
||||
assert len(get_list_reponse.vc_records) == 1
|
||||
@@ -381,7 +381,7 @@ async def test_cat_trades(
|
||||
|
||||
await client_taker.vc_add_proofs(VCAddProofs.from_vc_proofs(proofs_taker))
|
||||
assert (
|
||||
await client_taker.vc_get_proofs_for_root(VCGetProofsForRoot(proof_root_taker))
|
||||
await client_taker.vc_get_proofs_for_root(VCGetProofsForRoot(root=proof_root_taker))
|
||||
).to_vc_proofs().key_value_pairs == proofs_taker.key_value_pairs
|
||||
get_list_reponse = await client_taker.vc_get_list(VCGetList())
|
||||
assert len(get_list_reponse.vc_records) == 1
|
||||
|
||||
@@ -302,7 +302,7 @@ async def test_creation_from_backup_file(wallet_environments: WalletTestFramewor
|
||||
)
|
||||
did_wallet_2 = env_2.wallet_state_manager.get_wallet(id=uint32(2), required_type=DIDWallet)
|
||||
current_coin_info_response = await env_0.rpc_client.did_get_current_coin_info(
|
||||
DIDGetCurrentCoinInfo(uint32(env_0.wallet_aliases["did"]))
|
||||
DIDGetCurrentCoinInfo(wallet_id=uint32(env_0.wallet_aliases["did"]))
|
||||
)
|
||||
assert current_coin_info_response.wallet_id == env_0.wallet_aliases["did"]
|
||||
|
||||
@@ -370,7 +370,7 @@ async def test_did_find_lost_did(wallet_environments: WalletTestFramework):
|
||||
assert len(wallet_node_0.wallet_state_manager.wallets) == 1
|
||||
# Find lost DID
|
||||
assert did_wallet_0.did_info.origin_coin is not None # mypy
|
||||
await env_0.rpc_client.find_lost_did(DIDFindLostDID(did_wallet_0.did_info.origin_coin.name().hex()))
|
||||
await env_0.rpc_client.find_lost_did(DIDFindLostDID(coin_id=did_wallet_0.did_info.origin_coin.name().hex()))
|
||||
did_wallets = list(
|
||||
filter(
|
||||
lambda w: (w.type == WalletType.DECENTRALIZED_ID),
|
||||
@@ -434,7 +434,7 @@ async def test_did_find_lost_did(wallet_environments: WalletTestFramework):
|
||||
did_wallet.did_info = dataclasses.replace(did_wallet.did_info, current_inner=new_inner_puzzle)
|
||||
# Recovery the coin
|
||||
assert did_wallet.did_info.origin_coin is not None # mypy
|
||||
await env_0.rpc_client.find_lost_did(DIDFindLostDID(did_wallet.did_info.origin_coin.name().hex()))
|
||||
await env_0.rpc_client.find_lost_did(DIDFindLostDID(coin_id=did_wallet.did_info.origin_coin.name().hex()))
|
||||
found_coin = await did_wallet.get_coin()
|
||||
assert found_coin == coin
|
||||
assert did_wallet.did_info.current_inner != new_inner_puzzle
|
||||
@@ -782,8 +782,8 @@ async def test_get_info(wallet_environments: WalletTestFramework):
|
||||
)
|
||||
assert did_wallet_1.did_info.origin_coin is not None # mypy
|
||||
coin_id_as_bech32 = encode_puzzle_hash(did_wallet_1.did_info.origin_coin.name(), AddressType.DID.value)
|
||||
response = await api_0.get_did_info(DIDGetInfo(did_wallet_1.did_info.origin_coin.name().hex()))
|
||||
response_with_bech32 = await api_0.get_did_info(DIDGetInfo(coin_id_as_bech32))
|
||||
response = await api_0.get_did_info(DIDGetInfo(coin_id=did_wallet_1.did_info.origin_coin.name().hex()))
|
||||
response_with_bech32 = await api_0.get_did_info(DIDGetInfo(coin_id=coin_id_as_bech32))
|
||||
assert response == response_with_bech32
|
||||
assert response.did_id == coin_id_as_bech32
|
||||
assert response.launcher_id == did_wallet_1.did_info.origin_coin.name()
|
||||
@@ -803,7 +803,7 @@ async def test_get_info(wallet_environments: WalletTestFramework):
|
||||
assert coin.amount % 2 == 1
|
||||
coin_id = coin.name()
|
||||
with pytest.raises(ValueError, match="The coin is not a DID"):
|
||||
await api_0.get_did_info(DIDGetInfo(coin_id.hex()))
|
||||
await api_0.get_did_info(DIDGetInfo(coin_id=coin_id.hex()))
|
||||
|
||||
# Test multiple odd coins
|
||||
odd_amount = uint64(1)
|
||||
@@ -857,7 +857,7 @@ async def test_get_info(wallet_environments: WalletTestFramework):
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"This is not a singleton, multiple children coins found."):
|
||||
await api_0.get_did_info(DIDGetInfo(coin_1.name().hex()))
|
||||
await api_0.get_did_info(DIDGetInfo(coin_id=coin_1.name().hex()))
|
||||
|
||||
|
||||
@pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN], reason="irrelevant")
|
||||
|
||||
@@ -433,7 +433,12 @@ async def test_nft_mint_rpc(wallet_environments: WalletTestFramework, zero_royal
|
||||
)
|
||||
|
||||
# check NFT edition numbers
|
||||
nfts = [nft for nft in (await env_1.rpc_client.list_nfts(NFTGetNFTs(uint32(env_1.wallet_aliases["nft"])))).nft_list]
|
||||
nfts = [
|
||||
nft
|
||||
for nft in (
|
||||
await env_1.rpc_client.list_nfts(NFTGetNFTs(wallet_id=uint32(env_1.wallet_aliases["nft"])))
|
||||
).nft_list
|
||||
]
|
||||
for nft in nfts:
|
||||
edition_num = nft.edition_number
|
||||
meta_dict = metadata_list[edition_num - 1]
|
||||
|
||||
@@ -535,7 +535,9 @@ async def test_nft_wallet_creation_and_transfer(wallet_environments: WalletTestF
|
||||
NFTSetNFTDID(
|
||||
wallet_id=uint32(env_1.wallet_aliases["nft"]),
|
||||
did_id=None,
|
||||
nft_coin_id=(await env_1.rpc_client.list_nfts(NFTGetNFTs(uint32(env_1.wallet_aliases["nft"]))))
|
||||
nft_coin_id=(
|
||||
await env_1.rpc_client.list_nfts(NFTGetNFTs(wallet_id=uint32(env_1.wallet_aliases["nft"])))
|
||||
)
|
||||
.nft_list[0]
|
||||
.nft_coin_id,
|
||||
),
|
||||
@@ -659,10 +661,10 @@ async def test_nft_wallet_rpc_creation_and_list(wallet_environments: WalletTestF
|
||||
assert coins[0].data_hash.hex() == "0xD4584AD463139FA8C0D9F68F4B59F184D4584AD463139FA8C0D9F68F4B59F184"[2:].lower()
|
||||
|
||||
# test counts
|
||||
assert (await env.rpc_client.count_nfts(NFTCountNFTs(uint32(env.wallet_aliases["nft"])))).count == 2
|
||||
assert (await env.rpc_client.count_nfts(NFTCountNFTs(wallet_id=uint32(env.wallet_aliases["nft"])))).count == 2
|
||||
assert (await env.rpc_client.count_nfts(NFTCountNFTs())).count == 2
|
||||
with pytest.raises(ResponseFailureError, match="Wallet with id 50 does not exist"):
|
||||
await env.rpc_client.count_nfts(NFTCountNFTs(uint32(50)))
|
||||
await env.rpc_client.count_nfts(NFTCountNFTs(wallet_id=uint32(50)))
|
||||
|
||||
|
||||
@pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN], reason="irrelevant")
|
||||
@@ -715,7 +717,7 @@ async def test_sign_message_by_nft_id(wallet_environments: WalletTestFramework)
|
||||
]
|
||||
)
|
||||
|
||||
nft_list = await env.rpc_client.list_nfts(NFTGetNFTs(uint32(env.wallet_aliases["nft"])))
|
||||
nft_list = await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"])))
|
||||
nft_id = nft_list.nft_list[0].nft_id
|
||||
|
||||
# Test general string
|
||||
@@ -826,7 +828,7 @@ async def test_nft_wallet_rpc_update_metadata(wallet_environments: WalletTestFra
|
||||
)
|
||||
|
||||
coins: list[NFTInfo] = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
coin = coins[0]
|
||||
assert coin.mint_height > 0
|
||||
@@ -857,7 +859,9 @@ async def test_nft_wallet_rpc_update_metadata(wallet_environments: WalletTestFra
|
||||
tx_config=wallet_environments.tx_config,
|
||||
)
|
||||
|
||||
coins = (await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet.id(), start_index=uint32(0), num=uint32(1)))).nft_list
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
assert coins[0].pending_transaction
|
||||
|
||||
await wallet_environments.process_pending_states(
|
||||
@@ -876,7 +880,9 @@ async def test_nft_wallet_rpc_update_metadata(wallet_environments: WalletTestFra
|
||||
)
|
||||
|
||||
# check that new URI was added
|
||||
coins = (await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet.id(), start_index=uint32(0), num=uint32(1)))).nft_list
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
coin = coins[0]
|
||||
assert coin.mint_height > 0
|
||||
@@ -915,7 +921,9 @@ async def test_nft_wallet_rpc_update_metadata(wallet_environments: WalletTestFra
|
||||
]
|
||||
)
|
||||
|
||||
coins = (await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet.id(), start_index=uint32(0), num=uint32(1)))).nft_list
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
coin = coins[0]
|
||||
assert coin.mint_height > 0
|
||||
@@ -1005,7 +1013,7 @@ async def test_nft_with_did_wallet_creation(wallet_environments: WalletTestFrame
|
||||
NFTWalletWithDID(wallet_id=nft_wallet.id(), did_id=hmr_did_id, did_wallet_id=did_wallet.id())
|
||||
]
|
||||
|
||||
get_did_res = await env.rpc_client.get_nft_wallet_did(NFTGetWalletDID(nft_wallet.id()))
|
||||
get_did_res = await env.rpc_client.get_nft_wallet_did(NFTGetWalletDID(wallet_id=nft_wallet.id()))
|
||||
assert get_did_res.did_id == hmr_did_id
|
||||
|
||||
# Create a NFT with DID
|
||||
@@ -1101,7 +1109,7 @@ async def test_nft_with_did_wallet_creation(wallet_environments: WalletTestFrame
|
||||
)
|
||||
# Check DID NFT
|
||||
coins: list[NFTInfo] = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet.id(), start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
did_nft = coins[0]
|
||||
@@ -1117,7 +1125,7 @@ async def test_nft_with_did_wallet_creation(wallet_environments: WalletTestFrame
|
||||
nft_wallets = await env.wallet_state_manager.get_all_wallet_info_entries(WalletType.NFT)
|
||||
assert len(nft_wallets) == 2
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(nft_wallet_p2_puzzle, start_index=uint32(0), num=uint32(1)))
|
||||
await env.rpc_client.list_nfts(NFTGetNFTs(wallet_id=nft_wallet_p2_puzzle, start_index=uint32(0), num=uint32(1)))
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
non_did_nft = coins[0]
|
||||
@@ -1245,7 +1253,7 @@ async def test_nft_rpc_mint(wallet_environments: WalletTestFramework) -> None:
|
||||
|
||||
coins: list[NFTInfo] = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1387,7 +1395,7 @@ async def test_nft_transfer_nft_with_did(wallet_environments: WalletTestFramewor
|
||||
# Check DID NFT
|
||||
coins: list[NFTInfo] = (
|
||||
await env_0.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_0.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env_0.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1495,7 +1503,7 @@ async def test_nft_transfer_nft_with_did(wallet_environments: WalletTestFramewor
|
||||
assert env_1.wallet_aliases["nft"] == wallet_by_did_response.wallet_id
|
||||
coins = (
|
||||
await env_1.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_1.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env_1.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1563,7 +1571,7 @@ async def test_nft_transfer_nft_with_did(wallet_environments: WalletTestFramewor
|
||||
# Check NFT DID is set now
|
||||
coins = (
|
||||
await env_1.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_1.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env_1.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1687,7 +1695,7 @@ async def test_update_metadata_for_nft_did(wallet_environments: WalletTestFramew
|
||||
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1712,7 +1720,7 @@ async def test_update_metadata_for_nft_did(wallet_environments: WalletTestFramew
|
||||
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1749,7 +1757,7 @@ async def test_update_metadata_for_nft_did(wallet_environments: WalletTestFramew
|
||||
# check that new URI was added
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -1979,7 +1987,7 @@ async def test_nft_bulk_set_did(wallet_environments: WalletTestFramework) -> Non
|
||||
# Check DID NFT
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 2
|
||||
@@ -1989,7 +1997,7 @@ async def test_nft_bulk_set_did(wallet_environments: WalletTestFramework) -> Non
|
||||
assert nft12.owner_did is not None
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2018,7 +2026,7 @@ async def test_nft_bulk_set_did(wallet_environments: WalletTestFramework) -> Non
|
||||
assert set_did_bulk_resp.tx_num == 5 # 1 for each NFT being spent (3), 1 for fee tx, 1 for did tx
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 2
|
||||
@@ -2072,7 +2080,7 @@ async def test_nft_bulk_set_did(wallet_environments: WalletTestFramework) -> Non
|
||||
assert env.wallet_aliases["nft_w_did"] == wallet_by_did_response.wallet_id
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(3))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(3))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 3
|
||||
@@ -2315,7 +2323,7 @@ async def test_nft_bulk_transfer(wallet_environments: WalletTestFramework) -> No
|
||||
# Check DID NFT
|
||||
coins = (
|
||||
await env_0.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_0.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
NFTGetNFTs(wallet_id=uint32(env_0.wallet_aliases["nft_w_did"]), start_index=uint32(0), num=uint32(2))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 2
|
||||
@@ -2325,7 +2333,7 @@ async def test_nft_bulk_transfer(wallet_environments: WalletTestFramework) -> No
|
||||
assert nft12.owner_did is not None
|
||||
coins = (
|
||||
await env_0.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_0.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env_0.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2399,7 +2407,7 @@ async def test_nft_bulk_transfer(wallet_environments: WalletTestFramework) -> No
|
||||
await time_out_assert(30, get_wallet_number, 2, env_1.wallet_state_manager)
|
||||
coins = (
|
||||
await env_1.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env_1.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(3))
|
||||
NFTGetNFTs(wallet_id=uint32(env_1.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(3))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 3
|
||||
@@ -2510,7 +2518,7 @@ async def test_nft_set_did(wallet_environments: WalletTestFramework) -> None:
|
||||
# Check DID NFT
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2583,7 +2591,7 @@ async def test_nft_set_did(wallet_environments: WalletTestFramework) -> None:
|
||||
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did1"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did1"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2640,7 +2648,7 @@ async def test_nft_set_did(wallet_environments: WalletTestFramework) -> None:
|
||||
# Check NFT DID
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_w_did2"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_w_did2"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2682,7 +2690,7 @@ async def test_nft_set_did(wallet_environments: WalletTestFramework) -> None:
|
||||
# Check NFT DID
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft_no_did"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2767,7 +2775,7 @@ async def test_set_nft_status(wallet_environments: WalletTestFramework) -> None:
|
||||
# Check DID NFT
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2781,7 +2789,7 @@ async def test_set_nft_status(wallet_environments: WalletTestFramework) -> None:
|
||||
)
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
@@ -2868,7 +2876,7 @@ async def test_nft_sign_message(wallet_environments: WalletTestFramework) -> Non
|
||||
# Check DID NFT
|
||||
coins = (
|
||||
await env.rpc_client.list_nfts(
|
||||
NFTGetNFTs(uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
NFTGetNFTs(wallet_id=uint32(env.wallet_aliases["nft"]), start_index=uint32(0), num=uint32(1))
|
||||
)
|
||||
).nft_list
|
||||
assert len(coins) == 1
|
||||
|
||||
@@ -115,13 +115,13 @@ class TestWalletRpc:
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node)
|
||||
|
||||
async def is_singleton_confirmed(rpc_client: WalletRpcClient, lid: bytes32) -> bool:
|
||||
rec = (await rpc_client.dl_latest_singleton(DLLatestSingleton(lid))).singleton
|
||||
rec = (await rpc_client.dl_latest_singleton(DLLatestSingleton(launcher_id=lid))).singleton
|
||||
if rec is None:
|
||||
return False
|
||||
return rec.confirmed
|
||||
|
||||
await time_out_assert(15, is_singleton_confirmed, True, client, launcher_id)
|
||||
singleton_record = (await client.dl_latest_singleton(DLLatestSingleton(launcher_id))).singleton
|
||||
singleton_record = (await client.dl_latest_singleton(DLLatestSingleton(launcher_id=launcher_id))).singleton
|
||||
assert singleton_record is not None
|
||||
assert singleton_record.root == merkle_root
|
||||
|
||||
@@ -135,22 +135,27 @@ class TestWalletRpc:
|
||||
await asyncio.sleep(0.5)
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node)
|
||||
|
||||
new_singleton_record = (await client.dl_latest_singleton(DLLatestSingleton(launcher_id))).singleton
|
||||
new_singleton_record = (
|
||||
await client.dl_latest_singleton(DLLatestSingleton(launcher_id=launcher_id))
|
||||
).singleton
|
||||
assert new_singleton_record is not None
|
||||
assert new_singleton_record.root == new_root
|
||||
assert new_singleton_record.confirmed
|
||||
|
||||
assert (await client.dl_history(DLHistory(launcher_id))).history == [new_singleton_record, singleton_record]
|
||||
assert (await client.dl_history(DLHistory(launcher_id=launcher_id))).history == [
|
||||
new_singleton_record,
|
||||
singleton_record,
|
||||
]
|
||||
|
||||
# Test tracking a launcher id that does not exist
|
||||
with pytest.raises(ValueError):
|
||||
await client_2.dl_track_new(DLTrackNew(bytes32([1] * 32)))
|
||||
await client_2.dl_track_new(DLTrackNew(launcher_id=bytes32([1] * 32)))
|
||||
|
||||
await client_2.dl_track_new(DLTrackNew(launcher_id))
|
||||
await client_2.dl_track_new(DLTrackNew(launcher_id=launcher_id))
|
||||
|
||||
async def is_singleton_generation(rpc_client: WalletRpcClient, lid: bytes32, generation: int) -> bool:
|
||||
if await is_singleton_confirmed(rpc_client, lid):
|
||||
rec = (await rpc_client.dl_latest_singleton(DLLatestSingleton(lid))).singleton
|
||||
rec = (await rpc_client.dl_latest_singleton(DLLatestSingleton(launcher_id=lid))).singleton
|
||||
if rec is None:
|
||||
raise Exception(f"No latest singleton for: {lid!r}")
|
||||
return rec.generation == generation
|
||||
@@ -159,28 +164,28 @@ class TestWalletRpc:
|
||||
|
||||
await time_out_assert(15, is_singleton_generation, True, client_2, launcher_id, 1)
|
||||
|
||||
assert (await client_2.dl_history(DLHistory(launcher_id))).history == [
|
||||
assert (await client_2.dl_history(DLHistory(launcher_id=launcher_id))).history == [
|
||||
new_singleton_record,
|
||||
singleton_record,
|
||||
]
|
||||
|
||||
assert (await client.dl_history(DLHistory(launcher_id, min_generation=uint32(1)))).history == [
|
||||
assert (await client.dl_history(DLHistory(launcher_id=launcher_id, min_generation=uint32(1)))).history == [
|
||||
new_singleton_record
|
||||
]
|
||||
assert (await client.dl_history(DLHistory(launcher_id, max_generation=uint32(0)))).history == [
|
||||
assert (await client.dl_history(DLHistory(launcher_id=launcher_id, max_generation=uint32(0)))).history == [
|
||||
singleton_record
|
||||
]
|
||||
assert (await client.dl_history(DLHistory(launcher_id, num_results=uint32(1)))).history == [
|
||||
assert (await client.dl_history(DLHistory(launcher_id=launcher_id, num_results=uint32(1)))).history == [
|
||||
new_singleton_record
|
||||
]
|
||||
assert (await client.dl_history(DLHistory(launcher_id, num_results=uint32(2)))).history == [
|
||||
assert (await client.dl_history(DLHistory(launcher_id=launcher_id, num_results=uint32(2)))).history == [
|
||||
new_singleton_record,
|
||||
singleton_record,
|
||||
]
|
||||
assert (
|
||||
await client.dl_history(
|
||||
DLHistory(
|
||||
launcher_id,
|
||||
launcher_id=launcher_id,
|
||||
min_generation=uint32(1),
|
||||
max_generation=uint32(1),
|
||||
)
|
||||
@@ -189,7 +194,7 @@ class TestWalletRpc:
|
||||
assert (
|
||||
await client.dl_history(
|
||||
DLHistory(
|
||||
launcher_id,
|
||||
launcher_id=launcher_id,
|
||||
max_generation=uint32(0),
|
||||
num_results=uint32(1),
|
||||
)
|
||||
@@ -198,7 +203,7 @@ class TestWalletRpc:
|
||||
assert (
|
||||
await client.dl_history(
|
||||
DLHistory(
|
||||
launcher_id,
|
||||
launcher_id=launcher_id,
|
||||
min_generation=uint32(1),
|
||||
num_results=uint32(1),
|
||||
)
|
||||
@@ -207,7 +212,7 @@ class TestWalletRpc:
|
||||
assert (
|
||||
await client.dl_history(
|
||||
DLHistory(
|
||||
launcher_id,
|
||||
launcher_id=launcher_id,
|
||||
min_generation=uint32(1),
|
||||
max_generation=uint32(1),
|
||||
num_results=uint32(1),
|
||||
@@ -215,9 +220,9 @@ class TestWalletRpc:
|
||||
)
|
||||
).history == [new_singleton_record]
|
||||
|
||||
assert (await client.dl_singletons_by_root(DLSingletonsByRoot(launcher_id, new_root))).singletons == [
|
||||
new_singleton_record
|
||||
]
|
||||
assert (
|
||||
await client.dl_singletons_by_root(DLSingletonsByRoot(launcher_id=launcher_id, root=new_root))
|
||||
).singletons == [new_singleton_record]
|
||||
|
||||
launcher_id_2 = (
|
||||
await client.create_new_dl(CreateNewDL(root=merkle_root, fee=uint64(50), push=True), DEFAULT_TX_CONFIG)
|
||||
@@ -239,10 +244,10 @@ class TestWalletRpc:
|
||||
await client.dl_update_multiple(
|
||||
DLUpdateMultiple(
|
||||
updates=DLUpdateMultipleUpdates(
|
||||
[
|
||||
LauncherRootPair(launcher_id, next_root),
|
||||
LauncherRootPair(launcher_id_2, next_root),
|
||||
LauncherRootPair(launcher_id_3, next_root),
|
||||
launcher_root_pairs=[
|
||||
LauncherRootPair(launcher_id=launcher_id, new_root=next_root),
|
||||
LauncherRootPair(launcher_id=launcher_id_2, new_root=next_root),
|
||||
LauncherRootPair(launcher_id=launcher_id_3, new_root=next_root),
|
||||
]
|
||||
),
|
||||
fee=uint64(0),
|
||||
@@ -260,12 +265,12 @@ class TestWalletRpc:
|
||||
await time_out_assert(15, is_singleton_confirmed, True, client, launcher_id_3)
|
||||
|
||||
for lid in [launcher_id, launcher_id_2, launcher_id_3]:
|
||||
rec = (await client.dl_latest_singleton(DLLatestSingleton(lid))).singleton
|
||||
rec = (await client.dl_latest_singleton(DLLatestSingleton(launcher_id=lid))).singleton
|
||||
assert rec is not None
|
||||
assert rec.root == next_root
|
||||
|
||||
await client_2.dl_stop_tracking(DLStopTracking(launcher_id))
|
||||
assert (await client_2.dl_latest_singleton(DLLatestSingleton(lid))).singleton is None
|
||||
await client_2.dl_stop_tracking(DLStopTracking(launcher_id=launcher_id))
|
||||
assert (await client_2.dl_latest_singleton(DLLatestSingleton(launcher_id=lid))).singleton is None
|
||||
|
||||
owned_singletons = (await client.dl_owned_singletons()).singletons
|
||||
owned_launcher_ids = sorted(singleton.launcher_id for singleton in owned_singletons)
|
||||
@@ -303,18 +308,22 @@ class TestWalletRpc:
|
||||
True,
|
||||
uint32(height + 1),
|
||||
)
|
||||
await time_out_assert(15, client.dl_get_mirrors, DLGetMirrorsResponse([mirror]), DLGetMirrors(launcher_id))
|
||||
await time_out_assert(
|
||||
15, client.dl_get_mirrors, DLGetMirrorsResponse(mirrors=[mirror]), DLGetMirrors(launcher_id=launcher_id)
|
||||
)
|
||||
await client.dl_delete_mirror(
|
||||
DLDeleteMirror(coin_id=mirror_coin.name(), fee=uint64(2000000000000), push=True), DEFAULT_TX_CONFIG
|
||||
)
|
||||
for i in range(5):
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(bytes32.zeros))
|
||||
await asyncio.sleep(0.5)
|
||||
await time_out_assert(15, client.dl_get_mirrors, DLGetMirrorsResponse([]), DLGetMirrors(launcher_id))
|
||||
await time_out_assert(
|
||||
15, client.dl_get_mirrors, DLGetMirrorsResponse(mirrors=[]), DLGetMirrors(launcher_id=launcher_id)
|
||||
)
|
||||
|
||||
offer_creation_response = await client.create_offer_for_ids(
|
||||
CreateOfferForIDs(
|
||||
{launcher_id.hex(): "-1", launcher_id_2.hex(): "1"},
|
||||
offer={launcher_id.hex(): "-1", launcher_id_2.hex(): "1"},
|
||||
driver_dict={},
|
||||
solver=Solver(
|
||||
{
|
||||
|
||||
@@ -251,24 +251,24 @@ async def assert_get_balance(rpc_client: WalletRpcClient, wallet_node: WalletNod
|
||||
else:
|
||||
expected_balance_dict["asset_id"] = None
|
||||
assert (
|
||||
await rpc_client.get_wallet_balance(GetWalletBalance(wallet.id()))
|
||||
await rpc_client.get_wallet_balance(GetWalletBalance(wallet_id=wallet.id()))
|
||||
).wallet_balance.to_json_dict() == expected_balance_dict
|
||||
|
||||
|
||||
async def tx_in_mempool(client: WalletRpcClient, transaction_id: bytes32) -> bool:
|
||||
tx = (await client.get_transaction(GetTransaction(transaction_id))).transaction
|
||||
tx = (await client.get_transaction(GetTransaction(transaction_id=transaction_id))).transaction
|
||||
return tx.is_in_mempool()
|
||||
|
||||
|
||||
async def get_confirmed_balance(client: WalletRpcClient, wallet_id: int) -> uint128:
|
||||
return (
|
||||
await client.get_wallet_balance(GetWalletBalance(uint32(wallet_id)))
|
||||
await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(wallet_id)))
|
||||
).wallet_balance.confirmed_wallet_balance
|
||||
|
||||
|
||||
async def get_unconfirmed_balance(client: WalletRpcClient, wallet_id: int) -> uint128:
|
||||
return (
|
||||
await client.get_wallet_balance(GetWalletBalance(uint32(wallet_id)))
|
||||
await client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(wallet_id)))
|
||||
).wallet_balance.unconfirmed_wallet_balance
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ async def test_send_transaction(wallet_environments: WalletTestFramework) -> Non
|
||||
await farm_transaction(full_node_api, wallet_node, spend_bundle)
|
||||
|
||||
# Checks that the memo can be retrieved
|
||||
tx_confirmed = (await client.get_transaction(GetTransaction(transaction_id))).transaction
|
||||
tx_confirmed = (await client.get_transaction(GetTransaction(transaction_id=transaction_id))).transaction
|
||||
assert tx_confirmed.confirmed
|
||||
assert len(tx_confirmed.memos) == 1
|
||||
assert [b"this is a basic tx"] in tx_confirmed.memos.values()
|
||||
@@ -422,7 +422,7 @@ async def test_push_transactions(wallet_environments: WalletTestFramework) -> No
|
||||
assert (await client.get_transaction(GetTransaction(transaction_id=tx.name))).transaction.confirmed
|
||||
|
||||
# Just testing NOT failure here really (parsing)
|
||||
await client.push_tx(PushTX(spend_bundle))
|
||||
await client.push_tx(PushTX(spend_bundle=spend_bundle))
|
||||
resp = await client.fetch("push_tx", {"spend_bundle": bytes(spend_bundle).hex()})
|
||||
assert resp["success"]
|
||||
|
||||
@@ -472,7 +472,7 @@ async def test_get_farmed_amount(wallet_environments: WalletTestFramework) -> No
|
||||
|
||||
get_farmed_amount_result = await wallet_rpc_client.get_farmed_amount(GetFarmedAmount())
|
||||
get_timestamp_for_height_result = await wallet_rpc_client.get_timestamp_for_height(
|
||||
GetTimestampForHeight(uint32(3))
|
||||
GetTimestampForHeight(height=uint32(3))
|
||||
) # genesis + 2
|
||||
|
||||
expected_result = GetFarmedAmountResponse(
|
||||
@@ -531,7 +531,7 @@ async def test_get_timestamp_for_height(wallet_environments: WalletTestFramework
|
||||
client: WalletRpcClient = env.rpc_client
|
||||
|
||||
# This tests that the client returns successfully, rather than raising or returning something unexpected
|
||||
await client.get_timestamp_for_height(GetTimestampForHeight(uint32(1)))
|
||||
await client.get_timestamp_for_height(GetTimestampForHeight(height=uint32(1)))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -947,7 +947,7 @@ async def test_send_transaction_multi(wallet_environments: WalletTestFramework)
|
||||
await time_out_assert(20, get_confirmed_balance, INITIAL_BALANCE - amount_outputs - amount_fee, client, 1)
|
||||
|
||||
# Checks that the memo can be retrieved
|
||||
tx_confirmed = (await client.get_transaction(GetTransaction(send_tx_res.name))).transaction
|
||||
tx_confirmed = (await client.get_transaction(GetTransaction(transaction_id=send_tx_res.name))).transaction
|
||||
assert tx_confirmed.confirmed
|
||||
memos = tx_confirmed.memos
|
||||
assert len(memos) == len(outputs)
|
||||
@@ -975,16 +975,18 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
full_node_api: FullNodeSimulator = wallet_environments.full_node
|
||||
client: WalletRpcClient = env.rpc_client
|
||||
|
||||
all_transactions = (await client.get_transactions(GetTransactions(uint32(1)))).transactions
|
||||
all_transactions = (await client.get_transactions(GetTransactions(wallet_id=uint32(1)))).transactions
|
||||
initially_farmed_blocks = 3
|
||||
# We expect 2 transactions per farmed block
|
||||
expected_initial_txs_count = initially_farmed_blocks * 2
|
||||
unconfirmed_txs_count = 0
|
||||
assert len(all_transactions) == expected_initial_txs_count
|
||||
# Test transaction pagination
|
||||
some_transactions = (await client.get_transactions(GetTransactions(uint32(1), uint32(0), uint32(5)))).transactions
|
||||
some_transactions = (
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), start=uint32(0), end=uint32(5)))
|
||||
).transactions
|
||||
some_transactions_2 = (
|
||||
await client.get_transactions(GetTransactions(uint32(1), uint32(5), uint32(10)))
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), start=uint32(5), end=uint32(10)))
|
||||
).transactions
|
||||
assert some_transactions == all_transactions[0:5]
|
||||
assert some_transactions_2 == all_transactions[5:10]
|
||||
@@ -992,7 +994,7 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
# Testing sorts
|
||||
# Test the default sort (CONFIRMED_AT_HEIGHT)
|
||||
assert all_transactions == sorted(all_transactions, key=attrgetter("confirmed_at_height"))
|
||||
all_transactions = (await client.get_transactions(GetTransactions(uint32(1), reverse=True))).transactions
|
||||
all_transactions = (await client.get_transactions(GetTransactions(wallet_id=uint32(1), reverse=True))).transactions
|
||||
assert all_transactions == sorted(all_transactions, key=attrgetter("confirmed_at_height"), reverse=True)
|
||||
|
||||
# Test RELEVANCE
|
||||
@@ -1006,10 +1008,10 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
unconfirmed_txs_count += 1
|
||||
|
||||
with pytest.raises(ValueError, match="There is no known sort foo"):
|
||||
await client.get_transactions(GetTransactions(uint32(1), sort_key="foo"))
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), sort_key="foo"))
|
||||
|
||||
all_transactions = (
|
||||
await client.get_transactions(GetTransactions(uint32(1), sort_key=SortKey.RELEVANCE.name))
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), sort_key=SortKey.RELEVANCE.name))
|
||||
).transactions
|
||||
sorted_transactions = sorted(all_transactions, key=attrgetter("created_at_time"), reverse=True)
|
||||
sorted_transactions = sorted(sorted_transactions, key=attrgetter("confirmed_at_height"), reverse=True)
|
||||
@@ -1017,7 +1019,9 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
assert all_transactions == sorted_transactions
|
||||
|
||||
all_transactions = (
|
||||
await client.get_transactions(GetTransactions(uint32(1), sort_key=SortKey.RELEVANCE.name, reverse=True))
|
||||
await client.get_transactions(
|
||||
GetTransactions(wallet_id=uint32(1), sort_key=SortKey.RELEVANCE.name, reverse=True)
|
||||
)
|
||||
).transactions
|
||||
sorted_transactions = sorted(all_transactions, key=attrgetter("created_at_time"))
|
||||
sorted_transactions = sorted(sorted_transactions, key=attrgetter("confirmed_at_height"))
|
||||
@@ -1037,7 +1041,9 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
unconfirmed_txs_count += 1
|
||||
await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20)
|
||||
tx_for_address = (
|
||||
await client.get_transactions(GetTransactions(uint32(1), to_address=encode_puzzle_hash(ph_by_addr, "txch")))
|
||||
await client.get_transactions(
|
||||
GetTransactions(wallet_id=uint32(1), to_address=encode_puzzle_hash(ph_by_addr, "txch"))
|
||||
)
|
||||
).transactions
|
||||
assert (
|
||||
len(tx_for_address) == expected_initial_txs_count + unconfirmed_txs_count
|
||||
@@ -1049,17 +1055,23 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
# Test type filter
|
||||
all_transactions = (
|
||||
await client.get_transactions(
|
||||
GetTransactions(uint32(1), type_filter=TransactionTypeFilter.include([TransactionType.COINBASE_REWARD]))
|
||||
GetTransactions(
|
||||
wallet_id=uint32(1), type_filter=TransactionTypeFilter.include([TransactionType.COINBASE_REWARD])
|
||||
)
|
||||
)
|
||||
).transactions
|
||||
# Each farmed block creates one COINBASE_REWARD transaction
|
||||
assert len(all_transactions) == initially_farmed_blocks
|
||||
assert all(transaction.type == TransactionType.COINBASE_REWARD.value for transaction in all_transactions)
|
||||
# Test confirmed filter
|
||||
all_transactions = (await client.get_transactions(GetTransactions(uint32(1), confirmed=True))).transactions
|
||||
all_transactions = (
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), confirmed=True))
|
||||
).transactions
|
||||
assert len(all_transactions) == expected_initial_txs_count
|
||||
assert all(transaction.confirmed for transaction in all_transactions)
|
||||
all_transactions = (await client.get_transactions(GetTransactions(uint32(1), confirmed=False))).transactions
|
||||
all_transactions = (
|
||||
await client.get_transactions(GetTransactions(wallet_id=uint32(1), confirmed=False))
|
||||
).transactions
|
||||
assert len(all_transactions) == unconfirmed_txs_count
|
||||
assert all(not transaction.confirmed for transaction in all_transactions)
|
||||
|
||||
@@ -1070,7 +1082,7 @@ async def test_get_transactions(wallet_environments: WalletTestFramework) -> Non
|
||||
all_transactions = (
|
||||
await client.get_transactions(
|
||||
GetTransactions(
|
||||
uint32(1),
|
||||
wallet_id=uint32(1),
|
||||
type_filter=TransactionTypeFilter.include([TransactionType.INCOMING_CLAWBACK_SEND]),
|
||||
confirmed=False,
|
||||
)
|
||||
@@ -1090,15 +1102,17 @@ async def test_get_transaction_count(wallet_environments: WalletTestFramework) -
|
||||
env = wallet_environments.environments[0]
|
||||
client: WalletRpcClient = env.rpc_client
|
||||
|
||||
all_transactions = (await client.get_transactions(GetTransactions(uint32(1)))).transactions
|
||||
all_transactions = (await client.get_transactions(GetTransactions(wallet_id=uint32(1)))).transactions
|
||||
assert len(all_transactions) > 0
|
||||
transaction_count_response = await client.get_transaction_count(GetTransactionCount(uint32(1)))
|
||||
transaction_count_response = await client.get_transaction_count(GetTransactionCount(wallet_id=uint32(1)))
|
||||
assert transaction_count_response.count == len(all_transactions)
|
||||
transaction_count_response = await client.get_transaction_count(GetTransactionCount(uint32(1), confirmed=False))
|
||||
transaction_count_response = await client.get_transaction_count(
|
||||
GetTransactionCount(wallet_id=uint32(1), confirmed=False)
|
||||
)
|
||||
assert transaction_count_response.count == 0
|
||||
transaction_count_response = await client.get_transaction_count(
|
||||
GetTransactionCount(
|
||||
uint32(1), type_filter=TransactionTypeFilter.include([TransactionType.INCOMING_CLAWBACK_SEND])
|
||||
wallet_id=uint32(1), type_filter=TransactionTypeFilter.include([TransactionType.INCOMING_CLAWBACK_SEND])
|
||||
)
|
||||
)
|
||||
assert transaction_count_response.count == 0
|
||||
@@ -1165,22 +1179,24 @@ async def test_cat_endpoints(wallet_environments: WalletTestFramework, wallet_ty
|
||||
# for subset on `dict` `.items()`.
|
||||
assert (
|
||||
env_0.wallet_states[uint32(env_0.wallet_aliases["cat0"])].balance.to_json_dict().items()
|
||||
<= (await env_0.rpc_client.get_wallet_balance(GetWalletBalance(cat_0_id))).wallet_balance.to_json_dict().items()
|
||||
<= (await env_0.rpc_client.get_wallet_balance(GetWalletBalance(wallet_id=cat_0_id)))
|
||||
.wallet_balance.to_json_dict()
|
||||
.items()
|
||||
)
|
||||
asset_id = (await env_0.rpc_client.get_cat_asset_id(CATGetAssetID(cat_0_id))).asset_id
|
||||
asset_id = (await env_0.rpc_client.get_cat_asset_id(CATGetAssetID(wallet_id=cat_0_id))).asset_id
|
||||
assert (
|
||||
await env_0.rpc_client.get_cat_name(CATGetName(cat_0_id))
|
||||
await env_0.rpc_client.get_cat_name(CATGetName(wallet_id=cat_0_id))
|
||||
).name == wallet_type.default_wallet_name_for_unknown_cat(asset_id)
|
||||
await env_0.rpc_client.set_cat_name(CATSetName(cat_0_id, "My cat"))
|
||||
assert (await env_0.rpc_client.get_cat_name(CATGetName(cat_0_id))).name == "My cat"
|
||||
asset_to_name_response = await env_0.rpc_client.cat_asset_id_to_name(CATAssetIDToName(asset_id))
|
||||
await env_0.rpc_client.set_cat_name(CATSetName(wallet_id=cat_0_id, name="My cat"))
|
||||
assert (await env_0.rpc_client.get_cat_name(CATGetName(wallet_id=cat_0_id))).name == "My cat"
|
||||
asset_to_name_response = await env_0.rpc_client.cat_asset_id_to_name(CATAssetIDToName(asset_id=asset_id))
|
||||
assert asset_to_name_response.wallet_id == cat_0_id
|
||||
assert asset_to_name_response.name == "My cat"
|
||||
asset_to_name_response = await env_0.rpc_client.cat_asset_id_to_name(CATAssetIDToName(bytes32.zeros))
|
||||
asset_to_name_response = await env_0.rpc_client.cat_asset_id_to_name(CATAssetIDToName(asset_id=bytes32.zeros))
|
||||
assert asset_to_name_response.name is None
|
||||
verified_asset_id = next(iter(DEFAULT_CATS.items()))[1]["asset_id"]
|
||||
asset_to_name_response = await env_0.rpc_client.cat_asset_id_to_name(
|
||||
CATAssetIDToName(bytes32.from_hexstr(verified_asset_id))
|
||||
CATAssetIDToName(asset_id=bytes32.from_hexstr(verified_asset_id))
|
||||
)
|
||||
assert asset_to_name_response.wallet_id is None
|
||||
assert asset_to_name_response.name == next(iter(DEFAULT_CATS.items()))[1]["name"]
|
||||
@@ -1213,8 +1229,8 @@ async def test_cat_endpoints(wallet_environments: WalletTestFramework, wallet_ty
|
||||
]
|
||||
)
|
||||
|
||||
addr_0 = (await env_0.rpc_client.get_next_address(GetNextAddress(cat_0_id, False))).address
|
||||
addr_1 = (await env_1.rpc_client.get_next_address(GetNextAddress(cat_1_id, False))).address
|
||||
addr_0 = (await env_0.rpc_client.get_next_address(GetNextAddress(wallet_id=cat_0_id, new_address=False))).address
|
||||
addr_1 = (await env_1.rpc_client.get_next_address(GetNextAddress(wallet_id=cat_1_id, new_address=False))).address
|
||||
|
||||
assert addr_0 != addr_1
|
||||
|
||||
@@ -1498,7 +1514,9 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
),
|
||||
tx_config=wallet_environments.tx_config,
|
||||
)
|
||||
wallet_2_address = (await env_2.rpc_client.get_next_address(GetNextAddress(cat_wallet_id, False))).address
|
||||
wallet_2_address = (
|
||||
await env_2.rpc_client.get_next_address(GetNextAddress(wallet_id=cat_wallet_id, new_address=False))
|
||||
).address
|
||||
adds = [Addition(puzzle_hash=decode_puzzle_hash(wallet_2_address), amount=uint64(4), memos=["the cat memo"])]
|
||||
tx_res = (
|
||||
await env_1.rpc_client.send_transaction_multi(
|
||||
@@ -1548,14 +1566,14 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
|
||||
test_crs: list[CoinRecord] = (
|
||||
await env_1.rpc_client.get_coin_records_by_names(
|
||||
GetCoinRecordsByNames([a.name() for a in spend_bundle.additions() if a.amount != 4])
|
||||
GetCoinRecordsByNames(names=[a.name() for a in spend_bundle.additions() if a.amount != 4])
|
||||
)
|
||||
).coin_records
|
||||
for cr in test_crs:
|
||||
assert cr.coin in spend_bundle.additions()
|
||||
with pytest.raises(ValueError):
|
||||
await env_1.rpc_client.get_coin_records_by_names(
|
||||
GetCoinRecordsByNames([a.name() for a in spend_bundle.additions() if a.amount == 4])
|
||||
GetCoinRecordsByNames(names=[a.name() for a in spend_bundle.additions() if a.amount == 4])
|
||||
)
|
||||
# Create an offer of 5 chia for one CAT
|
||||
await env_1.rpc_client.create_offer_for_ids(
|
||||
@@ -1585,10 +1603,10 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
)
|
||||
offer = create_res.offer
|
||||
|
||||
offer_summary_response = await env_1.rpc_client.get_offer_summary(GetOfferSummary(offer.to_bech32()))
|
||||
offer_summary_response = await env_1.rpc_client.get_offer_summary(GetOfferSummary(offer=offer.to_bech32()))
|
||||
assert offer_summary_response.id == offer.name()
|
||||
offer_summary_response_advanced = await env_1.rpc_client.get_offer_summary(
|
||||
GetOfferSummary(offer.to_bech32(), advanced=True)
|
||||
GetOfferSummary(offer=offer.to_bech32(), advanced=True)
|
||||
)
|
||||
assert offer_summary_response_advanced.id == offer.name()
|
||||
assert offer_summary_response_advanced.summary == OfferSummary(
|
||||
@@ -1602,7 +1620,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
)
|
||||
assert offer_summary_response_advanced.summary == offer_summary_response.summary
|
||||
|
||||
offer_validity_response = await env_1.rpc_client.check_offer_validity(CheckOfferValidity(offer.to_bech32()))
|
||||
offer_validity_response = await env_1.rpc_client.check_offer_validity(CheckOfferValidity(offer=offer.to_bech32()))
|
||||
assert offer_validity_response.id == offer.name()
|
||||
assert offer_validity_response.valid
|
||||
|
||||
@@ -1637,7 +1655,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
tx_config=wallet_environments.tx_config,
|
||||
)
|
||||
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(offer.name(), file_contents=True))).trade_record
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(trade_id=offer.name(), file_contents=True))).trade_record
|
||||
assert trade_record.offer == bytes(offer)
|
||||
assert TradeStatus(trade_record.status) == TradeStatus.CANCELLED
|
||||
|
||||
@@ -1646,7 +1664,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
tx_config=wallet_environments.tx_config,
|
||||
)
|
||||
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(offer.name()))).trade_record
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(trade_id=offer.name()))).trade_record
|
||||
assert TradeStatus(trade_record.status) == TradeStatus.PENDING_CANCEL
|
||||
|
||||
create_res = await env_1.rpc_client.create_offer_for_ids(
|
||||
@@ -1733,7 +1751,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
)
|
||||
|
||||
async def is_trade_confirmed(client: WalletRpcClient, offer: Offer) -> bool:
|
||||
trade_record = (await client.get_offer(GetOffer(offer.name()))).trade_record
|
||||
trade_record = (await client.get_offer(GetOffer(trade_id=offer.name()))).trade_record
|
||||
return TradeStatus(trade_record.status) == TradeStatus.CONFIRMED
|
||||
|
||||
await time_out_assert(15, is_trade_confirmed, True, env_1.rpc_client, offer)
|
||||
@@ -1742,7 +1760,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
|
||||
def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
|
||||
return [t.trade_id for t in trades]
|
||||
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(offer.name()))).trade_record
|
||||
trade_record = (await env_1.rpc_client.get_offer(GetOffer(trade_id=offer.name()))).trade_record
|
||||
all_offers = ( # confirmed at index descending
|
||||
await env_1.rpc_client.get_all_offers(GetAllOffers(include_completed=True))
|
||||
).trade_records
|
||||
@@ -1987,16 +2005,16 @@ async def test_get_coin_records_by_names(wallet_environments: WalletTestFramewor
|
||||
assert len(coin_ids_unspent) > 0
|
||||
# Do some queries to trigger all parameters
|
||||
# 1. Empty coin_ids
|
||||
assert (await client.get_coin_records_by_names(GetCoinRecordsByNames([]))).coin_records == []
|
||||
assert (await client.get_coin_records_by_names(GetCoinRecordsByNames(names=[]))).coin_records == []
|
||||
# 2. All coins
|
||||
rpc_result = await client.get_coin_records_by_names(GetCoinRecordsByNames(coin_ids + coin_ids_unspent))
|
||||
rpc_result = await client.get_coin_records_by_names(GetCoinRecordsByNames(names=coin_ids + coin_ids_unspent))
|
||||
assert {record.coin for record in rpc_result.coin_records} == {*coins, *coins_unspent}
|
||||
# 3. All spent coins
|
||||
rpc_result = await client.get_coin_records_by_names(GetCoinRecordsByNames(coin_ids, include_spent_coins=True))
|
||||
rpc_result = await client.get_coin_records_by_names(GetCoinRecordsByNames(names=coin_ids, include_spent_coins=True))
|
||||
assert {record.coin for record in rpc_result.coin_records} == coins
|
||||
# 4. All unspent coins
|
||||
rpc_result = await client.get_coin_records_by_names(
|
||||
GetCoinRecordsByNames(coin_ids_unspent, include_spent_coins=False)
|
||||
GetCoinRecordsByNames(names=coin_ids_unspent, include_spent_coins=False)
|
||||
)
|
||||
assert {record.coin for record in rpc_result.coin_records} == coins_unspent
|
||||
# 5. Filter start/end height
|
||||
@@ -2008,12 +2026,12 @@ async def test_get_coin_records_by_names(wallet_environments: WalletTestFramewor
|
||||
max_height = max(record.confirmed_block_height for record in filter_records)
|
||||
assert min_height != max_height
|
||||
rpc_result = await client.get_coin_records_by_names(
|
||||
GetCoinRecordsByNames(filter_coin_ids, start_height=min_height, end_height=max_height)
|
||||
GetCoinRecordsByNames(names=filter_coin_ids, start_height=min_height, end_height=max_height)
|
||||
)
|
||||
assert {record.coin for record in rpc_result.coin_records} == filter_coins
|
||||
# 8. Test the failure case
|
||||
with pytest.raises(ValueError, match="not found"):
|
||||
await client.get_coin_records_by_names(GetCoinRecordsByNames(coin_ids, include_spent_coins=False))
|
||||
await client.get_coin_records_by_names(GetCoinRecordsByNames(names=coin_ids, include_spent_coins=False))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -2062,7 +2080,7 @@ async def test_did_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
await env.change_balances({"nft": {"init": True, "set_remainder": True}})
|
||||
|
||||
# Get wallet name
|
||||
get_name_res = await wallet_1_rpc.did_get_wallet_name(DIDGetWalletName(did_wallet_id_0))
|
||||
get_name_res = await wallet_1_rpc.did_get_wallet_name(DIDGetWalletName(wallet_id=did_wallet_id_0))
|
||||
assert get_name_res.name == "Profile 1"
|
||||
nft_wallet = wallet_1_node.wallet_state_manager.wallets[uint32(did_wallet_id_0 + 1)]
|
||||
assert isinstance(nft_wallet, NFTWallet)
|
||||
@@ -2070,17 +2088,17 @@ async def test_did_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
|
||||
# Set wallet name
|
||||
new_wallet_name = "test name"
|
||||
await wallet_1_rpc.did_set_wallet_name(DIDSetWalletName(did_wallet_id_0, new_wallet_name))
|
||||
get_name_res = await wallet_1_rpc.did_get_wallet_name(DIDGetWalletName(did_wallet_id_0))
|
||||
await wallet_1_rpc.did_set_wallet_name(DIDSetWalletName(wallet_id=did_wallet_id_0, name=new_wallet_name))
|
||||
get_name_res = await wallet_1_rpc.did_get_wallet_name(DIDGetWalletName(wallet_id=did_wallet_id_0))
|
||||
assert get_name_res.name == new_wallet_name
|
||||
with pytest.raises(ValueError, match="wallet id 1 is of type Wallet but type DIDWallet is required"):
|
||||
await wallet_1_rpc.did_set_wallet_name(DIDSetWalletName(wallet_1_id, new_wallet_name))
|
||||
await wallet_1_rpc.did_set_wallet_name(DIDSetWalletName(wallet_id=wallet_1_id, name=new_wallet_name))
|
||||
|
||||
# Check DID ID
|
||||
did_id_res = await wallet_1_rpc.get_did_id(DIDGetDID(did_wallet_id_0))
|
||||
did_id_res = await wallet_1_rpc.get_did_id(DIDGetDID(wallet_id=did_wallet_id_0))
|
||||
assert did_id_0 == did_id_res.my_did
|
||||
# Create backup file
|
||||
await wallet_1_rpc.create_did_backup_file(DIDCreateBackupFile(did_wallet_id_0))
|
||||
await wallet_1_rpc.create_did_backup_file(DIDCreateBackupFile(wallet_id=did_wallet_id_0))
|
||||
|
||||
await wallet_environments.process_pending_states(
|
||||
[
|
||||
@@ -2109,7 +2127,7 @@ async def test_did_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
wallet_environments.tx_config,
|
||||
)
|
||||
|
||||
get_metadata_res = await wallet_1_rpc.get_did_metadata(DIDGetMetadata(did_wallet_id_0))
|
||||
get_metadata_res = await wallet_1_rpc.get_did_metadata(DIDGetMetadata(wallet_id=did_wallet_id_0))
|
||||
assert get_metadata_res.metadata["Twitter"] == "Https://test"
|
||||
|
||||
await wallet_environments.process_pending_states(
|
||||
@@ -2230,7 +2248,7 @@ async def test_did_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
assert next_did_coin.puzzle_hash == last_did_coin.puzzle_hash
|
||||
|
||||
# Test did_get_pubkey
|
||||
pubkey_res = await wallet_2_rpc.get_did_pubkey(DIDGetPubkey(did_wallet_2.id()))
|
||||
pubkey_res = await wallet_2_rpc.get_did_pubkey(DIDGetPubkey(wallet_id=did_wallet_2.id()))
|
||||
assert isinstance(pubkey_res.pubkey, G1Element)
|
||||
|
||||
|
||||
@@ -2302,13 +2320,13 @@ async def test_nft_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
|
||||
# Test with the hex version of nft_id
|
||||
nft_id = (await nft_wallet.get_current_nfts())[0].coin.name().hex()
|
||||
nft_info = (await wallet_1_rpc.get_nft_info(NFTGetInfo(nft_id))).nft_info
|
||||
nft_info = (await wallet_1_rpc.get_nft_info(NFTGetInfo(coin_id=nft_id))).nft_info
|
||||
assert nft_info.nft_coin_id == (await nft_wallet.get_current_nfts())[0].coin.name()
|
||||
# Test with the bech32m version of nft_id
|
||||
hmr_nft_id = encode_puzzle_hash(
|
||||
(await nft_wallet.get_current_nfts())[0].coin.name(), AddressType.NFT.hrp(wallet_1_node.config)
|
||||
)
|
||||
nft_info = (await wallet_1_rpc.get_nft_info(NFTGetInfo(hmr_nft_id))).nft_info
|
||||
nft_info = (await wallet_1_rpc.get_nft_info(NFTGetInfo(coin_id=hmr_nft_id))).nft_info
|
||||
assert nft_info.nft_coin_id == (await nft_wallet.get_current_nfts())[0].coin.name()
|
||||
|
||||
async with wallet_2.wallet_state_manager.new_action_scope(wallet_environments.tx_config, push=True) as action_scope:
|
||||
@@ -2345,12 +2363,12 @@ async def test_nft_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
)[0].id
|
||||
nft_wallet_1 = wallet_2_node.wallet_state_manager.wallets[nft_wallet_id_1]
|
||||
assert isinstance(nft_wallet_1, NFTWallet)
|
||||
nft_info_1 = (await wallet_1_rpc.get_nft_info(NFTGetInfo(nft_id, False))).nft_info
|
||||
nft_info_1 = (await wallet_1_rpc.get_nft_info(NFTGetInfo(coin_id=nft_id, latest=False))).nft_info
|
||||
assert nft_info_1 == nft_info
|
||||
nft_info_1 = (await wallet_1_rpc.get_nft_info(NFTGetInfo(nft_id))).nft_info
|
||||
nft_info_1 = (await wallet_1_rpc.get_nft_info(NFTGetInfo(coin_id=nft_id))).nft_info
|
||||
assert nft_info_1.nft_coin_id == (await nft_wallet_1.get_current_nfts())[0].coin.name()
|
||||
# Cross-check NFT
|
||||
nft_info_2 = (await wallet_2_rpc.list_nfts(NFTGetNFTs(nft_wallet_id_1))).nft_list[0]
|
||||
nft_info_2 = (await wallet_2_rpc.list_nfts(NFTGetNFTs(wallet_id=nft_wallet_id_1))).nft_list[0]
|
||||
assert nft_info_1 == nft_info_2
|
||||
nft_info_2 = (await wallet_2_rpc.list_nfts(NFTGetNFTs())).nft_list[0]
|
||||
assert nft_info_1 == nft_info_2
|
||||
@@ -2359,50 +2377,50 @@ async def test_nft_endpoints(wallet_environments: WalletTestFramework) -> None:
|
||||
with pytest.raises(ValueError, match="Multiple royalty assets with same name specified"):
|
||||
await wallet_1_rpc.nft_calculate_royalties(
|
||||
NFTCalculateRoyalties(
|
||||
[
|
||||
royalty_assets=[
|
||||
RoyaltyAsset(
|
||||
"my asset",
|
||||
"my address",
|
||||
uint16(10000),
|
||||
asset="my asset",
|
||||
royalty_address="my address",
|
||||
royalty_percentage=uint16(10000),
|
||||
),
|
||||
RoyaltyAsset(
|
||||
"my asset",
|
||||
"some other address",
|
||||
uint16(11111),
|
||||
asset="my asset",
|
||||
royalty_address="some other address",
|
||||
royalty_percentage=uint16(11111),
|
||||
),
|
||||
],
|
||||
[],
|
||||
fungible_assets=[],
|
||||
)
|
||||
)
|
||||
with pytest.raises(ValueError, match="Multiple fungible assets with same name specified"):
|
||||
await wallet_1_rpc.nft_calculate_royalties(
|
||||
NFTCalculateRoyalties(
|
||||
[],
|
||||
[
|
||||
royalty_assets=[],
|
||||
fungible_assets=[
|
||||
FungibleAsset(
|
||||
None,
|
||||
uint64(10000),
|
||||
asset=None,
|
||||
amount=uint64(10000),
|
||||
),
|
||||
FungibleAsset(
|
||||
None,
|
||||
uint64(11111),
|
||||
asset=None,
|
||||
amount=uint64(11111),
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
royalty_summary = await wallet_1_rpc.nft_calculate_royalties(
|
||||
NFTCalculateRoyalties(
|
||||
[
|
||||
royalty_assets=[
|
||||
RoyaltyAsset(
|
||||
"my asset",
|
||||
"my address",
|
||||
uint16(10000),
|
||||
asset="my asset",
|
||||
royalty_address="my address",
|
||||
royalty_percentage=uint16(10000),
|
||||
)
|
||||
],
|
||||
[
|
||||
fungible_assets=[
|
||||
FungibleAsset(
|
||||
None,
|
||||
uint64(10000),
|
||||
asset=None,
|
||||
amount=uint64(10000),
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -2439,19 +2457,19 @@ async def _check_delete_key(
|
||||
save_config(wallet_node.root_path, "config.yaml", test_config)
|
||||
|
||||
# Check farmer_fp key
|
||||
resp = await client.check_delete_key(CheckDeleteKey(uint32(farmer_fp)))
|
||||
resp = await client.check_delete_key(CheckDeleteKey(fingerprint=uint32(farmer_fp)))
|
||||
assert resp.fingerprint == farmer_fp
|
||||
assert resp.used_for_farmer_rewards is True
|
||||
assert resp.used_for_pool_rewards is False
|
||||
|
||||
# Check pool_fp key
|
||||
resp = await client.check_delete_key(CheckDeleteKey(uint32(pool_fp)))
|
||||
resp = await client.check_delete_key(CheckDeleteKey(fingerprint=uint32(pool_fp)))
|
||||
assert resp.fingerprint == pool_fp
|
||||
assert resp.used_for_farmer_rewards is False
|
||||
assert resp.used_for_pool_rewards is True
|
||||
|
||||
# Check unknown key
|
||||
resp = await client.check_delete_key(CheckDeleteKey(uint32(123456), uint16(10)))
|
||||
resp = await client.check_delete_key(CheckDeleteKey(fingerprint=uint32(123456), max_ph_to_search=uint16(10)))
|
||||
assert resp.fingerprint == 123456
|
||||
assert resp.used_for_farmer_rewards is False
|
||||
assert resp.used_for_pool_rewards is False
|
||||
@@ -2471,7 +2489,7 @@ async def test_key_and_address_endpoints(wallet_environments: WalletTestFramewor
|
||||
wallet_node: WalletNode = env.node
|
||||
client: WalletRpcClient = env.rpc_client
|
||||
|
||||
address = (await client.get_next_address(GetNextAddress(uint32(1), True))).address
|
||||
address = (await client.get_next_address(GetNextAddress(wallet_id=uint32(1), new_address=True))).address
|
||||
assert len(address) > 10
|
||||
|
||||
pks = (await client.get_public_keys()).pk_fingerprints
|
||||
@@ -2493,23 +2511,23 @@ async def test_key_and_address_endpoints(wallet_environments: WalletTestFramewor
|
||||
|
||||
await time_out_assert(20, tx_in_mempool, True, client, created_tx.name)
|
||||
assert len(await wallet.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(1)) == 1
|
||||
await client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(uint32(1)))
|
||||
await client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(wallet_id=uint32(1)))
|
||||
assert len(await wallet.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(1)) == 0
|
||||
|
||||
sk_resp = await client.get_private_key(GetPrivateKey(pks[0]))
|
||||
sk_resp = await client.get_private_key(GetPrivateKey(fingerprint=pks[0]))
|
||||
assert sk_resp.private_key.fingerprint == pks[0]
|
||||
assert sk_resp.private_key.seed is not None
|
||||
|
||||
resp = await client.generate_mnemonic()
|
||||
assert len(resp.mnemonic) == 24
|
||||
|
||||
await client.add_key(AddKey(resp.mnemonic))
|
||||
await client.add_key(AddKey(mnemonic=resp.mnemonic))
|
||||
|
||||
pks = (await client.get_public_keys()).pk_fingerprints
|
||||
assert len(pks) == 2
|
||||
|
||||
await client.log_in(LogIn(pks[1]))
|
||||
sk_resp = await client.get_private_key(GetPrivateKey(pks[1]))
|
||||
await client.log_in(LogIn(fingerprint=pks[1]))
|
||||
sk_resp = await client.get_private_key(GetPrivateKey(fingerprint=pks[1]))
|
||||
assert sk_resp.private_key.fingerprint == pks[1]
|
||||
|
||||
# test hardened keys
|
||||
@@ -2524,7 +2542,7 @@ async def test_key_and_address_endpoints(wallet_environments: WalletTestFramewor
|
||||
save_config(wallet_node.root_path, "config.yaml", test_config)
|
||||
|
||||
# Check key
|
||||
delete_key_resp = await client.check_delete_key(CheckDeleteKey(pks[1]))
|
||||
delete_key_resp = await client.check_delete_key(CheckDeleteKey(fingerprint=pks[1]))
|
||||
assert delete_key_resp.fingerprint == pks[1]
|
||||
assert delete_key_resp.used_for_farmer_rewards is False
|
||||
assert delete_key_resp.used_for_pool_rewards is True
|
||||
@@ -2536,15 +2554,15 @@ async def test_key_and_address_endpoints(wallet_environments: WalletTestFramewor
|
||||
save_config(wallet_node.root_path, "config.yaml", test_config)
|
||||
|
||||
# Check key
|
||||
delete_key_resp = await client.check_delete_key(CheckDeleteKey(pks[0]))
|
||||
delete_key_resp = await client.check_delete_key(CheckDeleteKey(fingerprint=pks[0]))
|
||||
assert delete_key_resp.fingerprint == pks[0]
|
||||
assert delete_key_resp.used_for_farmer_rewards is False
|
||||
assert delete_key_resp.used_for_pool_rewards is False
|
||||
|
||||
assert get_wallet_db_path(wallet_node.root_path, wallet_node.config, str(pks[0])).exists()
|
||||
await client.delete_key(DeleteKey(pks[0]))
|
||||
await client.delete_key(DeleteKey(fingerprint=pks[0]))
|
||||
assert not get_wallet_db_path(wallet_node.root_path, wallet_node.config, str(pks[0])).exists()
|
||||
await client.log_in(LogIn(uint32(pks[1])))
|
||||
await client.log_in(LogIn(fingerprint=uint32(pks[1])))
|
||||
assert len((await client.get_public_keys()).pk_fingerprints) == 1
|
||||
|
||||
assert not (await client.get_sync_status()).synced
|
||||
@@ -2561,7 +2579,7 @@ async def test_key_and_address_endpoints(wallet_environments: WalletTestFramewor
|
||||
|
||||
# Delete all keys
|
||||
resp = await client.generate_mnemonic()
|
||||
add_key_resp = await client.add_key(AddKey(resp.mnemonic))
|
||||
add_key_resp = await client.add_key(AddKey(mnemonic=resp.mnemonic))
|
||||
assert get_wallet_db_path(wallet_node.root_path, wallet_node.config, str(pks[1])).exists()
|
||||
assert get_wallet_db_path(wallet_node.root_path, wallet_node.config, str(add_key_resp.fingerprint)).exists()
|
||||
await client.delete_all_keys()
|
||||
@@ -2957,13 +2975,20 @@ async def test_notification_rpcs(wallet_environments: WalletTestFramework) -> No
|
||||
)
|
||||
|
||||
notification = (await client_2.get_notifications(GetNotifications())).notifications[0]
|
||||
assert [notification] == (await client_2.get_notifications(GetNotifications([notification.id]))).notifications
|
||||
assert [] == (await client_2.get_notifications(GetNotifications(None, uint32(0), uint32(0)))).notifications
|
||||
assert [notification] == (await client_2.get_notifications(GetNotifications(None, None, uint32(1)))).notifications
|
||||
assert [] == (await client_2.get_notifications(GetNotifications(None, uint32(1), None))).notifications
|
||||
assert [notification] == (await client_2.get_notifications(GetNotifications(None, None, None))).notifications
|
||||
assert [notification] == (await client_2.get_notifications(GetNotifications(ids=[notification.id]))).notifications
|
||||
assert (
|
||||
[]
|
||||
== (await client_2.get_notifications(GetNotifications(ids=None, start=uint32(0), end=uint32(0)))).notifications
|
||||
)
|
||||
assert [notification] == (
|
||||
await client_2.get_notifications(GetNotifications(ids=None, start=None, end=uint32(1)))
|
||||
).notifications
|
||||
assert [] == (await client_2.get_notifications(GetNotifications(ids=None, start=uint32(1), end=None))).notifications
|
||||
assert [notification] == (
|
||||
await client_2.get_notifications(GetNotifications(ids=None, start=None, end=None))
|
||||
).notifications
|
||||
await client_2.delete_notifications(DeleteNotifications())
|
||||
assert [] == (await client_2.get_notifications(GetNotifications([notification.id]))).notifications
|
||||
assert [] == (await client_2.get_notifications(GetNotifications(ids=[notification.id]))).notifications
|
||||
|
||||
async with wallet_2.wallet_state_manager.new_action_scope(wallet_environments.tx_config, push=True) as action_scope:
|
||||
await client.send_notification(
|
||||
@@ -2999,8 +3024,8 @@ async def test_notification_rpcs(wallet_environments: WalletTestFramework) -> No
|
||||
)
|
||||
|
||||
notification = (await client_2.get_notifications(GetNotifications())).notifications[0]
|
||||
await client_2.delete_notifications(DeleteNotifications([notification.id]))
|
||||
assert [] == (await client_2.get_notifications(GetNotifications([notification.id]))).notifications
|
||||
await client_2.delete_notifications(DeleteNotifications(ids=[notification.id]))
|
||||
assert [] == (await client_2.get_notifications(GetNotifications(ids=[notification.id]))).notifications
|
||||
|
||||
|
||||
# The signatures below were made from an ephemeral key pair that isn't included in the test code.
|
||||
@@ -3185,8 +3210,10 @@ async def test_sign_message_by_address(wallet_environments: WalletTestFramework)
|
||||
client: WalletRpcClient = wallet_environments.environments[0].rpc_client
|
||||
|
||||
message = "foo"
|
||||
address = await client.get_next_address(GetNextAddress(uint32(1)))
|
||||
signed_message = await client.sign_message_by_address(SignMessageByAddress(address.address, message))
|
||||
address = await client.get_next_address(GetNextAddress(wallet_id=uint32(1)))
|
||||
signed_message = await client.sign_message_by_address(
|
||||
SignMessageByAddress(address=address.address, message=message)
|
||||
)
|
||||
|
||||
await wallet_environments.environments[0].rpc_client.verify_signature(
|
||||
VerifySignature(
|
||||
@@ -3251,7 +3278,7 @@ async def test_set_wallet_resync_on_startup(wallet_environments: WalletTestFrame
|
||||
wallet_environments.tx_config,
|
||||
)
|
||||
nft_wallet_id = nft_wallet_res.wallet_id
|
||||
address = (await wc.get_next_address(GetNextAddress(env.xch_wallet.id(), True))).address
|
||||
address = (await wc.get_next_address(GetNextAddress(wallet_id=env.xch_wallet.id(), new_address=True))).address
|
||||
await wc.mint_nft(
|
||||
request=NFTMintNFTRequest(
|
||||
wallet_id=nft_wallet_id,
|
||||
@@ -3412,7 +3439,7 @@ async def test_set_wallet_resync_on_startup_disable(wallet_environments: WalletT
|
||||
assert wallet_node._wallet_state_manager
|
||||
assert len(await wallet_node._wallet_state_manager.coin_store.get_all_unspent_coins()) == 2
|
||||
before_txs = await wallet_node.wallet_state_manager.tx_store.get_all_transactions()
|
||||
await client.set_wallet_resync_on_startup(SetWalletResyncOnStartup(False))
|
||||
await client.set_wallet_resync_on_startup(SetWalletResyncOnStartup(enable=False))
|
||||
wallet_node._close()
|
||||
await wallet_node._await_closed()
|
||||
config = load_config(wallet_node.root_path, "config.yaml")
|
||||
@@ -3660,7 +3687,7 @@ async def test_get_balances(wallet_environments: WalletTestFramework) -> None:
|
||||
assert bals_response.wallet_balances[uint32(1)].confirmed_wallet_balance == 1999999999880
|
||||
assert bals_response.wallet_balances[uint32(2)].confirmed_wallet_balance == 100
|
||||
assert bals_response.wallet_balances[uint32(3)].confirmed_wallet_balance == 20
|
||||
bals_response = await client.get_wallet_balances(GetWalletBalances([uint32(3), uint32(2)]))
|
||||
bals_response = await client.get_wallet_balances(GetWalletBalances(wallet_ids=[uint32(3), uint32(2)]))
|
||||
assert len(bals_response.wallet_balances) == 2
|
||||
assert bals_response.wallet_balances[uint32(2)].confirmed_wallet_balance == 100
|
||||
assert bals_response.wallet_balances[uint32(3)].confirmed_wallet_balance == 20
|
||||
@@ -3845,7 +3872,7 @@ async def test_split_coins(wallet_environments: WalletTestFramework, capsys: pyt
|
||||
assert xch_request.rpc_info.client_info is not None
|
||||
|
||||
async def not_synced() -> GetSyncStatusResponse:
|
||||
return GetSyncStatusResponse(False, False)
|
||||
return GetSyncStatusResponse(synced=False, syncing=False)
|
||||
|
||||
xch_request.rpc_info.client_info.client.get_sync_status = not_synced # type: ignore[method-assign]
|
||||
await xch_request.run()
|
||||
@@ -4067,7 +4094,7 @@ async def test_combine_coins(wallet_environments: WalletTestFramework, capsys: p
|
||||
assert xch_combine_request.rpc_info.client_info is not None
|
||||
|
||||
async def not_synced() -> GetSyncStatusResponse:
|
||||
return GetSyncStatusResponse(False, False)
|
||||
return GetSyncStatusResponse(synced=False, syncing=False)
|
||||
|
||||
xch_combine_request.rpc_info.client_info.client.get_sync_status = not_synced # type: ignore[method-assign]
|
||||
await xch_combine_request.run()
|
||||
|
||||
@@ -256,7 +256,7 @@ async def test_list(wallet_environments: WalletTestFramework, capsys: pytest.Cap
|
||||
assert base_command.rpc_info.client_info is not None
|
||||
|
||||
async def not_synced() -> GetSyncStatusResponse:
|
||||
return GetSyncStatusResponse(False, False)
|
||||
return GetSyncStatusResponse(synced=False, syncing=False)
|
||||
|
||||
base_command.rpc_info.client_info.client.get_sync_status = not_synced # type: ignore[method-assign]
|
||||
await base_command.run()
|
||||
|
||||
@@ -178,7 +178,9 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
|
||||
assert utx.signing_instructions.targets[0].message == message
|
||||
|
||||
signing_responses: list[SigningResponse] = (
|
||||
await wallet_rpc.execute_signing_instructions(ExecuteSigningInstructions(utx.signing_instructions))
|
||||
await wallet_rpc.execute_signing_instructions(
|
||||
ExecuteSigningInstructions(signing_instructions=utx.signing_instructions)
|
||||
)
|
||||
).signing_responses
|
||||
assert len(signing_responses) == 1
|
||||
assert signing_responses[0].hook == utx.signing_instructions.targets[0].hook
|
||||
@@ -288,7 +290,7 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
|
||||
|
||||
# And test that we can get compressed versions if we want
|
||||
request = GatherSigningInfo(
|
||||
[Spend.from_coin_spend(coin_spend), Spend.from_coin_spend(not_our_coin_spend)]
|
||||
spends=[Spend.from_coin_spend(coin_spend), Spend.from_coin_spend(not_our_coin_spend)]
|
||||
).to_json_dict()
|
||||
response_dict = await wallet_rpc.fetch("gather_signing_info", {"translation": "chip-0029", **request})
|
||||
response: GatherSigningInfoResponse = json_deserialize_with_clvm_streamable(
|
||||
|
||||
@@ -425,7 +425,7 @@ async def test_puzzle_hash_requests(wallet_environments: WalletTestFramework) ->
|
||||
(0,),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(uint32(0)))
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(index=uint32(0)))
|
||||
|
||||
# Reset to a normal state
|
||||
await wsm.puzzle_store.delete_wallet(wsm.main_wallet.id())
|
||||
@@ -436,17 +436,17 @@ async def test_puzzle_hash_requests(wallet_environments: WalletTestFramework) ->
|
||||
|
||||
# Test an index already created
|
||||
with pytest.raises(ValueError):
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(uint32(0)))
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(index=uint32(0)))
|
||||
|
||||
# Test an index too far in the future
|
||||
with pytest.raises(ValueError):
|
||||
await rpc_client.extend_derivation_index(
|
||||
ExtendDerivationIndex(uint32(MAX_DERIVATION_INDEX_DELTA + expected_state.highest_index + 1))
|
||||
ExtendDerivationIndex(index=uint32(MAX_DERIVATION_INDEX_DELTA + expected_state.highest_index + 1))
|
||||
)
|
||||
|
||||
# Test the actual functionality
|
||||
assert (
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(uint32(expected_state.highest_index + 5)))
|
||||
await rpc_client.extend_derivation_index(ExtendDerivationIndex(index=uint32(expected_state.highest_index + 5)))
|
||||
).index == expected_state.highest_index + 5
|
||||
expected_state = PuzzleHashState(expected_state.highest_index + 5, expected_state.used_up_to_index)
|
||||
assert await get_puzzle_hash_state() == expected_state
|
||||
|
||||
@@ -240,7 +240,7 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None:
|
||||
WalletStateTransition(),
|
||||
]
|
||||
)
|
||||
new_vc_record: VCRecord | None = (await client_0.vc_get(VCGet(vc_record.vc.launcher_id))).vc_record
|
||||
new_vc_record: VCRecord | None = (await client_0.vc_get(VCGet(vc_id=vc_record.vc.launcher_id))).vc_record
|
||||
assert new_vc_record is not None
|
||||
|
||||
# Spend VC
|
||||
@@ -296,7 +296,7 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None:
|
||||
WalletStateTransition(),
|
||||
]
|
||||
)
|
||||
vc_record_updated: VCRecord | None = (await client_0.vc_get(VCGet(vc_record.vc.launcher_id))).vc_record
|
||||
vc_record_updated: VCRecord | None = (await client_0.vc_get(VCGet(vc_id=vc_record.vc.launcher_id))).vc_record
|
||||
assert vc_record_updated is not None
|
||||
assert vc_record_updated.vc.proof_hash == proof_root
|
||||
|
||||
@@ -325,7 +325,7 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None:
|
||||
# Doing it again just to make sure it doesn't care
|
||||
await client_0.vc_add_proofs(VCAddProofs.from_vc_proofs(proofs))
|
||||
assert (
|
||||
await client_0.vc_get_proofs_for_root(VCGetProofsForRoot(proof_root))
|
||||
await client_0.vc_get_proofs_for_root(VCGetProofsForRoot(root=proof_root))
|
||||
).to_vc_proofs().key_value_pairs == proofs.key_value_pairs
|
||||
get_list_reponse = await client_0.vc_get_list(VCGetList())
|
||||
assert len(get_list_reponse.vc_records) == 1
|
||||
@@ -467,9 +467,9 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None:
|
||||
pending_tx = (
|
||||
await client_1.get_transactions(
|
||||
GetTransactions(
|
||||
uint32(env_1.dealias_wallet_id("crcat")),
|
||||
uint32(0),
|
||||
uint32(1),
|
||||
wallet_id=uint32(env_1.dealias_wallet_id("crcat")),
|
||||
start=uint32(0),
|
||||
end=uint32(1),
|
||||
reverse=True,
|
||||
type_filter=TransactionTypeFilter.include([TransactionType.INCOMING_CRCAT_PENDING]),
|
||||
)
|
||||
@@ -637,7 +637,7 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None:
|
||||
),
|
||||
]
|
||||
)
|
||||
vc_record_updated = (await client_1.vc_get(VCGet(vc_record_updated.vc.launcher_id))).vc_record
|
||||
vc_record_updated = (await client_1.vc_get(VCGet(vc_id=vc_record_updated.vc.launcher_id))).vc_record
|
||||
assert vc_record_updated is not None
|
||||
|
||||
# Revoke VC
|
||||
@@ -753,7 +753,7 @@ async def test_self_revoke(wallet_environments: WalletTestFramework) -> None:
|
||||
)
|
||||
]
|
||||
)
|
||||
new_vc_record: VCRecord | None = (await client_0.vc_get(VCGet(vc_record.vc.launcher_id))).vc_record
|
||||
new_vc_record: VCRecord | None = (await client_0.vc_get(VCGet(vc_id=vc_record.vc.launcher_id))).vc_record
|
||||
assert new_vc_record is not None
|
||||
|
||||
# Test a negative case real quick (mostly unrelated)
|
||||
@@ -809,7 +809,7 @@ async def test_self_revoke(wallet_environments: WalletTestFramework) -> None:
|
||||
)
|
||||
]
|
||||
)
|
||||
vc_record_revoked: VCRecord | None = (await client_0.vc_get(VCGet(vc_record.vc.launcher_id))).vc_record
|
||||
vc_record_revoked: VCRecord | None = (await client_0.vc_get(VCGet(vc_id=vc_record.vc.launcher_id))).vc_record
|
||||
assert vc_record_revoked is None
|
||||
assert (
|
||||
len(await (await wallet_node_0.wallet_state_manager.get_or_create_vc_wallet()).store.get_unconfirmed_vcs()) == 0
|
||||
|
||||
@@ -236,7 +236,7 @@ async def get_wallet(root_path: Path, wallet_client: WalletRpcClient, fingerprin
|
||||
|
||||
if selected_fingerprint is not None:
|
||||
try:
|
||||
await wallet_client.log_in(LogIn(uint32(selected_fingerprint)))
|
||||
await wallet_client.log_in(LogIn(fingerprint=uint32(selected_fingerprint)))
|
||||
except ValueError as e:
|
||||
raise CliRpcConnectionError(f"Login failed for fingerprint {selected_fingerprint}: {e.args[0]}")
|
||||
|
||||
|
||||
@@ -221,14 +221,14 @@ async def async_split(
|
||||
return []
|
||||
|
||||
if number_of_coins is None:
|
||||
response = await client_info.client.get_coin_records_by_names(GetCoinRecordsByNames([target_coin_id]))
|
||||
response = await client_info.client.get_coin_records_by_names(GetCoinRecordsByNames(names=[target_coin_id]))
|
||||
if len(response.coin_records) == 0:
|
||||
print("Could not find target coin.")
|
||||
return []
|
||||
assert amount_per_coin is not None
|
||||
number_of_coins = int(response.coin_records[0].coin.amount // amount_per_coin.convert_amount(mojo_per_unit))
|
||||
elif amount_per_coin is None:
|
||||
response = await client_info.client.get_coin_records_by_names(GetCoinRecordsByNames([target_coin_id]))
|
||||
response = await client_info.client.get_coin_records_by_names(GetCoinRecordsByNames(names=[target_coin_id]))
|
||||
if len(response.coin_records) == 0:
|
||||
print("Could not find target coin.")
|
||||
return []
|
||||
|
||||
@@ -57,7 +57,7 @@ async def get_wallets_stats(
|
||||
include_pool_rewards: bool,
|
||||
) -> GetFarmedAmountResponse | None:
|
||||
async with get_any_service_client(WalletRpcClient, root_path, wallet_rpc_port) as (wallet_client, _):
|
||||
return await wallet_client.get_farmed_amount(GetFarmedAmount(include_pool_rewards))
|
||||
return await wallet_client.get_farmed_amount(GetFarmedAmount(include_pool_rewards=include_pool_rewards))
|
||||
|
||||
|
||||
async def get_challenges(root_path: Path, farmer_rpc_port: int | None) -> list[dict[str, Any]] | None:
|
||||
|
||||
@@ -132,7 +132,9 @@ async def create(
|
||||
while time.time() - start < 10:
|
||||
await asyncio.sleep(0.1)
|
||||
tx = (
|
||||
await wallet_info.client.get_transaction(GetTransaction(create_response.transaction.name))
|
||||
await wallet_info.client.get_transaction(
|
||||
GetTransaction(transaction_id=create_response.transaction.name)
|
||||
)
|
||||
).transaction
|
||||
if len(tx.sent_to) > 0:
|
||||
print(transaction_submitted_msg(tx))
|
||||
@@ -174,7 +176,9 @@ async def pprint_pool_wallet_state(
|
||||
print(f"Target state: {PoolSingletonState(pool_wallet_info.target.state).name}")
|
||||
print(f"Target pool URL: {pool_wallet_info.target.pool_url}")
|
||||
if pool_wallet_info.current.state == PoolSingletonState.SELF_POOLING.value:
|
||||
balances = (await wallet_client.get_wallet_balance(GetWalletBalance(uint32(wallet_id)))).wallet_balance
|
||||
balances = (
|
||||
await wallet_client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(wallet_id)))
|
||||
).wallet_balance
|
||||
balance = balances.confirmed_wallet_balance
|
||||
typ = WalletType(int(WalletType.POOLING_WALLET))
|
||||
address_prefix, scale = wallet_coin_unit(typ, address_prefix)
|
||||
@@ -219,7 +223,7 @@ async def pprint_all_pool_wallet_state(
|
||||
pool_wallet_id = wallet_info.id
|
||||
typ = WalletType(int(wallet_info.type))
|
||||
if typ == WalletType.POOLING_WALLET:
|
||||
pool_wallet_info = (await wallet_client.pw_status(PWStatus(uint32(pool_wallet_id)))).state
|
||||
pool_wallet_info = (await wallet_client.pw_status(PWStatus(wallet_id=uint32(pool_wallet_id)))).state
|
||||
await pprint_pool_wallet_state(
|
||||
wallet_client,
|
||||
pool_wallet_id,
|
||||
@@ -252,7 +256,9 @@ async def show(
|
||||
for pool_state_item in pool_state_list
|
||||
}
|
||||
if wallet_id_passed_in is not None:
|
||||
pool_wallet_info = (await wallet_info.client.pw_status(PWStatus(uint32(wallet_id_passed_in)))).state
|
||||
pool_wallet_info = (
|
||||
await wallet_info.client.pw_status(PWStatus(wallet_id=uint32(wallet_id_passed_in)))
|
||||
).state
|
||||
await pprint_pool_wallet_state(
|
||||
wallet_info.client,
|
||||
wallet_id_passed_in,
|
||||
@@ -298,7 +304,7 @@ async def submit_tx_with_confirmation(
|
||||
continue
|
||||
while time.time() - start < 10:
|
||||
await asyncio.sleep(0.1)
|
||||
tx = (await wallet_client.get_transaction(GetTransaction(tx_record.name))).transaction
|
||||
tx = (await wallet_client.get_transaction(GetTransaction(transaction_id=tx_record.name))).transaction
|
||||
if len(tx.sent_to) > 0:
|
||||
print(transaction_submitted_msg(tx))
|
||||
print(transaction_status_msg(fingerprint, tx_record.name))
|
||||
@@ -346,7 +352,7 @@ async def join_pool(
|
||||
if not sync_status.synced:
|
||||
raise click.ClickException("Wallet must be synced before joining a pool.")
|
||||
|
||||
pool_wallet_info = (await wallet_info.client.pw_status(PWStatus(uint32(selected_wallet_id)))).state
|
||||
pool_wallet_info = (await wallet_info.client.pw_status(PWStatus(wallet_id=uint32(selected_wallet_id)))).state
|
||||
if (
|
||||
pool_wallet_info.current.state == PoolSingletonState.FARMING_TO_POOL.value
|
||||
and pool_wallet_info.current.pool_url == pool_url
|
||||
@@ -418,7 +424,7 @@ async def self_pool(*, wallet_info: WalletClientInfo, fee: uint64, wallet_id: in
|
||||
|
||||
async def inspect_cmd(wallet_info: WalletClientInfo, wallet_id: int | None) -> None:
|
||||
selected_wallet_id = await wallet_id_lookup_and_check(wallet_info.client, wallet_id)
|
||||
res = await wallet_info.client.pw_status(PWStatus(uint32(selected_wallet_id)))
|
||||
res = await wallet_info.client.pw_status(PWStatus(wallet_id=uint32(selected_wallet_id)))
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
|
||||
+72
-51
@@ -265,7 +265,7 @@ async def get_transactions(
|
||||
txs = (
|
||||
await wallet_client.get_transactions(
|
||||
GetTransactions(
|
||||
uint32(wallet_id),
|
||||
wallet_id=uint32(wallet_id),
|
||||
start=uint32(offset),
|
||||
end=uint32(offset + limit),
|
||||
sort_key=sort_key.name,
|
||||
@@ -394,7 +394,8 @@ async def send(
|
||||
puzzle_decorator=(
|
||||
[
|
||||
ClawbackPuzzleDecoratorOverride(
|
||||
PuzzleDecoratorType.CLAWBACK.name, clawback_timelock=uint64(clawback_time_lock)
|
||||
decorator=PuzzleDecoratorType.CLAWBACK.name,
|
||||
clawback_timelock=uint64(clawback_time_lock),
|
||||
)
|
||||
]
|
||||
if clawback_time_lock > 0
|
||||
@@ -437,7 +438,7 @@ async def send(
|
||||
start = time.time()
|
||||
while time.time() - start < 10:
|
||||
await asyncio.sleep(0.1)
|
||||
tx = (await wallet_client.get_transaction(GetTransaction(tx_id))).transaction
|
||||
tx = (await wallet_client.get_transaction(GetTransaction(transaction_id=tx_id))).transaction
|
||||
if len(tx.sent_to) > 0:
|
||||
print(transaction_submitted_msg(tx))
|
||||
print(transaction_status_msg(fingerprint, tx_id))
|
||||
@@ -454,7 +455,9 @@ async def get_address(
|
||||
root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, wallet_id: int, new_address: bool
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
res = (await wallet_client.get_next_address(GetNextAddress(uint32(wallet_id), new_address))).address
|
||||
res = (
|
||||
await wallet_client.get_next_address(GetNextAddress(wallet_id=uint32(wallet_id), new_address=new_address))
|
||||
).address
|
||||
print(res)
|
||||
|
||||
|
||||
@@ -462,7 +465,7 @@ async def delete_unconfirmed_transactions(
|
||||
root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, wallet_id: int
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, fingerprint, _):
|
||||
await wallet_client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(uint32(wallet_id)))
|
||||
await wallet_client.delete_unconfirmed_transactions(DeleteUnconfirmedTransactions(wallet_id=uint32(wallet_id)))
|
||||
print(f"Successfully deleted all unconfirmed transactions for wallet id {wallet_id} on key {fingerprint}")
|
||||
|
||||
|
||||
@@ -477,7 +480,7 @@ async def update_derivation_index(
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
print("Updating derivation index... This may take a while.")
|
||||
res = await wallet_client.extend_derivation_index(ExtendDerivationIndex(uint32(index)))
|
||||
res = await wallet_client.extend_derivation_index(ExtendDerivationIndex(index=uint32(index)))
|
||||
print(f"Updated derivation index: {res.index}")
|
||||
print("Your balances may take a while to update.")
|
||||
|
||||
@@ -486,7 +489,7 @@ async def add_token(
|
||||
root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, asset_id: bytes32, token_name: str
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, fingerprint, _):
|
||||
existing_info = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(asset_id))
|
||||
existing_info = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(asset_id=asset_id))
|
||||
|
||||
if existing_info.wallet_id is None:
|
||||
response = await wallet_client.create_new_wallet(
|
||||
@@ -499,10 +502,10 @@ async def add_token(
|
||||
tx_config=DEFAULT_TX_CONFIG,
|
||||
)
|
||||
wallet_id = response.wallet_id
|
||||
await wallet_client.set_cat_name(CATSetName(wallet_id, token_name))
|
||||
await wallet_client.set_cat_name(CATSetName(wallet_id=wallet_id, name=token_name))
|
||||
print(f"Successfully added {token_name} with wallet id {wallet_id} on key {fingerprint}")
|
||||
else:
|
||||
await wallet_client.set_cat_name(CATSetName(existing_info.wallet_id, token_name))
|
||||
await wallet_client.set_cat_name(CATSetName(wallet_id=existing_info.wallet_id, name=token_name))
|
||||
print(
|
||||
f"Successfully renamed {existing_info.name} with wallet_id {existing_info.wallet_id}"
|
||||
f" on key {fingerprint} to {token_name}"
|
||||
@@ -535,21 +538,23 @@ async def make_offer(
|
||||
try:
|
||||
b32_id = bytes32.from_hexstr(name)
|
||||
id: str = b32_id.hex()
|
||||
result = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(b32_id))
|
||||
result = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(asset_id=b32_id))
|
||||
if result.name is not None:
|
||||
name = result.name
|
||||
else:
|
||||
name = "Unknown CAT"
|
||||
unit = units["cat"]
|
||||
if item in offers:
|
||||
fungible_assets.append(FungibleAsset(name, uint64(abs(int(Decimal(amount) * unit)))))
|
||||
fungible_assets.append(
|
||||
FungibleAsset(asset=name, amount=uint64(abs(int(Decimal(amount) * unit))))
|
||||
)
|
||||
except ValueError:
|
||||
try:
|
||||
hrp, _ = bech32_decode(name)
|
||||
if hrp == "nft":
|
||||
coin_id = decode_puzzle_hash(name)
|
||||
unit = 1
|
||||
info = (await wallet_client.get_nft_info(NFTGetInfo(coin_id.hex()))).nft_info
|
||||
info = (await wallet_client.get_nft_info(NFTGetInfo(coin_id=coin_id.hex()))).nft_info
|
||||
id = info.launcher_id.hex()
|
||||
assert isinstance(id, str)
|
||||
if item in requests:
|
||||
@@ -578,9 +583,11 @@ async def make_offer(
|
||||
}
|
||||
royalty_assets.append(
|
||||
RoyaltyAsset(
|
||||
name,
|
||||
encode_puzzle_hash(info.royalty_puzzle_hash, AddressType.XCH.hrp(config)),
|
||||
info.royalty_percentage,
|
||||
asset=name,
|
||||
royalty_address=encode_puzzle_hash(
|
||||
info.royalty_puzzle_hash, AddressType.XCH.hrp(config)
|
||||
),
|
||||
royalty_percentage=info.royalty_percentage,
|
||||
)
|
||||
)
|
||||
driver_dict[info.launcher_id] = PuzzleInfo(puzzle_info_dict)
|
||||
@@ -594,10 +601,12 @@ async def make_offer(
|
||||
name = "XCH"
|
||||
unit = units["chia"]
|
||||
else:
|
||||
name = (await wallet_client.get_cat_name(CATGetName(uint32(name)))).name
|
||||
name = (await wallet_client.get_cat_name(CATGetName(wallet_id=uint32(name)))).name
|
||||
unit = units["cat"]
|
||||
if item in offers:
|
||||
fungible_assets.append(FungibleAsset(name, uint64(abs(int(Decimal(amount) * unit)))))
|
||||
fungible_assets.append(
|
||||
FungibleAsset(asset=name, amount=uint64(abs(int(Decimal(amount) * unit))))
|
||||
)
|
||||
multiplier: int = -1 if item in offers else 1
|
||||
printable_dict[name] = (amount, unit, multiplier)
|
||||
if id in offer_dict:
|
||||
@@ -626,7 +635,7 @@ async def make_offer(
|
||||
|
||||
if len(royalty_assets) > 0:
|
||||
royalty_summary: NFTCalculateRoyaltiesResponse = await wallet_client.nft_calculate_royalties(
|
||||
NFTCalculateRoyalties(royalty_assets, fungible_assets)
|
||||
NFTCalculateRoyalties(royalty_assets=royalty_assets, fungible_assets=fungible_assets)
|
||||
)
|
||||
total_amounts_requested: dict[Any, int] = {}
|
||||
print()
|
||||
@@ -704,7 +713,7 @@ async def print_offer_summary(
|
||||
description = " [Typically represents change returned from the included fee]"
|
||||
else:
|
||||
unit = units["cat"]
|
||||
result = await cat_name_resolver(CATAssetIDToName(bytes32.from_hexstr(asset_id)))
|
||||
result = await cat_name_resolver(CATAssetIDToName(asset_id=bytes32.from_hexstr(asset_id)))
|
||||
if result.name is not None:
|
||||
wid = str(result.wallet_id)
|
||||
name = result.name
|
||||
@@ -807,7 +816,9 @@ async def get_offers(
|
||||
start = end
|
||||
end += batch_size
|
||||
else:
|
||||
records = [(await wallet_client.get_offer(GetOffer(offer_id, file_contents))).trade_record]
|
||||
records = [
|
||||
(await wallet_client.get_offer(GetOffer(trade_id=offer_id, file_contents=file_contents))).trade_record
|
||||
]
|
||||
if filepath is not None:
|
||||
with open(pathlib.Path(filepath), "w") as file:
|
||||
file.write(Offer.from_bytes(records[0].offer).to_bech32())
|
||||
@@ -859,9 +870,9 @@ async def take_offer(
|
||||
percentage, address = await get_nft_royalty_percentage_and_address(royalty_asset_id, wallet_client)
|
||||
royalty_assets.append(
|
||||
RoyaltyAsset(
|
||||
encode_puzzle_hash(royalty_asset_id, AddressType.NFT.hrp(config)),
|
||||
encode_puzzle_hash(address, AddressType.XCH.hrp(config)),
|
||||
percentage,
|
||||
asset=encode_puzzle_hash(royalty_asset_id, AddressType.NFT.hrp(config)),
|
||||
royalty_address=encode_puzzle_hash(address, AddressType.XCH.hrp(config)),
|
||||
royalty_percentage=percentage,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -874,16 +885,16 @@ async def take_offer(
|
||||
if fungible_asset_id is None:
|
||||
nft_royalty_currency = network_xch
|
||||
else:
|
||||
result = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(fungible_asset_id))
|
||||
result = await wallet_client.cat_asset_id_to_name(CATAssetIDToName(asset_id=fungible_asset_id))
|
||||
if result.name is not None:
|
||||
nft_royalty_currency = result.name
|
||||
fungible_assets.append(
|
||||
FungibleAsset(nft_royalty_currency, uint64(requested[fungible_asset_id_str]))
|
||||
FungibleAsset(asset=nft_royalty_currency, amount=uint64(requested[fungible_asset_id_str]))
|
||||
)
|
||||
|
||||
if len(fungible_assets) > 0:
|
||||
royalty_summary = await wallet_client.nft_calculate_royalties(
|
||||
NFTCalculateRoyalties(royalty_assets, fungible_assets)
|
||||
NFTCalculateRoyalties(royalty_assets=royalty_assets, fungible_assets=fungible_assets)
|
||||
)
|
||||
total_amounts_requested: dict[Any, int] = {}
|
||||
print("Royalties Summary:")
|
||||
@@ -939,7 +950,7 @@ async def cancel_offer(
|
||||
condition_valid_times: ConditionValidTimes,
|
||||
) -> list[TransactionRecord]:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, fingerprint, config):
|
||||
trade_record = (await wallet_client.get_offer(GetOffer(offer_id, file_contents=True))).trade_record
|
||||
trade_record = (await wallet_client.get_offer(GetOffer(trade_id=offer_id, file_contents=True))).trade_record
|
||||
await print_trade_record(trade_record, wallet_client, summaries=True)
|
||||
|
||||
cli_confirm(f"Are you sure you wish to cancel offer with ID: {trade_record.trade_id}? (y/n): ")
|
||||
@@ -979,7 +990,7 @@ async def print_balances(
|
||||
root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, wallet_type: WalletType | None = None
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, fingerprint, config):
|
||||
summaries_response = await wallet_client.get_wallets(GetWallets(uint16.construct_optional(wallet_type)))
|
||||
summaries_response = await wallet_client.get_wallets(GetWallets(type=uint16.construct_optional(wallet_type)))
|
||||
address_prefix = selected_network_address_prefix(config)
|
||||
|
||||
sync_response = await wallet_client.get_sync_status()
|
||||
@@ -1004,7 +1015,9 @@ async def print_balances(
|
||||
# A future RPC update may split them apart, but for now we'll show the first 32 bytes (64 chars)
|
||||
asset_id = summary.data[:64]
|
||||
wallet_id = summary.id
|
||||
balances = (await wallet_client.get_wallet_balance(GetWalletBalance(uint32(wallet_id)))).wallet_balance
|
||||
balances = (
|
||||
await wallet_client.get_wallet_balance(GetWalletBalance(wallet_id=uint32(wallet_id)))
|
||||
).wallet_balance
|
||||
typ = WalletType(int(summary.type))
|
||||
address_prefix, scale = wallet_coin_unit(typ, address_prefix)
|
||||
total_balance: str = print_balance(balances.confirmed_wallet_balance, scale, address_prefix)
|
||||
@@ -1029,11 +1042,11 @@ async def print_balances(
|
||||
print(f"{indent}{'-Spendable:'.ljust(ljust)} {spendable_balance}")
|
||||
print(f"{indent}{'-Type:'.ljust(ljust)} {typ.name}")
|
||||
if typ == WalletType.DECENTRALIZED_ID:
|
||||
get_did_response = await wallet_client.get_did_id(DIDGetDID(wallet_id))
|
||||
get_did_response = await wallet_client.get_did_id(DIDGetDID(wallet_id=wallet_id))
|
||||
my_did = get_did_response.my_did
|
||||
print(f"{indent}{'-DID ID:'.ljust(ljust)} {my_did}")
|
||||
elif typ == WalletType.NFT:
|
||||
my_did = (await wallet_client.get_nft_wallet_did(NFTGetWalletDID(wallet_id))).did_id
|
||||
my_did = (await wallet_client.get_nft_wallet_did(NFTGetWalletDID(wallet_id=wallet_id))).did_id
|
||||
if my_did is not None and len(my_did) > 0:
|
||||
print(f"{indent}{'-DID ID:'.ljust(ljust)} {my_did}")
|
||||
elif len(asset_id) > 0:
|
||||
@@ -1085,7 +1098,7 @@ async def did_set_wallet_name(
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
try:
|
||||
await wallet_client.did_set_wallet_name(DIDSetWalletName(uint32(wallet_id), name))
|
||||
await wallet_client.did_set_wallet_name(DIDSetWalletName(wallet_id=uint32(wallet_id), name=name))
|
||||
print(f"Successfully set a new name for DID wallet with id {wallet_id}: {name}")
|
||||
except Exception as e:
|
||||
print(f"Failed to set DID wallet name: {e}")
|
||||
@@ -1094,7 +1107,7 @@ async def did_set_wallet_name(
|
||||
async def get_did(root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, did_wallet_id: int) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
try:
|
||||
response = await wallet_client.get_did_id(DIDGetDID(uint32(did_wallet_id)))
|
||||
response = await wallet_client.get_did_id(DIDGetDID(wallet_id=uint32(did_wallet_id)))
|
||||
print(f"{'DID:'.ljust(23)} {response.my_did}")
|
||||
print(f"{'Coin ID:'.ljust(23)} {response.coin_id.hex() if response.coin_id is not None else 'Unknown'}")
|
||||
except Exception as e:
|
||||
@@ -1107,7 +1120,7 @@ async def get_did_info(
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
did_padding_length = 23
|
||||
try:
|
||||
response = await wallet_client.get_did_info(DIDGetInfo(coin_id, latest))
|
||||
response = await wallet_client.get_did_info(DIDGetInfo(coin_id=coin_id, latest=latest))
|
||||
print(f"{'DID:'.ljust(did_padding_length)} {response.did_id}")
|
||||
print(f"{'Coin ID:'.ljust(did_padding_length)} {response.latest_coin.hex()}")
|
||||
print(f"{'Inner P2 Address:'.ljust(did_padding_length)} {response.p2_address}")
|
||||
@@ -1241,10 +1254,12 @@ async def find_lost_did(
|
||||
try:
|
||||
response = await wallet_client.find_lost_did(
|
||||
DIDFindLostDID(
|
||||
coin_id,
|
||||
bytes32.from_hexstr(recovery_list_hash) if recovery_list_hash is not None else None,
|
||||
uint16.construct_optional(num_verification),
|
||||
json.loads(metadata) if metadata is not None else None,
|
||||
coin_id=coin_id,
|
||||
recovery_list_hash=bytes32.from_hexstr(recovery_list_hash)
|
||||
if recovery_list_hash is not None
|
||||
else None,
|
||||
num_verification=uint16.construct_optional(num_verification),
|
||||
metadata=json.loads(metadata) if metadata is not None else None,
|
||||
)
|
||||
)
|
||||
print(f"Successfully found lost DID {coin_id}, latest coin ID: {response.latest_coin_id.hex()}")
|
||||
@@ -1302,7 +1317,7 @@ async def mint_nft(
|
||||
royalty_address = royalty_cli_address.validate_address_type(AddressType.XCH) if royalty_cli_address else None
|
||||
target_address = target_cli_address.validate_address_type(AddressType.XCH) if target_cli_address else None
|
||||
try:
|
||||
response = await wallet_client.get_nft_wallet_did(NFTGetWalletDID(uint32(wallet_id)))
|
||||
response = await wallet_client.get_nft_wallet_did(NFTGetWalletDID(wallet_id=uint32(wallet_id)))
|
||||
wallet_did = response.did_id
|
||||
wallet_has_did = wallet_did is not None
|
||||
did_id: str | None = wallet_did
|
||||
@@ -1486,7 +1501,9 @@ async def list_nfts(
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, fingerprint, config):
|
||||
try:
|
||||
response = await wallet_client.list_nfts(NFTGetNFTs(uint32(wallet_id), uint32(start_index), uint32(num)))
|
||||
response = await wallet_client.list_nfts(
|
||||
NFTGetNFTs(wallet_id=uint32(wallet_id), start_index=uint32(start_index), num=uint32(num))
|
||||
)
|
||||
nft_list = response.nft_list
|
||||
if len(nft_list) > 0:
|
||||
for nft in nft_list:
|
||||
@@ -1536,7 +1553,7 @@ async def set_nft_did(
|
||||
async def get_nft_info(root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, nft_coin_id: str) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, config):
|
||||
try:
|
||||
response = await wallet_client.get_nft_info(NFTGetInfo(nft_coin_id))
|
||||
response = await wallet_client.get_nft_info(NFTGetInfo(coin_id=nft_coin_id))
|
||||
print_nft_info(response.nft_info, config=config)
|
||||
except Exception as e:
|
||||
print(f"Failed to get NFT info: {e}")
|
||||
@@ -1545,7 +1562,7 @@ async def get_nft_info(root_path: pathlib.Path, wallet_rpc_port: int | None, fp:
|
||||
async def get_nft_royalty_percentage_and_address(
|
||||
nft_coin_id: bytes32, wallet_client: WalletRpcClient
|
||||
) -> tuple[uint16, bytes32]:
|
||||
info = (await wallet_client.get_nft_info(NFTGetInfo(nft_coin_id.hex()))).nft_info
|
||||
info = (await wallet_client.get_nft_info(NFTGetInfo(coin_id=nft_coin_id.hex()))).nft_info
|
||||
assert info.royalty_puzzle_hash is not None
|
||||
percentage = uint16(info.royalty_percentage) if info.royalty_percentage is not None else 0
|
||||
return uint16(percentage), info.royalty_puzzle_hash
|
||||
@@ -1611,9 +1628,9 @@ async def send_notification(
|
||||
|
||||
response = await wallet_client.send_notification(
|
||||
SendNotification(
|
||||
address.puzzle_hash,
|
||||
message,
|
||||
amount,
|
||||
target=address.puzzle_hash,
|
||||
message=message,
|
||||
amount=amount,
|
||||
fee=fee,
|
||||
push=push,
|
||||
),
|
||||
@@ -1681,18 +1698,22 @@ async def sign_message(
|
||||
print("Address is required for XCH address type.")
|
||||
return
|
||||
response = await wallet_client.sign_message_by_address(
|
||||
SignMessageByAddress(address.original_address, message)
|
||||
SignMessageByAddress(address=address.original_address, message=message)
|
||||
)
|
||||
elif addr_type == AddressType.DID:
|
||||
if did_id is None:
|
||||
print("DID id is required for DID address type.")
|
||||
return
|
||||
response = await wallet_client.sign_message_by_id(SignMessageByID(did_id.original_address, message))
|
||||
response = await wallet_client.sign_message_by_id(
|
||||
SignMessageByID(id=did_id.original_address, message=message)
|
||||
)
|
||||
elif addr_type == AddressType.NFT:
|
||||
if nft_id is None:
|
||||
print("NFT id is required for NFT address type.")
|
||||
return
|
||||
response = await wallet_client.sign_message_by_id(SignMessageByID(nft_id.original_address, message))
|
||||
response = await wallet_client.sign_message_by_id(
|
||||
SignMessageByID(id=nft_id.original_address, message=message)
|
||||
)
|
||||
else:
|
||||
print("Invalid wallet type.")
|
||||
return
|
||||
@@ -1772,7 +1793,7 @@ async def mint_vc(
|
||||
|
||||
async def get_vcs(root_path: pathlib.Path, wallet_rpc_port: int | None, fp: int | None, start: int, count: int) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, config):
|
||||
get_list_response = await wallet_client.vc_get_list(VCGetList(uint32(start), uint32(count)))
|
||||
get_list_response = await wallet_client.vc_get_list(VCGetList(start=uint32(start), end=uint32(count)))
|
||||
print("Proofs:")
|
||||
for hash, proof_dict in get_list_response.proof_dict.items():
|
||||
if proof_dict is not None:
|
||||
@@ -1861,7 +1882,7 @@ async def get_proofs_for_root(
|
||||
) -> None:
|
||||
async with get_wallet_client(root_path, wallet_rpc_port, fp) as (wallet_client, _, _):
|
||||
proof_dict: dict[str, str] = (
|
||||
(await wallet_client.vc_get_proofs_for_root(VCGetProofsForRoot(bytes32.from_hexstr(proof_hash))))
|
||||
(await wallet_client.vc_get_proofs_for_root(VCGetProofsForRoot(root=bytes32.from_hexstr(proof_hash))))
|
||||
.to_vc_proofs()
|
||||
.key_value_pairs
|
||||
)
|
||||
@@ -1886,7 +1907,7 @@ async def revoke_vc(
|
||||
if vc_id is None:
|
||||
print("Must specify either --parent-coin-id or --vc-id")
|
||||
return []
|
||||
record = (await wallet_client.vc_get(VCGet(vc_id))).vc_record
|
||||
record = (await wallet_client.vc_get(VCGet(vc_id=vc_id))).vc_record
|
||||
if record is None:
|
||||
print(f"Cannot find a VC with ID {vc_id.hex()}")
|
||||
return []
|
||||
|
||||
@@ -277,7 +277,7 @@ class DataLayer:
|
||||
|
||||
async def wallet_log_in(self, fingerprint: int) -> int:
|
||||
try:
|
||||
result = await self.wallet_rpc.log_in(LogIn(uint32(fingerprint)))
|
||||
result = await self.wallet_rpc.log_in(LogIn(fingerprint=uint32(fingerprint)))
|
||||
except ValueError as e:
|
||||
raise Exception(f"DataLayer wallet RPC log in request failed: {e.args[0]}")
|
||||
|
||||
@@ -338,9 +338,10 @@ class DataLayer:
|
||||
for store_id in store_ids:
|
||||
await self._update_confirmation_status(store_id=store_id)
|
||||
root_hash = await self._get_publishable_root_hash(store_id=store_id)
|
||||
updates.append(LauncherRootPair(store_id, root_hash))
|
||||
updates.append(LauncherRootPair(launcher_id=store_id, new_root=root_hash))
|
||||
response = await self.wallet_rpc.dl_update_multiple(
|
||||
DLUpdateMultiple(updates=DLUpdateMultipleUpdates(updates), fee=fee), DEFAULT_TX_CONFIG
|
||||
DLUpdateMultiple(updates=DLUpdateMultipleUpdates(launcher_root_pairs=updates), fee=fee),
|
||||
DEFAULT_TX_CONFIG,
|
||||
)
|
||||
return response.transactions
|
||||
else:
|
||||
@@ -369,10 +370,11 @@ class DataLayer:
|
||||
raise Exception("No pending roots found to submit")
|
||||
for pending_root in pending_roots:
|
||||
root_hash = pending_root.node_hash if pending_root.node_hash is not None else self.none_bytes
|
||||
updates.append(LauncherRootPair(pending_root.store_id, root_hash))
|
||||
updates.append(LauncherRootPair(launcher_id=pending_root.store_id, new_root=root_hash))
|
||||
await self.data_store.change_root_status(pending_root, Status.PENDING)
|
||||
response = await self.wallet_rpc.dl_update_multiple(
|
||||
DLUpdateMultiple(updates=DLUpdateMultipleUpdates(updates), fee=fee), DEFAULT_TX_CONFIG
|
||||
DLUpdateMultiple(updates=DLUpdateMultipleUpdates(launcher_root_pairs=updates), fee=fee),
|
||||
DEFAULT_TX_CONFIG,
|
||||
)
|
||||
return response.transactions
|
||||
|
||||
@@ -504,7 +506,9 @@ class DataLayer:
|
||||
return res
|
||||
|
||||
async def get_root(self, store_id: bytes32) -> SingletonRecord | None:
|
||||
latest = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
latest = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if latest is None:
|
||||
self.log.error(f"Failed to get root for {store_id.hex()}")
|
||||
return latest
|
||||
@@ -519,7 +523,7 @@ class DataLayer:
|
||||
return res.node_hash
|
||||
|
||||
async def get_root_history(self, store_id: bytes32) -> list[SingletonRecord]:
|
||||
records = (await self.wallet_rpc.dl_history(DLHistory(store_id))).history
|
||||
records = (await self.wallet_rpc.dl_history(DLHistory(launcher_id=store_id))).history
|
||||
if records is None:
|
||||
self.log.error(f"Failed to get root history for {store_id.hex()}")
|
||||
root_history = []
|
||||
@@ -536,7 +540,9 @@ class DataLayer:
|
||||
root = await self.data_store.get_tree_root(store_id=store_id)
|
||||
except Exception:
|
||||
root = None
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
return
|
||||
if root is None:
|
||||
@@ -590,7 +596,9 @@ class DataLayer:
|
||||
await self.data_store.clear_pending_roots(store_id=store_id)
|
||||
|
||||
async def fetch_and_validate(self, store_id: bytes32) -> None:
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
self.log.info(f"Fetch data: No singleton record for {store_id}.")
|
||||
return
|
||||
@@ -709,7 +717,9 @@ class DataLayer:
|
||||
return None
|
||||
|
||||
async def clean_old_full_tree_files(self, store_id: bytes32) -> None:
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
return
|
||||
await self._update_confirmation_status(store_id=store_id)
|
||||
@@ -727,7 +737,9 @@ class DataLayer:
|
||||
|
||||
async def upload_files(self, store_id: bytes32) -> None:
|
||||
uploaders = await self.get_uploaders(store_id)
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
self.log.info(f"Upload files: no on-chain record for {store_id}.")
|
||||
return
|
||||
@@ -794,7 +806,9 @@ class DataLayer:
|
||||
root = await self.data_store.get_tree_root(store_id=store_id)
|
||||
latest_generation = root.generation
|
||||
full_tree_first_publish_generation = max(0, latest_generation - self.maximum_full_file_count + 1)
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
self.log.error(f"No singleton record found for: {store_id}")
|
||||
return
|
||||
@@ -839,7 +853,7 @@ class DataLayer:
|
||||
async def subscribe(self, store_id: bytes32, urls: list[str]) -> Subscription:
|
||||
parsed_urls = [url.rstrip("/") for url in urls]
|
||||
subscription = Subscription(store_id, [ServerInfo(url, 0, 0) for url in parsed_urls])
|
||||
await self.wallet_rpc.dl_track_new(DLTrackNew(subscription.store_id))
|
||||
await self.wallet_rpc.dl_track_new(DLTrackNew(launcher_id=subscription.store_id))
|
||||
async with self.subscription_lock:
|
||||
await self.data_store.subscribe(subscription)
|
||||
self.log.info(f"Done adding subscription: {subscription.store_id}")
|
||||
@@ -891,7 +905,7 @@ class DataLayer:
|
||||
)
|
||||
|
||||
# stop tracking first, then unsubscribe from the data store
|
||||
await self.wallet_rpc.dl_stop_tracking(DLStopTracking(store_id))
|
||||
await self.wallet_rpc.dl_stop_tracking(DLStopTracking(launcher_id=store_id))
|
||||
await self.data_store.unsubscribe(store_id)
|
||||
|
||||
self.log.info(f"Unsubscribed to {store_id}")
|
||||
@@ -916,11 +930,11 @@ class DataLayer:
|
||||
await self.wallet_rpc.dl_delete_mirror(DLDeleteMirror(coin_id=coin_id, fee=fee, push=True), DEFAULT_TX_CONFIG)
|
||||
|
||||
async def get_mirrors(self, store_id: bytes32) -> list[Mirror]:
|
||||
mirrors: list[Mirror] = (await self.wallet_rpc.dl_get_mirrors(DLGetMirrors(store_id))).mirrors
|
||||
mirrors: list[Mirror] = (await self.wallet_rpc.dl_get_mirrors(DLGetMirrors(launcher_id=store_id))).mirrors
|
||||
return [mirror for mirror in mirrors if mirror.urls]
|
||||
|
||||
async def update_subscriptions_from_wallet(self, store_id: bytes32) -> None:
|
||||
mirrors: list[Mirror] = (await self.wallet_rpc.dl_get_mirrors(DLGetMirrors(store_id))).mirrors
|
||||
mirrors: list[Mirror] = (await self.wallet_rpc.dl_get_mirrors(DLGetMirrors(launcher_id=store_id))).mirrors
|
||||
urls: list[str] = []
|
||||
for mirror in mirrors:
|
||||
urls += mirror.urls
|
||||
@@ -953,7 +967,7 @@ class DataLayer:
|
||||
try:
|
||||
subscriptions = await self.data_store.get_subscriptions()
|
||||
for subscription in subscriptions:
|
||||
await self.wallet_rpc.dl_track_new(DLTrackNew(subscription.store_id))
|
||||
await self.wallet_rpc.dl_track_new(DLTrackNew(launcher_id=subscription.store_id))
|
||||
break
|
||||
except aiohttp.client_exceptions.ClientConnectorError:
|
||||
pass
|
||||
@@ -1306,7 +1320,9 @@ class DataLayer:
|
||||
if not await self.data_store.store_id_exists(store_id=store_id):
|
||||
raise Exception(f"No store id stored in the local database for {store_id}")
|
||||
root = await self.data_store.get_tree_root(store_id=store_id)
|
||||
singleton_record = (await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(store_id, True))).singleton
|
||||
singleton_record = (
|
||||
await self.wallet_rpc.dl_latest_singleton(DLLatestSingleton(launcher_id=store_id, only_confirmed=True))
|
||||
).singleton
|
||||
if singleton_record is None:
|
||||
raise Exception(f"No singleton found for {store_id}")
|
||||
|
||||
|
||||
+296
-300
File diff suppressed because it is too large
Load Diff
+180
-132
@@ -739,18 +739,18 @@ class WalletRpcApi:
|
||||
"""
|
||||
|
||||
if self.service.logged_in_fingerprint == request.fingerprint:
|
||||
return LogInResponse(request.fingerprint)
|
||||
return LogInResponse(fingerprint=request.fingerprint)
|
||||
|
||||
await self._stop_wallet()
|
||||
started = await self.service._start_with_fingerprint(request.fingerprint)
|
||||
if started is True:
|
||||
return LogInResponse(request.fingerprint)
|
||||
return LogInResponse(fingerprint=request.fingerprint)
|
||||
|
||||
raise ValueError(f"fingerprint {request.fingerprint} not found in keychain or keychain is empty")
|
||||
|
||||
@marshal
|
||||
async def get_logged_in_fingerprint(self, request: Empty) -> GetLoggedInFingerprintResponse:
|
||||
return GetLoggedInFingerprintResponse(uint32.construct_optional(self.service.logged_in_fingerprint))
|
||||
return GetLoggedInFingerprintResponse(fingerprint=uint32.construct_optional(self.service.logged_in_fingerprint))
|
||||
|
||||
@marshal
|
||||
async def get_public_keys(self, request: Empty) -> GetPublicKeysResponse:
|
||||
@@ -796,7 +796,7 @@ class WalletRpcApi:
|
||||
|
||||
@marshal
|
||||
async def generate_mnemonic(self, request: Empty) -> GenerateMnemonicResponse:
|
||||
return GenerateMnemonicResponse(generate_mnemonic().split(" "))
|
||||
return GenerateMnemonicResponse(mnemonic=generate_mnemonic().split(" "))
|
||||
|
||||
@marshal
|
||||
async def add_key(self, request: AddKey) -> AddKeyResponse:
|
||||
@@ -1000,11 +1000,11 @@ class WalletRpcApi:
|
||||
elif extra_conditions != tuple():
|
||||
raise ValueError("Cannot add conditions to a transaction if no new fee spend is being added")
|
||||
|
||||
return PushTransactionsResponse([], []) # tx_endpoint takes care of this
|
||||
return PushTransactionsResponse(unsigned_transactions=[], transactions=[]) # tx_endpoint takes care of this
|
||||
|
||||
@marshal
|
||||
async def get_timestamp_for_height(self, request: GetTimestampForHeight) -> GetTimestampForHeightResponse:
|
||||
return GetTimestampForHeightResponse(await self.service.get_timestamp_for_height(request.height))
|
||||
return GetTimestampForHeightResponse(timestamp=await self.service.get_timestamp_for_height(request.height))
|
||||
|
||||
@marshal
|
||||
async def set_auto_claim(self, request: AutoClaimSettings) -> AutoClaimSettings:
|
||||
@@ -1055,16 +1055,18 @@ class WalletRpcApi:
|
||||
|
||||
wallet_infos.append(
|
||||
WalletInfoResponse(
|
||||
wallet.id,
|
||||
wallet.name,
|
||||
wallet.type,
|
||||
data,
|
||||
authorized_providers,
|
||||
proofs_checker_flags,
|
||||
id=wallet.id,
|
||||
name=wallet.name,
|
||||
type=wallet.type,
|
||||
data=data,
|
||||
authorized_providers=authorized_providers,
|
||||
flags_needed=proofs_checker_flags,
|
||||
)
|
||||
)
|
||||
|
||||
return GetWalletsResponse(wallet_infos, uint32.construct_optional(self.service.logged_in_fingerprint))
|
||||
return GetWalletsResponse(
|
||||
wallets=wallet_infos, fingerprint=uint32.construct_optional(self.service.logged_in_fingerprint)
|
||||
)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -1097,7 +1099,11 @@ class WalletRpcApi:
|
||||
asset_id = cat_wallet.get_asset_id()
|
||||
self.service.wallet_state_manager.state_changed("wallet_created")
|
||||
return CreateNewWalletResponse(
|
||||
[], [], type=cat_wallet.type().name, asset_id=asset_id, wallet_id=cat_wallet.id()
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=cat_wallet.type().name,
|
||||
asset_id=asset_id,
|
||||
wallet_id=cat_wallet.id(),
|
||||
)
|
||||
|
||||
elif request.mode == WalletCreationMode.EXISTING:
|
||||
@@ -1107,8 +1113,8 @@ class WalletRpcApi:
|
||||
wallet_state_manager, main_wallet, request.asset_id, request.name
|
||||
)
|
||||
return CreateNewWalletResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=cat_wallet.type().name,
|
||||
asset_id=request.asset_id,
|
||||
wallet_id=cat_wallet.id(),
|
||||
@@ -1144,7 +1150,11 @@ class WalletRpcApi:
|
||||
nft_wallet_name,
|
||||
)
|
||||
return CreateNewWalletResponse(
|
||||
[], [], type=did_wallet.type().name, my_did=my_did_id, wallet_id=did_wallet.id()
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=did_wallet.type().name,
|
||||
my_did=my_did_id,
|
||||
wallet_id=did_wallet.id(),
|
||||
)
|
||||
|
||||
elif request.did_type == DIDType.RECOVERY:
|
||||
@@ -1161,8 +1171,8 @@ class WalletRpcApi:
|
||||
newpuzhash = did_wallet.did_info.temp_puzhash
|
||||
pubkey = did_wallet.did_info.temp_pubkey
|
||||
return CreateNewWalletResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=did_wallet.type().name,
|
||||
my_did=my_did,
|
||||
wallet_id=did_wallet.id(),
|
||||
@@ -1183,8 +1193,8 @@ class WalletRpcApi:
|
||||
if wallet.get_did() == did_id:
|
||||
log.info("NFT wallet already existed, skipping.")
|
||||
return CreateNewWalletResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=wallet.type().name,
|
||||
wallet_id=wallet.id(),
|
||||
)
|
||||
@@ -1194,8 +1204,8 @@ class WalletRpcApi:
|
||||
wallet_state_manager, main_wallet, did_id, request.name
|
||||
)
|
||||
return CreateNewWalletResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
type=nft_wallet.type().name,
|
||||
wallet_id=nft_wallet.id(),
|
||||
)
|
||||
@@ -1222,8 +1232,8 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
return CreateNewWalletResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
total_fee=uint64(request.fee * 2),
|
||||
launcher_id=launcher_id,
|
||||
@@ -1256,7 +1266,7 @@ class WalletRpcApi:
|
||||
|
||||
@marshal
|
||||
async def get_wallet_balance(self, request: GetWalletBalance) -> GetWalletBalanceResponse:
|
||||
return GetWalletBalanceResponse(await self._get_wallet_balance(request.wallet_id))
|
||||
return GetWalletBalanceResponse(wallet_balance=await self._get_wallet_balance(request.wallet_id))
|
||||
|
||||
@marshal
|
||||
async def get_wallet_balances(self, request: GetWalletBalances) -> GetWalletBalancesResponse:
|
||||
@@ -1265,7 +1275,7 @@ class WalletRpcApi:
|
||||
else:
|
||||
wallet_ids = list(self.service.wallet_state_manager.wallets.keys())
|
||||
return GetWalletBalancesResponse(
|
||||
{wallet_id: await self._get_wallet_balance(wallet_id) for wallet_id in wallet_ids}
|
||||
wallet_balances={wallet_id: await self._get_wallet_balance(wallet_id) for wallet_id in wallet_ids}
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -1275,8 +1285,8 @@ class WalletRpcApi:
|
||||
raise ValueError(f"Transaction 0x{request.transaction_id.hex()} not found")
|
||||
|
||||
return GetTransactionResponse(
|
||||
await self._convert_tx_puzzle_hash(tr),
|
||||
tr.name,
|
||||
transaction=await self._convert_tx_puzzle_hash(tr),
|
||||
transaction_id=tr.name,
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -1299,7 +1309,7 @@ class WalletRpcApi:
|
||||
else:
|
||||
raise ValueError(f"Transaction 0x{transaction_id.hex()} doesn't have any coin spend.")
|
||||
assert tr.spend_bundle is not None
|
||||
return GetTransactionMemoResponse({transaction_id: compute_memos(tr.spend_bundle)})
|
||||
return GetTransactionMemoResponse(transaction_memos={transaction_id: compute_memos(tr.spend_bundle)})
|
||||
|
||||
@tx_endpoint(push=False)
|
||||
@marshal
|
||||
@@ -1316,7 +1326,8 @@ class WalletRpcApi:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
|
||||
return SplitCoinsResponse([], []) # tx_endpoint will take care to fill this out
|
||||
# tx_endpoint will take care to fill this out
|
||||
return SplitCoinsResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@tx_endpoint(push=False)
|
||||
@marshal
|
||||
@@ -1334,7 +1345,8 @@ class WalletRpcApi:
|
||||
target_coin_ids=request.target_coin_ids if request.target_coin_ids != [] else None,
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
return CombineCoinsResponse([], []) # tx_endpoint will take care to fill this out
|
||||
# tx_endpoint will take care to fill this out
|
||||
return CombineCoinsResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@marshal
|
||||
async def get_transactions(self, request: GetTransactions) -> GetTransactionsResponse:
|
||||
@@ -1384,8 +1396,8 @@ class WalletRpcApi:
|
||||
request.wallet_id, confirmed=request.confirmed, type_filter=request.type_filter
|
||||
)
|
||||
return GetTransactionCountResponse(
|
||||
request.wallet_id,
|
||||
uint16(count),
|
||||
wallet_id=request.wallet_id,
|
||||
count=uint16(count),
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -1408,8 +1420,8 @@ class WalletRpcApi:
|
||||
raise ValueError(f"Wallet type {wallet.type()} cannot create puzzle hashes")
|
||||
|
||||
return GetNextAddressResponse(
|
||||
request.wallet_id,
|
||||
address,
|
||||
wallet_id=request.wallet_id,
|
||||
address=address,
|
||||
)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@@ -1426,13 +1438,13 @@ class WalletRpcApi:
|
||||
CreateSignedTransaction(
|
||||
additions=[
|
||||
Addition(
|
||||
request.amount,
|
||||
decode_puzzle_hash(
|
||||
amount=request.amount,
|
||||
puzzle_hash=decode_puzzle_hash(
|
||||
ensure_valid_address(
|
||||
request.address, allowed_types={AddressType.XCH}, config=self.service.config
|
||||
)
|
||||
),
|
||||
request.memos,
|
||||
memos=request.memos,
|
||||
)
|
||||
],
|
||||
wallet_id=request.wallet_id,
|
||||
@@ -1445,7 +1457,12 @@ class WalletRpcApi:
|
||||
|
||||
# Transaction may not have been included in the mempool yet. Use get_transaction to check.
|
||||
# tx_endpoint will take care of the default values here
|
||||
return SendTransactionResponse([], [], transaction=REPLACEABLE_TRANSACTION_RECORD, transaction_id=bytes32.zeros)
|
||||
return SendTransactionResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
transaction_id=bytes32.zeros,
|
||||
)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -1480,7 +1497,10 @@ class WalletRpcApi:
|
||||
|
||||
# tx_endpoint will take care of these values
|
||||
return SendTransactionMultiResponse(
|
||||
[], [], transaction=REPLACEABLE_TRANSACTION_RECORD, transaction_id=bytes32.zeros
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
transaction_id=bytes32.zeros,
|
||||
)
|
||||
|
||||
@tx_endpoint(push=True, merge_spends=False)
|
||||
@@ -1529,7 +1549,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will fill in the default values here
|
||||
return SpendClawbackCoinsResponse([], [], transaction_ids=[])
|
||||
return SpendClawbackCoinsResponse(unsigned_transactions=[], transactions=[], transaction_ids=[])
|
||||
|
||||
@marshal
|
||||
async def delete_unconfirmed_transactions(self, request: DeleteUnconfirmedTransactions) -> Empty:
|
||||
@@ -1658,7 +1678,7 @@ class WalletRpcApi:
|
||||
if missed_coins:
|
||||
raise ValueError(f"Coin ID's: {missed_coins} not found.")
|
||||
|
||||
return GetCoinRecordsByNamesResponse(coin_records)
|
||||
return GetCoinRecordsByNamesResponse(coin_records=coin_records)
|
||||
|
||||
@marshal
|
||||
async def get_current_derivation_index(self, request: Empty) -> GetCurrentDerivationIndexResponse:
|
||||
@@ -1666,7 +1686,7 @@ class WalletRpcApi:
|
||||
|
||||
index: uint32 | None = await self.service.wallet_state_manager.puzzle_store.get_last_derivation_path()
|
||||
|
||||
return GetCurrentDerivationIndexResponse(index)
|
||||
return GetCurrentDerivationIndexResponse(index=index)
|
||||
|
||||
@marshal
|
||||
async def extend_derivation_index(self, request: ExtendDerivationIndex) -> ExtendDerivationIndexResponse:
|
||||
@@ -1703,13 +1723,15 @@ class WalletRpcApi:
|
||||
|
||||
updated_index = await self.service.wallet_state_manager.puzzle_store.get_last_derivation_path()
|
||||
|
||||
return ExtendDerivationIndexResponse(updated_index)
|
||||
return ExtendDerivationIndexResponse(index=updated_index)
|
||||
|
||||
@marshal
|
||||
async def get_notifications(self, request: GetNotifications) -> GetNotificationsResponse:
|
||||
return GetNotificationsResponse(
|
||||
await self.service.wallet_state_manager.notification_manager.notification_store.get_notifications(
|
||||
coin_ids=request.ids, pagination=(request.start, request.end)
|
||||
notifications=(
|
||||
await self.service.wallet_state_manager.notification_manager.notification_store.get_notifications(
|
||||
coin_ids=request.ids, pagination=(request.start, request.end)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1739,7 +1761,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of these default values
|
||||
return SendNotificationResponse([], [], tx=REPLACEABLE_TRANSACTION_RECORD)
|
||||
return SendNotificationResponse(unsigned_transactions=[], transactions=[], tx=REPLACEABLE_TRANSACTION_RECORD)
|
||||
|
||||
@marshal
|
||||
async def verify_signature(self, request: VerifySignature) -> VerifySignatureResponse:
|
||||
@@ -1847,7 +1869,9 @@ class WalletRpcApi:
|
||||
|
||||
@marshal
|
||||
async def get_cat_list(self, request: Empty) -> GetCATListResponse:
|
||||
return GetCATListResponse([DefaultCAT.from_json_dict(default_cat) for default_cat in DEFAULT_CATS.values()])
|
||||
return GetCATListResponse(
|
||||
cat_list=[DefaultCAT.from_json_dict(default_cat) for default_cat in DEFAULT_CATS.values()]
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def cat_set_name(self, request: CATSetName) -> CATSetNameResponse:
|
||||
@@ -1889,15 +1913,15 @@ class WalletRpcApi:
|
||||
else [
|
||||
Addition(
|
||||
# Our __post_init__ guards against these not being None
|
||||
request.amount, # type: ignore[arg-type]
|
||||
decode_puzzle_hash(
|
||||
amount=request.amount, # type: ignore[arg-type]
|
||||
puzzle_hash=decode_puzzle_hash(
|
||||
ensure_valid_address(
|
||||
request.inner_address, # type: ignore[arg-type]
|
||||
allowed_types={AddressType.XCH},
|
||||
config=self.service.config,
|
||||
)
|
||||
),
|
||||
request.memos,
|
||||
memos=request.memos,
|
||||
)
|
||||
],
|
||||
wallet_id=request.wallet_id,
|
||||
@@ -1912,7 +1936,12 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will fill in these default values
|
||||
return CATSpendResponse([], [], transaction=REPLACEABLE_TRANSACTION_RECORD, transaction_id=bytes32.zeros)
|
||||
return CATSpendResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
transaction_id=bytes32.zeros,
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def cat_get_asset_id(self, request: CATGetAssetID) -> CATGetAssetIDResponse:
|
||||
@@ -1963,8 +1992,8 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
return CreateOfferForIDsResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
offer=Offer.from_bytes(result[1].offer),
|
||||
trade_record=result[1],
|
||||
)
|
||||
@@ -2057,11 +2086,12 @@ class WalletRpcApi:
|
||||
SigningResponse(bytes(request.parsed_offer._bundle.aggregated_signature), trade_record.trade_id)
|
||||
)
|
||||
|
||||
# tx_endpoint will fill in this default value
|
||||
return TakeOfferResponse(
|
||||
[], # tx_endpoint will fill in this default value
|
||||
[], # tx_endpoint will fill in this default value
|
||||
Offer.from_bytes(trade_record.offer),
|
||||
trade_record,
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
offer=Offer.from_bytes(trade_record.offer),
|
||||
trade_record=trade_record,
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -2075,8 +2105,8 @@ class WalletRpcApi:
|
||||
offer_to_return: bytes = trade_record.offer if trade_record.taken_offer is None else trade_record.taken_offer
|
||||
offer: str | None = Offer.from_bytes(offer_to_return).to_bech32() if request.file_contents else None
|
||||
return GetOfferResponse(
|
||||
offer,
|
||||
trade_record,
|
||||
offer=offer,
|
||||
trade_record=trade_record,
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -2134,7 +2164,8 @@ class WalletRpcApi:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
|
||||
return CancelOfferResponse([], []) # tx_endpoint will fill in default values here
|
||||
# tx_endpoint will fill in default values here
|
||||
return CancelOfferResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@tx_endpoint(push=True, merge_spends=False)
|
||||
@marshal
|
||||
@@ -2177,7 +2208,8 @@ class WalletRpcApi:
|
||||
|
||||
log.info(f"Created offer cancellations for {start} to {start + request.batch_size} ...")
|
||||
|
||||
return CancelOffersResponse([], []) # tx_endpoint wrapper will take care of this
|
||||
# tx_endpoint will fill in default values here
|
||||
return CancelOffersResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
##########################################################################################
|
||||
# Distributed Identities
|
||||
@@ -2187,12 +2219,12 @@ class WalletRpcApi:
|
||||
async def did_set_wallet_name(self, request: DIDSetWalletName) -> DIDSetWalletNameResponse:
|
||||
wallet = self.service.wallet_state_manager.get_wallet(id=request.wallet_id, required_type=DIDWallet)
|
||||
await wallet.set_name(request.name)
|
||||
return DIDSetWalletNameResponse(request.wallet_id)
|
||||
return DIDSetWalletNameResponse(wallet_id=request.wallet_id)
|
||||
|
||||
@marshal
|
||||
async def did_get_wallet_name(self, request: DIDGetWalletName) -> DIDGetWalletNameResponse:
|
||||
wallet = self.service.wallet_state_manager.get_wallet(id=request.wallet_id, required_type=DIDWallet)
|
||||
return DIDGetWalletNameResponse(request.wallet_id, wallet.get_name())
|
||||
return DIDGetWalletNameResponse(wallet_id=request.wallet_id, name=wallet.get_name())
|
||||
|
||||
@tx_endpoint(push=False)
|
||||
@marshal
|
||||
@@ -2214,7 +2246,9 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of the default values here
|
||||
return DIDMessageSpendResponse([], [], WalletSpendBundle([], G2Element()))
|
||||
return DIDMessageSpendResponse(
|
||||
unsigned_transactions=[], transactions=[], spend_bundle=WalletSpendBundle([], G2Element())
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def did_get_info(self, request: DIDGetInfo) -> DIDGetInfoResponse:
|
||||
@@ -2260,7 +2294,7 @@ class WalletRpcApi:
|
||||
override_metadata=request.metadata,
|
||||
)
|
||||
|
||||
return DIDFindLostDIDResponse(coin_id)
|
||||
return DIDFindLostDIDResponse(latest_coin_id=coin_id)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -2278,8 +2312,8 @@ class WalletRpcApi:
|
||||
await wallet.create_update_spend(action_scope, request.fee, extra_conditions=extra_conditions)
|
||||
# tx_endpoint wrapper will take care of these default values
|
||||
return DIDUpdateMetadataResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
@@ -2310,7 +2344,7 @@ class WalletRpcApi:
|
||||
async def did_get_pubkey(self, request: DIDGetPubkey) -> DIDGetPubkeyResponse:
|
||||
wallet = self.service.wallet_state_manager.get_wallet(id=request.wallet_id, required_type=DIDWallet)
|
||||
return DIDGetPubkeyResponse(
|
||||
(await wallet.wallet_state_manager.get_unused_derivation_record(request.wallet_id)).pubkey
|
||||
pubkey=(await wallet.wallet_state_manager.get_unused_derivation_record(request.wallet_id)).pubkey
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -2355,7 +2389,12 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# The tx_endpoint wrapper will take care of these default values
|
||||
return DIDTransferDIDResponse([], [], transaction=REPLACEABLE_TRANSACTION_RECORD, transaction_id=bytes32.zeros)
|
||||
return DIDTransferDIDResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
transaction_id=bytes32.zeros,
|
||||
)
|
||||
|
||||
##########################################################################################
|
||||
# NFT Wallet
|
||||
@@ -2414,8 +2453,8 @@ class WalletRpcApi:
|
||||
)
|
||||
nft_id_bech32 = encode_puzzle_hash(nft_id, AddressType.NFT.hrp(self.service.config))
|
||||
return NFTMintNFTResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()), # tx_endpoint wrapper will take care of this
|
||||
nft_id=nft_id_bech32,
|
||||
@@ -2430,7 +2469,7 @@ class WalletRpcApi:
|
||||
).get_nft_count()
|
||||
else:
|
||||
count = await self.service.wallet_state_manager.nft_store.count()
|
||||
return NFTCountNFTsResponse(request.wallet_id, uint64(count))
|
||||
return NFTCountNFTsResponse(wallet_id=request.wallet_id, count=uint64(count))
|
||||
|
||||
@marshal
|
||||
async def nft_get_nfts(self, request: NFTGetNFTs) -> NFTGetNFTsResponse:
|
||||
@@ -2449,7 +2488,7 @@ class WalletRpcApi:
|
||||
for nft in nfts:
|
||||
nft_info = await nft_puzzle_utils.get_nft_info_from_puzzle(nft, self.service.wallet_state_manager.config)
|
||||
nft_info_list.append(nft_info)
|
||||
return NFTGetNFTsResponse(request.wallet_id, nft_info_list)
|
||||
return NFTGetNFTsResponse(wallet_id=request.wallet_id, nft_list=nft_info_list)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -2478,7 +2517,12 @@ class WalletRpcApi:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
# tx_endpoint wrapper takes care of setting most of these default values
|
||||
return NFTSetNFTDIDResponse([], [], request.wallet_id, WalletSpendBundle([], G2Element()))
|
||||
return NFTSetNFTDIDResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -2546,8 +2590,8 @@ class WalletRpcApi:
|
||||
|
||||
async with action_scope.use() as interface:
|
||||
return NFTSetDIDBulkResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=list(nft_dict.keys()),
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
tx_num=uint16(len(interface.side_effects.transactions)),
|
||||
@@ -2611,8 +2655,8 @@ class WalletRpcApi:
|
||||
self.service.wallet_state_manager.state_changed("nft_coin_did_set", wallet_id)
|
||||
async with action_scope.use() as interface:
|
||||
return NFTTransferBulkResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=list(nft_dict.keys()),
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
tx_num=uint16(len(interface.side_effects.transactions)),
|
||||
@@ -2625,7 +2669,7 @@ class WalletRpcApi:
|
||||
did_id = decode_puzzle_hash(request.did_id)
|
||||
for wallet in self.service.wallet_state_manager.wallets.values():
|
||||
if isinstance(wallet, NFTWallet) and wallet.get_did() == did_id:
|
||||
return NFTGetByDIDResponse(uint32(wallet.wallet_id))
|
||||
return NFTGetByDIDResponse(wallet_id=uint32(wallet.wallet_id))
|
||||
raise ValueError(f"Cannot find a NFT wallet DID = {did_id}")
|
||||
|
||||
@marshal
|
||||
@@ -2635,7 +2679,7 @@ class WalletRpcApi:
|
||||
did_id = ""
|
||||
if did_bytes is not None:
|
||||
did_id = encode_puzzle_hash(did_bytes, AddressType.DID.hrp(self.service.config))
|
||||
return NFTGetWalletDIDResponse(None if len(did_id) == 0 else did_id)
|
||||
return NFTGetWalletDIDResponse(did_id=None if len(did_id) == 0 else did_id)
|
||||
|
||||
@marshal
|
||||
async def nft_get_wallets_with_dids(self, request: Empty) -> NFTGetWalletsWithDIDsResponse:
|
||||
@@ -2664,7 +2708,7 @@ class WalletRpcApi:
|
||||
did_wallet_id=did_wallet_id,
|
||||
)
|
||||
)
|
||||
return NFTGetWalletsWithDIDsResponse(did_nft_wallets)
|
||||
return NFTGetWalletsWithDIDsResponse(nft_wallets=did_nft_wallets)
|
||||
|
||||
@marshal
|
||||
async def nft_set_nft_status(self, request: NFTSetNFTStatus) -> Empty:
|
||||
@@ -2702,7 +2746,12 @@ class WalletRpcApi:
|
||||
)
|
||||
await nft_wallet.update_coin_status(nft_coin_info.coin.name(), True)
|
||||
# tx_endpoint takes care of filling in default values here
|
||||
return NFTTransferNFTResponse([], [], request.wallet_id, WalletSpendBundle([], G2Element()))
|
||||
return NFTTransferNFTResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def nft_get_info(self, request: NFTGetInfo) -> NFTGetInfoResponse:
|
||||
@@ -2715,7 +2764,7 @@ class WalletRpcApi:
|
||||
|
||||
# This is a bit hacky, it should just come out like this, but this works for this RPC
|
||||
nft_info = dataclasses.replace(search_results.nft_info, p2_address=search_results.next_p2_puzzle_hash)
|
||||
return NFTGetInfoResponse(nft_info)
|
||||
return NFTGetInfoResponse(nft_info=nft_info)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -2738,7 +2787,12 @@ class WalletRpcApi:
|
||||
nft_coin_info, request.key, request.uri, action_scope, fee=request.fee, extra_conditions=extra_conditions
|
||||
)
|
||||
# tx_endpoint takes care of setting the default values here
|
||||
return NFTAddURIResponse([], [], request.wallet_id, WalletSpendBundle([], G2Element()))
|
||||
return NFTAddURIResponse(
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
wallet_id=request.wallet_id,
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def nft_calculate_royalties(self, request: NFTCalculateRoyalties) -> NFTCalculateRoyaltiesResponse:
|
||||
@@ -2838,10 +2892,10 @@ class WalletRpcApi:
|
||||
|
||||
# tx_endpoint will take care of the default values here
|
||||
return NFTMintBulkResponse(
|
||||
[],
|
||||
[],
|
||||
WalletSpendBundle([], G2Element()),
|
||||
nft_id_list,
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
spend_bundle=WalletSpendBundle([], G2Element()),
|
||||
nft_id_list=nft_id_list,
|
||||
)
|
||||
|
||||
async def get_coin_records(self, request: dict[str, Any]) -> EndpointResult:
|
||||
@@ -2992,7 +3046,9 @@ class WalletRpcApi:
|
||||
),
|
||||
)
|
||||
# tx_endpoint wrapper will take care of these default values
|
||||
return CreateSignedTransactionsResponse([], [], [], REPLACEABLE_TRANSACTION_RECORD)
|
||||
return CreateSignedTransactionsResponse(
|
||||
unsigned_transactions=[], transactions=[], signed_txs=[], signed_tx=REPLACEABLE_TRANSACTION_RECORD
|
||||
)
|
||||
|
||||
if hold_lock:
|
||||
async with self.service.wallet_state_manager.lock:
|
||||
@@ -3032,8 +3088,8 @@ class WalletRpcApi:
|
||||
total_fee = await wallet.join_pool(new_target_state, request.fee, action_scope)
|
||||
# tx_endpoint will take care of filling in these default values
|
||||
return PWJoinPoolResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
total_fee=total_fee,
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
fee_transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
@@ -3055,8 +3111,8 @@ class WalletRpcApi:
|
||||
total_fee = await wallet.self_pool(request.fee, action_scope)
|
||||
# tx_endpoint will take care of filling in these default values
|
||||
return PWSelfPoolResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
total_fee=total_fee,
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
fee_transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
@@ -3078,8 +3134,8 @@ class WalletRpcApi:
|
||||
await wallet.claim_pool_rewards(request.fee, request.max_spends_in_tx, action_scope)
|
||||
state: PoolWalletInfo = await wallet.get_current_state()
|
||||
return PWAbsorbRewardsResponse(
|
||||
[],
|
||||
[],
|
||||
unsigned_transactions=[],
|
||||
transactions=[],
|
||||
state=state,
|
||||
transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
fee_transaction=REPLACEABLE_TRANSACTION_RECORD,
|
||||
@@ -3124,7 +3180,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of these default values
|
||||
return CreateNewDLResponse([], [], launcher_id=launcher_id)
|
||||
return CreateNewDLResponse(unsigned_transactions=[], transactions=[], launcher_id=launcher_id)
|
||||
|
||||
@marshal
|
||||
async def dl_track_new(self, request: DLTrackNew) -> Empty:
|
||||
@@ -3156,7 +3212,7 @@ class WalletRpcApi:
|
||||
|
||||
wallet = await self.service.wallet_state_manager.get_dl_wallet()
|
||||
record = await wallet.get_latest_singleton(request.launcher_id, request.only_confirmed)
|
||||
return DLLatestSingletonResponse(record)
|
||||
return DLLatestSingletonResponse(singleton=record)
|
||||
|
||||
@marshal
|
||||
async def dl_singletons_by_root(self, request: DLSingletonsByRoot) -> DLSingletonsByRootResponse:
|
||||
@@ -3166,7 +3222,7 @@ class WalletRpcApi:
|
||||
|
||||
wallet = await self.service.wallet_state_manager.get_dl_wallet()
|
||||
records = await wallet.get_singletons_by_root(request.launcher_id, request.root)
|
||||
return DLSingletonsByRootResponse(records)
|
||||
return DLSingletonsByRootResponse(singletons=records)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -3191,11 +3247,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of default values here
|
||||
return DLUpdateRootResponse(
|
||||
[],
|
||||
[],
|
||||
REPLACEABLE_TRANSACTION_RECORD,
|
||||
)
|
||||
return DLUpdateRootResponse(unsigned_transactions=[], transactions=[], tx_record=REPLACEABLE_TRANSACTION_RECORD)
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -3225,10 +3277,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of default values here
|
||||
return DLUpdateMultipleResponse(
|
||||
[],
|
||||
[],
|
||||
)
|
||||
return DLUpdateMultipleResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@marshal
|
||||
async def dl_history(self, request: DLHistory) -> DLHistoryResponse:
|
||||
@@ -3247,7 +3296,7 @@ class WalletRpcApi:
|
||||
additional_kwargs["num_results"] = uint32(request.num_results)
|
||||
|
||||
history = await wallet.get_history(request.launcher_id, **additional_kwargs)
|
||||
return DLHistoryResponse(history, uint32(len(history)))
|
||||
return DLHistoryResponse(history=history, count=uint32(len(history)))
|
||||
|
||||
@marshal
|
||||
async def dl_owned_singletons(self, request: Empty) -> DLOwnedSingletonsResponse:
|
||||
@@ -3258,7 +3307,7 @@ class WalletRpcApi:
|
||||
wallet = await self.service.wallet_state_manager.get_dl_wallet()
|
||||
singletons = await wallet.get_owned_singletons()
|
||||
|
||||
return DLOwnedSingletonsResponse(singletons, uint32(len(singletons)))
|
||||
return DLOwnedSingletonsResponse(singletons=singletons, count=uint32(len(singletons)))
|
||||
|
||||
@marshal
|
||||
async def dl_get_mirrors(self, request: DLGetMirrors) -> DLGetMirrorsResponse:
|
||||
@@ -3267,7 +3316,7 @@ class WalletRpcApi:
|
||||
raise ValueError("The wallet service is not currently initialized")
|
||||
|
||||
wallet = await self.service.wallet_state_manager.get_dl_wallet()
|
||||
return DLGetMirrorsResponse(await wallet.get_mirrors_for_launcher(request.launcher_id))
|
||||
return DLGetMirrorsResponse(mirrors=await wallet.get_mirrors_for_launcher(request.launcher_id))
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -3293,10 +3342,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of default values here
|
||||
return DLNewMirrorResponse(
|
||||
[],
|
||||
[],
|
||||
)
|
||||
return DLNewMirrorResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -3321,10 +3367,7 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of default values here
|
||||
return DLDeleteMirrorResponse(
|
||||
[],
|
||||
[],
|
||||
)
|
||||
return DLDeleteMirrorResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@marshal
|
||||
async def dl_verify_proof(
|
||||
@@ -3367,7 +3410,7 @@ class WalletRpcApi:
|
||||
vc_record = await vc_wallet.launch_new_vc(
|
||||
did_id, action_scope, puzhash, request.fee, extra_conditions=extra_conditions
|
||||
)
|
||||
return VCMintResponse([], [], vc_record)
|
||||
return VCMintResponse(unsigned_transactions=[], transactions=[], vc_record=vc_record)
|
||||
|
||||
@marshal
|
||||
async def vc_get(self, request: VCGet) -> VCGetResponse:
|
||||
@@ -3377,7 +3420,7 @@ class WalletRpcApi:
|
||||
:return: the 'vc_record' representing the specified verifiable credential
|
||||
"""
|
||||
vc_record = await self.service.wallet_state_manager.vc_store.get_vc_record(request.vc_id)
|
||||
return VCGetResponse(vc_record)
|
||||
return VCGetResponse(vc_record=vc_record)
|
||||
|
||||
@marshal
|
||||
async def vc_get_list(self, request: VCGetList) -> VCGetListResponse:
|
||||
@@ -3389,10 +3432,11 @@ class WalletRpcApi:
|
||||
|
||||
vc_list = await self.service.wallet_state_manager.vc_store.get_vc_record_list(request.start, request.end)
|
||||
return VCGetListResponse(
|
||||
[VCRecordWithCoinID.from_vc_record(vc) for vc in vc_list],
|
||||
[
|
||||
vc_records=[VCRecordWithCoinID.from_vc_record(vc) for vc in vc_list],
|
||||
proofs=[
|
||||
VCProofWithHash(
|
||||
rec.vc.proof_hash, None if fetched_proof is None else VCProofsRPC.from_vc_proofs(fetched_proof)
|
||||
hash=rec.vc.proof_hash,
|
||||
proof=None if fetched_proof is None else VCProofsRPC.from_vc_proofs(fetched_proof),
|
||||
)
|
||||
for rec in vc_list
|
||||
if rec.vc.proof_hash is not None
|
||||
@@ -3435,7 +3479,7 @@ class WalletRpcApi:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
|
||||
return VCSpendResponse([], []) # tx_endpoint takes care of filling this out
|
||||
return VCSpendResponse(unsigned_transactions=[], transactions=[]) # tx_endpoint takes care of filling this out
|
||||
|
||||
@marshal
|
||||
async def vc_add_proofs(self, request: VCAddProofs) -> Empty:
|
||||
@@ -3490,7 +3534,7 @@ class WalletRpcApi:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
|
||||
return VCRevokeResponse([], []) # tx_endpoint takes care of filling this out
|
||||
return VCRevokeResponse(unsigned_transactions=[], transactions=[]) # tx_endpoint takes care of filling this out
|
||||
|
||||
@tx_endpoint(push=True)
|
||||
@marshal
|
||||
@@ -3519,14 +3563,16 @@ class WalletRpcApi:
|
||||
)
|
||||
|
||||
# tx_endpoint will take care of default values here
|
||||
return CRCATApprovePendingResponse([], [])
|
||||
return CRCATApprovePendingResponse(unsigned_transactions=[], transactions=[])
|
||||
|
||||
@marshal
|
||||
async def gather_signing_info(
|
||||
self,
|
||||
request: GatherSigningInfo,
|
||||
) -> GatherSigningInfoResponse:
|
||||
return GatherSigningInfoResponse(await self.service.wallet_state_manager.gather_signing_info(request.spends))
|
||||
return GatherSigningInfoResponse(
|
||||
signing_instructions=await self.service.wallet_state_manager.gather_signing_info(request.spends)
|
||||
)
|
||||
|
||||
@marshal
|
||||
async def apply_signatures(
|
||||
@@ -3534,7 +3580,9 @@ class WalletRpcApi:
|
||||
request: ApplySignatures,
|
||||
) -> ApplySignaturesResponse:
|
||||
return ApplySignaturesResponse(
|
||||
[await self.service.wallet_state_manager.apply_signatures(request.spends, request.signing_responses)]
|
||||
signed_transactions=[
|
||||
await self.service.wallet_state_manager.apply_signatures(request.spends, request.signing_responses)
|
||||
]
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -3543,7 +3591,7 @@ class WalletRpcApi:
|
||||
request: SubmitTransactions,
|
||||
) -> SubmitTransactionsResponse:
|
||||
return SubmitTransactionsResponse(
|
||||
await self.service.wallet_state_manager.submit_transactions(request.signed_transactions)
|
||||
mempool_ids=await self.service.wallet_state_manager.submit_transactions(request.signed_transactions)
|
||||
)
|
||||
|
||||
@marshal
|
||||
@@ -3552,7 +3600,7 @@ class WalletRpcApi:
|
||||
request: ExecuteSigningInstructions,
|
||||
) -> ExecuteSigningInstructionsResponse:
|
||||
return ExecuteSigningInstructionsResponse(
|
||||
await self.service.wallet_state_manager.execute_signing_instructions(
|
||||
signing_responses=await self.service.wallet_state_manager.execute_signing_instructions(
|
||||
request.signing_instructions, request.partial_allowed
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user