Skip to content

Commit

Permalink
fix(certificates): add deprecated types
Browse files Browse the repository at this point in the history
refs #76
  • Loading branch information
ygrishajev committed May 15, 2024
1 parent 97fe303 commit a4a632f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/certificates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const jrpc = JsonRPC.connect_xhr("https://bridge.testnet.akash.network/akashnetw

export type { pems };

export type CertificatePemDeprecated = CertificatePem & {
csr: string;
};

export async function broadcastCertificate(
pem: Pick<CertificatePem, "cert" | "publicKey">,
owner: string,
Expand All @@ -27,8 +31,8 @@ export async function broadcastCertificate(
owner: string,
client: SigningStargateClient
): Promise<DeliverTxResponse> {
if ("csr" in pem) {
console.warn("The `csr` field is deprecated. Use `cert` instead.");
if ("csr" in pem && !("cert" in pem)) {
console.trace("The `csr` field is deprecated. Use `cert` instead.");
}
const certKey = "cert" in pem ? pem.cert : pem.csr;
const encodedCsr = base64ToUInt(toBase64(certKey));
Expand All @@ -42,13 +46,13 @@ export async function broadcastCertificate(
return await client.signAndBroadcast(owner, [message.message], message.fee);
}

export async function createCertificate(bech32Address: string) {
export async function createCertificate(bech32Address: string): Promise<CertificatePemDeprecated> {
const pem = certificateManager.generatePEM(bech32Address);

return {
...pem,
get csr() {
console.warn("The `csr` field is deprecated. Use `cert` instead.");
console.trace("The `csr` field is deprecated. Use `cert` instead.");
return pem.cert;
}
};
Expand Down

0 comments on commit a4a632f

Please sign in to comment.