Giter VIP home page Giter VIP logo

factom-harmony-connect-js-sdk's Introduction

Table of Contents

INTRODUCTION

GETTING STARTED

METHODS

SAMPLE APPLICATION

INTRODUCTION

About This Document

This documentation is written for developers with a basic level of coding knowledge and familiarity of the JavaScript programming language.

Readers can find guidelines to quickly get started with building and using the JavaScript SDK for Factom Harmony Connect.

You can learn more about Factom Harmony Connect here.

This SDK is open source and can be accessed on Github here.

SDK Architecture Overview

architecture

FactomSDK Class: Manages SDK constructor, product connection and provides access to other layers.

Utilities: Contain functions shared between core components.

Core: Contains main components that interact with Connect API.

Request/Response Handler: Handles all requests/responses (HTTP / HTTPS) from Connect API before passing them to other components.

GETTING STARTED

This section contains a summary of the steps required to get started with JavaScript Connect SDK installation.

System Requirements

In order to use this JavaScript SDK, you will need the following tools:

  • NodeJS v8 or above: Please find the link here. Current node LTS version is 10.15.0.

  • NPM: Node installation will include Npm, which is responsible for dependencies management.

Installation

Node.js

npm install factom-harmony-connect

Usage

This SDK relies on Promises making it easier to handle the asynchronous requests made to the API.

For more details of a specific module, please refer to the Methods section.

If you want to understand how the SDK works in practice, refer to the Sample Application section.

Below is an example of how to use the SDK. Before executing any requests, you will need to instantiate an instance of the SDK. The required parameters include details about the application you will be using to authenticate your requests. If you do not have an application yet, you can get one here.

import Factom from "factom-harmony-connect"

const factomConnectSDK = new Factom({
  baseUrl: "YOUR API URL",
  accessToken: {
    appId: "YOUR APP ID",
    appKey: "YOUR APP KEY"
  },
});

When the Factom SDK is initialized, there will be an optional automaticSigning param, which defaults to true.

  • When this initial config is set to true as default, all chain and entry POST methods require passing the params: signerPrivateKey and signerChainId which will be used to create signed chains and entries, as per the Factom Signing Standard.

  • When this initial config is set to false, the FactomSDK will not sign the chains and entries that are created and therefore it does not require the params: signerPrivateKey and signerChainId.

The primary benefit of automaticSigning param is to encourage you to create chains and entries with unique signatures. Later on, you can validate that the chains or entries were created by you or that a certain user/device/ organization/etc. actually signed and published a certain message that you see in your chain.

Now that you have initialized the SDK, you can use the SDK's Methods, which will execute the necessary REST API calls on your behalf. Following the Promises notation, you should use Async/Await syntax or .then()/.catch in ES5 to handle successful and failed requests.

All Method calls take an object as a parameter.

Async/Await

const DoSomeThingWithData = async () => {
  try {
    const response = await factomConnectSDK.identities.create({
      name: [... < your names array > ]
      keys: [... < your public key array > ]
    })
    // handle the response
  } catch (error) {
    // handle the error
  }
}

ES5 syntax

function DoSomeThingWithData() {
  factomConnectSDK.identities.create({
    name: [... < your names array > ]
    keys: [... < your public key array > ]
  }).then((response) => {
    // handle the response
  }).catch((error) => {
    // handle the error
  })
}

Patterns to utilize the Factom SDK:

// Return a JSON chain object as is from the API.
const chain = await factomConnectSDK.chains.get({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
});

// Return JSON entries array as is from API.

const entries = await factomConnectSDK.chains.entries.list({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
});

// Return a JSON single entry object as is from the API.

const entry = await factomConnectSDK.chains.entries.get({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
  entryHash: 'e0e2b7f7920ce25c20cf98c13ae454566e7cda7bb815b8a9ca568320d7bdeb93',
});

Note: The SDK allows for override values that were set in the instatiation of the SDK on a per-method call basis. To override the parameters that were set in the instantiated SDK class, you may specify any of the following properties in the calls where these properties apply:

  • appId
  • appKey
  • baseUrl
  • automaticSigning

Example:

// Create a chain with automaticSigning turned off for one call
const createChainResponse = await factomConnectSDK.chains.create({
  externalIds: ["NotarySimulation", "CustomerChain", "cust123"],
  content: "This chain represents a notary service's customer in the NotarySimulation, a sample implementation provided as part of the Factom Harmony SDKs. Learn more here: https://docs.harmony.factom.com/docs/sdks-clients",
  automaticSigning: false

});

// Return a JSON chain object as is from the API with new appId, appKey, and baseUrl.
const chain = await FactomSDK.chains.get({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
  accessToken: {
    appId: "YOUR APP ID",
    appKey: "YOUR APP KEY"
  },
  baseUrl: "YOUR API URL"
});

// Return JSON entries array as is from API with new appId, appKey, and baseUrl.
const entries = await FactomSDK.chains.entries.list({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
  accessToken: {
    appId: "YOUR APP ID",
    appKey: "YOUR APP KEY"
  },
  baseUrl: "YOUR API URL"
});

// Return a JSON single entry object as is from the API with new appId, appKey, and baseUrl.
const entry = await FactomSDK.chains.entries.get({
  chainId: '5dc94c605769d8e9dac1423048f8e5a1182e575aab6d923207a3a8d15771ad63',
  entryHash: 'e0e2b7f7920ce25c20cf98c13ae454566e7cda7bb815b8a9ca568320d7bdeb93',
  accessToken: {
    appId: "YOUR APP ID",
    appKey: "YOUR APP KEY"
  },
  baseUrl: "YOUR API URL"
});

License

The Harmony Connect SDK is provided with an MIT License.

METHODS

identities

apiInfo

chains

anchors

receipts

utils

SAMPLE APPLICATION

Overview

architecture

This Sample App is created to illustrate some of the core methods of this SDK and a real-world business scenario of how it can be used.

Since the application is built as a standalone application with a backend SDK process, the reader should review the commented code here.

The concept of the Sample App is a simple Notary service with a business flow as follows:

  • A Notary service begins using Factom Harmony: To use Harmony, there should be at least 1 identity used when signing written data. So, to start, the app creates an identity’s chain for the Notary service.

  • The first customer purchases the Notary service’s new “Blockchain authentication” service tier: To track the customer’s documents, the app creates a signed chain for them, allowing easy retrieval for that customer’s records.

  • The customer requests notarization of the first document: The app creates a signed entry within the customer’s chain containing a hashed version of the document. At this time, the notary service should also be storing the document in a secure location.

  • The customer returns at a later date and the clerk retrieves the past work for this customer: The app searches the blockchain for the customer’s chain, and with that data, retrieves the chain. The SDK automatically validates the authenticity of this chain, which ensures that the Notary’s systems have not been tampered with and the blockchain data was submitted by the Notary service.

  • The customer requests the document that was notarized: The app searches for an entry in the chain validated in the step above and gets that entry info, then validates the authenticity of the signature used to sign that entry.

  • The document’s authenticity is validated: The app pulls out the document’s hash from the entry’s content and compares it against a freshly generated hash of a stored document.

    • Note: It is recommended that in a real-world scenario, scheduled tasks are run to validate the data for proactive validation.
  • A developer who had access to one of the keys leaves employment with the Notary company, so they carry out proactive security: The app replaces the old key pair that the employee had access to.

Installation

  1. Checkout the repository.
  2. Run npm install.
  3. Run npm run build.
  4. Navigate to folder cd ./sample-app.
  5. Open configure.js.
  6. Change configuration settings with your baseUrl, appId and appKey, which can be found or generated at https://account.factom.com.
  7. Run node server.js.
  8. Open localhost:8080 on your browser.

Usage

Starting screen: The app comes with a starting page where the user clicks the "Run Notary Simulation" button to run the app.

architecture

Simulating screen: Then the system will take some time to generate all responses by calling the Harmony Connect API through the JavaScript Connect SDK in Node JS backend.

architecture

Response screen: After the loading process is finished, the app will display relevant data with regard to this business flow.

architecture

factom-harmony-connect-js-sdk's People

Contributors

bephahoai avatar cahl-dee avatar danielricaud avatar dmalone87 avatar dorono avatar hannemennah avatar hieumt2 avatar sambarnes avatar trangle286 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

virtualadam

factom-harmony-connect-js-sdk's Issues

entire external_ids array coming back in base64

Executing the following method...

    const chainSearchResult = await factomConnectSDK.chains.searchChains({
      externalIds: ['doron']
    });

...returns this result which was created with "doron" as one of the array items...

	"chainSearchResult": {
		"offset": 0,
		"limit": 15,
		"data": {
			"0": {
				"stage": "factom",
				"href": "/v1/chains/6e43a3f0711792d42834dc0e6b5da28bfa74ac22915f4662c7d27c4ec527f77a",
				"external_ids": ["ZG9yb24=", "NDQ=", "dGV4YXM="],
				"created_at": "2019-02-08T17:19:00.000000Z",
				"chain_id": "6e43a3f0711792d42834dc0e6b5da28bfa74ac22915f4662c7d27c4ec527f77a"
			},
			"dblock": {
				"height": 121115,
				"keymr": "0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e",
				"href": "/v1/dblocks/0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e"
			}
		},
		"count": 1
	},

Also, please make sure that the return format of the external_ids is included in the unit tests.

globalTunnel method breaks server process

Hello @hieumt2, is this code in the repo just for debugging on your end: https://github.com/FactomProject/factom-harmony-connect-js-sdk/blob/master/sample-app/simulateNotary.js#L8-L11 ? I noticed that the npm package necessary to execute this code was missing from the package.json, so maybe it wasn't intended to stay?

I ask because when I pulled down the latest from master and then tried running the sample app starting the simulation process, the api call timed out and gave me the errors below. However, once I removed that code, everything seems to work perfectly.

Can you please confirm that the globalTunnel code needs to remain there, and if so, perhaps you can clarify why I might be getting this error.


{ Error: tunneling socket could not be established, cause=connect ETIMEDOUT 10.133.93.63:8080
    at ClientRequest.onError (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/node_modules/tunnel/lib/tunnel.js:180:17)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  code: 'ECONNRESET',
  config: 
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers: 
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        app_id: 'aabe7d81',
        app_key: '502a5c77f8f600b9ec32e94fbe008f11',
        'User-Agent': 'axios/0.18.0',
        'Content-Length': 255 },
     method: 'post',
     url: 'https://durable.sandbox.harmony.factom.com/v1/identities',
     data: '{"name":["Tm90YXJ5U2ltdWxhdGlvbg==","MjAxOS0wMi0xM1QxNzo0ODoyMi42NDJa"],"keys":["idpub2Cktw6EgcBVMHMXmfcCyTHndcFvG7fJKyBpy3sTYcdTmdTuKya","idpub2JegfdBQBnqbXGKMMD89v8N81e4DpvERHWTJp6zvWaoAVi8Jnj","idpub2SrEYac7YQd6xQJKHt7hMWTgzBLDeyPYsK9jwJyQx5bfZvcxE9"]}' },
  request: 
   Writable {
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     domain: null,
     _events: 
      { response: [Function: handleResponse],
        error: [Function: handleRequestError] },
     _eventsCount: 2,
     _maxListeners: undefined,
     _options: 
      { maxRedirects: 21,
        maxBodyLength: 10485760,
        protocol: 'https:',
        path: '/v1/identities',
        method: 'post',
        headers: [Object],
        agent: undefined,
        auth: undefined,
        hostname: 'durable.sandbox.harmony.factom.com',
        port: null,
        nativeProtocols: [Object],
        pathname: '/v1/identities' },
     _ended: false,
     _ending: true,
     _redirectCount: 0,
     _redirects: [],
     _requestBodyLength: 255,
     _requestBodyBuffers: [ [Object] ],
     _onNativeResponse: [Function],
     _currentRequest: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 6,
        _maxListeners: undefined,
        output: [Array],
        outputEncodings: [Array],
        outputCallbacks: [Array],
        outputSize: 531,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: false,
        _headerSent: true,
        socket: null,
        connection: null,
        _header: 'POST /v1/identities HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\napp_id: aabe7d81\r\napp_key: 502a5c77f8f600b9ec32e94fbe008f11\r\nUser-Agent: axios/0.18.0\r\nContent-Length: 255\r\nHost: durable.sandbox.harmony.factom.com\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/v1/identities',
        _ended: false,
        res: null,
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Circular],
        [Symbol(outHeadersKey)]: [Object] },
     _currentUrl: 'https://durable.sandbox.harmony.factom.com/v1/identities' },
  response: undefined }

eval Error in NPM Build

Getting the following when running npm run build.

image

Tried updating all npm packages and running npm audit fix, issue w/developer has been open for 6 months now: emn178/js-sha256#18.

Options:

  1. figure out a way to fix the error (ideal, of course)
  2. replace package with another sha256 package
  3. confirm that this is not posing an actual security vulnerability in our case, and set Rollup to not display this error

Update SDK Method Names to More Closely Mirror REST HTTP Methods

Best practice is usually to have standard interfaces for each request type that match up with the REST interface (GET, CREATE, DESTROY, etc) with more specific variants for the less commonly used behavior.

For example, if i'm doing FactomSDK.indentity.createIdentity(), I already know it's an identity by it being encapsulated by Identity. so a more useful name for that would be FactomSDK.identity.create().

Each Resource method should have its own methods ending simply in get() or create(). The only non-REST generic methods would be search(), getFirst() and getLast().

So for example:

First, we instantiate our chain by doing, instead of...

const myChain = factomConnectSDK.chain({
    chainId: '123456'
});

...we do...

const myChain = FactomSDK.chain.get({
    chainId: '123456'
});

...so no more Chain constructor for the user to think about, we roll it all into the .get() method.

From there, continuing the pattern, we change this...

myChain.createEntry({
...
})

...to be...

myChain.entries.create({
...
});

Going one level deeper, this...

myChain.getFirstEntry();

...becomes...

myChain.entry.getFirst() // defaults to `true` for checking validation
myChain.entry.getFirst({
    signatureValidation: false
}) // doesn't check validation

AND...

const myEntries = myChain.entries.get();
const myEntrySearchResults = myEntries.searchEntriesOfChain({
...
})

...becomes...

const myEntries = myChain.entries.get();
const myEntrySearchResults = myEntries.search({
...
})

Allow for override values on a per-method call basis

UPDATE (5/16/19): After doing some more research, we've decided NOT to put overriding properties on a separate clientOverrides object. Instead, we will simply be allowing developers to place those properties on the top level of the parameter object for each method. So we would be "merging-left" any of the optional property values (code example below has been updated).

There are certain instances where we'd like to allow the user to specify override parameters that were set in the instantiation of the SDK. Right now, the parameters we're looking to allow to be overridden are:

  • appId
  • appKey
  • baseUrl
  • automaticSigning

To add optional overrides, we are going to add a new property named clientOverrides, which will be an object containing the aforementioned properties (appId, appKey, etc). Simply add to clientOverrides any properties that are part of the instantiated SDK class that you'd like to override the override.
Example:

await factomConnectSDK.chains.get({
    chainId: "4b9532c79d53ab22b85951b4a5853f81c2682132b3c810a95128c30401cd1e58",
    accessToken: {
        appId: "YOUR APP ID",
        appKey: "YOUR APP KEY"
    },
    baseUrl: "YOUR API URL"
});

const createChainResponse = await factomConnectSDK.chains.create({
    signerPrivateKey: keyToSign.private_key,
    signerChainId: identityChainId,
    externalIds: ["NotarySimulation", "CustomerChain", "cust123"],
    content:
        "This chain represents a notary service's customer in the NotarySimulation, a sample implementation provided as part of the Factom Harmony SDKs. Learn more here: https://docs.harmony.factom.com/docs/sdks-clients",
    automaticSigning: false
});

searchChains() response's "data" property is an object instead of an array

Here is the response as it is returned from the API alone:

image

...and here is that same response as it comes back from the SDK method, searchChains():

	"chainSearchResult": {
		"0": {
			"stage": "replicated",
			"href": "/v1/chains/ce80b403fb3ebc71c81cec4dcf375f183baeb7c70f73d80f99db7cdd79108d4a",
			"external_ids": ["U2lnbmVkQ2hhaW4=", "AQ==", "MTcxZTU4NTE0NTFjZTZmMmQ5NzMwYzE1MzdkYTQzNzVmZWI0NDI4NzBkODM1YzU0YTFiY2E4ZmZhN2UyYmRhNw==", "aWRwdWIyU3JFWWFjN1lRZDZ4UUpLSHQ3aE1XVGd6QkxEZXlQWXNLOWp3SnlReDViZlp2Y3hFOQ==", "/Fopv1Mocy7tpqRcLWI8E4o6hBF25Hh8bGdmW0PhgpUcHGrXlFg7Hf9cOmh/WaKxWabKGtG2jkIM/tfitUFUCw==", "MjAxOS0wMi0xMlQyMjowMTo0NS4zMTBa", "Tm90YXJ5U2ltdWxhdGlvbg==", "Q3VzdG9tZXJDaGFpbg==", "Y3VzdDEyMw=="],
			"created_at": null,
			"chain_id": "ce80b403fb3ebc71c81cec4dcf375f183baeb7c70f73d80f99db7cdd79108d4a"
		},
		"dblock": {
			"height": 121115,
			"keymr": "0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e",
			"href": "/v1/dblocks/0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e"
		}
	},

@hieumt2 I believe you already know about this, but just wanted to create a GIthub issue to make it easier to track and discuss.

stringified numbers in external_ids returning in different format

Creating a chain using this method call...

    const createChainResponse = await factomConnectSDK.chains.createChain({
      externalIds: ['doron', '44', 'texas'],
      content: 'I am an awesome guy'
    });

...and then getting that info back using this method call...

const getAllChainsResponse = await factomConnectSDK.chains.getAllChains();

...is returning...

	"chainInfo": {
		"chain": {
			"data": {
				"stage": "factom",
				"external_ids": ["doron", "0x3434", "texas"],
				"entries": {
					"href": "/v1/chains/6e43a3f0711792d42834dc0e6b5da28bfa74ac22915f4662c7d27c4ec527f77a/entries"
				},
				"eblock": {
					"keymr": "8dea3aca60f7caf377b78684360c34ac8b1caee98b7e4027ccaf3d38befc6f27",
					"href": "/v1/eblocks/8dea3aca60f7caf377b78684360c34ac8b1caee98b7e4027ccaf3d38befc6f27"
				},
				"dblock": {
					"height": 121115,
					"keymr": "0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e",
					"href": "/v1/dblocks/0fc6fc4c48b45b0d82638717d2b7de327ec5f2eea485c0c5e41999f6f0f5349e"
				},
				"created_at": "2019-02-08T17:19:00.000000Z",
				"content": "I am an awesome guy",
				"chain_id": "6e43a3f0711792d42834dc0e6b5da28bfa74ac22915f4662c7d27c4ec527f77a"
			}
		},
		"status": "not_signed/invalid_chain_format"
	},

The 2nd value in the external_ids property, "0x3434" should be "44"?

NOTE: This bug does not seem to apply to all stringified numbers, and in fact, 44 is the only number I am seeing coming back in the wrong format. If I try, say, "144" or "111", then those array items come back in the correct format, just like they were specified when the chain was created via the SDK.

Getting this for the following methods:

  • factomConnectSDK.chains.getAllChains()
  • factomConnectSDK.chains.chainInfo()
  • factomConnectSDK.entries.getEntryInfo()(also seen it come back as "3434" when it was last item in array)

Update Display of Proactive Security data on Simulation output

Please make the following changes:

  • Shows calculated state w/ comments in code explaining the logic of what makes a key be in a particular state. This should be:
    • "Pending" if the activated height is null
    • "Pending and Replacement Pending" if activated height is null and there is a pending key replacement for the same priority
    • While the above two states are the only ones that will actually happen in the Simulation, it's important to have in the code clear logic as to the fact that there are these other two states and what makes a key be in them
      • "Active" if there is an activated_height and a null retired_height
      • "Retired/replaced" if there is a retired_height
  • Add pending key from the identity response - see pending_key object in response here: https://docs.google.com/document/d/19R1g-_Djoc5b1AI66PAU0Ne34kduY4HdmJJdHZpCKVM/edit#heading=h.sw9h5hhahgpp
  • Crosses out key being replaced via css text-decoration
  • Doesn't show retired height (irrelevant to the topic here since it will always be null in this output). While activated height will also always be null, it's useful to see as it is the value used to indicate that the state is pending

Previous Display

image

New Display

image

getLastEntry() not working

        const chainInfo = await factomConnectSDK.chains.getChainInfo({
          chainId: '71c013c0fd9dc287735518b63ac283d51798b44391985f2ab21f542b288c5211'
        });
        const lastEntryInfo = await chainInfo.getlastEntry();

...gets me in the console...

TypeError: chainInfo.getlastEntry is not a function
    at module.exports (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/sample-app/testMethods.js:127:47)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

getEntries() not working

Running this...

        const chainInfo = await factomConnectSDK.chains.getChainInfo({
          chainId: '71c013c0fd9dc287735518b63ac283d51798b44391985f2ab21f542b288c5211'
        });
        const entriesList = await chainInfo.getEntries();

Results in this error in the console...

TypeError: chainInfo.getEntries is not a function
    at module.exports (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/sample-app/testMethods.js:126:41)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: chainInfo.getEntries is not a function
    at module.exports (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/sample-app/testMethods.js:126:41)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

The docs indicate that there is an SDK method named getEntries(), but the odd thing is that the documentation doesn't indicate that chainId is a required or optional parameter, nor does it specify that getEntries() needs to be called on an instance of an existing chain object.

getFirstEntry() not working

Maybe I am misunderstanding how this works (in which case we should probably update the docs to clarify), but...

        const chainInfo = await factomConnectSDK.chains.getChainInfo({
          chainId: '71c013c0fd9dc287735518b63ac283d51798b44391985f2ab21f542b288c5211'
        });
        const firstEntryInfo = await chainInfo.getFirstEntry();

gives me this in the console:

TypeError: chainInfo.getFirstEntry is not a function
    at module.exports (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/sample-app/testMethods.js:127:42)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: chainInfo.getFirstEntry is not a function
    at module.exports (/Users/DoronHomeFolder/Sites/factom/factom-harmony-connect-js-sdk/sample-app/testMethods.js:127:42)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.