Skip to content

Commit

Permalink
devop: proper define
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Oct 23, 2024
1 parent 7522403 commit c350d24
Show file tree
Hide file tree
Showing 17 changed files with 464 additions and 1,006 deletions.
9 changes: 9 additions & 0 deletions packages/extension/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ namespace NodeJS {
MINIFY: 'true' | 'false'
}
}

declare let __PREFILL_PASSWORD__: string
declare let __PACKAGE_VERSION__: string
declare let __IS_DEV__: boolean
declare let __IS_FIREFOX__: boolean
declare let __IS_OPERA__: boolean
declare let __IS_CHROME__: boolean
declare let __IS_SAFARI__: boolean
declare let __BUILD_TIME__: string
50 changes: 25 additions & 25 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,34 @@
"@ethereumjs/common": "^4.4.0",
"@ethereumjs/tx": "^5.4.0",
"@ethereumjs/util": "^9.1.0",
"@kadena/client": "^1.14.0",
"@kadena/pactjs-cli": "^1.14.0",
"@kadena/client": "^1.15.0",
"@kadena/pactjs-cli": "^1.15.0",
"@ledgerhq/hw-transport-webusb": "^6.29.4",
"@metamask/eth-sig-util": "^7.0.3",
"@metaplex-foundation/mpl-bubblegum": "^4.2.1",
"@metaplex-foundation/umi": "^0.9.2",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@polkadot/api": "^13.2.1",
"@polkadot/extension-inject": "^0.53.1",
"@polkadot/keyring": "^13.1.1",
"@polkadot/rpc-provider": "^13.2.1",
"@polkadot/types": "^13.2.1",
"@polkadot/types-known": "^13.2.1",
"@polkadot/api": "^14.1.1",
"@polkadot/extension-inject": "^0.54.1",
"@polkadot/keyring": "^13.2.1",
"@polkadot/rpc-provider": "^14.1.1",
"@polkadot/types": "^14.1.1",
"@polkadot/types-known": "^14.1.1",
"@polkadot/ui-shared": "^3.10.1",
"@polkadot/util": "^13.1.1",
"@polkadot/wasm-crypto": "^7.3.2",
"@polkadot/util": "^13.2.1",
"@polkadot/wasm-crypto": "^7.4.1",
"@solana-developers/helpers": "^2.5.6",
"@solana/spl-token": "^0.4.8",
"@solana/spl-token": "^0.4.9",
"@solana/wallet-standard-features": "^1.2.0",
"@solana/web3.js": "^1.95.3",
"@solana/web3.js": "^1.95.4",
"@wallet-standard/base": "^0.0.0-20240703212708",
"add": "^2.0.6",
"bignumber.js": "^9.1.2",
"bip39": "^3.1.0",
"bitcoinjs-lib": "^6.1.6",
"bs58": "^6.0.0",
"chai": "^4.5.0",
"concurrently": "^8.2.2",
"concurrently": "^9.0.1",
"echarts": "^5.5.1",
"ethereum-cryptography": "^2.2.1",
"ethereumjs-abi": "^0.6.8",
Expand All @@ -71,14 +71,14 @@
"lodash": "^4.17.21",
"memoize-one": "^6.0.0",
"moment": "^2.30.1",
"nanoevents": "^9.0.0",
"nanoevents": "^9.1.0",
"pact-lang-api": "^4.3.6",
"pinia": "^2.2.4",
"qrcode.vue": "^3.5.0",
"qrcode.vue": "^3.5.1",
"switch-ts": "^1.1.1",
"url-parse": "^1.5.10",
"uuid": "^10.0.0",
"vue": "^3.5.11",
"vue": "^3.5.12",
"vue-echarts": "7.0.3",
"vue-router": "^4.4.5",
"vue3-lottie": "^3.3.1",
Expand All @@ -99,40 +99,40 @@
"@rollup/plugin-typescript": "^12.1.1",
"@tsconfig/node20": "^20.1.4",
"@types/bs58": "^4.0.4",
"@types/chrome": "^0.0.273",
"@types/chrome": "^0.0.279",
"@types/ethereumjs-abi": "^0.6.5",
"@types/events": "^3.0.3",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.13",
"@types/less": "^3.0.6",
"@types/lodash": "^4.17.9",
"@types/mocha": "^10.0.8",
"@types/node": "^22.7.7",
"@types/lodash": "^4.17.12",
"@types/mocha": "^10.0.9",
"@types/node": "^22.7.8",
"@types/url-parse": "^1.4.11",
"@types/utf-8-validate": "^5.0.2",
"@types/uuid": "^10.0.0",
"@types/wif": "^2.0.5",
"@types/zxcvbn": "^4.4.5",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/eslint-config-prettier": "^10.0.0",
"@vue/eslint-config-typescript": "^14.0.0",
"@vue/eslint-config-typescript": "^14.1.2",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^11.1.0",
"cross-env": "^7.0.3",
"eslint": "^9.12.0",
"eslint-plugin-vue": "^9.28.0",
"eslint": "^9.13.0",
"eslint-plugin-vue": "^9.29.1",
"fs-extra": "^11.2.0",
"less": "^4.2.0",
"less-loader": "^12.2.0",
"mocha": "^10.7.3",
"npm-run-all2": "^6.2.3",
"npm-run-all2": "^6.2.6",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"rollup": "^4.24.0",
"rollup-plugin-uglify": "^6.0.4",
"semver": "^7.6.3",
"systeminformation": "^5.23.5",
"typescript": "~5.5.4",
"typescript": "~5.6.3",
"url": "^0.11.4",
"vite": "^5.4.9",
"vite-plugin-node-polyfills": "0.17.0",
Expand Down
134 changes: 66 additions & 68 deletions packages/extension/src/libs/keyring/public-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,137 +3,135 @@ import {
Errors,
WalletType,
EnkryptAccount,
} from "@enkryptcom/types";
import { assert } from "chai";
import { KeyRingBase } from "./keyring";
} from '@enkryptcom/types'
import { assert } from 'chai'
import { KeyRingBase } from './keyring'
class PublicKeyRing {
#keyring: KeyRingBase;
#keyring: KeyRingBase
constructor() {
this.#keyring = new KeyRingBase();
this.#keyring = new KeyRingBase()
}
private async getKeysObject(): Promise<{ [key: string]: EnkryptAccount }> {
const allKeys = await this.#keyring.getKeysObject();
if (process.env.IS_DEV) {
allKeys["0x99999990d598b918799f38163204bbc30611b6b6"] = {
address: "0x99999990d598b918799f38163204bbc30611b6b6",
const allKeys = await this.#keyring.getKeysObject()
if (__IS_DEV__) {
allKeys['0x99999990d598b918799f38163204bbc30611b6b6'] = {
address: '0x99999990d598b918799f38163204bbc30611b6b6',
basePath: "m/44'/60'/1'/0",
name: "fake account #1",
name: 'fake account #1',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.secp256k1,
walletType: WalletType.mnemonic,
isHardware: false,
};
allKeys["0xb1ea5a3e5ea7fa1834d48058ecda26d8c59e8251"] = {
address: "0xb1ea5a3e5ea7fa1834d48058ecda26d8c59e8251", //optimism nfts
}
allKeys['0xb1ea5a3e5ea7fa1834d48058ecda26d8c59e8251'] = {
address: '0xb1ea5a3e5ea7fa1834d48058ecda26d8c59e8251', //optimism nfts
basePath: "m/44'/60'/2'/0",
name: "fake account #2",
name: 'fake account #2',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.secp256k1,
walletType: WalletType.mnemonic,
isHardware: false,
};
allKeys["0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391"] = {
address: "0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391",
}
allKeys['0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391'] = {
address: '0xe5dc07bdcdb8c98850050c7f67de7e164b1ea391',
basePath: "m/44'/60'/1'/1",
name: "fake ledger account #3",
name: 'fake ledger account #3',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.secp256k1,
walletType: WalletType.ledger,
isHardware: true,
};
allKeys["5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D"] = {
address: "5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D",
basePath: "//",
name: "fake ledger account #2",
}
allKeys['5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D'] = {
address: '5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D',
basePath: '//',
name: 'fake ledger account #2',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.sr25519,
walletType: WalletType.ledger,
isHardware: true,
};
allKeys["5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D"] = {
address: "5CFnoCsP3pDK2thhSqYPwKELJFLQ1hBodqzSUypexyh7eHkB",
basePath: "//",
name: "fake account #4",
}
allKeys['5E56EZk6jmpq1q3Har3Ms99D9TLN9ra2inFh7Q1Hj6GpUx6D'] = {
address: '5CFnoCsP3pDK2thhSqYPwKELJFLQ1hBodqzSUypexyh7eHkB',
basePath: '//',
name: 'fake account #4',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.sr25519,
walletType: WalletType.mnemonic,
isHardware: false,
};
}
allKeys[
"bc1puzz9tmxawd7zdd7klfgtywrgpma3u22fz5ecxhucd4j8tygqe5ms2vdd9y"
'bc1puzz9tmxawd7zdd7klfgtywrgpma3u22fz5ecxhucd4j8tygqe5ms2vdd9y'
] = {
address:
"bc1puzz9tmxawd7zdd7klfgtywrgpma3u22fz5ecxhucd4j8tygqe5ms2vdd9y",
'bc1puzz9tmxawd7zdd7klfgtywrgpma3u22fz5ecxhucd4j8tygqe5ms2vdd9y',
basePath: "m/49'/2'/0'/1",
name: "fake ltc account #4",
name: 'fake ltc account #4',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.secp256k1btc,
walletType: WalletType.mnemonic,
isHardware: false,
};
allKeys["77hREDDaAiimedtD9bR1JDMgYLW3AA5yPvD91pvrueRp"] = {
address: "77hREDDaAiimedtD9bR1JDMgYLW3AA5yPvD91pvrueRp",
}
allKeys['77hREDDaAiimedtD9bR1JDMgYLW3AA5yPvD91pvrueRp'] = {
address: '77hREDDaAiimedtD9bR1JDMgYLW3AA5yPvD91pvrueRp',
basePath: "m/44'/501'/0'/1",
name: "fake sol acc 1",
name: 'fake sol acc 1',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.ed25519sol,
walletType: WalletType.mnemonic,
isHardware: false,
};
allKeys["tQvduDby4rvC6VU4rSirhVWuRYxbJz3rvUrVMkUWsZP"] = {
address: "tQvduDby4rvC6VU4rSirhVWuRYxbJz3rvUrVMkUWsZP",
}
allKeys['tQvduDby4rvC6VU4rSirhVWuRYxbJz3rvUrVMkUWsZP'] = {
address: 'tQvduDby4rvC6VU4rSirhVWuRYxbJz3rvUrVMkUWsZP',
basePath: "m/44'/501'/0'/1",
name: "fake sol acc 2",
name: 'fake sol acc 2',
pathIndex: 0,
publicKey: "0x0",
publicKey: '0x0',
signerType: SignerType.ed25519sol,
walletType: WalletType.mnemonic,
isHardware: false,
};
}
}
return allKeys;
return allKeys
}
async getAccounts(types?: SignerType[]): Promise<EnkryptAccount[]> {
return this.getKeysObject().then((keysObject) => {
const records = Object.values(keysObject);
return types
? records.filter((r) => types.includes(r.signerType))
: records;
});
return this.getKeysObject().then(keysObject => {
const records = Object.values(keysObject)
return types ? records.filter(r => types.includes(r.signerType)) : records
})
}
async getAccount(address: string): Promise<EnkryptAccount> {
const allKeys = await this.getKeysObject();
assert(allKeys[address], Errors.KeyringErrors.AddressDoesntExists);
return allKeys[address];
const allKeys = await this.getKeysObject()
assert(allKeys[address], Errors.KeyringErrors.AddressDoesntExists)
return allKeys[address]
}
isLocked(): boolean {
return this.#keyring.isLocked();
return this.#keyring.isLocked()
}
isInitialized(): Promise<boolean> {
return this.#keyring.isInitialized();
return this.#keyring.isInitialized()
}
async accountAlreadyAdded(newAddress: string): Promise<boolean> {
newAddress = newAddress.toLowerCase();
newAddress = newAddress.toLowerCase()

const allAccounts = await this.getAccounts();
const allAccounts = await this.getAccounts()

let alreadyExists = false;
let alreadyExists = false

for (const account of allAccounts) {
if (account.address.toLowerCase() === newAddress) {
alreadyExists = true;
break;
alreadyExists = true
break
}
}

return alreadyExists;
return alreadyExists
}
}
export default PublicKeyRing;
export default PublicKeyRing
Loading

1 comment on commit c350d24

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.