@concordium/browser-wallet-api-helpers 1.0.0 → 2.1.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 +13 -0
- package/lib/wallet-api-types.d.ts +23 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -136,6 +136,19 @@ const signature = await provider.signMessage(
|
|
|
136
136
|
);
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
+
### Add CIS-2 Tokens
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
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
|
+
|
|
145
|
+
The following exemplifies requesting tokens with id AA and BB from the contract on index 1399, and subindex 0 to the account `2za2yAXbFiaB151oYqTteZfqiBzibHXizwjNbpdU8hodq9SfEk`.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const provider = await detectConcordiumProvider();
|
|
149
|
+
await provider.addCIS2Tokens('2za2yAXbFiaB151oYqTteZfqiBzibHXizwjNbpdU8hodq9SfEk', ['AA', 'BB'], '1399', '0');
|
|
150
|
+
```
|
|
151
|
+
|
|
139
152
|
## Events
|
|
140
153
|
|
|
141
154
|
### Account changed
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload, JsonRpcClient, SchemaVersion, UpdateContractPayload } from '@concordium/web-sdk';
|
|
2
|
-
declare type SendTransactionPayload = Exclude<AccountTransactionPayload, UpdateContractPayload | InitContractPayload> | Omit<UpdateContractPayload, '
|
|
1
|
+
import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload, JsonRpcClient, SchemaVersion, UpdateContractPayload, IdStatement, IdProofOutput } from '@concordium/web-sdk';
|
|
2
|
+
declare type SendTransactionPayload = Exclude<AccountTransactionPayload, UpdateContractPayload | InitContractPayload> | Omit<UpdateContractPayload, 'message'> | Omit<InitContractPayload, 'param'>;
|
|
3
3
|
/**
|
|
4
4
|
* An enumeration of the events that can be emitted by the WalletApi.
|
|
5
5
|
*/
|
|
@@ -22,12 +22,12 @@ interface MainWalletApi {
|
|
|
22
22
|
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
23
23
|
* @param accountAddress the address of the account that should sign the transaction
|
|
24
24
|
* @param type the type of transaction that is to be signed and sent.
|
|
25
|
-
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the
|
|
25
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the params/message fields, those should instead be provided in the subsequent argument instead.
|
|
26
26
|
* @param parameters parameters for the initContract and updateContract transactions in JSON-like format.
|
|
27
27
|
* @param schema schema used for the initContract and updateContract transactions to serialize the parameters. Should be base64 encoded.
|
|
28
28
|
* @param schemaVersion version of the schema provided. Must be supplied for schemas that use version 0 or 1, as they don't have the version embedded.
|
|
29
29
|
*/
|
|
30
|
-
sendTransaction(accountAddress: string, type: AccountTransactionType.
|
|
30
|
+
sendTransaction(accountAddress: string, type: AccountTransactionType.Update | AccountTransactionType.InitContract, payload: SendTransactionPayload, parameters: Record<string, unknown>, schema: string, schemaVersion?: SchemaVersion): Promise<string>;
|
|
31
31
|
/**
|
|
32
32
|
* Sends a transaction to the Concordium Wallet and awaits the users action. Note that a header is not sent, and will be constructed by the wallet itself.
|
|
33
33
|
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
@@ -54,6 +54,25 @@ interface MainWalletApi {
|
|
|
54
54
|
getMostRecentlySelectedAccount(): Promise<string | undefined>;
|
|
55
55
|
removeAllListeners(event?: EventType | string | undefined): this;
|
|
56
56
|
getJsonRpcClient(): JsonRpcClient;
|
|
57
|
+
/**
|
|
58
|
+
* Request that the user adds the specified tokens for a given contract to the wallet.
|
|
59
|
+
* Returns which of the given tokens the user accepted to add the tokens into the wallet.
|
|
60
|
+
* Note that this will throw an error if the dApp is not connected with the accountAddress.
|
|
61
|
+
* @param accountAddress the address of the account whose display the tokens should be added to.
|
|
62
|
+
* @param tokenIds the list of ids, for the tokens that should be added.
|
|
63
|
+
* @param contractIndex the index of the CIS-2 contract which the tokens are in.
|
|
64
|
+
* @param contractSubindex the subindex of the CIS-2 contract which the tokens are in.
|
|
65
|
+
* @returns a list containing the ids of the tokens that was added to the wallet.
|
|
66
|
+
*/
|
|
67
|
+
addCIS2Tokens(accountAddress: string, tokenIds: string[], contractIndex: bigint, contractSubindex?: bigint): Promise<string[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Request that the user provides a proof for the given statement.
|
|
70
|
+
* @param accountAddress the address of the account that should prove the statement.
|
|
71
|
+
* @param statement the id statement that should be proven.
|
|
72
|
+
* @param challenge bytes chosen by the verifier. Should be HEX encoded.
|
|
73
|
+
* @returns The id proof and the id of the credential used to prove it.
|
|
74
|
+
*/
|
|
75
|
+
requestIdProof(accountAddress: string, statement: IdStatement, challenge: string): Promise<IdProofOutput>;
|
|
57
76
|
}
|
|
58
77
|
export declare type WalletApi = MainWalletApi & EventListeners;
|
|
59
78
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@concordium/browser-wallet-api-helpers",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.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": "^
|
|
22
|
+
"@concordium/web-sdk": "^3.1.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@babel/core": "^7.17.10",
|