Skip to content

Commit

Permalink
feat: fix string pad
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Oct 24, 2023
1 parent 12ee84a commit 28e7be5
Show file tree
Hide file tree
Showing 5 changed files with 14,703 additions and 9,017 deletions.
4 changes: 2 additions & 2 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"ahooks": "^3.7.7",
"react": "^18.2.0",
"vconsole": "^3.15.1",
"@portkey/types": "^1.2.2",
"@portkey/did-ui-react": "^1.2.2"
"@portkey/types": "1.3.0-alpha.3",
"@portkey/did-ui-react": "1.3.0-alpha.3"
},
"devDependencies": {
"@craco/craco": "^6.4.2",
Expand Down
13 changes: 7 additions & 6 deletions packages/login/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aelf-web-login",
"version": "1.1.3-alpha",
"version": "1.1.4-alpha",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
Expand Down Expand Up @@ -48,17 +48,18 @@
},
"dependencies": {
"@aelf-react/core": "^0.1.19",
"@portkey/contracts": "^1.3.0-alpha.3",
"@portkey/contracts": "1.3.0-alpha.3",
"@portkey/detect-provider": "1.0.1-alpha.0",
"@portkey/did-ui-react": "^1.3.0-alpha.3",
"@portkey/did-ui-react": "1.3.0-alpha.3",
"@portkey/provider-types": "1.0.1-alpha.0",
"@portkey/services": "^1.3.0-alpha.3",
"@portkey/types": "^1.3.0-alpha.3",
"@portkey/utils": "^1.3.0-alpha.3",
"@portkey/services": "1.3.0-alpha.3",
"@portkey/types": "1.3.0-alpha.3",
"@portkey/utils": "1.3.0-alpha.3",
"aelf-bridge": "^0.0.10",
"aelf-sdk": "^3.2.40",
"ahooks": "^3.7.7",
"antd": "^4.24.4",
"bn.js": "^5.2.1",
"typescript": "^4.9.5"
},
"devDependencies": {
Expand Down
13 changes: 7 additions & 6 deletions packages/login/src/wallets/discover/useDiscover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DiscoverOptions } from 'src/types';
import useChainIdsSync from './useChainIdsSync';
import { ERR_CODE, makeError } from '../../errors';
import wait from '../../utils/waitForSeconds';

import BN from 'bn.js';
export type DiscoverDetectState = 'unknown' | 'detected' | 'not-detected';
export type DiscoverInterface = WalletHookInterface & {
discoverDetected: DiscoverDetectState;
Expand Down Expand Up @@ -263,11 +263,12 @@ export function useDiscover({
data: signInfo || params.hexToBeSign,
},
});
const signedMsgString = [
signedMsgObject.r.toString(16, 64),
signedMsgObject.s.toString(16, 64),
`0${signedMsgObject.recoveryParam!.toString()}`,
].join('');
signedMsgObject.r = '1';
signedMsgObject.s = '2';
const r = BN.isBN(signedMsgObject.r) ? signedMsgObject.r.toString(16, 64) : signedMsgObject.r.padStart(64, '0');
const s = BN.isBN(signedMsgObject.s) ? signedMsgObject.s.toString(16, 64) : signedMsgObject.s.padStart(64, '0');
const signedMsgString = [r, s, `0${signedMsgObject.recoveryParam!.toString()}`].join('');

return {
error: 0,
errorMessage: '',
Expand Down
9 changes: 4 additions & 5 deletions packages/login/src/wallets/elf/useElf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { WalletType, WebLoginState, WebLoginEvents } from '../../constants';
import isMobile from '../../utils/isMobile';
import checkSignatureParams from '../../utils/signatureParams';
import detectNightElf from './detectNightElf';
import BN from 'bn.js';

export function useElf({
options,
Expand Down Expand Up @@ -234,11 +235,9 @@ export function useElf({
signedMsgObject.errorMessage.message || signedMsgObject.errorMessage || signedMsgObject.message,
);
}
const signedMsgString = [
signedMsgObject.r.toString(16, 64),
signedMsgObject.s.toString(16, 64),
`0${signedMsgObject.recoveryParam.toString()}`,
].join('');
const r = BN.isBN(signedMsgObject.r) ? signedMsgObject.r.toString(16, 64) : signedMsgObject.r.padStart(64, '0');
const s = BN.isBN(signedMsgObject.s) ? signedMsgObject.s.toString(16, 64) : signedMsgObject.s.padStart(64, '0');
const signedMsgString = [r, s, `0${signedMsgObject.recoveryParam.toString()}`].join('');
return {
error: 0,
errorMessage: '',
Expand Down
Loading

0 comments on commit 28e7be5

Please sign in to comment.