diff --git a/src/networkProviders/accounts.ts b/src/networkProviders/accounts.ts index cee89aea..673487e0 100644 --- a/src/networkProviders/accounts.ts +++ b/src/networkProviders/accounts.ts @@ -1,12 +1,11 @@ import BigNumber from "bignumber.js"; import { Address } from "../address"; -import { IAddress } from "./interface"; /** * A plain view of an account, as queried from the Network. */ export class AccountOnNetwork { - address: IAddress = Address.empty(); + address: Address = Address.empty(); nonce: number = 0; balance: BigNumber = new BigNumber(0); code: string = ""; @@ -54,7 +53,7 @@ export class GuardianData { return result; } - getCurrentGuardianAddress(): IAddress | undefined { + getCurrentGuardianAddress(): Address | undefined { if (!this.guarded) { return undefined; } @@ -65,7 +64,7 @@ export class GuardianData { class Guardian { activationEpoch: number = 0; - address: IAddress = Address.empty(); + address: Address = Address.empty(); serviceUID: string = ""; static fromHttpResponse(responsePart: any): Guardian { diff --git a/src/networkProviders/apiNetworkProvider.ts b/src/networkProviders/apiNetworkProvider.ts index 7b2bd6a4..3d478476 100644 --- a/src/networkProviders/apiNetworkProvider.ts +++ b/src/networkProviders/apiNetworkProvider.ts @@ -1,3 +1,4 @@ +import { Address } from "../address"; import { ErrContractQuery, ErrNetworkProvider } from "../errors"; import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; import { Transaction } from "../transaction"; @@ -9,7 +10,7 @@ import { AccountOnNetwork, GuardianData } from "./accounts"; import { defaultAxiosConfig, defaultPagination } from "./config"; import { BaseUserAgent } from "./constants"; import { ContractQueryRequest } from "./contractQueryRequest"; -import { IAddress, INetworkProvider, IPagination } from "./interface"; +import { INetworkProvider, IPagination } from "./interface"; import { NetworkConfig } from "./networkConfig"; import { NetworkGeneralStatistics } from "./networkGeneralStatistics"; import { NetworkProviderConfig } from "./networkProviderConfig"; @@ -64,18 +65,18 @@ export class ApiNetworkProvider implements INetworkProvider { return stats; } - async getAccount(address: IAddress): Promise { + async getAccount(address: Address): Promise { const response = await this.doGetGeneric(`accounts/${address.bech32()}`); const account = AccountOnNetwork.fromHttpResponse(response); return account; } - async getGuardianData(address: IAddress): Promise { + async getGuardianData(address: Address): Promise { return await this.backingProxyNetworkProvider.getGuardianData(address); } async getFungibleTokensOfAccount( - address: IAddress, + address: Address, pagination?: IPagination, ): Promise { pagination = pagination || defaultPagination; @@ -90,7 +91,7 @@ export class ApiNetworkProvider implements INetworkProvider { } async getNonFungibleTokensOfAccount( - address: IAddress, + address: Address, pagination?: IPagination, ): Promise { pagination = pagination || defaultPagination; @@ -105,7 +106,7 @@ export class ApiNetworkProvider implements INetworkProvider { } async getFungibleTokenOfAccount( - address: IAddress, + address: Address, tokenIdentifier: string, ): Promise { const response = await this.doGetGeneric(`accounts/${address.bech32()}/tokens/${tokenIdentifier}`); @@ -114,7 +115,7 @@ export class ApiNetworkProvider implements INetworkProvider { } async getNonFungibleTokenOfAccount( - address: IAddress, + address: Address, collection: string, nonce: number, ): Promise { diff --git a/src/networkProviders/interface.ts b/src/networkProviders/interface.ts index 2ddd3b5b..773f2613 100644 --- a/src/networkProviders/interface.ts +++ b/src/networkProviders/interface.ts @@ -1,3 +1,4 @@ +import { Address } from "../address"; import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; import { Transaction } from "../transaction"; import { TransactionOnNetwork } from "../transactionOnNetwork"; @@ -37,31 +38,31 @@ export interface INetworkProvider { /** * Fetches the state of an account. */ - getAccount(address: IAddress): Promise; + getAccount(address: Address): Promise; /** * Fetches data about the fungible tokens held by an account. */ - getFungibleTokensOfAccount(address: IAddress, pagination?: IPagination): Promise; + getFungibleTokensOfAccount(address: Address, pagination?: IPagination): Promise; /** * Fetches data about the non-fungible tokens held by account. */ getNonFungibleTokensOfAccount( - address: IAddress, + address: Address, pagination?: IPagination, ): Promise; /** * Fetches data about a specific fungible token held by an account. */ - getFungibleTokenOfAccount(address: IAddress, tokenIdentifier: string): Promise; + getFungibleTokenOfAccount(address: Address, tokenIdentifier: string): Promise; /** * Fetches data about a specific non-fungible token (instance) held by an account. */ getNonFungibleTokenOfAccount( - address: IAddress, + address: Address, collection: string, nonce: number, ): Promise; @@ -124,8 +125,8 @@ export interface INetworkProvider { } export interface IContractQuery { - address: IAddress; - caller?: IAddress; + address: Address; + caller?: Address; func: { toString(): string }; value?: { toString(): string }; getEncodedArguments(): string[]; @@ -135,7 +136,3 @@ export interface IPagination { from: number; size: number; } - -export interface IAddress { - bech32(): string; -} diff --git a/src/networkProviders/pairs.ts b/src/networkProviders/pairs.ts index 31a92bf1..b54d10ce 100644 --- a/src/networkProviders/pairs.ts +++ b/src/networkProviders/pairs.ts @@ -1,9 +1,8 @@ import BigNumber from "bignumber.js"; import { Address } from "../address"; -import { IAddress } from "./interface"; export class PairOnNetwork { - address: IAddress = Address.empty(); + address: Address = Address.empty(); id: string = ""; symbol: string = ""; name: string = ""; diff --git a/src/networkProviders/proxyNetworkProvider.ts b/src/networkProviders/proxyNetworkProvider.ts index 056f02c8..f54ea831 100644 --- a/src/networkProviders/proxyNetworkProvider.ts +++ b/src/networkProviders/proxyNetworkProvider.ts @@ -10,7 +10,7 @@ import { AccountOnNetwork, GuardianData } from "./accounts"; import { defaultAxiosConfig } from "./config"; import { BaseUserAgent } from "./constants"; import { ContractQueryRequest } from "./contractQueryRequest"; -import { IAddress, INetworkProvider, IPagination } from "./interface"; +import { INetworkProvider, IPagination } from "./interface"; import { NetworkConfig } from "./networkConfig"; import { NetworkGeneralStatistics } from "./networkGeneralStatistics"; import { NetworkProviderConfig } from "./networkProviderConfig"; @@ -58,20 +58,20 @@ export class ProxyNetworkProvider implements INetworkProvider { throw new Error("Method not implemented."); } - async getAccount(address: IAddress): Promise { + async getAccount(address: Address): Promise { const response = await this.doGetGeneric(`address/${address.bech32()}`); const account = AccountOnNetwork.fromHttpResponse(response.account); return account; } - async getGuardianData(address: IAddress): Promise { + async getGuardianData(address: Address): Promise { const response = await this.doGetGeneric(`address/${address.bech32()}/guardian-data`); const accountGuardian = GuardianData.fromHttpResponse(response.guardianData); return accountGuardian; } async getFungibleTokensOfAccount( - address: IAddress, + address: Address, _pagination?: IPagination, ): Promise { const url = `address/${address.bech32()}/esdt`; @@ -87,7 +87,7 @@ export class ProxyNetworkProvider implements INetworkProvider { } async getNonFungibleTokensOfAccount( - address: IAddress, + address: Address, _pagination?: IPagination, ): Promise { const url = `address/${address.bech32()}/esdt`; @@ -105,7 +105,7 @@ export class ProxyNetworkProvider implements INetworkProvider { } async getFungibleTokenOfAccount( - address: IAddress, + address: Address, tokenIdentifier: string, ): Promise { const response = await this.doGetGeneric(`address/${address.bech32()}/esdt/${tokenIdentifier}`); @@ -114,7 +114,7 @@ export class ProxyNetworkProvider implements INetworkProvider { } async getNonFungibleTokenOfAccount( - address: IAddress, + address: Address, collection: string, nonce: number, ): Promise { diff --git a/src/networkProviders/tokenDefinitions.ts b/src/networkProviders/tokenDefinitions.ts index fbaccf2a..31f04ec5 100644 --- a/src/networkProviders/tokenDefinitions.ts +++ b/src/networkProviders/tokenDefinitions.ts @@ -1,12 +1,11 @@ import BigNumber from "bignumber.js"; import { Address } from "../address"; -import { IAddress } from "./interface"; export class DefinitionOfFungibleTokenOnNetwork { identifier: string = ""; name: string = ""; ticker: string = ""; - owner: IAddress = Address.empty(); + owner: Address = Address.empty(); decimals: number = 0; supply: BigNumber = new BigNumber(0); isPaused: boolean = false; @@ -76,7 +75,7 @@ export class DefinitionOfTokenCollectionOnNetwork { type: string = ""; name: string = ""; ticker: string = ""; - owner: IAddress = Address.empty(); + owner: Address = Address.empty(); decimals: number = 0; canPause: boolean = false; canFreeze: boolean = false; diff --git a/src/networkProviders/tokens.ts b/src/networkProviders/tokens.ts index 1c838f07..04f0d49f 100644 --- a/src/networkProviders/tokens.ts +++ b/src/networkProviders/tokens.ts @@ -1,7 +1,6 @@ import { BigNumber } from "bignumber.js"; import { Address } from "../address"; import { numberToPaddedHex } from "../utils.codec"; -import { IAddress } from "./interface"; export class FungibleTokenOfAccountOnNetwork { identifier: string = ""; @@ -27,7 +26,7 @@ export class NonFungibleTokenOfAccountOnNetwork { nonce: number = 0; type: string = ""; name: string = ""; - creator: IAddress = Address.empty(); + creator: Address = Address.empty(); supply: BigNumber = new BigNumber(0); decimals: number = 0; royalties: BigNumber = new BigNumber(0); diff --git a/src/networkProviders/transactionReceipt.ts b/src/networkProviders/transactionReceipt.ts index 49d14d62..10947b2e 100644 --- a/src/networkProviders/transactionReceipt.ts +++ b/src/networkProviders/transactionReceipt.ts @@ -1,9 +1,8 @@ import { Address } from "../address"; -import { IAddress } from "./interface"; export class TransactionReceipt { value: string = ""; - sender: IAddress = Address.empty(); + sender: Address = Address.empty(); data: string = ""; hash: string = ""; diff --git a/src/testutils/mockNetworkProvider.ts b/src/testutils/mockNetworkProvider.ts index 053b7754..6d61df27 100644 --- a/src/testutils/mockNetworkProvider.ts +++ b/src/testutils/mockNetworkProvider.ts @@ -14,7 +14,7 @@ import { NetworkStatus, NonFungibleTokenOfAccountOnNetwork, } from "../networkProviders"; -import { IAddress, INetworkProvider, IPagination } from "../networkProviders/interface"; +import { INetworkProvider, IPagination } from "../networkProviders/interface"; import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; import { Transaction, TransactionHash } from "../transaction"; import { TransactionOnNetwork } from "../transactionOnNetwork"; @@ -66,22 +66,22 @@ export class MockNetworkProvider implements INetworkProvider { throw new Error("Method not implemented."); } getFungibleTokensOfAccount( - _address: IAddress, + _address: Address, _pagination?: IPagination, ): Promise { throw new Error("Method not implemented."); } getNonFungibleTokensOfAccount( - _address: IAddress, + _address: Address, _pagination?: IPagination, ): Promise { throw new Error("Method not implemented."); } - getFungibleTokenOfAccount(_address: IAddress, _tokenIdentifier: string): Promise { + getFungibleTokenOfAccount(_address: Address, _tokenIdentifier: string): Promise { throw new Error("Method not implemented."); } getNonFungibleTokenOfAccount( - _address: IAddress, + _address: Address, _collection: string, _nonce: number, ): Promise {