@tezos-x/octez.connect-dapp 0.9.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/LICENCE +19 -0
- package/README.md +16 -0
- package/dist/cjs/beacon-message-events.d.ts +9 -0
- package/dist/cjs/beacon-message-events.js +109 -0
- package/dist/cjs/beacon-message-events.js.map +1 -0
- package/dist/cjs/dapp-client/DAppClient.d.ts +282 -0
- package/dist/cjs/dapp-client/DAppClient.js +2073 -0
- package/dist/cjs/dapp-client/DAppClient.js.map +1 -0
- package/dist/cjs/dapp-client/DAppClientOptions.d.ts +117 -0
- package/dist/cjs/dapp-client/DAppClientOptions.js +3 -0
- package/dist/cjs/dapp-client/DAppClientOptions.js.map +1 -0
- package/dist/cjs/events.d.ts +209 -0
- package/dist/cjs/events.js +718 -0
- package/dist/cjs/events.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/transports/DappP2PTransport.d.ts +14 -0
- package/dist/cjs/transports/DappP2PTransport.js +53 -0
- package/dist/cjs/transports/DappP2PTransport.js.map +1 -0
- package/dist/cjs/transports/DappPostMessageTransport.d.ts +14 -0
- package/dist/cjs/transports/DappPostMessageTransport.js +53 -0
- package/dist/cjs/transports/DappPostMessageTransport.js.map +1 -0
- package/dist/cjs/transports/DappWalletConnectTransport.d.ts +17 -0
- package/dist/cjs/transports/DappWalletConnectTransport.js +52 -0
- package/dist/cjs/transports/DappWalletConnectTransport.js.map +1 -0
- package/dist/cjs/utils/available-transports.d.ts +4 -0
- package/dist/cjs/utils/available-transports.js +12 -0
- package/dist/cjs/utils/available-transports.js.map +1 -0
- package/dist/cjs/utils/block-explorer.d.ts +24 -0
- package/dist/cjs/utils/block-explorer.js +24 -0
- package/dist/cjs/utils/block-explorer.js.map +1 -0
- package/dist/cjs/utils/get-instance.d.ts +4 -0
- package/dist/cjs/utils/get-instance.js +21 -0
- package/dist/cjs/utils/get-instance.js.map +1 -0
- package/dist/cjs/utils/shorten-string.d.ts +1 -0
- package/dist/cjs/utils/shorten-string.js +11 -0
- package/dist/cjs/utils/shorten-string.js.map +1 -0
- package/dist/cjs/utils/tzkt-blockexplorer.d.ts +12 -0
- package/dist/cjs/utils/tzkt-blockexplorer.js +59 -0
- package/dist/cjs/utils/tzkt-blockexplorer.js.map +1 -0
- package/dist/esm/beacon-message-events.d.ts +9 -0
- package/dist/esm/beacon-message-events.js +106 -0
- package/dist/esm/beacon-message-events.js.map +1 -0
- package/dist/esm/dapp-client/DAppClient.d.ts +282 -0
- package/dist/esm/dapp-client/DAppClient.js +2001 -0
- package/dist/esm/dapp-client/DAppClient.js.map +1 -0
- package/dist/esm/dapp-client/DAppClientOptions.d.ts +117 -0
- package/dist/esm/dapp-client/DAppClientOptions.js +2 -0
- package/dist/esm/dapp-client/DAppClientOptions.js.map +1 -0
- package/dist/esm/events.d.ts +209 -0
- package/dist/esm/events.js +702 -0
- package/dist/esm/events.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/transports/DappP2PTransport.d.ts +14 -0
- package/dist/esm/transports/DappP2PTransport.js +34 -0
- package/dist/esm/transports/DappP2PTransport.js.map +1 -0
- package/dist/esm/transports/DappPostMessageTransport.d.ts +14 -0
- package/dist/esm/transports/DappPostMessageTransport.js +34 -0
- package/dist/esm/transports/DappPostMessageTransport.js.map +1 -0
- package/dist/esm/transports/DappWalletConnectTransport.d.ts +17 -0
- package/dist/esm/transports/DappWalletConnectTransport.js +35 -0
- package/dist/esm/transports/DappWalletConnectTransport.js.map +1 -0
- package/dist/esm/utils/available-transports.d.ts +4 -0
- package/dist/esm/utils/available-transports.js +9 -0
- package/dist/esm/utils/available-transports.js.map +1 -0
- package/dist/esm/utils/block-explorer.d.ts +24 -0
- package/dist/esm/utils/block-explorer.js +10 -0
- package/dist/esm/utils/block-explorer.js.map +1 -0
- package/dist/esm/utils/get-instance.d.ts +4 -0
- package/dist/esm/utils/get-instance.js +17 -0
- package/dist/esm/utils/get-instance.js.map +1 -0
- package/dist/esm/utils/shorten-string.d.ts +1 -0
- package/dist/esm/utils/shorten-string.js +7 -0
- package/dist/esm/utils/shorten-string.js.map +1 -0
- package/dist/esm/utils/tzkt-blockexplorer.d.ts +12 -0
- package/dist/esm/utils/tzkt-blockexplorer.js +43 -0
- package/dist/esm/utils/tzkt-blockexplorer.js.map +1 -0
- package/dist/octez.connect.dapp.min.js +1066 -0
- package/dist/walletbeacon.dapp.min.js +1066 -0
- package/package.json +45 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2021 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# `@tezos-x/octez.connect-dapp`
|
|
2
|
+
|
|
3
|
+
This package is part of the `@tezos-x/octez.connect-sdk` project. [Read more](https://github.com/trilitech/octez.connect-sdk)
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
Use this package on your dApp to instanciate a `DAppClient` object and communicate to wallets.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
import { DAppClient } from '@tezos-x/octez.connect-dapp'
|
|
13
|
+
|
|
14
|
+
const dAppClient = new DAppClient({ name: "octez.connect Docs" });
|
|
15
|
+
```
|
|
16
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.messageEvents = void 0;
|
|
4
|
+
const events_1 = require("./events");
|
|
5
|
+
const octez_connect_types_1 = require("@tezos-x/octez.connect-types");
|
|
6
|
+
exports.messageEvents = {
|
|
7
|
+
[octez_connect_types_1.BeaconMessageType.BlockchainRequest]: {
|
|
8
|
+
sent: events_1.BeaconEvent.OPERATION_REQUEST_SENT,
|
|
9
|
+
success: events_1.BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS,
|
|
10
|
+
error: events_1.BeaconEvent.OPERATION_REQUEST_ERROR
|
|
11
|
+
},
|
|
12
|
+
[octez_connect_types_1.BeaconMessageType.BlockchainResponse]: {
|
|
13
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
14
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
15
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
16
|
+
},
|
|
17
|
+
[octez_connect_types_1.BeaconMessageType.PermissionRequest]: {
|
|
18
|
+
sent: events_1.BeaconEvent.PERMISSION_REQUEST_SENT,
|
|
19
|
+
success: events_1.BeaconEvent.PERMISSION_REQUEST_SUCCESS,
|
|
20
|
+
error: events_1.BeaconEvent.PERMISSION_REQUEST_ERROR
|
|
21
|
+
},
|
|
22
|
+
[octez_connect_types_1.BeaconMessageType.PermissionResponse]: {
|
|
23
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
24
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
25
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
26
|
+
},
|
|
27
|
+
[octez_connect_types_1.BeaconMessageType.ProofOfEventChallengeRequest]: {
|
|
28
|
+
sent: events_1.BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT,
|
|
29
|
+
success: events_1.BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS,
|
|
30
|
+
error: events_1.BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR
|
|
31
|
+
},
|
|
32
|
+
[octez_connect_types_1.BeaconMessageType.ProofOfEventChallengeResponse]: {
|
|
33
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
34
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
35
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
36
|
+
},
|
|
37
|
+
[octez_connect_types_1.BeaconMessageType.SimulatedProofOfEventChallengeRequest]: {
|
|
38
|
+
sent: events_1.BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT,
|
|
39
|
+
success: events_1.BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS,
|
|
40
|
+
error: events_1.BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR
|
|
41
|
+
},
|
|
42
|
+
[octez_connect_types_1.BeaconMessageType.SimulatedProofOfEventChallengeResponse]: {
|
|
43
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
44
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
45
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
46
|
+
},
|
|
47
|
+
[octez_connect_types_1.BeaconMessageType.OperationRequest]: {
|
|
48
|
+
sent: events_1.BeaconEvent.OPERATION_REQUEST_SENT,
|
|
49
|
+
success: events_1.BeaconEvent.OPERATION_REQUEST_SUCCESS,
|
|
50
|
+
error: events_1.BeaconEvent.OPERATION_REQUEST_ERROR
|
|
51
|
+
},
|
|
52
|
+
[octez_connect_types_1.BeaconMessageType.OperationResponse]: {
|
|
53
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
54
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
55
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
56
|
+
},
|
|
57
|
+
[octez_connect_types_1.BeaconMessageType.SignPayloadRequest]: {
|
|
58
|
+
sent: events_1.BeaconEvent.SIGN_REQUEST_SENT,
|
|
59
|
+
success: events_1.BeaconEvent.SIGN_REQUEST_SUCCESS,
|
|
60
|
+
error: events_1.BeaconEvent.SIGN_REQUEST_ERROR
|
|
61
|
+
},
|
|
62
|
+
[octez_connect_types_1.BeaconMessageType.SignPayloadResponse]: {
|
|
63
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
64
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
65
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
66
|
+
},
|
|
67
|
+
// TODO: ENCRYPTION
|
|
68
|
+
// [BeaconMessageType.EncryptPayloadRequest]: {
|
|
69
|
+
// sent: BeaconEvent.ENCRYPT_REQUEST_SENT,
|
|
70
|
+
// success: BeaconEvent.ENCRYPT_REQUEST_SUCCESS,
|
|
71
|
+
// error: BeaconEvent.ENCRYPT_REQUEST_ERROR
|
|
72
|
+
// },
|
|
73
|
+
// [BeaconMessageType.EncryptPayloadResponse]: {
|
|
74
|
+
// sent: BeaconEvent.UNKNOWN,
|
|
75
|
+
// success: BeaconEvent.UNKNOWN,
|
|
76
|
+
// error: BeaconEvent.UNKNOWN
|
|
77
|
+
// },
|
|
78
|
+
[octez_connect_types_1.BeaconMessageType.BroadcastRequest]: {
|
|
79
|
+
sent: events_1.BeaconEvent.BROADCAST_REQUEST_SENT,
|
|
80
|
+
success: events_1.BeaconEvent.BROADCAST_REQUEST_SUCCESS,
|
|
81
|
+
error: events_1.BeaconEvent.BROADCAST_REQUEST_ERROR
|
|
82
|
+
},
|
|
83
|
+
[octez_connect_types_1.BeaconMessageType.BroadcastResponse]: {
|
|
84
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
85
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
86
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
87
|
+
},
|
|
88
|
+
[octez_connect_types_1.BeaconMessageType.ChangeAccountRequest]: {
|
|
89
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
90
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
91
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
92
|
+
},
|
|
93
|
+
[octez_connect_types_1.BeaconMessageType.Acknowledge]: {
|
|
94
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
95
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
96
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
97
|
+
},
|
|
98
|
+
[octez_connect_types_1.BeaconMessageType.Disconnect]: {
|
|
99
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
100
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
101
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
102
|
+
},
|
|
103
|
+
[octez_connect_types_1.BeaconMessageType.Error]: {
|
|
104
|
+
sent: events_1.BeaconEvent.UNKNOWN,
|
|
105
|
+
success: events_1.BeaconEvent.UNKNOWN,
|
|
106
|
+
error: events_1.BeaconEvent.UNKNOWN
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=beacon-message-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beacon-message-events.js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AC3C;IACD,CAAC,uCAAiB,CAAC,iBAAiB,CAAC,EAAE;QACrC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,oBAAoB,CAAC,EAAE;QACxC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,WAAW,CAAC,EAAE;QAC/B,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,UAAU,CAAC,EAAE;QAC9B,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,KAAK,CAAC,EAAE;QACzB,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;CACF,CAAA"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { BeaconEvent, BeaconEventHandlerFunction, BeaconEventType } from '../events';
|
|
2
|
+
import { AccountInfo, TransportType, BeaconMessageType, RequestPermissionInput, RequestSignPayloadInput, RequestOperationInput, RequestBroadcastInput, PermissionResponseOutput, SignPayloadResponseOutput, OperationResponseOutput, BroadcastResponseOutput, Network, AppMetadata, ExtendedPeerInfo, ColorMode, Blockchain, BlockchainRequestV3, BlockchainResponseV3, PermissionRequestV3, PermissionResponseV3, ProofOfEventChallengeResponse, RequestProofOfEventChallengeInput, PeerInfoType, SimulatedProofOfEventChallengeResponse, RequestSimulatedProofOfEventChallengeInput } from '@tezos-x/octez.connect-types';
|
|
3
|
+
import { Client, Transport } from '@tezos-x/octez.connect-core';
|
|
4
|
+
import { BlockExplorer } from '../utils/block-explorer';
|
|
5
|
+
import { DAppClientOptions } from './DAppClientOptions';
|
|
6
|
+
import { BeaconEventHandler } from '@tezos-x/octez.connect-dapp';
|
|
7
|
+
import { DappPostMessageTransport } from '../transports/DappPostMessageTransport';
|
|
8
|
+
import { DappP2PTransport } from '../transports/DappP2PTransport';
|
|
9
|
+
import { DappWalletConnectTransport } from '../transports/DappWalletConnectTransport';
|
|
10
|
+
/**
|
|
11
|
+
* @publicapi
|
|
12
|
+
*
|
|
13
|
+
* The DAppClient has to be used in decentralized applications. It handles all the logic related to connecting to beacon-compatible
|
|
14
|
+
* wallets and sending requests.
|
|
15
|
+
*
|
|
16
|
+
* @category DApp
|
|
17
|
+
*/
|
|
18
|
+
export declare class DAppClient extends Client {
|
|
19
|
+
/**
|
|
20
|
+
* The description of the app
|
|
21
|
+
*/
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The block explorer used by the SDK
|
|
25
|
+
*/
|
|
26
|
+
readonly blockExplorer: BlockExplorer;
|
|
27
|
+
/**
|
|
28
|
+
* Automatically switch between apps on Mobile Devices (Enabled by Default)
|
|
29
|
+
*/
|
|
30
|
+
private enableAppSwitching;
|
|
31
|
+
/**
|
|
32
|
+
* Enable metrics tracking (Disabled by Default)
|
|
33
|
+
*/
|
|
34
|
+
private enableMetrics?;
|
|
35
|
+
private userId?;
|
|
36
|
+
network: Network;
|
|
37
|
+
protected readonly events: BeaconEventHandler;
|
|
38
|
+
protected postMessageTransport: DappPostMessageTransport | undefined;
|
|
39
|
+
protected p2pTransport: DappP2PTransport | undefined;
|
|
40
|
+
protected walletConnectTransport: DappWalletConnectTransport | undefined;
|
|
41
|
+
protected wcProjectId?: string;
|
|
42
|
+
protected wcRelayUrl?: string;
|
|
43
|
+
private isGetActiveAccountHandled;
|
|
44
|
+
private readonly openRequestsOtherTabs;
|
|
45
|
+
/**
|
|
46
|
+
* A map of requests that are currently "open", meaning we have sent them to a wallet and are still awaiting a response.
|
|
47
|
+
*/
|
|
48
|
+
private readonly openRequests;
|
|
49
|
+
/**
|
|
50
|
+
* The currently active account. For all requests that are associated to a specific request (operation request, signing request),
|
|
51
|
+
* the active account is used to determine the network and destination wallet
|
|
52
|
+
*/
|
|
53
|
+
private _activeAccount;
|
|
54
|
+
/**
|
|
55
|
+
* The currently active peer. This is used to address a peer in case the active account is not set. (Eg. for permission requests)
|
|
56
|
+
*/
|
|
57
|
+
private _activePeer;
|
|
58
|
+
private _initPromise;
|
|
59
|
+
private isInitPending;
|
|
60
|
+
private readonly activeAccountLoaded;
|
|
61
|
+
private readonly appMetadataManager;
|
|
62
|
+
private readonly disclaimerText?;
|
|
63
|
+
private readonly errorMessages;
|
|
64
|
+
private readonly featuredWallets;
|
|
65
|
+
private readonly storageValidator;
|
|
66
|
+
private readonly beaconIDB;
|
|
67
|
+
private debounceSetActiveAccount;
|
|
68
|
+
private multiTabChannel;
|
|
69
|
+
constructor(config: DAppClientOptions);
|
|
70
|
+
private checkIfBCLeaderExists;
|
|
71
|
+
private onElectedLeaderhandler;
|
|
72
|
+
private onBCMessageHandler;
|
|
73
|
+
private prepareRequest;
|
|
74
|
+
private createStateSnapshot;
|
|
75
|
+
private initUserID;
|
|
76
|
+
initInternalTransports(): Promise<void>;
|
|
77
|
+
private initEvents;
|
|
78
|
+
private onRelayerError;
|
|
79
|
+
private wcToastHandler;
|
|
80
|
+
private channelClosedHandler;
|
|
81
|
+
/**
|
|
82
|
+
* Destroy the instance.
|
|
83
|
+
*
|
|
84
|
+
* WARNING: Call `destroy` whenever you no longer need dAppClient
|
|
85
|
+
* as it frees internal subscriptions to the transport and therefore the instance may no longer work properly.
|
|
86
|
+
* If you wish to disconnect your dApp, use `disconnect` instead.
|
|
87
|
+
*/
|
|
88
|
+
destroy(): Promise<void>;
|
|
89
|
+
init(transport?: Transport<any>, substratePairing?: boolean): Promise<TransportType>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the active account
|
|
92
|
+
*/
|
|
93
|
+
getActiveAccount(): Promise<AccountInfo | undefined>;
|
|
94
|
+
private isInvalidState;
|
|
95
|
+
private resetInvalidState;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the active account
|
|
98
|
+
*
|
|
99
|
+
* @param account The account that will be set as the active account
|
|
100
|
+
*/
|
|
101
|
+
setActiveAccount(account?: AccountInfo): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Clear the active account
|
|
104
|
+
*/
|
|
105
|
+
clearActiveAccount(): Promise<void>;
|
|
106
|
+
setColorMode(colorMode: ColorMode): Promise<void>;
|
|
107
|
+
getColorMode(): Promise<ColorMode>;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated
|
|
110
|
+
*
|
|
111
|
+
* Use getOwnAppMetadata instead
|
|
112
|
+
*/
|
|
113
|
+
getAppMetadata(): Promise<AppMetadata>;
|
|
114
|
+
showPrepare(): Promise<void>;
|
|
115
|
+
hideUI(elements: ('alert' | 'toast')[]): Promise<void>;
|
|
116
|
+
private tryToAppSwitch;
|
|
117
|
+
private addQueryParam;
|
|
118
|
+
private buildPayload;
|
|
119
|
+
private updateMetricsStorage;
|
|
120
|
+
private sendMetrics;
|
|
121
|
+
private checkMakeRequest;
|
|
122
|
+
/**
|
|
123
|
+
* Will remove the account from the local storage and set a new active account if necessary.
|
|
124
|
+
*
|
|
125
|
+
* @param accountIdentifier ID of the account
|
|
126
|
+
*/
|
|
127
|
+
removeAccount(accountIdentifier: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Remove all accounts and set active account to undefined
|
|
130
|
+
*/
|
|
131
|
+
removeAllAccounts(): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Removes a peer and all the accounts that have been connected through that peer
|
|
134
|
+
*
|
|
135
|
+
* @param peer Peer to be removed
|
|
136
|
+
*/
|
|
137
|
+
removePeer(peer: ExtendedPeerInfo, sendDisconnectToPeer?: boolean): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Remove all peers and all accounts that have been connected through those peers
|
|
140
|
+
*/
|
|
141
|
+
removeAllPeers(sendDisconnectToPeers?: boolean): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Allows the user to subscribe to specific events that are fired in the SDK
|
|
144
|
+
*
|
|
145
|
+
* @param internalEvent The event to subscribe to
|
|
146
|
+
* @param eventCallback The callback that will be called when the event occurs
|
|
147
|
+
*/
|
|
148
|
+
subscribeToEvent<K extends BeaconEvent>(internalEvent: K, eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Check if we have permissions to send the specific message type to the active account.
|
|
151
|
+
* If no active account is set, only permission requests are allowed.
|
|
152
|
+
*
|
|
153
|
+
* @param type The type of the message
|
|
154
|
+
*/
|
|
155
|
+
checkPermissions(type: BeaconMessageType): Promise<boolean>;
|
|
156
|
+
sendNotification(title: string, message: string, payload: string, protocolIdentifier: string): Promise<string>;
|
|
157
|
+
private blockchains;
|
|
158
|
+
addBlockchain(chain: Blockchain): void;
|
|
159
|
+
removeBlockchain(chainIdentifier: string): void;
|
|
160
|
+
permissionRequest(input: PermissionRequestV3<string>): Promise<PermissionResponseV3<string>>;
|
|
161
|
+
request(input: BlockchainRequestV3<string>): Promise<BlockchainResponseV3<string>>;
|
|
162
|
+
/**
|
|
163
|
+
* Send a permission request to the DApp. This should be done as the first step. The wallet will respond
|
|
164
|
+
* with an publicKey and permissions that were given. The account returned will be set as the "activeAccount"
|
|
165
|
+
* and will be used for the following requests.
|
|
166
|
+
*
|
|
167
|
+
* @param input The message details we need to prepare the PermissionRequest message.
|
|
168
|
+
*/
|
|
169
|
+
requestPermissions(input?: RequestPermissionInput): Promise<PermissionResponseOutput>;
|
|
170
|
+
/**
|
|
171
|
+
* Send a proof of event request to the wallet. The wallet will either accept or decline the challenge.
|
|
172
|
+
* If it is accepted, the challenge will be stored, meaning that even if the user refresh the page, the DAppClient will keep checking if the challenge has been fulfilled.
|
|
173
|
+
* Once the challenge is stored, a challenge stored message will be sent to the wallet.
|
|
174
|
+
* It's **highly recommended** to run a proof of event challenge to check the identity of an abstracted account
|
|
175
|
+
*
|
|
176
|
+
* @param input The message details we need to prepare the ProofOfEventChallenge message.
|
|
177
|
+
*/
|
|
178
|
+
requestProofOfEventChallenge(input: RequestProofOfEventChallengeInput): Promise<ProofOfEventChallengeResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Send a simulated proof of event request to the wallet. The wallet will either accept or decline the challenge.
|
|
181
|
+
* It's the same than `requestProofOfEventChallenge` but rather than executing operations on the blockchain to prove the identity,
|
|
182
|
+
* The wallet will return a list of operations that you'll be able to run on your side to verify the identity of the abstracted account
|
|
183
|
+
* It's **highly recommended** to run a proof of event challenge to check the identity of an abstracted account
|
|
184
|
+
*
|
|
185
|
+
* @param input The message details we need to prepare the SimulatedProofOfEventChallenge message.
|
|
186
|
+
*/
|
|
187
|
+
requestSimulatedProofOfEventChallenge(input: RequestSimulatedProofOfEventChallengeInput): Promise<SimulatedProofOfEventChallengeResponse>;
|
|
188
|
+
/**
|
|
189
|
+
* This method will send a "SignPayloadRequest" to the wallet. This method is meant to be used to sign
|
|
190
|
+
* arbitrary data (eg. a string). It will return the signature in the format of "edsig..."
|
|
191
|
+
*
|
|
192
|
+
* @param input The message details we need to prepare the SignPayloadRequest message.
|
|
193
|
+
*/
|
|
194
|
+
requestSignPayload(input: RequestSignPayloadInput): Promise<SignPayloadResponseOutput>;
|
|
195
|
+
/**
|
|
196
|
+
* This method will send an "EncryptPayloadRequest" to the wallet. This method is meant to be used to encrypt or decrypt
|
|
197
|
+
* arbitrary data (eg. a string). It will return the encrypted or decrypted payload
|
|
198
|
+
*
|
|
199
|
+
* @param input The message details we need to prepare the EncryptPayloadRequest message.
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* This method sends an OperationRequest to the wallet. This method should be used for all kinds of operations,
|
|
203
|
+
* eg. transaction or delegation. Not all properties have to be provided. Data like "counter" and fees will be
|
|
204
|
+
* fetched and calculated by the wallet (but they can still be provided if required).
|
|
205
|
+
*
|
|
206
|
+
* @param input The message details we need to prepare the OperationRequest message.
|
|
207
|
+
*/
|
|
208
|
+
requestOperation(input: RequestOperationInput): Promise<OperationResponseOutput>;
|
|
209
|
+
/**
|
|
210
|
+
* Sends a "BroadcastRequest" to the wallet. This method can be used to inject an already signed transaction
|
|
211
|
+
* to the network.
|
|
212
|
+
*
|
|
213
|
+
* @param input The message details we need to prepare the BroadcastRequest message.
|
|
214
|
+
*/
|
|
215
|
+
requestBroadcast(input: RequestBroadcastInput): Promise<BroadcastResponseOutput>;
|
|
216
|
+
protected setActivePeer(peer?: PeerInfoType): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* A "setter" for when the transport needs to be changed.
|
|
219
|
+
*/
|
|
220
|
+
protected setTransport(transport?: Transport<any>): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* This method will emit an internal error message.
|
|
223
|
+
*
|
|
224
|
+
* @param errorMessage The error message to send.
|
|
225
|
+
*/
|
|
226
|
+
private sendInternalError;
|
|
227
|
+
/**
|
|
228
|
+
* This method will remove all accounts associated with a specific peer.
|
|
229
|
+
*
|
|
230
|
+
* @param peersToRemove An array of peers for which accounts should be removed
|
|
231
|
+
*/
|
|
232
|
+
private removeAccountsForPeers;
|
|
233
|
+
private removeAccountsForPeerIds;
|
|
234
|
+
/**
|
|
235
|
+
* This message handles errors that we receive from the wallet.
|
|
236
|
+
*
|
|
237
|
+
* @param request The request we sent
|
|
238
|
+
* @param beaconError The error we received
|
|
239
|
+
*/
|
|
240
|
+
private handleRequestError;
|
|
241
|
+
/**
|
|
242
|
+
* This message will send an event when we receive a successful response to one of the requests we sent.
|
|
243
|
+
*
|
|
244
|
+
* @param request The request we sent
|
|
245
|
+
* @param response The response we received
|
|
246
|
+
*/
|
|
247
|
+
private notifySuccess;
|
|
248
|
+
private getWalletInfoFromStorage;
|
|
249
|
+
private updateStorageWallet;
|
|
250
|
+
private getWalletInfo;
|
|
251
|
+
private getPeer;
|
|
252
|
+
/**
|
|
253
|
+
* This method handles sending of requests to the DApp. It makes sure that the DAppClient is initialized and connected
|
|
254
|
+
* to the transport. After that rate limits and permissions will be checked, an ID is attached and the request is sent
|
|
255
|
+
* to the DApp over the transport.
|
|
256
|
+
*
|
|
257
|
+
* @param requestInput The BeaconMessage to be sent to the wallet
|
|
258
|
+
* @param account The account that the message will be sent to
|
|
259
|
+
* @param skipResponse If true, the function return as soon as the message is sent
|
|
260
|
+
*/
|
|
261
|
+
private makeRequest;
|
|
262
|
+
/**
|
|
263
|
+
* This method handles sending of requests to the DApp. It makes sure that the DAppClient is initialized and connected
|
|
264
|
+
* to the transport. After that rate limits and permissions will be checked, an ID is attached and the request is sent
|
|
265
|
+
* to the DApp over the transport.
|
|
266
|
+
*
|
|
267
|
+
* @param requestInput The BeaconMessage to be sent to the wallet
|
|
268
|
+
* @param account The account that the message will be sent to
|
|
269
|
+
*/
|
|
270
|
+
private makeRequestV3;
|
|
271
|
+
private makeRequestBC;
|
|
272
|
+
disconnect(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Adds a requests to the "openRequests" set so we know what messages have already been answered/handled.
|
|
275
|
+
*
|
|
276
|
+
* @param id The ID of the message
|
|
277
|
+
* @param promise A promise that resolves once the response for that specific message is received
|
|
278
|
+
*/
|
|
279
|
+
private addOpenRequest;
|
|
280
|
+
private sendNotificationWithAccessToken;
|
|
281
|
+
private onNewAccount;
|
|
282
|
+
}
|