@metamask/connect-multichain 0.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/CHANGELOG.md +17 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/browser/es/connect-multichain.d.mts +585 -0
- package/dist/browser/es/connect-multichain.mjs +2609 -0
- package/dist/browser/es/connect-multichain.mjs.map +1 -0
- package/dist/browser/es/metafile-esm.json +1 -0
- package/dist/browser/iife/connect-multichain.d.ts +585 -0
- package/dist/browser/iife/connect-multichain.js +30057 -0
- package/dist/browser/iife/connect-multichain.js.map +1 -0
- package/dist/browser/iife/metafile-iife.json +1 -0
- package/dist/browser/umd/connect-multichain.d.ts +585 -0
- package/dist/browser/umd/connect-multichain.js +2622 -0
- package/dist/browser/umd/connect-multichain.js.map +1 -0
- package/dist/browser/umd/metafile-cjs.json +1 -0
- package/dist/node/cjs/connect-multichain.d.ts +585 -0
- package/dist/node/cjs/connect-multichain.js +2603 -0
- package/dist/node/cjs/connect-multichain.js.map +1 -0
- package/dist/node/cjs/metafile-cjs.json +1 -0
- package/dist/node/es/connect-multichain.d.mts +585 -0
- package/dist/node/es/connect-multichain.mjs +2564 -0
- package/dist/node/es/connect-multichain.mjs.map +1 -0
- package/dist/node/es/metafile-esm.json +1 -0
- package/dist/react-native/es/connect-multichain.d.mts +585 -0
- package/dist/react-native/es/connect-multichain.mjs +2517 -0
- package/dist/react-native/es/connect-multichain.mjs.map +1 -0
- package/dist/react-native/es/metafile-esm.json +1 -0
- package/dist/src/config/index.d.ts +4 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +4 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/domain/errors/base.d.ts +7 -0
- package/dist/src/domain/errors/base.d.ts.map +1 -0
- package/dist/src/domain/errors/base.js +8 -0
- package/dist/src/domain/errors/base.js.map +1 -0
- package/dist/src/domain/errors/index.d.ts +3 -0
- package/dist/src/domain/errors/index.d.ts.map +1 -0
- package/dist/src/domain/errors/index.js +2 -0
- package/dist/src/domain/errors/index.js.map +1 -0
- package/dist/src/domain/errors/rpc.d.ts +25 -0
- package/dist/src/domain/errors/rpc.d.ts.map +1 -0
- package/dist/src/domain/errors/rpc.js +33 -0
- package/dist/src/domain/errors/rpc.js.map +1 -0
- package/dist/src/domain/errors/storage.d.ts +24 -0
- package/dist/src/domain/errors/storage.d.ts.map +1 -0
- package/dist/src/domain/errors/storage.js +30 -0
- package/dist/src/domain/errors/storage.js.map +1 -0
- package/dist/src/domain/errors/types.d.ts +7 -0
- package/dist/src/domain/errors/types.d.ts.map +1 -0
- package/dist/src/domain/errors/types.js +2 -0
- package/dist/src/domain/errors/types.js.map +1 -0
- package/dist/src/domain/events/index.d.ts +39 -0
- package/dist/src/domain/events/index.d.ts.map +1 -0
- package/dist/src/domain/events/index.js +58 -0
- package/dist/src/domain/events/index.js.map +1 -0
- package/dist/src/domain/events/types/index.d.ts +8 -0
- package/dist/src/domain/events/types/index.d.ts.map +1 -0
- package/dist/src/domain/events/types/index.js +2 -0
- package/dist/src/domain/events/types/index.js.map +1 -0
- package/dist/src/domain/index.d.ts +9 -0
- package/dist/src/domain/index.d.ts.map +1 -0
- package/dist/src/domain/index.js +9 -0
- package/dist/src/domain/index.js.map +1 -0
- package/dist/src/domain/logger/index.d.ts +41 -0
- package/dist/src/domain/logger/index.d.ts.map +1 -0
- package/dist/src/domain/logger/index.js +79 -0
- package/dist/src/domain/logger/index.js.map +1 -0
- package/dist/src/domain/multichain/api/constants.d.ts +5 -0
- package/dist/src/domain/multichain/api/constants.d.ts.map +1 -0
- package/dist/src/domain/multichain/api/constants.js +101 -0
- package/dist/src/domain/multichain/api/constants.js.map +1 -0
- package/dist/src/domain/multichain/api/eip155.d.ts +58 -0
- package/dist/src/domain/multichain/api/eip155.d.ts.map +1 -0
- package/dist/src/domain/multichain/api/eip155.js +2 -0
- package/dist/src/domain/multichain/api/eip155.js.map +1 -0
- package/dist/src/domain/multichain/api/infura.d.ts +3 -0
- package/dist/src/domain/multichain/api/infura.d.ts.map +1 -0
- package/dist/src/domain/multichain/api/infura.js +10 -0
- package/dist/src/domain/multichain/api/infura.js.map +1 -0
- package/dist/src/domain/multichain/api/types.d.ts +89 -0
- package/dist/src/domain/multichain/api/types.d.ts.map +1 -0
- package/dist/src/domain/multichain/api/types.js +2 -0
- package/dist/src/domain/multichain/api/types.js.map +1 -0
- package/dist/src/domain/multichain/index.d.ts +51 -0
- package/dist/src/domain/multichain/index.d.ts.map +1 -0
- package/dist/src/domain/multichain/index.js +33 -0
- package/dist/src/domain/multichain/index.js.map +1 -0
- package/dist/src/domain/multichain/types.d.ts +102 -0
- package/dist/src/domain/multichain/types.d.ts.map +1 -0
- package/dist/src/domain/multichain/types.js +2 -0
- package/dist/src/domain/multichain/types.js.map +1 -0
- package/dist/src/domain/platform/index.d.ts +17 -0
- package/dist/src/domain/platform/index.d.ts.map +1 -0
- package/dist/src/domain/platform/index.js +122 -0
- package/dist/src/domain/platform/index.js.map +1 -0
- package/dist/src/domain/store/adapter.d.ts +10 -0
- package/dist/src/domain/store/adapter.d.ts.map +1 -0
- package/dist/src/domain/store/adapter.js +6 -0
- package/dist/src/domain/store/adapter.js.map +1 -0
- package/dist/src/domain/store/client.d.ts +16 -0
- package/dist/src/domain/store/client.d.ts.map +1 -0
- package/dist/src/domain/store/client.js +3 -0
- package/dist/src/domain/store/client.js.map +1 -0
- package/dist/src/domain/store/index.d.ts +3 -0
- package/dist/src/domain/store/index.d.ts.map +1 -0
- package/dist/src/domain/store/index.js +3 -0
- package/dist/src/domain/store/index.js.map +1 -0
- package/dist/src/domain/ui/factory.d.ts +26 -0
- package/dist/src/domain/ui/factory.d.ts.map +1 -0
- package/dist/src/domain/ui/factory.js +2 -0
- package/dist/src/domain/ui/factory.js.map +1 -0
- package/dist/src/domain/ui/index.d.ts +3 -0
- package/dist/src/domain/ui/index.d.ts.map +1 -0
- package/dist/src/domain/ui/index.js +2 -0
- package/dist/src/domain/ui/index.js.map +1 -0
- package/dist/src/domain/ui/types.d.ts +34 -0
- package/dist/src/domain/ui/types.d.ts.map +1 -0
- package/dist/src/domain/ui/types.js +38 -0
- package/dist/src/domain/ui/types.js.map +1 -0
- package/dist/src/domain/utils/index.d.ts +7 -0
- package/dist/src/domain/utils/index.d.ts.map +1 -0
- package/dist/src/domain/utils/index.js +9 -0
- package/dist/src/domain/utils/index.js.map +1 -0
- package/dist/src/index.browser.d.ts +4 -0
- package/dist/src/index.browser.d.ts.map +1 -0
- package/dist/src/index.browser.js +28 -0
- package/dist/src/index.browser.js.map +1 -0
- package/dist/src/index.native.d.ts +4 -0
- package/dist/src/index.native.d.ts.map +1 -0
- package/dist/src/index.native.js +28 -0
- package/dist/src/index.native.js.map +1 -0
- package/dist/src/index.node.d.ts +4 -0
- package/dist/src/index.node.d.ts.map +1 -0
- package/dist/src/index.node.js +28 -0
- package/dist/src/index.node.js.map +1 -0
- package/dist/src/multichain/index.d.ts +41 -0
- package/dist/src/multichain/index.d.ts.map +1 -0
- package/dist/src/multichain/index.js +499 -0
- package/dist/src/multichain/index.js.map +1 -0
- package/dist/src/multichain/rpc/handlers/rpcClient.d.ts +19 -0
- package/dist/src/multichain/rpc/handlers/rpcClient.d.ts.map +1 -0
- package/dist/src/multichain/rpc/handlers/rpcClient.js +105 -0
- package/dist/src/multichain/rpc/handlers/rpcClient.js.map +1 -0
- package/dist/src/multichain/rpc/requestRouter.d.ts +29 -0
- package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -0
- package/dist/src/multichain/rpc/requestRouter.js +104 -0
- package/dist/src/multichain/rpc/requestRouter.js.map +1 -0
- package/dist/src/multichain/transports/default/index.d.ts +17 -0
- package/dist/src/multichain/transports/default/index.d.ts.map +1 -0
- package/dist/src/multichain/transports/default/index.js +101 -0
- package/dist/src/multichain/transports/default/index.js.map +1 -0
- package/dist/src/multichain/transports/mwp/KeyManager.d.ts +9 -0
- package/dist/src/multichain/transports/mwp/KeyManager.d.ts.map +1 -0
- package/dist/src/multichain/transports/mwp/KeyManager.js +35 -0
- package/dist/src/multichain/transports/mwp/KeyManager.js.map +1 -0
- package/dist/src/multichain/transports/mwp/index.d.ts +65 -0
- package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -0
- package/dist/src/multichain/transports/mwp/index.js +323 -0
- package/dist/src/multichain/transports/mwp/index.js.map +1 -0
- package/dist/src/multichain/utils/index.d.ts +41 -0
- package/dist/src/multichain/utils/index.d.ts.map +1 -0
- package/dist/src/multichain/utils/index.js +239 -0
- package/dist/src/multichain/utils/index.js.map +1 -0
- package/dist/src/store/adapters/node.d.ts +9 -0
- package/dist/src/store/adapters/node.d.ts.map +1 -0
- package/dist/src/store/adapters/node.js +34 -0
- package/dist/src/store/adapters/node.js.map +1 -0
- package/dist/src/store/adapters/rn.d.ts +8 -0
- package/dist/src/store/adapters/rn.d.ts.map +1 -0
- package/dist/src/store/adapters/rn.js +33 -0
- package/dist/src/store/adapters/rn.js.map +1 -0
- package/dist/src/store/adapters/web.d.ts +16 -0
- package/dist/src/store/adapters/web.d.ts.map +1 -0
- package/dist/src/store/adapters/web.js +99 -0
- package/dist/src/store/adapters/web.js.map +1 -0
- package/dist/src/store/index.d.ts +17 -0
- package/dist/src/store/index.d.ts.map +1 -0
- package/dist/src/store/index.js +130 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/ui/index.d.ts +45 -0
- package/dist/src/ui/index.d.ts.map +1 -0
- package/dist/src/ui/index.js +185 -0
- package/dist/src/ui/index.js.map +1 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.d.ts +16 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.d.ts.map +1 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.js +90 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.js.map +1 -0
- package/dist/src/ui/modals/base/AbstractOTPModal.d.ts +8 -0
- package/dist/src/ui/modals/base/AbstractOTPModal.d.ts.map +1 -0
- package/dist/src/ui/modals/base/AbstractOTPModal.js +16 -0
- package/dist/src/ui/modals/base/AbstractOTPModal.js.map +1 -0
- package/dist/src/ui/modals/base/utils.d.ts +3 -0
- package/dist/src/ui/modals/base/utils.d.ts.map +1 -0
- package/dist/src/ui/modals/base/utils.js +30 -0
- package/dist/src/ui/modals/base/utils.js.map +1 -0
- package/dist/src/ui/modals/node/index.d.ts +3 -0
- package/dist/src/ui/modals/node/index.d.ts.map +1 -0
- package/dist/src/ui/modals/node/index.js +3 -0
- package/dist/src/ui/modals/node/index.js.map +1 -0
- package/dist/src/ui/modals/node/install.d.ts +9 -0
- package/dist/src/ui/modals/node/install.d.ts.map +1 -0
- package/dist/src/ui/modals/node/install.js +47 -0
- package/dist/src/ui/modals/node/install.js.map +1 -0
- package/dist/src/ui/modals/node/otp.d.ts +10 -0
- package/dist/src/ui/modals/node/otp.d.ts.map +1 -0
- package/dist/src/ui/modals/node/otp.js +10 -0
- package/dist/src/ui/modals/node/otp.js.map +1 -0
- package/dist/src/ui/modals/rn/index.d.ts +3 -0
- package/dist/src/ui/modals/rn/index.d.ts.map +1 -0
- package/dist/src/ui/modals/rn/index.js +3 -0
- package/dist/src/ui/modals/rn/index.js.map +1 -0
- package/dist/src/ui/modals/rn/install.d.ts +7 -0
- package/dist/src/ui/modals/rn/install.d.ts.map +1 -0
- package/dist/src/ui/modals/rn/install.js +9 -0
- package/dist/src/ui/modals/rn/install.js.map +1 -0
- package/dist/src/ui/modals/rn/otp.d.ts +10 -0
- package/dist/src/ui/modals/rn/otp.d.ts.map +1 -0
- package/dist/src/ui/modals/rn/otp.js +10 -0
- package/dist/src/ui/modals/rn/otp.js.map +1 -0
- package/dist/src/ui/modals/types.d.ts +13 -0
- package/dist/src/ui/modals/types.d.ts.map +1 -0
- package/dist/src/ui/modals/types.js +2 -0
- package/dist/src/ui/modals/types.js.map +1 -0
- package/dist/src/ui/modals/web/index.d.ts +3 -0
- package/dist/src/ui/modals/web/index.d.ts.map +1 -0
- package/dist/src/ui/modals/web/index.js +3 -0
- package/dist/src/ui/modals/web/index.js.map +1 -0
- package/dist/src/ui/modals/web/install.d.ts +7 -0
- package/dist/src/ui/modals/web/install.d.ts.map +1 -0
- package/dist/src/ui/modals/web/install.js +32 -0
- package/dist/src/ui/modals/web/install.js.map +1 -0
- package/dist/src/ui/modals/web/otp.d.ts +10 -0
- package/dist/src/ui/modals/web/otp.d.ts.map +1 -0
- package/dist/src/ui/modals/web/otp.js +10 -0
- package/dist/src/ui/modals/web/otp.js.map +1 -0
- package/dist/src/ui/qr.d.ts +3 -0
- package/dist/src/ui/qr.d.ts.map +1 -0
- package/dist/src/ui/qr.js +32 -0
- package/dist/src/ui/qr.js.map +1 -0
- package/dist/types/connect-multichain.d.ts +585 -0
- package/package.json +111 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Initial release
|
|
15
|
+
|
|
16
|
+
[Unreleased]: https://github.com/MetaMask/metamask-connect-monorepo/compare/@metamask/connect-multichain@0.1.0...HEAD
|
|
17
|
+
[0.1.0]: https://github.com/MetaMask/metamask-connect-monorepo/releases/tag/@metamask/connect-multichain@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/connect-multichain`
|
|
2
|
+
|
|
3
|
+
multichain
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/connect-multichain`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/connect-multichain`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/metamask-connect-monorepo#readme).
|
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { SessionData, Transport, MultichainApiClient } from '@metamask/multichain-api-client';
|
|
3
|
+
export { SessionData } from '@metamask/multichain-api-client';
|
|
4
|
+
import { CaipAccountId, Json } from '@metamask/utils';
|
|
5
|
+
import { SessionRequest } from '@metamask/mobile-wallet-protocol-core';
|
|
6
|
+
import { Components } from '@metamask/multichain-ui';
|
|
7
|
+
|
|
8
|
+
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
|
|
9
|
+
type ErrorCodeRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
|
|
10
|
+
type DomainErrorCodes = ErrorCodeRange<1, 50>;
|
|
11
|
+
type RPCErrorCodes = ErrorCodeRange<50, 60>;
|
|
12
|
+
type StorageErrorCodes = ErrorCodeRange<60, 70>;
|
|
13
|
+
type ErrorCodes = DomainErrorCodes | RPCErrorCodes | StorageErrorCodes;
|
|
14
|
+
|
|
15
|
+
declare abstract class BaseErr<C extends string, T extends ErrorCodes> extends Error {
|
|
16
|
+
readonly message: `${C}Err${T}: ${string}`;
|
|
17
|
+
readonly code: T;
|
|
18
|
+
constructor(message: `${C}Err${T}: ${string}`, code: T);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class RPCHttpErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
22
|
+
readonly rpcEndpoint: string;
|
|
23
|
+
readonly method: string;
|
|
24
|
+
readonly httpStatus: number;
|
|
25
|
+
static readonly code = 50;
|
|
26
|
+
constructor(rpcEndpoint: string, method: string, httpStatus: number);
|
|
27
|
+
}
|
|
28
|
+
declare class RPCReadonlyResponseErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
static readonly code = 51;
|
|
31
|
+
constructor(reason: string);
|
|
32
|
+
}
|
|
33
|
+
declare class RPCReadonlyRequestErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
static readonly code = 52;
|
|
36
|
+
constructor(reason: string);
|
|
37
|
+
}
|
|
38
|
+
declare class RPCInvokeMethodErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
39
|
+
readonly reason: string;
|
|
40
|
+
static readonly code = 53;
|
|
41
|
+
constructor(reason: string);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type SDKEvents = {
|
|
45
|
+
display_uri: [evt: string];
|
|
46
|
+
wallet_sessionChanged: [evt: SessionData | undefined];
|
|
47
|
+
[key: string]: [evt: unknown];
|
|
48
|
+
};
|
|
49
|
+
type EventTypes = SDKEvents;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A type-safe event emitter that provides a strongly-typed wrapper around EventEmitter2.
|
|
53
|
+
*
|
|
54
|
+
* This class ensures type safety for event names and their corresponding argument types,
|
|
55
|
+
* making it easier to work with events in a type-safe manner.
|
|
56
|
+
*
|
|
57
|
+
* @template TEvents - A record type mapping event names to their argument types.
|
|
58
|
+
* Each key represents an event name, and the value is a tuple of argument types.
|
|
59
|
+
*/
|
|
60
|
+
declare class EventEmitter<TEvents extends Record<string, unknown[]>> {
|
|
61
|
+
#private;
|
|
62
|
+
/**
|
|
63
|
+
* Emits an event with the specified name and arguments.
|
|
64
|
+
*
|
|
65
|
+
* @template TEventName - The name of the event to emit (must be a key of TEvents)
|
|
66
|
+
* @param eventName - The name of the event to emit
|
|
67
|
+
* @param eventArg - The arguments to pass to the event handlers
|
|
68
|
+
*/
|
|
69
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
70
|
+
/**
|
|
71
|
+
* Registers an event handler for the specified event.
|
|
72
|
+
*
|
|
73
|
+
* @template TEventName - The name of the event to listen for (must be a key of TEvents)
|
|
74
|
+
* @param eventName - The name of the event to listen for
|
|
75
|
+
* @param handler - The function to call when the event is emitted
|
|
76
|
+
* @returns Nothing
|
|
77
|
+
*/
|
|
78
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): () => void;
|
|
79
|
+
/**
|
|
80
|
+
* Removes a specific event handler for the specified event.
|
|
81
|
+
*
|
|
82
|
+
* @template TEventName - The name of the event to remove the handler from (must be a key of TEvents)
|
|
83
|
+
* @param eventName - The name of the event to remove the handler from
|
|
84
|
+
* @param handler - The specific handler function to remove
|
|
85
|
+
*/
|
|
86
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type StoreOptions = Record<string, any>;
|
|
90
|
+
declare abstract class StoreAdapter {
|
|
91
|
+
options?: StoreOptions | undefined;
|
|
92
|
+
abstract platform: 'web' | 'rn' | 'node';
|
|
93
|
+
constructor(options?: StoreOptions | undefined);
|
|
94
|
+
abstract get(key: string): Promise<string | null>;
|
|
95
|
+
abstract set(key: string, value: string): Promise<void>;
|
|
96
|
+
abstract delete(key: string): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type EIP155 = {
|
|
100
|
+
methods: {
|
|
101
|
+
personal_sign: RpcMethod<{
|
|
102
|
+
message: string;
|
|
103
|
+
account: string;
|
|
104
|
+
}, string>;
|
|
105
|
+
eth_accounts: RpcMethod<void, string[]>;
|
|
106
|
+
eth_chainId: RpcMethod<void, string>;
|
|
107
|
+
eth_sendTransaction: RpcMethod<{
|
|
108
|
+
to: string;
|
|
109
|
+
value?: string;
|
|
110
|
+
data?: string;
|
|
111
|
+
}, string>;
|
|
112
|
+
eth_call: RpcMethod<{
|
|
113
|
+
to: string;
|
|
114
|
+
data?: string;
|
|
115
|
+
}, string>;
|
|
116
|
+
eth_getBalance: RpcMethod<{
|
|
117
|
+
address: string;
|
|
118
|
+
blockNumber: string;
|
|
119
|
+
}, string>;
|
|
120
|
+
wallet_switchEthereumChain: RpcMethod<{
|
|
121
|
+
chainId: string;
|
|
122
|
+
}, void>;
|
|
123
|
+
wallet_addEthereumChain: RpcMethod<{
|
|
124
|
+
chainId: string;
|
|
125
|
+
chainName: string;
|
|
126
|
+
nativeCurrency?: {
|
|
127
|
+
name: string;
|
|
128
|
+
symbol: string;
|
|
129
|
+
decimals: number;
|
|
130
|
+
} | undefined;
|
|
131
|
+
rpcUrls: readonly string[];
|
|
132
|
+
blockExplorerUrls?: string[] | undefined;
|
|
133
|
+
iconUrls?: string[] | undefined;
|
|
134
|
+
}, void>;
|
|
135
|
+
signAndSendTransaction: RpcMethod<{
|
|
136
|
+
to: string;
|
|
137
|
+
value?: string;
|
|
138
|
+
data?: string;
|
|
139
|
+
}, string>;
|
|
140
|
+
signTransaction: RpcMethod<{
|
|
141
|
+
to: string;
|
|
142
|
+
value?: string;
|
|
143
|
+
data?: string;
|
|
144
|
+
}, string>;
|
|
145
|
+
signMessage: RpcMethod<{
|
|
146
|
+
message: string;
|
|
147
|
+
}, string>;
|
|
148
|
+
signIn: RpcMethod<{
|
|
149
|
+
message: string;
|
|
150
|
+
}, string>;
|
|
151
|
+
};
|
|
152
|
+
events: ['eth_subscription'];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Represents a blockchain scope identifier in CAIP format.
|
|
157
|
+
*
|
|
158
|
+
* Scopes define which blockchain networks and standards the SDK
|
|
159
|
+
* can interact with. The format follows CAIP standards for
|
|
160
|
+
* blockchain identification.
|
|
161
|
+
*
|
|
162
|
+
* @template T - The RPC API type to extract available scopes from
|
|
163
|
+
*/
|
|
164
|
+
type Scope<T extends RPCAPI = RPCAPI> = `eip155:${string}` | `solana:${string}` | `${Extract<keyof T, string>}:${string}`;
|
|
165
|
+
/**
|
|
166
|
+
* Represents a generic RPC (Remote Procedure Call) method function type.
|
|
167
|
+
*
|
|
168
|
+
* This type defines the signature for RPC methods that can be either synchronous
|
|
169
|
+
* or asynchronous, providing flexibility for different types of API calls.
|
|
170
|
+
*
|
|
171
|
+
* @template Params - The type of parameters that the RPC method accepts
|
|
172
|
+
* @template Return - The type of value that the RPC method returns
|
|
173
|
+
*
|
|
174
|
+
* @param params - The parameters to pass to the RPC method
|
|
175
|
+
* @returns Either a Promise that resolves to the return value, or the return value directly
|
|
176
|
+
*/
|
|
177
|
+
type RpcMethod<Params, Return> = (params: Params) => Promise<Return> | Return;
|
|
178
|
+
/**
|
|
179
|
+
* Defines the structure of the RPC API interface.
|
|
180
|
+
*
|
|
181
|
+
* This type represents the available RPC APIs organized by blockchain standard.
|
|
182
|
+
* Currently supports EIP-155 (Ethereum) with the potential for additional
|
|
183
|
+
* blockchain standards to be added in the future.
|
|
184
|
+
*/
|
|
185
|
+
type RPCAPI = {
|
|
186
|
+
/** EIP-155 compliant RPC methods for Ethereum-based chains */
|
|
187
|
+
eip155: EIP155;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Callback function type for handling incoming notifications.
|
|
191
|
+
*
|
|
192
|
+
* This type defines the signature for functions that process notification
|
|
193
|
+
* messages received from RPC connections.
|
|
194
|
+
*
|
|
195
|
+
* @param notification - The notification object to handle
|
|
196
|
+
*/
|
|
197
|
+
type NotificationCallback = (notification: unknown) => void;
|
|
198
|
+
/**
|
|
199
|
+
* Options for invoking RPC methods with specific scope and request parameters.
|
|
200
|
+
*
|
|
201
|
+
* This type defines the structure for method invocation options, allowing
|
|
202
|
+
* callers to specify both the blockchain scope and the specific request details.
|
|
203
|
+
*/
|
|
204
|
+
type InvokeMethodOptions = {
|
|
205
|
+
/** The blockchain scope/standard to use for the method call */
|
|
206
|
+
scope: Scope;
|
|
207
|
+
/** The request details including method name and parameters */
|
|
208
|
+
request: {
|
|
209
|
+
/** The name of the RPC method to invoke */
|
|
210
|
+
method: string;
|
|
211
|
+
/** The parameters to pass to the RPC method */
|
|
212
|
+
params: unknown;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Mapping of CAIP chain IDs to their corresponding RPC URLs.
|
|
217
|
+
*
|
|
218
|
+
* This type defines the structure for providing custom RPC endpoints
|
|
219
|
+
* for different blockchain networks using CAIP-2 format identifiers.
|
|
220
|
+
*/
|
|
221
|
+
type RpcUrlsMap = {
|
|
222
|
+
/** CAIP-2 format chain ID mapped to its RPC URL (e.g., "eip155:1" -> "https://...") */
|
|
223
|
+
[chainId: CaipChainId]: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Represents the structure of a JSON-RPC response.
|
|
227
|
+
*
|
|
228
|
+
* This type defines the expected format of JSON-RPC responses from RPC endpoints.
|
|
229
|
+
* It includes the unique identifier for the request, the JSON-RPC version used,
|
|
230
|
+
* and the result of the RPC call.
|
|
231
|
+
*
|
|
232
|
+
* id - The unique identifier for the request
|
|
233
|
+
* jsonrpc - The JSON-RPC version used
|
|
234
|
+
* result - The result of the RPC call JSON
|
|
235
|
+
*/
|
|
236
|
+
type RPCResponse = {
|
|
237
|
+
id: number;
|
|
238
|
+
jsonrpc: string;
|
|
239
|
+
result: unknown;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
declare abstract class AbstractOTPCodeModal extends Modal<OTPCodeWidgetProps, OTPCode> {
|
|
243
|
+
protected instance?: HTMLMmOtpModalElement | undefined;
|
|
244
|
+
get otpCode(): string;
|
|
245
|
+
set otpCode(code: string);
|
|
246
|
+
updateOTPCode(code: string): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare abstract class AbstractInstallModal extends Modal<InstallWidgetProps, QRLink> {
|
|
250
|
+
protected instance?: HTMLMmInstallModalElement | undefined;
|
|
251
|
+
private expirationInterval;
|
|
252
|
+
private lastLoggedCountdown;
|
|
253
|
+
abstract renderQRCode(link: QRLink, connectionRequest: ConnectionRequest): void;
|
|
254
|
+
get link(): QRLink;
|
|
255
|
+
set link(link: QRLink);
|
|
256
|
+
get connectionRequest(): ConnectionRequest;
|
|
257
|
+
set connectionRequest(connectionRequest: ConnectionRequest);
|
|
258
|
+
protected updateLink(link: QRLink): void;
|
|
259
|
+
protected updateExpiresIn(expiresIn: number): void;
|
|
260
|
+
protected startExpirationCheck(connectionRequest: ConnectionRequest): void;
|
|
261
|
+
protected stopExpirationCheck(): void;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Record type that maps modal names to their corresponding Modal instances.
|
|
266
|
+
* Used to store different types of modals that can be created by the factory.
|
|
267
|
+
*/
|
|
268
|
+
type FactoryModals = {
|
|
269
|
+
InstallModal: new (options: InstallWidgetProps) => AbstractInstallModal;
|
|
270
|
+
OTPCodeModal: new (options: OTPCodeWidgetProps) => AbstractOTPCodeModal;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
declare class ModalFactory<T extends FactoryModals = FactoryModals> {
|
|
274
|
+
protected readonly options: T;
|
|
275
|
+
modal: Modal<any>;
|
|
276
|
+
private readonly platform;
|
|
277
|
+
private successCallback;
|
|
278
|
+
/**
|
|
279
|
+
* Creates a new modal factory instance.
|
|
280
|
+
*
|
|
281
|
+
* @param options - The modals configuration object
|
|
282
|
+
*/
|
|
283
|
+
constructor(options: T);
|
|
284
|
+
private validateModals;
|
|
285
|
+
unload(error?: Error): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Determines if the current platform is a mobile native environment.
|
|
288
|
+
* Currently only includes React Native.
|
|
289
|
+
*/
|
|
290
|
+
get isMobile(): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Determines if the current platform is a Node.js environment.
|
|
293
|
+
* Used for server-side or non-browser environments.
|
|
294
|
+
*/
|
|
295
|
+
get isNode(): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Determines if the current platform is a web environment.
|
|
298
|
+
* Includes desktop web, MetaMask mobile webview, and mobile web.
|
|
299
|
+
*/
|
|
300
|
+
get isWeb(): boolean;
|
|
301
|
+
private getContainer;
|
|
302
|
+
private getMountedContainer;
|
|
303
|
+
createDeeplink(connectionRequest?: ConnectionRequest): string;
|
|
304
|
+
createUniversalLink(connectionRequest?: ConnectionRequest): string;
|
|
305
|
+
private onCloseModal;
|
|
306
|
+
private onStartDesktopOnboarding;
|
|
307
|
+
renderInstallModal(preferDesktop: boolean, createConnectionRequest: () => Promise<ConnectionRequest>, successCallback: (error?: Error) => Promise<void>): Promise<void>;
|
|
308
|
+
renderOTPCodeModal(createOTPCode: () => Promise<OTPCode>, successCallback: (error?: Error) => Promise<void>, updateOTPCode: (otpCode: OTPCode, modal: AbstractOTPCodeModal) => void): Promise<void>;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare enum PlatformType {
|
|
312
|
+
NonBrowser = "nodejs",
|
|
313
|
+
MetaMaskMobileWebview = "in-app-browser",
|
|
314
|
+
DesktopWeb = "web-desktop",
|
|
315
|
+
MobileWeb = "web-mobile",
|
|
316
|
+
ReactNative = "react-native"
|
|
317
|
+
}
|
|
318
|
+
declare function getPlatformType(): PlatformType;
|
|
319
|
+
/**
|
|
320
|
+
* Check if MetaMask extension is installed
|
|
321
|
+
*
|
|
322
|
+
* @returns True if extension is installed, false otherwise
|
|
323
|
+
*/
|
|
324
|
+
declare function isMetamaskExtensionInstalled(): boolean;
|
|
325
|
+
declare function isSecure(): boolean;
|
|
326
|
+
declare function hasExtension(): Promise<boolean>;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Configuration settings for the dapp using the SDK.
|
|
330
|
+
*
|
|
331
|
+
* This type allows for two variants of dapp configuration:
|
|
332
|
+
* - Using a regular icon URL
|
|
333
|
+
* - Using a base64-encoded icon
|
|
334
|
+
*/
|
|
335
|
+
type DappSettings = {
|
|
336
|
+
name?: string;
|
|
337
|
+
url?: string;
|
|
338
|
+
} & ({
|
|
339
|
+
iconUrl?: string;
|
|
340
|
+
} | {
|
|
341
|
+
base64Icon?: string;
|
|
342
|
+
});
|
|
343
|
+
type ConnectionRequest = {
|
|
344
|
+
sessionRequest: SessionRequest;
|
|
345
|
+
metadata: {
|
|
346
|
+
dapp: DappSettings;
|
|
347
|
+
sdk: {
|
|
348
|
+
version: string;
|
|
349
|
+
platform: PlatformType;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Constructor options for creating a Multichain SDK instance.
|
|
355
|
+
*
|
|
356
|
+
* This type defines all the configuration options available when
|
|
357
|
+
* initializing the SDK, including dapp settings, API configuration,
|
|
358
|
+
* analytics, storage, UI preferences, and transport options.
|
|
359
|
+
*/
|
|
360
|
+
type MultichainOptions = {
|
|
361
|
+
/** Dapp identification and branding settings */
|
|
362
|
+
dapp: DappSettings;
|
|
363
|
+
/** Optional API configuration for external services */
|
|
364
|
+
api?: {
|
|
365
|
+
/** The Infura API key to use for RPC requests */
|
|
366
|
+
infuraAPIKey?: string;
|
|
367
|
+
/** A map of RPC URLs to use for read-only requests */
|
|
368
|
+
readonlyRPCMap?: RpcUrlsMap;
|
|
369
|
+
};
|
|
370
|
+
/** Analytics configuration */
|
|
371
|
+
analytics?: {
|
|
372
|
+
enabled: false;
|
|
373
|
+
} | {
|
|
374
|
+
enabled: true;
|
|
375
|
+
integrationType: string;
|
|
376
|
+
};
|
|
377
|
+
/** Storage client for persisting SDK data */
|
|
378
|
+
storage: StoreClient;
|
|
379
|
+
/** UI configuration options */
|
|
380
|
+
ui: {
|
|
381
|
+
factory: ModalFactory;
|
|
382
|
+
headless?: boolean;
|
|
383
|
+
preferExtension?: boolean;
|
|
384
|
+
preferDesktop?: boolean;
|
|
385
|
+
};
|
|
386
|
+
mobile?: {
|
|
387
|
+
preferredOpenLink?: (deeplink: string, target?: string) => void;
|
|
388
|
+
/**
|
|
389
|
+
* The `MetaMaskSDK` constructor option `useDeeplink: boolean` controls which type of link is used:
|
|
390
|
+
* - If `true`, the SDK will attempt to use the `metamask://` deeplink.
|
|
391
|
+
* - If `false` (the default for web), the SDK will use the `https://metamask.app.link` universal link.
|
|
392
|
+
*/
|
|
393
|
+
useDeeplink?: boolean;
|
|
394
|
+
};
|
|
395
|
+
/** Optional transport configuration */
|
|
396
|
+
transport?: {
|
|
397
|
+
/** Extension ID for browser extension transport */
|
|
398
|
+
extensionId?: string;
|
|
399
|
+
onNotification?: (notification: unknown) => void;
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
type MultiChainFNOptions = Omit<MultichainOptions, 'storage' | 'ui'> & {
|
|
403
|
+
ui?: Omit<MultichainOptions['ui'], 'factory'>;
|
|
404
|
+
} & {
|
|
405
|
+
storage?: StoreClient;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Complete options for Multichain SDK configuration.
|
|
409
|
+
*
|
|
410
|
+
* This type extends the base options with storage configuration,
|
|
411
|
+
* providing all necessary options for SDK initialization.
|
|
412
|
+
*/
|
|
413
|
+
type CreateMultichainFN = (options: MultiChainFNOptions) => Promise<MultichainCore>;
|
|
414
|
+
type ExtendedTransport = Omit<Transport, 'connect'> & {
|
|
415
|
+
connect: (props?: {
|
|
416
|
+
scopes: Scope[];
|
|
417
|
+
caipAccountIds: CaipAccountId[];
|
|
418
|
+
}) => Promise<void>;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
declare const infuraRpcUrls: RpcUrlsMap;
|
|
422
|
+
declare const RPC_HANDLED_METHODS: Set<string>;
|
|
423
|
+
declare const SDK_HANDLED_METHODS: Set<string>;
|
|
424
|
+
|
|
425
|
+
declare function getInfuraRpcUrls(infuraAPIKey: string): RpcUrlsMap;
|
|
426
|
+
|
|
427
|
+
type SDKState = 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting';
|
|
428
|
+
declare enum TransportType {
|
|
429
|
+
Browser = "browser",
|
|
430
|
+
MPW = "mwp",
|
|
431
|
+
UNKNOWN = "unknown"
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Abstract base class for the Multichain SDK implementation.
|
|
435
|
+
*
|
|
436
|
+
* This class defines the core interface that all Multichain SDK implementations
|
|
437
|
+
* must provide, including session management, connection handling, and method invocation.
|
|
438
|
+
*/
|
|
439
|
+
declare abstract class MultichainCore extends EventEmitter<SDKEvents> {
|
|
440
|
+
protected readonly options: MultichainOptions;
|
|
441
|
+
abstract storage: StoreClient;
|
|
442
|
+
abstract state: SDKState;
|
|
443
|
+
abstract provider: MultichainApiClient<RPCAPI>;
|
|
444
|
+
abstract transport: Transport;
|
|
445
|
+
/**
|
|
446
|
+
* Establishes a connection to the multichain provider, or re-use existing session
|
|
447
|
+
*
|
|
448
|
+
* @returns Promise that resolves to the session data
|
|
449
|
+
*/
|
|
450
|
+
abstract connect(scopes: Scope[], caipAccountIds: CaipAccountId[]): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Disconnects from the multichain provider.
|
|
453
|
+
*
|
|
454
|
+
* @returns Promise that resolves when disconnection is complete
|
|
455
|
+
*/
|
|
456
|
+
abstract disconnect(): Promise<void>;
|
|
457
|
+
/**
|
|
458
|
+
* Invokes an RPC method with the specified options.
|
|
459
|
+
*
|
|
460
|
+
* @param options - The method invocation options including scope and request details
|
|
461
|
+
* @returns Promise that resolves to the method result
|
|
462
|
+
*/
|
|
463
|
+
abstract invokeMethod(options: InvokeMethodOptions): Promise<Json>;
|
|
464
|
+
constructor(options: MultichainOptions);
|
|
465
|
+
}
|
|
466
|
+
declare function getTransportType(type: string): TransportType;
|
|
467
|
+
|
|
468
|
+
declare abstract class StoreClient {
|
|
469
|
+
abstract adapter: StoreAdapter;
|
|
470
|
+
abstract getAnonId(): Promise<string>;
|
|
471
|
+
abstract getExtensionId(): Promise<string | null>;
|
|
472
|
+
abstract setExtensionId(extensionId: string): Promise<void>;
|
|
473
|
+
abstract getTransport(): Promise<TransportType | null>;
|
|
474
|
+
abstract setTransport(transport: TransportType): Promise<void>;
|
|
475
|
+
abstract removeTransport(): Promise<void>;
|
|
476
|
+
abstract setAnonId(anonId: string): Promise<void>;
|
|
477
|
+
abstract removeExtensionId(): Promise<void>;
|
|
478
|
+
abstract removeAnonId(): Promise<void>;
|
|
479
|
+
abstract getDebug(): Promise<string | null>;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Supported debug namespace types for the MetaMask SDK logger.
|
|
484
|
+
* These namespaces help categorize and filter debug output.
|
|
485
|
+
*/
|
|
486
|
+
type LoggerNameSpaces = 'metamask-sdk' | 'metamask-sdk:core' | 'metamask-sdk:provider' | 'metamask-sdk:ui' | 'metamask-sdk:transport';
|
|
487
|
+
/**
|
|
488
|
+
* Creates a debug logger instance with the specified namespace and color.
|
|
489
|
+
*
|
|
490
|
+
* This function initializes a debug logger using the 'debug' library,
|
|
491
|
+
* which allows for conditional logging based on environment variables or storage settings.
|
|
492
|
+
*
|
|
493
|
+
* @param namespace - The debug namespace to use for this logger instance
|
|
494
|
+
* @param color - The ANSI color code to use for log output (default: '214' for yellow)
|
|
495
|
+
* @returns A configured debug logger instance
|
|
496
|
+
*/
|
|
497
|
+
declare const createLogger: (namespace?: LoggerNameSpaces, color?: string) => debug.Debugger;
|
|
498
|
+
/**
|
|
499
|
+
* Enables debug logging for the specified namespace.
|
|
500
|
+
*
|
|
501
|
+
* This function activates debug output for the given namespace,
|
|
502
|
+
* allowing debug messages to be displayed in the console.
|
|
503
|
+
*
|
|
504
|
+
* @param namespace - The debug namespace to enable
|
|
505
|
+
*/
|
|
506
|
+
declare const enableDebug: (namespace?: LoggerNameSpaces) => void;
|
|
507
|
+
/**
|
|
508
|
+
* Determines if debug logging is enabled for a specific namespace.
|
|
509
|
+
*
|
|
510
|
+
* This function checks multiple sources to determine if debug logging should be active:
|
|
511
|
+
* 1. First checks the process environment variable 'debug'
|
|
512
|
+
* 2. Falls back to checking the debug setting in storage
|
|
513
|
+
* 3. Returns false if neither source enables the namespace
|
|
514
|
+
*
|
|
515
|
+
* @param namespace - The namespace to check for debug enablement
|
|
516
|
+
* @param storage - The storage client to check for debug settings
|
|
517
|
+
* @returns Promise that resolves to true if debug logging is enabled, false otherwise
|
|
518
|
+
*/
|
|
519
|
+
declare const isEnabled: (namespace: LoggerNameSpaces, storage: StoreClient) => Promise<boolean>;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Options passed when establishing a connection through a modal.
|
|
523
|
+
* Contains the scopes (permissions) and account IDs involved in the connection.
|
|
524
|
+
*/
|
|
525
|
+
type ModalFactoryConnectOptions = {
|
|
526
|
+
scopes: Scope[];
|
|
527
|
+
caipAccountIds: CaipAccountId[];
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Configuration options for the modal factory.
|
|
531
|
+
* Combines mobile settings from SDK options with UI preferences and connection handling.
|
|
532
|
+
*/
|
|
533
|
+
type ModalFactoryOptions = Pick<MultichainOptions, 'mobile' | 'transport'> & {
|
|
534
|
+
ui: {
|
|
535
|
+
headless?: boolean;
|
|
536
|
+
preferExtension?: boolean;
|
|
537
|
+
preferDesktop?: boolean;
|
|
538
|
+
};
|
|
539
|
+
onConnection: (transport: Transport, options: ModalFactoryConnectOptions) => Promise<void>;
|
|
540
|
+
getCurrentSession: () => Promise<SessionData | undefined>;
|
|
541
|
+
connection?: ModalFactoryConnectOptions;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
type OTPCode = string;
|
|
545
|
+
type QRLink = string;
|
|
546
|
+
type InstallWidgetProps = Components.MmInstallModal & {
|
|
547
|
+
parentElement?: Element;
|
|
548
|
+
connectionRequest: ConnectionRequest;
|
|
549
|
+
onClose: (shouldTerminate?: boolean) => void;
|
|
550
|
+
startDesktopOnboarding: () => void;
|
|
551
|
+
createConnectionRequest: () => Promise<ConnectionRequest>;
|
|
552
|
+
generateQRCode: (connectionRequest: ConnectionRequest) => Promise<QRLink>;
|
|
553
|
+
};
|
|
554
|
+
type OTPCodeWidgetProps = Components.MmOtpModal & {
|
|
555
|
+
parentElement?: Element;
|
|
556
|
+
onClose: () => Promise<void>;
|
|
557
|
+
onDisconnect?: () => void;
|
|
558
|
+
createOTPCode: () => Promise<OTPCode>;
|
|
559
|
+
updateOTPCode: (otpValue: string) => void;
|
|
560
|
+
};
|
|
561
|
+
type DataType = OTPCode | QRLink;
|
|
562
|
+
/**
|
|
563
|
+
* Abstract Modal class with shared functionality across all models
|
|
564
|
+
*/
|
|
565
|
+
declare abstract class Modal<Options, Data extends DataType = DataType> {
|
|
566
|
+
protected readonly options: Options;
|
|
567
|
+
protected abstract instance?: HTMLMmInstallModalElement | HTMLMmOtpModalElement | undefined;
|
|
568
|
+
abstract mount(): void;
|
|
569
|
+
abstract unmount(): void;
|
|
570
|
+
constructor(options: Options);
|
|
571
|
+
get isMounted(): boolean;
|
|
572
|
+
get data(): Data;
|
|
573
|
+
set data(data: Data);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Returns the version of the Multichain SDK.
|
|
578
|
+
*
|
|
579
|
+
* @returns The version of the Multichain SDK.
|
|
580
|
+
*/
|
|
581
|
+
declare function getVersion(): string;
|
|
582
|
+
|
|
583
|
+
declare const createMetamaskConnect: CreateMultichainFN;
|
|
584
|
+
|
|
585
|
+
export { type ConnectionRequest, type CreateMultichainFN, type DappSettings, type DataType, type DomainErrorCodes, type Enumerate, type ErrorCodeRange, type ErrorCodes, EventEmitter, type EventTypes, type ExtendedTransport, type InstallWidgetProps, type InvokeMethodOptions, type LoggerNameSpaces, Modal, type ModalFactoryConnectOptions, type ModalFactoryOptions, MultichainCore, type MultichainOptions, type NotificationCallback, type OTPCode, type OTPCodeWidgetProps, PlatformType, type QRLink, type RPCAPI, type RPCErrorCodes, RPCHttpErr, RPCInvokeMethodErr, RPCReadonlyRequestErr, RPCReadonlyResponseErr, type RPCResponse, RPC_HANDLED_METHODS, type RpcMethod, type RpcUrlsMap, type SDKEvents, type SDKState, SDK_HANDLED_METHODS, type Scope, type StorageErrorCodes, StoreAdapter, StoreClient, type StoreOptions, TransportType, createLogger, createMetamaskConnect, enableDebug, getInfuraRpcUrls, getPlatformType, getTransportType, getVersion, hasExtension, infuraRpcUrls, isEnabled, isMetamaskExtensionInstalled, isSecure };
|