npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cosmic-plus/tx-result

v1.5.0

Published

Turns Stellar Horizon responses into meaningful descriptions

Downloads

24

Readme

tx-result / ReadmeContributingChangelog

Readme

Licence Dependencies Vulnerabilities Bundle Downloads

Turns Stellar Horizon responses into meaningful descriptions.

(Weekly updates: Reddit, Twitter, Keybase, Telegram)

Introduction

After posting a transaction to the network, most software needs to display comprehensive feedback to the user. This is especially true when an error happens.

This library produces human-readable descriptions for any possible code Stellar Core returns:

const response = await server.submitTransaction(transaction)
const result = new TxResult(response)

Result for successful transactions:

{
 validated: true,
 title: "The transaction has been validated",
 hash: "d89c...007e",
 ledger: 370369,
 offerResults: undefined,
 link: "https://horizon-testnet.stellar.org/transactions/d89c...007e"
}

Note: offerResults is as described in StellarSdk [server.submitTransaction()](https://stellar.github.io/js-stellar-sdk/Server.html#submitTransaction) documentation.

Result for failed transactions:

{
 validated: false,
 title: "The transaction has been rejected",
 errors: [
   "Operation 1: The destination account doesn't exist.",
   "Operation 3: The source does not have enough funds."
 ]
}

Installation

NPM/Yarn

  • NPM: npm install @cosmic-plus/tx-result
  • Yarn: yarn add @cosmic-plus/tx-result

In your script: const txResult = require("@cosmic-plus/tx-result")

Bower

bower install cosmic-plus-tx-result

In your HTML page:

<script src="./bower_components/cosmic-plus-tx-result/tx-result.js"></script>

CDN

In your HTML page:

<script src="https://cdn.cosmic.plus/[email protected]"></script>

Note: For production release it is advised to serve your copy of the library.

Usage

Functions

new TxResult(txResponse)

The TxResult constructor.

| Param | Type | Description | | ---------- | -------- | --------------------------------------------------------------- | | txResponse | Object | A response returned by StellarSdk server.submitTransaction(). |

await TxResult.fromPromise(promise) ⇒ TxResult

Returns the TxResult for an unresolved StellarSdk server.submitTransaction() Promise.

| Param | Type | Description | | ------- | --------- | ------------------------------- | | promise | Promise | An unresolved Horizon response. |

TxResult.describeTxCode(code) ⇒ String

Returns a comprehensive description for transaction return code.

See: Transaction possible errors

| Param | Type | Description | | ----- | -------- | ---------------------------------- | | code | String | A Stellar transaction return code. |

TxResult.describeOpCode(code) ⇒ String

Returns a comprehensive description for operation return code.

See: Operations possible errors

| Param | Type | Description | | ----- | -------- | -------------------------------- | | code | String | A Stellar operation return code. |

await TxResult.forCosmicLink(cosmicLink) ⇒ TxResult

Submits cosmicLink using cosmicLink.send() then returns its TxResult. The advantage of using this function is that it generates reports for callbacks and StellarGuard submission as well.

| Param | Type | Description | | ---------- | ------------ | ------------------------ | | cosmicLink | CosmicLink | A .lock()ed cosmicLink |

Links

Organization: Cosmic.plus | @GitHub | @NPM

Follow: Reddit | Twitter | Medium | Codepen

Talk: Telegram | Keybase