Skip to content

Commit

Permalink
Adding wallet sign in needed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Sep 2, 2022
1 parent cd0c48f commit b92b792
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 1 deletion.
56 changes: 56 additions & 0 deletions src/common/rest/check-challenge-signature/index.ts
@@ -0,0 +1,56 @@
import { MethodMetadata, Parameter } from '..';
import { useMasaMutation, useRestCall } from '../../helpers/rest-calls';

const path = 'session/check-signature';

export function useMethod({ body }: any) {
const { data, error, loading, getData } = useRestCall({
headers: Headers,
metadata,
body,
});

return { data, error, loading, getData };
}

export function useSimpleMethod({ pathParameters, body, settings }: any) {
const masaQuery = useMasaMutation(
'check-challenge-signature',
{
pathParameters,
headers: Headers,
body,
metadata,
},
settings
);
return masaQuery;
}

const parameters: Parameter[] = [
{
key: 1,
name: 'signature',
description: 'Challenge signature',
required: 'yes',
default: '',
dataType: 'string',
},
{
key: 2,
name: 'address',
description: 'User address',
required: 'yes',
default: '',
dataType: 'string',
},
];

export const metadata: MethodMetadata = {
author: 'Hide on bush',
authorPicture: '',
description: 'Send signed challenge to backend for authentication',
name: path,
method: 'POST',
parameters: parameters,
};
36 changes: 36 additions & 0 deletions src/common/rest/get-challenge/index.ts
@@ -0,0 +1,36 @@
import { MethodMetadata } from '..';
import { Headers } from '../../helpers/axios';
import { useMasaQuery, useRestCall } from '../../helpers/rest-calls';

const path = 'session/get-challenge';

export function useMethod() {
const { data, error, loading, getData } = useRestCall({
headers: Headers,
metadata,
});
return { data, error, loading, getData };
}

export function useSimpleMethod({ pathParameters, body, settings }: any) {
const masaQuery = useMasaQuery(
'get-challenge',
{
pathParameters,
headers: Headers,
body,
metadata,
},
settings
);
return masaQuery;
}

export const metadata: MethodMetadata = {
author: 'Hide on bush',
authorPicture: '',
description: 'Get challenge',
name: path,
method: 'GET',
parameters: [],
};
36 changes: 36 additions & 0 deletions src/common/rest/get-session/index.ts
@@ -0,0 +1,36 @@
import { MethodMetadata } from '..';
import { Headers } from '../../helpers/axios';
import { useMasaQuery, useRestCall } from '../../helpers/rest-calls';

const path = 'session/check';

export function useMethod() {
const { data, error, loading, getData } = useRestCall({
headers: Headers,
metadata,
});
return { data, error, loading, getData };
}

export function useSimpleMethod({ pathParameters, body, settings }: any) {
const masaQuery = useMasaQuery(
'get-session',
{
pathParameters,
headers: Headers,
body,
metadata,
},
settings
);
return masaQuery;
}

export const metadata: MethodMetadata = {
author: 'Hide on bush',
authorPicture: '',
description: 'Get session',
name: path,
method: 'GET',
parameters: [],
};
10 changes: 9 additions & 1 deletion src/common/rest/index.ts
Expand Up @@ -12,7 +12,6 @@ import * as contractsMint from './contracts-mint';
import * as mintCreditScore from './mint-credit-score';
import * as getCreditScore from './get-credit-score';


import * as getVezgoLink from './vezgo/get-link';
import * as listVezgoProviders from './vezgo/list-providers';
import * as listVezgoAccounts from './vezgo/list-accounts';
Expand All @@ -36,6 +35,11 @@ import * as balances from './balances';

import * as getIdentity from './get-identity';

import * as getChallenge from './get-challenge';
import * as getSession from './get-session';
import * as checkSignatureChallenge from './check-challenge-signature';
import * as sessionLogout from './session-logout';

export interface Parameter {
key: number;
name: string;
Expand Down Expand Up @@ -84,4 +88,8 @@ export const masaRestClient = {
getNodeOperators,
postNodeOperators,
getIdentity,
getChallenge,
checkSignatureChallenge,
getSession,
sessionLogout,
};
39 changes: 39 additions & 0 deletions src/common/rest/session-logout/index.ts
@@ -0,0 +1,39 @@
import { MethodMetadata, Parameter } from '..';
import { useMasaMutation, useRestCall } from '../../helpers/rest-calls';

const path = 'session/logout';

export function useMethod({ body }: any) {
const { data, error, loading, getData } = useRestCall({
headers: Headers,
metadata,
body,
});

return { data, error, loading, getData };
}

export function useSimpleMethod({ pathParameters, body, settings }: any) {
const masaQuery = useMasaMutation(
'logout',
{
pathParameters,
headers: Headers,
body,
metadata,
},
settings
);
return masaQuery;
}

const parameters: Parameter[] = [];

export const metadata: MethodMetadata = {
author: 'Hide on bush',
authorPicture: '',
description: 'Logout and remove user sesison from backend',
name: path,
method: 'POST',
parameters: parameters,
};

0 comments on commit b92b792

Please sign in to comment.