-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
1,568 additions
and
470 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-http","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-http","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-ipc","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-ipc","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-ws","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-ws","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-abi","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-abi","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-account","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-account","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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,23 @@ | ||
// import { checkParams } from '~@vite/vitejs-utils'; | ||
|
||
// export function checkAccountBlockKeywords({ blockType, accountAddress, toAddress, amount }) { | ||
// const err = checkParams({ blockType, accountAddress, toAddress, amount }, [], [ { | ||
// name: 'accountAddress', | ||
// func: isAddress | ||
// }, { | ||
// name: 'toAddress', | ||
// func: isAddress | ||
// }, { | ||
// name: 'blockType', | ||
// func: _b => BlockType[_b], | ||
// msg: `Don\'t have blockType ${ blockType }` | ||
// }, { | ||
// name: 'amount', | ||
// func: isNonNegativeInteger, | ||
// msg: 'Amount must be an non-negative integer string.' | ||
// } ]); | ||
|
||
// if (err) { | ||
// return err; | ||
// } | ||
// } |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-accountblock","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-accountblock","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"@vite/vitejs-addraccount","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} | ||
{"name":"@vite/vitejs-addraccount","version":"2.2.11-alpha.0","main":"dist/index.node.js","browser":"dist/index.web.js","typings":"index.ts","repository":{"type":"git","url":"git+https://github.com/vitelabs/vite.js.git"},"license":"ISC","bugs":{"url":"https://github.com/vitelabs/vite.js/issues"},"homepage":"https://github.com/vitelabs/vite.js#readme","publishConfig":{"access":"public"}} |
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
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,67 @@ | ||
const hd = require('@sisi/ed25519-blake2b-hd-key'); | ||
import { createAddressByPrivateKey, isAddress as _isAddress, getRealAddressFromAddress as _getRealAddressFromAddress } from '~@vite/vitejs-privtoaddr'; | ||
import { paramsFormat } from '~@vite/vitejs-error'; | ||
import { bytesToHex, blake2b } from '~@vite/vitejs-utils'; | ||
|
||
import { AddrObj, Hex } from './type'; | ||
|
||
const ROOT_PATH = 'm/44\'/666666\''; | ||
|
||
export function createAddress(seed: string, isContract?: boolean): AddrObj { | ||
const path = getPath(0); | ||
return getAddrFromPath(path, seed, isContract); | ||
} | ||
|
||
export function getAddrFromMnemonic(seed, index = 0, isContract?: boolean): AddrObj { | ||
if (index < 0) { | ||
console.warn(`${ paramsFormat.message } Index must greater than 0.`); | ||
index = 0; | ||
} | ||
|
||
const path = getPath(index); | ||
return getAddrFromPath(path, seed, isContract); | ||
} | ||
|
||
export function getAddrsFromMnemonic(seed, start = 0, num = 10, isContract?: boolean): AddrObj[] { | ||
if (start < 0) { | ||
console.warn(`${ paramsFormat.message } Start must greater than 0 or equal to 0.`); | ||
start = 0; | ||
} | ||
|
||
if (num <= 0) { | ||
return []; | ||
} | ||
|
||
const addrs = []; | ||
for (let i = start; i < start + num; i++) { | ||
const currentPath = getPath(i); | ||
const addr = getAddrFromPath(currentPath, seed, isContract); | ||
addrs.push(addr); | ||
} | ||
|
||
return addrs; | ||
} | ||
|
||
export const getId = _getId; | ||
|
||
export const getRealAddressFromAddress = _getRealAddressFromAddress; | ||
|
||
export const isAddress = _isAddress; | ||
|
||
|
||
function getAddrFromPath(path: string, seed: string, isContract?: boolean): AddrObj { | ||
const { key } = hd.derivePath(path, seed); | ||
const { privateKey } = hd.getPublicKey(key); | ||
const priv = bytesToHex(privateKey); | ||
return createAddressByPrivateKey(priv, isContract); | ||
} | ||
|
||
function getPath(index: number): string { | ||
return `${ ROOT_PATH }/${ index }\'`; | ||
} | ||
|
||
function _getId(address: string): Hex { | ||
const keyBuffer = Buffer.from(address); | ||
const idByte = blake2b(keyBuffer, null, 32); | ||
return Buffer.from(idByte).toString('hex'); | ||
} |
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
Oops, something went wrong.