@cosmjs/launchpad
Advanced tools
Comparing version 0.22.0 to 0.22.1
@@ -57,3 +57,5 @@ "use strict"; | ||
var pubkey_1 = require("./pubkey"); | ||
Object.defineProperty(exports, "decodeAminoPubkey", { enumerable: true, get: function () { return pubkey_1.decodeAminoPubkey; } }); | ||
Object.defineProperty(exports, "decodeBech32Pubkey", { enumerable: true, get: function () { return pubkey_1.decodeBech32Pubkey; } }); | ||
Object.defineProperty(exports, "encodeAminoPubkey", { enumerable: true, get: function () { return pubkey_1.encodeAminoPubkey; } }); | ||
Object.defineProperty(exports, "encodeBech32Pubkey", { enumerable: true, get: function () { return pubkey_1.encodeBech32Pubkey; } }); | ||
@@ -60,0 +62,0 @@ Object.defineProperty(exports, "encodeSecp256k1Pubkey", { enumerable: true, get: function () { return pubkey_1.encodeSecp256k1Pubkey; } }); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encodeBech32Pubkey = exports.decodeBech32Pubkey = exports.encodeSecp256k1Pubkey = void 0; | ||
exports.encodeBech32Pubkey = exports.encodeAminoPubkey = exports.decodeBech32Pubkey = exports.decodeAminoPubkey = exports.encodeSecp256k1Pubkey = void 0; | ||
const encoding_1 = require("@cosmjs/encoding"); | ||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal")); | ||
const utils_1 = require("@cosmjs/utils"); | ||
const types_1 = require("./types"); | ||
@@ -27,7 +24,9 @@ function encodeSecp256k1Pubkey(pubkey) { | ||
const pubkeyAminoPrefixLength = pubkeyAminoPrefixSecp256k1.length; | ||
function decodeBech32Pubkey(bechEncoded) { | ||
const { data } = encoding_1.Bech32.decode(bechEncoded); | ||
/** | ||
* Decodes a pubkey in the Amino binary format to a type/value object. | ||
*/ | ||
function decodeAminoPubkey(data) { | ||
const aminoPrefix = data.slice(0, pubkeyAminoPrefixLength); | ||
const rest = data.slice(pubkeyAminoPrefixLength); | ||
if (fast_deep_equal_1.default(aminoPrefix, pubkeyAminoPrefixSecp256k1)) { | ||
if (utils_1.arrayContentEquals(aminoPrefix, pubkeyAminoPrefixSecp256k1)) { | ||
if (rest.length !== 33) { | ||
@@ -41,3 +40,3 @@ throw new Error("Invalid rest data length. Expected 33 bytes (compressed secp256k1 pubkey)."); | ||
} | ||
else if (fast_deep_equal_1.default(aminoPrefix, pubkeyAminoPrefixEd25519)) { | ||
else if (utils_1.arrayContentEquals(aminoPrefix, pubkeyAminoPrefixEd25519)) { | ||
if (rest.length !== 32) { | ||
@@ -51,3 +50,3 @@ throw new Error("Invalid rest data length. Expected 32 bytes (Ed25519 pubkey)."); | ||
} | ||
else if (fast_deep_equal_1.default(aminoPrefix, pubkeyAminoPrefixSr25519)) { | ||
else if (utils_1.arrayContentEquals(aminoPrefix, pubkeyAminoPrefixSr25519)) { | ||
if (rest.length !== 32) { | ||
@@ -65,4 +64,18 @@ throw new Error("Invalid rest data length. Expected 32 bytes (Sr25519 pubkey)."); | ||
} | ||
exports.decodeAminoPubkey = decodeAminoPubkey; | ||
/** | ||
* Decodes a bech32 pubkey to Amino binary, which is then decoded to a type/value object. | ||
* The bech32 prefix is ignored and discareded. | ||
* | ||
* @param bechEncoded the bech32 encoded pubkey | ||
*/ | ||
function decodeBech32Pubkey(bechEncoded) { | ||
const { data } = encoding_1.Bech32.decode(bechEncoded); | ||
return decodeAminoPubkey(data); | ||
} | ||
exports.decodeBech32Pubkey = decodeBech32Pubkey; | ||
function encodeBech32Pubkey(pubkey, prefix) { | ||
/** | ||
* Encodes a public key to binary Amino. | ||
*/ | ||
function encodeAminoPubkey(pubkey) { | ||
let aminoPrefix; | ||
@@ -74,9 +87,21 @@ switch (pubkey.type) { | ||
break; | ||
case types_1.pubkeyType.ed25519: | ||
aminoPrefix = pubkeyAminoPrefixEd25519; | ||
break; | ||
default: | ||
throw new Error("Unsupported pubkey type"); | ||
} | ||
const data = new Uint8Array([...aminoPrefix, ...encoding_1.fromBase64(pubkey.value)]); | ||
return encoding_1.Bech32.encode(prefix, data); | ||
return new Uint8Array([...aminoPrefix, ...encoding_1.fromBase64(pubkey.value)]); | ||
} | ||
exports.encodeAminoPubkey = encodeAminoPubkey; | ||
/** | ||
* Encodes a public key to binary Amino and then to bech32. | ||
* | ||
* @param pubkey the public key to encode | ||
* @param prefix the bech32 prefix (human readable part) | ||
*/ | ||
function encodeBech32Pubkey(pubkey, prefix) { | ||
return encoding_1.Bech32.encode(prefix, encodeAminoPubkey(pubkey)); | ||
} | ||
exports.encodeBech32Pubkey = encodeBech32Pubkey; | ||
//# sourceMappingURL=pubkey.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pubkeyTypes = exports.pubkeyType = exports.isStdTx = void 0; | ||
exports.pubkeyType = exports.isStdTx = void 0; | ||
function isStdTx(txValue) { | ||
@@ -17,3 +17,2 @@ const { memo, msg, fee, signatures } = txValue; | ||
}; | ||
exports.pubkeyTypes = [exports.pubkeyType.secp256k1, exports.pubkeyType.ed25519, exports.pubkeyType.sr25519]; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@cosmjs/launchpad", | ||
"version": "0.22.0", | ||
"version": "0.22.1", | ||
"description": "A client library for the Cosmos SDK 0.37 (cosmoshub-3), 0.38 and 0.39 (Launchpad)", | ||
@@ -44,8 +44,7 @@ "contributors": [ | ||
"dependencies": { | ||
"@cosmjs/crypto": "^0.22.0", | ||
"@cosmjs/encoding": "^0.22.0", | ||
"@cosmjs/math": "^0.22.0", | ||
"@cosmjs/utils": "^0.22.0", | ||
"axios": "^0.19.0", | ||
"fast-deep-equal": "^3.1.1" | ||
"@cosmjs/crypto": "^0.22.1", | ||
"@cosmjs/encoding": "^0.22.1", | ||
"@cosmjs/math": "^0.22.1", | ||
"@cosmjs/utils": "^0.22.1", | ||
"axios": "^0.19.0" | ||
}, | ||
@@ -55,3 +54,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "3a5c23c2e863744686332dd4c743d93a3b84913d" | ||
"gitHead": "04a086a6cbaa79e52bda62e13913c88d6500139a" | ||
} |
@@ -85,3 +85,9 @@ import * as logs from "./logs"; | ||
export { isMsgDelegate, isMsgSend, Msg, MsgDelegate, MsgSend } from "./msgs"; | ||
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey"; | ||
export { | ||
decodeAminoPubkey, | ||
decodeBech32Pubkey, | ||
encodeAminoPubkey, | ||
encodeBech32Pubkey, | ||
encodeSecp256k1Pubkey, | ||
} from "./pubkey"; | ||
export { findSequenceForSignedTx } from "./sequence"; | ||
@@ -88,0 +94,0 @@ export { encodeSecp256k1Signature, decodeSignature } from "./signature"; |
import { PubKey } from "./types"; | ||
export declare function encodeSecp256k1Pubkey(pubkey: Uint8Array): PubKey; | ||
/** | ||
* Decodes a pubkey in the Amino binary format to a type/value object. | ||
*/ | ||
export declare function decodeAminoPubkey(data: Uint8Array): PubKey; | ||
/** | ||
* Decodes a bech32 pubkey to Amino binary, which is then decoded to a type/value object. | ||
* The bech32 prefix is ignored and discareded. | ||
* | ||
* @param bechEncoded the bech32 encoded pubkey | ||
*/ | ||
export declare function decodeBech32Pubkey(bechEncoded: string): PubKey; | ||
/** | ||
* Encodes a public key to binary Amino. | ||
*/ | ||
export declare function encodeAminoPubkey(pubkey: PubKey): Uint8Array; | ||
/** | ||
* Encodes a public key to binary Amino and then to bech32. | ||
* | ||
* @param pubkey the public key to encode | ||
* @param prefix the bech32 prefix (human readable part) | ||
*/ | ||
export declare function encodeBech32Pubkey(pubkey: PubKey, prefix: string): string; |
@@ -39,2 +39,1 @@ import { Coin } from "./coins"; | ||
}; | ||
export declare const pubkeyTypes: readonly string[]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
185654
5
3255
- Removedfast-deep-equal@^3.1.1
- Removedfast-deep-equal@3.1.3(transitive)
Updated@cosmjs/crypto@^0.22.1
Updated@cosmjs/encoding@^0.22.1
Updated@cosmjs/math@^0.22.1
Updated@cosmjs/utils@^0.22.1