Skip to content

Commit

Permalink
Merge branch 'main' into og
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbrucker committed Jan 21, 2023
2 parents c63f176 + 88c3d01 commit d9ec8c7
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 62 deletions.
139 changes: 82 additions & 57 deletions chives-blockchain-gui/packages/api-react/src/services/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const apiWithTag = api.enhanceEndpoints({
'DerivationIndex',
'MasterNode',
'MasterNodeMyCard',
'MasterNodeSummary',
],
});

Expand Down Expand Up @@ -154,9 +155,9 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(({ id }) => ({ type: 'Wallets', id } as const)),
{ type: 'Wallets', id: 'LIST' },
]
...result.map(({ id }) => ({ type: 'Wallets', id } as const)),
{ type: 'Wallets', id: 'LIST' },
]
: [{ type: 'Wallets', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -419,8 +420,8 @@ export const walletApi = apiWithTag.injectEndpoints({
async queryFn(args, queryApi, _extraOptions, fetchWithBQ) {
let subscribeResponse:
| {
data: Function;
}
data: Function;
}
| undefined;

function unsubscribe() {
Expand Down Expand Up @@ -538,9 +539,9 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags: keys =>
keys
? [
...keys.map(key => ({ type: 'Keys', id: key } as const)),
{ type: 'Keys', id: 'LIST' },
]
...keys.map(key => ({ type: 'Keys', id: key } as const)),
{ type: 'Keys', id: 'LIST' },
]
: [{ type: 'Keys', id: 'LIST' }],
}),

Expand Down Expand Up @@ -732,11 +733,11 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
: [{ type: 'Transactions', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -810,11 +811,11 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
: [{ type: 'Transactions', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -888,11 +889,11 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
...result.map(
({ name }) => ({ type: 'Transactions', id: name } as const)
),
{ type: 'Transactions', id: 'LIST' },
]
: [{ type: 'Transactions', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -961,7 +962,7 @@ export const walletApi = apiWithTag.injectEndpoints({
keepUnusedDataFor: 5,
transformResponse: (response: any) => response?.result,
providesTags: (result, _error, { walletId }) =>
result ? [{ type: 'MasterNode', id: walletId }] : [],
result ? [{ type: 'MasterNodeMyCard', id: walletId }] : [],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
{
command: 'onCoinAdded',
Expand Down Expand Up @@ -998,6 +999,30 @@ export const walletApi = apiWithTag.injectEndpoints({
args: [walletId, false],
}),
transformResponse: (response: any) => response?.result,
providesTags: (result, _error, { walletId }) =>
result ? [{ type: 'MasterNodeSummary', id: walletId }] : [],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
{
command: 'onCoinAdded',
service: Wallet,
endpoint: () => walletApi.endpoints.getMasterNodeSummary,
},
{
command: 'onCoinRemoved',
service: Wallet,
endpoint: () => walletApi.endpoints.getMasterNodeSummary,
},
{
command: 'onPendingTransaction',
service: Wallet,
endpoint: () => walletApi.endpoints.getMasterNodeSummary,
},
{
command: 'onNewBlock',
service: Wallet,
endpoint: () => walletApi.endpoints.getMasterNodeSummary,
},
]),
}),

getCurrentAddress: build.query<
Expand Down Expand Up @@ -1179,12 +1204,12 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags: connections =>
connections
? [
...connections.map(
({ nodeId }) =>
({ type: 'WalletConnections', id: nodeId } as const)
),
{ type: 'WalletConnections', id: 'LIST' },
]
...connections.map(
({ nodeId }) =>
({ type: 'WalletConnections', id: nodeId } as const)
),
{ type: 'WalletConnections', id: 'LIST' },
]
: [{ type: 'WalletConnections', id: 'LIST' }],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
{
Expand Down Expand Up @@ -1288,12 +1313,12 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(
({ tradeId }) =>
({ type: 'OfferTradeRecord', id: tradeId } as const)
),
{ type: 'OfferTradeRecord', id: 'LIST' },
]
...result.map(
({ tradeId }) =>
({ type: 'OfferTradeRecord', id: tradeId } as const)
),
{ type: 'OfferTradeRecord', id: 'LIST' },
]
: [{ type: 'OfferTradeRecord', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -1575,8 +1600,8 @@ export const walletApi = apiWithTag.injectEndpoints({
async queryFn(args, queryApi, _extraOptions, fetchWithBQ) {
let subscribeResponse:
| {
data: Function;
}
data: Function;
}
| undefined;

function unsubscribe() {
Expand Down Expand Up @@ -2122,9 +2147,9 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags(result) {
return result
? [
...result.map(({ id }) => ({ type: 'DIDWallet', id } as const)),
{ type: 'DIDWallet', id: 'LIST' },
]
...result.map(({ id }) => ({ type: 'DIDWallet', id } as const)),
{ type: 'DIDWallet', id: 'LIST' },
]
: [{ type: 'DIDWallet', id: 'LIST' }];
},
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
Expand Down Expand Up @@ -2224,13 +2249,13 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags: (nftsByWalletId, _error) =>
nftsByWalletId
? [
...Object.entries(nftsByWalletId).flatMap(([_walletId, nfts]) => {
return nfts.map(
nft => ({ type: 'NFTInfo', id: nft.launcherId } as const)
);
}),
{ type: 'NFTInfo', id: 'LIST' },
]
...Object.entries(nftsByWalletId).flatMap(([_walletId, nfts]) => {
return nfts.map(
nft => ({ type: 'NFTInfo', id: nft.launcherId } as const)
);
}),
{ type: 'NFTInfo', id: 'LIST' },
]
: [{ type: 'NFTInfo', id: 'LIST' }],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
{
Expand Down Expand Up @@ -2261,11 +2286,11 @@ export const walletApi = apiWithTag.injectEndpoints({
providesTags: (result, _error) =>
result
? [
...result.map(({ walletId }) => ({
NFTWalletWithDID: walletId,
})),
{ NFTWalletWithDID: 'LIST' },
]
...result.map(({ walletId }) => ({
NFTWalletWithDID: walletId,
})),
{ NFTWalletWithDID: 'LIST' },
]
: [{ type: 'NFTWalletWithDID', id: 'LIST' }],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, [
{
Expand Down Expand Up @@ -2352,10 +2377,10 @@ export const walletApi = apiWithTag.injectEndpoints({
invalidatesTags: (result, _error, { nftLauncherId }) =>
result
? [
{ type: 'NFTInfo', id: 'LIST' },
{ type: 'NFTWalletWithDID', id: 'LIST' },
{ type: 'DIDWallet', id: 'LIST' },
]
{ type: 'NFTInfo', id: 'LIST' },
{ type: 'NFTWalletWithDID', id: 'LIST' },
{ type: 'DIDWallet', id: 'LIST' },
]
: [],
}),

Expand Down
10 changes: 5 additions & 5 deletions chives/masternode/masternode_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ async def checkSyncedStatus(self, logged_in_fingerprint=None) -> None:
return checkSyncedStatus, checkSyncedStatusText, logged_in_fingerprint
elif is_synced:
checkSyncedStatusText.append("Chives Wallet Sync Status: Synced")
checkSyncedStatusText.append(f"Chives Wallet Derivation ndex: {self.get_current_derivation_index}")
checkSyncedStatusText.append(f"Chives Wallet Derivation index: {self.get_current_derivation_index}")
checkSyncedStatus += 1
else:
checkSyncedStatusText.append("Chives Wallet Sync Status: Not synced")
Expand Down Expand Up @@ -997,9 +997,9 @@ async def masternode_cancel_json(self, args: dict, wallet_client: WalletRpcClien
cancel_masternode_staking_coins = await self.cancel_masternode_staking_coins(STAKING_ADDRESS, STAKING_PUZZLE, wallet_client, fingerprint)
# print(f"cancel_masternode_staking_coins:{cancel_masternode_staking_coins}")
if cancel_masternode_staking_coins is not None and "tx_id" in cancel_masternode_staking_coins:
jsonResult['data'].append({"Canncel staking coins for MasterNode have submitted to nodes": ""})
jsonResult['data'].append({"Cancel staking coins for MasterNode have submitted to nodes": ""})
jsonResult['data'].append(
{"You have canncel staking coins. Waiting 1-3 minutes, will see your coins in wallet.": ""})
{"You have cancel staking coins. Waiting 1-3 minutes, will see your coins in wallet.": ""})
jsonResult['data'].append({"": ""})
jsonResult['data'].append({"Tx id": cancel_masternode_staking_coins['tx_id']})
jsonResult['success'] = True
Expand Down Expand Up @@ -1531,7 +1531,7 @@ async def save_launcher(self, launcher_id, pk, Height, StakingData):
return StakingData

async def get_all_nft_ids(self):
query = "SELECT launcher_id FROM masternode_list"
query = "SELECT launcher_id FROM masternode_list order by Height desc"
cursor = await self.db_connection.execute(query)
rows = await cursor.fetchall()
await cursor.close()
Expand Down Expand Up @@ -1759,7 +1759,7 @@ async def cancel_staking_coins_from_staking_coin(self, STAKING_ADDRESS, STAKING_
return res
elif res["status"] == "PENDING":
res['success'] = True
res["error"] = "Cancel Staking Coin Failed. Maybe it can only be canceled after reaching the specified block height. If you choose for test purpose, it will can canncel after 10 minutes."
res["error"] = "Cancel Staking Coin Failed. Maybe it can only be canceled after reaching the specified block height. If you choose for test purpose, it will can cancel after 10 minutes."
return res
else:
return res
Expand Down

0 comments on commit d9ec8c7

Please sign in to comment.