Catalog npm
Back to packageRELEASE DETAILS

0.1.153

npm

@!tach!/sgejs

<p align="center"> <img src="https://app-assets.testnet.sixsigmasports.io/img/logo-center.png" width="80"><br /><br /> SgeJS makes it easy to compose and broadcast Sge and Cosmos messages, with all of the proto and amino encoding handled for you. </

Published12 Jun 2023
Direct dependencies37
Transitive dependenciesNot calculated

README

Current package documentation

SgeJS



SgeJS makes it easy to compose and broadcast Sge and Cosmos messages, with all of the proto encoding handled for you.

install

npm install sge

Table of contents

Usage

RPC Clients

import { sgenetwork } from '@!tach!/sgejs';

const { createRPCQueryClient } = sgenetwork.ClientFactory; 
const client = await createRPCQueryClient({ rpcEndpoint: RPC_ENDPOINT });

// now you can query the cosmos modules
const balance = await client.cosmos.bank.v1beta1
    .allBalances({ address: 'sge1addresshere' });

// you can also query the sge modules
const balances = await client.sge.market
    .market({ uid: '2d55a893-163f-41a7-b71f-837912b7b1e9' })

Composing Messages

Import the sge object from sge.

import { sgenetwork } from '@!tach!/sgejs';

const {
    betsByUIDs, /** Queries a list of Bet items filtered by uid list. */
    betsByCreator, /** Queries list of Bet items of a certain creator sorted by timestamp. */
    pendingBets /** Queries list of pending Bet items. */
} = sge.bet;

Cosmos Messages

import { cosmos } from '@!tach!/sgejs';

const {
    fundCommunityPool,
    withdrawDelegatorReward,
    withdrawValidatorCommission
} = cosmos.distribution.v1beta1.MessageComposer.fromPartial;

const {
    beginRedelegate,
    delegate,
    undelegate
} = cosmos.staking.v1beta1.MessageComposer.fromPartial;

const {
    deposit,
} = cosmos.gov.v1beta1.MessageComposer.fromPartial;

Connecting with Wallets and Signing Messages

⚡️ For web interfaces, we recommend using cosmos-kit. Continue below to see how to manually construct signers and clients.

Here are the docs on creating signers in cosmos-kit that can be used with Keplr and other wallets.

Creating Signers

To broadcast messages, you can create signers with a variety of options:

Proto Signer

import { getOfflineSignerProto as getOfflineSigner } from 'cosmjs-utils';

WARNING: NOT RECOMMENDED TO USE PLAIN-TEXT MNEMONICS. Please take care of your security and use best practices such as AES encryption and/or methods from 12factor applications.

import { chains } from 'chain-registry';

const mnemonic =
  'unfold client turtle either pilot stock floor glow toward bullet car science';
  const chain = chains.find(({ chain_name }) => chain_name === 'sge-network');
  const signer = await getOfflineSigner({
    mnemonic,
    chain
  });

Broadcasting Messages

Now that you have your stargateClient, you can broadcast messages:

const { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl;

const msg = send({
    amount: [
    {
        denom: 'coin',
        amount: '1000'
    }
    ],
    toAddress: address,
    fromAddress: address
});

const fee: StdFee = {
    amount: [
    {
        denom: 'coin',
        amount: '864'
    }
    ],
    gas: '86364'
};
const response = await stargateClient.signAndBroadcast(address, [msg], fee);

Credits

Code built with the help of these related projects:

  • @osmonauts/telescope a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
  • cosmos-kit A wallet connector for the Cosmos ⚛️

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 37

Native requirements
37 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@babel/runtime
Environment
{
  "local_name": "@babel/runtime",
  "alias": false,
  "peer_metadata": null
}
^7.19.4runtime
@cosmjs/amino
Environment
{
  "local_name": "@cosmjs/amino",
  "alias": false,
  "peer_metadata": null
}
0.29.4runtime
@cosmjs/proto-signing
Environment
{
  "local_name": "@cosmjs/proto-signing",
  "alias": false,
  "peer_metadata": null
}
0.29.4runtime
@cosmjs/stargate
Environment
{
  "local_name": "@cosmjs/stargate",
  "alias": false,
  "peer_metadata": null
}
0.29.4runtime
@cosmjs/tendermint-rpc
Environment
{
  "local_name": "@cosmjs/tendermint-rpc",
  "alias": false,
  "peer_metadata": null
}
^0.29.4runtime
@osmonauts/lcd
Environment
{
  "local_name": "@osmonauts/lcd",
  "alias": false,
  "peer_metadata": null
}
^0.10.0runtime
protobufjs
Environment
{
  "local_name": "protobufjs",
  "alias": false,
  "peer_metadata": null
}
^6.11.2runtime
@babel/cli
Environment
{
  "local_name": "@babel/cli",
  "alias": false,
  "peer_metadata": null
}
7.19.3development
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
7.19.3development
@babel/eslint-parser
Environment
{
  "local_name": "@babel/eslint-parser",
  "alias": false,
  "peer_metadata": null
}
^7.19.1development
@babel/node
Environment
{
  "local_name": "@babel/node",
  "alias": false,
  "peer_metadata": null
}
^7.19.1development
@babel/plugin-proposal-class-properties
Environment
{
  "local_name": "@babel/plugin-proposal-class-properties",
  "alias": false,
  "peer_metadata": null
}
7.18.6development
@babel/plugin-proposal-export-default-from
Environment
{
  "local_name": "@babel/plugin-proposal-export-default-from",
  "alias": false,
  "peer_metadata": null
}
7.18.10development
@babel/plugin-proposal-nullish-coalescing-operator
Environment
{
  "local_name": "@babel/plugin-proposal-nullish-coalescing-operator",
  "alias": false,
  "peer_metadata": null
}
7.18.6development
@babel/plugin-proposal-numeric-separator
Environment
{
  "local_name": "@babel/plugin-proposal-numeric-separator",
  "alias": false,
  "peer_metadata": null
}
7.18.6development
@babel/plugin-proposal-object-rest-spread
Environment
{
  "local_name": "@babel/plugin-proposal-object-rest-spread",
  "alias": false,
  "peer_metadata": null
}
7.19.4development
@babel/plugin-proposal-optional-chaining
Environment
{
  "local_name": "@babel/plugin-proposal-optional-chaining",
  "alias": false,
  "peer_metadata": null
}
7.18.9development
@babel/plugin-transform-runtime
Environment
{
  "local_name": "@babel/plugin-transform-runtime",
  "alias": false,
  "peer_metadata": null
}
7.19.1development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
7.19.4development
@babel/preset-typescript
Environment
{
  "local_name": "@babel/preset-typescript",
  "alias": false,
  "peer_metadata": null
}
^7.18.6development
@osmonauts/telescope
Environment
{
  "local_name": "@osmonauts/telescope",
  "alias": false,
  "peer_metadata": null
}
^0.78.0development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.2development
babel-core
Environment
{
  "local_name": "babel-core",
  "alias": false,
  "peer_metadata": null
}
7.0.0-bridge.0development
babel-jest
Environment
{
  "local_name": "babel-jest",
  "alias": false,
  "peer_metadata": null
}
29.1.2development
babel-watch
Environment
{
  "local_name": "babel-watch",
  "alias": false,
  "peer_metadata": null
}
^7.0.0development
cross-env
Environment
{
  "local_name": "cross-env",
  "alias": false,
  "peer_metadata": null
}
^7.0.2development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
8.25.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^8.5.0development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^4.2.1development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.2development
jest-in-case
Environment
{
  "local_name": "jest-in-case",
  "alias": false,
  "peer_metadata": null
}
^1.0.2development
long
Environment
{
  "local_name": "long",
  "alias": false,
  "peer_metadata": null
}
^5.2.0development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.7.1development
regenerator-runtime
Environment
{
  "local_name": "regenerator-runtime",
  "alias": false,
  "peer_metadata": null
}
^0.13.7development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^3.0.2development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.0.3development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.8.4development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-eM/pkLmdF6lHZWqT3Idq/ha+8Zv1aTesh1Yt+79Yy2iCDd8A8Tdr27MQkzPy8tzOrAo7nlYM72hgbJUi1T33PQ==",
  "shasum": "3de702ae1ec41fa7f7ae0b3dc63e621f8cb8d7a9",
  "tarball": "https://registry.npmjs.org/@!tach!/sgejs/-/sgejs-0.1.153.tgz",
  "fileCount": 982,
  "unpackedSize": 10223774,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIAK2KvxzSILDMIR19NA5E+8OqeFIqbo0c3d9R829Y1U1AiEA3DMOYapQOjqRKNoaajxW6pefiqWx91+vTRmTfVd5pvg="
    }
  ]
}

Repository

PENDING
saage-tech/sgejs

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:44 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:6ebfea8580dcbf2fdc77b3f2462b7b2c582ec6fffc073b375a7c63ffe6dfd9d7

Other collected versions

0.1.31714 Aug0.1.31614 Aug0.1.31511 Aug0.1.31411 Aug0.1.3139 Aug0.1.3129 AugView all collected versions →