Skip to content

Commit

Permalink
nodejs: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Apr 29, 2024
1 parent 9e0e4e3 commit f69965a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
10 changes: 5 additions & 5 deletions bindings/nodejs/lib/types/wallet/event.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import type { OutputWithExtendedMetadata } from './output';
import type { OutputData } from './output';
import { InclusionState } from './transaction';
import { InputSigningData, Remainder } from '../client';
import { Transaction, SignedTransactionPayload, TransactionId } from '../block';
Expand Down Expand Up @@ -57,7 +57,7 @@ class LedgerAddressGenerationWalletEvent extends WalletEvent {
* A 'new output' wallet event.
*/
class NewOutputWalletEvent extends WalletEvent {
output: OutputWithExtendedMetadata;
output: OutputData;
transaction?: SignedTransactionPayload;
transactionInputs?: OutputWithMetadata[];

Expand All @@ -67,7 +67,7 @@ class NewOutputWalletEvent extends WalletEvent {
* @param transactionInputs The inputs for the transaction that created the output. Might be pruned and not available.
*/
constructor(
output: OutputWithExtendedMetadata,
output: OutputData,
transaction?: SignedTransactionPayload,
transactionInputs?: OutputWithMetadata[],
) {
Expand All @@ -82,12 +82,12 @@ class NewOutputWalletEvent extends WalletEvent {
* A 'spent output' wallet event.
*/
class SpentOutputWalletEvent extends WalletEvent {
output: OutputWithExtendedMetadata;
output: OutputData;

/**
* @param output The spent output.
*/
constructor(output: OutputWithExtendedMetadata) {
constructor(output: OutputData) {
super(WalletEventType.SpentOutput);
this.output = output;
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/wallet/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum OutputsToClaim {
}

/** An output with extended metadata */
export class OutputWithExtendedMetadata {
export class OutputData {
/** The output itself */
@Type(() => Output, {
discriminator: OutputDiscriminator,
Expand Down
48 changes: 17 additions & 31 deletions bindings/nodejs/lib/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FilterOptions,
CreateNativeTokenParams,
MintNftParams,
OutputWithExtendedMetadata,
OutputData,
OutputParams,
OutputsToClaim,
TransactionWithMetadata,
Expand Down Expand Up @@ -303,15 +303,13 @@ export class Wallet {
*
* @returns The accounts of the wallet.
*/
async accounts(): Promise<OutputWithExtendedMetadata[]> {
async accounts(): Promise<OutputData[]> {
const response = await this.methodHandler.callMethod({
name: 'accounts',
});

const parsed = JSON.parse(response) as Response<
OutputWithExtendedMetadata[]
>;
return plainToInstance(OutputWithExtendedMetadata, parsed.payload);
const parsed = JSON.parse(response) as Response<OutputData[]>;
return plainToInstance(OutputData, parsed.payload);
}

/**
Expand Down Expand Up @@ -703,19 +701,17 @@ export class Wallet {
/**
* Get the data for an output.
* @param outputId The output to get.
* @returns The `OutputWithExtendedMetadata`.
* @returns The `OutputData`.
*/
async getOutput(outputId: OutputId): Promise<OutputWithExtendedMetadata> {
async getOutput(outputId: OutputId): Promise<OutputData> {
const response = await this.methodHandler.callMethod({
name: 'getOutput',
data: {
outputId,
},
});
const parsed = JSON.parse(
response,
) as Response<OutputWithExtendedMetadata>;
return plainToInstance(OutputWithExtendedMetadata, parsed.payload);
const parsed = JSON.parse(response) as Response<OutputData>;
return plainToInstance(OutputData, parsed.payload);
}

/**
Expand Down Expand Up @@ -877,18 +873,14 @@ export class Wallet {
* @param filterOptions Options to filter the to be returned outputs.
* @returns The outputs with metadata.
*/
async outputs(
filterOptions?: FilterOptions,
): Promise<OutputWithExtendedMetadata[]> {
async outputs(filterOptions?: FilterOptions): Promise<OutputData[]> {
const response = await this.methodHandler.callMethod({
name: 'outputs',
data: { filterOptions },
});

const parsed = JSON.parse(response) as Response<
OutputWithExtendedMetadata[]
>;
return plainToInstance(OutputWithExtendedMetadata, parsed.payload);
const parsed = JSON.parse(response) as Response<OutputData[]>;
return plainToInstance(OutputData, parsed.payload);
}

/**
Expand Down Expand Up @@ -959,15 +951,13 @@ export class Wallet {
*
* @returns The implicit accounts of the wallet.
*/
async implicitAccounts(): Promise<OutputWithExtendedMetadata[]> {
async implicitAccounts(): Promise<OutputData[]> {
const response = await this.methodHandler.callMethod({
name: 'implicitAccounts',
});

const parsed = JSON.parse(response) as Response<
OutputWithExtendedMetadata[]
>;
return plainToInstance(OutputWithExtendedMetadata, parsed.payload);
const parsed = JSON.parse(response) as Response<OutputData[]>;
return plainToInstance(OutputData, parsed.payload);
}

/**
Expand Down Expand Up @@ -1006,17 +996,13 @@ export class Wallet {
* @param filterOptions Options to filter the to be returned outputs.
* @returns The outputs with metadata.
*/
async unspentOutputs(
filterOptions?: FilterOptions,
): Promise<OutputWithExtendedMetadata[]> {
async unspentOutputs(filterOptions?: FilterOptions): Promise<OutputData[]> {
const response = await this.methodHandler.callMethod({
name: 'unspentOutputs',
data: { filterOptions },
});
const parsed = JSON.parse(response) as Response<
OutputWithExtendedMetadata[]
>;
return plainToInstance(OutputWithExtendedMetadata, parsed.payload);
const parsed = JSON.parse(response) as Response<OutputData[]>;
return plainToInstance(OutputData, parsed.payload);
}

/**
Expand Down

0 comments on commit f69965a

Please sign in to comment.