mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
API typed as object (#94)
encode, encode for signing, and decode ledger are all typed as `object`. linter error disabled.
This commit is contained in:
@@ -28,9 +28,11 @@ function decode(binary: string): JsonObject {
|
||||
* @param json The JSON representation of a transaction
|
||||
* @returns A hex-string of the encoded transaction
|
||||
*/
|
||||
function encode(json: JsonObject): string {
|
||||
function encode(json: object): string {
|
||||
assert(typeof json === "object");
|
||||
return serializeObject(json).toString("hex").toUpperCase();
|
||||
return serializeObject(json as JsonObject)
|
||||
.toString("hex")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,9 +42,11 @@ function encode(json: JsonObject): string {
|
||||
* @param signer string representing the account to sign the transaction with
|
||||
* @returns a hex string of the encoded transaction
|
||||
*/
|
||||
function encodeForSigning(json: JsonObject): string {
|
||||
function encodeForSigning(json: object): string {
|
||||
assert(typeof json === "object");
|
||||
return signingData(json).toString("hex").toUpperCase();
|
||||
return signingData(json as JsonObject)
|
||||
.toString("hex")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,9 +56,11 @@ function encodeForSigning(json: JsonObject): string {
|
||||
* @param signer string representing the account to sign the transaction with
|
||||
* @returns a hex string of the encoded transaction
|
||||
*/
|
||||
function encodeForSigningClaim(json: ClaimObject): string {
|
||||
function encodeForSigningClaim(json: object): string {
|
||||
assert(typeof json === "object");
|
||||
return signingClaimData(json).toString("hex").toUpperCase();
|
||||
return signingClaimData(json as ClaimObject)
|
||||
.toString("hex")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,10 +70,12 @@ function encodeForSigningClaim(json: ClaimObject): string {
|
||||
* @param signer string representing the account to sign the transaction with
|
||||
* @returns a hex string of the encoded transaction
|
||||
*/
|
||||
function encodeForMultisigning(json: JsonObject, signer: string): string {
|
||||
function encodeForMultisigning(json: object, signer: string): string {
|
||||
assert(typeof json === "object");
|
||||
assert.equal(json.SigningPubKey, "");
|
||||
return multiSigningData(json, signer).toString("hex").toUpperCase();
|
||||
assert.equal(json["SigningPubKey"], "");
|
||||
return multiSigningData(json as JsonObject, signer)
|
||||
.toString("hex")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,7 +159,7 @@ function ledgerHash(header: ledgerObject): Hash256 {
|
||||
* @param binary A serialized ledger header
|
||||
* @returns A JSON object describing a ledger header
|
||||
*/
|
||||
function decodeLedgerData(binary: string): ledgerObject {
|
||||
function decodeLedgerData(binary: string): object {
|
||||
assert(typeof binary === "string", "binary must be a hex string");
|
||||
const parser = new BinaryParser(binary);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user