0.6.1 • Published 4 days ago

@akashnetwork/akashjs v0.6.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 days ago

akashjs

build:main

Connect and communicate with the Akash Network. Pure JS library can be used in browser for unsigned transactions, and with node.js for full compatibility.

compatibility

Compatible with modern browsers, nodejs 14+ and Webpack 5

getting started

install from npm or yarn

npm i @akashnetwork/akashjs
yarn add @akashnetwork/akashjs

or use the umd bundle the object returned is Window.akjs

<script
  type="text/javascript"
  src="https://unpkg.com/@akashnetwork/akashjs@0.0.6/umd/akashjs.js"
></script>

stargate

While akashjs manages much under the hood, more control is available through all of the exported types, clients and protocols.

Import the registry for signing and broadcasting signed transactions, this is needed if you plan to use Stargate

import { stargate as akashStargate } from "@akashnetwork/akashjs";
import { Registry } from "@cosmjs/proto-signing";

const myRegistry = new Registry([
  ...defaultRegistryTypes,
  ...akashStargate.registry,
]);

const client = await SigningStargateClient.connectWithSigner(
  `http://rpcUrl/`,
  offlineSigner,
  {
    registry: myRegistry,
  }
);

You can use the signer to create and sign requests. Below is an example of sending a deployment take-down message.

const mnemonic = "your wallet mnemonic";
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" });

// get first account
const [account] = await wallet.getAccounts();

// Use the encode method for the message to wrap the data
const message = MsgCloseDeployment.fromPartial({
    id: {
        dseq: "555555",
        owner: account.address,
    }
});

// Set the appropriate typeUrl and attach the encoded message as the value
const msgAny = {
    typeUrl: getTypeUrl(MsgCloseDeployment),
    value: message
};

// You can use your own RPC node, or get a list of public nodes from akashjs
const rpcEndpoint = "http://my.rpc.node";

const myRegistry = new Registry(
    getAkashTypeRegistry()
);

const client = await SigningStargateClient.connectWithSigner(
    rpcEndpoint,
    wallet,
    {
        registry: myRegistry
    }
);

const fee = {
    amount: [
        {
            denom: "uakt",
            amount: "5000",
        },
    ],
    gas: "800000",
};

const signedMessage = await client.signAndBroadcast(
    account.address,
    [msgAny],
    fee,
    "take down deployment"
);

examples

Additional examples can be found in the examples directory

Contribution Guidelines

Project Stack

This repository is primarily written in TypeScript and uses Node.js version 18. We use Webpack 5 for UMD bundling. These tools ensure that our development environment is consistent and our builds are stable.

Automated CI Checks and Releases

Our project enforces high standards of code quality and consistency to ensure that all contributions adhere to our guidelines and maintain a high level of reliability. Here's what you should be aware of when contributing to our repository:

  • Code Linting: We use ESLint to analyze the code for potential errors and coding style issues. This ensures that all contributions maintain a consistent style and follow best practices.

  • Code Formatting: Prettier is configured to format code automatically. This helps keep our codebase clean and readable without requiring manual adjustments for styling.

  • Commit Linting: All commit messages must adhere to the Conventional Commits specification. This is enforced through automated linting of commits, helping us keep our project history clear and easy to navigate. See Conventional Commits for more information. commitizen is a great tool to get started with.

  • Automated Testing: Upon creating a pull request, automated tests are run to verify that the new code does not break any existing functionality and meets all testing standards.

  • Semantic Release: When changes are merged into the main branch, a semantic release process is triggered. This process automatically determines version numbers and generates changelogs based on the commit messages, streamlining the release process and ensuring consistent versioning.

  • Continuous Integration: Our CI workflows are designed to validate pull requests and manage releases. They perform multiple checks including commit validation, linting, and testing code coverage before merging changes.

To better follow the above guidelines, we recommend using git hooks that would run the necessary checks before pushing your code. To do so after dependencies are installed, run the following command:

npm run setup-git-hooks

Contributing

PRs are welcome! By adhering to these guidelines and leveraging our automated systems, we can maintain a high-quality codebase and streamline our development processes. We appreciate your contributions to making this project even better!

0.6.1

4 days ago

0.6.0

10 days ago

0.5.11

1 month ago

0.5.10

1 month ago

0.5.9

1 month ago

0.5.4

4 months ago

0.5.1

5 months ago

0.5.0

6 months ago

0.4.9

9 months ago

0.4.8

9 months ago

0.4.17

8 months ago

0.4.18

8 months ago

0.4.15

8 months ago

0.4.13

8 months ago

0.4.14

8 months ago

0.4.11

8 months ago

0.4.7

9 months ago

0.4.5

11 months ago

0.4.4

11 months ago

0.4.3

11 months ago

0.4.0

1 year ago

0.4.2

1 year ago

0.3.3

1 year ago

0.3.0

1 year ago

0.3.1

1 year ago

0.2.5

1 year ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.4

1 year ago

0.2.1

2 years ago

0.1.1

2 years ago

0.0.28

2 years ago

0.0.26

2 years ago

0.0.20

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago