[chore] update a lot

@types
neeboo 6 years ago
parent 7b41bae315
commit 14546f58ea
  1. 2
      examples/temp.html
  2. 1
      gulpfile.js
  3. 1
      package.json
  4. 23
      packages/harmony-contract/package.json
  5. 1559
      packages/harmony-contract/src/abi/abiCoder.ts
  6. 1
      packages/harmony-contract/src/index.ts
  7. 8
      packages/harmony-contract/tsconfig.json
  8. 5
      packages/harmony-contract/tsconfig.test.json
  9. 39
      packages/harmony-crypto/__test__/base58.test.ts
  10. 140
      packages/harmony-crypto/__test__/base58fixture.ts
  11. 5
      packages/harmony-crypto/package.json
  12. 18
      packages/harmony-crypto/src/base58.ts
  13. 4
      scripts/jest/jest.src.config.js
  14. 1
      scripts/packages.js
  15. 1
      scripts/packagesList.js
  16. 1
      scripts/packagesTs.ts
  17. 1
      tsconfig.json

@ -38,7 +38,7 @@
<script src="../dist/HarmonyJs.browser.js"></script>
<script>
const harmony= new HarmonyJs.Harmony('ws://localhost:18545',1);
const harmony= new HarmonyJs.Harmony('ws://localhost:9128',0);
// console.log()

@ -6,6 +6,7 @@ const packages = [
'harmony-crypto',
'harmony-account',
'harmony-network',
'harmony-contract',
'harmony-utils',
'harmony-transaction',
];

@ -47,6 +47,7 @@
"@babel/preset-typescript": "^7.0.0-beta.56",
"@babel/runtime": "^7.0.0-beta.56",
"@trust/webcrypto": "^0.9.2",
"@types/base-x": "^3.0.0",
"@types/bip39": "^2.4.2",
"@types/bn.js": "^4.11.3",
"@types/camelcase": "^4.1.0",

@ -0,0 +1,23 @@
{
"name": "@harmony/contract",
"version": "0.0.1",
"description": "contract libraries for harmony",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "neeboo@firestack.one",
"publishConfig": {
"access": "public"
},
"license": "ISC",
"dependencies": {
"@harmony/crypto": "^0.0.1",
"@harmony/utils": "^0.0.1"
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
export * from './abi/abiCoder';

@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src", "../../typings/**/*.d.ts"]
}

@ -0,0 +1,5 @@
{
"extends": "../../tsconfig.test.json",
"include": ["src", "test", "../../typings/**/*.d.ts"],
"references": []
}

@ -0,0 +1,39 @@
import { bs58Decode, bs58Encode } from '../src/base58';
import { fixtures, testData } from './base58fixture';
describe('test bs58', () => {
it('should test encode', () => {
fixtures.valid.forEach((f: any) => {
const actual = bs58Encode(f.hex);
expect(actual).toEqual(f.string);
});
});
it('should test decode', () => {
fixtures.valid.forEach((f: any) => {
const actual = bs58Decode(f.string);
expect(actual).toEqual(f.hex);
});
});
it('should throw error', () => {
fixtures.invalid.forEach((f: any) => {
try {
bs58Decode(f.string);
} catch (error) {
expect(error.message).toEqual('Non-base58 character');
}
});
});
it('another test', () => {
testData.forEach((f: any) => {
const actual = bs58Encode(f.raw);
expect(actual).toEqual(f.res);
const actualDecode = bs58Decode(f.res);
expect(actualDecode).toEqual(f.raw);
});
});
it('manual test', () => {
const raw = '0x';
const actual = bs58Encode(raw);
expect(actual).toEqual('');
});
});

@ -0,0 +1,140 @@
export const fixtures = {
valid: [
{
hex: '',
string: '',
},
{
hex: '61',
string: '2g',
},
{
hex: '626262',
string: 'a3gV',
},
{
hex: '636363',
string: 'aPEr',
},
{
hex: '73696d706c792061206c6f6e6720737472696e67',
string: '2cFupjhnEsSn59qHXstmK2ffpLv2',
},
{
hex: '00eb15231dfceb60925886b67d065299925915aeb172c06647',
string: '1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L',
},
{
hex: '516b6fcd0f',
string: 'ABnLTmg',
},
{
hex: 'bf4f89001e670274dd',
string: '3SEo3LWLoPntC',
},
{
hex: '572e4794',
string: '3EFU7m',
},
{
hex: 'ecac89cad93923c02321',
string: 'EJDM8drfXA6uyA',
},
{
hex: '10c8511e',
string: 'Rt5zm',
},
{
hex: '00000000000000000000',
string: '1111111111',
},
{
hex:
'801184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd206ec97e',
string: '5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD',
},
{
hex: '003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187',
string: '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS',
},
],
invalid: [
{
description: 'non-base58 string',
string: 'invalid',
},
{
description: 'non-base58 alphabet',
string: 'c2F0b3NoaQo=',
},
{
description: 'leading whitespace',
string: ' 1111111111',
},
{
description: 'trailing whitespace',
string: '1111111111 ',
},
{
description: 'unexpected character after whitespace',
string: ' \t\n\u000b\f\r skip \r\f\u000b\n\t a',
},
],
};
export const testData = [
{
raw: '',
res: '',
},
{
raw: '61',
res: '2g',
},
{
raw: '626262',
res: 'a3gV',
},
{
raw: '636363',
res: 'aPEr',
},
{
raw: '73696d706c792061206c6f6e6720737472696e67',
res: '2cFupjhnEsSn59qHXstmK2ffpLv2',
},
{
raw: '00eb15231dfceb60925886b67d065299925915aeb172c06647',
res: '1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L',
},
{
raw: '516b6fcd0f',
res: 'ABnLTmg',
},
{
raw: '572e4794',
res: '3EFU7m',
},
{
raw: 'ecac89cad93923c02321',
res: 'EJDM8drfXA6uyA',
},
{
raw: '10c8511e',
res: 'Rt5zm',
},
{
raw: '00000000000000000000',
res: '1111111111',
},
{
raw:
'801184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd206ec97e',
res: '5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD',
},
{
raw: '003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187',
res: '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS',
},
];

@ -7,7 +7,7 @@
"browser": "dist/index.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"typings":"dist/index.d.ts",
"typings": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@ -17,8 +17,9 @@
},
"license": "ISC",
"dependencies": {
"@harmony/utils":"^0.0.1",
"@harmony/utils": "^0.0.1",
"aes-js": "^3.1.2",
"base-x": "^3.0.5",
"bip39": "^2.5.0",
"bn.js": "^4.11.8",
"elliptic": "^6.4.1",

@ -0,0 +1,18 @@
import base from 'base-x';
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const base58 = base(BASE58);
export const bs58Encode = (hex: string): string => {
if (hex.startsWith('0x') || hex.startsWith('0X')) {
hex = hex.substring(2);
}
const hexBuff = Buffer.from(hex, 'hex');
return base58.encode(hexBuff);
};
export const bs58Decode = (baseString: string): string => {
const baseBuf = base58.decode(baseString);
return baseBuf.toString('hex');
};

@ -15,7 +15,7 @@ const config = {
'<rootDir>/packages/harmony-core/__test__/?(*.)+(spec|test).ts',
// '<rootDir>/packages/laksa-core/__test__/?(*.)+(spec|test).js'
// '<rootDir>/packages/laksa-core-contract/__test__/?(*.)+(spec|test).js'
// '<rootDir>/packages/laksa-core-crypto/__test__/?(*.)+(spec|test).js',
'<rootDir>/packages/harmony-crypto/__test__/?(*.)+(spec|test).ts',
// '<rootDir>/packages/laksa-core-messenger/__test__/?(*.)+(spec|test).js'
// '<rootDir>/packages/laksa-core-provider/__test__/?(*.)+(spec|test).js',
// '<rootDir>/packages/laksa-core-transaction/__test__/?(*.)+(spec|test).js',
@ -46,7 +46,7 @@ const config = {
// 'packages/!(harmony-core)/src/**/*.ts',
'packages/harmony-core/src/**/*.ts',
'packages/harmony-utils/src/**/*.ts',
// 'packages/!(laksa-core-crypto)/src/*.js'
'packages/harmony-crypto/src/**/*.ts',
],
timers: 'fake',
setupFiles: ['<rootDir>/scripts/jest/jest.setup.js'],

@ -3,6 +3,7 @@ export default [
'harmony-utils',
'harmony-crypto',
'harmony-account',
'harmony-contract',
'harmony-network',
'harmony-transaction',
];

@ -3,6 +3,7 @@ module.exports = [
{ name: 'HarmonyNetwork', dest: 'harmony-network' },
{ name: 'HarmonyUtils', dest: 'harmony-utils' },
{ name: 'HarmonyCrypto', dest: 'harmony-crypto' },
{ name: 'HarmonyContract', dest: 'harmony-contract' },
{ name: 'HarmonyAccount', dest: 'harmony-account' },
{ name: 'HarmonyTransaction', dest: 'harmony-transaction' },
];

@ -2,6 +2,7 @@ const packages = [
'harmony-core',
'harmony-utils',
'harmony-crypto',
'harmony-contract',
'harmony-account',
'harmony-network',
'harmony-transaction',

@ -3,6 +3,7 @@
"references": [
{ "path": "packages/harmony-core" },
{ "path": "packages/harmony-account" },
{ "path": "packages/harmony-contract" },
{ "path": "packages/harmony-crypto" },
{ "path": "packages/harmony-utils" },
{ "path": "packages/harmony-network" },

Loading…
Cancel
Save