-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Native tokens Tab to address pages (#1119)
* feat: add output tab to address page * fix: add components to display native tokens * Remove unused code in AddressPageTabbedSections component * remove unused interfaces * Update address states and Add basic outputs API endpoint * Add eslint-disable for unsafe return in novaApiService.ts * Add Foundries tab to Accound address page (#1134) * fix: validation check in foundries endpoint * fix: component imports * fix: imports * fix: select first tab on address page --------- Co-authored-by: Mario <[email protected]>
- Loading branch information
Showing
38 changed files
with
1,105 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface IAddressDetailsRequest { | ||
/** | ||
* The network to search on. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The bech32 address to get the basic output ids for. | ||
*/ | ||
address: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument */ | ||
import { OutputResponse } from "@iota/sdk-nova"; | ||
import { IResponse } from "./IResponse"; | ||
|
||
export interface IAddressDetailsResponse extends IResponse { | ||
/** | ||
* The outputs data. | ||
*/ | ||
outputs?: OutputResponse[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface IFoundriesRequest { | ||
/** | ||
* The network to search on. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The bech32 account address to get the foundy output ids for. | ||
*/ | ||
accountAddress: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument */ | ||
import { IOutputsResponse } from "@iota/sdk-nova"; | ||
import { IResponse } from "../IResponse"; | ||
|
||
export interface IFoundriesResponse extends IResponse { | ||
/** | ||
* The output ids response. | ||
*/ | ||
foundryOutputsResponse?: IOutputsResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface IFoundryRequest { | ||
/** | ||
* The network to search on. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The foundry id to get the foundry details for. | ||
*/ | ||
foundryId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument */ | ||
import { OutputResponse } from "@iota/sdk-nova"; | ||
import { IResponse } from "../IResponse"; | ||
|
||
export interface IFoundryResponse extends IResponse { | ||
/** | ||
* The foundry details response. | ||
*/ | ||
foundryDetails?: OutputResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ServiceFactory } from "../../../../factories/serviceFactory"; | ||
import { IFoundriesRequest } from "../../../../models/api/nova/foundry/IFoundriesRequest"; | ||
import { IFoundriesResponse } from "../../../../models/api/nova/foundry/IFoundriesResponse"; | ||
import { IConfiguration } from "../../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../../services/networkService"; | ||
import { NovaApiService } from "../../../../services/nova/novaApiService"; | ||
import { ValidationHelper } from "../../../../utils/validationHelper"; | ||
|
||
/** | ||
* Get controlled Foundry output id by controller Account address | ||
* @param config The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(config: IConfiguration, request: IFoundriesRequest): Promise<IFoundriesResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
ValidationHelper.string(request.accountAddress, "accountAddress"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
const novaApiService = ServiceFactory.get<NovaApiService>(`api-service-${networkConfig.network}`); | ||
return novaApiService.accountFoundries(request.accountAddress); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ServiceFactory } from "../../../../../factories/serviceFactory"; | ||
import { IAddressDetailsRequest } from "../../../../../models/api/nova/IAddressDetailsRequest"; | ||
import { IAddressDetailsResponse } from "../../../../../models/api/nova/IAddressDetailsResponse"; | ||
import { IConfiguration } from "../../../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../../../services/networkService"; | ||
import { NovaApiService } from "../../../../../services/nova/novaApiService"; | ||
import { ValidationHelper } from "../../../../../utils/validationHelper"; | ||
|
||
/** | ||
* Fetch the basic output details by address. | ||
* @param config The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(config: IConfiguration, request: IAddressDetailsRequest): Promise<IAddressDetailsResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
const novaApiService = ServiceFactory.get<NovaApiService>(`api-service-${networkConfig.network}`); | ||
return novaApiService.basicOutputDetailsByAddress(request.address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ServiceFactory } from "../../../factories/serviceFactory"; | ||
import { IFoundryRequest } from "../../../models/api/nova/foundry/IFoundryRequest"; | ||
import { IFoundryResponse } from "../../../models/api/nova/foundry/IFoundryResponse"; | ||
import { IConfiguration } from "../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../services/networkService"; | ||
import { NovaApiService } from "../../../services/nova/novaApiService"; | ||
import { ValidationHelper } from "../../../utils/validationHelper"; | ||
|
||
/** | ||
* Get foundry output details by Foundry id. | ||
* @param config The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(config: IConfiguration, request: IFoundryRequest): Promise<IFoundryResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
ValidationHelper.string(request.foundryId, "foundryId"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
const novaApiService = ServiceFactory.get<NovaApiService>(`api-service-${networkConfig.network}`); | ||
return novaApiService.foundryDetails(request.foundryId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.