rewards-frontend-package / AddAllocationsComponent / AddAllocationsComponent
Class: AddAllocationsComponent
Defined in: src/AddAllocationsComponent.ts:17
Component for managing and adding reward allocations to multiple addresses.
This component handles the UI and logic for adding allocations to various addresses with corresponding amounts. It integrates with the RewardsClient to fetch data and submit transactions to the blockchain.
Example
const addAllocationsComponent = new AddAllocationsComponent(rewardsClient, walletManager)
addAllocationsComponent.bind(document.getElementById('add-allocations-container'))
Constructors
Constructor
new AddAllocationsComponent(
rewardsClient,walletManager):AddAllocationsComponent
Defined in: src/AddAllocationsComponent.ts:31
Creates an instance of AddAllocationsComponent.
Parameters
rewardsClient
The client for interacting with rewards contract and API
walletManager
WalletManager
The wallet manager for account and network state
Returns
AddAllocationsComponent
Properties
addresses
privateaddresses:string[] =[]
Defined in: src/AddAllocationsComponent.ts:21
amounts
privateamounts:number[] =[]
Defined in: src/AddAllocationsComponent.ts:22
decimals
privatedecimals:number=6
Defined in: src/AddAllocationsComponent.ts:23
element
privateelement:HTMLElement|null=null
Defined in: src/AddAllocationsComponent.ts:18
rewardsClient
privaterewardsClient:RewardsClient
Defined in: src/AddAllocationsComponent.ts:19
walletManager
privatewalletManager:WalletManager
Defined in: src/AddAllocationsComponent.ts:20
Methods
addEventListeners()
privateaddEventListeners():void
Defined in: src/AddAllocationsComponent.ts:114
Adds event listeners for user interactions.
Listens for click events on the add allocations button and updates internal state from textarea inputs before submission.
Returns
void
bind()
bind(
element):void
Defined in: src/AddAllocationsComponent.ts:42
Binds the component to a DOM element and initializes event listeners.
Parameters
element
HTMLElement
The HTML element to bind the component to
Returns
void
destroy()
destroy():
void
Defined in: src/AddAllocationsComponent.ts:130
Cleans up the component.
Currently no specific cleanup needed, but provided for interface consistency.
Returns
void
fetchAllocationsData()
privatefetchAllocationsData():Promise<void>
Defined in: src/AddAllocationsComponent.ts:61
Fetches allocation data from the backend API for the active account.
Updates the internal state with addresses and amounts, then re-renders the UI. Handles errors by displaying alerts to the user.
Returns
Promise<void>
handleAddAllocations()
privatehandleAddAllocations():Promise<void>
Defined in: src/AddAllocationsComponent.ts:91
Handles the add allocations transaction submission.
Sends the current addresses and amounts to the blockchain via RewardsClient. Displays success/error messages and refreshes data on success.
Returns
Promise<void>