@tari-project/wallet-daemon-signer 0.12.1 → 0.13.0

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/dist/provider.js CHANGED
@@ -14,7 +14,7 @@ export class WalletDaemonTariProvider {
14
14
  }
15
15
  static async buildWebRtc(params) {
16
16
  const allPermissions = WalletDaemonTariProvider.buildPermissions(params);
17
- let connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
17
+ const connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
18
18
  const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
19
19
  await connection.init(allPermissions, (conn) => {
20
20
  params.onConnection?.();
@@ -50,7 +50,7 @@ export class WalletDaemonTariProvider {
50
50
  }
51
51
  async getSubstate(req) {
52
52
  // TODO: Substate address cannot be converted to SubstateId directly - Perhaps we need to change the provider interface
53
- const { substate, } = await this.client.substatesGet({ substate_id: req.substate_address });
53
+ const { substate } = await this.client.substatesGet({ substate_id: req.substate_address });
54
54
  if (!substate) {
55
55
  throw new Error(`Substate not found for address: ${req.substate_address}`);
56
56
  }
package/dist/signer.d.ts CHANGED
@@ -2,7 +2,7 @@ import { TariPermissions } from "@tari-project/tari-permissions";
2
2
  import { TariSigner } from "@tari-project/tari-signer";
3
3
  import { WalletDaemonClient } from "@tari-project/wallet_jrpc_client";
4
4
  import { AccountData, GetTransactionResultResponse, SubmitTransactionRequest, SubmitTransactionResponse, VaultBalances, TemplateDefinition, Substate, ListSubstatesResponse, ListSubstatesRequest } from "@tari-project/tarijs-types";
5
- import { ConfidentialViewVaultBalanceRequest, ListAccountNftRequest, ListAccountNftResponse } from "@tari-project/typescript-bindings";
5
+ import { AccountGetResponse, AccountsListRequest, AccountsListResponse, ConfidentialViewVaultBalanceRequest, ListAccountNftRequest, ListAccountNftResponse, WalletGetInfoResponse } from "@tari-project/typescript-bindings";
6
6
  export declare const WalletDaemonNotConnected = "WALLET_DAEMON_NOT_CONNECTED";
7
7
  export declare const Unsupported = "UNSUPPORTED";
8
8
  export interface WalletDaemonBaseParameters {
@@ -32,7 +32,9 @@ export declare class WalletDaemonTariSigner implements TariSigner {
32
32
  get tokenUrl(): string | undefined;
33
33
  isConnected(): boolean;
34
34
  createFreeTestCoins(): Promise<AccountData>;
35
+ accountsList(req: AccountsListRequest): Promise<AccountsListResponse>;
35
36
  getAccount(): Promise<AccountData>;
37
+ getAccountByAddress(address: string): Promise<AccountGetResponse>;
36
38
  getAccountBalances(componentAddress: string): Promise<unknown>;
37
39
  getSubstate(substateId: string): Promise<Substate>;
38
40
  submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
@@ -42,4 +44,5 @@ export declare class WalletDaemonTariSigner implements TariSigner {
42
44
  getConfidentialVaultBalances({ vault_id, view_key_id, maximum_expected_value, minimum_expected_value, }: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances>;
43
45
  listSubstates({ filter_by_template, filter_by_type, limit, offset, }: ListSubstatesRequest): Promise<ListSubstatesResponse>;
44
46
  getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse>;
47
+ getWalletInfo(): Promise<WalletGetInfoResponse>;
45
48
  }
package/dist/signer.js CHANGED
@@ -16,7 +16,7 @@ export class WalletDaemonTariSigner {
16
16
  }
17
17
  static async build(params) {
18
18
  const allPermissions = WalletDaemonTariSigner.buildPermissions(params);
19
- let connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
19
+ const connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
20
20
  const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
21
21
  await connection.init(allPermissions, (conn) => {
22
22
  params.onConnection?.();
@@ -81,7 +81,12 @@ export class WalletDaemonTariSigner {
81
81
  vaults: [],
82
82
  };
83
83
  }
84
+ async accountsList(req) {
85
+ const resp = await this.client.accountsList(req);
86
+ return resp;
87
+ }
84
88
  async getAccount() {
89
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
85
90
  const { account, public_key } = (await this.client.accountsGetDefault({}));
86
91
  const address = typeof account.address === "object" ? account.address.Component : account.address;
87
92
  const { balances } = await this.client.accountsGetBalances({
@@ -102,11 +107,19 @@ export class WalletDaemonTariSigner {
102
107
  })),
103
108
  };
104
109
  }
110
+ async getAccountByAddress(address) {
111
+ const resp = await this.client.accountsGet({
112
+ name_or_address: {
113
+ ComponentAddress: address,
114
+ },
115
+ });
116
+ return resp;
117
+ }
105
118
  async getAccountBalances(componentAddress) {
106
119
  return await this.client.accountsGetBalances({ account: { ComponentAddress: componentAddress }, refresh: true });
107
120
  }
108
121
  async getSubstate(substateId) {
109
- const { substate, } = await this.client.substatesGet({ substate_id: substateId });
122
+ const { substate } = await this.client.substatesGet({ substate_id: substateId });
110
123
  if (!substate) {
111
124
  throw new Error(`Substate not found for address: ${substateId}`);
112
125
  }
@@ -146,7 +159,7 @@ export class WalletDaemonTariSigner {
146
159
  return res.public_key;
147
160
  }
148
161
  async getTemplateDefinition(template_address) {
149
- let resp = await this.client.templatesGet({ template_address });
162
+ const resp = await this.client.templatesGet({ template_address });
150
163
  return resp.template_definition;
151
164
  }
152
165
  async getConfidentialVaultBalances({ vault_id, view_key_id, maximum_expected_value = null, minimum_expected_value = null, }) {
@@ -176,4 +189,8 @@ export class WalletDaemonTariSigner {
176
189
  async getNftsList(req) {
177
190
  return await this.client.nftsList(req);
178
191
  }
192
+ async getWalletInfo() {
193
+ const resp = await this.client.walletGetInfo();
194
+ return resp;
195
+ }
179
196
  }
package/dist/webrtc.js CHANGED
@@ -20,12 +20,12 @@ class SignalingServer {
20
20
  console.log("jsonRpc", method, token, params);
21
21
  let id = 0;
22
22
  id += 1;
23
- let address = this._server_url;
24
- let headers = { "Content-Type": "application/json" };
23
+ const address = this._server_url;
24
+ const headers = { "Content-Type": "application/json" };
25
25
  if (token) {
26
26
  headers["Authorization"] = `Bearer ${token}`;
27
27
  }
28
- let response = await fetch(address, {
28
+ const response = await fetch(address, {
29
29
  method: "POST",
30
30
  body: JSON.stringify({
31
31
  method: method,
@@ -35,7 +35,7 @@ class SignalingServer {
35
35
  }),
36
36
  headers: headers,
37
37
  });
38
- let json = await response.json();
38
+ const json = await response.json();
39
39
  if (json.error) {
40
40
  throw json.error;
41
41
  }
@@ -84,14 +84,14 @@ export class TariConnection {
84
84
  await this._signalingServer.initToken(permissions);
85
85
  // Setup our receiving end
86
86
  this._dataChannel.onmessage = (message) => {
87
- let response = JSON.parse(message.data);
87
+ const response = JSON.parse(message.data);
88
88
  console.log("response", response);
89
89
  if (!this._callbacks[response.id]) {
90
90
  console.error("No callback found for id", response.id);
91
91
  return;
92
92
  }
93
93
  // The response should contain id, to identify the Promise.resolve, that is waiting for this result
94
- let [resolve, reject] = this._callbacks[response.id];
94
+ const [resolve, reject] = this._callbacks[response.id];
95
95
  delete this._callbacks[response.id];
96
96
  if (response.payload?.error) {
97
97
  reject(new Error(response.payload.error));
@@ -103,8 +103,7 @@ export class TariConnection {
103
103
  this._dataChannel.onopen = () => {
104
104
  // This should be removed before the release, but it's good for debugging.
105
105
  console.log("Data channel is open!");
106
- this.sendMessage({ id: 0, jsonrpc: "2.0", method: "get.token", params: {} }, this._signalingServer.token)
107
- .then((walletToken) => {
106
+ this.sendMessage({ id: 0, jsonrpc: "2.0", method: "get.token", params: {} }, this._signalingServer.token).then((walletToken) => {
108
107
  if (typeof walletToken !== "string") {
109
108
  throw Error("Received invalid JWT from wallet daemon");
110
109
  }
@@ -141,11 +140,11 @@ export class TariConnection {
141
140
  async setAnswer() {
142
141
  // This is called once the other end got the offer and ices and created and store an answer and its ice candidates
143
142
  // We get its answer sdp
144
- let sdp = await this._signalingServer.getAnswer();
143
+ const sdp = await this._signalingServer.getAnswer();
145
144
  // And its ice candidates
146
- let iceCandidates = await this._signalingServer.getIceCandidates();
145
+ const iceCandidates = await this._signalingServer.getIceCandidates();
147
146
  // For us the answer is remote sdp
148
- let answer = new RTCSessionDescription({ sdp, type: "answer" });
147
+ const answer = new RTCSessionDescription({ sdp, type: "answer" });
149
148
  this._peerConnection.setRemoteDescription(answer);
150
149
  // We add all the ice candidates to connect, the other end is doing the same with our ice candidates
151
150
  for (const iceCandidate of iceCandidates) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tari-project/wallet-daemon-signer",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -10,12 +10,12 @@
10
10
  "author": "The Tari Community",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@tari-project/typescript-bindings": ">=1.14.0",
13
+ "@tari-project/typescript-bindings": ">=1.15.0",
14
14
  "@tari-project/wallet_jrpc_client": "^1.7.2",
15
- "@tari-project/tari-signer": "^0.12.1",
16
- "@tari-project/tari-provider": "^0.12.1",
17
- "@tari-project/tari-permissions": "^0.12.1",
18
- "@tari-project/tarijs-types": "^0.12.1"
15
+ "@tari-project/tari-permissions": "^0.13.0",
16
+ "@tari-project/tari-provider": "^0.13.0",
17
+ "@tari-project/tari-signer": "^0.13.0",
18
+ "@tari-project/tarijs-types": "^0.13.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^22.13.1",
@@ -27,6 +27,7 @@
27
27
  "main": "dist/index.js",
28
28
  "types": "dist/index.d.ts",
29
29
  "scripts": {
30
- "build": "tsc -b"
30
+ "build": "tsc -b",
31
+ "lint": "eslint src/"
31
32
  }
32
33
  }