Skip to content

Commit 389ad58

Browse files
committed
feat: mainnet config
1 parent df58fde commit 389ad58

File tree

5 files changed

+70
-24
lines changed

5 files changed

+70
-24
lines changed

package-lock.json

Lines changed: 45 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@deltadefi-protocol/sdk",
33
"description": "The Typescript SDK for DeltaDeFi protocol",
4-
"version": "0.3.31",
4+
"version": "1.0.0",
55
"main": "./dist/index.cjs",
66
"browser": "./dist/index.js",
77
"module": "./dist/index.js",

src/client/index.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class ApiClient {
1616

1717
private jwt: string = '';
1818

19-
public networkId: 0 | 1 = 0;
19+
public networkId: 0 | 1 = 1;
2020

2121
public accounts: Accounts;
2222

@@ -39,20 +39,19 @@ export class ApiClient {
3939
providedBaseURL?: string,
4040
providedWsURL?: string,
4141
) {
42-
let baseURL = 'https://api-staging.deltadefi.io';
43-
let wsURL = 'wss://api-staging.deltadefi.io';
42+
let baseURL = 'https://api.deltadefi.io';
43+
let wsURL = 'wss://stream.deltadefi.io';
4444
const headers: ApiHeaders = {
4545
'Content-Type': 'application/json',
4646
};
4747
if (network) {
4848
this.networkId = network === 'mainnet' ? 1 : 0;
4949
if (network === 'mainnet') {
50-
// TODO: input production link once available
5150
baseURL = 'https://api.deltadefi.io';
52-
wsURL = 'wss://api.deltadefi.io';
51+
wsURL = 'wss://stream.deltadefi.io';
5352
} else {
5453
baseURL = 'https://api-staging.deltadefi.io';
55-
wsURL = 'wss://api-staging.deltadefi.io';
54+
wsURL = 'wss://stream-staging.deltadefi.io';
5655
}
5756
}
5857
if (jwt) {
@@ -137,6 +136,22 @@ export class ApiClient {
137136
});
138137
return { message: 'Order cancelled successfully', orderId };
139138
}
139+
140+
/**
141+
* Cancels all open orders.
142+
* @returns A promise that resolves to a message indicating the orders were cancelled successfully.
143+
*/
144+
public async cancelAllOrders() {
145+
if (!this.operationWallet) {
146+
throw new Error('Operation wallet is not initialized');
147+
}
148+
const buildRes = await this.orders.buildCancelAllOrdersTransaction();
149+
const signedTxs = await this.operationWallet.signTxs(buildRes.tx_hexes);
150+
await this.orders.submitCancelAllOrdersTransaction({
151+
signed_txs: signedTxs,
152+
});
153+
return { message: 'All orders cancelled successfully' };
154+
}
140155
}
141156

142157
export { encryptWithCipher, decryptWithCipher } from './components/encryption';

src/types/models/account.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { TransferStatus } from '../requests';
2-
31
export type AccountBalance = {
42
asset: string;
53
asset_unit: string;
@@ -24,6 +22,8 @@ export type AccountBalanceStream = {
2422
balance: AccountBalance[];
2523
};
2624

25+
export type TransferStatus = 'pending' | 'confirmed';
26+
2727
export type TransferalType = 'normal' | 'deposit' | `withdrawal`;
2828

2929
export type TransferDirection = 'incoming' | 'outgoing';

src/types/requests/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UTxO } from '@meshsdk/core';
22
import { TradingSymbol, OrderSide, OrderType } from '../models/order';
3-
import { TransferalType } from '../models/account';
3+
import { TransferalType, TransferStatus } from '../models/account';
44

55
// SignInRequest to be refactored
66
export type SignInRequest = {
@@ -109,8 +109,6 @@ export type GetOrderRecordRequest = {
109109
page?: number; // default number is 1 while number must be between 1 and 1000
110110
};
111111

112-
export type TransferStatus = 'pending' | 'confirmed';
113-
114112
export type GetTransferalRecordsRequest = {
115113
status: TransferStatus; // Must be either 'pending' | 'confirmed'
116114
limit?: number; // default number is 10 while number must be between 1 and 250

0 commit comments

Comments
 (0)