Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk-multichain-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Install modal web package for multichain, renders and uses the new mobile wallet protocol ConnectionRequest QRCodes.

This project includes fully functional InstallModal web used in the Multichain SDK for Trusted flows.
This project includes fully functional InstallModal web used in the MetaMask Connect Module for Trusted flows.

Untrusted flows use the OTPModal which exists but is not yet fully supported.

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-multichain-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@metamask/sdk-multichain-ui",
"version": "0.0.0",
"description": "MetaMask SDK Install Modal for Web",
"description": "MetaMask Connect Install Modal for Web",
"homepage": "https://github.com/MetaMask/metamask-sdk#readme",
"bugs": {
"url": "https://github.com/MetaMask/metamask-sdk/issues"
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-multichain-ui/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const config = [
file: packageJson.unpkg,
format: 'umd',
exports: 'named',
name: 'MetaMaskSDKInstallModal',
name: 'MetaMaskConnectInstallModal',
sourcemap: true
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { h } from "@stencil/core";

export default function ConnectVersion({version}: {version?: string}) {
return (
<div class="version-title">Connect Version {version ? `v${version}`:`unknown`}</div>
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Prop, h, Event, EventEmitter, State, Element, Watch } from '@stencil/core';
import { WidgetWrapper } from '../widget-wrapper/widget-wrapper';
import InstallIcon from '../misc/InstallIcon';
import SDKVersion from '../misc/SDKVersion';
import ConnectVersion from '../misc/ConnectVersion';
import CloseButton from '../misc/CloseButton';

import QRCodeStyling, {
Expand All @@ -27,7 +27,7 @@ export class InstallModal {

@Prop() expiresIn: number;

@Prop() sdkVersion?: string;
@Prop() connectVersion?: string;

@Prop() preferDesktop: boolean;

Expand Down Expand Up @@ -215,7 +215,7 @@ export class InstallModal {
)}
</div>

<SDKVersion version={this.sdkVersion} />
<ConnectVersion version={this.connectVersion} />
</div>
</WidgetWrapper>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Prop, h, Event, EventEmitter, State, Element } from '@stencil/core';
import { WidgetWrapper } from '../widget-wrapper/widget-wrapper';
import SDKVersion from '../misc/SDKVersion';
import ConnectVersion from '../misc/ConnectVersion';
import CloseButton from '../misc/CloseButton';
import { SimpleI18n } from '../misc/simple-i18n';
import InstallIcon from '../misc/InstallIcon';
Expand All @@ -16,7 +16,7 @@ export class OtpModal {
*/
@Prop() displayOTP?: boolean;

@Prop() sdkVersion?: string;
@Prop() connectVersion?: string;

private i18nInstance: SimpleI18n;

Expand Down Expand Up @@ -67,7 +67,7 @@ export class OtpModal {
}

const displayOTP = this.displayOTP ?? true;
const sdkVersion = this.sdkVersion
const connectVersion = this.connectVersion
const t = (key: string) => this.i18nInstance.t(key);

return (
Expand Down Expand Up @@ -132,7 +132,7 @@ export class OtpModal {
</button>
</div>
</div>
<SDKVersion version={sdkVersion} />
<ConnectVersion version={connectVersion} />
</div>
</WidgetWrapper>
)
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-multichain-ui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>SDK Install Modal Web</title>
<title>MetaMask Connect Install Modal Web</title>
<script type="module" src="/build/sdk-install-modal-web.esm.js"></script>
<script nomodule src="/build/sdk-install-modal-web.js"></script>
<style>
Expand Down Expand Up @@ -42,7 +42,7 @@
<h2>Install Modal</h2>
<mm-install-modal
link="https://example.com/install"
sdk-version="1.0.0"
connect-version="1.0.0"
prefer-desktop="true"
></mm-install-modal>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-multichain/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# MetaMask SDK Multichain
# MetaMask Connect Multichain

The MetaMask SDK Multichain is a protocol-based, domain-driven SDK that enables seamless integration with MetaMask wallets across multiple blockchain networks and platforms.
The MetaMask Connect Multichain module is a protocol-based, domain-driven Connect that enables seamless integration with MetaMask wallets across multiple blockchain networks and platforms.

## Overview

The SDK provides a unified interface for dapps to connect with MetaMask Extension or Mobile wallets, regardless of the platform (browser, mobile, or Node.js) or blockchain protocol. It automatically handles connection flows, deeplinks, and QR codes based on the user's environment.
MetaMask Connect Multichain module provides a unified interface for dapps to connect with MetaMask Extension or Mobile wallets, regardless of the platform (browser, mobile, or Node.js) or blockchain protocol. It automatically handles connection flows, deeplinks, and QR codes based on the user's environment.

## Architecture

### Domain-Driven Design

The SDK follows a clean domain-driven architecture with clear separation of concerns:
MetaMask Connect Multichain module follows a clean domain-driven architecture with clear separation of concerns:

```
src/
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-multichain/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@metamask/multichain-sdk",
"version": "0.0.0",
"description": "Multichain package for MetaMask SDK",
"description": "Multichain package for MetaMask Connect",
"main": "dist/node/cjs/multichain-sdk.js",
"module": "dist/browser/es/multichain-sdk.mjs",
"browser": "dist/browser/es/multichain-sdk.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-multichain/src/domain/events/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { SessionData } from '@metamask/multichain-api-client';

export type SDKEvents = {
export type ConnectEvents = {
display_uri: [evt: string];
wallet_sessionChanged: [evt: SessionData | undefined];
[key: string]: [evt: unknown];
};

export type EventTypes = SDKEvents;
export type EventTypes = ConnectEvents;
6 changes: 3 additions & 3 deletions packages/sdk-multichain/src/domain/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Bowser from 'bowser';
import * as t from 'vitest';

import { createLogger, EventEmitter, enableDebug, getPlatformType, isEnabled, PlatformType, type SDKEvents } from './';
import { createLogger, EventEmitter, enableDebug, getPlatformType, isEnabled, PlatformType, type ConnectEvents } from './';

const parseMock = t.vi.fn();
// Mock Bowser at the top level
Expand Down Expand Up @@ -319,8 +319,8 @@ t.describe('Logger', () => {

t.describe('EventEmitter', () => {
t.describe('emit', () => {
t.describe('SDKEvents', () => {
let eventEmitter: EventEmitter<SDKEvents>;
t.describe('ConnectEvents', () => {
let eventEmitter: EventEmitter<ConnectEvents>;

t.beforeEach(() => {
eventEmitter = new EventEmitter();
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-multichain/src/domain/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import debug from 'debug';
import type { StoreClient } from '../store/client';

/**
* Supported debug namespace types for the MetaMask SDK logger.
* Supported debug namespace types for the MetaMask Connect Module logger.
* These namespaces help categorize and filter debug output.
*/
export type LoggerNameSpaces = 'metamask-sdk' | 'metamask-sdk:core' | 'metamask-sdk:provider' | 'metamask-sdk:ui' | 'metamask-sdk:transport';
export type LoggerNameSpaces = 'metamask-connect' | 'metamask-connect:core' | 'metamask-connect:provider' | 'metamask-connect:ui' | 'metamask-connect:transport';

/**
* Creates a debug logger instance with the specified namespace and color.
Expand Down Expand Up @@ -41,7 +41,7 @@ export const enableDebug = (namespace: LoggerNameSpaces = 'metamask-sdk') => {
*
* This function determines whether debug logging should be active for a namespace
* by checking if the debug value contains the namespace, a wildcard pattern, or
* the general MetaMask SDK wildcard.
* the general MetaMask Connect Module wildcard.
*
* @param debugValue - The debug configuration string (e.g., from environment or storage)
* @param namespace - The namespace to check for enablement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type EIP155 from './eip155';
/**
* Represents a blockchain scope identifier in CAIP format.
*
* Scopes define which blockchain networks and standards the SDK
* Scopes define which blockchain networks and standards the MetaMask Connect Module
* can interact with. The format follows CAIP standards for
* blockchain identification.
*
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk-multichain/src/domain/multichain/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { MultichainApiClient, SessionData, Transport } from '@metamask/multichain-api-client';
import type { CaipAccountId, Json } from '@metamask/utils';
import { EventEmitter, type SDKEvents } from '../events';
import { EventEmitter, type ConnectEvents } from '../events';
import type { StoreClient } from '../store/client';
import type { InvokeMethodOptions, RPCAPI, Scope } from './api/types';
import type { MultichainOptions } from './types';

export type SDKState = 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting';
export type ConnectState = 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting';

export enum TransportType {
Browser = 'browser',
Expand All @@ -14,14 +14,14 @@ export enum TransportType {
}

/**
* Abstract base class for the Multichain SDK implementation.
* Abstract base class for the MetaMask Connect Module implementation.
*
* This class defines the core interface that all Multichain SDK implementations
* This class defines the core interface that all MetaMask Connect Module implementations
* must provide, including session management, connection handling, and method invocation.
*/
export abstract class MultichainCore extends EventEmitter<SDKEvents> {
export abstract class MultichainCore extends EventEmitter<ConnectEvents> {
abstract storage: StoreClient;
abstract state: SDKState;
abstract state: ConnectState;
abstract provider: MultichainApiClient<RPCAPI>;
abstract transport: Transport;

Expand Down
20 changes: 10 additions & 10 deletions packages/sdk-multichain/src/domain/multichain/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { CaipAccountId } from '@metamask/utils';
export type { SessionData } from '@metamask/multichain-api-client';

/**
* Configuration settings for the dapp using the SDK.
* Configuration settings for the dapp using the MetaMask Connect Module.
*
* This type allows for two variants of dapp configuration:
* - Using a regular icon URL
Expand All @@ -25,15 +25,15 @@ export type ConnectionRequest = {
sessionRequest: SessionRequest;
metadata: {
dapp: DappSettings;
sdk: { version: string; platform: PlatformType };
connect: { version: string; platform: PlatformType };
};
};

/**
* Constructor options for creating a Multichain SDK instance.
* Constructor options for creating a MetaMask Connect Module instance.
*
* This type defines all the configuration options available when
* initializing the SDK, including dapp settings, API configuration,
* initializing the MetaMask Connect Module, including dapp settings, API configuration,
* analytics, storage, UI preferences, and transport options.
*/
export type MultichainOptions = {
Expand All @@ -48,7 +48,7 @@ export type MultichainOptions = {
};
/** Analytics configuration */
analytics?: { enabled: false } | { enabled: true; integrationType: string };
/** Storage client for persisting SDK data */
/** Storage client for persisting MetaMask Connect data */
storage: StoreClient;
/** UI configuration options */
ui: {
Expand All @@ -60,9 +60,9 @@ export type MultichainOptions = {
mobile?: {
preferredOpenLink?: (deeplink: string, target?: string) => void;
/**
* The `MetaMaskSDK` constructor option `useDeeplink: boolean` controls which type of link is used:
* - If `true`, the SDK will attempt to use the `metamask://` deeplink.
* - If `false` (the default for web), the SDK will use the `https://metamask.app.link` universal link.
* The `MetaMaskConnect` constructor option `useDeeplink: boolean` controls which type of link is used:
* - If `true`, the MetaMask Connect Module will attempt to use the `metamask://` deeplink.
* - If `false` (the default for web), the MetaMask Connect Module will use the `https://metamask.app.link` universal link.
*/
useDeeplink?: boolean;
};
Expand All @@ -81,10 +81,10 @@ type MultiChainFNOptions = Omit<MultichainOptions, 'storage' | 'ui'> & {
};

/**
* Complete options for Multichain SDK configuration.
* Complete options for MetaMask Connect Module configuration.
*
* This type extends the base options with storage configuration,
* providing all necessary options for SDK initialization.
* providing all necessary options for MetaMask Connect Module initialization.
*/
export type CreateMultichainFN = (options: MultiChainFNOptions) => Promise<MultichainCore>;

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-multichain/src/domain/ui/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ModalFactoryConnectOptions = {

/**
* Configuration options for the modal factory.
* Combines mobile settings from SDK options with UI preferences and connection handling.
* Combines mobile settings from MetaMask Connect Module options with UI preferences and connection handling.
*/
export type ModalFactoryOptions = Pick<MultichainOptions, 'mobile' | 'transport'> & {
ui: {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-multichain/src/index.browser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { CreateMultichainFN, StoreClient } from './domain';
import { MultichainSDK } from './multichain';
import { MultichainConnect } from './multichain';
import { Store } from './store';
import { ModalFactory } from './ui';

export * from './domain';

export const createMetamaskSDK: CreateMultichainFN = async (options) => {
export const createMetamaskConnect: CreateMultichainFN = async (options) => {
const uiModules = await import('./ui/modals/web');
let storage: StoreClient;
if (!options.storage) {
Expand All @@ -16,7 +16,7 @@ export const createMetamaskSDK: CreateMultichainFN = async (options) => {
storage = options.storage;
}
const factory = new ModalFactory(uiModules);
return MultichainSDK.create({
return MultichainConnect.create({
...options,
storage,
ui: {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-multichain/src/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { CreateMultichainFN, StoreClient } from './domain';
import { MultichainSDK } from './multichain';
import { MultichainConnect } from './multichain';
import { Store } from './store';
import { ModalFactory } from './ui';

export * from './domain';

export const createMetamaskSDK: CreateMultichainFN = async (options) => {
export const createMetamaskConnect: CreateMultichainFN = async (options) => {
const uiModules = await import('./ui/modals/rn');
let storage: StoreClient;
if (!options.storage) {
Expand All @@ -16,7 +16,7 @@ export const createMetamaskSDK: CreateMultichainFN = async (options) => {
storage = options.storage;
}
const factory = new ModalFactory(uiModules);
return MultichainSDK.create({
return MultichainConnect.create({
...options,
storage,
ui: {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-multichain/src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { CreateMultichainFN, StoreClient } from './domain';
import { MultichainSDK } from './multichain';
import { MultichainConnect } from './multichain';
import { Store } from './store';
import { ModalFactory } from './ui';

export * from './domain';

export const createMetamaskSDK: CreateMultichainFN = async (options) => {
export const createMetamaskConnect: CreateMultichainFN = async (options) => {
const uiModules = await import('./ui/modals/node');
let storage: StoreClient;
if (!options.storage) {
Expand All @@ -16,7 +16,7 @@ export const createMetamaskSDK: CreateMultichainFN = async (options) => {
storage = options.storage;
}
const factory = new ModalFactory(uiModules);
return MultichainSDK.create({
return MultichainConnect.create({
...options,
storage,
ui: {
Expand Down
Loading
Loading