Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from confio/initial-changes
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
msteiner96 authored Feb 8, 2022
2 parents cd5d81b + 3be9fa1 commit 497c8bf
Show file tree
Hide file tree
Showing 12 changed files with 776 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
83 changes: 82 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,85 @@

[![npm version](https://img.shields.io/npm/v/cosmwasm.svg)](https://www.npmjs.com/package/cosmwasm)

Source of the cosmwasm npm package
## About

Cosmwasm.js was created to help new developers get started with their first dApps.
It is just a wrapper package to easily import needed features from CosmJS.

## Get started

### Installation

**NPM**

`npm install cosmwasm`

**Yarn**

`yarn add cosmwasm`

## Usage

### Get a read-only stargate client

```ts
import { CosmWasmClient } from "cosmwasm";

// This is your rpc endpoint
const rpcEndpoint = "https://rpc.cliffnet.cosmwasm.com:443/";

async function main() {
const client = await CosmWasmClient.connect(rpcEndpoint);
console.log(client);
}

main();
```

### Create a wallet and a signing stargate client

```ts
import { StargateSigningClient, Secp256k1HdWallet } from "cosmwasm";

// This is your rpc endpoint
const rpcEndpoint = "https://rpc.cliffnet.cosmwasm.com:443/";

// Using a random generated mnemonic
const mnemonic = "rifle same bitter control garage duck grab spare mountain doctor rubber cook";

async function main() {

// Create a wallet
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);

// Using
const client = await StargateSigningClient.connectWithSigner(
rpcEndpoint,
wallet
);
console.log(client);
}

main();
```

### Interacting with contracts

```ts
import { CosmWasmClient } from "cosmwasm";

// This is your rpc endpoint
const rpcEndpoint = "https://rpc.cliffnet.cosmwasm.com:443/";

// This is your contract address
const contractAddr = "wasm19qws2lfd8pskyn0cfgpl5yjjyq3msy5402qr8nkzff9kdnkaepyqycedfh";

async function main() {
const client = await CosmWasmClient.connect(rpcEndpoint);
const config = await client.queryContractSmart(contractAddr, { config: {} });

console.log(config);
}

main();
```
37 changes: 31 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
{
"name": "cosmwasm",
"version": "0.0.1",
"description": "A CosmJS wrapper for CosmWasm projects",
"main": "index.js",
"version": "0.27.1",
"description": "A wrapper package for all relevant cosmjs packages.",
"main": "build/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -rf ./build && tsc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/confio/cosmwasm.js.git"
},
"author": "",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"contributors": [
{
"name": "Simon Warta",
"email": "[email protected]"
},
{
"name": "Milan Steiner",
"email": "[email protected]"
}
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/confio/cosmwasm.js/issues"
},
"homepage": "https://github.com/confio/cosmwasm.js#readme"
"homepage": "https://github.com/confio/cosmwasm.js#readme",
"dependencies": {
"@cosmjs/amino": "0.27.1",
"@cosmjs/cosmwasm-stargate": "0.27.1",
"@cosmjs/crypto": "0.27.1",
"@cosmjs/encoding": "0.27.1",
"@cosmjs/proto-signing": "0.27.1",
"@cosmjs/stargate": "0.27.1"
},
"devDependencies": {
"typescript": "^4.5.5"
}
}
39 changes: 39 additions & 0 deletions src/amino.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export {
pubkeyToAddress,
pubkeyToRawAddress,
rawSecp256k1PubkeyToRawAddress,
decodeAminoPubkey,
decodeBech32Pubkey,
encodeAminoPubkey,
Coin,
coin,
coins,
parseCoins,
encodeBech32Pubkey,
encodeSecp256k1Pubkey,
makeCosmoshubPath,
isSecp256k1Pubkey,
isSinglePubkey,
Pubkey,
pubkeyType,
Secp256k1Pubkey,
SinglePubkey,
Secp256k1HdWallet,
Secp256k1HdWalletOptions,
Secp256k1Wallet,
decodeSignature,
encodeSecp256k1Signature,
StdSignature,
AminoMsg,
makeSignDoc,
serializeSignDoc,
StdFee,
StdSignDoc,
AccountData,
Algo,
AminoSignResponse,
OfflineAminoSigner,
isStdTx,
makeStdTx,
StdTx,
} from "@cosmjs/amino";
11 changes: 11 additions & 0 deletions src/cosmwasm-stargate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {
ChangeAdminResult,
ExecuteResult,
InstantiateOptions,
InstantiateResult,
MigrateResult,
CosmWasmClient,
SigningCosmWasmClient,
SigningCosmWasmClientOptions,
UploadResult,
} from "@cosmjs/cosmwasm-stargate";
4 changes: 4 additions & 0 deletions src/crypto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export {
HdPath,
pathToString,
} from "@cosmjs/crypto";
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./amino";
export * from "./cosmwasm-stargate";
export * from "./crypto";
export * from "./proto-signing";
export * from "./stargate";
6 changes: 6 additions & 0 deletions src/proto-signing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export {
DirectSecp256k1HdWallet,
Registry,
OfflineDirectSigner,
OfflineSigner
} from "@cosmjs/proto-signing";
8 changes: 8 additions & 0 deletions src/stargate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
IndexedTx,
StargateClient,
SigningStargateClient,
GasPrice,
QueryClient,
Block
} from "@cosmjs/stargate";
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"declaration": true,
"outDir": "./build",
"strict": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}
Loading

0 comments on commit 497c8bf

Please sign in to comment.