Skip to content

Commit

Permalink
[EXC-1679] add support for colocation on sui ts client (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
NidaKarimAli authored Sep 15, 2023
1 parent cc4c3ef commit 45dd1bd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bluefin-exchange/bluefin-v2-client",
"version": "2.2.0",
"version": "2.3.0",
"description": "The Bluefin client Library allows traders to sign, create, retrieve and listen to orders on Bluefin Exchange.",
"main": "dist/index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions src/bluefinClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export class BluefinClient {
else if (userOnboarding) {
await this.userOnBoarding();
}

if (this.network.UUID) {
this.setUUID(this.network.UUID);
}
};

initializeWithHook = async (
Expand All @@ -203,6 +207,12 @@ export class BluefinClient {
}
};

/***
* Set UUID to api headers for colocation partners
*/
setUUID = (uuid: string) => {
this.apiService.setUUID(uuid);
};
/**
* @description
* initializes web3 and wallet with the given account private key
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const Networks = {
webSocketURL: "wss://notifications.api.sui-staging.bluefin.io",
onboardingUrl: "https://testnet.bluefin.io",
faucet: "https://faucet.devnet.sui.io",
UUID: "",
},
PRODUCTION_SUI: {
name: "production",
Expand All @@ -20,6 +21,7 @@ export const Networks = {
webSocketURL: "wss://notifications.api.sui-prod.bluefin.io",
onboardingUrl: "https://trade-sui.bluefin.exchange",
faucet: "does not exist",
UUID: "",
},
};

Expand Down
10 changes: 10 additions & 0 deletions src/exchange/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class APIService {

private baseUrl: string | undefined = undefined;

private uuid: string = "";

constructor(url: string) {
this.baseUrl = url;
this.apiService = axios.create({
Expand Down Expand Up @@ -116,6 +118,10 @@ export class APIService {
this.token = token;
};

setUUID = async (uuid: string) => {
this.uuid = uuid;
};

setApiToken = async (apiToken: string) => {
this.apiToken = apiToken;
};
Expand All @@ -133,6 +139,10 @@ export class APIService {
} else {
headers.Authorization = `Bearer ${this.token}`;
}
if (this.uuid) {
headers["x-mm-id"] = this.uuid;
}

headers["x-wallet-address"] = this.walletAddress || "";
return JSON.stringify(data);
};
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Sockets {
async listen(event: string, callback: Function): Promise<void> {
this.callbacks[event] = callback;
}

setApiToken = async (apiToken: string) => {
this.apiToken = apiToken;
};
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ export interface ExtendedNetwork extends NetworkConfigs {
onboardingUrl?: string;
webSocketURL: string;
dmsURL?: string;
UUID?: string;
}

export interface ConfigResponse {
Expand Down

0 comments on commit 45dd1bd

Please sign in to comment.