Skip to content

Commit

Permalink
chore: add stakePub property to CardanoSignDataRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Charon-Fan committed Jul 26, 2024
1 parent 5306af8 commit 75e66a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ur-registry-cardano/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystonehq/bc-ur-registry-cardano",
"version": "0.3.7",
"version": "0.3.8",
"description": "bc-ur-registry extension for Cardano",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions packages/ur-registry-cardano/src/CardanoSignDataRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ enum Keys {
derivationPath,
origin,
signType,
stakePub,
}

type signRequestProps = {
requestId?: Buffer;
signData: Buffer;
stakePub: Buffer;
derivationPath: CryptoKeypath;
origin?: string;
};
Expand All @@ -31,6 +33,7 @@ export class CardanoSignDataRequest extends RegistryItem {
private signData: Buffer;
private derivationPath: CryptoKeypath;
private origin?: string;
private stakePub: Buffer;

getRegistryType = () => ExtendedRegistryTypes.CARDANO_SIGN_DATA_REQUEST;

Expand All @@ -40,12 +43,14 @@ export class CardanoSignDataRequest extends RegistryItem {
this.signData = args.signData;
this.derivationPath = args.derivationPath;
this.origin = args.origin;
this.stakePub = args.stakePub;
}

public getRequestId = () => this.requestId;
public getSignData = () => this.signData;
public getDerivationPath = () => this.derivationPath.getPath();
public getOrigin = () => this.origin;
public getStakePub = () => this.stakePub;

public toDataItem = () => {
const map: DataItemMap = {};
Expand All @@ -65,6 +70,7 @@ export class CardanoSignDataRequest extends RegistryItem {
const keyPath = this.derivationPath.toDataItem();
keyPath.setTag(this.derivationPath.getRegistryType().getTag());
map[Keys.derivationPath] = keyPath;
map[Keys.stakePub] = this.stakePub;

return new DataItem(map);
};
Expand All @@ -77,12 +83,14 @@ export class CardanoSignDataRequest extends RegistryItem {
? map[Keys.requestId].getData()
: undefined;
const origin = map[Keys.origin] ? map[Keys.origin] : undefined;
const stakePub = map[Keys.stakePub];

return new CardanoSignDataRequest({
requestId,
signData,
derivationPath,
origin,
stakePub,
});
};

Expand All @@ -95,6 +103,7 @@ export class CardanoSignDataRequest extends RegistryItem {
signData: string,
hdPath: string,
xfp: string,
stakePub: string,
uuidString?: string,
origin?: string
) {
Expand All @@ -118,6 +127,7 @@ export class CardanoSignDataRequest extends RegistryItem {
signData: Buffer.from(signData, "hex"),
derivationPath: hdpathObject,
origin: origin || undefined,
stakePub: Buffer.from(stakePub, "hex"),
});
}
}

0 comments on commit 75e66a5

Please sign in to comment.