1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix @keystonehq/bc-ur-registry patch (#16155)

We use the `@keystonehq/bc-ur-registry` package for integration with
Keystone devices. This package is peculiar as it not only ships with
JavaScript files but also original TypeScript files. When we started
adding support for TypeScript into the build system, we realized that
the TypeScript files were apparently developed using a different
TypeScript config than we use and therefore resulted in errors in our
build process. So we added a patch which removed these TypeScript files
so that we would fall back to using the compiled JavaScript files. This
removed type information but fixed our build system.

Since then, we've bumped this package and the files we removed have
changed, so the patch is no longer valid. This commit recreates the
patch so that we no longer get warnings from `patch-package`.
This commit is contained in:
Elliot Winkler 2022-10-11 11:27:29 -06:00 committed by GitHub
parent d640c9a924
commit 33522a7b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,14 +40,15 @@ index a5f9f7d..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts
deleted file mode 100644 deleted file mode 100644
index 753e535..0000000 index e6efeeb..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoAccount.ts
+++ /dev/null +++ /dev/null
@@ -1,57 +0,0 @@ @@ -1,58 +0,0 @@
-import { CryptoOutput } from '.'; -import { CryptoOutput } from '.';
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryTypes } from './RegistryType'; -import { RegistryTypes } from './RegistryType';
-import { DataItemMap } from './types';
- -
-enum Keys { -enum Keys {
- masterFingerprint = 1, - masterFingerprint = 1,
@ -70,7 +71,7 @@ index 753e535..0000000
- public getOutputDescriptors = () => this.outputDescriptors; - public getOutputDescriptors = () => this.outputDescriptors;
- -
- public toDataItem = () => { - public toDataItem = () => {
- const map = {}; - const map: DataItemMap = {};
- if (this.masterFingerprint) { - if (this.masterFingerprint) {
- map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE(0); - map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE(0);
- } - }
@ -103,13 +104,14 @@ index 753e535..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts
deleted file mode 100644 deleted file mode 100644
index 0201682..0000000 index 843b50c..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoCoinInfo.ts
+++ /dev/null +++ /dev/null
@@ -1,58 +0,0 @@ @@ -1,59 +0,0 @@
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryTypes } from './RegistryType'; -import { RegistryTypes } from './RegistryType';
-import { DataItemMap } from './types';
- -
-enum Keys { -enum Keys {
- type = '1', - type = '1',
@ -143,7 +145,7 @@ index 0201682..0000000
- }; - };
- -
- public toDataItem = () => { - public toDataItem = () => {
- const map = {}; - const map: DataItemMap = {};
- if (this.type) { - if (this.type) {
- map[Keys.type] = this.type; - map[Keys.type] = this.type;
- } - }
@ -167,13 +169,14 @@ index 0201682..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts
deleted file mode 100644 deleted file mode 100644
index 1e964fc..0000000 index 54c3c4b..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoECKey.ts
+++ /dev/null +++ /dev/null
@@ -1,59 +0,0 @@ @@ -1,68 +0,0 @@
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryTypes } from './RegistryType'; -import { RegistryTypes } from './RegistryType';
-import { DataItemMap, ICryptoKey } from './types';
- -
-enum Keys { -enum Keys {
- curve = 1, - curve = 1,
@ -181,17 +184,21 @@ index 1e964fc..0000000
- data, - data,
-} -}
- -
-export class CryptoECKey extends RegistryItem { -export class CryptoECKey extends RegistryItem implements ICryptoKey {
- private data: Buffer; - private data: Buffer;
- private curve: number; - private curve: number | undefined;
- private privateKey: boolean; - private privateKey: boolean | undefined;
- constructor(args: { data: Buffer; curve?: number; privateKey?: boolean }) { - constructor(args: { data: Buffer; curve?: number; privateKey?: boolean }) {
- super(); - super();
- this.data = args.data; - this.data = args.data;
- this.curve = args.curve; - this.curve = args.curve;
- this.privateKey = args.privateKey; - this.privateKey = args.privateKey || undefined;
- } - }
- -
- isECKey = () => {
- return true;
- };
-
- public getCurve = () => this.curve || 0; - public getCurve = () => this.curve || 0;
- public isPrivateKey = () => this.privateKey || false; - public isPrivateKey = () => this.privateKey || false;
- public getData = () => this.data; - public getData = () => this.data;
@ -201,7 +208,7 @@ index 1e964fc..0000000
- }; - };
- -
- toDataItem = () => { - toDataItem = () => {
- const map = {}; - const map: DataItemMap = {};
- if (this.curve) { - if (this.curve) {
- map[Keys.curve] = this.curve; - map[Keys.curve] = this.curve;
- } - }
@ -212,6 +219,10 @@ index 1e964fc..0000000
- return new DataItem(map); - return new DataItem(map);
- }; - };
- -
- getOutputDescriptorContent = () => {
- return this.data.toString('hex');
- }
-
- static fromDataItem = (dataItem: DataItem) => { - static fromDataItem = (dataItem: DataItem) => {
- const map = dataItem.getData(); - const map = dataItem.getData();
- const curve = map[Keys.curve]; - const curve = map[Keys.curve];
@ -232,16 +243,20 @@ index 1e964fc..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts
deleted file mode 100644 deleted file mode 100644
index bbfd331..0000000 index 8fc2a82..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoHDKey.ts
+++ /dev/null +++ /dev/null
@@ -1,210 +0,0 @@ @@ -1,237 +0,0 @@
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
-import { encode } from 'bs58check'; -import { encode } from 'bs58check';
-import { CryptoCoinInfo } from './CryptoCoinInfo'; -import { CryptoCoinInfo } from './CryptoCoinInfo';
-import { CryptoKeypath } from './CryptoKeypath'; -import { CryptoKeypath } from './CryptoKeypath';
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryTypes } from './RegistryType'; -import { RegistryTypes } from './RegistryType';
-import { DataItemMap, ICryptoKey } from './types';
-import { PathComponent } from './PathComponent';
- -
-enum Keys { -enum Keys {
- is_master = 1, - is_master = 1,
@ -274,17 +289,22 @@ index bbfd331..0000000
- name?: string; - name?: string;
- note?: string; - note?: string;
-}; -};
-export class CryptoHDKey extends RegistryItem { -
- private master: boolean; -export class CryptoHDKey extends RegistryItem implements ICryptoKey {
- private privateKey: boolean; - private master?: boolean;
- private key: Buffer; - private privateKey?: boolean;
- private chainCode: Buffer; - private key?: Buffer;
- private useInfo: CryptoCoinInfo; - private chainCode?: Buffer;
- private origin: CryptoKeypath; - private useInfo?: CryptoCoinInfo;
- private children: CryptoKeypath; - private origin?: CryptoKeypath;
- private parentFingerprint: Buffer; - private children?: CryptoKeypath;
- private name: string; - private parentFingerprint?: Buffer;
- private note: string; - private name?: string;
- private note?: string;
-
- isECKey = () => {
- return false;
- };
- -
- public getKey = () => this.key; - public getKey = () => this.key;
- public getChainCode = () => this.chainCode; - public getChainCode = () => this.chainCode;
@ -299,22 +319,24 @@ index bbfd331..0000000
- public getBip32Key = () => { - public getBip32Key = () => {
- let version: Buffer; - let version: Buffer;
- let depth: number; - let depth: number;
- let index: number; - let index = 0;
- let parentFingerprint: Buffer = Buffer.alloc(4).fill(0); - let parentFingerprint: Buffer = Buffer.alloc(4).fill(0);
- if(this.isMaster()) { - if (this.isMaster()) {
- // version bytes defined on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format - // version bytes defined on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format
- version = Buffer.from("0488ADE4", "hex") - version = Buffer.from('0488ADE4', 'hex');
- depth = 0; - depth = 0;
- index = 0; - index = 0;
- } else { - } else {
- depth = this.getOrigin().getComponents().length || this.getOrigin().getDepth(); - depth = this.getOrigin()?.getComponents().length || this.getOrigin()?.getDepth() as number;
- const paths = this.getOrigin().getComponents(); - const paths = this.getOrigin()?.getComponents() as PathComponent[];
- const lastPath = paths[paths.length - 1]; - const lastPath = paths[paths.length - 1];
- if(lastPath) { - if (lastPath) {
- index = lastPath.isHardened() ? lastPath.getIndex()! + 0x80000000 : lastPath.getIndex()!; - index = lastPath.isHardened() ? lastPath.getIndex()! + 0x80000000 : lastPath.getIndex()!;
- parentFingerprint = this.getParentFingerprint(); - if (this.getParentFingerprint()) {
- parentFingerprint = this.getParentFingerprint() as Buffer;
- }
- } - }
- if(this.isPrivateKey()) { - if (this.isPrivateKey()) {
- version = Buffer.from('0488ADE4', 'hex'); - version = Buffer.from('0488ADE4', 'hex');
- } else { - } else {
- version = Buffer.from('0488B21E', 'hex'); - version = Buffer.from('0488B21E', 'hex');
@ -326,13 +348,29 @@ index bbfd331..0000000
- indexBuffer.writeUInt32BE(index, 0); - indexBuffer.writeUInt32BE(index, 0);
- const chainCode = this.getChainCode(); - const chainCode = this.getChainCode();
- const key = this.getKey(); - const key = this.getKey();
- return encode(Buffer.concat([version, depthBuffer, parentFingerprint, indexBuffer, chainCode, key])); - return encode(Buffer.concat([version, depthBuffer, parentFingerprint, indexBuffer, chainCode as Buffer, key as Buffer]));
- } - };
- -
- public getRegistryType = () => { - public getRegistryType = () => {
- return RegistryTypes.CRYPTO_HDKEY; - return RegistryTypes.CRYPTO_HDKEY;
- }; - };
- -
- public getOutputDescriptorContent = () => {
- let result = '';
- if (this.getOrigin()) {
- if (this.getOrigin()?.getSourceFingerprint() && this.getOrigin()?.getPath()) {
- result += `${this.getOrigin()?.getSourceFingerprint()?.toString('hex')}/${this.getOrigin()?.getPath()}`;
- }
- }
- result += this.getBip32Key();
- if (this.getChildren()) {
- if (this.getChildren()?.getPath()) {
- result += `/${this.getChildren()?.getPath()}`;
- }
- }
- return result;
- };
-
- constructor(args: DeriveKeyProps | MasterKeyProps) { - constructor(args: DeriveKeyProps | MasterKeyProps) {
- super(); - super();
- if (args.isMaster) { - if (args.isMaster) {
@ -362,7 +400,7 @@ index bbfd331..0000000
- }; - };
- -
- public toDataItem = () => { - public toDataItem = () => {
- const map = {}; - const map: DataItemMap = {};
- if (this.master) { - if (this.master) {
- map[Keys.is_master] = true; - map[Keys.is_master] = true;
- map[Keys.key_data] = this.key; - map[Keys.key_data] = this.key;
@ -418,8 +456,8 @@ index bbfd331..0000000
- const children = map[Keys.children] - const children = map[Keys.children]
- ? CryptoKeypath.fromDataItem(map[Keys.children]) - ? CryptoKeypath.fromDataItem(map[Keys.children])
- : undefined; - : undefined;
- let _parentFingerprint = map[Keys.parent_fingerprint]; - const _parentFingerprint = map[Keys.parent_fingerprint];
- let parentFingerprint: Buffer; - let parentFingerprint: Buffer | undefined = undefined;
- if (_parentFingerprint) { - if (_parentFingerprint) {
- parentFingerprint = Buffer.alloc(4); - parentFingerprint = Buffer.alloc(4);
- parentFingerprint.writeUInt32BE(_parentFingerprint, 0); - parentFingerprint.writeUInt32BE(_parentFingerprint, 0);
@ -448,14 +486,15 @@ index bbfd331..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts
deleted file mode 100644 deleted file mode 100644
index 4babe91..0000000 index 00146ce..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoKeypath.ts
+++ /dev/null +++ /dev/null
@@ -1,95 +0,0 @@ @@ -1,96 +0,0 @@
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
-import { PathComponent } from './PathComponent'; -import { PathComponent } from './PathComponent';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryTypes } from './RegistryType'; -import { RegistryTypes } from './RegistryType';
-import { DataItemMap } from './types';
- -
-enum Keys { -enum Keys {
- components = 1, - components = 1,
@ -494,16 +533,16 @@ index 4babe91..0000000
- public getDepth = () => this.depth; - public getDepth = () => this.depth;
- -
- toDataItem = () => { - toDataItem = () => {
- const map: Record<string, any> = {}; - const map: DataItemMap = {};
- const components = []; - const components: (number | boolean | any[])[] = [];
- this.components && - this.components &&
- this.components.forEach((component) => { - this.components.forEach((component) => {
- if (component.isWildcard()) { - if (component.isWildcard()) {
- components.push([]); - components.push([]);
- } else { - } else {
- components.push(component.getIndex()); - components.push(component.getIndex() as number);
- } - }
- components.push(component.isHardened() ? true : false); - components.push(component.isHardened());
- }); - });
- map[Keys.components] = components; - map[Keys.components] = components;
- if (this.sourceFingerprint) { - if (this.sourceFingerprint) {
@ -533,7 +572,7 @@ index 4babe91..0000000
- } - }
- } - }
- const _sourceFingerprint = map[Keys.source_fingerprint]; - const _sourceFingerprint = map[Keys.source_fingerprint];
- let sourceFingerprint: Buffer; - let sourceFingerprint: Buffer | undefined;
- if (_sourceFingerprint) { - if (_sourceFingerprint) {
- sourceFingerprint = Buffer.alloc(4); - sourceFingerprint = Buffer.alloc(4);
- sourceFingerprint.writeUInt32BE(_sourceFingerprint, 0); - sourceFingerprint.writeUInt32BE(_sourceFingerprint, 0);
@ -549,10 +588,10 @@ index 4babe91..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts b/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts
deleted file mode 100644 deleted file mode 100644
index cd3009c..0000000 index 90abf6f..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/CryptoOutput.ts
+++ /dev/null +++ /dev/null
@@ -1,114 +0,0 @@ @@ -1,127 +0,0 @@
-import { CryptoECKey } from './CryptoECKey'; -import { CryptoECKey } from './CryptoECKey';
-import { CryptoHDKey } from './CryptoHDKey'; -import { CryptoHDKey } from './CryptoHDKey';
-import { decodeToDataItem, DataItem } from './lib'; -import { decodeToDataItem, DataItem } from './lib';
@ -599,6 +638,18 @@ index cd3009c..0000000
- -
- public getScriptExpressions = () => this.scriptExpressions; - public getScriptExpressions = () => this.scriptExpressions;
- -
- private _toOutputDescriptor = (seIndex: number): string => {
- if (seIndex >= this.scriptExpressions.length) {
- return this.cryptoKey.getOutputDescriptorContent();
- } else {
- return `${this.scriptExpressions[seIndex].getExpression()}(${this._toOutputDescriptor(seIndex + 1)})`;
- }
- };
-
- public toString = () => {
- return this._toOutputDescriptor(0);
- };
-
- toDataItem = () => { - toDataItem = () => {
- let dataItem = this.cryptoKey.toDataItem(); - let dataItem = this.cryptoKey.toDataItem();
- if ( - if (
@ -625,9 +676,10 @@ index cd3009c..0000000
- public static fromDataItem = (dataItem: DataItem) => { - public static fromDataItem = (dataItem: DataItem) => {
- const scriptExpressions: ScriptExpression[] = []; - const scriptExpressions: ScriptExpression[] = [];
- let _dataItem = dataItem; - let _dataItem = dataItem;
- // eslint-disable-next-line no-constant-condition
- while (true) { - while (true) {
- let _tag = _dataItem.getTag() || undefined; - let _tag = _dataItem.getTag();
- const se = ScriptExpression.fromTag(_tag); - const se = ScriptExpression.fromTag(_tag as number);
- if (se) { - if (se) {
- scriptExpressions.push(se); - scriptExpressions.push(se);
- if (_dataItem.getData() instanceof DataItem) { - if (_dataItem.getData() instanceof DataItem) {
@ -646,7 +698,7 @@ index cd3009c..0000000
- (scriptExpressions[seLength - 1].getExpression() === - (scriptExpressions[seLength - 1].getExpression() ===
- ScriptExpressions.MULTISIG.getExpression() || - ScriptExpressions.MULTISIG.getExpression() ||
- scriptExpressions[seLength - 1].getExpression() === - scriptExpressions[seLength - 1].getExpression() ===
- ScriptExpressions.SORTED_MULTISIG.getExpression()); - ScriptExpressions.SORTED_MULTISIG.getExpression());
- //TODO: judge is multi key by scriptExpressions - //TODO: judge is multi key by scriptExpressions
- if (isMultiKey) { - if (isMultiKey) {
- const multiKey = MultiKey.fromDataItem(_dataItem); - const multiKey = MultiKey.fromDataItem(_dataItem);
@ -707,10 +759,10 @@ index 626b647..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts
deleted file mode 100644 deleted file mode 100644
index 0460694..0000000 index 5d7e3fe..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/Decoder/index.ts
+++ /dev/null +++ /dev/null
@@ -1,40 +0,0 @@ @@ -1,41 +0,0 @@
-import { URDecoder } from '@ngraveio/bc-ur'; -import { URDecoder } from '@ngraveio/bc-ur';
-import { -import {
- Bytes, - Bytes,
@ -723,6 +775,7 @@ index 0460694..0000000
- CryptoPSBT, - CryptoPSBT,
-} from '..'; -} from '..';
-import { RegistryTypes } from '../RegistryType'; -import { RegistryTypes } from '../RegistryType';
-import { UnknownURTypeError } from '../errors';
- -
-export class URRegistryDecoder extends URDecoder { -export class URRegistryDecoder extends URDecoder {
- public resultRegistryType = () => { - public resultRegistryType = () => {
@ -745,7 +798,7 @@ index 0460694..0000000
- case RegistryTypes.CRYPTO_ACCOUNT.getType(): - case RegistryTypes.CRYPTO_ACCOUNT.getType():
- return CryptoAccount.fromCBOR(ur.cbor); - return CryptoAccount.fromCBOR(ur.cbor);
- default: - default:
- throw new Error( - throw new UnknownURTypeError(
- `#[ur-registry][Decoder][fn.resultRegistryType]: registry type ${ur.type} is not supported now`, - `#[ur-registry][Decoder][fn.resultRegistryType]: registry type ${ur.type} is not supported now`,
- ); - );
- } - }
@ -753,15 +806,16 @@ index 0460694..0000000
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts b/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts
deleted file mode 100644 deleted file mode 100644
index 0522fbd..0000000 index ced19dc..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/MultiKey.ts
+++ /dev/null +++ /dev/null
@@ -1,54 +0,0 @@ @@ -1,60 +0,0 @@
-import { CryptoECKey } from './CryptoECKey'; -import { CryptoECKey } from './CryptoECKey';
-import { CryptoHDKey } from './CryptoHDKey'; -import { CryptoHDKey } from './CryptoHDKey';
-import { DataItem } from './lib/DataItem'; -import { DataItem } from './lib/DataItem';
-import { RegistryItem } from './RegistryItem'; -import { RegistryItem } from './RegistryItem';
-import { RegistryType, RegistryTypes } from './RegistryType'; -import { RegistryType, RegistryTypes } from './RegistryType';
-import { DataItemMap } from './types';
- -
-enum Keys { -enum Keys {
- threshold = 1, - threshold = 1,
@ -769,24 +823,24 @@ index 0522fbd..0000000
-} -}
- -
-export class MultiKey extends RegistryItem { -export class MultiKey extends RegistryItem {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- getRegistryType: () => RegistryType; - getRegistryType: () => RegistryType;
- -
- constructor( - constructor(
- private threshold: number, - private threshold: number,
- private ecKeys: CryptoECKey[], - private keys: (CryptoECKey | CryptoHDKey)[],
- private hdKeys: CryptoHDKey[],
- ) { - ) {
- super(); - super();
- } - }
- -
- getThreshold = () => this.threshold; - getThreshold = () => this.threshold;
- getEcKeys = () => this.ecKeys as CryptoECKey[]; - getKeys = () => this.keys;
- getHdKeys = () => this.hdKeys as CryptoHDKey[];
- -
- toDataItem = () => { - toDataItem = () => {
- const map = {}; - const map: DataItemMap = {};
- map[Keys.threshold] = this.threshold; - map[Keys.threshold] = this.threshold;
- const keys: DataItem[] = [...this.ecKeys, ...this.hdKeys].map((k) => { - const keys: DataItem[] = this.keys.map((k) => {
- const dataItem = k.toDataItem(); - const dataItem = k.toDataItem();
- dataItem.setTag(k.getRegistryType().getTag()); - dataItem.setTag(k.getRegistryType().getTag());
- return dataItem; - return dataItem;
@ -795,20 +849,25 @@ index 0522fbd..0000000
- return new DataItem(map); - return new DataItem(map);
- }; - };
- -
- getOutputDescriptorContent = () => {
- return [this.getThreshold(),
- this.keys.map(k => k.getOutputDescriptorContent()).join(','),
- ].join(',');
- };
-
- static fromDataItem = (dataItem: DataItem) => { - static fromDataItem = (dataItem: DataItem) => {
- const map = dataItem.getData(); - const map = dataItem.getData();
- const threshold = map[Keys.threshold]; - const threshold = map[Keys.threshold];
- const keys = map[Keys.keys] as DataItem[]; - const _keys = map[Keys.keys] as DataItem[];
- const ecKeys = []; - const keys: (CryptoECKey | CryptoHDKey)[] = [];
- const hdKeys = []; - _keys.forEach((k) => {
- keys.forEach((k) => {
- if (k.getTag() === RegistryTypes.CRYPTO_HDKEY.getTag()) { - if (k.getTag() === RegistryTypes.CRYPTO_HDKEY.getTag()) {
- hdKeys.push(CryptoHDKey.fromDataItem(k)); - keys.push(CryptoHDKey.fromDataItem(k));
- } else if (k.getTag() === RegistryTypes.CRYPTO_ECKEY.getTag()) { - } else if (k.getTag() === RegistryTypes.CRYPTO_ECKEY.getTag()) {
- ecKeys.push(CryptoECKey.fromDataItem(k)); - keys.push(CryptoECKey.fromDataItem(k));
- } - }
- }); - });
- return new MultiKey(threshold, ecKeys, hdKeys); - return new MultiKey(threshold, keys);
- }; - };
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts b/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts b/node_modules/@keystonehq/bc-ur-registry/src/PathComponent.ts
@ -914,7 +973,7 @@ index 64637bc..0000000
-}; -};
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts b/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts b/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts
deleted file mode 100644 deleted file mode 100644
index fdd3f05..0000000 index 8fbf0db..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/ScriptExpression.ts
+++ /dev/null +++ /dev/null
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
@ -940,16 +999,27 @@ index fdd3f05..0000000
- WITNESS_PUBLIC_KEY_HASH: new ScriptExpression(404, 'wpkh'), - WITNESS_PUBLIC_KEY_HASH: new ScriptExpression(404, 'wpkh'),
- COMBO: new ScriptExpression(405, 'combo'), - COMBO: new ScriptExpression(405, 'combo'),
- MULTISIG: new ScriptExpression(406, 'multi'), - MULTISIG: new ScriptExpression(406, 'multi'),
- SORTED_MULTISIG: new ScriptExpression(407, 'sorted'), - SORTED_MULTISIG: new ScriptExpression(407, 'sortedmulti'),
- ADDRESS: new ScriptExpression(307, 'addr'), - ADDRESS: new ScriptExpression(307, 'addr'),
- RAW_SCRIPT: new ScriptExpression(408, 'raw'), - RAW_SCRIPT: new ScriptExpression(408, 'raw'),
-}; -};
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/errors/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/errors/index.ts
deleted file mode 100644
index dd2b0bd..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/errors/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export class UnknownURTypeError extends Error {
- constructor(message: string) {
- super(message);
- }
-}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/index.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/index.ts b/node_modules/@keystonehq/bc-ur-registry/src/index.ts
deleted file mode 100644 deleted file mode 100644
index 172a1e5..0000000 index bb07bc8..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/index.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/index.ts
+++ /dev/null +++ /dev/null
@@ -1,89 +0,0 @@ @@ -1,110 +0,0 @@
-import './patchCBOR'; -import './patchCBOR';
- -
-import { CryptoHDKey } from './CryptoHDKey'; -import { CryptoHDKey } from './CryptoHDKey';
@ -971,6 +1041,7 @@ index 172a1e5..0000000
-import { ScriptExpressions } from './ScriptExpression'; -import { ScriptExpressions } from './ScriptExpression';
-import { PathComponent } from './PathComponent'; -import { PathComponent } from './PathComponent';
- -
-import { RegistryItem } from './RegistryItem';
-import { RegistryTypes, RegistryType } from './RegistryType'; -import { RegistryTypes, RegistryType } from './RegistryType';
- -
-import { -import {
@ -983,7 +1054,6 @@ index 172a1e5..0000000
-} from './lib'; -} from './lib';
- -
-export { DataItem } from './lib'; -export { DataItem } from './lib';
-export { RegistryItem } from './RegistryItem';
- -
-import { patchTags } from './utils'; -import { patchTags } from './utils';
- -
@ -1014,9 +1084,12 @@ index 172a1e5..0000000
- -
-const extend = { -const extend = {
- RegistryTypes, - RegistryTypes,
- RegistryItem,
- RegistryType, - RegistryType,
-
- decodeToDataItem, - decodeToDataItem,
- encodeDataItem, - encodeDataItem,
-
- cbor, - cbor,
-}; -};
- -
@ -1038,6 +1111,24 @@ index 172a1e5..0000000
- extend, - extend,
-}; -};
- -
-export * from './errors';
-export * from './Decoder';
-export * from './lib';
-export * from './CryptoAccount'
-export * from './CryptoPSBT'
-export * from './CryptoHDKey'
-export * from './CryptoOutput'
-export * from './CryptoCoinInfo'
-export * from './CryptoECKey'
-export * from './MultiKey'
-export * from './CryptoKeypath'
-export * from './patchCBOR'
-export * from './PathComponent'
-export * from './RegistryItem'
-export * from './RegistryType'
-export * from './types'
-export * from './utils'
-
-export default URlib; -export default URlib;
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts b/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts b/node_modules/@keystonehq/bc-ur-registry/src/lib/DataItem.ts
deleted file mode 100644 deleted file mode 100644
@ -1070,12 +1161,54 @@ index 9727f7e..0000000
- return this.data; - return this.data;
- }; - };
-} -}
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.d.ts b/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.d.ts
deleted file mode 100644
index 6374ba7..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.d.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-export namespace config {
- const useToJSON: boolean;
-}
-export function addWriter(format: any, writerFunction: any): void;
-export function addReader(format: any, readerFunction: any): void;
-export function encode(data: any, format: any): any;
-export function encodeDataItem(data: any, format?: any): any;
-export function decode(data: any, format: any): any;
-export function decodeToDataItem(data: any, format?: any): import("./DataItem").DataItem;
-export function addSemanticEncode(tag: any, fn: any): {
- config: {
- useToJSON: boolean;
- };
- addWriter: (format: any, writerFunction: any) => void;
- addReader: (format: any, readerFunction: any) => void;
- encode: (data: any, format: any) => any;
- encodeDataItem: (data: any, format: any) => any;
- decode: (data: any, format: any) => any;
- decodeToDataItem: (data: any, format: any) => import("./DataItem").DataItem;
- addSemanticEncode: (tag: any, fn: any) => any;
- addSemanticDecode: (tag: any, fn: any) => any;
-};
-export function addSemanticDecode(tag: any, fn: any): {
- config: {
- useToJSON: boolean;
- };
- addWriter: (format: any, writerFunction: any) => void;
- addReader: (format: any, readerFunction: any) => void;
- encode: (data: any, format: any) => any;
- encodeDataItem: (data: any, format: any) => any;
- decode: (data: any, format: any) => any;
- decodeToDataItem: (data: any, format: any) => import("./DataItem").DataItem;
- addSemanticEncode: (tag: any, fn: any) => any;
- addSemanticDecode: (tag: any, fn: any) => any;
-};
-//# sourceMappingURL=cbor-sync.d.ts.map
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js b/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js diff --git a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js b/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js
deleted file mode 100644 deleted file mode 100644
index 63e5b3a..0000000 index df8db90..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js --- a/node_modules/@keystonehq/bc-ur-registry/src/lib/cbor-sync.js
+++ /dev/null +++ /dev/null
@@ -1,695 +0,0 @@ @@ -1,693 +0,0 @@
-(function (global, factory) { -(function (global, factory) {
- if (typeof define === 'function' && define.amd) { - if (typeof define === 'function' && define.amd) {
- define([], factory); - define([], factory);
@ -1531,8 +1664,6 @@ index 63e5b3a..0000000
- semanticDecoders[tag] = fn; - semanticDecoders[tag] = fn;
- return this; - return this;
- }, - },
- Reader: Reader,
- Writer: Writer,
- }; - };
- -
- /** Node.js Buffers **/ - /** Node.js Buffers **/
@ -1788,7 +1919,7 @@ index deb0156..0000000
-export { DataItem } from './DataItem'; -export { DataItem } from './DataItem';
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts b/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts b/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts
deleted file mode 100644 deleted file mode 100644
index b9909a7..0000000 index 218e912..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/patchCBOR.ts
+++ /dev/null +++ /dev/null
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
@ -1802,17 +1933,29 @@ index b9909a7..0000000
-const scriptExpressionTags = Object.values(ScriptExpressions).map((se) => -const scriptExpressionTags = Object.values(ScriptExpressions).map((se) =>
- se.getTag(), - se.getTag(),
-); -);
-patchTags(registryTags.concat(scriptExpressionTags)); -patchTags(registryTags.concat(scriptExpressionTags) as number[]);
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/types.ts b/node_modules/@keystonehq/bc-ur-registry/src/types.ts
deleted file mode 100644
index 29aa370..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/types.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export interface ICryptoKey {
- isECKey: () => boolean;
- getOutputDescriptorContent: () => string;
-}
-
-export type DataItemMap = Record<string, any>;
diff --git a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts b/node_modules/@keystonehq/bc-ur-registry/src/utils.ts diff --git a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts b/node_modules/@keystonehq/bc-ur-registry/src/utils.ts
deleted file mode 100644 deleted file mode 100644
index ee39b78..0000000 index e38112b..0000000
--- a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts --- a/node_modules/@keystonehq/bc-ur-registry/src/utils.ts
+++ /dev/null +++ /dev/null
@@ -1,19 +0,0 @@ @@ -1,19 +0,0 @@
-import { addSemanticDecode, addSemanticEncode, DataItem } from './lib'; -import { addSemanticDecode, addSemanticEncode, DataItem } from './lib';
- -
-const alreadyPatchedTag = []; -const alreadyPatchedTag: number[] = [];
-export const patchTags = (tags: number[]) => { -export const patchTags = (tags: number[]): void => {
- tags.forEach((tag) => { - tags.forEach((tag) => {
- if (alreadyPatchedTag.find((i) => i === tag)) return; - if (alreadyPatchedTag.find((i) => i === tag)) return;
- addSemanticEncode(tag, (data: any) => { - addSemanticEncode(tag, (data: any) => {