-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from KeystoneHQ/prerelease
Prerelease
- Loading branch information
Showing
9 changed files
with
2,232 additions
and
2,563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# BC-UR-Registry-Avalanche | ||
|
||
This repository is the Avalanche extension of [bc-ur-registry](https://github.com/KeystoneHQ/ur-registry) | ||
|
||
## Installing | ||
|
||
To install, run: | ||
|
||
```bash | ||
yarn add @keystonehq/bc-ur-registry-avalanche | ||
``` | ||
|
||
```bash | ||
npm install --save @keystonehq/bc-ur-registry-avalanche | ||
``` |
21 changes: 21 additions & 0 deletions
21
packages/ur-registry-avalanche/__tests__/AvalancheSignRequest.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @ts-nocheck | ||
|
||
import { StellarSignRequest, SignType, AvalancheSignRequest } from "../src"; | ||
import { CryptoKeypath, PathComponent } from "../src"; | ||
import * as uuid from "uuid"; | ||
|
||
describe("avalanche-sign-request", () => { | ||
it("test should generate avalanche-sign-reqeust", () => { | ||
const avalancheData = Buffer.from( | ||
"00000000000000000001ed5f38341e436e5d46e2bb00b45d62ae97d1b050c64bc634ae10626739e35c4b0000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000000000089544000000000000000000000000100000001512e7191685398f00663e12197a3d8f6012d9ea300000001db720ad6707915cc4751fb7e5491a3af74e127a1d81817abe9438590c0833fe10000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000000989680000000010000000000000000", | ||
"hex" | ||
); | ||
|
||
const avalancheSignRequest = | ||
AvalancheSignRequest.constructAvalancheRequest(avalancheData); | ||
|
||
expect(avalancheSignRequest.toUR().cbor.toString("hex")).toBe( | ||
"58de00000000000000000001ed5f38341e436e5d46e2bb00b45d62ae97d1b050c64bc634ae10626739e35c4b0000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000000000089544000000000000000000000000100000001512e7191685398f00663e12197a3d8f6012d9ea300000001db720ad6707915cc4751fb7e5491a3af74e127a1d81817abe9438590c0833fe10000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000000989680000000010000000000000000" | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@keystonehq/bc-ur-registry-avalanche", | ||
"version": "0.0.2", | ||
"description": "bc-ur-registry extension for Avalanche", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"directories": { | ||
"lib": "src", | ||
"test": "__tests__" | ||
}, | ||
"files": [ | ||
"src", | ||
"dist" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf ./dist", | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "jest --passWithNoTests" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@keystonehq/bc-ur-registry": "^0.6.4", | ||
"uuid": "^8.3.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@types/uuid": "^8.3.1", | ||
"tsdx": "^0.14.1", | ||
"typescript": "^4.6.2" | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/ur-registry-avalanche/src/AvalancheSignRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DataItem, RegistryItem } from "@keystonehq/bc-ur-registry"; | ||
import { ExtendedRegistryTypes } from "./RegistryType"; | ||
import * as uuid from "uuid"; | ||
|
||
type signRequestProps = { | ||
requestId?: Buffer; | ||
data: Buffer; | ||
}; | ||
|
||
export class AvalancheSignRequest extends RegistryItem { | ||
private requestId?: Buffer; | ||
private data: Buffer; | ||
|
||
getRegistryType = () => ExtendedRegistryTypes.AVALANCHE_SIGN_REQUEST; | ||
|
||
constructor(args: signRequestProps) { | ||
super(); | ||
this.requestId = args.requestId; | ||
this.data = args.data; | ||
} | ||
|
||
public getRequestId = () => this.requestId; | ||
public getSignData = () => this.data; | ||
|
||
public toDataItem = () => { | ||
return new DataItem(this.data); | ||
}; | ||
|
||
public static constructAvalancheRequest(data: Buffer, uuidString?: string) { | ||
return new AvalancheSignRequest({ | ||
data, | ||
requestId: uuidString | ||
? Buffer.from(uuid.parse(uuidString) as Uint8Array) | ||
: undefined, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { RegistryType } from "@keystonehq/bc-ur-registry"; | ||
|
||
export const ExtendedRegistryTypes = { | ||
AVALANCHE_SIGN_REQUEST: new RegistryType("avax-sign-request", 8301), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { patchTags } from "@keystonehq/bc-ur-registry"; | ||
import { ExtendedRegistryTypes } from "./RegistryType"; | ||
export * from "@keystonehq/bc-ur-registry"; | ||
|
||
patchTags( | ||
Object.values(ExtendedRegistryTypes) | ||
.filter((rt) => !!rt.getTag()) | ||
.map((rt) => rt.getTag()) as number[] | ||
); | ||
|
||
export { AvalancheSignRequest } from "./AvalancheSignRequest"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"rootDir": "./", | ||
"baseUrl": "./", | ||
"paths": { | ||
"*": ["src/*", "node_modules/*"] | ||
} | ||
} | ||
} |
Oops, something went wrong.