@keystonehq/bc-ur-registry-avalanche 0.0.5 → 0.1.1
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.
- package/dist/AvalancheSignRequest.cjs +112 -0
- package/dist/AvalancheSignRequest.cjs.map +1 -0
- package/dist/AvalancheSignRequest.d.cts +25 -0
- package/dist/AvalancheSignRequest.d.cts.map +1 -0
- package/dist/AvalancheSignRequest.d.mts +25 -0
- package/dist/AvalancheSignRequest.d.mts.map +1 -0
- package/dist/AvalancheSignRequest.mjs +77 -0
- package/dist/AvalancheSignRequest.mjs.map +1 -0
- package/dist/AvalancheSignature.cjs +40 -0
- package/dist/AvalancheSignature.cjs.map +1 -0
- package/dist/{AvalancheSignature.d.ts → AvalancheSignature.d.cts} +13 -13
- package/dist/AvalancheSignature.d.cts.map +1 -0
- package/dist/AvalancheSignature.d.mts +13 -0
- package/dist/AvalancheSignature.d.mts.map +1 -0
- package/dist/AvalancheSignature.mjs +38 -0
- package/dist/AvalancheSignature.mjs.map +1 -0
- package/dist/AvalancheUtxo.cjs +63 -0
- package/dist/AvalancheUtxo.cjs.map +1 -0
- package/dist/AvalancheUtxo.d.cts +26 -0
- package/dist/AvalancheUtxo.d.cts.map +1 -0
- package/dist/AvalancheUtxo.d.mts +26 -0
- package/dist/AvalancheUtxo.d.mts.map +1 -0
- package/dist/AvalancheUtxo.mjs +61 -0
- package/dist/AvalancheUtxo.mjs.map +1 -0
- package/dist/RegistryType.cjs +10 -0
- package/dist/RegistryType.cjs.map +1 -0
- package/dist/{RegistryType.d.ts → RegistryType.d.cts} +7 -5
- package/dist/RegistryType.d.cts.map +1 -0
- package/dist/RegistryType.d.mts +7 -0
- package/dist/RegistryType.d.mts.map +1 -0
- package/dist/RegistryType.mjs +8 -0
- package/dist/RegistryType.mjs.map +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +17 -11
- package/src/AvalancheSignRequest.ts +35 -33
- package/src/AvalancheUtxo.ts +100 -0
- package/src/RegistryType.ts +1 -0
- package/src/index.ts +1 -0
- package/dist/AvalancheSignRequest.d.ts +0 -24
- package/dist/bc-ur-registry-avalanche.cjs.development.js +0 -132
- package/dist/bc-ur-registry-avalanche.cjs.development.js.map +0 -1
- package/dist/bc-ur-registry-avalanche.cjs.production.min.js +0 -2
- package/dist/bc-ur-registry-avalanche.cjs.production.min.js.map +0 -1
- package/dist/bc-ur-registry-avalanche.esm.js +0 -120
- package/dist/bc-ur-registry-avalanche.esm.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendedRegistryTypes = void 0;
|
|
4
|
+
const bc_ur_registry_1 = require("@keystonehq/bc-ur-registry");
|
|
5
|
+
exports.ExtendedRegistryTypes = {
|
|
6
|
+
AVALANCHE_SIGN_REQUEST: new bc_ur_registry_1.RegistryType("avax-sign-request", 8301),
|
|
7
|
+
AVALANCHE_SIGNATURE: new bc_ur_registry_1.RegistryType("avax-signature", 8302),
|
|
8
|
+
AVALANCHE_UTXO: new bc_ur_registry_1.RegistryType("avax-utxo", 8303),
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=RegistryType.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryType.cjs","sourceRoot":"","sources":["../src/RegistryType.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAE7C,QAAA,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,IAAI,6BAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC;IACnE,mBAAmB,EAAE,IAAI,6BAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC;IAC7D,cAAc,EAAE,IAAI,6BAAY,CAAC,WAAW,EAAE,IAAI,CAAC;CACpD,CAAC","sourcesContent":["import { RegistryType } from \"@keystonehq/bc-ur-registry\";\n\nexport const ExtendedRegistryTypes = {\n AVALANCHE_SIGN_REQUEST: new RegistryType(\"avax-sign-request\", 8301),\n AVALANCHE_SIGNATURE: new RegistryType(\"avax-signature\", 8302),\n AVALANCHE_UTXO: new RegistryType(\"avax-utxo\", 8303),\n};\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { RegistryType } from "@keystonehq/bc-ur-registry";
|
|
2
|
-
export declare const ExtendedRegistryTypes: {
|
|
3
|
-
AVALANCHE_SIGN_REQUEST: RegistryType;
|
|
4
|
-
AVALANCHE_SIGNATURE: RegistryType;
|
|
5
|
-
|
|
1
|
+
import { RegistryType } from "@keystonehq/bc-ur-registry";
|
|
2
|
+
export declare const ExtendedRegistryTypes: {
|
|
3
|
+
AVALANCHE_SIGN_REQUEST: RegistryType;
|
|
4
|
+
AVALANCHE_SIGNATURE: RegistryType;
|
|
5
|
+
AVALANCHE_UTXO: RegistryType;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=RegistryType.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryType.d.cts","sourceRoot":"","sources":["../src/RegistryType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAE1D,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryType.d.mts","sourceRoot":"","sources":["../src/RegistryType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAE1D,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import $keystonehqbcurregistry from "@keystonehq/bc-ur-registry";
|
|
2
|
+
const { RegistryType } = $keystonehqbcurregistry;
|
|
3
|
+
export const ExtendedRegistryTypes = {
|
|
4
|
+
AVALANCHE_SIGN_REQUEST: new RegistryType("avax-sign-request", 8301),
|
|
5
|
+
AVALANCHE_SIGNATURE: new RegistryType("avax-signature", 8302),
|
|
6
|
+
AVALANCHE_UTXO: new RegistryType("avax-utxo", 8303),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=RegistryType.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryType.mjs","sourceRoot":"","sources":["../src/RegistryType.ts"],"names":[],"mappings":";;AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,sBAAsB,EAAE,IAAI,YAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC;IACnE,mBAAmB,EAAE,IAAI,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC;IAC7D,cAAc,EAAE,IAAI,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC;CACpD,CAAC","sourcesContent":["import { RegistryType } from \"@keystonehq/bc-ur-registry\";\n\nexport const ExtendedRegistryTypes = {\n AVALANCHE_SIGN_REQUEST: new RegistryType(\"avax-sign-request\", 8301),\n AVALANCHE_SIGNATURE: new RegistryType(\"avax-signature\", 8302),\n AVALANCHE_UTXO: new RegistryType(\"avax-utxo\", 8303),\n};\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AvalancheSignature = exports.AvalancheSignRequest = void 0;
|
|
18
|
+
const bc_ur_registry_1 = require("@keystonehq/bc-ur-registry");
|
|
19
|
+
const RegistryType_1 = require("./RegistryType.cjs");
|
|
20
|
+
__exportStar(require("@keystonehq/bc-ur-registry"), exports);
|
|
21
|
+
(0, bc_ur_registry_1.patchTags)(Object.values(RegistryType_1.ExtendedRegistryTypes)
|
|
22
|
+
.filter((rt) => !!rt.getTag())
|
|
23
|
+
.map((rt) => rt.getTag()));
|
|
24
|
+
var AvalancheSignRequest_1 = require("./AvalancheSignRequest.cjs");
|
|
25
|
+
Object.defineProperty(exports, "AvalancheSignRequest", { enumerable: true, get: function () { return AvalancheSignRequest_1.AvalancheSignRequest; } });
|
|
26
|
+
var AvalancheSignature_1 = require("./AvalancheSignature.cjs");
|
|
27
|
+
Object.defineProperty(exports, "AvalancheSignature", { enumerable: true, get: function () { return AvalancheSignature_1.AvalancheSignature; } });
|
|
28
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,qDAAuD;AACvD,6DAA2C;AAE3C,IAAA,0BAAS,EACP,MAAM,CAAC,MAAM,CAAC,oCAAqB,CAAC;KACjC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;KAC7B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAa,CACxC,CAAC;AAEF,mEAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,+DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["import { patchTags } from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nexport * from \"@keystonehq/bc-ur-registry\";\n\npatchTags(\n Object.values(ExtendedRegistryTypes)\n .filter((rt) => !!rt.getTag())\n .map((rt) => rt.getTag()) as number[]\n);\n\nexport { AvalancheSignRequest } from \"./AvalancheSignRequest\";\nexport { AvalancheSignature } from \"./AvalancheSignature\";\nexport { AvalancheUtxoData } from \"./AvalancheUtxo\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "@keystonehq/bc-ur-registry";
|
|
2
|
+
export { AvalancheSignRequest } from "./AvalancheSignRequest.cjs";
|
|
3
|
+
export { AvalancheSignature } from "./AvalancheSignature.cjs";
|
|
4
|
+
export { AvalancheUtxoData } from "./AvalancheUtxo.cjs";
|
|
5
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAQ3C,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,iCAA6B;AAC1D,OAAO,EAAE,iBAAiB,EAAE,4BAAwB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "@keystonehq/bc-ur-registry";
|
|
2
|
+
export { AvalancheSignRequest } from "./AvalancheSignRequest.mjs";
|
|
3
|
+
export { AvalancheSignature } from "./AvalancheSignature.mjs";
|
|
4
|
+
export { AvalancheUtxoData } from "./AvalancheUtxo.mjs";
|
|
5
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAQ3C,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,iCAA6B;AAC1D,OAAO,EAAE,iBAAiB,EAAE,4BAAwB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import $keystonehqbcurregistry from "@keystonehq/bc-ur-registry";
|
|
2
|
+
const { patchTags } = $keystonehqbcurregistry;
|
|
3
|
+
import { ExtendedRegistryTypes } from "./RegistryType.mjs";
|
|
4
|
+
export * from "@keystonehq/bc-ur-registry";
|
|
5
|
+
patchTags(Object.values(ExtendedRegistryTypes)
|
|
6
|
+
.filter((rt) => !!rt.getTag())
|
|
7
|
+
.map((rt) => rt.getTag()));
|
|
8
|
+
export { AvalancheSignRequest } from "./AvalancheSignRequest.mjs";
|
|
9
|
+
export { AvalancheSignature } from "./AvalancheSignature.mjs";
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,qBAAqB,EAAE,2BAAuB;AACvD,2CAA2C;AAE3C,SAAS,CACP,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;KACjC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;KAC7B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAa,CACxC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,iCAA6B","sourcesContent":["import { patchTags } from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nexport * from \"@keystonehq/bc-ur-registry\";\n\npatchTags(\n Object.values(ExtendedRegistryTypes)\n .filter((rt) => !!rt.getTag())\n .map((rt) => rt.getTag()) as number[]\n);\n\nexport { AvalancheSignRequest } from \"./AvalancheSignRequest\";\nexport { AvalancheSignature } from \"./AvalancheSignature\";\nexport { AvalancheUtxoData } from \"./AvalancheUtxo\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystonehq/bc-ur-registry-avalanche",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "bc-ur-registry extension for Avalanche",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.mts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.mts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"directories": {
|
|
8
16
|
"lib": "src",
|
|
9
17
|
"test": "__tests__"
|
|
@@ -12,12 +20,6 @@
|
|
|
12
20
|
"src",
|
|
13
21
|
"dist"
|
|
14
22
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"clean": "rm -rf ./dist",
|
|
17
|
-
"start": "tsdx watch",
|
|
18
|
-
"build": "tsdx build",
|
|
19
|
-
"test": "jest --passWithNoTests"
|
|
20
|
-
},
|
|
21
23
|
"publishConfig": {
|
|
22
24
|
"access": "public"
|
|
23
25
|
},
|
|
@@ -30,7 +32,11 @@
|
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@babel/preset-typescript": "^7.15.0",
|
|
32
34
|
"@types/uuid": "^8.3.1",
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
+
"typescript": "^5.2.2"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "rm -rf ./dist",
|
|
39
|
+
"build": "pnpm ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
40
|
+
"test": "jest --passWithNoTests"
|
|
35
41
|
}
|
|
36
42
|
}
|
|
@@ -3,34 +3,33 @@ import {
|
|
|
3
3
|
RegistryItem,
|
|
4
4
|
extend,
|
|
5
5
|
DataItemMap,
|
|
6
|
+
CryptoKeypath,
|
|
6
7
|
} from "@keystonehq/bc-ur-registry";
|
|
7
8
|
import { ExtendedRegistryTypes } from "./RegistryType";
|
|
8
9
|
import * as uuid from "uuid";
|
|
10
|
+
import { AvalancheUtxo, AvalancheUtxoData } from "./AvalancheUtxo";
|
|
9
11
|
|
|
10
12
|
const { RegistryTypes } = extend;
|
|
11
13
|
|
|
12
14
|
type signRequestProps = {
|
|
13
15
|
requestId?: Buffer;
|
|
14
16
|
data: Buffer;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
walletIndex: number;
|
|
17
|
+
derivationPath: CryptoKeypath;
|
|
18
|
+
utxos: AvalancheUtxo[];
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
enum Keys {
|
|
21
22
|
requestId = 1,
|
|
22
|
-
signData
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
walletIndex = 7,
|
|
23
|
+
signData,
|
|
24
|
+
derivationPath,
|
|
25
|
+
utxos,
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
export class AvalancheSignRequest extends RegistryItem {
|
|
29
28
|
private requestId?: Buffer;
|
|
30
29
|
private data: Buffer;
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
|
|
30
|
+
private derivationPath: CryptoKeypath;
|
|
31
|
+
private utxos: AvalancheUtxo[];
|
|
32
|
+
|
|
34
33
|
|
|
35
34
|
getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;
|
|
36
35
|
|
|
@@ -38,13 +37,14 @@ export class AvalancheSignRequest extends RegistryItem {
|
|
|
38
37
|
super();
|
|
39
38
|
this.requestId = args.requestId;
|
|
40
39
|
this.data = args.data;
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.walletIndex = args.walletIndex;
|
|
40
|
+
this.derivationPath = args.derivationPath;
|
|
41
|
+
this.utxos = args.utxos;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
public getRequestId = () => this.requestId;
|
|
47
45
|
public getSignData = () => this.data;
|
|
46
|
+
public getUtxos = () => this.utxos;
|
|
47
|
+
public getDerivationPath = () => this.derivationPath;
|
|
48
48
|
|
|
49
49
|
public toDataItem = () => {
|
|
50
50
|
const map: DataItemMap = {};
|
|
@@ -56,40 +56,40 @@ export class AvalancheSignRequest extends RegistryItem {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
map[Keys.signData] = Buffer.from(this.data);
|
|
59
|
-
map[Keys.
|
|
60
|
-
map[Keys.
|
|
61
|
-
|
|
59
|
+
map[Keys.derivationPath] = this.derivationPath;
|
|
60
|
+
map[Keys.utxos] = this.utxos.map((utxo) => {
|
|
61
|
+
const res = utxo.toDataItem();
|
|
62
|
+
res.setTag(utxo.getRegistryType().getTag());
|
|
63
|
+
return res;
|
|
64
|
+
});
|
|
62
65
|
|
|
63
66
|
return new DataItem(map);
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
public static fromDataItem = (dataItem: DataItem) => {
|
|
67
70
|
const map = dataItem.getData();
|
|
68
|
-
const masterFingerprint = Buffer.alloc(4);
|
|
69
|
-
const _masterFingerprint = map[Keys.mfp];
|
|
70
|
-
masterFingerprint.writeUInt32BE(_masterFingerprint, 0);
|
|
71
71
|
const requestId = map[Keys.requestId]
|
|
72
72
|
? map[Keys.requestId].getData()
|
|
73
73
|
: undefined;
|
|
74
74
|
const data = map[Keys.signData];
|
|
75
|
-
const
|
|
76
|
-
const
|
|
75
|
+
const derivationPath = map[Keys.signData];
|
|
76
|
+
const utxos: AvalancheUtxo[] = map[Keys.utxos].map((utxo: DataItem) =>
|
|
77
|
+
AvalancheUtxo.fromDataItem(utxo)
|
|
78
|
+
);
|
|
77
79
|
|
|
78
80
|
return new AvalancheSignRequest({
|
|
79
81
|
requestId,
|
|
80
82
|
data,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
mfp: masterFingerprint,
|
|
83
|
+
derivationPath,
|
|
84
|
+
utxos,
|
|
84
85
|
});
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
public static constructAvalancheRequest(
|
|
88
89
|
data: Buffer,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
requestId?: string | Buffer
|
|
90
|
+
derivationPath: CryptoKeypath,
|
|
91
|
+
utxos: AvalancheUtxoData[],
|
|
92
|
+
requestId?: string | Buffer,
|
|
93
93
|
) {
|
|
94
94
|
let _requestId;
|
|
95
95
|
if (typeof requestId === "string") {
|
|
@@ -97,15 +97,17 @@ export class AvalancheSignRequest extends RegistryItem {
|
|
|
97
97
|
} else if (requestId instanceof Buffer) {
|
|
98
98
|
_requestId = requestId;
|
|
99
99
|
} else {
|
|
100
|
-
_requestId = Buffer.from(uuid.parse(uuid.v4()));
|
|
100
|
+
_requestId = Buffer.from(uuid.parse(uuid.v4()) as Uint8Array);
|
|
101
101
|
}
|
|
102
|
+
const avalancheUtxos = utxos.map((utxo) =>
|
|
103
|
+
AvalancheUtxo.constructAvalancheUtxo(utxo)
|
|
104
|
+
);
|
|
102
105
|
|
|
103
106
|
return new AvalancheSignRequest({
|
|
104
107
|
data,
|
|
105
108
|
requestId: _requestId,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
walletIndex,
|
|
109
|
+
derivationPath,
|
|
110
|
+
utxos: avalancheUtxos,
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
113
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CryptoKeypath,
|
|
3
|
+
extend,
|
|
4
|
+
DataItem,
|
|
5
|
+
PathComponent,
|
|
6
|
+
RegistryItem,
|
|
7
|
+
DataItemMap,
|
|
8
|
+
} from "@keystonehq/bc-ur-registry";
|
|
9
|
+
import { ExtendedRegistryTypes } from "./RegistryType";
|
|
10
|
+
|
|
11
|
+
const { decodeToDataItem } = extend;
|
|
12
|
+
|
|
13
|
+
enum Keys {
|
|
14
|
+
txid = 1,
|
|
15
|
+
vout,
|
|
16
|
+
path,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AvalancheUtxoProps {
|
|
20
|
+
txid: Buffer;
|
|
21
|
+
vout: number;
|
|
22
|
+
path: CryptoKeypath;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AvalancheUtxoData {
|
|
26
|
+
txid: string;
|
|
27
|
+
vout: number;
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class AvalancheUtxo extends RegistryItem {
|
|
32
|
+
private txid: Buffer;
|
|
33
|
+
private vout: number;
|
|
34
|
+
private path: CryptoKeypath;
|
|
35
|
+
|
|
36
|
+
getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_UTXO;
|
|
37
|
+
|
|
38
|
+
constructor(args: AvalancheUtxoProps) {
|
|
39
|
+
super();
|
|
40
|
+
this.txid = args.txid;
|
|
41
|
+
this.vout = args.vout;
|
|
42
|
+
this.path = args.path;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getTxid = () => this.txid;
|
|
46
|
+
public getVout = () => this.vout;
|
|
47
|
+
public getKeyPath = () => this.path.getPath();
|
|
48
|
+
|
|
49
|
+
public toDataItem = () => {
|
|
50
|
+
const map: DataItemMap = {};
|
|
51
|
+
map[Keys.txid] = this.txid;
|
|
52
|
+
map[Keys.vout] = this.vout;
|
|
53
|
+
|
|
54
|
+
const keyPath = this.path.toDataItem();
|
|
55
|
+
keyPath.setTag(this.path.getRegistryType().getTag());
|
|
56
|
+
map[Keys.path] = keyPath;
|
|
57
|
+
|
|
58
|
+
return new DataItem(map);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
public static fromDataItem = (dataItem: DataItem) => {
|
|
62
|
+
const map = dataItem.getData();
|
|
63
|
+
const txid = map[Keys.txid];
|
|
64
|
+
const vout = map[Keys.vout];
|
|
65
|
+
const path = CryptoKeypath.fromDataItem(map[Keys.path]);
|
|
66
|
+
|
|
67
|
+
return new AvalancheUtxo({
|
|
68
|
+
txid,
|
|
69
|
+
vout,
|
|
70
|
+
path,
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
public static fromCBOR = (_cborPayload: Buffer) => {
|
|
75
|
+
const dataItem = decodeToDataItem(_cborPayload);
|
|
76
|
+
return AvalancheUtxo.fromDataItem(dataItem);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
public static constructAvalancheUtxo({
|
|
80
|
+
txid,
|
|
81
|
+
vout,
|
|
82
|
+
path,
|
|
83
|
+
}: AvalancheUtxoData) {
|
|
84
|
+
const paths = path.replace(/[m|M]\//, "").split("/");
|
|
85
|
+
const hdPathObject = new CryptoKeypath(
|
|
86
|
+
paths.map((path) => {
|
|
87
|
+
const index = parseInt(path.replace("'", ""));
|
|
88
|
+
const isHardened = path.endsWith("'");
|
|
89
|
+
return new PathComponent({ index, hardened: isHardened });
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return new AvalancheUtxo({
|
|
94
|
+
txid: Buffer.from(txid, "hex"),
|
|
95
|
+
vout,
|
|
96
|
+
path: hdPathObject,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
package/src/RegistryType.ts
CHANGED
|
@@ -3,4 +3,5 @@ import { RegistryType } from "@keystonehq/bc-ur-registry";
|
|
|
3
3
|
export const ExtendedRegistryTypes = {
|
|
4
4
|
AVALANCHE_SIGN_REQUEST: new RegistryType("avax-sign-request", 8301),
|
|
5
5
|
AVALANCHE_SIGNATURE: new RegistryType("avax-signature", 8302),
|
|
6
|
+
AVALANCHE_UTXO: new RegistryType("avax-utxo", 8303),
|
|
6
7
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { DataItem, RegistryItem } from "@keystonehq/bc-ur-registry";
|
|
3
|
-
declare type signRequestProps = {
|
|
4
|
-
requestId?: Buffer;
|
|
5
|
-
data: Buffer;
|
|
6
|
-
mfp: Buffer;
|
|
7
|
-
xpub: string;
|
|
8
|
-
walletIndex: number;
|
|
9
|
-
};
|
|
10
|
-
export declare class AvalancheSignRequest extends RegistryItem {
|
|
11
|
-
private requestId?;
|
|
12
|
-
private data;
|
|
13
|
-
private mfp;
|
|
14
|
-
private xpub;
|
|
15
|
-
private walletIndex;
|
|
16
|
-
getRegistryType: () => import("@keystonehq/bc-ur-registry").RegistryType;
|
|
17
|
-
constructor(args: signRequestProps);
|
|
18
|
-
getRequestId: () => Buffer | undefined;
|
|
19
|
-
getSignData: () => Buffer;
|
|
20
|
-
toDataItem: () => DataItem;
|
|
21
|
-
static fromDataItem: (dataItem: DataItem) => AvalancheSignRequest;
|
|
22
|
-
static constructAvalancheRequest(data: Buffer, mfp: string, xpub: string, walletIndex: number, requestId?: string | Buffer): AvalancheSignRequest;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var bcUrRegistry = require('@keystonehq/bc-ur-registry');
|
|
6
|
-
var uuid = require('uuid');
|
|
7
|
-
|
|
8
|
-
const ExtendedRegistryTypes = {
|
|
9
|
-
AVALANCHE_SIGN_REQUEST: /*#__PURE__*/new bcUrRegistry.RegistryType("avax-sign-request", 8301),
|
|
10
|
-
AVALANCHE_SIGNATURE: /*#__PURE__*/new bcUrRegistry.RegistryType("avax-signature", 8302)
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
RegistryTypes
|
|
15
|
-
} = bcUrRegistry.extend;
|
|
16
|
-
var Keys;
|
|
17
|
-
(function (Keys) {
|
|
18
|
-
Keys[Keys["requestId"] = 1] = "requestId";
|
|
19
|
-
Keys[Keys["signData"] = 2] = "signData";
|
|
20
|
-
Keys[Keys["mfp"] = 3] = "mfp";
|
|
21
|
-
Keys[Keys["xpub"] = 6] = "xpub";
|
|
22
|
-
Keys[Keys["walletIndex"] = 7] = "walletIndex";
|
|
23
|
-
})(Keys || (Keys = {}));
|
|
24
|
-
class AvalancheSignRequest extends bcUrRegistry.RegistryItem {
|
|
25
|
-
constructor(args) {
|
|
26
|
-
super();
|
|
27
|
-
this.getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST;
|
|
28
|
-
this.getRequestId = () => this.requestId;
|
|
29
|
-
this.getSignData = () => this.data;
|
|
30
|
-
this.toDataItem = () => {
|
|
31
|
-
const map = {};
|
|
32
|
-
if (this.requestId) {
|
|
33
|
-
map[Keys.requestId] = new bcUrRegistry.DataItem(this.requestId, RegistryTypes.UUID.getTag());
|
|
34
|
-
}
|
|
35
|
-
map[Keys.signData] = Buffer.from(this.data);
|
|
36
|
-
map[Keys.mfp] = this.mfp.readUInt32BE(0);
|
|
37
|
-
map[Keys.xpub] = this.xpub;
|
|
38
|
-
map[Keys.walletIndex] = Number(this.walletIndex);
|
|
39
|
-
return new bcUrRegistry.DataItem(map);
|
|
40
|
-
};
|
|
41
|
-
this.requestId = args.requestId;
|
|
42
|
-
this.data = args.data;
|
|
43
|
-
this.mfp = args.mfp;
|
|
44
|
-
this.xpub = args.xpub;
|
|
45
|
-
this.walletIndex = args.walletIndex;
|
|
46
|
-
}
|
|
47
|
-
static constructAvalancheRequest(data, mfp, xpub, walletIndex, requestId) {
|
|
48
|
-
let _requestId;
|
|
49
|
-
if (typeof requestId === "string") {
|
|
50
|
-
_requestId = Buffer.from(uuid.parse(requestId));
|
|
51
|
-
} else if (requestId instanceof Buffer) {
|
|
52
|
-
_requestId = requestId;
|
|
53
|
-
} else {
|
|
54
|
-
_requestId = Buffer.from(uuid.parse(uuid.v4()));
|
|
55
|
-
}
|
|
56
|
-
return new AvalancheSignRequest({
|
|
57
|
-
data,
|
|
58
|
-
requestId: _requestId,
|
|
59
|
-
mfp: Buffer.from(mfp, "hex"),
|
|
60
|
-
xpub,
|
|
61
|
-
walletIndex
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
AvalancheSignRequest.fromDataItem = dataItem => {
|
|
66
|
-
const map = dataItem.getData();
|
|
67
|
-
const masterFingerprint = Buffer.alloc(4);
|
|
68
|
-
const _masterFingerprint = map[Keys.mfp];
|
|
69
|
-
masterFingerprint.writeUInt32BE(_masterFingerprint, 0);
|
|
70
|
-
const requestId = map[Keys.requestId] ? map[Keys.requestId].getData() : undefined;
|
|
71
|
-
const data = map[Keys.signData];
|
|
72
|
-
const xpub = map[Keys.xpub];
|
|
73
|
-
const walletIndex = map[Keys.signData];
|
|
74
|
-
return new AvalancheSignRequest({
|
|
75
|
-
requestId,
|
|
76
|
-
data,
|
|
77
|
-
xpub,
|
|
78
|
-
walletIndex,
|
|
79
|
-
mfp: masterFingerprint
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
RegistryTypes: RegistryTypes$1,
|
|
85
|
-
decodeToDataItem
|
|
86
|
-
} = bcUrRegistry.extend;
|
|
87
|
-
var Keys$1;
|
|
88
|
-
(function (Keys) {
|
|
89
|
-
Keys[Keys["requestId"] = 1] = "requestId";
|
|
90
|
-
Keys[Keys["signature"] = 2] = "signature";
|
|
91
|
-
})(Keys$1 || (Keys$1 = {}));
|
|
92
|
-
class AvalancheSignature extends bcUrRegistry.RegistryItem {
|
|
93
|
-
constructor(signature, requestId) {
|
|
94
|
-
super();
|
|
95
|
-
this.getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGNATURE;
|
|
96
|
-
this.getRequestId = () => this.requestId;
|
|
97
|
-
this.getSignature = () => this.signature;
|
|
98
|
-
this.toDataItem = () => {
|
|
99
|
-
const map = {};
|
|
100
|
-
if (this.requestId) {
|
|
101
|
-
map[Keys$1.requestId] = new bcUrRegistry.DataItem(this.requestId, RegistryTypes$1.UUID.getTag());
|
|
102
|
-
}
|
|
103
|
-
map[Keys$1.signature] = this.signature;
|
|
104
|
-
return new bcUrRegistry.DataItem(map);
|
|
105
|
-
};
|
|
106
|
-
this.signature = signature;
|
|
107
|
-
this.requestId = requestId;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
AvalancheSignature.fromDataItem = dataItem => {
|
|
111
|
-
const map = dataItem.getData();
|
|
112
|
-
const signature = map[Keys$1.signature];
|
|
113
|
-
return new AvalancheSignature(signature);
|
|
114
|
-
};
|
|
115
|
-
AvalancheSignature.fromCBOR = _cborPayload => {
|
|
116
|
-
const dataItem = decodeToDataItem(_cborPayload);
|
|
117
|
-
return AvalancheSignature.fromDataItem(dataItem);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
bcUrRegistry.patchTags(Object.values(ExtendedRegistryTypes).filter(rt => !!rt.getTag()).map(rt => rt.getTag()));
|
|
121
|
-
|
|
122
|
-
Object.keys(bcUrRegistry).forEach(function (k) {
|
|
123
|
-
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () {
|
|
126
|
-
return bcUrRegistry[k];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
exports.AvalancheSignRequest = AvalancheSignRequest;
|
|
131
|
-
exports.AvalancheSignature = AvalancheSignature;
|
|
132
|
-
//# sourceMappingURL=bc-ur-registry-avalanche.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bc-ur-registry-avalanche.cjs.development.js","sources":["../src/RegistryType.ts","../src/AvalancheSignRequest.ts","../src/AvalancheSignature.ts","../src/index.ts"],"sourcesContent":["import { RegistryType } from \"@keystonehq/bc-ur-registry\";\n\nexport const ExtendedRegistryTypes = {\n AVALANCHE_SIGN_REQUEST: new RegistryType(\"avax-sign-request\", 8301),\n AVALANCHE_SIGNATURE: new RegistryType(\"avax-signature\", 8302),\n};\n","import {\n DataItem,\n RegistryItem,\n extend,\n DataItemMap,\n} from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nimport * as uuid from \"uuid\";\n\nconst { RegistryTypes } = extend;\n\ntype signRequestProps = {\n requestId?: Buffer;\n data: Buffer;\n mfp: Buffer;\n xpub: string;\n walletIndex: number;\n};\n\nenum Keys {\n requestId = 1,\n signData = 2,\n mfp = 3,\n xpub = 6,\n walletIndex = 7,\n}\n\nexport class AvalancheSignRequest extends RegistryItem {\n private requestId?: Buffer;\n private data: Buffer;\n private mfp: Buffer;\n private xpub: string;\n private walletIndex: number;\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.mfp = args.mfp;\n this.xpub = args.xpub;\n this.walletIndex = args.walletIndex;\n }\n\n public getRequestId = () => this.requestId;\n public getSignData = () => this.data;\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.mfp] = this.mfp.readUInt32BE(0);\n map[Keys.xpub] = this.xpub;\n map[Keys.walletIndex] = Number(this.walletIndex);\n\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const masterFingerprint = Buffer.alloc(4);\n const _masterFingerprint = map[Keys.mfp];\n masterFingerprint.writeUInt32BE(_masterFingerprint, 0);\n const requestId = map[Keys.requestId]\n ? map[Keys.requestId].getData()\n : undefined;\n const data = map[Keys.signData];\n const xpub = map[Keys.xpub];\n const walletIndex = map[Keys.signData];\n\n return new AvalancheSignRequest({\n requestId,\n data,\n xpub,\n walletIndex,\n mfp: masterFingerprint,\n });\n };\n\n public static constructAvalancheRequest(\n data: Buffer,\n mfp: string,\n xpub: string,\n walletIndex: number,\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()));\n }\n\n return new AvalancheSignRequest({\n data,\n requestId: _requestId,\n mfp: Buffer.from(mfp, \"hex\"),\n xpub,\n walletIndex,\n });\n }\n}\n","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","import { patchTags } from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nexport * from \"@keystonehq/bc-ur-registry\";\n\npatchTags(\n Object.values(ExtendedRegistryTypes)\n .filter((rt) => !!rt.getTag())\n .map((rt) => rt.getTag()) as number[]\n);\n\nexport { AvalancheSignRequest } from \"./AvalancheSignRequest\";\nexport { AvalancheSignature } from \"./AvalancheSignature\";\n"],"names":["ExtendedRegistryTypes","AVALANCHE_SIGN_REQUEST","RegistryType","AVALANCHE_SIGNATURE","RegistryTypes","extend","Keys","AvalancheSignRequest","RegistryItem","constructor","args","requestId","data","map","DataItem","UUID","getTag","signData","Buffer","from","mfp","readUInt32BE","xpub","walletIndex","Number","constructAvalancheRequest","_requestId","uuid","dataItem","getData","masterFingerprint","alloc","_masterFingerprint","writeUInt32BE","undefined","decodeToDataItem","AvalancheSignature","signature","_cborPayload","fromDataItem","patchTags","Object","values","filter","rt"],"mappings":";;;;;;;AAEO,MAAMA,qBAAqB,GAAG;EACnCC,sBAAsB,eAAE,IAAIC,yBAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC;EACnEC,mBAAmB,eAAE,IAAID,yBAAY,CAAC,gBAAgB,EAAE,IAAI;CAC7D;;ACID,MAAM;EAAEE;CAAe,GAAGC,mBAAM;AAUhC,IAAKC,IAMJ;AAND,WAAKA,IAAI;EACPA,yCAAa;EACbA,uCAAY;EACZA,6BAAO;EACPA,+BAAQ;EACRA,6CAAe;AACjB,CAAC,EANIA,IAAI,KAAJA,IAAI;AAQT,MAAaC,oBAAqB,SAAQC,yBAAY;EASpDC,YAAYC,IAAsB;IAChC,KAAK,EAAE;IAHT,oBAAe,GAAG,MAAMV,qBAAqB,CAACC,sBAAsB;IAW7D,iBAAY,GAAG,MAAM,IAAI,CAACU,SAAS;IACnC,gBAAW,GAAG,MAAM,IAAI,CAACC,IAAI;IAE7B,eAAU,GAAG;MAClB,MAAMC,GAAG,GAAgB,EAAE;MAC3B,IAAI,IAAI,CAACF,SAAS,EAAE;QAClBE,GAAG,CAACP,IAAI,CAACK,SAAS,C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AM,IAAI,CAAC0B,SAAS;IAEnC,eAAU,GAAG;MAClB,MAAMxB,GAAG,GAAgB,EAAE;MAC3B,IAAI,IAAI,CAACF,SAAS,EAAE;QAClBE,GAAG,CAACP,MAAI,CAACK,SAAS,CAAC,GAAG,IAAIG,qBAAQ,CAChC,IAAI,CAACH,SAAS,EACdP,eAAa,CAACW,IAAI,CAACC,MAAM,EAAE,CAC5B;;MAEHH,GAAG,CAACP,MAAI,CAAC+B,SAAS,CAAC,GAAG,IAAI,CAACA,SAAS;MACpC,OAAO,IAAIvB,qBAAQ,CAACD,GAAG,CAAC;KACzB;IAjBC,IAAI,CAACwB,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAAC1B,SAAS,GAAGA,SAAS;;;AAkBdyB,+BAAY,GAAIR,QAAkB;EAC9C,MAAMf,GAAG,GAAGe,QAAQ,CAACC,OAAO,EAAE;EAC9B,MAAMQ,SAAS,GAAGxB,GAAG,CAACP,MAAI,CAAC+B,SAAS,CAAC;EAErC,OAAO,IAAID,kBAAkB,CAACC,SAAS,CAAC;AAC1C,CAAC;AAEaD,2BAAQ,GAAIE,YAAoB;EAC5C,MAAMV,QAAQ,GAAGO,gBAAgB,CAACG,YAAY,CAAC;EAC/C,OAAOF,kBAAkB,CAACG,YAAY,CAACX,QAAQ,CAAC;AAClD,CAAC;;AChDHY,sBAAS,CACPC,MAAM,CAACC,MAAM,CAAC1C,qBAAqB,CAAC,CACjC2C,MAAM,CAAEC,EAAE,IAAK,CAAC,CAACA,EAAE,CAAC5B,MAAM,EAAE,CAAC,CAC7BH,GAAG,CAAE+B,EAAE,IAAKA,EAAE,CAAC5B,MAAM,EAAE,CAAa,CACxC;;;;;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@keystonehq/bc-ur-registry"),t=require("uuid");const s={AVALANCHE_SIGN_REQUEST:new e.RegistryType("avax-sign-request",8301),AVALANCHE_SIGNATURE:new e.RegistryType("avax-signature",8302)},{RegistryTypes:a}=e.extend;var r;!function(e){e[e.requestId=1]="requestId",e[e.signData=2]="signData",e[e.mfp=3]="mfp",e[e.xpub=6]="xpub",e[e.walletIndex=7]="walletIndex"}(r||(r={}));class n extends e.RegistryItem{constructor(t){super(),this.getRegistryType=()=>s.AVALANCHE_SIGN_REQUEST,this.getRequestId=()=>this.requestId,this.getSignData=()=>this.data,this.toDataItem=()=>{const t={};return this.requestId&&(t[r.requestId]=new e.DataItem(this.requestId,a.UUID.getTag())),t[r.signData]=Buffer.from(this.data),t[r.mfp]=this.mfp.readUInt32BE(0),t[r.xpub]=this.xpub,t[r.walletIndex]=Number(this.walletIndex),new e.DataItem(t)},this.requestId=t.requestId,this.data=t.data,this.mfp=t.mfp,this.xpub=t.xpub,this.walletIndex=t.walletIndex}static constructAvalancheRequest(e,s,a,r,u){let i;return i="string"==typeof u?Buffer.from(t.parse(u)):u instanceof Buffer?u:Buffer.from(t.parse(t.v4())),new n({data:e,requestId:i,mfp:Buffer.from(s,"hex"),xpub:a,walletIndex:r})}}n.fromDataItem=e=>{const t=e.getData(),s=Buffer.alloc(4);s.writeUInt32BE(t[r.mfp],0);const a=t[r.requestId]?t[r.requestId].getData():void 0;return new n({requestId:a,data:t[r.signData],xpub:t[r.xpub],walletIndex:t[r.signData],mfp:s})};const{RegistryTypes:u,decodeToDataItem:i}=e.extend;var I;!function(e){e[e.requestId=1]="requestId",e[e.signature=2]="signature"}(I||(I={}));class d extends e.RegistryItem{constructor(t,a){super(),this.getRegistryType=()=>s.AVALANCHE_SIGNATURE,this.getRequestId=()=>this.requestId,this.getSignature=()=>this.signature,this.toDataItem=()=>{const t={};return this.requestId&&(t[I.requestId]=new e.DataItem(this.requestId,u.UUID.getTag())),t[I.signature]=this.signature,new e.DataItem(t)},this.signature=t,this.requestId=a}}d.fromDataItem=e=>{const t=e.getData();return new d(t[I.signature])},d.fromCBOR=e=>{const t=i(e);return d.fromDataItem(t)},e.patchTags(Object.values(s).filter(e=>!!e.getTag()).map(e=>e.getTag())),Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.AvalancheSignRequest=n,exports.AvalancheSignature=d;
|
|
2
|
-
//# sourceMappingURL=bc-ur-registry-avalanche.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bc-ur-registry-avalanche.cjs.production.min.js","sources":["../src/RegistryType.ts","../src/AvalancheSignRequest.ts","../src/AvalancheSignature.ts","../src/index.ts"],"sourcesContent":["import { RegistryType } from \"@keystonehq/bc-ur-registry\";\n\nexport const ExtendedRegistryTypes = {\n AVALANCHE_SIGN_REQUEST: new RegistryType(\"avax-sign-request\", 8301),\n AVALANCHE_SIGNATURE: new RegistryType(\"avax-signature\", 8302),\n};\n","import {\n DataItem,\n RegistryItem,\n extend,\n DataItemMap,\n} from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nimport * as uuid from \"uuid\";\n\nconst { RegistryTypes } = extend;\n\ntype signRequestProps = {\n requestId?: Buffer;\n data: Buffer;\n mfp: Buffer;\n xpub: string;\n walletIndex: number;\n};\n\nenum Keys {\n requestId = 1,\n signData = 2,\n mfp = 3,\n xpub = 6,\n walletIndex = 7,\n}\n\nexport class AvalancheSignRequest extends RegistryItem {\n private requestId?: Buffer;\n private data: Buffer;\n private mfp: Buffer;\n private xpub: string;\n private walletIndex: number;\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.mfp = args.mfp;\n this.xpub = args.xpub;\n this.walletIndex = args.walletIndex;\n }\n\n public getRequestId = () => this.requestId;\n public getSignData = () => this.data;\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.mfp] = this.mfp.readUInt32BE(0);\n map[Keys.xpub] = this.xpub;\n map[Keys.walletIndex] = Number(this.walletIndex);\n\n return new DataItem(map);\n };\n\n public static fromDataItem = (dataItem: DataItem) => {\n const map = dataItem.getData();\n const masterFingerprint = Buffer.alloc(4);\n const _masterFingerprint = map[Keys.mfp];\n masterFingerprint.writeUInt32BE(_masterFingerprint, 0);\n const requestId = map[Keys.requestId]\n ? map[Keys.requestId].getData()\n : undefined;\n const data = map[Keys.signData];\n const xpub = map[Keys.xpub];\n const walletIndex = map[Keys.signData];\n\n return new AvalancheSignRequest({\n requestId,\n data,\n xpub,\n walletIndex,\n mfp: masterFingerprint,\n });\n };\n\n public static constructAvalancheRequest(\n data: Buffer,\n mfp: string,\n xpub: string,\n walletIndex: number,\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()));\n }\n\n return new AvalancheSignRequest({\n data,\n requestId: _requestId,\n mfp: Buffer.from(mfp, \"hex\"),\n xpub,\n walletIndex,\n });\n }\n}\n","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","import { patchTags } from \"@keystonehq/bc-ur-registry\";\nimport { ExtendedRegistryTypes } from \"./RegistryType\";\nexport * from \"@keystonehq/bc-ur-registry\";\n\npatchTags(\n Object.values(ExtendedRegistryTypes)\n .filter((rt) => !!rt.getTag())\n .map((rt) => rt.getTag()) as number[]\n);\n\nexport { AvalancheSignRequest } from \"./AvalancheSignRequest\";\nexport { AvalancheSignature } from \"./AvalancheSignature\";\n"],"names":["ExtendedRegistryTypes","AVALANCHE_SIGN_REQUEST","RegistryType","AVALANCHE_SIGNATURE","RegistryTypes","extend","Keys","AvalancheSignRequest","RegistryItem","constructor","args","super","this","requestId","data","map","DataItem","UUID","getTag","signData","Buffer","from","mfp","readUInt32BE","xpub","walletIndex","Number","[object Object]","_requestId","uuid","dataItem","getData","masterFingerprint","alloc","writeUInt32BE","undefined","decodeToDataItem","AvalancheSignature","signature","_cborPayload","fromDataItem","patchTags","Object","values","filter","rt"],"mappings":"kIAEO,MAAMA,EAAwB,CACnCC,uBAAwB,IAAIC,eAAa,oBAAqB,MAC9DC,oBAAqB,IAAID,eAAa,iBAAkB,QCKpDE,cAAEA,GAAkBC,SAU1B,IAAKC,GAAL,SAAKA,GACHA,6BACAA,2BACAA,iBACAA,mBACAA,iCALF,CAAKA,IAAAA,aAQQC,UAA6BC,eASxCC,YAAYC,GACVC,QAHFC,qBAAkB,IAAMZ,EAAsBC,uBAWvCW,kBAAe,IAAMA,KAAKC,UAC1BD,iBAAc,IAAMA,KAAKE,KAEzBF,gBAAa,KAClB,MAAMG,EAAm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