Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aptos keyring #135

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions packages/aptos-keyring/build.sh

This file was deleted.

2 changes: 0 additions & 2 deletions packages/aptos-keyring/config.ts.example

This file was deleted.

9 changes: 3 additions & 6 deletions packages/aptos-keyring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystonehq/aptos-keyring",
"version": "0.6.2",
"version": "0.6.3",
"description": "aptos-keyring interact with Keystone",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -10,9 +10,7 @@
"scripts": {
"clean": "rm -rf ./dist",
"start": "tsdx watch",
"ci:prepare": "./prepare.sh",
"copy:config": "cp ./config.ts ./src/Secret.ts",
"build": "npm run copy:config && ./build.sh"
"build": "tsdx build"
},
"publishConfig": {
"access": "public"
Expand All @@ -31,6 +29,5 @@
"@types/uuid": "^8.3.1",
"tsdx": "^0.14.1",
"typescript": "^4.6.2"
},
"gitHead": "83d8e223d29e5cc71dccc963388d65a87c894636"
}
}
4 changes: 0 additions & 4 deletions packages/aptos-keyring/prepare.sh

This file was deleted.

24 changes: 3 additions & 21 deletions packages/aptos-keyring/src/BaseKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as uuid from "uuid";
import { InteractionProvider } from "./InteractionProvider";
import { CryptoMultiAccounts } from "@keystonehq/bc-ur-registry";
import { AptosSignRequest, SignType } from "@keystonehq/bc-ur-registry-aptos";
import { Tracker } from './Tracker';

const keyringType = "QR Hardware Wallet Device";

Expand Down Expand Up @@ -32,7 +31,6 @@ export class BaseKeyring {
protected keys: HDKey[];
protected name: string;
protected device: string;
public isTracking: boolean;

constructor() {
//common props
Expand All @@ -41,7 +39,6 @@ export class BaseKeyring {
this.initialized = false;
this.device = "";
this.xfp = "";
this.isTracking = true;
}

protected requestSignature = async (
Expand All @@ -66,14 +63,6 @@ export class BaseKeyring {
);
}
}
if (this.isTracking) {
Tracker.track("sign", {
distinctId: this.device,
time: Date.now(),
xfp: this.xfp,
requestId: _requestId,
});
}
return { signature, authPubKey };
};

Expand All @@ -91,23 +80,16 @@ export class BaseKeyring {
this.keys = keys.map((each, index) => ({
hdPath: each.getOrigin().getPath(),
pubKey: each.getKey().toString("hex"),
index
index,
}));
this.initialized = true;
if (this.isTracking) {
Tracker.track("sync", {
distinctId: this.device,
time: Date.now(),
xfp: this.xfp,
});
}
}

public syncKeyringData({
xfp,
keys,
name = "QR Hardware",
device
device,
}: KeyringInitData): void {
this.xfp = xfp;
this.name = name;
Expand Down Expand Up @@ -143,7 +125,7 @@ export class BaseKeyring {
) {
const requestId = uuid.v4();
const key = this.getPubKeys().find(
key => this._ensureHex(key.pubKey) === this._ensureHex(authPubKey)
(key) => this._ensureHex(key.pubKey) === this._ensureHex(authPubKey)
);
const accounts = senderAddress
? [Buffer.from(this._ensureHex(senderAddress).slice(2))]
Expand Down
8 changes: 4 additions & 4 deletions packages/aptos-keyring/src/DefaultInteractionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AptosSignature,
AptosSignRequest
AptosSignRequest,
} from "@keystonehq/bc-ur-registry-aptos";
import { InteractionProvider } from "./InteractionProvider";
import sdk, { PlayStatus, ReadStatus, SupportedResult } from "@keystonehq/sdk";
Expand All @@ -27,10 +27,10 @@ export class DefaultInteractionProvider implements InteractionProvider {
description: "Please scan the QR code displayed on your Keystone",
renderInitial: {
walletMode: "Aptos",
link: "https://keyst.one/defi"
link: "https://keyst.one/defi",
},
URTypeErrorMessage:
"The scanned QR code is not the sync code from the Keystone hardware wallet. Please verify the code and try again"
"The scanned QR code is not the sync code from the Keystone hardware wallet. Please verify the code and try again",
}
);
if (decodedResult.status === ReadStatus.success) {
Expand All @@ -50,7 +50,7 @@ export class DefaultInteractionProvider implements InteractionProvider {
hasNext: true,
title: requestTitle,
description: requestDescription,
maxFragmentLength: 400
maxFragmentLength: 400,
});
if (status === PlayStatus.canceled)
throw new Error("#ktek_error[play-cancel]: play canceled");
Expand Down
2 changes: 1 addition & 1 deletion packages/aptos-keyring/src/InteractionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AptosSignature,
AptosSignRequest
AptosSignRequest,
} from "@keystonehq/bc-ur-registry-aptos";
import { CryptoMultiAccounts } from "@keystonehq/bc-ur-registry";

Expand Down
40 changes: 0 additions & 40 deletions packages/aptos-keyring/src/Tracker.ts

This file was deleted.