0.30.0 • Published 8 months ago

@metamask/sdk-communication-layer v0.30.0

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

MetaMask SDK Communication Layer

Installation

yarn add @metamask/sdk-communication-layer

Using

Dapp

RemoteCommunication = new RemoteCommunicationLib({
      commLayer: 'socket'
    });

    const { channelId, pubKey } = RemoteCommunication.generateChannelId();

    const linkParams = `channelId=${encodeURIComponent(
      channelId,
    )}&comm=${encodeURIComponent(
      'socket'
    )}&pubkey=${encodeURIComponent(pubKey)}`;

    console.log("Connect to", linkParams)

    RemoteCommunication.on('message', (message) => {
      console.log("New Message", message)
    })

    RemoteCommunication.on('clients_ready', (message) => {
      console.log("Clients now connected!")
    })

MetaMask

const url = new URL(this.state.urlToConnect);

    // https://metamask.app.link/connect?channelId=4cddce59-c4ea-4c70-9dbf-d1ddbe8f7a9f&comm=socket&pubkey=BCCKuS6Z26iZkxA1oB69X9DN73dlCYEQa46d0id8MCXdshRHGqI4rVuIeXjMS2vrlq7PkD4nbzb7gEFn%2FJfHz4E%3D
    console.log(url.searchParams);

    const otherPublicKey = url.searchParams.get('pubkey');
    const channelId = url.searchParams.get('channelId');
    console.log('otherPublicKey', otherPublicKey);
    console.log('channelId', channelId);

    RemoteCommunication = new RemoteCommunicationLib({
      commLayer: 'socket',
      otherPublicKey,
    });

    RemoteCommunication.connectToChannel(channelId);

    RemoteCommunication.on('clients_ready', () => {
      this.setState({ connected: true });
    });

    RemoteCommunication.on('message', (message) => {
      console.log("New message", message);
    });
0.30.0

8 months ago

0.29.0

8 months ago

0.29.2

8 months ago

0.29.1

8 months ago

0.27.0

11 months ago

0.29.0-wallet

9 months ago

0.28.1

10 months ago

0.28.0

10 months ago

0.26.2

12 months ago

0.26.0

12 months ago

0.20.5

1 year ago

0.20.4

1 year ago

0.28.2

10 months ago

0.26.4

12 months ago

0.20.2

1 year ago

0.19.0

1 year ago

0.18.5

1 year ago

0.18.4

1 year ago

0.18.2

1 year ago

0.18.1

1 year ago

0.18.0

1 year ago

0.17.0

1 year ago

0.16.0

1 year ago

0.15.0

1 year ago

0.14.3

1 year ago

0.14.2

1 year ago

0.11.0

2 years ago

0.10.1

2 years ago

0.12.0

2 years ago

0.11.1

2 years ago

0.13.0

2 years ago

0.12.1

2 years ago

0.14.0

2 years ago

0.12.2

2 years ago

0.14.1

2 years ago

0.12.3

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.6.2

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.5.2

2 years ago

0.6.0

2 years ago

0.4.2

2 years ago

0.3.3

2 years ago

0.3.0

2 years ago

0.3.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.0

3 years ago

0.0.1-beta.4

3 years ago

0.0.1-beta.3

3 years ago

0.0.1-beta.2

3 years ago