Socket
Socket
Sign inDemoInstall

@keplr-wallet/cosmos

Package Overview
Dependencies
Maintainers
1
Versions
571
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keplr-wallet/cosmos - npm Package Compare versions

Comparing version 0.9.9 to 0.9.10-rc.0

build/adr-36/amino.d.ts

1

build/index.d.ts

@@ -6,1 +6,2 @@ export * from "./account";

export * from "./stargate";
export * from "./adr-36";

@@ -18,2 +18,3 @@ "use strict";

__exportStar(require("./stargate"), exports);
__exportStar(require("./adr-36"), exports);
//# sourceMappingURL=index.js.map

@@ -45,2 +45,3 @@ "use strict";

exports.defaultProtoCodec.registerAny("/cosmos.staking.v1beta1.MsgBeginRedelegate", proto_2.cosmos.staking.v1beta1.MsgBeginRedelegate);
exports.defaultProtoCodec.registerAny("/cosmwasm.wasm.v1.MsgExecuteContract", proto_2.cosmwasm.wasm.v1.MsgExecuteContract);
//# sourceMappingURL=index.js.map

9

build/stargate/wrapper/index.d.ts

@@ -5,9 +5,10 @@ import { ProtoSignDocDecoder } from "../decoder";

export declare class SignDocWrapper {
protected readonly signDoc: StdSignDoc | cosmos.tx.v1beta1.SignDoc;
protected _protoSignDoc?: ProtoSignDocDecoder;
readonly isADR36SignDoc: boolean;
readonly mode: "amino" | "direct";
protected readonly message: Uint8Array;
protected _protoSignDoc?: ProtoSignDocDecoder;
protected _aminoSignDoc?: StdSignDoc;
constructor(mode: "amino" | "direct", message: Uint8Array);
constructor(signDoc: StdSignDoc | cosmos.tx.v1beta1.SignDoc);
static fromAminoSignDoc(signDoc: StdSignDoc): SignDocWrapper;
static fromDirectSignDoc(signDoc: cosmos.tx.v1beta1.SignDoc): SignDocWrapper;
static fromDirectSignDocBytes(signDocBytes: Uint8Array): SignDocWrapper;
clone(): SignDocWrapper;

@@ -14,0 +15,0 @@ get protoSignDoc(): ProtoSignDocDecoder;

@@ -5,24 +5,45 @@ "use strict";

const decoder_1 = require("../decoder");
const buffer_1 = require("buffer/");
const proto_1 = require("../proto");
const adr_36_1 = require("../../adr-36");
class SignDocWrapper {
constructor(mode, message) {
this.mode = mode;
this.message = message;
constructor(signDoc) {
this.signDoc = signDoc;
if ("msgs" in signDoc) {
this.mode = "amino";
}
else {
this.mode = "direct";
}
if (this.mode === "amino") {
// Check that the sign doc is for ADR-36.
// The validation should be performed on the background process.
// So, here, we check once more, but the validation related to bech32 is considered to be done in the background process.
this.isADR36SignDoc = adr_36_1.checkAndValidateADR36AminoSignDoc(this.aminoSignDoc);
}
else {
// Currently, only support amino sign doc for ADR-36
this.isADR36SignDoc = false;
}
}
static fromAminoSignDoc(signDoc) {
const wrapper = new SignDocWrapper("amino", new Uint8Array(0));
wrapper._aminoSignDoc = signDoc;
return wrapper;
return new SignDocWrapper(signDoc);
}
static fromDirectSignDoc(signDoc) {
const wrapper = new SignDocWrapper("direct", new Uint8Array(0));
wrapper._protoSignDoc = new decoder_1.ProtoSignDocDecoder(signDoc);
return wrapper;
return new SignDocWrapper(signDoc);
}
static fromDirectSignDocBytes(signDocBytes) {
return new SignDocWrapper(proto_1.cosmos.tx.v1beta1.SignDoc.decode(signDocBytes));
}
clone() {
return new SignDocWrapper(this.mode, this.message);
return new SignDocWrapper(this.signDoc);
}
get protoSignDoc() {
if (this.mode === "amino") {
throw new Error("Sign doc is encoded as Amino Json");
}
if ("msgs" in this.signDoc) {
throw new Error("Unexpected error");
}
if (!this._protoSignDoc) {
this._protoSignDoc = decoder_1.ProtoSignDocDecoder.decode(this.message);
this._protoSignDoc = new decoder_1.ProtoSignDocDecoder(this.signDoc);
}

@@ -32,7 +53,9 @@ return this._protoSignDoc;

get aminoSignDoc() {
if (!this._aminoSignDoc) {
this._aminoSignDoc = JSON.parse(buffer_1.Buffer.from(this.message).toString());
if (this.mode === "direct") {
throw new Error("Sign doc is encoded as Protobuf");
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._aminoSignDoc;
if (!("msgs" in this.signDoc)) {
throw new Error("Unexpected error");
}
return this.signDoc;
}

@@ -39,0 +62,0 @@ get chainId() {

{
"name": "@keplr-wallet/cosmos",
"version": "0.9.9",
"version": "0.9.10-rc.0",
"main": "build/index.js",

@@ -22,4 +22,5 @@ "author": "chainapsis",

"@cosmjs/launchpad": "^0.24.0-alpha.25",
"@keplr-wallet/types": "^0.9.9",
"@keplr-wallet/unit": "^0.9.9",
"@keplr-wallet/crypto": "^0.9.10-rc.0",
"@keplr-wallet/types": "^0.9.10-rc.0",
"@keplr-wallet/unit": "^0.9.10-rc.0",
"axios": "^0.21.0",

@@ -31,3 +32,3 @@ "bech32": "^1.1.4",

},
"gitHead": "ead06cf2f414219770f0e27a8ab69d166a392b27"
"gitHead": "44cdd98d7397e9975b36af246db80c4faaeebe9e"
}

@@ -6,1 +6,2 @@ export * from "./account";

export * from "./stargate";
export * from "./adr-36";
import { google } from "../proto";
import * as $protobuf from "protobufjs";
import { cosmos } from "../proto";
import { cosmos, cosmwasm } from "../proto";
import { UnknownMessage } from "./unknown";

@@ -60,1 +60,5 @@

);
defaultProtoCodec.registerAny(
"/cosmwasm.wasm.v1.MsgExecuteContract",
cosmwasm.wasm.v1.MsgExecuteContract
);
import { ProtoSignDocDecoder } from "../decoder";
import { Coin, StdSignDoc } from "@cosmjs/launchpad";
import { Buffer } from "buffer/";
import { cosmos } from "../proto";
import { checkAndValidateADR36AminoSignDoc } from "../../adr-36";

@@ -10,28 +10,54 @@ export class SignDocWrapper {

protected _aminoSignDoc?: StdSignDoc;
public readonly isADR36SignDoc: boolean;
public readonly mode: "amino" | "direct";
constructor(
public readonly mode: "amino" | "direct",
protected readonly message: Uint8Array
) {}
protected readonly signDoc: StdSignDoc | cosmos.tx.v1beta1.SignDoc
) {
if ("msgs" in signDoc) {
this.mode = "amino";
} else {
this.mode = "direct";
}
if (this.mode === "amino") {
// Check that the sign doc is for ADR-36.
// The validation should be performed on the background process.
// So, here, we check once more, but the validation related to bech32 is considered to be done in the background process.
this.isADR36SignDoc = checkAndValidateADR36AminoSignDoc(
this.aminoSignDoc
);
} else {
// Currently, only support amino sign doc for ADR-36
this.isADR36SignDoc = false;
}
}
static fromAminoSignDoc(signDoc: StdSignDoc) {
const wrapper = new SignDocWrapper("amino", new Uint8Array(0));
wrapper._aminoSignDoc = signDoc;
return wrapper;
return new SignDocWrapper(signDoc);
}
static fromDirectSignDoc(signDoc: cosmos.tx.v1beta1.SignDoc) {
const wrapper = new SignDocWrapper("direct", new Uint8Array(0));
wrapper._protoSignDoc = new ProtoSignDocDecoder(signDoc);
return wrapper;
return new SignDocWrapper(signDoc);
}
static fromDirectSignDocBytes(signDocBytes: Uint8Array) {
return new SignDocWrapper(cosmos.tx.v1beta1.SignDoc.decode(signDocBytes));
}
clone(): SignDocWrapper {
return new SignDocWrapper(this.mode, this.message);
return new SignDocWrapper(this.signDoc);
}
get protoSignDoc(): ProtoSignDocDecoder {
if (this.mode === "amino") {
throw new Error("Sign doc is encoded as Amino Json");
}
if ("msgs" in this.signDoc) {
throw new Error("Unexpected error");
}
if (!this._protoSignDoc) {
this._protoSignDoc = ProtoSignDocDecoder.decode(this.message);
this._protoSignDoc = new ProtoSignDocDecoder(this.signDoc);
}

@@ -43,8 +69,10 @@

get aminoSignDoc(): StdSignDoc {
if (!this._aminoSignDoc) {
this._aminoSignDoc = JSON.parse(Buffer.from(this.message).toString());
if (this.mode === "direct") {
throw new Error("Sign doc is encoded as Protobuf");
}
if (!("msgs" in this.signDoc)) {
throw new Error("Unexpected error");
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._aminoSignDoc!;
return this.signDoc;
}

@@ -51,0 +79,0 @@

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

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