Skip to content

feat: add get operation key #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@deltadefi-protocol/typescript-sdk",
"description": "The Typescript SDK for interacting with DeltaDeFi protocol",
"version": "0.3.18",
"version": "0.3.19",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
16 changes: 13 additions & 3 deletions src/client/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
GenerateNewAPIKeyResponse,
AccountBalance,
GetAPIKeyResponse,
GetOperationKeyResponse,
} from '../../types';
import { Api } from '../api';

Expand All @@ -40,11 +41,11 @@ export class Accounts extends Api {
/**
* Signs in a user.
* @param data - The sign-in request data.
* @param apiKey - The API key for authentication.
* @returns A promise that resolves to the sign-in response.
*/
public signIn(data: SignInRequest, apiKey: string): Promise<SignInResponse> {
public signIn(data: SignInRequest): Promise<SignInResponse> {
const {
x_api_key,
wallet_address,
encrypted_operation_key,
operation_key_hash,
Expand All @@ -58,11 +59,20 @@ export class Accounts extends Api {
operation_key_hash,
is_script_operation_key,
},
{ headers: { 'X-API-KEY': apiKey } },
{ headers: { 'X-API-KEY': x_api_key } },
);
return this.resolveAxiosData(res);
}

/**
* Retrieves encryption operation key
* @returns A promise that resolves to the operation key response.
*/
public getOperationKey(): Promise<GetOperationKeyResponse> {
const res = this.axiosInstance.get('/accounts/operation-key');
return this.resolveAxiosData(res);
}

/**
* Retrieves deposit records.
* @returns A promise that resolves to the deposit records response.
Expand Down
1 change: 1 addition & 0 deletions src/types/requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TradingSymbol, OrderSide, OrderType } from '../models/order';

// SignInRequest to be refactored
export type SignInRequest = {
x_api_key: string;
wallet_address: string;
encrypted_operation_key?: string;
operation_key_hash?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/types/responses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export type SignInResponse = {
is_first_time: boolean;
};

export type GetOperationKeyResponse = {
encrypted_operation_key: string;
operation_key_hash: string;
};

// export type BuildSendRefScriptsTransactionResponse = {
// tx_hex: string;
// };
Expand Down
5 changes: 4 additions & 1 deletion tests/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('Account APIs', () => {
test('Sign In', async () => {
if (skipApiTests) return;
const api = new ApiClient({ apiKey, network: 'preprod' });
const res = await api.accounts.signIn({ wallet_address }, apiKey);
const res = await api.accounts.signIn({
x_api_key: apiKey,
wallet_address,
});
expect(res.token).not.toBe('');
});
test('Get Orders', async () => {
Expand Down
Loading