Skip to content

Commit

Permalink
Merge pull request #1820 from Chia-Network/rifeljm/#1699-verifiable-c…
Browse files Browse the repository at this point in the history
…redentials
  • Loading branch information
paninaro authored Jun 5, 2023
2 parents b493c9b + 226f345 commit 60491b6
Show file tree
Hide file tree
Showing 14 changed files with 754 additions and 78 deletions.
15 changes: 14 additions & 1 deletion packages/api-react/src/services/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,20 @@ export const walletApi = apiWithTag.injectEndpoints({
transformResponse: (response) => response.vcRecord,
}),

getVCList: query(build, VC, 'getVCList'),
getVCList: query(build, VC, 'getVCList', {
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onVCCoinAdded',
service: VC,
endpoint: 'getVCList',
},
{
command: 'onVCCoinRemoved',
service: VC,
endpoint: 'getVCList',
},
]),
}),

spendVC: mutation(build, VC, 'spendVC'),

Expand Down
26 changes: 26 additions & 0 deletions packages/api/src/services/WalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,32 @@ export default class Wallet extends Service {
return this.onStateChanged('nft_coin_updated', callback);
}

onVCCoinAdded(
callback: (
data: {
additionalData: Object;
state: 'vc_coin_added';
walletId: number;
},
message: Message
) => void
) {
return this.onStateChanged('vc_coin_added', callback);
}

onVCCoinRemoved(
callback: (
data: {
additionalData: Object;
state: 'vc_coin_removed';
walletId: number;
},
message: Message
) => void
) {
return this.onStateChanged('vc_coin_removed', callback);
}

onNewDerivationIndex(
callback: (
data: {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/wallets/VC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class VCWallet extends Wallet {
return this.command<{ proofs: any }>('vc_get_proofs_for_root', { root });
}

async revokeVC(args: { vcParentId: string; fee: number; reusePuzhash: boolean }) {
async revokeVC(args: { vcParentId: string; fee?: number; reusePuzhash?: boolean }) {
return this.command<{
transactions: TransactionType[];
}>('vc_revoke', args);
Expand Down
9 changes: 9 additions & 0 deletions packages/gui/src/@types/WalletConnectCommandParamName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ enum WalletConnectCommandParamName {
META_URIS = 'metaUris',
NAME = 'name',
NEW_ADDRESS = 'newAddress',
NEW_PROOF_HASH = 'newProofHash',
NEW_PUZHASH = 'newPuzhash',
NFT_COIN_ID = 'nftCoinId',
NFT_COIN_IDS = 'nftCoinIds',
NFT_LAUNCHER_ID = 'nftLauncherId',
Expand All @@ -36,8 +38,12 @@ enum WalletConnectCommandParamName {
OFFER = 'offer',
OFFER_DATA = 'offerData',
OFFER_ID = 'offerId',
PROOFS = 'proofs',
PROVIDER_INNER_PUZHASH = 'providerInnerPuzhash',
PUBKEY = 'pubkey',
REVERSE = 'reverse',
REUSE_PUZHASH = 'reusePuzhash',
ROOT = 'root',
ROYALTY_ADDRESS = 'royaltyAddress',
ROYALTY_PERCENTAGE = 'royaltyPercentage',
SECURE = 'secure',
Expand All @@ -53,6 +59,9 @@ enum WalletConnectCommandParamName {
URIS = 'uris',
URL = 'url',
VALIDATE_ONLY = 'validateOnly',
VC_ID = 'vcId',
VC_PARENT_ID = 'vcParentId',
WAIT_FOR_CONFIRMATION = 'waitForConfirmation',
WALLET_ID = 'walletId',
WALLET_IDS = 'walletIds',
WALLET_IDS_AND_AMOUNTS = 'walletIdsAndAmounts',
Expand Down
Loading

0 comments on commit 60491b6

Please sign in to comment.