@concordium/browser-wallet-api-helpers 2.4.0 → 2.5.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/README.md CHANGED
@@ -74,6 +74,15 @@ if (accountAddress) {
74
74
  }
75
75
  ```
76
76
 
77
+ ### getSelectedChain
78
+
79
+ This can be invoked to get the genesis hash of the chain selected in the wallet. The method returns a `Promise`, resolving with the genesis hash (as a hex string) of the selected chain, or undefined if the wallet is locked or has not been set up by the user.
80
+
81
+ ```typescript
82
+ const provider = await detectConcordiumProvider();
83
+ const genesisHash = await provider.getSelectedChain();
84
+ ```
85
+
77
86
  N.B. In the current version, if the currently selected account has not whitelisted the dApp, the returned account will not actually be the most recently selected account, but instead the oldest account that has whitelisted the dApp.
78
87
 
79
88
  ### sendTransaction
@@ -142,10 +151,10 @@ It is possible to sign arbitrary messages using the keys for an account stored i
142
151
 
143
152
  If the wallet is locked, or you have not connected with the wallet (or previously been whitelisted) or if the user rejects signing the meesage, the `Promise` will reject.
144
153
 
145
- The message should either utf8 string or an object with the following fields:
154
+ The message should be either a utf8 string or an object with the following fields:
146
155
 
147
156
  - data: A hex string representing the bytes that should be signed.
148
- - schema: A base64 string that represents a schema for the data field, and which can be used to deserialize the data into a JSON format.
157
+ - schema: A base64 string that represents a schema for the data field, and which can be used to deserialize the data into a JSON format. (For reference, the type of schema used here is the same that is used for smart contract types)
149
158
 
150
159
  The following exemplifies requesting a signature of a message, where the message is a utf8 string:
151
160
 
@@ -1,4 +1,4 @@
1
- import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload, JsonRpcClient, SchemaVersion, UpdateContractPayload, IdStatement, IdProofOutput } from '@concordium/web-sdk';
1
+ import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload, JsonRpcClient, SchemaVersion, UpdateContractPayload, IdStatement, IdProofOutput, ConcordiumGRPCClient } from '@concordium/web-sdk';
2
2
  export declare type SendTransactionPayload = Exclude<AccountTransactionPayload, UpdateContractPayload | InitContractPayload> | Omit<UpdateContractPayload, 'message'> | Omit<InitContractPayload, 'param'>;
3
3
  export declare type SmartContractParameters = {
4
4
  [key: string]: SmartContractParameters;
@@ -70,7 +70,20 @@ interface MainWalletApi {
70
70
  */
71
71
  getMostRecentlySelectedAccount(): Promise<string | undefined>;
72
72
  removeAllListeners(event?: EventType | string | undefined): this;
73
+ /**
74
+ * @deprecated use { @link getGrpcClient} instead
75
+ */
73
76
  getJsonRpcClient(): JsonRpcClient;
77
+ /**
78
+ * Returns a gRPC client that is connected to the node that the wallet is.
79
+ * Note that any calls will throw an error, if the site is not connected with the wallet.
80
+ */
81
+ getGrpcClient(): ConcordiumGRPCClient;
82
+ /**
83
+ * Returns the genesis hash of the currently selected chain in the wallet.
84
+ * Returns undefined if the wallet is either locked or not set up by the user.
85
+ */
86
+ getSelectedChain(): Promise<string | undefined>;
74
87
  /**
75
88
  * Request that the user adds the specified tokens for a given contract to the wallet.
76
89
  * Returns which of the given tokens the user accepted to add the tokens into the wallet.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concordium/browser-wallet-api-helpers",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "packageManager": "yarn@3.2.0",
6
6
  "main": "lib/index.js",
@@ -19,7 +19,7 @@
19
19
  "url": "https://concordium.com"
20
20
  },
21
21
  "dependencies": {
22
- "@concordium/web-sdk": "^3.4.0"
22
+ "@concordium/web-sdk": "^3.4.2"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/core": "^7.17.10",
@@ -31,6 +31,7 @@
31
31
  "webpack-cli": "^4.9.2"
32
32
  },
33
33
  "scripts": {
34
- "build": "tsc && webpack"
34
+ "build": "tsc && webpack",
35
+ "build:api-helpers": "yarn build"
35
36
  }
36
37
  }