Core concepts
Connection lifecycle
How WalletBridgeClient picks a connection, connects with init() and releases it with destroy().
WalletBridgeClient is the central class. You give it an appCenterOrigin (or your own transport), then call init().
import { WalletBridgeClient } from '@hydraone-sdk/core';
const client = new WalletBridgeClient({
appCenterOrigin: 'https://alpha.hydraone.app',
});
await client.init();
How the connection is chosen
| Where the game runs | What init() does |
|---|---|
| Inside an iframe (embedded in the App Center) | Sends CLIENT_READY over the transport and waits for the host to acknowledge it. A transport (or appCenterOrigin) is required. |
| Outside an iframe | Rejects with ERR_NOT_IN_IFRAME, because there is no host shell to connect to. |
init() is safe to call more than once. It resolves immediately when the client is already connected and shares one in-flight handshake.Connection state
Read the state at any time:
client.connectionState:'disconnected' | 'connecting' | 'connected' | 'error'client.isConnectedclient.hostInfo: what the host reported during the handshake
The React hooks and Vue composables expose the same state as reactive values.
Releasing the client
Call client.destroy() when the game shuts down. It removes listeners, cancels pending timers and releases the transport. A transport the client created from appCenterOrigin is destroyed with it; a transport you passed in is yours to manage.
Next steps
- Wallet operations to read balances and sign transactions.
- Message protocol for what
CLIENT_READYandHOST_ACKlook like on the wire.
