diff --git a/packages/core/src/composeAPI.ts b/packages/core/src/composeAPI.ts index 875aa6f5b..afd2f9f4d 100644 --- a/packages/core/src/composeAPI.ts +++ b/packages/core/src/composeAPI.ts @@ -29,7 +29,6 @@ import { createGetNeighbors, createGetNewAddress, createGetNodeInfo, - createGetTips, createGetTransactionObjects, createGetTransactionsToApprove, createGetTrytes, @@ -74,7 +73,7 @@ export function returnType(func: Func) { /** * @method composeApi - * + * * @summary Creates an API object that's used to send requests to an IRI node. * * @memberof module:core @@ -89,12 +88,12 @@ export function returnType(func: Func) { * @example * ```js * const Iota = require('@iota/core`); - * + * * const iota = Iota.composeAPI({ * provider: 'https://nodes.devnet.thetangle.org:443' * }); * ``` - * + * * @return {API} iota - API object to use to interact with an IRI node. */ export const composeAPI = (settings: Partial = {}) => { @@ -103,7 +102,7 @@ export const composeAPI = (settings: Partial = {}) => { /** * @method setSettings - * + * * @summary Defines network provider configuration and [`attachToTangle`]{@link #module_core.attachToTangle} method. * * @memberof API @@ -126,13 +125,13 @@ export const composeAPI = (settings: Partial = {}) => { } /** - * + * * @method overrideNetwork - * + * * @summary Overrides the default provider * * @memberof API - * + * * @ignore * * @param {Provider} network - Provider instance to use to override the existing network settings @@ -145,11 +144,11 @@ export const composeAPI = (settings: Partial = {}) => { /** * * @method overrideAttachToTangle - * + * * @summary Overrides the default [`attachToTangle`]{@link #module_core.attachToTangle} method * * @memberof API - * + * * @ignore * * @param {function} attachToTangle - Function that overrides the @@ -171,7 +170,6 @@ export const composeAPI = (settings: Partial = {}) => { getInclusionStates: createGetInclusionStates(provider), getNeighbors: createGetNeighbors(provider), getNodeInfo: createGetNodeInfo(provider), - getTips: createGetTips(provider), getTransactionsToApprove: createGetTransactionsToApprove(provider), getTrytes: createGetTrytes(provider), interruptAttachingToTangle: createInterruptAttachingToTangle(provider), diff --git a/packages/core/src/createGetTips.ts b/packages/core/src/createGetTips.ts deleted file mode 100644 index ca9c06d11..000000000 --- a/packages/core/src/createGetTips.ts +++ /dev/null @@ -1,56 +0,0 @@ -import * as Promise from 'bluebird' -import { Callback, GetTipsCommand, GetTipsResponse, Hash, IRICommand, Provider } from '../../types' - -/** - * @method createGetTips - * - * @summary Creates a new `getTips()` method, using a custom Provider instance. - * - * @memberof module:core - * - * @ignore - * - * @param {Provider} provider - The Provider object that the method should use to call the node's API endpoints. - * - * @return {Function} [`getTips`]{@link #module_core.getTips} - A new `getTips()` function that uses your chosen Provider instance. - */ -export const createGetTips = ({ send }: Provider) => - /** - * This method finds all transactions that aren't referenced by other transactions in the Tangle - * by calling the connected IRI node's [`getTips`](https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference#gettips) endpoint. - * - * ## Related methods - * - * To find two consistent tip transactions to use as branch and trunk transactions, use the [`getTransactionsToApprove()`]{@link #module_core.getTransactionsToApprove} method. - * - * @method getTips - * - * @summary Searches the Tangle for tip transactions. - * - * @memberof module:core - * - * @param {Callback} [callback] - Optional callback function - * - * @example - * - * ```js - * getTips() - * .then(tips => { - * console.log('Found the following tip transactions:'); - * console.log(JSON.stringify(tips)); - * }) - * .catch(error => { - * console.log(`Something went wrong: ${error}`); - * }) - * ``` - * - * @return {Promise} - * - * @fulfil {Hash[]} tips - Array of tip transaction hashes - * - * @reject {Error} error - Fetch error: The connected IOTA node's API returned an error. See the [list of error messages](https://docs.iota.org/docs/node-software/0.1/iri/references/api-errors) - */ - (callback?: Callback>): Promise> => - send({ command: IRICommand.GET_TIPS }) - .then(({ hashes }) => hashes) - .asCallback(callback) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 96a308e78..060559c27 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -35,8 +35,6 @@ export { GetNeighborsResponse, GetNodeInfoCommand, GetNodeInfoResponse, - GetTipsCommand, - GetTipsResponse, GetTransactionsToApproveCommand, GetTransactionsToApproveResponse, TransactionsToApprove, @@ -68,8 +66,6 @@ export { createGetNeighbors } from './createGetNeighbors' export { createGetNodeInfo } from './createGetNodeInfo' -export { createGetTips } from './createGetTips' - export { createGetTransactionsToApprove } from './createGetTransactionsToApprove' export { createGetTrytes } from './createGetTrytes' diff --git a/packages/core/test/integration/getTips.test.ts b/packages/core/test/integration/getTips.test.ts deleted file mode 100644 index 29116669a..000000000 --- a/packages/core/test/integration/getTips.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { createHttpClient } from '@iota/http-client' -import test from 'ava' -import { createGetTips } from '../../src' -import { getTipsResponse } from './nocks/getTips' - -const getTips = createGetTips(createHttpClient()) - -test('getTips() resolves to correct tips response', async t => { - t.deepEqual(await getTips(), getTipsResponse.hashes, 'getTips() should resolve to correct tips') -}) - -test.cb('getTips() invokes callback', t => { - getTips(t.end) -}) - -test.cb('getTips() passes correct arguments to callback', t => { - getTips((err, res) => { - t.is(err, null, 'getTips() should pass null as first argument in callback for successuful requests') - - t.deepEqual( - res, - getTipsResponse.hashes, - 'getTips() should pass the correct response as second argument in callback' - ) - - t.end() - }) -}) diff --git a/packages/core/test/integration/nocks/getTips.ts b/packages/core/test/integration/nocks/getTips.ts deleted file mode 100644 index 38b555556..000000000 --- a/packages/core/test/integration/nocks/getTips.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as nock from 'nock' -import { GetTipsCommand, GetTipsResponse, IRICommand } from '../../../../types' -import headers from './headers' - -export const getTipsCommand: GetTipsCommand = { - command: IRICommand.GET_TIPS, -} - -export const getTipsResponse: GetTipsResponse = { - hashes: ['T'.repeat(81), 'U'.repeat(81)], - duration: 10, -} - -export const getBalancesNock = nock('http://localhost:14265', headers) - .persist() - .post('/', getTipsCommand) - .reply(200, getTipsResponse) diff --git a/packages/http-client/src/index.ts b/packages/http-client/src/index.ts index 0d0477b48..0a3b66249 100644 --- a/packages/http-client/src/index.ts +++ b/packages/http-client/src/index.ts @@ -24,8 +24,6 @@ export { GetNeighborsResponse, GetNodeInfoCommand, GetNodeInfoResponse, - GetTipsCommand, - GetTipsResponse, GetTransactionsToApproveCommand, GetTransactionsToApproveResponse, TransactionsToApprove, diff --git a/packages/types.ts b/packages/types.ts index ce72d2f1d..a062d34ee 100644 --- a/packages/types.ts +++ b/packages/types.ts @@ -89,7 +89,6 @@ export enum IRICommand { GET_NEIGHBORS = 'getNeighbors', ADD_NEIGHBORS = 'addNeighbors', REMOVE_NEIGHBORS = 'removeNeighbors', - GET_TIPS = 'getTips', FIND_TRANSACTIONS = 'findTransactions', GET_TRYTES = 'getTrytes', GET_INCLUSION_STATES = 'getInclusionStates', @@ -226,15 +225,6 @@ export interface GetNodeInfoResponse { readonly transactionsToRequest: number } -export interface GetTipsCommand extends BaseCommand { - command: IRICommand.GET_TIPS -} - -export interface GetTipsResponse { - readonly hashes: ReadonlyArray - readonly duration: number -} - export interface TransactionsToApprove { readonly trunkTransaction: Hash readonly branchTransaction: Hash