Skip to content

Commit

Permalink
Untitled commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Nov 13, 2023
1 parent 2fb1c40 commit a04aaed
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 16 deletions.
10 changes: 5 additions & 5 deletions frontend/src/lib/keys/secp256k1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class Secp256k1PublicKey implements PublicKey {
return rawKey;
}

private readonly rawKey: ArrayBuffer;
private readonly derKey: DerEncodedPublicKey;
public readonly rawKey: ArrayBuffer;
public readonly derKey: DerEncodedPublicKey;

// `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
private constructor(key: ArrayBuffer) {
Expand All @@ -94,7 +94,7 @@ export class Secp256k1PublicKey implements PublicKey {
return this.derKey;
}

public toRaw(): ArrayBuffer {
return this.rawKey;
}
// public toRaw(): ArrayBuffer {
// return this.rawKey;
// }
}
2 changes: 1 addition & 1 deletion frontend/src/lib/services/seed-neurons.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const claimSeedNeurons = async () => {
});

const bufferKey = identity.getPublicKey() as Secp256k1PublicKey;
const hexPubKey = buf2hex(bufferKey.toRaw());
const hexPubKey = buf2hex(bufferKey.rawKey);
const isHex = hexPubKey.match("^[0-9a-fA-F]+$");
if (!isHex) {
toastsError({
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ export const stringifyJson = (
case "symbol":
return value.toString();
case "object": {
// Represent Principals as strings rather than as byte arrays when serializing to JSON strings
if (isPrincipal(value)) {
const asText = value.toString();
// To not stringify NOT Principal instance that contains _isPrincipal field
return asText === "[object Object]" ? value : asText;
}

// optimistic hash stringifying
if (Array.isArray(value) && isHash(value)) {
return bytesToHexString(value);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/lib/identities/ledger.identity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("LedgerIdentity", () => {
mockLedgerApp.getAddressAndPubKey.mockResolvedValue({
errorMessage: undefined,
returnCode: LedgerError.NoErrors,
publicKey: Buffer.from(publicKey.toRaw()),
publicKey: Buffer.from(publicKey.rawKey),
principal: Buffer.from(mockPrincipal.toUint8Array()),
address: Buffer.from(""),
principalText: mockPrincipal.toText(),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/lib/keys/secp256k1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("secp256k1", () => {

const expectedPublicKey = fromHexString(rawPublicKeyHex);
expect(
new Uint8Array(Secp256k1PublicKey.fromDer(derPublicKey).toRaw())
new Uint8Array(Secp256k1PublicKey.fromDer(derPublicKey).rawKey)
).toEqual(new Uint8Array(expectedPublicKey));
}
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/lib/utils/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("utils", () => {

it("should render principal as hash", () => {
expect(stringifyJson({ principal: mockPrincipal })).toBe(
`{"principal":"${mockPrincipal.toString()}"}`
`{"principal":{"__principal__":"${mockPrincipal.toString()}"}}`
);
});

Expand Down

0 comments on commit a04aaed

Please sign in to comment.