Skip to content

Commit

Permalink
allow all methods needed for tari.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnaveira committed Jul 17, 2024
1 parent b27a002 commit a07f906
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { useTheme } from "@mui/material/styles";
import { TariPermission, TariPermissionKeyList, TariPermissionTransactionGet, TariPermissionTransactionSend } from "../../utils/tari_permissions";
import { Core } from '@walletconnect/core'
import { Web3Wallet } from '@walletconnect/web3wallet'
import { substatesGet, client as wallet_daemon_client } from "../../utils/json_rpc";
import { accountsGetBalances, accountsGetDefault, confidentialViewVaultBalance, keysCreate, substatesGet, templatesGet, transactionsGet, transactionsGetResult, transactionsSubmit } from "../../utils/json_rpc";

const projectId: string | null = import.meta.env.VITE_WALLET_CONNECT_PROJECT_ID || null;

Expand Down Expand Up @@ -126,10 +126,24 @@ const ConnectorDialog = () => {
return wallet;
}

async function send_wallet_daemon_request(method, params) {
async function send_wallet_daemon_request(method: string, params: any) {
switch(method) {
case "substates.get":
return substatesGet(params);
case "accounts.get_default":
return accountsGetDefault(params);
case "accounts.get_balances":
return accountsGetBalances(params);
case "transactions.submit":
return transactionsSubmit(params);
case "transactions.get_result":
return transactionsGetResult(params);
case "templates.get":
return templatesGet(params);
case "keys.create":
return keysCreate(params);
case "confidential.view_vault_balance":
return confidentialViewVaultBalance(params);
default:
throw new Error("Invalid wallet daemon method")
}
Expand Down
11 changes: 8 additions & 3 deletions applications/tari_dan_wallet_web_ui/src/utils/json_rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ import type {
AccountsTransferResponse,
SubstatesGetRequest,
SubstatesGetResponse,
TemplatesGetResponse,
} from "@tariproject/typescript-bindings/wallet-daemon-client";
import { WalletDaemonClient } from "@tariproject/wallet_daemon_client";
import { AccountGetDefaultRequest, TemplatesGetRequest, WalletDaemonClient } from "@tariproject/wallet_daemon_client";

let clientInstance: WalletDaemonClient | null = null;
let pendingClientInstance: Promise<WalletDaemonClient> | null = null;
Expand Down Expand Up @@ -184,6 +185,8 @@ export const accountsSetDefault = (request: AccountSetDefaultRequest): Promise<A
export const accountsCreateFreeTestCoins = (
request: AccountsCreateFreeTestCoinsRequest,
): Promise<AccountsCreateFreeTestCoinsResponse> => client().then((c) => c.createFreeTestCoins(request));
export const accountsGetDefault = (request: AccountGetDefaultRequest): Promise<AccountGetResponse> =>
client().then((c) => c.accountsGetDefault(request));

// confidential
export const confidentialViewVaultBalance = (
Expand All @@ -199,8 +202,10 @@ export const nftList = (request: ListAccountNftRequest): Promise<ListAccountNftR
export const validatorsClaimFees = (request: ClaimValidatorFeesRequest): Promise<ClaimValidatorFeesResponse> =>
client().then((c) => c.validatorsClaimFees(request));


// substates

export const substatesGet = (request: SubstatesGetRequest): Promise<SubstatesGetResponse> =>
client().then((c) => c.substatesGet(request));

// templates
export const templatesGet = (request: TemplatesGetRequest): Promise<TemplatesGetResponse> =>
client().then((c) => c.templatesGet(request));

0 comments on commit a07f906

Please sign in to comment.