Socket
Socket
Sign inDemoInstall

@bundlr-network/cosmos

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bundlr-network/cosmos - npm Package Compare versions

Comparing version 0.0.1-rc2 to 0.0.1-rc3

2

cjs/node/index.d.ts

@@ -21,3 +21,2 @@ import BigNumber from "bignumber.js";

signerInstance: CosmosSigner;
readyPromise: Promise<void>;
private localConfig;

@@ -40,3 +39,2 @@ path: HdPath;

getPublicKey(): string | Buffer;
ready(): Promise<void>;
getGas(): Promise<[BigNumber, number]>;

@@ -43,0 +41,0 @@ }

61

cjs/node/index.js

@@ -49,2 +49,6 @@ "use strict";

const crypto_1 = require("@cosmjs/crypto");
const encoding_1 = require("@cosmjs/encoding");
const crypto_2 = __importDefault(require("crypto"));
const elliptic_1 = require("elliptic");
const bn_js_1 = __importDefault(require("bn.js"));
class CosmosConfig extends currency_1.default {

@@ -55,3 +59,37 @@ constructor(config) {

this.base = [this.localConfig.denomination, this.localConfig.decimals];
this.readyPromise = this.ready();
const path2number = new bignumber_js_1.default(this.localConfig.derivePath).toNumber();
this.path = [
crypto_1.Slip10RawIndex.hardened(44),
crypto_1.Slip10RawIndex.hardened(path2number),
crypto_1.Slip10RawIndex.hardened(0),
crypto_1.Slip10RawIndex.normal(0),
crypto_1.Slip10RawIndex.normal(0),
];
// const walletSeed = await Bip39.mnemonicToSeed(new EnglishMnemonic(this.wallet));
const mnemonicBytes = (0, encoding_1.toUtf8)(new crypto_1.EnglishMnemonic(this.wallet).toString().normalize("NFKD"));
const salt = "mnemonic"; //no password
const saltBytes = (0, encoding_1.toUtf8)(salt);
const walletSeed = crypto_2.default.pbkdf2Sync(mnemonicBytes, saltBytes, 2048, 64, "sha512");
const slip = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, walletSeed, this.path);
const privkey = slip.privkey;
const secp256k1 = new elliptic_1.ec("secp256k1");
const secp256k1N = new bn_js_1.default("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", "hex");
if (privkey.length !== 32) {
throw new Error("input data is not a valid secp256k1 private key");
}
const keypair = secp256k1.keyFromPrivate(privkey);
if (keypair.validate().result !== true) {
throw new Error("input data is not a valid secp256k1 private key");
}
const privkeyAsBigInteger = new bn_js_1.default(privkey);
if (privkeyAsBigInteger.gte(secp256k1N)) {
throw new Error("input data is not a valid secp256k1 private key");
}
this.keyPair = {
privkey: (0, encoding_1.fromHex)(keypair.getPrivate("hex")),
pubkey: Uint8Array.from(keypair.getPublic("array")),
};
// this.keyPair = await Secp256k1.makeKeypair(slip.privkey);
this.signerInstance = new CosmosSigner_1.default(this.keyPair.privkey, this.localConfig.prefix);
this._address = this.ownerToAddress(this.keyPair.pubkey);
}

@@ -175,23 +213,2 @@ getProvider() {

}
ready() {
return __awaiter(this, void 0, void 0, function* () {
if (this.readyPromise) {
return yield this.readyPromise;
}
const path2number = new bignumber_js_1.default(this.localConfig.derivePath).toNumber();
this.path = [
crypto_1.Slip10RawIndex.hardened(44),
crypto_1.Slip10RawIndex.hardened(path2number),
crypto_1.Slip10RawIndex.hardened(0),
crypto_1.Slip10RawIndex.normal(0),
crypto_1.Slip10RawIndex.normal(0),
];
const walletSeed = yield crypto_1.Bip39.mnemonicToSeed(new crypto_1.EnglishMnemonic(this.wallet));
const slip = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, walletSeed, this.path);
this.keyPair = yield crypto_1.Secp256k1.makeKeypair(slip.privkey);
this.signerInstance = new CosmosSigner_1.default(this.keyPair.privkey, this.localConfig.prefix);
this._address = this.ownerToAddress(this.keyPair.pubkey);
return;
});
}
getGas() {

@@ -198,0 +215,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -21,3 +21,2 @@ import BigNumber from "bignumber.js";

signerInstance: CosmosSigner;
readyPromise: Promise<void>;
private localConfig;

@@ -40,3 +39,2 @@ path: HdPath;

getPublicKey(): string | Buffer;
ready(): Promise<void>;
getGas(): Promise<[BigNumber, number]>;

@@ -43,0 +41,0 @@ }

@@ -10,5 +10,8 @@ import BigNumber from "bignumber.js";

import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Slip10RawIndex, Secp256k1, EnglishMnemonic, Bip39, Slip10, Slip10Curve } from "@cosmjs/crypto";
import { Slip10RawIndex, Secp256k1, EnglishMnemonic, Slip10, Slip10Curve, } from "@cosmjs/crypto";
import { toUtf8, fromHex } from "@cosmjs/encoding";
import Crypto from "crypto";
import { ec } from "elliptic";
import BN from "bn.js";
export default class CosmosConfig extends BaseNodeCurrency {
readyPromise;
localConfig;

@@ -19,3 +22,37 @@ constructor(config) {

this.base = [this.localConfig.denomination, this.localConfig.decimals];
this.readyPromise = this.ready();
const path2number = new BigNumber(this.localConfig.derivePath).toNumber();
this.path = [
Slip10RawIndex.hardened(44),
Slip10RawIndex.hardened(path2number),
Slip10RawIndex.hardened(0),
Slip10RawIndex.normal(0),
Slip10RawIndex.normal(0),
];
// const walletSeed = await Bip39.mnemonicToSeed(new EnglishMnemonic(this.wallet));
const mnemonicBytes = toUtf8(new EnglishMnemonic(this.wallet).toString().normalize("NFKD"));
const salt = "mnemonic"; //no password
const saltBytes = toUtf8(salt);
const walletSeed = Crypto.pbkdf2Sync(mnemonicBytes, saltBytes, 2048, 64, "sha512");
const slip = Slip10.derivePath(Slip10Curve.Secp256k1, walletSeed, this.path);
const privkey = slip.privkey;
const secp256k1 = new ec("secp256k1");
const secp256k1N = new BN("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", "hex");
if (privkey.length !== 32) {
throw new Error("input data is not a valid secp256k1 private key");
}
const keypair = secp256k1.keyFromPrivate(privkey);
if (keypair.validate().result !== true) {
throw new Error("input data is not a valid secp256k1 private key");
}
const privkeyAsBigInteger = new BN(privkey);
if (privkeyAsBigInteger.gte(secp256k1N)) {
throw new Error("input data is not a valid secp256k1 private key");
}
this.keyPair = {
privkey: fromHex(keypair.getPrivate("hex")),
pubkey: Uint8Array.from(keypair.getPublic("array")),
};
// this.keyPair = await Secp256k1.makeKeypair(slip.privkey);
this.signerInstance = new CosmosSigner(this.keyPair.privkey, this.localConfig.prefix);
this._address = this.ownerToAddress(this.keyPair.pubkey);
}

@@ -123,21 +160,2 @@ async getProvider() {

}
async ready() {
if (this.readyPromise) {
return await this.readyPromise;
}
const path2number = new BigNumber(this.localConfig.derivePath).toNumber();
this.path = [
Slip10RawIndex.hardened(44),
Slip10RawIndex.hardened(path2number),
Slip10RawIndex.hardened(0),
Slip10RawIndex.normal(0),
Slip10RawIndex.normal(0),
];
const walletSeed = await Bip39.mnemonicToSeed(new EnglishMnemonic(this.wallet));
const slip = Slip10.derivePath(Slip10Curve.Secp256k1, walletSeed, this.path);
this.keyPair = await Secp256k1.makeKeypair(slip.privkey);
this.signerInstance = new CosmosSigner(this.keyPair.privkey, this.localConfig.prefix);
this._address = this.ownerToAddress(this.keyPair.pubkey);
return;
}
async getGas() {

@@ -144,0 +162,0 @@ return [new BigNumber(await getRedstonePrice("ATOM")), 1e6];

{
"name": "@bundlr-network/cosmos",
"version": "0.0.1-rc2",
"version": "0.0.1-rc3",
"description": "Cosmos Currency for Bundlr",

@@ -27,3 +27,2 @@ "main": "index.js",

],
"peerDependencies": {},
"dependencies": {

@@ -38,5 +37,8 @@ "@bundlr-network/client": "^0.8.0-rc2",

"cosmjs-types": "^0.4.1",
"elliptic": "^6.5.4",
"keccak": "^3.0.2"
},
"devDependencies": {}
"devDependencies": {
"@types/elliptic": "^6.4.14"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc