Compare commits
10 Commits
6bcc378170
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ca9dbb3e | ||
|
|
9d5de815b5 | ||
|
|
9003a0bc8f | ||
|
|
e43aa9ed80 | ||
|
|
2cd5a0045d | ||
|
|
6f2943e8ca | ||
|
|
c5fd3932df | ||
|
|
0453eab059 | ||
|
|
9e7850e49b | ||
|
|
bb8b1da5f5 |
114
.gitignore
vendored
114
.gitignore
vendored
@@ -1,7 +1,109 @@
|
||||
# 以'#'开始的行,被视为注释.
|
||||
node_modules
|
||||
package-lock.json
|
||||
.vscode
|
||||
.svn
|
||||
~*
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
# how to include another gitignore?
|
||||
# https://stackoverflow.com/questions/7005142/can-i-include-other-gitignore-file-in-a-gitignore-file-like-include-in-c-li
|
||||
# https://github.com/github/gitignore
|
||||
# https://github.com/SlideWave/gitignore-include?tab=readme-ov-file#examples
|
||||
# https://gitignore.io
|
||||
|
||||
### .gitignore.global.txt ###
|
||||
|
||||
# Self defined pattern to ignore
|
||||
?*.gitignore
|
||||
?*.gitignore/
|
||||
?*.gitignore.*
|
||||
?*.gitignore.*/
|
||||
*.gitomit
|
||||
*.gitomit/
|
||||
*.gitomit.*
|
||||
*.gitomit.*/
|
||||
# 保留
|
||||
!.gitignore
|
||||
!.gitignore.*
|
||||
!.gitkeep
|
||||
|
||||
# 通用
|
||||
.svn/
|
||||
.deploy_git/
|
||||
.idea/
|
||||
.sass-cache/
|
||||
.wrangler
|
||||
/test/unit/coverage/
|
||||
/test/e2e/reports/
|
||||
node_modules/
|
||||
*.aab
|
||||
*.apk
|
||||
*.ipa
|
||||
*.min.js
|
||||
*.min.css
|
||||
*.min.html
|
||||
*.iml
|
||||
*.njsproj
|
||||
*.ntvs*
|
||||
*.sw*
|
||||
*.sln
|
||||
*.suo
|
||||
.gitattributes
|
||||
.umi
|
||||
.umi-production
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
yarn.lock
|
||||
selenium-debug.log
|
||||
Thumbs.db
|
||||
thumbs.db
|
||||
_desktop.ini
|
||||
|
||||
# vue-cli 项目
|
||||
/dist/
|
||||
|
||||
# 来自 vue-cli 创建项目的 .gitignore
|
||||
.project
|
||||
|
||||
# hexo
|
||||
/public/
|
||||
|
||||
# Hardhat
|
||||
/artifacts/
|
||||
/cache/
|
||||
|
||||
# seafile 临时文件
|
||||
._*
|
||||
|
||||
.$*
|
||||
|
||||
# office 暂存文件
|
||||
~$*
|
||||
|
||||
# 用户shell配置脚本
|
||||
.bashrc_custom
|
||||
|
||||
# 苹果系统临时文件
|
||||
.DS_Store
|
||||
|
||||
# 安卓缓存文件夹
|
||||
.thumbnails
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# hexo
|
||||
/db.json
|
||||
|
||||
# wo
|
||||
# 服务端
|
||||
/_archive/*
|
||||
/_datastore/*
|
||||
/_filestore/*
|
||||
/_logstore/*
|
||||
/_webroot/*
|
||||
/_ssl/*
|
||||
# uniapp 客户端
|
||||
/unpackage/*
|
||||
!/unpackage/res/
|
||||
package-lock.json
|
||||
pages4loader.json5
|
||||
|
||||
### .gitignore.local.txt ###
|
||||
|
||||
|
||||
6
btc.js
6
btc.js
@@ -10,9 +10,9 @@ const BTC_TXFEE = 30
|
||||
|
||||
class BTC {
|
||||
constructor (privateKey) {
|
||||
if (!ticc.is_seckey({ prikey: privateKey }))
|
||||
if (!ticc.is_prikey({ prikey: privateKey }))
|
||||
throw new Error('Invalid PrivateKey')
|
||||
var publicKey = ticc.seckey_to_pubkey(privateKey)
|
||||
var publicKey = ticc.prikey_to_pubkey(privateKey)
|
||||
Object.defineProperties(this, {
|
||||
privateKey: {
|
||||
enumerable: true,
|
||||
@@ -22,7 +22,7 @@ class BTC {
|
||||
publicKey: {
|
||||
enumerable: true,
|
||||
writable: false,
|
||||
value: ticc.seckey_to_pubkey({ prikey: privateKey, coin: 'BTC' })
|
||||
value: ticc.prikey_to_pubkey({ prikey: privateKey, coin: 'BTC' })
|
||||
},
|
||||
address: {
|
||||
enumerable: true,
|
||||
|
||||
68
seafile-ignore.txt
Normal file
68
seafile-ignore.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
# https://help.seafile.com/syncing_client/excluding_files/
|
||||
# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。
|
||||
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
|
||||
# 在这种情况下,
|
||||
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
|
||||
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
|
||||
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
|
||||
|
||||
### seafile-ignore.global.txt ###
|
||||
|
||||
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
|
||||
*.sfignore
|
||||
*.sfignore/
|
||||
*.sfignore.*
|
||||
*.sfignore.*/
|
||||
*.sfomit
|
||||
*.sfomit.*
|
||||
*.sfomit/
|
||||
*.sfomit.*/
|
||||
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
|
||||
.thumbnails
|
||||
*/.thumbnails
|
||||
|
||||
Thumbs.db
|
||||
*/Thumbs.db
|
||||
thumbs.db
|
||||
*/thumbs.db
|
||||
|
||||
_desktop.ini
|
||||
*/_desktop.ini
|
||||
|
||||
._*
|
||||
*/._*
|
||||
|
||||
.$*
|
||||
*/.$*
|
||||
|
||||
~$*
|
||||
*/~$*
|
||||
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
package-lock.json
|
||||
|
||||
pages4loader.json5
|
||||
|
||||
.deploy_git/
|
||||
*/.deploy_git/
|
||||
|
||||
# HBuilder 目录
|
||||
unpackage/
|
||||
*/unpackage/
|
||||
|
||||
Icon
|
||||
OneDrive/Icon
|
||||
|
||||
# wrangler project
|
||||
|
||||
.dev.vars*
|
||||
*/.dev.vars*
|
||||
.wrangler/
|
||||
*/.wrangler/
|
||||
|
||||
### seafile-ignore.local.txt ###
|
||||
|
||||
8
tic.js
8
tic.js
@@ -8,7 +8,7 @@ const TIC_NODE = require('./netConfig').TIC_NODE
|
||||
|
||||
class TIC {
|
||||
constructor (prikey, option = {}) {
|
||||
if (!prikey || !ticc.is_seckey({ prikey })) throw 'ERROR:Invalid Seckey'
|
||||
if (!prikey || !ticc.is_prikey({ prikey })) throw 'ERROR:Invalid Seckey'
|
||||
Object.defineProperties(this, {
|
||||
prikey: {
|
||||
value: prikey,
|
||||
@@ -16,13 +16,13 @@ class TIC {
|
||||
writable: false
|
||||
},
|
||||
pubkey: {
|
||||
value: ticc.seckey_to_pubkey({ prikey }),
|
||||
value: ticc.prikey_to_pubkey({ prikey }),
|
||||
enumerable: true,
|
||||
writable: false
|
||||
},
|
||||
address: {
|
||||
value: ticc.pubkey_to_address({
|
||||
pubkey: ticc.seckey_to_pubkey(prikey)
|
||||
pubkey: ticc.prikey_to_pubkey(prikey)
|
||||
}),
|
||||
enumerable: true,
|
||||
writable: false
|
||||
@@ -93,7 +93,7 @@ class TIC {
|
||||
}
|
||||
|
||||
static isValidAddress (address) {
|
||||
return ticc.is_chain_address({ address })
|
||||
return ticc.which_chain_address({ address })
|
||||
}
|
||||
|
||||
async sendTransaction (toAddress, amount, option = { gasFee: TIC_TXFEE }) {
|
||||
|
||||
@@ -1,97 +1,111 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
var bigNumberify = require('./bignumber').bigNumberify;
|
||||
var convert = require('./convert');
|
||||
var getAddress = require('./address').getAddress;
|
||||
var utf8 = require('./utf8');
|
||||
var bigNumberify = require('./bignumber').bigNumberify
|
||||
var convert = require('./convert')
|
||||
var getAddress = require('./address').getAddress
|
||||
var utf8 = require('./utf8')
|
||||
|
||||
var hashKeccak256 = require('./keccak256');
|
||||
var hashSha256 = require('./sha2').sha256;
|
||||
var hashKeccak256 = require('./keccak256')
|
||||
var hashSha256 = require('./sha2').sha256
|
||||
|
||||
var regexBytes = new RegExp("^bytes([0-9]+)$");
|
||||
var regexNumber = new RegExp("^(u?int)([0-9]*)$");
|
||||
var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
|
||||
var regexBytes = new RegExp('^bytes([0-9]+)$')
|
||||
var regexNumber = new RegExp('^(u?int)([0-9]*)$')
|
||||
var regexArray = new RegExp('^(.*)\\[([0-9]*)\\]$')
|
||||
|
||||
var Zeros = '0000000000000000000000000000000000000000000000000000000000000000';
|
||||
var Zeros = '0000000000000000000000000000000000000000000000000000000000000000'
|
||||
|
||||
function _pack(type, value, isArray) {
|
||||
switch(type) {
|
||||
case 'address':
|
||||
if (isArray) { return convert.padZeros(value, 32); }
|
||||
return convert.arrayify(value);
|
||||
case 'string':
|
||||
return utf8.toUtf8Bytes(value);
|
||||
case 'bytes':
|
||||
return convert.arrayify(value);
|
||||
case 'bool':
|
||||
value = (value ? '0x01': '0x00');
|
||||
if (isArray) { return convert.padZeros(value, 32); }
|
||||
return convert.arrayify(value);
|
||||
function _pack (type, value, isArray) {
|
||||
switch (type) {
|
||||
case 'address':
|
||||
if (isArray) {
|
||||
return convert.padZeros(value, 32)
|
||||
}
|
||||
return convert.arrayify(value)
|
||||
case 'string':
|
||||
return utf8.toUtf8Bytes(value)
|
||||
case 'bytes':
|
||||
return convert.arrayify(value)
|
||||
case 'bool':
|
||||
value = value ? '0x01' : '0x00'
|
||||
if (isArray) {
|
||||
return convert.padZeros(value, 32)
|
||||
}
|
||||
return convert.arrayify(value)
|
||||
}
|
||||
|
||||
var match = type.match(regexNumber)
|
||||
if (match) {
|
||||
var signed = match[1] === 'int'
|
||||
var size = parseInt(match[2] || '256')
|
||||
if (size % 8 != 0 || size === 0 || size > 256) {
|
||||
throw new Error('invalid number type - ' + type)
|
||||
}
|
||||
|
||||
var match = type.match(regexNumber);
|
||||
if (match) {
|
||||
var signed = (match[1] === 'int')
|
||||
var size = parseInt(match[2] || "256")
|
||||
if ((size % 8 != 0) || size === 0 || size > 256) {
|
||||
throw new Error('invalid number type - ' + type);
|
||||
}
|
||||
|
||||
if (isArray) { size = 256; }
|
||||
|
||||
value = bigNumberify(value).toTwos(size);
|
||||
|
||||
return convert.padZeros(value, size / 8);
|
||||
if (isArray) {
|
||||
size = 256
|
||||
}
|
||||
|
||||
match = type.match(regexBytes);
|
||||
if (match) {
|
||||
var size = match[1];
|
||||
if (size != parseInt(size) || size === 0 || size > 32) {
|
||||
throw new Error('invalid number type - ' + type);
|
||||
}
|
||||
size = parseInt(size);
|
||||
if (convert.arrayify(value).byteLength !== size) { throw new Error('invalid value for ' + type); }
|
||||
if (isArray) { return (value + Zeros).substring(0, 66); }
|
||||
return value;
|
||||
}
|
||||
value = bigNumberify(value).toTwos(size)
|
||||
|
||||
match = type.match(regexArray);
|
||||
if (match) {
|
||||
var baseType = match[1];
|
||||
var count = parseInt(match[2] || value.length);
|
||||
if (count != value.length) { throw new Error('invalid value for ' + type); }
|
||||
var result = [];
|
||||
value.forEach(function(value) {
|
||||
value = _pack(baseType, value, true);
|
||||
result.push(value);
|
||||
});
|
||||
return convert.concat(result);
|
||||
}
|
||||
return convert.padZeros(value, size / 8)
|
||||
}
|
||||
|
||||
throw new Error('unknown type - ' + type);
|
||||
match = type.match(regexBytes)
|
||||
if (match) {
|
||||
var size = match[1]
|
||||
if (size != parseInt(size) || size === 0 || size > 32) {
|
||||
throw new Error('invalid number type - ' + type)
|
||||
}
|
||||
size = parseInt(size)
|
||||
if (convert.arrayify(value).byteLength !== size) {
|
||||
throw new Error('invalid value for ' + type)
|
||||
}
|
||||
if (isArray) {
|
||||
return (value + Zeros).substring(0, 66)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
match = type.match(regexArray)
|
||||
if (match) {
|
||||
var valueType = match[1]
|
||||
var count = parseInt(match[2] || value.length)
|
||||
if (count != value.length) {
|
||||
throw new Error('invalid value for ' + type)
|
||||
}
|
||||
var result = []
|
||||
value.forEach(function (value) {
|
||||
value = _pack(valueType, value, true)
|
||||
result.push(value)
|
||||
})
|
||||
return convert.concat(result)
|
||||
}
|
||||
|
||||
throw new Error('unknown type - ' + type)
|
||||
}
|
||||
|
||||
function pack(types, values) {
|
||||
if (types.length != values.length) { throw new Error('type/value count mismatch'); }
|
||||
var tight = [];
|
||||
types.forEach(function(type, index) {
|
||||
tight.push(_pack(type, values[index]));
|
||||
});
|
||||
return convert.hexlify(convert.concat(tight));
|
||||
function pack (types, values) {
|
||||
if (types.length != values.length) {
|
||||
throw new Error('type/value count mismatch')
|
||||
}
|
||||
var tight = []
|
||||
types.forEach(function (type, index) {
|
||||
tight.push(_pack(type, values[index]))
|
||||
})
|
||||
return convert.hexlify(convert.concat(tight))
|
||||
}
|
||||
|
||||
function keccak256(types, values) {
|
||||
return hashKeccak256(pack(types, values));
|
||||
function keccak256 (types, values) {
|
||||
return hashKeccak256(pack(types, values))
|
||||
}
|
||||
|
||||
function sha256(types, values) {
|
||||
return hashSha256(pack(types, values));
|
||||
function sha256 (types, values) {
|
||||
return hashSha256(pack(types, values))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
pack: pack,
|
||||
pack: pack,
|
||||
|
||||
keccak256: keccak256,
|
||||
sha256: sha256,
|
||||
keccak256: keccak256,
|
||||
sha256: sha256
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user