cosmos-client
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -13,3 +13,3 @@ /** | ||
import { Configuration } from "./configuration"; | ||
import { AxiosInstance } from 'axios'; | ||
import { AxiosInstance } from "axios"; | ||
export declare const BASE_PATH: string; | ||
@@ -16,0 +16,0 @@ /** |
@@ -64,3 +64,2 @@ "use strict"; | ||
exports.BaseAPI = BaseAPI; | ||
; | ||
/** | ||
@@ -67,0 +66,0 @@ * |
@@ -20,1 +20,4 @@ "use strict"; | ||
codec_1.codec.registerCodec("cosmos-sdk/MsgTransferNFT", types_1.MsgTransferNFT, types_1.MsgTransferNFT.fromJSON); | ||
codec_1.codec.registerCodec("cosmos-sdk/MsgEditNFTMetadata", types_1.MsgEditNFTMetadata, types_1.MsgEditNFTMetadata.fromJSON); | ||
codec_1.codec.registerCodec("cosmos-sdk/MsgMintNFT", types_1.MsgMintNFT, types_1.MsgMintNFT.fromJSON); | ||
codec_1.codec.registerCodec("cosmos-sdk/MsgBurnNFT", types_1.MsgBurnNFT, types_1.MsgBurnNFT.fromJSON); |
@@ -1,1 +0,34 @@ | ||
export {}; | ||
import { StdTx } from "../../x/auth"; | ||
import { CosmosSDK } from "../../cosmos-sdk"; | ||
import { BaseReq } from "../../api"; | ||
import { AccAddress } from "../../types"; | ||
export declare function supplyDenomGet(sdk: CosmosSDK, denom: string): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function ownerDelegatorAddrGet(sdk: CosmosSDK, delegatorAddress: AccAddress): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function ownerDelegatorAddrCollectionDenomGet(sdk: CosmosSDK, delegatorAddress: AccAddress, denom: string): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function collectionDenomGet(sdk: CosmosSDK, denom: string): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function DenomsGet(sdk: CosmosSDK): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function collectionDenomNftIdGet(sdk: CosmosSDK, denom: string, id: string): Promise<import("axios").AxiosResponse<any>>; | ||
export declare function mintPost(sdk: CosmosSDK, req: { | ||
base_req: BaseReq; | ||
recipient: string; | ||
denom: string; | ||
id: string; | ||
tokenURI: string; | ||
}): import("axios").AxiosPromise<StdTx>; | ||
export declare function transferPost(sdk: CosmosSDK, req: { | ||
base_req: BaseReq; | ||
denom: string; | ||
id: string; | ||
recipient: string; | ||
}): import("axios").AxiosPromise<StdTx>; | ||
export declare function collectionDenomNftIdBurnMetadataPut(sdk: CosmosSDK, req: { | ||
base_req: BaseReq; | ||
denom: string; | ||
id: string; | ||
tokenURI: string; | ||
}): import("axios").AxiosPromise<StdTx>; | ||
export declare function collectionDenomNftIdBurnPut(sdk: CosmosSDK, req: { | ||
base_req: BaseReq; | ||
denom: string; | ||
id: string; | ||
}): import("axios").AxiosPromise<StdTx>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var auth_1 = require("../../x/auth"); | ||
var axios_1 = __importDefault(require("axios")); | ||
function supplyDenomGet(sdk, denom) { | ||
return axios_1.default.get(sdk.url + "/nft/supply/" + denom); | ||
} | ||
exports.supplyDenomGet = supplyDenomGet; | ||
function ownerDelegatorAddrGet(sdk, delegatorAddress) { | ||
return axios_1.default.get(sdk.url + "/nft/owner/" + delegatorAddress.toBech32()); | ||
} | ||
exports.ownerDelegatorAddrGet = ownerDelegatorAddrGet; | ||
function ownerDelegatorAddrCollectionDenomGet(sdk, delegatorAddress, denom) { | ||
return axios_1.default.get(sdk.url + "/nft/owner/" + delegatorAddress.toBech32() + "/collection/" + denom); | ||
} | ||
exports.ownerDelegatorAddrCollectionDenomGet = ownerDelegatorAddrCollectionDenomGet; | ||
function collectionDenomGet(sdk, denom) { | ||
return axios_1.default.get(sdk.url + "/nft/collection/" + denom); | ||
} | ||
exports.collectionDenomGet = collectionDenomGet; | ||
function DenomsGet(sdk) { | ||
return axios_1.default.get(sdk.url + "/nft/denoms"); | ||
} | ||
exports.DenomsGet = DenomsGet; | ||
function collectionDenomNftIdGet(sdk, denom, id) { | ||
return axios_1.default.get(sdk.url + "/collection/" + denom + "/nft/" + id); | ||
} | ||
exports.collectionDenomNftIdGet = collectionDenomNftIdGet; | ||
function mintPost(sdk, req) { | ||
return sdk.instancifyObjectWithoutAminoJSON(auth_1.StdTx, axios_1.default.post(sdk.url + "/nfts/mint", req)); | ||
} | ||
exports.mintPost = mintPost; | ||
function transferPost(sdk, req) { | ||
return sdk.instancifyObjectWithoutAminoJSON(auth_1.StdTx, axios_1.default.post(sdk.url + "/nfts/transfer", req)); | ||
} | ||
exports.transferPost = transferPost; | ||
function collectionDenomNftIdBurnMetadataPut(sdk, req) { | ||
return sdk.instancifyObjectWithoutAminoJSON(auth_1.StdTx, axios_1.default.put(sdk.url + "/nfts/collection/" + req.denom + "/nft/" + req.id + "/metadata", req)); | ||
} | ||
exports.collectionDenomNftIdBurnMetadataPut = collectionDenomNftIdBurnMetadataPut; | ||
function collectionDenomNftIdBurnPut(sdk, req) { | ||
return sdk.instancifyObjectWithoutAminoJSON(auth_1.StdTx, axios_1.default.put(sdk.url + "/nfts/collection/" + req.denom + "/nft/" + req.id + "/burn", req)); | ||
} | ||
exports.collectionDenomNftIdBurnPut = collectionDenomNftIdBurnPut; |
import { Msg } from "../../../types/msg"; | ||
import { AccAddress } from "../../../types/address/acc-address"; | ||
export declare class MsgBurnNFT implements Msg { | ||
sender: AccAddress; | ||
id: string; | ||
denom: string; | ||
Sender: AccAddress; | ||
ID: string; | ||
Denom: string; | ||
/** | ||
* @param sender | ||
* @param id | ||
* @param denom | ||
* @param Sender | ||
* @param ID | ||
* @param Denom | ||
*/ | ||
constructor(sender: AccAddress, id: string, denom: string); | ||
constructor(Sender: AccAddress, ID: string, Denom: string); | ||
static fromJSON(value: any): MsgBurnNFT; | ||
} |
@@ -6,13 +6,13 @@ "use strict"; | ||
/** | ||
* @param sender | ||
* @param id | ||
* @param denom | ||
* @param Sender | ||
* @param ID | ||
* @param Denom | ||
*/ | ||
function MsgBurnNFT(sender, id, denom) { | ||
this.sender = sender; | ||
this.id = id; | ||
this.denom = denom; | ||
function MsgBurnNFT(Sender, ID, Denom) { | ||
this.Sender = Sender; | ||
this.ID = ID; | ||
this.Denom = Denom; | ||
} | ||
MsgBurnNFT.fromJSON = function (value) { | ||
return new MsgBurnNFT(acc_address_1.AccAddress.fromBech32(value.sender), value.id, value.denom); | ||
return new MsgBurnNFT(acc_address_1.AccAddress.fromBech32(value.Sender), value.ID, value.Denom); | ||
}; | ||
@@ -19,0 +19,0 @@ return MsgBurnNFT; |
import { Msg } from "../../../types/msg"; | ||
import { AccAddress } from "../../../types/address/acc-address"; | ||
export declare class MsgEditNFTMetadata implements Msg { | ||
sender: AccAddress; | ||
id: string; | ||
denom: string; | ||
token_uri: string; | ||
Sender: AccAddress; | ||
ID: string; | ||
Denom: string; | ||
TokenURI: string; | ||
/** | ||
* @param sender | ||
* @param id | ||
* @param denom | ||
* @param token_rui | ||
* @param Sender | ||
* @param ID | ||
* @param Denom | ||
* @param TokenURI | ||
*/ | ||
constructor(sender: AccAddress, id: string, denom: string, token_uri: string); | ||
constructor(Sender: AccAddress, ID: string, Denom: string, TokenURI: string); | ||
static fromJSON(value: any): MsgEditNFTMetadata; | ||
} |
@@ -6,15 +6,15 @@ "use strict"; | ||
/** | ||
* @param sender | ||
* @param id | ||
* @param denom | ||
* @param token_rui | ||
* @param Sender | ||
* @param ID | ||
* @param Denom | ||
* @param TokenURI | ||
*/ | ||
function MsgEditNFTMetadata(sender, id, denom, token_uri) { | ||
this.sender = sender; | ||
this.id = id; | ||
this.denom = denom; | ||
this.token_uri = token_uri; | ||
function MsgEditNFTMetadata(Sender, ID, Denom, TokenURI) { | ||
this.Sender = Sender; | ||
this.ID = ID; | ||
this.Denom = Denom; | ||
this.TokenURI = TokenURI; | ||
} | ||
MsgEditNFTMetadata.fromJSON = function (value) { | ||
return new MsgEditNFTMetadata(acc_address_1.AccAddress.fromBech32(value.sender), value.id, value.denom, value.token_uri); | ||
return new MsgEditNFTMetadata(acc_address_1.AccAddress.fromBech32(value.Sender), value.ID, value.Denom, value.TokenURI); | ||
}; | ||
@@ -21,0 +21,0 @@ return MsgEditNFTMetadata; |
import { Msg } from "../../../types/msg"; | ||
import { AccAddress } from "../../../types/address/acc-address"; | ||
export declare class MsgMintNFT implements Msg { | ||
sender: AccAddress; | ||
recipient: AccAddress; | ||
id: string; | ||
denom: string; | ||
token_uri: string; | ||
Sender: AccAddress; | ||
Recipient: AccAddress; | ||
ID: string; | ||
Denom: string; | ||
TokenURI: string; | ||
/** | ||
* @param sender | ||
* @param recipient | ||
* @param id | ||
* @param denom | ||
* @param token_uri | ||
* @param Sender | ||
* @param Recipient | ||
* @param ID | ||
* @param Denom | ||
* @param TokenURI | ||
*/ | ||
constructor(sender: AccAddress, recipient: AccAddress, id: string, denom: string, token_uri: string); | ||
constructor(Sender: AccAddress, Recipient: AccAddress, ID: string, Denom: string, TokenURI: string); | ||
static fromJSON(value: any): MsgMintNFT; | ||
} |
@@ -6,17 +6,17 @@ "use strict"; | ||
/** | ||
* @param sender | ||
* @param recipient | ||
* @param id | ||
* @param denom | ||
* @param token_uri | ||
* @param Sender | ||
* @param Recipient | ||
* @param ID | ||
* @param Denom | ||
* @param TokenURI | ||
*/ | ||
function MsgMintNFT(sender, recipient, id, denom, token_uri) { | ||
this.sender = sender; | ||
this.recipient = recipient; | ||
this.id = id; | ||
this.denom = denom; | ||
this.token_uri = token_uri; | ||
function MsgMintNFT(Sender, Recipient, ID, Denom, TokenURI) { | ||
this.Sender = Sender; | ||
this.Recipient = Recipient; | ||
this.ID = ID; | ||
this.Denom = Denom; | ||
this.TokenURI = TokenURI; | ||
} | ||
MsgMintNFT.fromJSON = function (value) { | ||
return new MsgMintNFT(acc_address_1.AccAddress.fromBech32(value.sender), acc_address_1.AccAddress.fromBech32(value.recipient), value.id, value.denom, value.token_uri); | ||
return new MsgMintNFT(acc_address_1.AccAddress.fromBech32(value.Sender ? value.Sender : value.Recipient), acc_address_1.AccAddress.fromBech32(value.Recipient), value.ID, value.Denom, value.TokenURI); | ||
}; | ||
@@ -23,0 +23,0 @@ return MsgMintNFT; |
import { AccAddress } from "../../../types/address/acc-address"; | ||
import { Msg } from "../../../types/msg"; | ||
export declare class MsgTransferNFT implements Msg { | ||
sender: AccAddress; | ||
recipient: AccAddress; | ||
denom: string; | ||
id: string; | ||
constructor(sender: AccAddress, recipient: AccAddress, denom: string, id: string); | ||
Sender: AccAddress; | ||
Recipient: AccAddress; | ||
Denom: string; | ||
ID: string; | ||
constructor(Sender: AccAddress, Recipient: AccAddress, Denom: string, ID: string); | ||
static fromJSON(value: any): MsgTransferNFT; | ||
} |
@@ -5,10 +5,10 @@ "use strict"; | ||
var MsgTransferNFT = /** @class */ (function () { | ||
function MsgTransferNFT(sender, recipient, denom, id) { | ||
this.sender = sender; | ||
this.recipient = recipient; | ||
this.denom = denom; | ||
this.id = id; | ||
function MsgTransferNFT(Sender, Recipient, Denom, ID) { | ||
this.Sender = Sender; | ||
this.Recipient = Recipient; | ||
this.Denom = Denom; | ||
this.ID = ID; | ||
} | ||
MsgTransferNFT.fromJSON = function (value) { | ||
return new MsgTransferNFT(acc_address_1.AccAddress.fromBech32(value.sender), acc_address_1.AccAddress.fromBech32(value.recipient), value.denom, value.id); | ||
return new MsgTransferNFT(acc_address_1.AccAddress.fromBech32(value.Sender), acc_address_1.AccAddress.fromBech32(value.Recipient), value.Denom, value.ID); | ||
}; | ||
@@ -15,0 +15,0 @@ return MsgTransferNFT; |
{ | ||
"name": "cosmos-client", | ||
"description": "REST API Client for Cosmos SDK Blockchain", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"author": "LCNEM, Inc.", | ||
@@ -20,8 +20,6 @@ "bugs": { | ||
"@types/bech32": "^1.1.1", | ||
"@types/jest": "^25.2.1", | ||
"@types/tiny-secp256k1": "^1.0.0", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^5.0.4", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-jasmine": "^3.1.1", | ||
"karma-typescript-preprocessor": "^0.4.0", | ||
"jest": "^26.0.1", | ||
"ts-jest": "^25.5.1", | ||
"typescript": "^3.8.3" | ||
@@ -41,2 +39,3 @@ }, | ||
"scripts": { | ||
"test": "jest", | ||
"build": "tsc --build --clean && tsc", | ||
@@ -43,0 +42,0 @@ "publish": "node bundle && cd dist && npm publish" |
@@ -21,4 +21,6 @@ # cosmos-client-ts | ||
// get account info | ||
let fromAddress: AccAddress; | ||
let privKey: PrivKeyEd25519; | ||
let fromAddress: AccAddress = AccAddress.fromPublicKey( | ||
privKey.getPubKey().toBuffer() | ||
); | ||
const account = await auth | ||
@@ -25,0 +27,0 @@ .accountsAddressGet(sdk, fromAddress) |
@@ -17,3 +17,3 @@ /// <reference types="node" /> | ||
*/ | ||
getPubKey(): PubKey; | ||
getPubKey(): PubKeyEd25519; | ||
/** | ||
@@ -35,3 +35,6 @@ * | ||
*/ | ||
toJSON(): string; | ||
toJSON(): { | ||
type: string; | ||
value: string; | ||
}; | ||
/** | ||
@@ -55,7 +58,6 @@ * | ||
/** | ||
* | ||
* @param message | ||
* message is not needed | ||
* @param signature | ||
*/ | ||
verify(_: Buffer, signature: Buffer): boolean; | ||
verify(signature: Buffer): boolean; | ||
/** | ||
@@ -72,3 +74,6 @@ * | ||
*/ | ||
toJSON(): string; | ||
toJSON(): { | ||
type: string; | ||
value: string; | ||
}; | ||
/** | ||
@@ -75,0 +80,0 @@ * |
@@ -20,3 +20,3 @@ "use strict"; | ||
function PrivKeyEd25519(privKey) { | ||
var keypair = nacl.sign.keyPair.fromSeed(privKey); | ||
var keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(privKey)); | ||
this.pubKey = new PubKeyEd25519(Buffer.from(keypair.publicKey)); | ||
@@ -36,4 +36,4 @@ this.privKey = privKey; | ||
PrivKeyEd25519.prototype.sign = function (message) { | ||
var keypair = nacl.sign.keyPair.fromSeed(this.privKey); | ||
return Buffer.from(nacl.sign(message, keypair.secretKey)); | ||
var keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(this.privKey)); | ||
return Buffer.from(nacl.sign(new Uint8Array(message), new Uint8Array(keypair.secretKey))); | ||
}; | ||
@@ -56,3 +56,3 @@ /** | ||
PrivKeyEd25519.prototype.toJSON = function () { | ||
return this.toBase64(); | ||
return { type: "tendermint/PrivKeyEd25519", value: this.toBase64() }; | ||
}; | ||
@@ -85,8 +85,8 @@ /** | ||
/** | ||
* | ||
* @param message | ||
* message is not needed | ||
* @param signature | ||
*/ | ||
PubKeyEd25519.prototype.verify = function (_, signature) { | ||
return nacl.sign.open(signature, this.pubKey) !== null; | ||
PubKeyEd25519.prototype.verify = function (signature) { | ||
return (nacl.sign.open(new Uint8Array(signature), new Uint8Array(this.pubKey)) !== | ||
null); | ||
}; | ||
@@ -109,3 +109,3 @@ /** | ||
PubKeyEd25519.prototype.toJSON = function () { | ||
return this.toBase64(); | ||
return { type: "tendermint/PubKeyEd25519", value: this.toBase64() }; | ||
}; | ||
@@ -112,0 +112,0 @@ /** |
@@ -11,3 +11,3 @@ /// <reference types="node" /> | ||
toBase64(): string; | ||
verify(message: Buffer, signature: Buffer): boolean; | ||
verify(signature: Buffer, message?: Buffer): boolean; | ||
}; |
@@ -17,3 +17,3 @@ /// <reference types="node" /> | ||
*/ | ||
getPubKey(): PubKey; | ||
getPubKey(): PubKeySecp256k1; | ||
/** | ||
@@ -35,3 +35,6 @@ * | ||
*/ | ||
toJSON(): string; | ||
toJSON(): { | ||
type: string; | ||
value: string; | ||
}; | ||
/** | ||
@@ -59,3 +62,3 @@ * | ||
*/ | ||
verify(message: Buffer, signature: Buffer): boolean; | ||
verify(signature: Buffer, message: Buffer): boolean; | ||
/** | ||
@@ -72,3 +75,6 @@ * | ||
*/ | ||
toJSON(): string; | ||
toJSON(): { | ||
type: string; | ||
value: string; | ||
}; | ||
/** | ||
@@ -75,0 +81,0 @@ * |
@@ -55,3 +55,3 @@ "use strict"; | ||
PrivKeySecp256k1.prototype.toJSON = function () { | ||
return this.toBase64(); | ||
return { type: "tendermint/PrivKeySecp256k1", value: this.toBase64() }; | ||
}; | ||
@@ -88,3 +88,3 @@ /** | ||
*/ | ||
PubKeySecp256k1.prototype.verify = function (message, signature) { | ||
PubKeySecp256k1.prototype.verify = function (signature, message) { | ||
var hash = crypto.createHash("sha256").update(message).digest(); | ||
@@ -109,3 +109,3 @@ return secp256k1.verify(hash, signature, this.pubKey); | ||
PubKeySecp256k1.prototype.toJSON = function () { | ||
return this.toBase64(); | ||
return { type: "tendermint/PubKeySecp256k1", value: this.toBase64() }; | ||
}; | ||
@@ -112,0 +112,0 @@ /** |
/// <reference types="node" /> | ||
export declare enum Prefix { | ||
Cosmos = "cosmos", | ||
Public = "pub", | ||
Account = "acc", | ||
Validator = "val", | ||
Operator = "oper", | ||
Consensus = "cons" | ||
} | ||
export declare const bech32Prefix: { | ||
accAddr: string; | ||
accPub: string; | ||
valAddr: string; | ||
valPub: string; | ||
consAddr: string; | ||
consPub: string; | ||
[key: string]: string; | ||
}; | ||
@@ -18,3 +21,2 @@ /** | ||
* @param value | ||
* @throws Error アドレスの長さが20でない場合、エラーがスローされます。 | ||
*/ | ||
@@ -28,2 +30,12 @@ constructor(value: Buffer); | ||
static fromPublicKey(publicKey: Buffer): Address; | ||
/** | ||
* | ||
* @param accAddr | ||
* @param accPub | ||
* @param valAddr | ||
* @param valPub | ||
* @param consAddr | ||
* @param consPub | ||
*/ | ||
static setBech32Prefix(accAddr: string, accPub: string, valAddr: string, valPub: string, consAddr: string, consPub: string): void; | ||
} |
@@ -11,17 +11,18 @@ "use strict"; | ||
var crypto = __importStar(require("crypto")); | ||
var prefix = { | ||
cosmos: "cosmos", | ||
public: "pub", | ||
account: "acc", | ||
validator: "val", | ||
operator: "oper", | ||
consensus: "cons", | ||
}; | ||
var Prefix; | ||
(function (Prefix) { | ||
Prefix["Cosmos"] = "cosmos"; | ||
Prefix["Public"] = "pub"; | ||
Prefix["Account"] = "acc"; | ||
Prefix["Validator"] = "val"; | ||
Prefix["Operator"] = "oper"; | ||
Prefix["Consensus"] = "cons"; | ||
})(Prefix = exports.Prefix || (exports.Prefix = {})); | ||
exports.bech32Prefix = { | ||
accAddr: prefix.cosmos, | ||
accPub: prefix.cosmos + prefix.public, | ||
valAddr: prefix.cosmos + prefix.validator + prefix.operator, | ||
valPub: prefix.cosmos + prefix.validator + prefix.operator + prefix.public, | ||
consAddr: prefix.cosmos + prefix.validator + prefix.consensus, | ||
consPub: prefix.cosmos + prefix.validator + prefix.consensus + prefix.public, | ||
accAddr: Prefix.Cosmos, | ||
accPub: Prefix.Cosmos + Prefix.Public, | ||
valAddr: Prefix.Cosmos + Prefix.Validator + Prefix.Operator, | ||
valPub: Prefix.Cosmos + Prefix.Validator + Prefix.Operator + Prefix.Public, | ||
consAddr: Prefix.Cosmos + Prefix.Validator + Prefix.Consensus, | ||
consPub: Prefix.Cosmos + Prefix.Validator + Prefix.Consensus + Prefix.Public, | ||
}; | ||
@@ -35,3 +36,2 @@ /** | ||
* @param value | ||
* @throws Error アドレスの長さが20でない場合、エラーがスローされます。 | ||
*/ | ||
@@ -41,3 +41,3 @@ function Address(value) { | ||
if (value.length !== addressLength) { | ||
throw Error(); | ||
throw Error("Address must be 20 bytes length."); | ||
} | ||
@@ -65,4 +65,21 @@ this._value = value; | ||
}; | ||
/** | ||
* | ||
* @param accAddr | ||
* @param accPub | ||
* @param valAddr | ||
* @param valPub | ||
* @param consAddr | ||
* @param consPub | ||
*/ | ||
Address.setBech32Prefix = function (accAddr, accPub, valAddr, valPub, consAddr, consPub) { | ||
exports.bech32Prefix.accAddr = accAddr; | ||
exports.bech32Prefix.accPub = accPub; | ||
exports.bech32Prefix.valAddr = valAddr; | ||
exports.bech32Prefix.valPub = valPub; | ||
exports.bech32Prefix.consAddr = consAddr; | ||
exports.bech32Prefix.consPub = consPub; | ||
}; | ||
return Address; | ||
}()); | ||
exports.Address = Address; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var crypto = __importStar(require("crypto")); | ||
var acc_address_1 = require("./acc-address"); | ||
var tendermint_1 = require("../../tendermint"); | ||
var val_address_1 = require("./val-address"); | ||
test("address", function () { | ||
var bytes = crypto.randomBytes(32); | ||
var key = new tendermint_1.PrivKeyEd25519(bytes); | ||
var address = acc_address_1.AccAddress.fromPublicKey(key.getPubKey().toBuffer()); | ||
var str = address.toBech32(); | ||
var revived = acc_address_1.AccAddress.fromBech32(str); | ||
expect(revived.toBech32()).toEqual(str); | ||
var valAddress = val_address_1.ValAddress.fromPublicKey(key.getPubKey().toBuffer()); | ||
expect(address.toBech32().split("1")[1].length).toEqual(valAddress.toBech32().split("1")[1].length); | ||
}); |
@@ -26,3 +26,3 @@ "use strict"; | ||
}; | ||
var newStdTx = new std_tx_1.StdTx(stdTx.msg, stdTx.fee, __spreadArrays(stdTx.signatures, [signature]), stdTx.memo); | ||
var newStdTx = new std_tx_1.StdTx(stdTx.msg, stdTx.fee, stdTx.signatures ? __spreadArrays(stdTx.signatures, [signature]) : [signature], stdTx.memo); | ||
return newStdTx; | ||
@@ -29,0 +29,0 @@ } |
import { AccAddress } from "../../../types/address/acc-address"; | ||
import { PubKey } from "../../../tendermint/types/key"; | ||
import { Coin } from "../../../api"; | ||
/** | ||
@@ -7,4 +8,5 @@ * | ||
export declare class BaseAccount { | ||
address: AccAddress; | ||
public_key: PubKey; | ||
address?: AccAddress | undefined; | ||
public_key?: PubKey | undefined; | ||
coins: Coin[]; | ||
account_number: number; | ||
@@ -16,6 +18,7 @@ sequence: number; | ||
* @param public_key | ||
* @param coins | ||
* @param account_number | ||
* @param sequence | ||
*/ | ||
constructor(address: AccAddress, public_key: PubKey, account_number: number, sequence: number); | ||
constructor(address?: AccAddress | undefined, public_key?: PubKey | undefined, coins?: Coin[], account_number?: number, sequence?: number); | ||
/** | ||
@@ -22,0 +25,0 @@ * |
@@ -12,8 +12,13 @@ "use strict"; | ||
* @param public_key | ||
* @param coins | ||
* @param account_number | ||
* @param sequence | ||
*/ | ||
function BaseAccount(address, public_key, account_number, sequence) { | ||
function BaseAccount(address, public_key, coins, account_number, sequence) { | ||
if (coins === void 0) { coins = []; } | ||
if (account_number === void 0) { account_number = 0; } | ||
if (sequence === void 0) { sequence = 0; } | ||
this.address = address; | ||
this.public_key = public_key; | ||
this.coins = coins; | ||
this.account_number = account_number; | ||
@@ -27,3 +32,3 @@ this.sequence = sequence; | ||
BaseAccount.fromJSON = function (value) { | ||
return new BaseAccount(acc_address_1.AccAddress.fromBech32(value.address), value.public_key, value.account_number, value.sequence); | ||
return new BaseAccount(!!value.address ? acc_address_1.AccAddress.fromBech32(value.address) : undefined, !!value.public_key ? value.public_key : undefined, value.coins, value.account_number, value.sequence); | ||
}; | ||
@@ -30,0 +35,0 @@ return BaseAccount; |
@@ -13,3 +13,3 @@ /// <reference types="node" /> | ||
fee: StdTxFee; | ||
signatures: StdSignature[]; | ||
signatures: StdSignature[] | null; | ||
memo: string; | ||
@@ -23,3 +23,3 @@ /** | ||
*/ | ||
constructor(msg: (Msg | codec.AminoWrapping)[], fee: StdTxFee, signatures: StdSignature[], memo: string); | ||
constructor(msg: (Msg | codec.AminoWrapping)[], fee: StdTxFee, signatures: StdSignature[] | null, memo: string); | ||
getSignBytes(chainID: string, accountNumber: number, sequence: number): Buffer; | ||
@@ -26,0 +26,0 @@ toObject(): StdTxObject; |
Sorry, the diff of this file is too big to display
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
815967
7
335
19170
56