@keystonehq/bc-ur-registry-avalanche 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/AvalancheSignRequest.cjs +112 -0
  2. package/dist/AvalancheSignRequest.cjs.map +1 -0
  3. package/dist/AvalancheSignRequest.d.cts +25 -0
  4. package/dist/AvalancheSignRequest.d.cts.map +1 -0
  5. package/dist/AvalancheSignRequest.d.mts +25 -0
  6. package/dist/AvalancheSignRequest.d.mts.map +1 -0
  7. package/dist/AvalancheSignRequest.mjs +77 -0
  8. package/dist/AvalancheSignRequest.mjs.map +1 -0
  9. package/dist/AvalancheSignature.cjs +40 -0
  10. package/dist/AvalancheSignature.cjs.map +1 -0
  11. package/dist/{AvalancheSignature.d.ts → AvalancheSignature.d.cts} +13 -13
  12. package/dist/AvalancheSignature.d.cts.map +1 -0
  13. package/dist/AvalancheSignature.d.mts +13 -0
  14. package/dist/AvalancheSignature.d.mts.map +1 -0
  15. package/dist/AvalancheSignature.mjs +38 -0
  16. package/dist/AvalancheSignature.mjs.map +1 -0
  17. package/dist/AvalancheUtxo.cjs +63 -0
  18. package/dist/AvalancheUtxo.cjs.map +1 -0
  19. package/dist/AvalancheUtxo.d.cts +26 -0
  20. package/dist/AvalancheUtxo.d.cts.map +1 -0
  21. package/dist/AvalancheUtxo.d.mts +26 -0
  22. package/dist/AvalancheUtxo.d.mts.map +1 -0
  23. package/dist/AvalancheUtxo.mjs +61 -0
  24. package/dist/AvalancheUtxo.mjs.map +1 -0
  25. package/dist/RegistryType.cjs +10 -0
  26. package/dist/RegistryType.cjs.map +1 -0
  27. package/dist/{RegistryType.d.ts → RegistryType.d.cts} +7 -5
  28. package/dist/RegistryType.d.cts.map +1 -0
  29. package/dist/RegistryType.d.mts +7 -0
  30. package/dist/RegistryType.d.mts.map +1 -0
  31. package/dist/RegistryType.mjs +8 -0
  32. package/dist/RegistryType.mjs.map +1 -0
  33. package/dist/index.cjs +28 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.cts +4 -0
  36. package/dist/index.d.cts.map +1 -0
  37. package/dist/index.d.mts +4 -0
  38. package/dist/index.d.mts.map +1 -0
  39. package/dist/index.mjs +10 -0
  40. package/dist/index.mjs.map +1 -0
  41. package/package.json +17 -11
  42. package/src/AvalancheSignRequest.ts +35 -33
  43. package/src/AvalancheUtxo.ts +100 -0
  44. package/src/RegistryType.ts +1 -0
  45. package/dist/AvalancheSignRequest.d.ts +0 -24
  46. package/dist/bc-ur-registry-avalanche.cjs.development.js +0 -132
  47. package/dist/bc-ur-registry-avalanche.cjs.development.js.map +0 -1
  48. package/dist/bc-ur-registry-avalanche.cjs.production.min.js +0 -2
  49. package/dist/bc-ur-registry-avalanche.cjs.production.min.js.map +0 -1
  50. package/dist/bc-ur-registry-avalanche.esm.js +0 -120
  51. package/dist/bc-ur-registry-avalanche.esm.js.map +0 -1
  52. package/dist/index.d.ts +0 -3
  53. package/dist/index.js +0 -8
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AvalancheSignRequest = void 0;
37
+ const bc_ur_registry_1 = require("@keystonehq/bc-ur-registry");
38
+ const RegistryType_1 = require("./RegistryType.cjs");
39
+ const uuid = __importStar(require("uuid"));
40
+ const AvalancheUtxo_1 = require("./AvalancheUtxo.cjs");
41
+ const { RegistryTypes } = bc_ur_registry_1.extend;
42
+ var Keys;
43
+ (function (Keys) {
44
+ Keys[Keys["requestId"] = 1] = "requestId";
45
+ Keys[Keys["signData"] = 2] = "signData";
46
+ Keys[Keys["derivationPath"] = 3] = "derivationPath";
47
+ Keys[Keys["utxos"] = 4] = "utxos";
48
+ })(Keys || (Keys = {}));
49
+ class AvalancheSignRequest extends bc_ur_registry_1.RegistryItem {
50
+ constructor(args) {
51
+ super();
52
+ this.getRegistryType = () => RegistryType_1.ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;
53
+ this.getRequestId = () => this.requestId;
54
+ this.getSignData = () => this.data;
55
+ this.getUtxos = () => this.utxos;
56
+ this.getDerivationPath = () => this.derivationPath;
57
+ this.toDataItem = () => {
58
+ const map = {};
59
+ if (this.requestId) {
60
+ map[Keys.requestId] = new bc_ur_registry_1.DataItem(this.requestId, RegistryTypes.UUID.getTag());
61
+ }
62
+ map[Keys.signData] = Buffer.from(this.data);
63
+ map[Keys.derivationPath] = this.derivationPath;
64
+ map[Keys.utxos] = this.utxos.map((utxo) => {
65
+ const res = utxo.toDataItem();
66
+ res.setTag(utxo.getRegistryType().getTag());
67
+ return res;
68
+ });
69
+ return new bc_ur_registry_1.DataItem(map);
70
+ };
71
+ this.requestId = args.requestId;
72
+ this.data = args.data;
73
+ this.derivationPath = args.derivationPath;
74
+ this.utxos = args.utxos;
75
+ }
76
+ static constructAvalancheRequest(data, derivationPath, utxos, requestId) {
77
+ let _requestId;
78
+ if (typeof requestId === "string") {
79
+ _requestId = Buffer.from(uuid.parse(requestId));
80
+ }
81
+ else if (requestId instanceof Buffer) {
82
+ _requestId = requestId;
83
+ }
84
+ else {
85
+ _requestId = Buffer.from(uuid.parse(uuid.v4()));
86
+ }
87
+ const avalancheUtxos = utxos.map((utxo) => AvalancheUtxo_1.AvalancheUtxo.constructAvalancheUtxo(utxo));
88
+ return new AvalancheSignRequest({
89
+ data,
90
+ requestId: _requestId,
91
+ derivationPath,
92
+ utxos: avalancheUtxos,
93
+ });
94
+ }
95
+ }
96
+ exports.AvalancheSignRequest = AvalancheSignRequest;
97
+ AvalancheSignRequest.fromDataItem = (dataItem) => {
98
+ const map = dataItem.getData();
99
+ const requestId = map[Keys.requestId]
100
+ ? map[Keys.requestId].getData()
101
+ : undefined;
102
+ const data = map[Keys.signData];
103
+ const derivationPath = map[Keys.signData];
104
+ const utxos = map[Keys.utxos].map((utxo) => AvalancheUtxo_1.AvalancheUtxo.fromDataItem(utxo));
105
+ return new AvalancheSignRequest({
106
+ requestId,
107
+ data,
108
+ derivationPath,
109
+ utxos,
110
+ });
111
+ };
112
+ //# sourceMappingURL=AvalancheSignRequest.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignRequest.cjs","sourceRoot":"","sources":["../src/AvalancheSignRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,qDAAuD;AACvD,2CAA6B;AAC7B,uDAAmE;AAEnE,MAAM,EAAE,aAAa,EAAE,GAAG,uBAAM,CAAC;AASjC,IAAK,IAKJ;AALD,WAAK,IAAI;IACP,yCAAa,CAAA;IACb,uCAAQ,CAAA;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I,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;QAC/B,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAoB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,EAAE,CACpE,6BAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CACjC,CAAC;IAEF,OAAO,IAAI,oBAAoB,CAAC;QAC9B,SAAS;QACT,IAAI;QACJ,cAAc;QACd,KAAK;KACN,CAAC,CAAC;AACL,CAAC,AAjByB,CAiBxB","sourcesContent":["import {\n DataItem,\n RegistryItem,\n extend,\n DataItemMap,\n CryptoKeypath,\n} from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nimport * as uuid from \"uuid\";\nimport { AvalancheUtxo, AvalancheUtxoData } from \"./AvalancheUtxo\";\n\nconst { RegistryTypes } = extend;\n\ntype signRequestProps = {\n requestId?: Buffer;\n data: Buffer;\n derivationPath: CryptoKeypath;\n utxos: AvalancheUtxo[];\n};\n\nenum Keys {\n requestId = 1,\n signData,\n derivationPath,\n utxos,\n}\nexport class AvalancheSignRequest extends RegistryItem {\n private requestId?: Buffer;\n private data: Buffer;\n private derivationPath: CryptoKeypath;\n private utxos: AvalancheUtxo[];\n\n\n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;\n\n constructor(args: signRequestProps) {\n super();\n this.requestId = args.requestId;\n this.data = args.data;\n this.derivationPath = args.derivationPath;\n this.utxos = args.utxos;\n }\n\n public getRequestId = () => this.requestId;\n public getSignData = () => this.data;\n public getUtxos = () => this.utxos;\n public getDerivationPath = () => this.derivationPath;\n\n public toDataItem = () => {\n const map: DataItemMap = {};\n if (this.requestId) {\n map[Keys.requestId] = new DataItem(\n this.requestId,\n RegistryTypes.UUID.getTag()\n );\n }\n\n map[Keys.signData] = Buffer.from(this.data);\n map[Keys.derivationPath] = this.derivationPath;\n map[Keys.utxos] = this.utxos.map((utxo) => {\n const res = utxo.toDataItem();\n res.setTag(utxo.getRegistryType().getTag());\n return res;\n });\n\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const requestId = map[Keys.requestId]\n ? map[Keys.requestId].getData()\n : undefined;\n const data = map[Keys.signData];\n const derivationPath = map[Keys.signData];\n const utxos: AvalancheUtxo[] = map[Keys.utxos].map((utxo: DataItem) =>\n AvalancheUtxo.fromDataItem(utxo)\n );\n\n return new AvalancheSignRequest({\n requestId,\n data,\n derivationPath,\n utxos,\n });\n };\n\n public static constructAvalancheRequest(\n data: Buffer,\n derivationPath: CryptoKeypath,\n utxos: AvalancheUtxoData[],\n requestId?: string | Buffer,\n ) {\n let _requestId;\n if (typeof requestId === \"string\") {\n _requestId = Buffer.from(uuid.parse(requestId) as Uint8Array);\n } else if (requestId instanceof Buffer) {\n _requestId = requestId;\n } else {\n _requestId = Buffer.from(uuid.parse(uuid.v4()) as Uint8Array);\n }\n const avalancheUtxos = utxos.map((utxo) =>\n AvalancheUtxo.constructAvalancheUtxo(utxo)\n );\n\n return new AvalancheSignRequest({\n data,\n requestId: _requestId,\n derivationPath,\n utxos: avalancheUtxos,\n });\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { DataItem, RegistryItem, CryptoKeypath } from "@keystonehq/bc-ur-registry";
2
+ import { AvalancheUtxo, AvalancheUtxoData } from "./AvalancheUtxo.cjs";
3
+ type signRequestProps = {
4
+ requestId?: Buffer;
5
+ data: Buffer;
6
+ derivationPath: CryptoKeypath;
7
+ utxos: AvalancheUtxo[];
8
+ };
9
+ export declare class AvalancheSignRequest extends RegistryItem {
10
+ private requestId?;
11
+ private data;
12
+ private derivationPath;
13
+ private utxos;
14
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
15
+ constructor(args: signRequestProps);
16
+ getRequestId: () => Buffer<ArrayBufferLike>;
17
+ getSignData: () => Buffer<ArrayBufferLike>;
18
+ getUtxos: () => AvalancheUtxo[];
19
+ getDerivationPath: () => CryptoKeypath;
20
+ toDataItem: () => DataItem;
21
+ static fromDataItem: (dataItem: DataItem) => AvalancheSignRequest;
22
+ static constructAvalancheRequest(data: Buffer, derivationPath: CryptoKeypath, utxos: AvalancheUtxoData[], requestId?: string | Buffer): AvalancheSignRequest;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=AvalancheSignRequest.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignRequest.d.cts","sourceRoot":"","sources":["../src/AvalancheSignRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EAGZ,aAAa,EACd,mCAAmC;AAGpC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,4BAAwB;AAInE,KAAK,gBAAgB,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,aAAa,CAAC;IAC9B,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAQF,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,KAAK,CAAkB;IAG/B,eAAe,0DAAsD;gBAEzD,IAAI,EAAE,gBAAgB;IAQ3B,YAAY,gCAAwB;IACpC,WAAW,gCAAmB;IAC9B,QAAQ,wBAAoB;IAC5B,iBAAiB,sBAA6B;IAE9C,UAAU,iBAkBf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,0BAiB9C;WAEY,yBAAyB,CACrC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,aAAa,EAC7B,KAAK,EAAE,iBAAiB,EAAE,EAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAqB9B"}
@@ -0,0 +1,25 @@
1
+ import { DataItem, RegistryItem, CryptoKeypath } from "@keystonehq/bc-ur-registry";
2
+ import { AvalancheUtxo, AvalancheUtxoData } from "./AvalancheUtxo.mjs";
3
+ type signRequestProps = {
4
+ requestId?: Buffer;
5
+ data: Buffer;
6
+ derivationPath: CryptoKeypath;
7
+ utxos: AvalancheUtxo[];
8
+ };
9
+ export declare class AvalancheSignRequest extends RegistryItem {
10
+ private requestId?;
11
+ private data;
12
+ private derivationPath;
13
+ private utxos;
14
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
15
+ constructor(args: signRequestProps);
16
+ getRequestId: () => Buffer<ArrayBufferLike>;
17
+ getSignData: () => Buffer<ArrayBufferLike>;
18
+ getUtxos: () => AvalancheUtxo[];
19
+ getDerivationPath: () => CryptoKeypath;
20
+ toDataItem: () => DataItem;
21
+ static fromDataItem: (dataItem: DataItem) => AvalancheSignRequest;
22
+ static constructAvalancheRequest(data: Buffer, derivationPath: CryptoKeypath, utxos: AvalancheUtxoData[], requestId?: string | Buffer): AvalancheSignRequest;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=AvalancheSignRequest.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignRequest.d.mts","sourceRoot":"","sources":["../src/AvalancheSignRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EAGZ,aAAa,EACd,mCAAmC;AAGpC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,4BAAwB;AAInE,KAAK,gBAAgB,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,aAAa,CAAC;IAC9B,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAQF,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,KAAK,CAAkB;IAG/B,eAAe,0DAAsD;gBAEzD,IAAI,EAAE,gBAAgB;IAQ3B,YAAY,gCAAwB;IACpC,WAAW,gCAAmB;IAC9B,QAAQ,wBAAoB;IAC5B,iBAAiB,sBAA6B;IAE9C,UAAU,iBAkBf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,0BAiB9C;WAEY,yBAAyB,CACrC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,aAAa,EAC7B,KAAK,EAAE,iBAAiB,EAAE,EAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAqB9B"}
@@ -0,0 +1,77 @@
1
+ import { DataItem, extend, CryptoKeypath } from "@keystonehq/bc-ur-registry";
2
+ import $keystonehqbcurregistry from "@keystonehq/bc-ur-registry";
3
+ const { RegistryItem } = $keystonehqbcurregistry;
4
+ import { ExtendedRegistryTypes } from "./RegistryType.mjs";
5
+ import * as uuid from "uuid";
6
+ import { AvalancheUtxo } from "./AvalancheUtxo.mjs";
7
+ const { RegistryTypes } = extend;
8
+ var Keys;
9
+ (function (Keys) {
10
+ Keys[Keys["requestId"] = 1] = "requestId";
11
+ Keys[Keys["signData"] = 2] = "signData";
12
+ Keys[Keys["derivationPath"] = 3] = "derivationPath";
13
+ Keys[Keys["utxos"] = 4] = "utxos";
14
+ })(Keys || (Keys = {}));
15
+ export class AvalancheSignRequest extends RegistryItem {
16
+ constructor(args) {
17
+ super();
18
+ this.getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;
19
+ this.getRequestId = () => this.requestId;
20
+ this.getSignData = () => this.data;
21
+ this.getUtxos = () => this.utxos;
22
+ this.getDerivationPath = () => this.derivationPath;
23
+ this.toDataItem = () => {
24
+ const map = {};
25
+ if (this.requestId) {
26
+ map[Keys.requestId] = new DataItem(this.requestId, RegistryTypes.UUID.getTag());
27
+ }
28
+ map[Keys.signData] = Buffer.from(this.data);
29
+ map[Keys.derivationPath] = this.derivationPath;
30
+ map[Keys.utxos] = this.utxos.map((utxo) => {
31
+ const res = utxo.toDataItem();
32
+ res.setTag(utxo.getRegistryType().getTag());
33
+ return res;
34
+ });
35
+ return new DataItem(map);
36
+ };
37
+ this.requestId = args.requestId;
38
+ this.data = args.data;
39
+ this.derivationPath = args.derivationPath;
40
+ this.utxos = args.utxos;
41
+ }
42
+ static constructAvalancheRequest(data, derivationPath, utxos, requestId) {
43
+ let _requestId;
44
+ if (typeof requestId === "string") {
45
+ _requestId = Buffer.from(uuid.parse(requestId));
46
+ }
47
+ else if (requestId instanceof Buffer) {
48
+ _requestId = requestId;
49
+ }
50
+ else {
51
+ _requestId = Buffer.from(uuid.parse(uuid.v4()));
52
+ }
53
+ const avalancheUtxos = utxos.map((utxo) => AvalancheUtxo.constructAvalancheUtxo(utxo));
54
+ return new AvalancheSignRequest({
55
+ data,
56
+ requestId: _requestId,
57
+ derivationPath,
58
+ utxos: avalancheUtxos,
59
+ });
60
+ }
61
+ }
62
+ AvalancheSignRequest.fromDataItem = (dataItem) => {
63
+ const map = dataItem.getData();
64
+ const requestId = map[Keys.requestId]
65
+ ? map[Keys.requestId].getData()
66
+ : undefined;
67
+ const data = map[Keys.signData];
68
+ const derivationPath = map[Keys.signData];
69
+ const utxos = map[Keys.utxos].map((utxo) => AvalancheUtxo.fromDataItem(utxo));
70
+ return new AvalancheSignRequest({
71
+ requestId,
72
+ data,
73
+ derivationPath,
74
+ utxos,
75
+ });
76
+ };
77
+ //# sourceMappingURL=AvalancheSignRequest.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignRequest.mjs","sourceRoot":"","sources":["../src/AvalancheSignRequest.ts"],"names":[],"mappings":";;;AAOA,OAAO,EAAE,qBAAqB,EAAE,2BAAuB;AACvD,OAAO,KAAK,IAAI,aAAa;AAC7B,OAAO,EAAE,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AAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;QACnC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;QAC/B,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAoB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,EAAE,CACpE,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CACjC,CAAC;IAEF,OAAO,IAAI,oBAAoB,CAAC;QAC9B,SAAS;QACT,IAAI;QACJ,cAAc;QACd,KAAK;KACN,CAAC,CAAC;AACL,CAAC,AAjByB,CAiBxB","sourcesContent":["import {\n DataItem,\n RegistryItem,\n extend,\n DataItemMap,\n CryptoKeypath,\n} from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nimport * as uuid from \"uuid\";\nimport { AvalancheUtxo, AvalancheUtxoData } from \"./AvalancheUtxo\";\n\nconst { RegistryTypes } = extend;\n\ntype signRequestProps = {\n requestId?: Buffer;\n data: Buffer;\n derivationPath: CryptoKeypath;\n utxos: AvalancheUtxo[];\n};\n\nenum Keys {\n requestId = 1,\n signData,\n derivationPath,\n utxos,\n}\nexport class AvalancheSignRequest extends RegistryItem {\n private requestId?: Buffer;\n private data: Buffer;\n private derivationPath: CryptoKeypath;\n private utxos: AvalancheUtxo[];\n\n\n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;\n\n constructor(args: signRequestProps) {\n super();\n this.requestId = args.requestId;\n this.data = args.data;\n this.derivationPath = args.derivationPath;\n this.utxos = args.utxos;\n }\n\n public getRequestId = () => this.requestId;\n public getSignData = () => this.data;\n public getUtxos = () => this.utxos;\n public getDerivationPath = () => this.derivationPath;\n\n public toDataItem = () => {\n const map: DataItemMap = {};\n if (this.requestId) {\n map[Keys.requestId] = new DataItem(\n this.requestId,\n RegistryTypes.UUID.getTag()\n );\n }\n\n map[Keys.signData] = Buffer.from(this.data);\n map[Keys.derivationPath] = this.derivationPath;\n map[Keys.utxos] = this.utxos.map((utxo) => {\n const res = utxo.toDataItem();\n res.setTag(utxo.getRegistryType().getTag());\n return res;\n });\n\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const requestId = map[Keys.requestId]\n ? map[Keys.requestId].getData()\n : undefined;\n const data = map[Keys.signData];\n const derivationPath = map[Keys.signData];\n const utxos: AvalancheUtxo[] = map[Keys.utxos].map((utxo: DataItem) =>\n AvalancheUtxo.fromDataItem(utxo)\n );\n\n return new AvalancheSignRequest({\n requestId,\n data,\n derivationPath,\n utxos,\n });\n };\n\n public static constructAvalancheRequest(\n data: Buffer,\n derivationPath: CryptoKeypath,\n utxos: AvalancheUtxoData[],\n requestId?: string | Buffer,\n ) {\n let _requestId;\n if (typeof requestId === \"string\") {\n _requestId = Buffer.from(uuid.parse(requestId) as Uint8Array);\n } else if (requestId instanceof Buffer) {\n _requestId = requestId;\n } else {\n _requestId = Buffer.from(uuid.parse(uuid.v4()) as Uint8Array);\n }\n const avalancheUtxos = utxos.map((utxo) =>\n AvalancheUtxo.constructAvalancheUtxo(utxo)\n );\n\n return new AvalancheSignRequest({\n data,\n requestId: _requestId,\n derivationPath,\n utxos: avalancheUtxos,\n });\n }\n}\n"]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AvalancheSignature = void 0;
4
+ const bc_ur_registry_1 = require("@keystonehq/bc-ur-registry");
5
+ const RegistryType_1 = require("./RegistryType.cjs");
6
+ const { RegistryTypes, decodeToDataItem } = bc_ur_registry_1.extend;
7
+ var Keys;
8
+ (function (Keys) {
9
+ Keys[Keys["requestId"] = 1] = "requestId";
10
+ Keys[Keys["signature"] = 2] = "signature";
11
+ })(Keys || (Keys = {}));
12
+ class AvalancheSignature extends bc_ur_registry_1.RegistryItem {
13
+ constructor(signature, requestId) {
14
+ super();
15
+ this.getRegistryType = () => RegistryType_1.ExtendedRegistryTypes.AVALANCHE_SIGNATURE;
16
+ this.getRequestId = () => this.requestId;
17
+ this.getSignature = () => this.signature;
18
+ this.toDataItem = () => {
19
+ const map = {};
20
+ if (this.requestId) {
21
+ map[Keys.requestId] = new bc_ur_registry_1.DataItem(this.requestId, RegistryTypes.UUID.getTag());
22
+ }
23
+ map[Keys.signature] = this.signature;
24
+ return new bc_ur_registry_1.DataItem(map);
25
+ };
26
+ this.signature = signature;
27
+ this.requestId = requestId;
28
+ }
29
+ }
30
+ exports.AvalancheSignature = AvalancheSignature;
31
+ AvalancheSignature.fromDataItem = (dataItem) => {
32
+ const map = dataItem.getData();
33
+ const signature = map[Keys.signature];
34
+ return new AvalancheSignature(signature);
35
+ };
36
+ AvalancheSignature.fromCBOR = (_cborPayload) => {
37
+ const dataItem = decodeToDataItem(_cborPayload);
38
+ return AvalancheSignature.fromDataItem(dataItem);
39
+ };
40
+ //# sourceMappingURL=AvalancheSignature.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignature.cjs","sourceRoot":"","sources":["../src/AvalancheSignature.ts"],"names":[],"mappings":";;;AAAA,+DAKoC;AACpC,qDAAuD;AAEvD,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,uBAAM,CAAC;AAEnD,IAAK,IAGJ;AAHD,WAAK,IAAI;IACP,yCAAa,CAAA;IACb,yCAAS,CAAA;AACX,CAAC,EAHI,IAAI,KAAJ,IAAI,QAGR;AAED,MAAa,kBAAmB,SAAQ,6BAAY;IAMlD,YAAY,SAAiB,EAAE,SAAkB;QAC/C,KAAK,EAAE,CAAC;QAHV,o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Types } from \"./RegistryType\";\n\nconst { RegistryTypes, decodeToDataItem } = extend;\n\nenum Keys {\n requestId = 1,\n signature,\n}\n\nexport class AvalancheSignature extends RegistryItem {\n private requestId?: Buffer;\n private signature: Buffer;\n\n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGNATURE;\n\n constructor(signature: Buffer, requestId?: Buffer) {\n super();\n this.signature = signature;\n this.requestId = requestId;\n }\n\n public getRequestId = () => this.requestId;\n public getSignature = () => this.signature;\n\n public toDataItem = () => {\n const map: DataItemMap = {};\n if (this.requestId) {\n map[Keys.requestId] = new DataItem(\n this.requestId,\n RegistryTypes.UUID.getTag()\n );\n }\n map[Keys.signature] = this.signature;\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const signature = map[Keys.signature];\n\n return new AvalancheSignature(signature);\n };\n\n public static fromCBOR = (_cborPayload: Buffer) => {\n const dataItem = decodeToDataItem(_cborPayload);\n return AvalancheSignature.fromDataItem(dataItem);\n };\n}\n"]}
@@ -1,13 +1,13 @@
1
- /// <reference types="node" />
2
- import { DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
3
- export declare class AvalancheSignature extends RegistryItem {
4
- private requestId?;
5
- private signature;
6
- getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
7
- constructor(signature: Buffer, requestId?: Buffer);
8
- getRequestId: () => Buffer | undefined;
9
- getSignature: () => Buffer;
10
- toDataItem: () => DataItem;
11
- static fromDataItem: (dataItem: DataItem) => AvalancheSignature;
12
- static fromCBOR: (_cborPayload: Buffer) => AvalancheSignature;
13
- }
1
+ import { DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
2
+ export declare class AvalancheSignature extends RegistryItem {
3
+ private requestId?;
4
+ private signature;
5
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
6
+ constructor(signature: Buffer, requestId?: Buffer);
7
+ getRequestId: () => Buffer<ArrayBufferLike>;
8
+ getSignature: () => Buffer<ArrayBufferLike>;
9
+ toDataItem: () => DataItem;
10
+ static fromDataItem: (dataItem: DataItem) => AvalancheSignature;
11
+ static fromCBOR: (_cborPayload: Buffer) => AvalancheSignature;
12
+ }
13
+ //# sourceMappingURL=AvalancheSignature.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignature.d.cts","sourceRoot":"","sources":["../src/AvalancheSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,YAAY,EAEb,mCAAmC;AAUpC,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAE1B,eAAe,0DAAmD;gBAEtD,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAM1C,YAAY,gCAAwB;IACpC,YAAY,gCAAwB;IAEpC,UAAU,iBAUf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,wBAK9C;IAEF,OAAc,QAAQ,GAAI,cAAc,MAAM,wBAG5C;CACH"}
@@ -0,0 +1,13 @@
1
+ import { DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
2
+ export declare class AvalancheSignature extends RegistryItem {
3
+ private requestId?;
4
+ private signature;
5
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
6
+ constructor(signature: Buffer, requestId?: Buffer);
7
+ getRequestId: () => Buffer<ArrayBufferLike>;
8
+ getSignature: () => Buffer<ArrayBufferLike>;
9
+ toDataItem: () => DataItem;
10
+ static fromDataItem: (dataItem: DataItem) => AvalancheSignature;
11
+ static fromCBOR: (_cborPayload: Buffer) => AvalancheSignature;
12
+ }
13
+ //# sourceMappingURL=AvalancheSignature.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheSignature.d.mts","sourceRoot":"","sources":["../src/AvalancheSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,YAAY,EAEb,mCAAmC;AAUpC,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAE1B,eAAe,0DAAmD;gBAEtD,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAM1C,YAAY,gCAAwB;IACpC,YAAY,gCAAwB;IAEpC,UAAU,iBAUf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,wBAK9C;IAEF,OAAc,QAAQ,GAAI,cAAc,MAAM,wBAG5C;CACH"}
@@ -0,0 +1,38 @@
1
+ import { extend, DataItem } from "@keystonehq/bc-ur-registry";
2
+ import $keystonehqbcurregistry from "@keystonehq/bc-ur-registry";
3
+ const { RegistryItem } = $keystonehqbcurregistry;
4
+ import { ExtendedRegistryTypes } from "./RegistryType.mjs";
5
+ const { RegistryTypes, decodeToDataItem } = extend;
6
+ var Keys;
7
+ (function (Keys) {
8
+ Keys[Keys["requestId"] = 1] = "requestId";
9
+ Keys[Keys["signature"] = 2] = "signature";
10
+ })(Keys || (Keys = {}));
11
+ export class AvalancheSignature extends RegistryItem {
12
+ constructor(signature, requestId) {
13
+ super();
14
+ this.getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGNATURE;
15
+ this.getRequestId = () => this.requestId;
16
+ this.getSignature = () => this.signature;
17
+ this.toDataItem = () => {
18
+ const map = {};
19
+ if (this.requestId) {
20
+ map[Keys.requestId] = new DataItem(this.requestId, RegistryTypes.UUID.getTag());
21
+ }
22
+ map[Keys.signature] = this.signature;
23
+ return new DataItem(map);
24
+ };
25
+ this.signature = signature;
26
+ this.requestId = requestId;
27
+ }
28
+ }
29
+ AvalancheSignature.fromDataItem = (dataItem) => {
30
+ const map = dataItem.getData();
31
+ const signature = map[Keys.signature];
32
+ return new AvalancheSignature(signature);
33
+ };
34
+ AvalancheSignature.fromCBOR = (_cborPayload) => {
35
+ const dataItem = decodeToDataItem(_cborPayload);
36
+ return AvalancheSignature.fromDataItem(dataItem);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AQ,CAAC,OAAO,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEtC,OAAO,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC,AALyB,CAKxB;AAEY,2BAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAChD,OAAO,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC,AAHqB,CAGpB","sourcesContent":["import {\n extend,\n DataItem,\n RegistryItem,\n DataItemMap,\n} from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\n\nconst { RegistryTypes, decodeToDataItem } = extend;\n\nenum Keys {\n requestId = 1,\n signature,\n}\n\nexport class AvalancheSignature extends RegistryItem {\n private requestId?: Buffer;\n private signature: Buffer;\n\n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGNATURE;\n\n constructor(signature: Buffer, requestId?: Buffer) {\n super();\n this.signature = signature;\n this.requestId = requestId;\n }\n\n public getRequestId = () => this.requestId;\n public getSignature = () => this.signature;\n\n public toDataItem = () => {\n const map: DataItemMap = {};\n if (this.requestId) {\n map[Keys.requestId] = new DataItem(\n this.requestId,\n RegistryTypes.UUID.getTag()\n );\n }\n map[Keys.signature] = this.signature;\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const signature = map[Keys.signature];\n\n return new AvalancheSignature(signature);\n };\n\n public static fromCBOR = (_cborPayload: Buffer) => {\n const dataItem = decodeToDataItem(_cborPayload);\n return AvalancheSignature.fromDataItem(dataItem);\n };\n}\n"]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AvalancheUtxo = void 0;
4
+ const bc_ur_registry_1 = require("@keystonehq/bc-ur-registry");
5
+ const RegistryType_1 = require("./RegistryType.cjs");
6
+ const { decodeToDataItem } = bc_ur_registry_1.extend;
7
+ var Keys;
8
+ (function (Keys) {
9
+ Keys[Keys["txid"] = 1] = "txid";
10
+ Keys[Keys["vout"] = 2] = "vout";
11
+ Keys[Keys["path"] = 3] = "path";
12
+ })(Keys || (Keys = {}));
13
+ class AvalancheUtxo extends bc_ur_registry_1.RegistryItem {
14
+ constructor(args) {
15
+ super();
16
+ this.getRegistryType = () => RegistryType_1.ExtendedRegistryTypes.AVALANCHE_UTXO;
17
+ this.getTxid = () => this.txid;
18
+ this.getVout = () => this.vout;
19
+ this.getKeyPath = () => this.path.getPath();
20
+ this.toDataItem = () => {
21
+ const map = {};
22
+ map[Keys.txid] = this.txid;
23
+ map[Keys.vout] = this.vout;
24
+ const keyPath = this.path.toDataItem();
25
+ keyPath.setTag(this.path.getRegistryType().getTag());
26
+ map[Keys.path] = keyPath;
27
+ return new bc_ur_registry_1.DataItem(map);
28
+ };
29
+ this.txid = args.txid;
30
+ this.vout = args.vout;
31
+ this.path = args.path;
32
+ }
33
+ static constructAvalancheUtxo({ txid, vout, path, }) {
34
+ const paths = path.replace(/[m|M]\//, "").split("/");
35
+ const hdPathObject = new bc_ur_registry_1.CryptoKeypath(paths.map((path) => {
36
+ const index = parseInt(path.replace("'", ""));
37
+ const isHardened = path.endsWith("'");
38
+ return new bc_ur_registry_1.PathComponent({ index, hardened: isHardened });
39
+ }));
40
+ return new AvalancheUtxo({
41
+ txid: Buffer.from(txid, "hex"),
42
+ vout,
43
+ path: hdPathObject,
44
+ });
45
+ }
46
+ }
47
+ exports.AvalancheUtxo = AvalancheUtxo;
48
+ AvalancheUtxo.fromDataItem = (dataItem) => {
49
+ const map = dataItem.getData();
50
+ const txid = map[Keys.txid];
51
+ const vout = map[Keys.vout];
52
+ const path = bc_ur_registry_1.CryptoKeypath.fromDataItem(map[Keys.path]);
53
+ return new AvalancheUtxo({
54
+ txid,
55
+ vout,
56
+ path,
57
+ });
58
+ };
59
+ AvalancheUtxo.fromCBOR = (_cborPayload) => {
60
+ const dataItem = decodeToDataItem(_cborPayload);
61
+ return AvalancheUtxo.fromDataItem(dataItem);
62
+ };
63
+ //# sourceMappingURL=AvalancheUtxo.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheUtxo.cjs","sourceRoot":"","sources":["../src/AvalancheUtxo.ts"],"names":[],"mappings":";;;AAAA,+DAOsC;AACpC,qDAAuD;AAEvD,MAAM,EAAE,gBAAgB,EAAE,GAAG,uBAAM,CAAC;AAEpC,IAAK,IAIJ;AAJD,WAAK,IAAI;IACP,+BAAQ,CAAA;IACR,+BAAI,CAAA;IACJ,+BAAI,CAAA;AACN,CAAC,EAJI,IAAI,KAAJ,IAAI,QAIR;AAcD,MAAa,aAAc,SAAQ,6BAAY;IAO7C,YAAY,IAAwB;QAClC,KAAK,EAAE,CAAC;QAHV,oBAAe,GAAG,GAAG,EAAE,CAAC,oCAAqB,CAAC,cAAc,CAAC;QAStD,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1B,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1B,eAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEvC,eAAU,GAAG,GAAG,EAAE;YACvB,MAAM,GAAG,GAAgB,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;YAE3B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACvC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC,IA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I,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,8BAAa,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD,OAAO,IAAI,aAAa,CAAC;QACvB,IAAI;QACJ,IAAI;QACJ,IAAI;KACL,CAAC,CAAC;AACL,CAAC,AAXyB,CAWxB;AAEY,sBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC,AAHqB,CAGpB","sourcesContent":["import {\n CryptoKeypath,\n extend,\n DataItem,\n PathComponent,\n RegistryItem,\n DataItemMap,\n } from \"@keystonehq/bc-ur-registry\";\n import { ExtendedRegistryTypes } from \"./RegistryType\";\n \n const { decodeToDataItem } = extend;\n \n enum Keys {\n txid = 1,\n vout,\n path,\n }\n \n export interface AvalancheUtxoProps {\n txid: Buffer;\n vout: number;\n path: CryptoKeypath;\n }\n \n export interface AvalancheUtxoData {\n txid: string;\n vout: number;\n path: string;\n }\n \n export class AvalancheUtxo extends RegistryItem {\n private txid: Buffer;\n private vout: number;\n private path: CryptoKeypath;\n \n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_UTXO;\n \n constructor(args: AvalancheUtxoProps) {\n super();\n this.txid = args.txid;\n this.vout = args.vout;\n this.path = args.path;\n }\n \n public getTxid = () => this.txid;\n public getVout = () => this.vout;\n public getKeyPath = () => this.path.getPath();\n \n public toDataItem = () => {\n const map: DataItemMap = {};\n map[Keys.txid] = this.txid;\n map[Keys.vout] = this.vout;\n \n const keyPath = this.path.toDataItem();\n keyPath.setTag(this.path.getRegistryType().getTag());\n map[Keys.path] = keyPath;\n \n return new DataItem(map);\n };\n \n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const txid = map[Keys.txid];\n const vout = map[Keys.vout];\n const path = CryptoKeypath.fromDataItem(map[Keys.path]);\n \n return new AvalancheUtxo({\n txid,\n vout,\n path,\n });\n };\n \n public static fromCBOR = (_cborPayload: Buffer) => {\n const dataItem = decodeToDataItem(_cborPayload);\n return AvalancheUtxo.fromDataItem(dataItem);\n };\n \n public static constructAvalancheUtxo({\n txid,\n vout,\n path,\n }: AvalancheUtxoData) {\n const paths = path.replace(/[m|M]\\//, \"\").split(\"/\");\n const hdPathObject = new CryptoKeypath(\n paths.map((path) => {\n const index = parseInt(path.replace(\"'\", \"\"));\n const isHardened = path.endsWith(\"'\");\n return new PathComponent({ index, hardened: isHardened });\n }),\n );\n \n return new AvalancheUtxo({\n txid: Buffer.from(txid, \"hex\"),\n vout,\n path: hdPathObject,\n });\n }\n }\n "]}
@@ -0,0 +1,26 @@
1
+ import { CryptoKeypath, DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
2
+ export interface AvalancheUtxoProps {
3
+ txid: Buffer;
4
+ vout: number;
5
+ path: CryptoKeypath;
6
+ }
7
+ export interface AvalancheUtxoData {
8
+ txid: string;
9
+ vout: number;
10
+ path: string;
11
+ }
12
+ export declare class AvalancheUtxo extends RegistryItem {
13
+ private txid;
14
+ private vout;
15
+ private path;
16
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
17
+ constructor(args: AvalancheUtxoProps);
18
+ getTxid: () => Buffer<ArrayBufferLike>;
19
+ getVout: () => number;
20
+ getKeyPath: () => string;
21
+ toDataItem: () => DataItem;
22
+ static fromDataItem: (dataItem: DataItem) => AvalancheUtxo;
23
+ static fromCBOR: (_cborPayload: Buffer) => AvalancheUtxo;
24
+ static constructAvalancheUtxo({ txid, vout, path, }: AvalancheUtxoData): AvalancheUtxo;
25
+ }
26
+ //# sourceMappingURL=AvalancheUtxo.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheUtxo.d.cts","sourceRoot":"","sources":["../src/AvalancheUtxo.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAEb,QAAQ,EAER,YAAY,EAEb,mCAAmC;AAWpC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAgB;IAE5B,eAAe,0DAA8C;gBAEjD,IAAI,EAAE,kBAAkB;IAO7B,OAAO,gCAAmB;IAC1B,OAAO,eAAmB;IAC1B,UAAU,eAA6B;IAEvC,UAAU,iBAUf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,mBAW9C;IAEF,OAAc,QAAQ,GAAI,cAAc,MAAM,mBAG5C;WAEY,sBAAsB,CAAC,EACnC,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,EAAE,iBAAiB;CAgBrB"}
@@ -0,0 +1,26 @@
1
+ import { CryptoKeypath, DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
2
+ export interface AvalancheUtxoProps {
3
+ txid: Buffer;
4
+ vout: number;
5
+ path: CryptoKeypath;
6
+ }
7
+ export interface AvalancheUtxoData {
8
+ txid: string;
9
+ vout: number;
10
+ path: string;
11
+ }
12
+ export declare class AvalancheUtxo extends RegistryItem {
13
+ private txid;
14
+ private vout;
15
+ private path;
16
+ getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
17
+ constructor(args: AvalancheUtxoProps);
18
+ getTxid: () => Buffer<ArrayBufferLike>;
19
+ getVout: () => number;
20
+ getKeyPath: () => string;
21
+ toDataItem: () => DataItem;
22
+ static fromDataItem: (dataItem: DataItem) => AvalancheUtxo;
23
+ static fromCBOR: (_cborPayload: Buffer) => AvalancheUtxo;
24
+ static constructAvalancheUtxo({ txid, vout, path, }: AvalancheUtxoData): AvalancheUtxo;
25
+ }
26
+ //# sourceMappingURL=AvalancheUtxo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheUtxo.d.mts","sourceRoot":"","sources":["../src/AvalancheUtxo.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAEb,QAAQ,EAER,YAAY,EAEb,mCAAmC;AAWpC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAgB;IAE5B,eAAe,0DAA8C;gBAEjD,IAAI,EAAE,kBAAkB;IAO7B,OAAO,gCAAmB;IAC1B,OAAO,eAAmB;IAC1B,UAAU,eAA6B;IAEvC,UAAU,iBAUf;IAEF,OAAc,YAAY,GAAI,UAAU,QAAQ,mBAW9C;IAEF,OAAc,QAAQ,GAAI,cAAc,MAAM,mBAG5C;WAEY,sBAAsB,CAAC,EACnC,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,EAAE,iBAAiB;CAgBrB"}
@@ -0,0 +1,61 @@
1
+ import { CryptoKeypath, extend, DataItem, PathComponent } from "@keystonehq/bc-ur-registry";
2
+ import $keystonehqbcurregistry from "@keystonehq/bc-ur-registry";
3
+ const { RegistryItem } = $keystonehqbcurregistry;
4
+ import { ExtendedRegistryTypes } from "./RegistryType.mjs";
5
+ const { decodeToDataItem } = extend;
6
+ var Keys;
7
+ (function (Keys) {
8
+ Keys[Keys["txid"] = 1] = "txid";
9
+ Keys[Keys["vout"] = 2] = "vout";
10
+ Keys[Keys["path"] = 3] = "path";
11
+ })(Keys || (Keys = {}));
12
+ export class AvalancheUtxo extends RegistryItem {
13
+ constructor(args) {
14
+ super();
15
+ this.getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_UTXO;
16
+ this.getTxid = () => this.txid;
17
+ this.getVout = () => this.vout;
18
+ this.getKeyPath = () => this.path.getPath();
19
+ this.toDataItem = () => {
20
+ const map = {};
21
+ map[Keys.txid] = this.txid;
22
+ map[Keys.vout] = this.vout;
23
+ const keyPath = this.path.toDataItem();
24
+ keyPath.setTag(this.path.getRegistryType().getTag());
25
+ map[Keys.path] = keyPath;
26
+ return new DataItem(map);
27
+ };
28
+ this.txid = args.txid;
29
+ this.vout = args.vout;
30
+ this.path = args.path;
31
+ }
32
+ static constructAvalancheUtxo({ txid, vout, path, }) {
33
+ const paths = path.replace(/[m|M]\//, "").split("/");
34
+ const hdPathObject = new CryptoKeypath(paths.map((path) => {
35
+ const index = parseInt(path.replace("'", ""));
36
+ const isHardened = path.endsWith("'");
37
+ return new PathComponent({ index, hardened: isHardened });
38
+ }));
39
+ return new AvalancheUtxo({
40
+ txid: Buffer.from(txid, "hex"),
41
+ vout,
42
+ path: hdPathObject,
43
+ });
44
+ }
45
+ }
46
+ AvalancheUtxo.fromDataItem = (dataItem) => {
47
+ const map = dataItem.getData();
48
+ const txid = map[Keys.txid];
49
+ const vout = map[Keys.vout];
50
+ const path = CryptoKeypath.fromDataItem(map[Keys.path]);
51
+ return new AvalancheUtxo({
52
+ txid,
53
+ vout,
54
+ path,
55
+ });
56
+ };
57
+ AvalancheUtxo.fromCBOR = (_cborPayload) => {
58
+ const dataItem = decodeToDataItem(_cborPayload);
59
+ return AvalancheUtxo.fromDataItem(dataItem);
60
+ };
61
+ //# sourceMappingURL=AvalancheUtxo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvalancheUtxo.mjs","sourceRoot":"","sources":["../src/AvalancheUtxo.ts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YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC,AAHqB,CAGpB","sourcesContent":["import {\n CryptoKeypath,\n extend,\n DataItem,\n PathComponent,\n RegistryItem,\n DataItemMap,\n } from \"@keystonehq/bc-ur-registry\";\n import { ExtendedRegistryTypes } from \"./RegistryType\";\n \n const { decodeToDataItem } = extend;\n \n enum Keys {\n txid = 1,\n vout,\n path,\n }\n \n export interface AvalancheUtxoProps {\n txid: Buffer;\n vout: number;\n path: CryptoKeypath;\n }\n \n export interface AvalancheUtxoData {\n txid: string;\n vout: number;\n path: string;\n }\n \n export class AvalancheUtxo extends RegistryItem {\n private txid: Buffer;\n private vout: number;\n private path: CryptoKeypath;\n \n getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_UTXO;\n \n constructor(args: AvalancheUtxoProps) {\n super();\n this.txid = args.txid;\n this.vout = args.vout;\n this.path = args.path;\n }\n \n public getTxid = () => this.txid;\n public getVout = () => this.vout;\n public getKeyPath = () => this.path.getPath();\n \n public toDataItem = () => {\n const map: DataItemMap = {};\n map[Keys.txid] = this.txid;\n map[Keys.vout] = this.vout;\n \n const keyPath = this.path.toDataItem();\n keyPath.setTag(this.path.getRegistryType().getTag());\n map[Keys.path] = keyPath;\n \n return new DataItem(map);\n };\n \n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const txid = map[Keys.txid];\n const vout = map[Keys.vout];\n const path = CryptoKeypath.fromDataItem(map[Keys.path]);\n \n return new AvalancheUtxo({\n txid,\n vout,\n path,\n });\n };\n \n public static fromCBOR = (_cborPayload: Buffer) => {\n const dataItem = decodeToDataItem(_cborPayload);\n return AvalancheUtxo.fromDataItem(dataItem);\n };\n \n public static constructAvalancheUtxo({\n txid,\n vout,\n path,\n }: AvalancheUtxoData) {\n const paths = path.replace(/[m|M]\\//, \"\").split(\"/\");\n const hdPathObject = new CryptoKeypath(\n paths.map((path) => {\n const index = parseInt(path.replace(\"'\", \"\"));\n const isHardened = path.endsWith(\"'\");\n return new PathComponent({ index, hardened: isHardened });\n }),\n );\n \n return new AvalancheUtxo({\n txid: Buffer.from(txid, \"hex\"),\n vout,\n path: hdPathObject,\n });\n }\n }\n "]}