Skip to content

Commit

Permalink
fix(app): wallet key integration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vrockz747 committed Jul 11, 2024
1 parent e857f2c commit aea1723
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/app-inheritance/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
site_name: '@cypherock/sdk-app-tron'
site_name: '@cypherock/sdk-app-inheritance'
34 changes: 25 additions & 9 deletions packages/app-inheritance/src/operations/walletSign/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
import { ISDK } from '@cypherock/sdk-core';
import { createLoggerWithPrefix } from '@cypherock/sdk-utils';
import { APP_VERSION } from '../../constants/appId';
import { GetChallengeResponse } from '../../proto/generated/inheritance/wallet_key';
import { IWalletAuthResultResponse } from '../../proto/generated/types';
import {
assertOrThrowInvalidResult,
OperationHelper,
logger as rootLogger,
} from '../../utils';

const logger = createLoggerWithPrefix(rootLogger, 'GetChallenge');
const logger = createLoggerWithPrefix(rootLogger, 'walletAuthRequest');

export const getWalletSign = async (
sdk: ISDK,
): Promise<GetChallengeResponse> => {
): Promise<IWalletAuthResultResponse> => {
logger.info('Started');

await sdk.checkAppCompatibility(APP_VERSION);

const helper = new OperationHelper({
sdk,
queryKey: 'getChallenge',
resultKey: 'getChallengeResponse',
queryKey: 'walletAuth',
resultKey: 'walletAuth',
});
// TODO: add vars to parameters
await helper.sendQuery({
initiate: {
challenge: new Uint8Array([
144, 213, 122, 213, 228, 193, 104, 222, 201, 19, 75, 27, 117, 55, 36,
46, 163, 239, 183, 51, 61, 251, 171, 30, 87, 72, 90, 53, 41, 121, 48,
132,
]),
walletId: new Uint8Array([
144, 213, 122, 213, 228, 193, 104, 222, 201, 19, 75, 27, 117, 55, 36,
46, 87, 72, 90, 53, 41, 121, 48, 132, 163, 239, 183, 51, 61, 251, 171,
30,
]),
isPublickey: false,
},
});

await helper.sendQuery({ challenge: 'CHALLENGE #XX' });
const result = await helper.waitForResult();
logger.verbose('getChallengeResponse', result);
assertOrThrowInvalidResult(result);
logger.verbose('walletAuthResponse', result);
console.log(JSON.stringify(result));
assertOrThrowInvalidResult(result.result);

logger.info('Completed');
return result;
return result.result;
};
2 changes: 1 addition & 1 deletion packages/app-inheritance/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
updateLoggerObject,
} from '@cypherock/sdk-utils';

export const loggerServiceName = 'sdk-app-tron';
export const loggerServiceName = 'sdk-app-inheritance';

export const logger: ILogger = {
...createDefaultConsoleLogger(loggerServiceName),
Expand Down

0 comments on commit aea1723

Please sign in to comment.