@airmoney-degn/controller-sdk
v7.7.0
Published
SDK for controlling AirMoney devices, providing button screen management, key event handling, and device communication capabilities
Downloads
287
Readme
AirMoney Controller SDK
A TypeScript SDK for interacting with AirMoney device. This SDK provides core functionality to control device screens, handle key events, and perform cryptographic operations.
Development
Prerequisites for Development
Before developing with this SDK, make sure you have the following installed:
- Node.js (v18 or higher)
- Yarn package manager
Development Workflow
Clone and Install Dependencies
git clone <repository-url> cd controller-sdk yarn installStart Development Mode
yarn devThis command will build the SDK and provide instructions for local testing.
Make Changes and Test
- Make your changes to the SDK source code
- Run
yarn devagain to rebuild the package - Test your changes in your consuming project
Available Scripts
yarn dev- Build the SDK for developmentyarn build- Build the SDK for productionyarn preview- Preview the built SDK locallyyarn lint- Run ESLint to check code qualityyarn check-types- Run TypeScript type checkingyarn changeset- Create a changeset for version managementyarn version- Apply changesets and update versionyarn release- Build and publish to npm registry
Code Quality
The project uses:
- ESLint for code linting with AirMoney's custom configuration
- Prettier for code formatting
- TypeScript for type safety
- Changesets for version management
Run linting and type checking:
yarn lint
yarn check-typesPreview
To preview the built SDK locally:
yarn previewThis will start a local preview server where you can test the built SDK.
Release
Version Management
This project uses Changesets for version management.
Creating a Release
Create a Changeset
yarn changesetThis will prompt you to:
- Select which packages to include
- Choose the type of change (patch, minor, major)
- Write a summary of the changes
Apply Changesets and Update Version
yarn versionThis will:
- Apply all pending changesets
- Update package versions
- Update CHANGELOG.md
Build and Publish
yarn releaseThis will:
- Build the SDK
- Publish to npm registry
Release Process
- Make your changes and commit them
- Create a changeset describing your changes
- Run
yarn versionto update versions - Run
yarn releaseto publish - Push changes and tags to the repository
API Reference
AirMoneyService
Constructor
new AirMoneyService(options?: { [key in Methods]?: Options<key> })Methods
setImage
setImage(params: { id: 'left' | 'right', imageName: string }): Promise<AMServiceScreenResponse>Displays a static image on the specified screen. Supports throttling configuration.
setAnimate
setAnimate(params: { id: 'left' | 'right', imageName: string }): Promise<AMServiceScreenResponse>Displays an animated GIF on the specified screen. Supports throttling configuration.
initialize
initialize(): Promise<void>Initializes the service by loading the app name from metadata.json or window.AIRMONEY_APP_ID.
AirMoneyKeyEvent
Constructor
new AirMoneyKeyEvent(config?: Partial<AMKeyEventConfig>)Configuration Options
interface AMKeyEventConfig {
threshold: number; // milliseconds for long press detection
combinations?: Record<string, AMKey[]>; // key combinations
doubleClicks?: Record<string, AMKey>; // double click keys
debug?: boolean; // enable debug logging
}Methods
on
on(callback: AMKeyEventCallback): voidRegisters a callback for key events.
off
off(): voidRemoves all event listeners and callbacks.
updateConfig
updateConfig(config?: Partial<AMKeyEventConfig>): voidUpdates the configuration of the key event handler.
AirMoneyKeyEventManager
Constructor
new AirMoneyKeyEventManager(config: { instance: AirMoneyKeyEvent, debug?: boolean })Methods
subscribe
subscribe(config: AMKeyEventTriggerGroupConfig): stringRegisters a group of triggers with a config object. Returns a unique listener ID.
unsubscribe
unsubscribe(listenerId: string): booleanUnsubscribe from key events by group ID. Returns true if successfully unsubscribed.
unsubscribeAll
unsubscribeAll(): voidUnsubscribe from all key events.
getKeyEventInstance
getKeyEventInstance(): AirMoneyKeyEventReturns the underlying AirMoneyKeyEvent instance.
updateConfig
updateConfig(config: Partial<AMKeyEventConfig>): voidUpdates the configuration of the AirMoneyKeyEvent instance.
destroy
destroy(): voidUnsubscribes all listeners and cleans up the manager and AirMoneyKeyEvent instance.
AirMoneyCryptoService
Constructor
new AirMoneyCryptoService()EVM Methods
getDefaultEvmWallet
getDefaultEvmWallet(): Promise<AMCryptoServiceGetDefaultEvmWalletResponse>Gets the default EVM wallet address.
signEvmMessage
signEvmMessage(params: { address: string, message: string }): Promise<AMCryptoServiceEvmMessageResponse>Signs a message with the specified EVM wallet.
signEvmTransaction
signEvmTransaction(params: { address: string, transaction: EVMTransaction, chainId: string }): Promise<AMCryptoServiceEvmTransactionResponse>Signs an EVM transaction.
signGeneralEvmTransaction
signGeneralEvmTransaction(params: { address: string, transaction: EVMTransaction, chainId: string }): Promise<AMCryptoServiceEvmTransactionResponse>Signs a general EVM transaction.
signEip712TypedData
signEip712TypedData(params: { address: string, domain: object, types: object, primaryType: string, message: object }): Promise<AMCryptoServiceEip712TypedDataResponse>Signs EIP-712 typed data.
verifyEip1271Signature
verifyEip1271Signature(params: { address: string, message: string, signature: string }): Promise<AMCryptoServiceVerifyEip1271SignatureResponse>Verifies an EIP-1271 signature.
signEVMRawTransaction
signEVMRawTransaction(params: { address: string, rawTransaction: RawEVMTransaction, chainId: string | number }): Promise<AMCryptoServiceEvmTransactionResponse>Signs a raw EVM transaction.
Solana Methods
getDefaultSvmWallet
getDefaultSvmWallet(): Promise<AMCryptoServiceGetDefaultSvmWalletResponse>Gets the default Solana wallet address.
signSolanaMessage
signSolanaMessage(params: { address: string, message: string }): Promise<AMCryptoServiceSolanaMessageResponse>Signs a message with the specified Solana wallet.
signSolanaTransaction
signSolanaTransaction(params: { address: string, transaction_base64: string }): Promise<AMCryptoServiceSolanaTransactionResponse>Signs a Solana transaction.
Bitcoin Methods
getDefaultBitcoinWallet
getDefaultBitcoinWallet(): Promise<AMCryptoServiceGetDefaultBitcoinWalletResponse>Gets the default Bitcoin wallet address.
signBitcoinMessage
signBitcoinMessage(params: { address: string, message: string }): Promise<AMCryptoServiceBitcoinMessageResponse>Signs a Bitcoin message.
verifyBitcoinSignature
verifyBitcoinSignature(params: { address: string, message: string, signature: string }): Promise<AMCryptoServiceVerifyBitcoinSignatureResponse>Verifies a Bitcoin signature.
signBitcoinTransaction
signBitcoinTransaction(params: { address: string, transaction: string }): Promise<AMCryptoServiceBitcoinTransactionResponse>Signs a Bitcoin transaction.
Utility Functions
Navigation Functions
backToHome
backToHome(): voidNavigates back to the home page.
goToApp
goToApp(appName?: string): voidNavigates to a specific app.
getAppLink
getAppLink(appName?: string): stringGets the link for an app.
displayAsset
displayAsset(appName?: string, path?: string): stringGets the display URL for an asset.
getAppLogo
getAppLogo(appName?: string): stringGets the logo URL for an app.
Transaction Functions
normalizeEVMTransaction
normalizeEVMTransaction(obj: RawEVMTransaction): EVMTransactionNormalizes an EVM transaction object.
toHexString
toHexString(obj: bigint | number | string): HexStringConverts a value to a hex string.
License
MIT © AirMoney
