diff --git a/dist/package.json b/dist/package.json index 63946fc6..0670dee2 100644 --- a/dist/package.json +++ b/dist/package.json @@ -70,7 +70,7 @@ "uuid": "^3.3.2", "is_js": "^0.9.0", "isomorphic-ws": "^4.0.1", - "mathjs": "^6.6.1", + "mathjs": "7.5.1", "ndjson": "^1.5.0", "pumpify": "^2.0.1", "secp256k1": "^3.7.1", diff --git a/dist/src/utils/crypto.js b/dist/src/utils/crypto.js index 11f044b9..00755afa 100644 --- a/dist/src/utils/crypto.js +++ b/dist/src/utils/crypto.js @@ -301,7 +301,8 @@ var Crypto = /*#__PURE__*/function () { switch (publicKey.type) { case types.PubkeyType.ed25519: - throw new _errors.SdkError("not implement", _errors.CODES.Panic); + hash = _utils.Utils.sha256(publicKey.value).substr(0, 40); + break; case types.PubkeyType.sm2: hash = _utils.Utils.sha256(publicKey.value).substr(0, 40); diff --git a/package.json b/package.json index 896322db..c83720c7 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "uuid": "^3.3.2", "is_js": "^0.9.0", "isomorphic-ws": "^4.0.1", - "mathjs": "^6.6.1", + "mathjs": "7.5.1", "ndjson": "^1.5.0", "pumpify": "^2.0.1", "secp256k1": "^3.7.1", diff --git a/src/utils/crypto.ts b/src/utils/crypto.ts index 86ac1aea..29385ea9 100644 --- a/src/utils/crypto.ts +++ b/src/utils/crypto.ts @@ -222,7 +222,8 @@ export class Crypto { let hash:string = ''; switch(publicKey.type){ case types.PubkeyType.ed25519: - throw new SdkError("not implement",CODES.Panic); + hash = Utils.sha256(publicKey.value).substr(0,40); + break; case types.PubkeyType.sm2: hash = Utils.sha256(publicKey.value).substr(0,40); break; diff --git a/test/crypto.test.ts b/test/crypto.test.ts index a4e91786..d4ed5847 100644 --- a/test/crypto.test.ts +++ b/test/crypto.test.ts @@ -33,8 +33,17 @@ test('Crypto', async () => { test('Marshal PubKey', async ()=>{ let pk = Crypto.aminoMarshalPubKey({ type:types.PubkeyType.ed25519, - value:'F205xccFhKHMnNEHFwtHLzDVjPaGGBuSnO0wR8OmEvo=' + value:'FT782NmKqtZYi6UyNzprh44u7defkzD18IePql6Uj3c==' }); let pk_bech32 = Crypto.encodeAddress(pk,'icp'); console.log('pk_bech32:',pk_bech32); }); + +test('get Address From PublicKey', async ()=>{ + let pk = Crypto.getAddressFromPublicKey({ + type:types.PubkeyType.ed25519, + value:Buffer.from('FT782NmKqtZYi6UyNzprh44u7defkzD18IePql6Uj3c==','base64').toString('hex') + },'ica'); + console.log('pk_bech32:',pk); +}); + diff --git a/test/slashing.test.ts b/test/slashing.test.ts index e6999f1e..605febc6 100644 --- a/test/slashing.test.ts +++ b/test/slashing.test.ts @@ -21,7 +21,7 @@ describe('Slashing Tests', () => { describe('Query Signing Info', () => { test('query signing info', async () => { await BaseTest.getClient() - .slashing.querySigningInfo('fca1f46x0s36d5ajjqjurt3znhqfdulyf7zlazpj8n') + .slashing.querySigningInfo('ica12x4wemz4qtwr5rql4awp0r6rx0pxws35t4wkdp') .then(res => { console.log(JSON.stringify(res)); }) diff --git a/yarn.lock b/yarn.lock index fcadd5dc..e89625f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2271,7 +2271,7 @@ decamelize@^1.1.0, decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= -decimal.js@^10.0.0, decimal.js@^10.2.0: +decimal.js@^10.0.0, decimal.js@^10.2.1: version "10.2.1" resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3" integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw== @@ -4360,19 +4360,19 @@ marked@^0.8.0: resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.2.tgz#4faad28d26ede351a7a1aaa5fec67915c869e355" integrity sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw== -mathjs@^6.6.1: - version "6.6.5" - resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-6.6.5.tgz#6bbad1fa3ac09e8f7106ef64af8d3908f877b8e8" - integrity sha512-jvRqk7eoEHBcx/lskmy05m+8M7xDHAJcJzRJoqIsqExtlTHPDQO0Zv85g5F0rasDAXF+DLog/70hcqCJijSzPQ== +mathjs@7.5.1: + version "7.5.1" + resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-7.5.1.tgz#eb125295310a99ddcaf6145c47b09aab36e48274" + integrity sha512-H2q/Dq0qxBLMw+G84SSXmGqo/znihuxviGgAQwAcyeFLwK2HksvSGNx4f3dllZF51bWOnu2op60VZxH2Sb51Pw== dependencies: complex.js "^2.0.11" - decimal.js "^10.2.0" + decimal.js "^10.2.1" escape-latex "^1.2.0" fraction.js "^4.0.12" javascript-natural-sort "^0.7.1" seed-random "^2.2.0" tiny-emitter "^2.1.0" - typed-function "^1.1.1" + typed-function "^2.0.0" md5.js@^1.3.4: version "1.3.5" @@ -6185,10 +6185,10 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -typed-function@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-1.1.1.tgz#a1316187ec3628c9e219b91ca96918660a10138e" - integrity sha512-RbN7MaTQBZLJYzDENHPA0nUmWT0Ex80KHItprrgbTPufYhIlTePvCXZxyQK7wgn19FW5bnuaBIKcBb5mRWjB1Q== +typed-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.0.0.tgz#15ab3825845138a8b1113bd89e60cd6a435739e8" + integrity sha512-Hhy1Iwo/e4AtLZNK10ewVVcP2UEs408DS35ubP825w/YgSBK1KVLwALvvIG4yX75QJrxjCpcWkzkVRB0BwwYlA== typedarray-to-buffer@^3.1.5: version "3.1.5"