diff --git a/README.md b/README.md index 0f034fa32..762fca804 100644 --- a/README.md +++ b/README.md @@ -129,8 +129,6 @@ For details on all available API methods, see the [reference page](api_reference * [.getNodeInfo([callback])](api_reference.md#module_core.getNodeInfo) -* [getTips([callback])](api_reference.md#module_core.getTips) - * [getTransactionObjects(hashes, [callback])](api_reference.md#module_core.getTransactionObjects) * [.getTransactionsToApprove(depth, [reference], [callback])](api_reference.md#module_core.getTransactionsToApprove) diff --git a/api_reference.md b/api_reference.md index f6122b16e..ffc6f5b46 100644 --- a/api_reference.md +++ b/api_reference.md @@ -336,10 +336,6 @@ Converts an integer value to trits * [.getNodeInfo([callback])](#module_core.getNodeInfo) - * [.createGetTips(provider)](#module_core.createGetTips) - - * [.getTips([callback])](#module_core.getTips) - * [.createGetTransactionObjects(provider)](#module_core.createGetTransactionObjects) * [.getTransactionObjects(hashes, [callback])](#module_core.getTransactionObjects) @@ -1083,39 +1079,7 @@ getNodeInfo() // ... }) ``` - - -### *core*.createGetTips(provider) - -| Param | Type | Description | -| --- | --- | --- | -| provider | Provider | Network provider | - -**Returns**: function - [`getTips`](#module_core.getTips) - - -### *core*.getTips([callback]) -**Fulfil**: Hash[] List of tip hashes -**Reject**: Error -- Fetch error - -| Param | Type | Description | -| --- | --- | --- | -| [callback] | Callback | Optional callback | -Returns a list of tips (transactions not referenced by other transactions), -as seen by the connected node. - -**Example** -```js -getTips() - .then(tips => { - // ... - }) - .catch(err => { - // ... - }) -``` ### *core*.createGetTransactionObjects(provider) diff --git a/packages/core/README.md b/packages/core/README.md index 32ef15d5c..e90e822d9 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -61,8 +61,6 @@ yarn add @iota/core * [.getNodeInfo([callback])](#module_core.getNodeInfo) - * [.getTips([callback])](#module_core.getTips) - * [.getTransactionObjects(hashes, [callback])](#module_core.getTransactionObjects) * [.getTransactionsToApprove(depth, [reference], [callback])](#module_core.getTransactionsToApprove) @@ -807,35 +805,6 @@ getNodeInfo() console.log(`Something went wrong: ${error}`); }) ``` - - -### *core*.getTips([callback]) -**Summary**: Searches the Tangle for tip transactions. -**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) - -| Param | Type | Description | -| --- | --- | --- | -| [callback] | Callback | Optional callback function | - -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()`](#module_core.getTransactionsToApprove) method. - -**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}`); - }) -``` ### *core*.getTransactionObjects(hashes, [callback]) 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 dc74b5147..7d894892c 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', @@ -225,15 +224,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