@tari-project/tarijs 0.12.2 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prototools +1 -1
- package/docusaurus/tari-docs/package.json +1 -1
- package/package.json +2 -3
- package/packages/builders/package.json +1 -1
- package/packages/indexer_provider/package.json +1 -1
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +17 -0
- package/packages/permissions/package.json +1 -1
- package/packages/react-mui-connect-button/package.json +3 -2
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +3 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +22 -1
- package/packages/react-mui-connect-button/tsconfig.json +4 -3
- package/packages/tari_provider/package.json +1 -1
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_signer/src/TariSigner.ts +7 -0
- package/packages/tari_universe/package.json +1 -1
- package/packages/tari_universe/src/signer.ts +20 -2
- package/packages/tari_universe/src/types.ts +2 -1
- package/packages/tari_universe/src/useIframeMessage.ts +82 -0
- package/packages/tari_universe/src/utils.ts +6 -2
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs_types/package.json +1 -1
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/signer.ts +23 -0
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +24 -0
- package/pnpm-workspace.yaml +1 -1
package/.prototools
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@eslint/js": "^9.30.0",
|
|
14
|
-
"@moonrepo/cli": "^1.32.1",
|
|
15
14
|
"eslint": "^9.30.0",
|
|
16
15
|
"knip": "^5.61.3",
|
|
17
16
|
"typedoc": "^0.28.7",
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
"typescript-eslint": "^8.35.0"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
|
-
"@tari-project/tarijs-types": "^0.
|
|
22
|
+
"@tari-project/tarijs-types": "^0.13.1"
|
|
24
23
|
},
|
|
25
24
|
"scripts": {
|
|
26
25
|
"docs": "typedoc",
|
|
@@ -15,9 +15,13 @@ import {
|
|
|
15
15
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
16
16
|
import { connectSnap, getSnap, isFlask, Snap } from "./utils";
|
|
17
17
|
import {
|
|
18
|
+
AccountGetResponse,
|
|
19
|
+
AccountsListRequest,
|
|
20
|
+
AccountsListResponse,
|
|
18
21
|
ConfidentialViewVaultBalanceRequest,
|
|
19
22
|
ListAccountNftRequest,
|
|
20
23
|
ListAccountNftResponse,
|
|
24
|
+
WalletGetInfoResponse,
|
|
21
25
|
} from "@tari-project/typescript-bindings";
|
|
22
26
|
|
|
23
27
|
export const MetamaskNotInstalled = "METAMASK_NOT_INSTALLED";
|
|
@@ -84,10 +88,18 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
|
|
91
|
+
async accountsList(req: AccountsListRequest): Promise<AccountsListResponse> {
|
|
92
|
+
return await this.metamaskRequest("accountsList", req);
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
async getAccount(): Promise<AccountData> {
|
|
88
96
|
return (await this.metamaskRequest("getAccountData", { account_id: 0 })) as any;
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
async getAccountByAddress(address: string): Promise<AccountGetResponse> {
|
|
100
|
+
return await this.metamaskRequest("accountsGet", { address });
|
|
101
|
+
}
|
|
102
|
+
|
|
91
103
|
async getSubstate(substate_address: string): Promise<Substate> {
|
|
92
104
|
const {
|
|
93
105
|
substate,
|
|
@@ -205,6 +217,11 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
205
217
|
const resp = (await this.metamaskRequest("getNftsList", req)) as ListAccountNftResponse;
|
|
206
218
|
return resp;
|
|
207
219
|
}
|
|
220
|
+
|
|
221
|
+
public async getWalletInfo(): Promise<WalletGetInfoResponse> {
|
|
222
|
+
const resp = (await this.metamaskRequest("getWalletInfo", {})) as WalletGetInfoResponse;
|
|
223
|
+
return resp;
|
|
224
|
+
}
|
|
208
225
|
}
|
|
209
226
|
|
|
210
227
|
function convertToStatus(result: any): TransactionStatus {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/react-mui-connect-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "React component to connect your website to the Tari Ootle Wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"@tari-project/tari-provider": "workspace:*",
|
|
20
20
|
"@tari-project/tari-signer": "workspace:^",
|
|
21
21
|
"@tari-project/wallet-connect-signer": "workspace:^",
|
|
22
|
-
"@tari-project/wallet-daemon-signer": "workspace:^"
|
|
22
|
+
"@tari-project/wallet-daemon-signer": "workspace:^",
|
|
23
|
+
"@tari-project/tari-universe-signer": "workspace:^"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"@mui/icons-material": "^7",
|
|
@@ -6,6 +6,7 @@ import { TariSigner } from "@tari-project/tari-signer";
|
|
|
6
6
|
import { TariLogoWhite } from "./Logos";
|
|
7
7
|
import { WalletDaemonFetchParameters } from "@tari-project/wallet-daemon-signer";
|
|
8
8
|
import { WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
9
|
+
import { TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
9
10
|
|
|
10
11
|
export interface TariConnectButtonProps {
|
|
11
12
|
isConnected: boolean;
|
|
@@ -13,6 +14,7 @@ export interface TariConnectButtonProps {
|
|
|
13
14
|
onConnected?: (signer: TariSigner) => void;
|
|
14
15
|
walletConnectParams?: WalletConnectParameters;
|
|
15
16
|
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
17
|
+
tariUniverseParams?: TariUniverseSignerParameters;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export function TariConnectButton(props: TariConnectButtonProps) {
|
|
@@ -44,6 +46,7 @@ export function TariConnectButton(props: TariConnectButtonProps) {
|
|
|
44
46
|
onConnected={props.onConnected}
|
|
45
47
|
walletConnectParams={props.walletConnectParams}
|
|
46
48
|
walletDaemonParams={props.walletDaemonParams}
|
|
49
|
+
tariUniverseParams={props.tariUniverseParams}
|
|
47
50
|
/>
|
|
48
51
|
</>
|
|
49
52
|
);
|
|
@@ -8,17 +8,19 @@ import { WalletDaemonTariSigner, WalletDaemonFetchParameters } from "@tari-proje
|
|
|
8
8
|
import { ReactElement, useState } from "react";
|
|
9
9
|
import { WalletConnectTariSigner, WalletConnectParameters } from "@tari-project/wallet-connect-signer";
|
|
10
10
|
import { TariLogo, WalletConnectLogo } from "./Logos";
|
|
11
|
+
import { TariUniverseSigner, TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
11
12
|
|
|
12
13
|
export interface WalletSelectionProps {
|
|
13
14
|
open: boolean;
|
|
14
15
|
onConnected?: (signer: TariSigner) => void;
|
|
15
16
|
walletConnectParams?: WalletConnectParameters;
|
|
16
17
|
walletDaemonParams?: WalletDaemonFetchParameters;
|
|
18
|
+
tariUniverseParams?: TariUniverseSignerParameters;
|
|
17
19
|
onClose: () => void;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactElement {
|
|
21
|
-
const { onClose, open, onConnected, walletConnectParams, walletDaemonParams } = props;
|
|
23
|
+
const { onClose, open, onConnected, walletConnectParams, walletDaemonParams, tariUniverseParams } = props;
|
|
22
24
|
const [isBusy, setIsBusy] = useState(false);
|
|
23
25
|
const [error, setError] = useState<string | null>(null);
|
|
24
26
|
|
|
@@ -58,6 +60,15 @@ export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactEle
|
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
|
|
63
|
+
const onTariUniverseClick = async () => {
|
|
64
|
+
if (!tariUniverseParams) {
|
|
65
|
+
throw new Error("Tari Universe Signer parameters were not provided.");
|
|
66
|
+
}
|
|
67
|
+
const tuSigner = new TariUniverseSigner(tariUniverseParams);
|
|
68
|
+
onConnected?.(tuSigner);
|
|
69
|
+
handleClose();
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
return (
|
|
62
73
|
<Dialog fullWidth={true} onClose={handleClose} open={open}>
|
|
63
74
|
<Box sx={{ padding: 4, borderRadius: 4 }}>
|
|
@@ -99,6 +110,16 @@ export function TariWalletSelectionDialog(props: WalletSelectionProps): ReactEle
|
|
|
99
110
|
></WalletConnectionMethodCard>
|
|
100
111
|
</Grid>
|
|
101
112
|
)}
|
|
113
|
+
|
|
114
|
+
{tariUniverseParams && (
|
|
115
|
+
<Grid container rowSpacing={1} columnSpacing={{ xs: 4 }}>
|
|
116
|
+
<WalletConnectionMethodCard
|
|
117
|
+
logo={<TariLogo />}
|
|
118
|
+
text="Tari Universe"
|
|
119
|
+
callback={onTariUniverseClick}
|
|
120
|
+
></WalletConnectionMethodCard>
|
|
121
|
+
</Grid>
|
|
122
|
+
)}
|
|
102
123
|
</Grid>
|
|
103
124
|
</Box>
|
|
104
125
|
</Dialog>
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
"outDir": "./dist",
|
|
9
9
|
"rootDir": "./src"
|
|
10
10
|
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
],
|
|
11
|
+
"include": ["src/**/*"],
|
|
14
12
|
"references": [
|
|
15
13
|
{
|
|
16
14
|
"path": "../permissions"
|
|
@@ -26,6 +24,9 @@
|
|
|
26
24
|
},
|
|
27
25
|
{
|
|
28
26
|
"path": "../walletconnect"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../tari_universe"
|
|
29
30
|
}
|
|
30
31
|
]
|
|
31
32
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
AccountGetResponse,
|
|
3
|
+
AccountsListRequest,
|
|
4
|
+
AccountsListResponse,
|
|
2
5
|
ConfidentialViewVaultBalanceRequest,
|
|
3
6
|
ListAccountNftRequest,
|
|
4
7
|
ListAccountNftResponse,
|
|
8
|
+
WalletGetInfoResponse,
|
|
5
9
|
} from "@tari-project/typescript-bindings";
|
|
6
10
|
import {
|
|
7
11
|
GetTransactionResultResponse,
|
|
@@ -18,7 +22,9 @@ import {
|
|
|
18
22
|
export interface TariSigner {
|
|
19
23
|
signerName: string;
|
|
20
24
|
isConnected(): boolean;
|
|
25
|
+
accountsList(req: AccountsListRequest): Promise<AccountsListResponse>;
|
|
21
26
|
getAccount(): Promise<AccountData>;
|
|
27
|
+
getAccountByAddress(address: string): Promise<AccountGetResponse>;
|
|
22
28
|
getSubstate(substate_address: string): Promise<Substate>;
|
|
23
29
|
submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
|
|
24
30
|
getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
|
|
@@ -27,4 +33,5 @@ export interface TariSigner {
|
|
|
27
33
|
getConfidentialVaultBalances(req: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances>;
|
|
28
34
|
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
29
35
|
getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse>;
|
|
36
|
+
getWalletInfo(): Promise<WalletGetInfoResponse>;
|
|
30
37
|
}
|
|
@@ -14,11 +14,16 @@ import { SignerRequest, SignerMethodNames, SignerReturnType, TariUniverseSignerP
|
|
|
14
14
|
import { sendSignerCall } from "./utils";
|
|
15
15
|
import { TariSigner } from "@tari-project/tari-signer";
|
|
16
16
|
import {
|
|
17
|
+
AccountGetResponse,
|
|
17
18
|
AccountsGetBalancesResponse,
|
|
19
|
+
AccountsListRequest,
|
|
20
|
+
AccountsListResponse,
|
|
18
21
|
ConfidentialViewVaultBalanceRequest,
|
|
19
22
|
ListAccountNftRequest,
|
|
20
23
|
ListAccountNftResponse,
|
|
24
|
+
WalletGetInfoResponse,
|
|
21
25
|
} from "@tari-project/typescript-bindings";
|
|
26
|
+
import { MessageType } from "./useIframeMessage";
|
|
22
27
|
|
|
23
28
|
export class TariUniverseSigner implements TariSigner {
|
|
24
29
|
public signerName = "TariUniverse";
|
|
@@ -26,8 +31,8 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
26
31
|
|
|
27
32
|
public constructor(public params: TariUniverseSignerParameters) {
|
|
28
33
|
const filterResizeEvent = function (event: MessageEvent) {
|
|
29
|
-
if (event.data && event.data.type ===
|
|
30
|
-
const resizeEvent = new CustomEvent(
|
|
34
|
+
if (event.data && event.data.type === MessageType.RESIZE) {
|
|
35
|
+
const resizeEvent = new CustomEvent(MessageType.RESIZE, {
|
|
31
36
|
detail: { width: event.data.width, height: event.data.height },
|
|
32
37
|
});
|
|
33
38
|
window.dispatchEvent(resizeEvent);
|
|
@@ -83,10 +88,19 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
83
88
|
return this.sendRequest({ methodName: "requestParentSize", args: [] });
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
public async accountsList(req: AccountsListRequest): Promise<AccountsListResponse> {
|
|
92
|
+
return this.sendRequest({ methodName: "accountsList", args: [req] });
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
public async getAccount(): Promise<AccountData> {
|
|
96
|
+
console.warn("ELOSZKI Z GET ACCOUNT");
|
|
87
97
|
return this.sendRequest({ methodName: "getAccount", args: [] });
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
public async getAccountByAddress(address: string): Promise<AccountGetResponse> {
|
|
101
|
+
return this.sendRequest({ methodName: "getAccountByAddress", args: [address] });
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
public async getAccountBalances(componentAddress: string): Promise<AccountsGetBalancesResponse> {
|
|
91
105
|
return this.sendRequest({
|
|
92
106
|
methodName: "getAccountBalances",
|
|
@@ -126,4 +140,8 @@ export class TariUniverseSigner implements TariSigner {
|
|
|
126
140
|
public async getNftsFromAccountBalances(req: ListAccountNftFromBalancesRequest): Promise<ListAccountNftResponse> {
|
|
127
141
|
return this.sendRequest({ methodName: "getNftsFromAccountBalances", args: [req] });
|
|
128
142
|
}
|
|
143
|
+
|
|
144
|
+
public async getWalletInfo(): Promise<WalletGetInfoResponse> {
|
|
145
|
+
return this.sendRequest({ methodName: "getWalletInfo", args: [] });
|
|
146
|
+
}
|
|
129
147
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
2
2
|
import { TariUniverseSigner } from "./signer";
|
|
3
|
+
import { MessageType } from "./useIframeMessage";
|
|
3
4
|
|
|
4
5
|
export type TariUniverseSignerParameters = {
|
|
5
6
|
permissions: TariPermissions;
|
|
@@ -28,7 +29,7 @@ export type SignerRequest<T extends SignerMethodNames> = {
|
|
|
28
29
|
|
|
29
30
|
export type SignerResponse<T extends SignerMethodNames> = {
|
|
30
31
|
id: number;
|
|
31
|
-
type:
|
|
32
|
+
type: MessageType.SIGNER_CALL;
|
|
32
33
|
result: SignerReturnType<T>;
|
|
33
34
|
resultError?: string;
|
|
34
35
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export enum MessageType {
|
|
2
|
+
SIGNER_CALL = "SIGNER_CALL",
|
|
3
|
+
RESIZE = "resize",
|
|
4
|
+
SET_LANGUAGE = "SET_LANGUAGE",
|
|
5
|
+
SET_THEME = "SET_THEME",
|
|
6
|
+
GET_INIT_CONFIG = "GET_INIT_CONFIG",
|
|
7
|
+
OPEN_EXTERNAL_LINK = "OPEN_EXTERNAL_LINK",
|
|
8
|
+
ERROR = "ERROR",
|
|
9
|
+
NOTIFICATION = "NOTIFICATION",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface SignerCallMessage {
|
|
13
|
+
type: MessageType.SIGNER_CALL;
|
|
14
|
+
payload: {
|
|
15
|
+
id: number;
|
|
16
|
+
methodName: string;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
args: any[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ResizeMessage {
|
|
23
|
+
type: MessageType.RESIZE;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SetLanguageMessage {
|
|
29
|
+
type: MessageType.SET_LANGUAGE;
|
|
30
|
+
payload: {
|
|
31
|
+
language: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface SetThemeMessage {
|
|
36
|
+
type: MessageType.SET_THEME;
|
|
37
|
+
payload: {
|
|
38
|
+
theme: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface GetInitConfigMessage {
|
|
43
|
+
type: MessageType.GET_INIT_CONFIG;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface OpenLinkMessage {
|
|
47
|
+
type: MessageType.OPEN_EXTERNAL_LINK;
|
|
48
|
+
payload: {
|
|
49
|
+
url: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type ErrorMessage = {
|
|
54
|
+
type: MessageType.ERROR;
|
|
55
|
+
payload: {
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface EmitNotificationMessage {
|
|
61
|
+
type: MessageType.NOTIFICATION;
|
|
62
|
+
payload: {
|
|
63
|
+
notification: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type IframeMessage =
|
|
68
|
+
| SignerCallMessage
|
|
69
|
+
| ResizeMessage
|
|
70
|
+
| SetLanguageMessage
|
|
71
|
+
| SetThemeMessage
|
|
72
|
+
| GetInitConfigMessage
|
|
73
|
+
| OpenLinkMessage
|
|
74
|
+
| ErrorMessage
|
|
75
|
+
| EmitNotificationMessage;
|
|
76
|
+
|
|
77
|
+
// Post a message to the parent window
|
|
78
|
+
export function postToParentIframe(message: IframeMessage, targetOrigin: string = "*") {
|
|
79
|
+
if (window.parent && message.type) {
|
|
80
|
+
window.parent.postMessage(message, targetOrigin);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SignerMethodNames, SignerRequest, SignerResponse, SignerReturnType } from "./types";
|
|
2
|
+
import { MessageType, postToParentIframe } from "./useIframeMessage";
|
|
2
3
|
|
|
3
4
|
export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
4
5
|
req: Omit<SignerRequest<MethodName>, "id">,
|
|
@@ -10,7 +11,7 @@ export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
|
10
11
|
window.removeEventListener("message", event_ref);
|
|
11
12
|
reject(resp.data.resultError);
|
|
12
13
|
}
|
|
13
|
-
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type ===
|
|
14
|
+
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type === MessageType.SIGNER_CALL) {
|
|
14
15
|
window.removeEventListener("message", event_ref);
|
|
15
16
|
resolve(resp.data.result);
|
|
16
17
|
}
|
|
@@ -18,6 +19,9 @@ export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
|
18
19
|
|
|
19
20
|
window.addEventListener("message", event_ref, false);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
postToParentIframe({
|
|
23
|
+
type: MessageType.SIGNER_CALL,
|
|
24
|
+
payload: { args: req.args, methodName: req.methodName, id: id },
|
|
25
|
+
});
|
|
22
26
|
});
|
|
23
27
|
}
|
|
@@ -16,12 +16,16 @@ import {
|
|
|
16
16
|
ListSubstatesRequest,
|
|
17
17
|
} from "@tari-project/tarijs-types";
|
|
18
18
|
import {
|
|
19
|
+
AccountGetResponse,
|
|
20
|
+
AccountsListRequest,
|
|
21
|
+
AccountsListResponse,
|
|
19
22
|
ConfidentialViewVaultBalanceRequest,
|
|
20
23
|
KeyBranch,
|
|
21
24
|
ListAccountNftRequest,
|
|
22
25
|
ListAccountNftResponse,
|
|
23
26
|
substateIdToString,
|
|
24
27
|
SubstatesListRequest,
|
|
28
|
+
WalletGetInfoResponse,
|
|
25
29
|
} from "@tari-project/typescript-bindings";
|
|
26
30
|
|
|
27
31
|
export const WalletDaemonNotConnected = "WALLET_DAEMON_NOT_CONNECTED";
|
|
@@ -133,6 +137,11 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
public async accountsList(req: AccountsListRequest): Promise<AccountsListResponse> {
|
|
141
|
+
const resp = await this.client.accountsList(req);
|
|
142
|
+
return resp;
|
|
143
|
+
}
|
|
144
|
+
|
|
136
145
|
public async getAccount(): Promise<AccountData> {
|
|
137
146
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
138
147
|
const { account, public_key } = (await this.client.accountsGetDefault({})) as any;
|
|
@@ -158,6 +167,15 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
158
167
|
};
|
|
159
168
|
}
|
|
160
169
|
|
|
170
|
+
public async getAccountByAddress(address: string): Promise<AccountGetResponse> {
|
|
171
|
+
const resp = await this.client.accountsGet({
|
|
172
|
+
name_or_address: {
|
|
173
|
+
ComponentAddress: address,
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
return resp;
|
|
177
|
+
}
|
|
178
|
+
|
|
161
179
|
public async getAccountBalances(componentAddress: string): Promise<unknown> {
|
|
162
180
|
return await this.client.accountsGetBalances({ account: { ComponentAddress: componentAddress }, refresh: true });
|
|
163
181
|
}
|
|
@@ -255,4 +273,9 @@ export class WalletDaemonTariSigner implements TariSigner {
|
|
|
255
273
|
public async getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse> {
|
|
256
274
|
return await this.client.nftsList(req);
|
|
257
275
|
}
|
|
276
|
+
|
|
277
|
+
public async getWalletInfo(): Promise<WalletGetInfoResponse> {
|
|
278
|
+
const resp = await this.client.walletGetInfo();
|
|
279
|
+
return resp;
|
|
280
|
+
}
|
|
258
281
|
}
|
|
@@ -15,12 +15,16 @@ import {
|
|
|
15
15
|
SubmitTransactionResponse,
|
|
16
16
|
} from "@tari-project/tarijs-types";
|
|
17
17
|
import {
|
|
18
|
+
AccountGetResponse,
|
|
19
|
+
AccountsListRequest,
|
|
20
|
+
AccountsListResponse,
|
|
18
21
|
ConfidentialViewVaultBalanceRequest,
|
|
19
22
|
KeyBranch,
|
|
20
23
|
ListAccountNftRequest,
|
|
21
24
|
ListAccountNftResponse,
|
|
22
25
|
substateIdToString,
|
|
23
26
|
TransactionSubmitRequest,
|
|
27
|
+
WalletGetInfoResponse,
|
|
24
28
|
} from "@tari-project/typescript-bindings";
|
|
25
29
|
import { TariPermission } from "@tari-project/tari-permissions";
|
|
26
30
|
|
|
@@ -39,6 +43,7 @@ const walletConnectParams = {
|
|
|
39
43
|
"tari_createFreeTestCoins",
|
|
40
44
|
"tari_listSubstates",
|
|
41
45
|
"tari_getNftsList",
|
|
46
|
+
"tari_getWalletInfo",
|
|
42
47
|
],
|
|
43
48
|
chains: ["tari:devnet"],
|
|
44
49
|
events: [],
|
|
@@ -154,6 +159,11 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
154
159
|
return this.wcSession !== null;
|
|
155
160
|
}
|
|
156
161
|
|
|
162
|
+
async accountsList(req: AccountsListRequest): Promise<AccountsListResponse> {
|
|
163
|
+
const res = await this.sendRequest("tari_accountsList", req);
|
|
164
|
+
return res as AccountsListResponse;
|
|
165
|
+
}
|
|
166
|
+
|
|
157
167
|
async getAccount(): Promise<AccountData> {
|
|
158
168
|
const { account, public_key } = await this.sendRequest("tari_getDefaultAccount", {});
|
|
159
169
|
const { balances } = await this.sendRequest("tari_getAccountBalances", {
|
|
@@ -177,6 +187,15 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
177
187
|
};
|
|
178
188
|
}
|
|
179
189
|
|
|
190
|
+
async getAccountByAddress(address: string): Promise<AccountGetResponse> {
|
|
191
|
+
const res = await this.sendRequest("tari_getAccountByAddress", {
|
|
192
|
+
name_or_address: {
|
|
193
|
+
ComponentAddress: address,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
return res as AccountGetResponse;
|
|
197
|
+
}
|
|
198
|
+
|
|
180
199
|
async getSubstate(substate_address: string): Promise<Substate> {
|
|
181
200
|
const method = "tari_getSubstate";
|
|
182
201
|
const params = { substate_id: substate_address };
|
|
@@ -296,4 +315,9 @@ export class WalletConnectTariSigner implements TariSigner {
|
|
|
296
315
|
const res = await this.sendRequest(method, params);
|
|
297
316
|
return res as ListAccountNftResponse;
|
|
298
317
|
}
|
|
318
|
+
|
|
319
|
+
public async getWalletInfo(): Promise<WalletGetInfoResponse> {
|
|
320
|
+
const res = await this.sendRequest("tari_getWalletInfo", {});
|
|
321
|
+
return res as WalletGetInfoResponse;
|
|
322
|
+
}
|
|
299
323
|
}
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -10,7 +10,7 @@ catalog:
|
|
|
10
10
|
vitest: ^3.0.4
|
|
11
11
|
vite: ^6.1.0
|
|
12
12
|
"@types/node": ^22.13.1
|
|
13
|
-
"@tari-project/typescript-bindings": ">=1.
|
|
13
|
+
"@tari-project/typescript-bindings": ">=1.15.0"
|
|
14
14
|
"@tari-project/wallet_jrpc_client": ^1.7.2
|
|
15
15
|
"@metamask/providers": ^18.2.0
|
|
16
16
|
"@walletconnect/universal-provider": 2.21.3
|