@kava-labs/javascript-sdk
Advanced tools
Comparing version 1.0.11 to 2.0.0-beta.0
{ | ||
"name": "@kava-labs/javascript-sdk", | ||
"version": "1.0.11", | ||
"version": "2.0.0-beta.0", | ||
"description": "Supports interaction with the Kava blockchain via a REST api", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@tendermint/sig": "^0.4.1", | ||
"@kava-labs/sig": "^0.1.0", | ||
"axios": "^0.19.2", | ||
"bech32": "^1.1.3", | ||
"big.js": "^5.2.2", | ||
"bip39": "^3.0.2", | ||
"crypto-js": "^4.0.0", | ||
@@ -15,3 +16,5 @@ "lodash": "^4.17.15", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"@binance-chain/javascript-sdk": "^3.0.2" | ||
}, | ||
"repository": { | ||
@@ -18,0 +21,0 @@ "type": "git", |
@@ -1,2 +0,2 @@ | ||
const sig = require("@tendermint/sig"); | ||
const sig = require("@kava-labs/sig"); | ||
const _ = require("lodash"); | ||
@@ -17,2 +17,3 @@ const tx = require("../tx").tx; | ||
getPrice: "/pricefeed/price", | ||
getRawPrices: "/pricefeed/rawprices", | ||
getSwap: "bep3/swap", | ||
@@ -113,3 +114,3 @@ getSwaps: "/bep3/swaps", | ||
chain_id: this.chainID, | ||
account_number: this.accNum, | ||
account_number: String(this.accNum), | ||
sequence: String(sequence) | ||
@@ -123,4 +124,4 @@ }; | ||
chain_id: this.chainID, | ||
account_number: this.accNum != null ? this.accNum : meta.account_number, | ||
sequence: sequence ? String(sequence) : meta.sequence | ||
account_number: this.accNum != null ? String(this.accNum) : String(meta.account_number), | ||
sequence: sequence ? String(sequence) : String(meta.sequence) | ||
}; | ||
@@ -205,2 +206,10 @@ } | ||
async getRawPrices(market) { | ||
const path = api.getRawPrices + "/" + market; | ||
const res = await tx.getTx(path, this.baseURI); | ||
if (res && res.data) { | ||
return res.data.result; | ||
} | ||
} | ||
/** | ||
@@ -444,5 +453,3 @@ * Get CDP if one exists for an owner and asset type | ||
* @param {String} amount the amount in coins to be transferred | ||
* @param {String} expectedIncome the amount of coins expected to be received by the recipient | ||
* @param {String} heightSpan the number of blocks that this swap will be active/claimable | ||
* @param {String} crossChain denotes if this swap is a cross-chain swap or a same-chain swap | ||
* @param {String} sequence optional account sequence | ||
@@ -458,5 +465,3 @@ * @return {Promise} | ||
amount, | ||
expectedIncome, | ||
heightSpan, | ||
crossChain, | ||
sequence = null | ||
@@ -472,5 +477,3 @@ ) { | ||
amount, | ||
expectedIncome, | ||
heightSpan, | ||
crossChain | ||
heightSpan | ||
); | ||
@@ -477,0 +480,0 @@ const rawTx = msg.newStdTx([msgCreateAtomicSwap]); |
@@ -1,2 +0,2 @@ | ||
const sig = require("@tendermint/sig"); | ||
const sig = require("@kava-labs/sig"); | ||
const bech32 = require("bech32"); | ||
@@ -3,0 +3,0 @@ const bip39 = require("bip39"); |
@@ -6,4 +6,6 @@ const _ = require("lodash"); | ||
// newStdTx creates a new StdTx from some messages, with default values for fees, memo and sigs | ||
function newStdTx(msgs, fee = defaultFee, memo = "", signatures = []) { | ||
function newStdTx(msgs, fee = defaultFee, memo = "", signatures = null) { | ||
return { | ||
type: "cosmos-sdk/StdTx", | ||
value: { | ||
msg: msgs, | ||
@@ -13,2 +15,3 @@ fee: fee, | ||
memo: memo | ||
}, | ||
}; | ||
@@ -23,3 +26,3 @@ } | ||
function newMsgSend(address, to, coins) { | ||
return { | ||
const sendTx = { | ||
type: "cosmos-sdk/MsgSend", | ||
@@ -32,2 +35,3 @@ value: { | ||
}; | ||
return sendTx | ||
} | ||
@@ -126,3 +130,2 @@ | ||
amount, | ||
expectedIncome, | ||
heightSpan, | ||
@@ -141,3 +144,2 @@ crossChain | ||
amount: amount, | ||
expected_income: String(expectedIncome), | ||
height_span: String(heightSpan), | ||
@@ -144,0 +146,0 @@ cross_chain: crossChain |
@@ -1,2 +0,2 @@ | ||
const sig = require("@tendermint/sig"); | ||
const sig = require("@kava-labs/sig"); | ||
const _ = require("lodash"); | ||
@@ -85,3 +85,3 @@ const axios = require("axios"); | ||
const url = new URL(api.postTx, base).toString(); | ||
txRes = await axios.post(url, sig.createBroadcastTx(tx, "block")); | ||
txRes = await axios.post(url, sig.createBroadcastTx(tx.value, "async")); | ||
} catch (err) { | ||
@@ -88,0 +88,0 @@ // Log status and error or network error |
@@ -109,2 +109,15 @@ const SHA256 = require("crypto-js/sha256"); | ||
/** | ||
* Formats a denom and amount into Cosmos-SDK compatible sdk.Coin object | ||
* @param {String} amount value of the asset | ||
* @param {String} denom name of the asset | ||
* @return {object} resulting formatted coin | ||
*/ | ||
const formatCoin = (amount, denom) => { | ||
return { | ||
denom: String(denom), | ||
amount: String(amount) | ||
}; | ||
}; | ||
/** | ||
* Formats a denom and amount into Cosmos-SDK compatible sdk.Coins object | ||
@@ -124,2 +137,26 @@ * @param {String} amount value of the asset | ||
/** | ||
* Formats an array of denoms and amounts into Cosmos-SDK compatible sdk.Coins object | ||
* @param {String} amounts an array of asset amounts | ||
* @param {String} denoms an array of asset denoms | ||
* @return {object} resulting formatted coins | ||
*/ | ||
const formatMultiCoins = (amounts, denoms) => { | ||
try { | ||
if (amounts.length != denoms.lenth) { | ||
throw new Error("Every amount must have exactly 1 corresponding denom."); | ||
} | ||
} catch (err) { | ||
console.log("Error:", err.message); | ||
return; | ||
} | ||
var coins = []; | ||
for(var i = 0; i < amounts.length; i++) { | ||
let coin = formatCoin(amounts[i], denoms[i]) | ||
coins.push(coin) | ||
} | ||
return coins; | ||
}; | ||
module.exports.utils = { | ||
@@ -130,3 +167,5 @@ generateRandomNumber, | ||
convertCoinDecimals, | ||
formatCoins | ||
formatCoin, | ||
formatCoins, | ||
formatMultiCoins | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46835
8
1
9
975
1
+ Added@kava-labs/sig@^0.1.0
+ Addedbip39@^3.0.2
+ Added@kava-labs/sig@0.1.0(transitive)
+ Added@noble/hashes@1.6.0(transitive)
+ Addedbip39@3.1.0(transitive)
- Removed@tendermint/sig@^0.4.1
- Removed@tendermint/sig@0.4.1(transitive)