@concordium/browser-wallet-api-helpers 2.8.0 → 3.0.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 +6 -7
- package/lib/concordiumHelpers.min.js +1 -1
- package/lib/concordiumHelpers.min.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/util.d.ts +2 -2
- package/lib/wallet-api-types.d.ts +92 -27
- package/package.json +15 -3
package/README.md
CHANGED
|
@@ -281,17 +281,16 @@ provider.on('accountDisconnected', (accountAddress) => {
|
|
|
281
281
|
provider.connect().then((accountAddress) => (selectedAccountAddress = accountAddress));
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
-
## Accessing node through
|
|
284
|
+
## Accessing the node through GRPC
|
|
285
285
|
|
|
286
|
-
The wallet API exposes
|
|
287
|
-
The dApp does not need to recreate the client again when the wallet changes node or network, the client will always use the wallet's current connected JSON-RPC server.
|
|
288
|
-
|
|
289
|
-
If you have not connected with the wallet (or previously been allowlisted), the commands will not be executed and the method will throw an error.
|
|
286
|
+
The wallet API exposes a browser-wallet specific GRPC transport layer, which communicates with the concordium blockchain selected in the wallet. This can be used to construct a GRPC client, by installing the peer dependency `@concordium/web-sdk`.
|
|
290
287
|
|
|
291
288
|
```typescript
|
|
289
|
+
import { ConcordiumGRPCClient } from '@concordium/web-sdk/grpc';
|
|
292
290
|
const provider = await detectConcordiumProvider();
|
|
293
|
-
const client
|
|
291
|
+
const client = new ConcordiumGRPCClient(provider.grpcTransport);
|
|
292
|
+
|
|
294
293
|
...
|
|
295
|
-
// The client can then be used to acccess node
|
|
294
|
+
// The client can then be used to acccess the GRPC v2 API of the node used in the wallet.
|
|
296
295
|
const accountInfo = await client.getAccountInfo(accountAddress);
|
|
297
296
|
```
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.concordiumHelpers=o():e.concordiumHelpers=o()}(self,(()=>(()=>{"use strict";var e={611:(e,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.detectConcordiumProvider=async function(e=5e3){return new Promise(((o,n)=>{if(window.concordium)o(window.concordium);else{const t=setTimeout((()=>{window.concordium?o(window.concordium):n()}),e);window.addEventListener("concordium#initialized",(()=>{window.concordium&&(clearTimeout(t),o(window.concordium))}),{once:!0})}}))}},685:(e,o,n)=>{Object.defineProperty(o,"__esModule",{value:!0});var t={detectConcordiumProvider:!0};Object.defineProperty(o,"detectConcordiumProvider",{enumerable:!0,get:function(){return
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.concordiumHelpers=o():e.concordiumHelpers=o()}(self,(()=>(()=>{"use strict";var e={611:(e,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.detectConcordiumProvider=async function(e=5e3){return new Promise(((o,n)=>{if(window.concordium)o(window.concordium);else{const t=setTimeout((()=>{window.concordium?o(window.concordium):n()}),e);window.addEventListener("concordium#initialized",(()=>{window.concordium&&(clearTimeout(t),o(window.concordium))}),{once:!0})}}))}},685:(e,o,n)=>{Object.defineProperty(o,"__esModule",{value:!0});var t={detectConcordiumProvider:!0};Object.defineProperty(o,"detectConcordiumProvider",{enumerable:!0,get:function(){return i.detectConcordiumProvider}});var r=n(740);Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(t,e)||e in o&&o[e]===r[e]||Object.defineProperty(o,e,{enumerable:!0,get:function(){return r[e]}}))}));var c=n(996);Object.keys(c).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(t,e)||e in o&&o[e]===c[e]||Object.defineProperty(o,e,{enumerable:!0,get:function(){return c[e]}}))}));var i=n(611)},996:(e,o)=>{Object.defineProperty(o,"__esModule",{value:!0})},740:(e,o)=>{var n,t;Object.defineProperty(o,"__esModule",{value:!0}),o.SchemaType=o.EventType=void 0,o.EventType=n,function(e){e.AccountChanged="accountChanged",e.AccountDisconnected="accountDisconnected",e.ChainChanged="chainChanged"}(n||(o.EventType=n={})),o.SchemaType=t,function(e){e.Module="module",e.Parameter="parameter"}(t||(o.SchemaType=t={}))}},o={};return function n(t){var r=o[t];if(void 0!==r)return r.exports;var c=o[t]={exports:{}};return e[t](c,c.exports,n),c.exports}(685)})()));
|
|
2
2
|
//# sourceMappingURL=concordiumHelpers.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concordiumHelpers.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA2B,kBAAID,IAE/BD,EAAwB,kBAAIC,IAR9B,CASGK,MAAM,I,kHCHFC,eAAwCC,EAAU,KACrD,OAAO,IAAIC,SAAQ,CAACC,EAASC,KACzB,GAAIC,OAAOC,WACPH,EAAQE,OAAOC,gBAEd,CACD,MAAMC,EAAIC,YAAW,KACbH,OAAOC,WACPH,EAAQE,OAAOC,YAGfF,MAELH,GACHI,OAAOI,iBAAiB,0BAA0B,KAC1CJ,OAAOC,aACPI,aAAaH,GACbJ,EAAQE,OAAOC,eAEpB,CAAEK,MAAM,U,yNCzBvB,8NACA,c,
|
|
1
|
+
{"version":3,"file":"concordiumHelpers.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA2B,kBAAID,IAE/BD,EAAwB,kBAAIC,IAR9B,CASGK,MAAM,I,kHCHFC,eAAwCC,EAAU,KACrD,OAAO,IAAIC,SAAQ,CAACC,EAASC,KACzB,GAAIC,OAAOC,WACPH,EAAQE,OAAOC,gBAEd,CACD,MAAMC,EAAIC,YAAW,KACbH,OAAOC,WACPH,EAAQE,OAAOC,YAGfF,MAELH,GACHI,OAAOI,iBAAiB,0BAA0B,KAC1CJ,OAAOC,aACPI,aAAaH,GACbJ,EAAQE,OAAOC,eAEpB,CAAEK,MAAM,U,yNCzBvB,8NACA,8NACA,c,0ECCO,IAAIC,EAMAC,E,+FALX,SAAWD,GACPA,EAAS,eAAqB,iBAC9BA,EAAS,oBAA0B,sBACnCA,EAAS,aAAmB,eAHhC,CAIGA,IAAc,EAAAA,UAAAA,EAAY,K,eAE7B,SAAWC,GACPA,EAAU,OAAa,SACvBA,EAAU,UAAgB,YAF9B,CAGGA,IAAe,EAAAA,WAAAA,EAAa,OCZ3BC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAatB,QAGrB,IAAIC,EAASkB,EAAyBE,GAAY,CAGjDrB,QAAS,IAOV,OAHAwB,EAAoBH,GAAUpB,EAAQA,EAAOD,QAASoB,GAG/CnB,EAAOD,QClBWoB,CAAoB,M","sources":["webpack:///webpack/universalModuleDefinition","webpack:///./lib/detector.js","webpack:///./lib/index.js","webpack:///./lib/wallet-api-types.js","webpack:///webpack/bootstrap","webpack:///webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"concordiumHelpers\"] = factory();\n\telse\n\t\troot[\"concordiumHelpers\"] = factory();\n})(self, () => {\nreturn ","/**\n * Detect the Concordium browser wallet API by waiting for it to have been successfully injected\n * into the window so that it is ready for use.\n * @param timeout determines how long to wait before rejecting if the Concordium provider is not available, in milliseconds.\n * @returns a promise containing the Concordium Wallet provider API.\n */\nexport async function detectConcordiumProvider(timeout = 5000) {\n return new Promise((resolve, reject) => {\n if (window.concordium) {\n resolve(window.concordium);\n }\n else {\n const t = setTimeout(() => {\n if (window.concordium) {\n resolve(window.concordium);\n }\n else {\n reject();\n }\n }, timeout);\n window.addEventListener('concordium#initialized', () => {\n if (window.concordium) {\n clearTimeout(t);\n resolve(window.concordium);\n }\n }, { once: true });\n }\n });\n}\n","export * from './wallet-api-types';\nexport * from './util';\nexport { detectConcordiumProvider } from './detector';\n","/**\n * An enumeration of the events that can be emitted by the WalletApi.\n */\nexport var EventType;\n(function (EventType) {\n EventType[\"AccountChanged\"] = \"accountChanged\";\n EventType[\"AccountDisconnected\"] = \"accountDisconnected\";\n EventType[\"ChainChanged\"] = \"chainChanged\";\n})(EventType || (EventType = {}));\nexport var SchemaType;\n(function (SchemaType) {\n SchemaType[\"Module\"] = \"module\";\n SchemaType[\"Parameter\"] = \"parameter\";\n})(SchemaType || (SchemaType = {}));\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(685);\n"],"names":["root","factory","exports","module","define","amd","self","async","timeout","Promise","resolve","reject","window","concordium","t","setTimeout","addEventListener","clearTimeout","once","EventType","SchemaType","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/util.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type LaxStringEnumValue<E extends string> = `${E}`;
|
|
2
|
+
export type LaxNumberEnumValue<E extends number> = `${E}` extends `${infer T extends number}` ? T : never;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload,
|
|
1
|
+
import type { AccountTransactionPayload, AccountTransactionSignature, AccountTransactionType, InitContractPayload, SchemaVersion, UpdateContractPayload, IdStatement, IdProofOutput, CredentialStatements, VerifiablePresentation, CredentialSubject, HexString, AccountAddress, Base58String, Base64String, ContractAddress, UpdateCredentialsPayload, RegisterDataPayload, SimpleTransferPayload, SimpleTransferWithMemoPayload, DeployModulePayload, ConfigureBakerPayload, ConfigureDelegationPayload } from '@concordium/web-sdk';
|
|
2
|
+
import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
|
|
2
3
|
import { LaxNumberEnumValue, LaxStringEnumValue } from './util';
|
|
3
4
|
export interface MetadataUrl {
|
|
4
5
|
url: string;
|
|
@@ -28,11 +29,13 @@ export interface CredentialProof {
|
|
|
28
29
|
type: 'Ed25519Signature2020';
|
|
29
30
|
verificationMethod: string;
|
|
30
31
|
}
|
|
31
|
-
export
|
|
32
|
-
export
|
|
32
|
+
export type SendTransactionUpdateContractPayload = Omit<UpdateContractPayload, 'message'>;
|
|
33
|
+
export type SendTransactionInitContractPayload = Omit<InitContractPayload, 'param'>;
|
|
34
|
+
export type SendTransactionPayload = Exclude<AccountTransactionPayload, UpdateContractPayload | InitContractPayload> | SendTransactionUpdateContractPayload | SendTransactionInitContractPayload;
|
|
35
|
+
export type SmartContractParameters = {
|
|
33
36
|
[key: string]: SmartContractParameters;
|
|
34
37
|
} | SmartContractParameters[] | number | string | boolean;
|
|
35
|
-
export
|
|
38
|
+
export type SignMessageObject = {
|
|
36
39
|
/** as base64 */
|
|
37
40
|
schema: string;
|
|
38
41
|
/** as hex */
|
|
@@ -50,18 +53,20 @@ export declare enum SchemaType {
|
|
|
50
53
|
Module = "module",
|
|
51
54
|
Parameter = "parameter"
|
|
52
55
|
}
|
|
53
|
-
export
|
|
56
|
+
export type SchemaWithContext = {
|
|
54
57
|
type: LaxStringEnumValue<SchemaType>;
|
|
55
58
|
value: string;
|
|
56
59
|
};
|
|
57
|
-
|
|
60
|
+
export type AccountAddressSource = Base58String | AccountAddress.Type;
|
|
61
|
+
export type SchemaSource = Base64String | SchemaWithContext;
|
|
62
|
+
type EventListener<Args extends any[]> = (...args: Args) => void;
|
|
58
63
|
interface Listeners<T extends EventType, Args extends any[]> {
|
|
59
64
|
on(eventName: T | `${T}`, listener: EventListener<Args>): this;
|
|
60
65
|
once(eventName: T | `${T}`, listener: EventListener<Args>): this;
|
|
61
66
|
addListener(eventName: T | `${T}`, listener: EventListener<Args>): this;
|
|
62
67
|
removeListener(eventName: T | `${T}`, listener: EventListener<Args>): this;
|
|
63
68
|
}
|
|
64
|
-
|
|
69
|
+
type EventListeners = Listeners<EventType.AccountChanged, [accountAddress: string]> & Listeners<EventType.ChainChanged, [chain: string]> & Listeners<EventType.AccountDisconnected, [accountAddress: string]>;
|
|
65
70
|
interface MainWalletApi {
|
|
66
71
|
/**
|
|
67
72
|
* 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.
|
|
@@ -69,11 +74,30 @@ interface MainWalletApi {
|
|
|
69
74
|
* @param accountAddress the address of the account that should sign the transaction
|
|
70
75
|
* @param type the type of transaction that is to be signed and sent.
|
|
71
76
|
* @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.
|
|
72
|
-
* @param parameters parameters for the initContract and updateContract transactions in JSON-like format.
|
|
73
|
-
* @param schema schema used for the initContract and updateContract transactions to serialize the parameters. Should be base64 encoded.
|
|
74
|
-
* @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.
|
|
77
|
+
* @param [parameters] parameters for the initContract and updateContract transactions in JSON-like format.
|
|
78
|
+
* @param [schema] schema used for the initContract and updateContract transactions to serialize the parameters. Should be base64 encoded.
|
|
79
|
+
* @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.
|
|
75
80
|
*/
|
|
76
|
-
sendTransaction(accountAddress:
|
|
81
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.InitContract>, payload: SendTransactionInitContractPayload, parameters?: SmartContractParameters, schema?: SchemaSource, schemaVersion?: SchemaVersion): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* 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.
|
|
84
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
85
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
86
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
87
|
+
* @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.
|
|
88
|
+
* @param [parameters] parameters for the initContract and updateContract transactions in JSON-like format.
|
|
89
|
+
* @param [schema] schema used for the initContract and updateContract transactions to serialize the parameters. Should be base64 encoded.
|
|
90
|
+
* @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.
|
|
91
|
+
*/
|
|
92
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.Update>, payload: SendTransactionUpdateContractPayload, parameters?: SmartContractParameters, schema?: SchemaSource, schemaVersion?: SchemaVersion): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* 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.
|
|
95
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
96
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
97
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
98
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
99
|
+
*/
|
|
100
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.UpdateCredentials>, payload: UpdateCredentialsPayload): Promise<string>;
|
|
77
101
|
/**
|
|
78
102
|
* 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.
|
|
79
103
|
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
@@ -81,14 +105,54 @@ interface MainWalletApi {
|
|
|
81
105
|
* @param type the type of transaction that is to be signed and sent.
|
|
82
106
|
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
83
107
|
*/
|
|
84
|
-
sendTransaction(accountAddress:
|
|
108
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.RegisterData>, payload: RegisterDataPayload): Promise<string>;
|
|
109
|
+
/**
|
|
110
|
+
* 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.
|
|
111
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
112
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
113
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
114
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
115
|
+
*/
|
|
116
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.Transfer>, payload: SimpleTransferPayload): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* 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.
|
|
119
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
120
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
121
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
122
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
123
|
+
*/
|
|
124
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.TransferWithMemo>, payload: SimpleTransferWithMemoPayload): Promise<string>;
|
|
125
|
+
/**
|
|
126
|
+
* 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.
|
|
127
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
128
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
129
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
130
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
131
|
+
*/
|
|
132
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.DeployModule>, payload: DeployModulePayload): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
* 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.
|
|
135
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
136
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
137
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
138
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
139
|
+
*/
|
|
140
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.ConfigureBaker>, payload: ConfigureBakerPayload): Promise<string>;
|
|
141
|
+
/**
|
|
142
|
+
* 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.
|
|
143
|
+
* Note that if the user rejects signing the transaction, this will throw an error.
|
|
144
|
+
* @param accountAddress the address of the account that should sign the transaction
|
|
145
|
+
* @param type the type of transaction that is to be signed and sent.
|
|
146
|
+
* @param payload the payload of the transaction to be signed and sent. Note that for smart contract transactions, the payload should not contain the parameters, those should instead be provided in the subsequent argument instead.
|
|
147
|
+
*/
|
|
148
|
+
sendTransaction(accountAddress: AccountAddressSource, type: LaxNumberEnumValue<AccountTransactionType.ConfigureDelegation>, payload: ConfigureDelegationPayload): Promise<string>;
|
|
85
149
|
/**
|
|
86
150
|
* Sends a message to the Concordium Wallet and awaits the users action. If the user signs the message, this will resolve to the signature.
|
|
87
151
|
* Note that if the user rejects signing the message, this will throw an error.
|
|
88
152
|
* @param accountAddress the address of the account that should sign the message
|
|
89
153
|
* @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 }.
|
|
90
154
|
*/
|
|
91
|
-
signMessage(accountAddress:
|
|
155
|
+
signMessage(accountAddress: AccountAddressSource, message: string | SignMessageObject): Promise<AccountTransactionSignature>;
|
|
92
156
|
/**
|
|
93
157
|
* Requests a connection to the Concordium wallet, prompting the user to either accept or reject the request.
|
|
94
158
|
* If a connection has already been accepted for the url once the returned promise will resolve without prompting the user.
|
|
@@ -112,14 +176,16 @@ interface MainWalletApi {
|
|
|
112
176
|
getMostRecentlySelectedAccount(): Promise<string | undefined>;
|
|
113
177
|
removeAllListeners(event?: EventType | string | undefined): this;
|
|
114
178
|
/**
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
*
|
|
179
|
+
* A GRPC transport layer which uses the node used in the wallet to communicate with the selected chain.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* import { ConcordiumGRPCClient } from '@concordium/web-sdk/grpc';
|
|
183
|
+
* import { detectConcordiumProvider } from '@concordium/browser-wallet-api-helpers';
|
|
184
|
+
*
|
|
185
|
+
* const walletApi = await detectConcordiumProvider();
|
|
186
|
+
* const grpcClient = new ConcordiumGRPCClient(await walletApi.grpcTransport);
|
|
121
187
|
*/
|
|
122
|
-
|
|
188
|
+
get grpcTransport(): RpcTransport;
|
|
123
189
|
/**
|
|
124
190
|
* Returns the genesis hash of the currently selected chain in the wallet.
|
|
125
191
|
* Returns undefined if the wallet is either locked or not set up by the user.
|
|
@@ -129,13 +195,12 @@ interface MainWalletApi {
|
|
|
129
195
|
* Request that the user adds the specified tokens for a given contract to the wallet.
|
|
130
196
|
* Returns which of the given tokens the user accepted to add the tokens into the wallet.
|
|
131
197
|
* Note that this will throw an error if the dApp is not connected with the accountAddress.
|
|
132
|
-
* @param accountAddress the
|
|
198
|
+
* @param accountAddress the {@linkcode AccountAddressSource} of the account whose display the tokens should be added to.
|
|
133
199
|
* @param tokenIds the list of ids, for the tokens that should be added.
|
|
134
|
-
* @param
|
|
135
|
-
* @
|
|
136
|
-
* @returns a list containing the ids of the tokens that was added to the wallet.
|
|
200
|
+
* @param contractAddress the {@link ContractAddress} of the contract
|
|
201
|
+
* @returns a list containing the ids of the tokens that were added to the wallet.
|
|
137
202
|
*/
|
|
138
|
-
addCIS2Tokens(accountAddress:
|
|
203
|
+
addCIS2Tokens(accountAddress: AccountAddressSource, tokenIds: string[], contractAddress: ContractAddress.Type): Promise<string[]>;
|
|
139
204
|
/**
|
|
140
205
|
* Request that the user provides a proof for the given statement.
|
|
141
206
|
* @deprecated Please use { @link requestVerifiablePresentation} instead.
|
|
@@ -144,7 +209,7 @@ interface MainWalletApi {
|
|
|
144
209
|
* @param challenge bytes chosen by the verifier. Should be HEX encoded.
|
|
145
210
|
* @returns The id proof and the id of the credential used to prove it.
|
|
146
211
|
*/
|
|
147
|
-
requestIdProof(accountAddress:
|
|
212
|
+
requestIdProof(accountAddress: AccountAddressSource, statement: IdStatement, challenge: string): Promise<IdProofOutput>;
|
|
148
213
|
/**
|
|
149
214
|
* Requests that a web3IdCredential is added to the wallet.
|
|
150
215
|
* Note that this will throw an error if the dApp is not allowlisted, locked, or if the user rejects adding the credential.
|
|
@@ -165,5 +230,5 @@ interface MainWalletApi {
|
|
|
165
230
|
*/
|
|
166
231
|
requestVerifiablePresentation(challenge: string, statements: CredentialStatements): Promise<VerifiablePresentation>;
|
|
167
232
|
}
|
|
168
|
-
export
|
|
233
|
+
export type WalletApi = MainWalletApi & EventListeners;
|
|
169
234
|
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@concordium/browser-wallet-api-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"packageManager": "yarn@3.2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"browser": "lib/concordiumHelpers.min.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
|
+
"cdn": "lib/concordiumHelpers.min.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"browser": "./lib/index.js",
|
|
13
|
+
"import": "./lib/index.js",
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"default": "./lib/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
9
18
|
"files": [
|
|
10
19
|
"/lib/**/*"
|
|
11
20
|
],
|
|
@@ -19,17 +28,20 @@
|
|
|
19
28
|
"url": "https://concordium.com"
|
|
20
29
|
},
|
|
21
30
|
"dependencies": {
|
|
22
|
-
"@
|
|
31
|
+
"@protobuf-ts/runtime-rpc": "^2.9.1"
|
|
23
32
|
},
|
|
24
33
|
"devDependencies": {
|
|
25
34
|
"@babel/core": "^7.17.10",
|
|
26
35
|
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
|
|
27
36
|
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
28
37
|
"@babel/preset-env": "^7.12.1",
|
|
29
|
-
"typescript": "^
|
|
38
|
+
"typescript": "^5.2.2",
|
|
30
39
|
"webpack": "^5.72.0",
|
|
31
40
|
"webpack-cli": "^4.9.2"
|
|
32
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@concordium/web-sdk": "^7.0"
|
|
44
|
+
},
|
|
33
45
|
"scripts": {
|
|
34
46
|
"build": "tsc && webpack",
|
|
35
47
|
"build:api-helpers": "yarn build"
|