Replace deprecated Encoding class with free functions

This commit is contained in:
Simon Warta 2020-06-04 20:59:23 +02:00
parent 76fa832202
commit 538004a1d6
32 changed files with 68 additions and 118 deletions

View File

@ -1,10 +1,8 @@
import { Algorithm, PubkeyBytes } from "@iov/bcp";
import { Encoding } from "@iov/encoding";
import { fromBase64, fromHex } from "@iov/encoding";
import { pubkeyToAddress } from "./address";
const { fromBase64, fromHex } = Encoding;
describe("address", () => {
describe("pubkeyToAddress", () => {
it("works for Secp256k1 compressed", () => {

View File

@ -1,9 +1,7 @@
import { PubKey, pubkeyToAddress as sdkPubkeyToAddress, pubkeyType } from "@cosmjs/sdk38";
import { Address, Algorithm, PubkeyBundle } from "@iov/bcp";
import { Secp256k1 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
const { toBase64 } = Encoding;
import { toBase64 } from "@iov/encoding";
// See https://github.com/tendermint/tendermint/blob/f2ada0a604b4c0763bda2f64fac53d506d3beca7/docs/spec/blockchain/encoding.md#public-key-cryptography
export function pubkeyToAddress(pubkey: PubkeyBundle, prefix: string): Address {

View File

@ -1,8 +1,6 @@
import { ChainId } from "@iov/bcp";
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
const { toHex, toUtf8 } = Encoding;
import { toHex, toUtf8 } from "@iov/encoding";
const hashedPrefix = "hashed-";

View File

@ -1,12 +1,10 @@
import { PostableBytes, PrehashType } from "@iov/bcp";
import { Encoding } from "@iov/encoding";
import { toUtf8 } from "@iov/encoding";
import { CosmosCodec } from "./cosmoscodec";
import { chainId, nonce, sendTxJson, signedTxBin, signedTxEncodedJson, signedTxJson } from "./testdata.spec";
import { BankToken } from "./types";
const { toUtf8 } = Encoding;
const defaultPrefix = "cosmos";
const defaultBankTokens: readonly BankToken[] = [

View File

@ -18,7 +18,7 @@ import {
UnsignedTransaction,
} from "@iov/bcp";
import { Random, Secp256k1, Secp256k1Signature, Sha256 } from "@iov/crypto";
import { Bech32, Encoding } from "@iov/encoding";
import { Bech32, fromBase64 } from "@iov/encoding";
import { HdPaths, Secp256k1HdWallet, UserProfile } from "@iov/keycontrol";
import { assert } from "@iov/utils";
import BN from "bn.js";
@ -27,8 +27,6 @@ import { CosmosConnection, TokenConfiguration } from "./cosmosconnection";
import { encodeFullSignature } from "./encode";
import * as testdata from "./testdata.spec";
const { fromBase64 } = Encoding;
function pendingWithoutWasmd(): void {
if (!process.env.WASMD_ENABLED) {
return pending("Set WASMD_ENABLED to enable Cosmos node-based tests");

View File

@ -35,7 +35,7 @@ import {
TxCodec,
UnsignedTransaction,
} from "@iov/bcp";
import { Encoding, Uint53 } from "@iov/encoding";
import { fromUtf8, Uint53 } from "@iov/encoding";
import { concat, DefaultValueProducer, ValueAndUpdates } from "@iov/stream";
import equal from "fast-deep-equal";
import { ReadonlyDate } from "readonly-date";
@ -255,7 +255,7 @@ export class CosmosConnection implements BlockchainConnection {
}
public async postTx(tx: PostableBytes): Promise<PostTxResponse> {
const txAsJson = JSON.parse(Encoding.fromUtf8(tx));
const txAsJson = JSON.parse(fromUtf8(tx));
if (!isStdTx(txAsJson)) throw new Error("Postable bytes must contain a JSON encoded StdTx");
const { transactionHash, rawLog } = await this.cosmosClient.postTx(txAsJson);
const transactionId = transactionHash as TransactionId;

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Coin, IndexedTx, Msg, PubKey, StdSignature } from "@cosmjs/sdk38";
import { Address, Algorithm, SendTransaction, TokenTicker } from "@iov/bcp";
import { Encoding } from "@iov/encoding";
import { fromBase64, fromHex } from "@iov/encoding";
import {
decodeAmount,
@ -19,8 +19,6 @@ import * as testdata from "./testdata.spec";
import cosmoshub from "./testdata/cosmoshub.json";
import { BankToken } from "./types";
const { fromBase64, fromHex } = Encoding;
describe("decode", () => {
const defaultPubkey = {
algo: Algorithm.Secp256k1,

View File

@ -29,12 +29,10 @@ import {
TransactionId,
UnsignedTransaction,
} from "@iov/bcp";
import { Decimal, Encoding } from "@iov/encoding";
import { Decimal, fromBase64 } from "@iov/encoding";
import { BankToken } from "./types";
const { fromBase64 } = Encoding;
export function decodePubkey(pubkey: PubKey): PubkeyBundle {
switch (pubkey.type) {
case pubkeyType.secp256k1:

View File

@ -11,7 +11,7 @@ import {
SignedTransaction,
TokenTicker,
} from "@iov/bcp";
import { Encoding } from "@iov/encoding";
import { fromBase64 } from "@iov/encoding";
import {
buildSignedTx,
@ -23,8 +23,6 @@ import {
} from "./encode";
import { BankToken } from "./types";
const { fromBase64 } = Encoding;
describe("encode", () => {
const atom = "ATOM" as TokenTicker;
// https://rpc.cosmos.network:26657/tx?hash=0x2268EB5AB730B45F8426078827BB5BB49819CE2B0D74B2C1D191070BADB379F1&prove=true

View File

@ -20,12 +20,10 @@ import {
UnsignedTransaction,
} from "@iov/bcp";
import { Secp256k1 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { toBase64 } from "@iov/encoding";
import { BankToken } from "./types";
const { toBase64 } = Encoding;
// TODO: This function seems to be unused and is not well tested (e.g. uncompressed secp256k1 or ed25519)
export function encodePubkey(pubkey: PubkeyBundle): PubKey {
switch (pubkey.algo) {

View File

@ -12,12 +12,10 @@ import {
TokenTicker,
TransactionId,
} from "@iov/bcp";
import { Encoding } from "@iov/encoding";
import { fromBase64, toUtf8 } from "@iov/encoding";
import data from "./testdata/cosmoshub.json";
const { fromBase64, toUtf8 } = Encoding;
export const pubJson: PubkeyBundle = {
algo: Algorithm.Secp256k1,
data: fromBase64(data.tx.value.signatures[0].pub_key.value) as PubkeyBytes,

View File

@ -102,8 +102,15 @@ export function main(originalArgs: readonly string[]): void {
[
"@iov/encoding",
[
"fromAscii",
"fromBase64",
"fromHex",
"fromUtf8",
"toAscii",
"toBase64",
"toHex",
"toUtf8",
"Bech32",
"Encoding",
"Decimal",
// integers
"Int53",
@ -122,17 +129,6 @@ export function main(originalArgs: readonly string[]): void {
for (const [moduleName, symbols] of imports.entries()) {
console.info(colors.yellow(` * from ${moduleName}: ${symbols.join(", ")}`));
}
const encodingHelpers = [
"fromAscii",
"fromBase64",
"fromHex",
"fromUtf8",
"toAscii",
"toBase64",
"toHex",
"toUtf8",
];
console.info(colors.yellow(` * helper functions: ${encodingHelpers.join(", ")}`));
let init = `
import axios from "axios";
@ -141,8 +137,6 @@ export function main(originalArgs: readonly string[]): void {
for (const [moduleName, symbols] of imports.entries()) {
init += `import { ${symbols.join(", ")} } from "${moduleName}";\n`;
}
// helper functions
init += `const { ${encodingHelpers.join(", ")} } = Encoding;\n`;
if (args.selftest) {
// execute some trival stuff and exit
@ -167,7 +161,7 @@ export function main(originalArgs: readonly string[]): void {
const pen = await Secp256k1Pen.fromMnemonic(mnemonic, makeCosmoshubPath(0));
const pubkey = encodeSecp256k1Pubkey(pen.pubkey);
const address = pubkeyToAddress(pubkey, "cosmos");
const data = Encoding.toAscii("foo bar");
const data = toAscii("foo bar");
const signature = await pen.sign(data);
console.info("Done testing, will exit now.");

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/camelcase */
import { makeSignBytes, MsgSend, Secp256k1Pen, StdFee } from "@cosmjs/sdk38";
import { Sha256 } from "@iov/crypto";
import { Bech32, Encoding } from "@iov/encoding";
import { Bech32, fromHex, fromUtf8, toAscii, toBase64 } from "@iov/encoding";
import { assert, sleep } from "@iov/utils";
import { ReadonlyDate } from "readonly-date";
@ -21,8 +21,6 @@ import {
wasmdEnabled,
} from "./testutils.spec";
const { fromHex, fromUtf8, toAscii, toBase64 } = Encoding;
const guest = {
address: "cosmos17d0jcz59jf68g52vq38tuuncmwwjk42u6mcxej",
};

View File

@ -8,7 +8,7 @@ import {
StdTx,
} from "@cosmjs/sdk38";
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { fromBase64, fromHex, toHex } from "@iov/encoding";
import { Log, parseLogs } from "./logs";
import { RestClient } from "./restclient";
@ -185,7 +185,7 @@ export class CosmWasmClient {
// We consult the REST API because we don't have a local amino encoder
const bytes = await this.restClient.encodeTx(tx);
const hash = new Sha256(bytes).digest();
return Encoding.toHex(hash).toUpperCase();
return toHex(hash).toUpperCase();
}
/**
@ -242,7 +242,7 @@ export class CosmWasmClient {
height: parseInt(response.block.header.height, 10),
chainId: response.block.header.chain_id,
},
txs: (response.block.data.txs || []).map((encoded) => Encoding.fromBase64(encoded)),
txs: (response.block.data.txs || []).map(fromBase64),
};
}
@ -315,7 +315,7 @@ export class CosmWasmClient {
return {
id: entry.id,
creator: entry.creator,
checksum: Encoding.toHex(Encoding.fromHex(entry.data_hash)),
checksum: toHex(fromHex(entry.data_hash)),
source: entry.source || undefined,
builder: entry.builder || undefined,
};
@ -331,10 +331,10 @@ export class CosmWasmClient {
const codeDetails: CodeDetails = {
id: getCodeResult.id,
creator: getCodeResult.creator,
checksum: Encoding.toHex(Encoding.fromHex(getCodeResult.data_hash)),
checksum: toHex(fromHex(getCodeResult.data_hash)),
source: getCodeResult.source || undefined,
builder: getCodeResult.builder || undefined,
data: Encoding.fromBase64(getCodeResult.data),
data: fromBase64(getCodeResult.data),
};
this.codesCache.set(codeId, codeDetails);
return codeDetails;

View File

@ -15,7 +15,7 @@ import {
StdTx,
} from "@cosmjs/sdk38";
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { fromAscii, fromBase64, fromHex, toAscii, toBase64, toHex } from "@iov/encoding";
import { assert, sleep } from "@iov/utils";
import { ReadonlyDate } from "readonly-date";
@ -49,8 +49,6 @@ import {
wasmdEnabled,
} from "./testutils.spec";
const { fromAscii, fromBase64, fromHex, toAscii, toBase64, toHex } = Encoding;
const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k";
function makeSignedTx(firstMsg: Msg, fee: StdFee, memo: string, firstSignature: StdSignature): StdTx {

View File

@ -1,10 +1,8 @@
import { BroadcastMode, CosmosSdkTx, RestClient as BaseRestClient } from "@cosmjs/sdk38";
import { Encoding } from "@iov/encoding";
import { fromBase64, fromUtf8, toHex, toUtf8 } from "@iov/encoding";
import { JsonObject, Model, parseWasmData, WasmData } from "./types";
const { fromBase64, fromUtf8, toHex, toUtf8 } = Encoding;
// Currently all wasm query responses return json-encoded strings...
// later deprecate this and use the specific types for result
// (assuming it is inlined, no second parse needed)

View File

@ -1,6 +1,6 @@
import { Coin, Secp256k1Pen } from "@cosmjs/sdk38";
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { toHex } from "@iov/encoding";
import { assert } from "@iov/utils";
import { PrivateCosmWasmClient } from "./cosmwasmclient";
@ -8,8 +8,6 @@ import { RestClient } from "./restclient";
import { SigningCosmWasmClient, UploadMeta } from "./signingcosmwasmclient";
import { alice, getHackatom, makeRandomAddress, pendingWithoutWasmd } from "./testutils.spec";
const { toHex } = Encoding;
const httpUrl = "http://localhost:1317";
describe("SigningCosmWasmClient", () => {

View File

@ -1,6 +1,6 @@
import { BroadcastMode, Coin, coins, makeSignBytes, MsgSend, StdFee, StdSignature } from "@cosmjs/sdk38";
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { toBase64, toHex } from "@iov/encoding";
import pako from "pako";
import { isValidBuilder } from "./builder";
@ -136,7 +136,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
value: {
sender: this.senderAddress,
// eslint-disable-next-line @typescript-eslint/camelcase
wasm_byte_code: Encoding.toBase64(compressed),
wasm_byte_code: toBase64(compressed),
source: source,
builder: builder,
},
@ -157,9 +157,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
const codeIdAttr = findAttribute(result.logs, "message", "code_id");
return {
originalSize: wasmCode.length,
originalChecksum: Encoding.toHex(new Sha256(wasmCode).digest()),
originalChecksum: toHex(new Sha256(wasmCode).digest()),
compressedSize: compressed.length,
compressedChecksum: Encoding.toHex(new Sha256(compressed).digest()),
compressedChecksum: toHex(new Sha256(compressed).digest()),
codeId: Number.parseInt(codeIdAttr.value, 10),
logs: result.logs,
transactionHash: result.transactionHash,

View File

@ -1,10 +1,10 @@
import { Random } from "@iov/crypto";
import { Bech32, Encoding } from "@iov/encoding";
import { Bech32, fromBase64 } from "@iov/encoding";
import hackatom from "./testdata/contract.json";
export function getHackatom(): Uint8Array {
return Encoding.fromBase64(hackatom.data);
return fromBase64(hackatom.data);
}
export function makeRandomAddress(): string {

View File

@ -1,6 +1,4 @@
import { Encoding } from "@iov/encoding";
const { fromBase64, fromHex } = Encoding;
import { fromBase64, fromHex } from "@iov/encoding";
export interface WasmData {
// key is hex-encoded

View File

@ -1,9 +1,7 @@
import { Encoding } from "@iov/encoding";
import { fromHex, toBase64 } from "@iov/encoding";
import { pubkeyToAddress } from "./address";
const { toBase64, fromHex } = Encoding;
describe("address", () => {
describe("pubkeyToAddress", () => {
it("works for Secp256k1 compressed", () => {

View File

@ -1,10 +1,8 @@
import { Ripemd160, Sha256 } from "@iov/crypto";
import { Bech32, Encoding } from "@iov/encoding";
import { Bech32, fromBase64 } from "@iov/encoding";
import { PubKey, pubkeyType } from "./types";
const { fromBase64 } = Encoding;
export function rawSecp256k1PubkeyToAddress(pubkeyRaw: Uint8Array, prefix: string): string {
if (pubkeyRaw.length !== 33) {
throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyRaw.length}`);

View File

@ -1,5 +1,5 @@
import { Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { fromBase64, toHex } from "@iov/encoding";
import { Coin } from "./coins";
import { Log, parseLogs } from "./logs";
@ -167,7 +167,7 @@ export class CosmosClient {
// We consult the REST API because we don't have a local amino encoder
const bytes = await this.restClient.encodeTx(tx);
const hash = new Sha256(bytes).digest();
return Encoding.toHex(hash).toUpperCase();
return toHex(hash).toUpperCase();
}
/**
@ -224,7 +224,7 @@ export class CosmosClient {
height: parseInt(response.block.header.height, 10),
chainId: response.block.header.chain_id,
},
txs: (response.block.data.txs || []).map((encoded) => Encoding.fromBase64(encoded)),
txs: (response.block.data.txs || []).map(fromBase64),
};
}

View File

@ -1,9 +1,9 @@
import { Encoding } from "@iov/encoding";
import { fromUtf8 } from "@iov/encoding";
import { isStdTx, StdTx } from "./types";
export function unmarshalTx(data: Uint8Array): StdTx {
const decoded = JSON.parse(Encoding.fromUtf8(data));
const decoded = JSON.parse(fromUtf8(data));
if (!isStdTx(decoded)) {
throw new Error("Must be json encoded StdTx");
}

View File

@ -1,9 +1,7 @@
import { Encoding } from "@iov/encoding";
import { toUtf8 } from "@iov/encoding";
import { Msg, StdFee, StdTx } from "./types";
const { toUtf8 } = Encoding;
function sortJson(json: any): any {
if (typeof json !== "object" || json === null) {
return json;
@ -24,7 +22,7 @@ function sortJson(json: any): any {
export function marshalTx(tx: StdTx): Uint8Array {
const json = JSON.stringify(tx);
return Encoding.toUtf8(json);
return toUtf8(json);
}
interface SignJson {

View File

@ -1,11 +1,9 @@
import { Secp256k1, Secp256k1Signature, Sha256 } from "@iov/crypto";
import { Encoding } from "@iov/encoding";
import { fromHex, toAscii } from "@iov/encoding";
import { Secp256k1Pen } from "./pen";
import { decodeSignature } from "./signature";
const { fromHex } = Encoding;
describe("Sec256k1Pen", () => {
it("can be constructed", async () => {
const pen = await Secp256k1Pen.fromMnemonic(
@ -33,7 +31,7 @@ describe("Sec256k1Pen", () => {
const pen = await Secp256k1Pen.fromMnemonic(
"special sign fit simple patrol salute grocery chicken wheat radar tonight ceiling",
);
const data = Encoding.toAscii("foo bar");
const data = toAscii("foo bar");
const { pubkey, signature } = decodeSignature(await pen.sign(data));
const valid = await Secp256k1.verifySignature(

View File

@ -1,10 +1,8 @@
import { Encoding } from "@iov/encoding";
import { fromBase64 } from "@iov/encoding";
import { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
import { PubKey } from "./types";
const { fromBase64 } = Encoding;
describe("pubkey", () => {
describe("encodeSecp256k1Pubkey", () => {
it("encodes a compresed pubkey", () => {

View File

@ -1,4 +1,4 @@
import { Bech32, Encoding } from "@iov/encoding";
import { Bech32, fromBase64, fromHex, toBase64, toHex } from "@iov/encoding";
import equal from "fast-deep-equal";
import { PubKey, pubkeyType } from "./types";
@ -9,16 +9,16 @@ export function encodeSecp256k1Pubkey(pubkey: Uint8Array): PubKey {
}
return {
type: pubkeyType.secp256k1,
value: Encoding.toBase64(pubkey),
value: toBase64(pubkey),
};
}
// As discussed in https://github.com/binance-chain/javascript-sdk/issues/163
// Prefixes listed here: https://github.com/tendermint/tendermint/blob/d419fffe18531317c28c29a292ad7d253f6cafdf/docs/spec/blockchain/encoding.md#public-key-cryptography
// Last bytes is varint-encoded length prefix
const pubkeyAminoPrefixSecp256k1 = Encoding.fromHex("eb5ae98721");
const pubkeyAminoPrefixEd25519 = Encoding.fromHex("1624de6420");
const pubkeyAminoPrefixSr25519 = Encoding.fromHex("0dfb1005");
const pubkeyAminoPrefixSecp256k1 = fromHex("eb5ae98721");
const pubkeyAminoPrefixEd25519 = fromHex("1624de6420");
const pubkeyAminoPrefixSr25519 = fromHex("0dfb1005");
const pubkeyAminoPrefixLength = pubkeyAminoPrefixSecp256k1.length;
export function decodeBech32Pubkey(bechEncoded: string): PubKey {
@ -32,7 +32,7 @@ export function decodeBech32Pubkey(bechEncoded: string): PubKey {
}
return {
type: pubkeyType.secp256k1,
value: Encoding.toBase64(rest),
value: toBase64(rest),
};
} else if (equal(aminoPrefix, pubkeyAminoPrefixEd25519)) {
if (rest.length !== 32) {
@ -40,7 +40,7 @@ export function decodeBech32Pubkey(bechEncoded: string): PubKey {
}
return {
type: pubkeyType.ed25519,
value: Encoding.toBase64(rest),
value: toBase64(rest),
};
} else if (equal(aminoPrefix, pubkeyAminoPrefixSr25519)) {
if (rest.length !== 32) {
@ -48,10 +48,10 @@ export function decodeBech32Pubkey(bechEncoded: string): PubKey {
}
return {
type: pubkeyType.sr25519,
value: Encoding.toBase64(rest),
value: toBase64(rest),
};
} else {
throw new Error("Unsupported Pubkey type. Amino prefix: " + Encoding.toHex(aminoPrefix));
throw new Error("Unsupported Pubkey type. Amino prefix: " + toHex(aminoPrefix));
}
}
@ -66,6 +66,6 @@ export function encodeBech32Pubkey(pubkey: PubKey, prefix: string): string {
throw new Error("Unsupported pubkey type");
}
const data = new Uint8Array([...aminoPrefix, ...Encoding.fromBase64(pubkey.value)]);
const data = new Uint8Array([...aminoPrefix, ...fromBase64(pubkey.value)]);
return Bech32.encode(prefix, data);
}

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Encoding } from "@iov/encoding";
import { fromBase64 } from "@iov/encoding";
import { assert, sleep } from "@iov/utils";
import { ReadonlyDate } from "readonly-date";
@ -27,8 +27,6 @@ import {
} from "./testutils.spec";
import { Msg, MsgSend, StdFee, StdSignature, StdTx } from "./types";
const { fromBase64 } = Encoding;
const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k";
function makeSignedTx(firstMsg: Msg, fee: StdFee, memo: string, firstSignature: StdSignature): StdTx {

View File

@ -1,4 +1,4 @@
import { Encoding, isNonNullObject } from "@iov/encoding";
import { fromBase64, isNonNullObject } from "@iov/encoding";
import axios, { AxiosError, AxiosInstance } from "axios";
import { Coin } from "./coins";
@ -301,7 +301,7 @@ export class RestClient {
if (!responseData.tx) {
throw new Error("Unexpected response data format");
}
return Encoding.fromBase64((responseData as EncodeTxResponse).tx);
return fromBase64((responseData as EncodeTxResponse).tx);
}
/**

View File

@ -1,10 +1,8 @@
import { Encoding } from "@iov/encoding";
import { fromBase64 } from "@iov/encoding";
import { decodeSignature, encodeSecp256k1Signature } from "./signature";
import { StdSignature } from "./types";
const { fromBase64 } = Encoding;
describe("signature", () => {
describe("encodeSecp256k1Signature", () => {
it("encodes a full signature", () => {

View File

@ -1,4 +1,4 @@
import { Encoding } from "@iov/encoding";
import { fromBase64, toBase64 } from "@iov/encoding";
import { encodeSecp256k1Pubkey } from "./pubkey";
import { pubkeyType, StdSignature } from "./types";
@ -19,7 +19,7 @@ export function encodeSecp256k1Signature(pubkey: Uint8Array, signature: Uint8Arr
return {
// eslint-disable-next-line @typescript-eslint/camelcase
pub_key: encodeSecp256k1Pubkey(pubkey),
signature: Encoding.toBase64(signature),
signature: toBase64(signature),
};
}
@ -30,8 +30,8 @@ export function decodeSignature(
// Note: please don't add cases here without writing additional unit tests
case pubkeyType.secp256k1:
return {
pubkey: Encoding.fromBase64(signature.pub_key.value),
signature: Encoding.fromBase64(signature.signature),
pubkey: fromBase64(signature.pub_key.value),
signature: fromBase64(signature.signature),
};
default:
throw new Error("Unsupported pubkey type");