@concordium/browser-wallet-api-helpers 2.3.0 → 2.4.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 +31 -1
- package/lib/wallet-api-types.d.ts +8 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -142,7 +142,12 @@ It is possible to sign arbitrary messages using the keys for an account stored i
|
|
|
142
142
|
|
|
143
143
|
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
144
|
|
|
145
|
-
The
|
|
145
|
+
The message should either utf8 string or an object with the following fields:
|
|
146
|
+
|
|
147
|
+
- 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.
|
|
149
|
+
|
|
150
|
+
The following exemplifies requesting a signature of a message, where the message is a utf8 string:
|
|
146
151
|
|
|
147
152
|
```typescript
|
|
148
153
|
const provider = await detectConcordiumProvider();
|
|
@@ -152,6 +157,31 @@ const signature = await provider.signMessage(
|
|
|
152
157
|
);
|
|
153
158
|
```
|
|
154
159
|
|
|
160
|
+
The following exemplifies requesting a signature of a message, where the message is an object:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const provider = await detectConcordiumProvider();
|
|
164
|
+
const signature = await provider.signMessage('4MyVHYbRkAU6fqQsoSDzni6mrVz1KEvhDJoMVmDmrCgPBD8b7S', {
|
|
165
|
+
data: '00000b0000004120676f6f64206974656d00a4fbca84010000',
|
|
166
|
+
schema: 'FAAEAAAADQAAAGF1Y3Rpb25fc3RhdGUVAgAAAAoAAABOb3RTb2xkWWV0AgQAAABTb2xkAQEAAAALDgAAAGhpZ2hlc3RfYmlkZGVyFQIAAAAEAAAATm9uZQIEAAAAU29tZQEBAAAACwQAAABpdGVtFgIDAAAAZW5kDQ',
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
In this example the user will be shown:
|
|
171
|
+
|
|
172
|
+
```JSON
|
|
173
|
+
{
|
|
174
|
+
"auction_state": {
|
|
175
|
+
"NotSoldYet": []
|
|
176
|
+
},
|
|
177
|
+
"end": "2022-12-01T00:00:00+00:00",
|
|
178
|
+
"highest_bidder": {
|
|
179
|
+
"None": []
|
|
180
|
+
},
|
|
181
|
+
"item": "A good item"
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
155
185
|
### Add CIS-2 Tokens
|
|
156
186
|
|
|
157
187
|
It is possible to suggest CIS-2 tokens to be added to an account's display. This method returns a `Promise` resolving with a list containing the ids of the tokens that were added.
|
|
@@ -3,6 +3,12 @@ export declare type SendTransactionPayload = Exclude<AccountTransactionPayload,
|
|
|
3
3
|
export declare type SmartContractParameters = {
|
|
4
4
|
[key: string]: SmartContractParameters;
|
|
5
5
|
} | SmartContractParameters[] | number | string | boolean;
|
|
6
|
+
export declare type SignMessageObject = {
|
|
7
|
+
/** as base64 */
|
|
8
|
+
schema: string;
|
|
9
|
+
/** as hex */
|
|
10
|
+
data: string;
|
|
11
|
+
};
|
|
6
12
|
/**
|
|
7
13
|
* An enumeration of the events that can be emitted by the WalletApi.
|
|
8
14
|
*/
|
|
@@ -51,9 +57,9 @@ interface MainWalletApi {
|
|
|
51
57
|
* Sends a message to the Concordium Wallet and awaits the users action. If the user signs the message, this will resolve to the signature.
|
|
52
58
|
* Note that if the user rejects signing the message, this will throw an error.
|
|
53
59
|
* @param accountAddress the address of the account that should sign the message
|
|
54
|
-
* @param message message to be signed. Note that the wallet will prepend some bytes to ensure the message cannot be a transaction
|
|
60
|
+
* @param message message to be signed. Note that the wallet will prepend some bytes to ensure the message cannot be a transaction. The message should either be a utf8 string or { @link SignMessageObject }.
|
|
55
61
|
*/
|
|
56
|
-
signMessage(accountAddress: string, message: string): Promise<AccountTransactionSignature>;
|
|
62
|
+
signMessage(accountAddress: string, message: string | SignMessageObject): Promise<AccountTransactionSignature>;
|
|
57
63
|
/**
|
|
58
64
|
* Requests a connection to the Concordium wallet, prompting the user to either accept or reject the request.
|
|
59
65
|
* If a connection has already been accepted for the url once the returned promise will resolve without prompting the user.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@concordium/browser-wallet-api-helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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.
|
|
22
|
+
"@concordium/web-sdk": "^3.4.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@babel/core": "^7.17.10",
|