Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync sdk types #1211

Merged
merged 9 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nova-build-temp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
TARGET_COMMIT:
description: "Target Commit Hash for the SDK"
required: false
default: "772a5665afb7663b5ddb2c1e4780d03401fc7aa2"
default: "9578e0e98bc7293e9781c75cc45c8d01d326da32"
environment:
type: choice
description: "Select the environment to deploy to"
Expand Down
2 changes: 1 addition & 1 deletion api/src/initServices.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */
import { MqttClient as ChrysalisMqttClient } from "@iota/mqtt.js";
import { IClientOptions as IStardustClientOptions, Client as StardustClient } from "@iota/sdk";
import { IClientOptions as INovaClientOptions, Client as NovaClient } from "@iota/sdk-nova";
import { ClientOptions as INovaClientOptions, Client as NovaClient } from "@iota/sdk-nova";
import { ServiceFactory } from "./factories/serviceFactory";
import logger from "./logger";
import { IConfiguration } from "./models/configuration/IConfiguration";
Expand Down
4 changes: 2 additions & 2 deletions api/src/models/api/nova/IAccountDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "./IResponse";

export interface IAccountDetailsResponse extends IResponse {
/**
* The account details response.
*/
accountOutputDetails?: OutputResponse;
accountOutputDetails?: OutputWithMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/IAddressDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "./IResponse";

export interface IAddressDetailsResponse extends IResponse {
/**
* The outputs data.
*/
outputs?: OutputResponse[];
outputs?: OutputWithMetadataResponse[];
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/IAnchorDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "./IResponse";

export interface IAnchorDetailsResponse extends IResponse {
/**
* The anchor details response.
*/
anchorOutputDetails?: OutputResponse;
anchorOutputDetails?: OutputWithMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/IBlockDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable import/no-unresolved */
import { IBlockMetadata } from "@iota/sdk-nova";
import { BlockMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "../IResponse";

export interface IBlockDetailsResponse extends IResponse {
/**
* Block metadata.
*/
metadata?: IBlockMetadata;
metadata?: BlockMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/INftDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "./IResponse";

export interface INftDetailsResponse extends IResponse {
/**
* The nft output details response.
*/
nftOutputDetails?: OutputResponse;
nftOutputDetails?: OutputWithMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/INodeInfoResponse.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import { INodeInfo } from "@iota/sdk-nova";
import { InfoResponse } from "@iota/sdk-nova";
import { IResponse } from "../IResponse";

/**
* The response with node info for a specific network.
*/
export type INodeInfoResponse = INodeInfo & IResponse;
export type INodeInfoResponse = InfoResponse & IResponse;
4 changes: 2 additions & 2 deletions api/src/models/api/nova/IOutputDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "./IResponse";

export interface IOutputDetailsResponse extends IResponse {
/**
* The output data.
*/
output?: OutputResponse;
output?: OutputWithMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/ISearchResponse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { Block, OutputResponse } from "@iota/sdk-nova";
import { Block, OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IAddressDetails } from "./IAddressDetails";
import { IResponse } from "../IResponse";

Expand All @@ -18,7 +18,7 @@ export interface ISearchResponse extends IResponse {
/**
* Output if it was found (block will also be populated).
*/
output?: OutputResponse;
output?: OutputWithMetadataResponse;

/**
* Account id if it was found.
Expand Down
4 changes: 2 additions & 2 deletions api/src/models/api/nova/feed/IFeedUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import { Block, IBlockMetadata, SlotIndex } from "@iota/sdk-nova";
import { Block, BlockMetadataResponse, SlotIndex } from "@iota/sdk-nova";

interface IFeedBlockUpdate {
blockId: string;
Expand All @@ -10,6 +10,6 @@ interface IFeedBlockUpdate {
export interface IFeedUpdate {
subscriptionId: string;
blockUpdate?: IFeedBlockUpdate;
blockMetadataUpdate?: IBlockMetadata;
blockMetadataUpdate?: BlockMetadataResponse;
slotFinalized?: SlotIndex;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/foundry/IFoundriesResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { IOutputsResponse } from "@iota/sdk-nova";
import { OutputsResponse } from "@iota/sdk-nova";
import { IResponse } from "../IResponse";

export interface IFoundriesResponse extends IResponse {
/**
* The output ids response.
*/
foundryOutputsResponse?: IOutputsResponse;
foundryOutputsResponse?: OutputsResponse;
}
4 changes: 2 additions & 2 deletions api/src/models/api/nova/foundry/IFoundryResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { OutputResponse } from "@iota/sdk-nova";
import { OutputWithMetadataResponse } from "@iota/sdk-nova";
import { IResponse } from "../IResponse";

export interface IFoundryResponse extends IResponse {
/**
* The foundry details response.
*/
foundryDetails?: OutputResponse;
foundryDetails?: OutputWithMetadataResponse;
}
4 changes: 2 additions & 2 deletions api/src/services/nova/feed/novaFeed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Block, Client, IBlockMetadata, SlotCommitment } from "@iota/sdk-nova";
import { Block, Client, BlockMetadataResponse, SlotCommitment } from "@iota/sdk-nova";
import { ClassConstructor, plainToInstance } from "class-transformer";
import { ServiceFactory } from "../../../factories/serviceFactory";
import logger from "../../../logger";
Expand Down Expand Up @@ -117,7 +117,7 @@ export class NovaFeed {
void this._mqttClient.listenMqtt(["block-metadata/accepted", "block-metadata/confirmed"], async (_, message) => {
try {
const deserializedMessage: { topic: string; payload: string } = JSON.parse(message);
const blockMetadataUpdate: IBlockMetadata = JSON.parse(deserializedMessage.payload);
const blockMetadataUpdate: BlockMetadataResponse = JSON.parse(deserializedMessage.payload);

const update: Partial<IFeedUpdate> = {
blockMetadataUpdate,
Expand Down
12 changes: 6 additions & 6 deletions api/src/services/nova/nodeInfoService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-unresolved */
import { Client, INodeInfo } from "@iota/sdk-nova";
import { Client, InfoResponse } from "@iota/sdk-nova";
import { NodeInfoError } from "../../errors/nodeInfoError";
import { ServiceFactory } from "../../factories/serviceFactory";
import { INetwork } from "../../models/db/INetwork";
Expand All @@ -16,14 +16,14 @@ export class NodeInfoService {
/**
* The node and token info.
*/
protected _nodeInfo: INodeInfo;
protected _nodeInfo: InfoResponse;

/**
* Create a new instance of NodeInfoService.
* @param network The network config.
* @param nodeInfo The fetched node info
*/
private constructor(network: INetwork, nodeInfo: INodeInfo) {
private constructor(network: INetwork, nodeInfo: InfoResponse) {
this._network = network;
this._nodeInfo = nodeInfo;
}
Expand All @@ -32,14 +32,14 @@ export class NodeInfoService {
const apiClient = ServiceFactory.get<Client>(`client-${network.network}`);

try {
const response = await apiClient.getInfo();
return new NodeInfoService(network, response.nodeInfo);
const response = await apiClient.getNodeInfo();
return new NodeInfoService(network, response.info);
} catch (err) {
throw new NodeInfoError(`Failed to fetch node info for "${network.network}" with error:\n${err}`);
}
}

public getNodeInfo(): INodeInfo {
public getNodeInfo(): InfoResponse {
return this._nodeInfo;
}
}
12 changes: 6 additions & 6 deletions api/src/services/nova/novaApiService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Client, OutputResponse } from "@iota/sdk-nova";
import { Client, OutputWithMetadataResponse } from "@iota/sdk-nova";
import { ServiceFactory } from "../../factories/serviceFactory";
import logger from "../../logger";
import { IFoundriesResponse } from "../../models/api/nova/foundry/IFoundriesResponse";
Expand Down Expand Up @@ -120,7 +120,7 @@ export class NovaApiService {
*/
public async outputDetails(outputId: string): Promise<IOutputDetailsResponse> {
try {
const outputResponse = await this.client.getOutput(outputId);
const outputResponse = await this.client.getOutputWithMetadata(outputId);
return { output: outputResponse };
} catch (e) {
logger.error(`Failed fetching output with output id ${outputId}. Cause: ${e}`);
Expand Down Expand Up @@ -247,9 +247,9 @@ export class NovaApiService {
* @param outputIds The output ids to get the details.
* @returns The item details.
*/
public async outputsDetails(outputIds: string[]): Promise<OutputResponse[]> {
public async outputsDetails(outputIds: string[]): Promise<OutputWithMetadataResponse[]> {
const promises: Promise<IOutputDetailsResponse>[] = [];
const outputResponses: OutputResponse[] = [];
const outputResponses: OutputWithMetadataResponse[] = [];

for (const outputId of outputIds) {
const promise = this.outputDetails(outputId);
Expand Down Expand Up @@ -367,7 +367,7 @@ export class NovaApiService {
* @returns The mana rewards.
*/
public async getRewards(outputId: string): Promise<IRewardsResponse> {
const manaRewardsResponse = await this.client.getRewards(outputId);
const manaRewardsResponse = await this.client.getOutputManaRewards(outputId);

return manaRewardsResponse ? { outputId, manaRewards: manaRewardsResponse } : { outputId, message: "Rewards data not found" };
}
Expand All @@ -379,7 +379,7 @@ export class NovaApiService {
*/
public async getSlotCommitment(slotIndex: number): Promise<ISlotResponse> {
try {
const slot = await this.client.getCommitmentByIndex(slotIndex);
const slot = await this.client.getCommitmentBySlot(slotIndex);

return { slot };
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/nova/stats/novaStatsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export class NovaStatsService extends BaseStatsService {
protected async updateStatistics(): Promise<void> {
try {
const client = ServiceFactory.get<Client>(`client-${this._networkConfiguration.network}`);
const response = await client.getInfo();
const response = await client.getNodeInfo();

if (response) {
const metrics = response.nodeInfo.metrics;
const metrics = response.info.metrics;
this._statistics.push({
itemsPerSecond: Number(metrics.blocksPerSecond),
confirmedItemsPerSecond: Number(metrics.confirmedBlocksPerSecond),
Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/nova/associatedOutputsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import {
Client,
IOutputsResponse,
OutputsResponse,
AddressType,
BasicOutputQueryParameters,
AccountOutputQueryParameters,
Expand Down Expand Up @@ -260,7 +260,7 @@ export class AssociatedOutputsHelper {
* @param association The association we are looking for.
*/
private async fetchAssociatedOutputIds<T>(
fetch: (req: T) => Promise<IOutputsResponse | string>,
fetch: (req: T) => Promise<OutputsResponse | string>,
args: T,
association: AssociationType,
): Promise<void> {
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/AppUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ServiceFactory } from "~/factories/serviceFactory";
import { NodeInfoService as NodeInfoServiceNova } from "~services/nova/nodeInfoService";
import { useNetworkInfoNova } from "~/helpers/nova/networkInfo";
import { NavigationRoute } from "./lib/interfaces";
import { InfoResponse } from "@iota/sdk-wasm-nova/web";

export const networkContextWrapper = (currentNetwork: string | undefined, nodeInfo: IStardustNodeInfo | null, uiTheme: Theme | undefined) =>
function withNetworkContext(wrappedComponent: ReactNode) {
Expand Down Expand Up @@ -152,7 +153,7 @@ export const getFaviconHelmet = (isShimmer: boolean) => {
export const populateNetworkInfoNova = (networkName: string) => {
const nodeService = ServiceFactory.get<NodeInfoServiceNova>("node-info-nova");
if (nodeService) {
const nodeInfo = nodeService.get(networkName);
const nodeInfo: InfoResponse = nodeService.get(networkName);
const protocolInfo =
nodeInfo?.protocolParameters.reduce((params, cur) => {
return params.startEpoch > cur.startEpoch ? params : cur;
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/components/nova/OutputView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmoun
<div className="card--value row">{Number((output as DelegationOutput).delegatedAmount)}</div>
<div className="card--label">Delegation Id:</div>
<div className="card--value row">{(output as DelegationOutput).delegationId}</div>
<div className="card--label">Validator Id:</div>
<div className="card--value row">{(output as DelegationOutput).validatorId}</div>
<div className="card--label">Validator Address:</div>
<div className="card--value row">{Utils.addressToBech32((output as DelegationOutput).validatorAddress, bech32Hrp)}</div>
<div className="card--label">Start epoch:</div>
<div className="card--value row">{(output as DelegationOutput).startEpoch}</div>
<div className="card--label">End epoch:</div>
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/components/nova/address/AddressBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INodeInfoBaseToken } from "@iota/sdk-wasm-nova/web";
import { BaseTokenResponse } from "@iota/sdk-wasm-nova/web";
import React, { useState } from "react";
import { useNetworkInfoNova } from "~/helpers/nova/networkInfo";
import { IManaBalance } from "~/models/api/nova/address/IAddressBalanceResponse";
Expand Down Expand Up @@ -109,7 +109,7 @@ const AddressBalance: React.FC<AddressBalanceProps> = ({
);
};

function buildBaseTokenBalanceView(tokenInfo: INodeInfoBaseToken) {
function buildBaseTokenBalanceView(tokenInfo: BaseTokenResponse) {
const baseTokenBalanceView = (
label: string,
isFormatFull: boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { OutputType, OutputResponse, CommonOutput, NativeToken, FeatureType, NativeTokenFeature } from "@iota/sdk-wasm-nova/web";
import {
OutputType,
OutputWithMetadataResponse,
CommonOutput,
NativeToken,
FeatureType,
NativeTokenFeature,
} from "@iota/sdk-wasm-nova/web";
import React, { useEffect, useState } from "react";
import Asset from "./Asset";
import Pagination from "~/app/components/Pagination";
import { plainToInstance } from "class-transformer";
import "./AssetsTable.scss";

interface AssetsTableProps {
readonly outputs: OutputResponse[] | null;
readonly outputs: OutputWithMetadataResponse[] | null;
readonly setTokensCount?: (count: number) => void;
}

Expand Down
Loading
Loading