Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #50 from cosmostation/develop
Browse files Browse the repository at this point in the history
Updated to kava-3
  • Loading branch information
Booyoun authored Jun 10, 2020
2 parents a7e3f62 + aa48859 commit 9055740
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ iris.setBech32MainPrefix("iaa");
```js
const cosmosjs = require("@cosmostation/cosmosjs"); // only NodeJS

const chainId = "kava-2";
const chainId = "kava-3";
const kava = cosmosjs.network(lcdUrl, chainId);
kava.setBech32MainPrefix("kava");
```
Expand Down
90 changes: 44 additions & 46 deletions docs/msg_types/kava.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

In this docs, these are supporting message types in Kava.

**_Note:_** At the time of this writing, CDP transactions are NOT available in `kava-2 (mainnet)`. It is only available in `kava-testnet-4000`.

- [Kava testnet link is available here](https://github.com/Kava-Labs/kava-testnets)

Kava is a collateralized debt position built on top of Cosmos SDK. It has pretty much the same message types as Cosmos Hub other than [4 different moduels](https://github.com/Kava-Labs/kava-devnet/blob/master/spec/kava.md) that make up the system.
Expand Down Expand Up @@ -41,17 +39,17 @@ let stdSignMsg = kava.newStdMsg({
value: {
amount: [
{
amount: String(100000), // 6 decimal places (1000000 uatom = 1 ATOM)
denom: "uatom"
amount: String(100000), // 6 decimal places (1000000 ukava = 1 KAVA)
denom: "ukava"
}
],
from_address: address,
to_address: "cosmos18vhdczjut44gpsy804crfhnd5nq003nz0nf20v"
to_address: "kava1qrlge6kqjz2763yp6ghws9ekv8u62dva9hs86p"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -72,19 +70,19 @@ let stdSignMsg = kava.newStdMsg({
address: address,
coins: [
{
amount: String(100000), // 6 decimal places (1000000 uatom = 1 ATOM)
denom: "uatom"
amount: String(100000), // 6 decimal places (1000000 ukava = 1 KAVA)
denom: "ukava"
}
]
}
],
outputs: [
{
address: "cosmos18vhdczjut44gpsy804crfhnd5nq003nz0nf20v",
address: "kava1qrlge6kqjz2763yp6ghws9ekv8u62dva9hs86p",
coins: [
{
amount: String(100000),
denom: "uatom"
denom: "ukava"
}
]
}
Expand All @@ -93,7 +91,7 @@ let stdSignMsg = kava.newStdMsg({
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand Down Expand Up @@ -122,17 +120,17 @@ let stdSignMsg = kava.newStdMsg({
},
min_self_delegation: String(1),
delegator_address: address,
validator_address: "cosmosvaloper106kt5cmued596rqusmthfnh39h38k64e73fxce",
pubkey: "cosmosvalconspub1zcjduepq8ve2hfuvnyhan9tz7vjgstslw7lygnk85sgp3emehtnxjpu3j7gqw5wvcz",
validator_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex",
pubkey: "kavavalconspub1zcjduepq8ve2hfuvnyhan9tz7vjgstslw7lygnk85sgp3emehtnxjpu3j7gqw5wvcz",
value: {
denom: "uatom",
denom: "ukava",
amount: String(1)
}
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -154,14 +152,14 @@ let stdSignMsg = kava.newStdMsg({
website: "[do-not-modify]",
details: "[do-not-modify]"
},
address: "cosmosvaloper106kt5cmued596rqusmthfnh39h38k64e73fxce",
address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex",
commission_rate: "0.220000000000000000", // 22.0%
min_self_delegation: null
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -179,15 +177,15 @@ let stdSignMsg = kava.newStdMsg({
value: {
amount: {
amount: String(1000000),
denom: "uatom"
denom: "ukava"
},
delegator_address: address,
validator_address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
validator_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -205,15 +203,15 @@ let stdSignMsg = kava.newStdMsg({
value: {
amount: {
amount: String(1000000),
denom: "uatom"
denom: "ukava"
},
delegator_address: address,
validator_address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
validator_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -231,16 +229,16 @@ let stdSignMsg = kava.newStdMsg({
value: {
amount: {
amount: String(1000000),
denom: "uatom"
denom: "ukava"
},
delegator_address: address,
validator_dst_address: "cosmosvaloper1ec3p6a75mqwkv33zt543n6cnxqwun37rr5xlqv",
validator_src_address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
validator_dst_address: "kavavaloper193ugtwwdm3u57f4zcxdg5ueky3g0swngck3fhc",
validator_src_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -257,12 +255,12 @@ let stdSignMsg = kava.newStdMsg({
type: "cosmos-sdk/MsgWithdrawDelegationReward",
value: {
delegator_address: address,
validator_address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
validator_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -278,12 +276,12 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cosmos-sdk/MsgWithdrawValidatorCommission",
value: {
validator_address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
validator_address: "kavavaloper1d5we85gdx9kdyszw0nd9a6jpdu65cxwqph4yex"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -300,12 +298,12 @@ let stdSignMsg = kava.newStdMsg({
type: "cosmos-sdk/MsgModifyWithdrawAddress",
value: {
delegator_address: address,
withdraw_address: "cosmos133mtfk63fuac5e2npfgcktwufnty2536wedfal"
withdraw_address: "kava193ugtwwdm3u57f4zcxdg5ueky3g0swng4qtp00"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -326,7 +324,7 @@ let stdSignMsg = kava.newStdMsg({
initial_deposit: [
{
amount: String(1000000),
denom: "uatom"
denom: "ukava"
}
],
proposal_type: "Text",
Expand All @@ -335,7 +333,7 @@ let stdSignMsg = kava.newStdMsg({
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -354,7 +352,7 @@ let stdSignMsg = kava.newStdMsg({
amount: [
{
amount: String(1000000),
denom: "uatom"
denom: "ukava"
}
],
depositor: address,
Expand All @@ -363,7 +361,7 @@ let stdSignMsg = kava.newStdMsg({
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -386,7 +384,7 @@ let stdSignMsg = kava.newStdMsg({
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -402,12 +400,12 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cosmos-sdk/MsgUnjail",
value: {
address: "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"
address: "kavavaloper193ugtwwdm3u57f4zcxdg5ueky3g0swngck3fhc"
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(5000), denom: "uatom" } ], gas: String(200000) },
fee: { amount: [ { amount: String(5000), denom: "ukava" } ], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
Expand All @@ -423,7 +421,7 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cdp/MsgCreateCDP",
value: {
sender: "kava1ztrqwujkdu3dfzqv059vjyw7p879zv87lp5qn6",
sender: "kava193ugtwwdm3u57f4zcxdg5ueky3g0swng4qtp00",
principal: [
{
denom: "usdx",
Expand Down Expand Up @@ -455,8 +453,8 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cdp/MsgDeposit",
value: {
owner: "kava1ztrqwujkdu3dfzqv059vjyw7p879zv87lp5qn6",
depositor: "kava1ztrqwujkdu3dfzqv059vjyw7p879zv87lp5qn6",
owner: "kava193ugtwwdm3u57f4zcxdg5ueky3g0swng4qtp00",
depositor: "kava193ugtwwdm3u57f4zcxdg5ueky3g0swng4qtp00",
collateral: [
{
denom: "btc",
Expand All @@ -483,7 +481,7 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cdp/MsgWithdraw",
value: {
owner: "kava12mhygxvk67n52wzcz0yuunw74xst7jmw2pkql3",
owner: "kava1d5we85gdx9kdyszw0nd9a6jpdu65cxwqvp0vp3",
depositor: "kava10tpyfe03nufsax5g038n287yzn9ldyqc9dvz5j",
collateral: [
{
Expand Down Expand Up @@ -511,7 +509,7 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cdp/MsgDrawDebt",
value: {
sender: "kava10tpyfe03nufsax5g038n287yzn9ldyqc9dvz5j",
sender: "kava1d5we85gdx9kdyszw0nd9a6jpdu65cxwqvp0vp3",
cdp_denom: "btc",
principal: [
{
Expand Down Expand Up @@ -539,7 +537,7 @@ let stdSignMsg = kava.newStdMsg({
{
type: "cdp/MsgRepayDebt",
value: {
sender: "kava10tpyfe03nufsax5g038n287yzn9ldyqc9dvz5j",
sender: "kava1d5we85gdx9kdyszw0nd9a6jpdu65cxwqvp0vp3",
payment: [
{
denom: "usdx",
Expand Down
6 changes: 3 additions & 3 deletions example/browser-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<title>CosmosJS Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/@cosmostation/[email protected].0/dist/cosmos.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@cosmostation/[email protected].1/dist/cosmos.min.js"></script>
<script>
function load() {
function send() {
const mnemonic = "swear buyer security impulse public stereo peasant correct cross tornado bid discover anchor float venture deal patch property cool wreck eight dwarf december surface";
const chainId = "cosmoshub-3";
const cosmos = cosmosjs.network("https://lcd-cosmos-free.cosmostation.io", chainId);
Expand Down Expand Up @@ -53,7 +53,7 @@
</script>
</head>

<body onload="load();">
<body onload="send();">
<p id="myAddress"></p>
</body>

Expand Down
2 changes: 1 addition & 1 deletion example/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cosmosjs = require("../src");

// [WARNING] This mnemonic is just for the demo purpose. DO NOT USE THIS MNEMONIC for your own wallet.
const mnemonic = "swear buyer security impulse public stereo peasant correct cross tornado bid discover anchor float venture deal patch property cool wreck eight dwarf december surface";
const chainId = "kava-2";
const chainId = "kava-3";
const kava = cosmosjs.network("https://lcd-kava.cosmostation.io", chainId);
kava.setBech32MainPrefix("kava");
kava.setPath("m/44'/459'/0'/0/0"); // new: m/44'/459'/0'/0/0, legacy: m/44'/118'/0'/0/0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cosmostation/cosmosjs",
"version": "0.6.0",
"version": "0.6.1",
"description": "A JavasSript Open Source Library for Cosmos Network, IRISnet, Kava and Band Protocol. (HTML developers can use /dist/cosmos.js)",
"main": "./src/index.js",
"repository": {
Expand Down

0 comments on commit 9055740

Please sign in to comment.